From 8a47cbd8e8ecbe1f9e0372529b621b66718ff374 Mon Sep 17 00:00:00 2001 From: Jingtao Ren Date: Fri, 7 Jul 2017 13:39:55 -0700 Subject: [PATCH] add validate tag for the purpose of required field (#886) * add validate tag for the purpose of required field * import gopkg.in/go-playground/validator.v9 * apply gopkg.in/go-playground/validator.v9 for 2017-07-01 api model * add handler for validation errors --- glide.lock | 16 +- glide.yaml | 4 + pkg/api/v20170701/types.go | 51 +- pkg/api/v20170701/validate.go | 153 +- .../Azure/azure-sdk-for-go/.travis.yml | 2 + .../Azure/azure-sdk-for-go/Gododir/gen.go | 30 +- .../azure-sdk-for-go/arm/advisor/version.go | 4 +- .../arm/analysisservices/version.go | 4 +- .../arm/apimanagement/version.go | 4 +- .../arm/appinsights/version.go | 4 +- .../arm/authorization/version.go | 4 +- .../arm/automation/version.go | 4 +- .../azure-sdk-for-go/arm/batch/version.go | 4 +- .../azure-sdk-for-go/arm/billing/version.go | 4 +- .../Azure/azure-sdk-for-go/arm/cdn/version.go | 4 +- .../arm/cognitiveservices/version.go | 4 +- .../azure-sdk-for-go/arm/commerce/version.go | 4 +- .../azure-sdk-for-go/arm/compute/version.go | 4 +- .../arm/consumption/version.go | 4 +- .../arm/containerregistry/version.go | 4 +- .../arm/containerservice/version.go | 4 +- .../arm/customer-insights/version.go | 4 +- .../arm/datalake-analytics/account/version.go | 4 +- .../arm/datalake-store/account/version.go | 4 +- .../arm/devtestlabs/version.go | 4 +- .../azure-sdk-for-go/arm/disk/version.go | 4 +- .../Azure/azure-sdk-for-go/arm/dns/version.go | 4 +- .../arm/documentdb/version.go | 4 +- .../azure-sdk-for-go/arm/eventhub/version.go | 4 +- .../arm/examples/check/check.go | 2 +- .../arm/examples/create/create.go | 8 +- .../arm/examples/dns/README.md | 34 + .../arm/examples/dns/create.go | 194 + .../arm/examples/dns/paging/paging.go | 201 + .../arm/examples/helpers/helpers.go | 8 +- .../azure-sdk-for-go/arm/graphrbac/version.go | 4 +- .../azure-sdk-for-go/arm/hdinsight/version.go | 4 +- .../azure-sdk-for-go/arm/insights/version.go | 4 +- .../azure-sdk-for-go/arm/intune/version.go | 4 +- .../azure-sdk-for-go/arm/iothub/version.go | 4 +- .../azure-sdk-for-go/arm/keyvault/version.go | 4 +- .../azure-sdk-for-go/arm/logic/version.go | 4 +- .../commitmentplans/version.go | 4 +- .../machinelearning/webservices/version.go | 4 +- .../arm/mediaservices/version.go | 4 +- .../arm/mobileengagement/version.go | 4 +- .../azure-sdk-for-go/arm/monitor/version.go | 4 +- .../azure-sdk-for-go/arm/network/version.go | 4 +- .../arm/notificationhubs/version.go | 4 +- .../arm/operationalinsights/version.go | 4 +- .../arm/powerbiembedded/version.go | 4 +- .../arm/recoveryservices/version.go | 4 +- .../arm/recoveryservicesbackup/version.go | 4 +- .../recoveryservicessiterecovery/client.go | 56 + .../recoveryservicessiterecovery/models.go | 2832 +++++++ .../operations.go | 170 + .../recoverypoints.go | 247 + .../replicationalertsettings.go | 307 + .../replicationevents.go | 237 + .../replicationfabrics.go | 741 ++ .../replicationjobs.go | 577 ++ .../replicationlogicalnetworks.go | 242 + .../replicationnetworkmappings.go | 636 ++ .../replicationnetworks.go | 374 + .../replicationpolicies.go | 487 ++ .../replicationprotectableitems.go | 245 + .../replicationprotecteditems.go | 1536 ++++ .../replicationprotectioncontainermappings.go | 639 ++ .../replicationprotectioncontainers.go | 717 ++ .../replicationrecoveryplans.go | 1044 +++ .../replicationrecoveryservicesproviders.go | 626 ++ ...eplicationstorageclassificationmappings.go | 552 ++ .../replicationstorageclassifications.go | 376 + .../replicationvcenters.go | 628 ++ .../recoveryservicessiterecovery/version.go | 28 + .../azure-sdk-for-go/arm/redis/version.go | 4 +- .../azure-sdk-for-go/arm/relay/version.go | 4 +- .../arm/resourcehealth/version.go | 4 +- .../arm/resources/features/version.go | 4 +- .../arm/resources/links/version.go | 4 +- .../arm/resources/locks/version.go | 4 +- .../appliancedefinitions.go | 720 ++ .../managedapplications/appliances.go | 1008 +++ .../resources/managedapplications/client.go | 53 + .../resources/managedapplications/models.go | 275 + .../resources/managedapplications/version.go | 29 + .../arm/resources/policy/version.go | 4 +- .../arm/resources/resources/version.go | 4 +- .../arm/resources/subscriptions/version.go | 4 +- .../azure-sdk-for-go/arm/scheduler/version.go | 4 +- .../azure-sdk-for-go/arm/search/version.go | 4 +- .../arm/servermanagement/version.go | 4 +- .../arm/service-map/version.go | 4 +- .../arm/servicebus/version.go | 4 +- .../arm/servicefabric/version.go | 4 +- .../Azure/azure-sdk-for-go/arm/sql/version.go | 4 +- .../azure-sdk-for-go/arm/storage/version.go | 4 +- .../arm/storageimportexport/version.go | 4 +- .../accesscontrolrecords.go | 385 + .../arm/storsimple8000series/alerts.go | 341 + .../storsimple8000series/backuppolicies.go | 487 ++ .../arm/storsimple8000series/backups.go | 489 ++ .../storsimple8000series/backupschedules.go | 400 + .../storsimple8000series/bandwidthsettings.go | 384 + .../arm/storsimple8000series/client.go | 53 + .../storsimple8000series/cloudappliances.go | 214 + .../arm/storsimple8000series/devices.go | 1304 +++ .../storsimple8000series/devicesettings.go | 832 ++ .../hardwarecomponentgroups.go | 219 + .../arm/storsimple8000series/jobs.go | 504 ++ .../arm/storsimple8000series/managers.go | 1354 ++++ .../arm/storsimple8000series/models.go | 1954 +++++ .../arm/storsimple8000series/operations.go | 169 + .../storageaccountcredentials.go | 389 + .../arm/storsimple8000series/version.go | 29 + .../storsimple8000series/volumecontainers.go | 548 ++ .../arm/storsimple8000series/volumes.go | 626 ++ .../arm/streamanalytics/client.go | 53 + .../arm/streamanalytics/functions.go | 670 ++ .../arm/streamanalytics/inputs.go | 588 ++ .../arm/streamanalytics/models.go | 806 ++ .../arm/streamanalytics/operations.go | 167 + .../arm/streamanalytics/outputs.go | 588 ++ .../arm/streamanalytics/streamingjobs.go | 842 ++ .../arm/streamanalytics/subscriptions.go | 109 + .../arm/streamanalytics/transformations.go | 284 + .../arm/streamanalytics/version.go | 29 + .../arm/trafficmanager/version.go | 4 +- .../Azure/azure-sdk-for-go/arm/web/version.go | 4 +- .../Azure/azure-sdk-for-go/buildTerraform.sh | 36 + .../datalake-store/filesystem/version.go | 4 +- .../dataplane/keyvault/version.go | 4 +- .../Azure/azure-sdk-for-go/glide.lock | 21 +- .../Azure/azure-sdk-for-go/glide.yaml | 2 +- .../azure-sdk-for-go/management/version.go | 2 +- .../Azure/azure-sdk-for-go/storage/blob.go | 24 +- .../azure-sdk-for-go/storage/blob_test.go | 7 +- .../azure-sdk-for-go/storage/blockblob.go | 19 +- .../Azure/azure-sdk-for-go/storage/client.go | 14 +- .../StorageBlobSuite/TestGetBlobRange.yaml | 137 +- .../go-autorest/autorest/retriablerequest.go | 77 + .../Azure/go-autorest/autorest/sender.go | 32 +- .../go-playground/locales/.gitignore | 24 + .../github.com/go-playground/locales/LICENSE | 21 + .../go-playground/locales/README.md | 172 + .../github.com/go-playground/locales/af/af.go | 613 ++ .../go-playground/locales/af/af_test.go | 1120 +++ .../go-playground/locales/af_NA/af_NA.go | 600 ++ .../go-playground/locales/af_NA/af_NA_test.go | 1120 +++ .../go-playground/locales/af_ZA/af_ZA.go | 613 ++ .../go-playground/locales/af_ZA/af_ZA_test.go | 1120 +++ .../go-playground/locales/agq/agq.go | 563 ++ .../go-playground/locales/agq/agq_test.go | 1120 +++ .../go-playground/locales/agq_CM/agq_CM.go | 563 ++ .../locales/agq_CM/agq_CM_test.go | 1120 +++ .../github.com/go-playground/locales/ak/ak.go | 563 ++ .../go-playground/locales/ak/ak_test.go | 1120 +++ .../go-playground/locales/ak_GH/ak_GH.go | 563 ++ .../go-playground/locales/ak_GH/ak_GH_test.go | 1120 +++ .../github.com/go-playground/locales/am/am.go | 643 ++ .../go-playground/locales/am/am_test.go | 1120 +++ .../go-playground/locales/am_ET/am_ET.go | 643 ++ .../go-playground/locales/am_ET/am_ET_test.go | 1120 +++ .../github.com/go-playground/locales/ar/ar.go | 712 ++ .../go-playground/locales/ar/ar_test.go | 1120 +++ .../go-playground/locales/ar_001/ar_001.go | 712 ++ .../locales/ar_001/ar_001_test.go | 1120 +++ .../go-playground/locales/ar_AE/ar_AE.go | 712 ++ .../go-playground/locales/ar_AE/ar_AE_test.go | 1120 +++ .../go-playground/locales/ar_BH/ar_BH.go | 712 ++ .../go-playground/locales/ar_BH/ar_BH_test.go | 1120 +++ .../go-playground/locales/ar_DJ/ar_DJ.go | 712 ++ .../go-playground/locales/ar_DJ/ar_DJ_test.go | 1120 +++ .../go-playground/locales/ar_DZ/ar_DZ.go | 698 ++ .../go-playground/locales/ar_DZ/ar_DZ_test.go | 1120 +++ .../go-playground/locales/ar_EG/ar_EG.go | 712 ++ .../go-playground/locales/ar_EG/ar_EG_test.go | 1120 +++ .../go-playground/locales/ar_EH/ar_EH.go | 712 ++ .../go-playground/locales/ar_EH/ar_EH_test.go | 1120 +++ .../go-playground/locales/ar_ER/ar_ER.go | 712 ++ .../go-playground/locales/ar_ER/ar_ER_test.go | 1120 +++ .../go-playground/locales/ar_IL/ar_IL.go | 658 ++ .../go-playground/locales/ar_IL/ar_IL_test.go | 1120 +++ .../go-playground/locales/ar_IQ/ar_IQ.go | 712 ++ .../go-playground/locales/ar_IQ/ar_IQ_test.go | 1120 +++ .../go-playground/locales/ar_JO/ar_JO.go | 712 ++ .../go-playground/locales/ar_JO/ar_JO_test.go | 1120 +++ .../go-playground/locales/ar_KM/ar_KM.go | 674 ++ .../go-playground/locales/ar_KM/ar_KM_test.go | 1120 +++ .../go-playground/locales/ar_KW/ar_KW.go | 712 ++ .../go-playground/locales/ar_KW/ar_KW_test.go | 1120 +++ .../go-playground/locales/ar_LB/ar_LB.go | 698 ++ .../go-playground/locales/ar_LB/ar_LB_test.go | 1120 +++ .../go-playground/locales/ar_LY/ar_LY.go | 698 ++ .../go-playground/locales/ar_LY/ar_LY_test.go | 1120 +++ .../go-playground/locales/ar_MA/ar_MA.go | 660 ++ .../go-playground/locales/ar_MA/ar_MA_test.go | 1120 +++ .../go-playground/locales/ar_MR/ar_MR.go | 698 ++ .../go-playground/locales/ar_MR/ar_MR_test.go | 1120 +++ .../go-playground/locales/ar_OM/ar_OM.go | 712 ++ .../go-playground/locales/ar_OM/ar_OM_test.go | 1120 +++ .../go-playground/locales/ar_PS/ar_PS.go | 712 ++ .../go-playground/locales/ar_PS/ar_PS_test.go | 1120 +++ .../go-playground/locales/ar_QA/ar_QA.go | 712 ++ .../go-playground/locales/ar_QA/ar_QA_test.go | 1120 +++ .../go-playground/locales/ar_SA/ar_SA.go | 712 ++ .../go-playground/locales/ar_SA/ar_SA_test.go | 1120 +++ .../go-playground/locales/ar_SD/ar_SD.go | 712 ++ .../go-playground/locales/ar_SD/ar_SD_test.go | 1120 +++ .../go-playground/locales/ar_SO/ar_SO.go | 712 ++ .../go-playground/locales/ar_SO/ar_SO_test.go | 1120 +++ .../go-playground/locales/ar_SS/ar_SS.go | 712 ++ .../go-playground/locales/ar_SS/ar_SS_test.go | 1120 +++ .../go-playground/locales/ar_SY/ar_SY.go | 712 ++ .../go-playground/locales/ar_SY/ar_SY_test.go | 1120 +++ .../go-playground/locales/ar_TD/ar_TD.go | 712 ++ .../go-playground/locales/ar_TD/ar_TD_test.go | 1120 +++ .../go-playground/locales/ar_TN/ar_TN.go | 698 ++ .../go-playground/locales/ar_TN/ar_TN_test.go | 1120 +++ .../go-playground/locales/ar_YE/ar_YE.go | 712 ++ .../go-playground/locales/ar_YE/ar_YE_test.go | 1120 +++ .../github.com/go-playground/locales/as/as.go | 667 ++ .../go-playground/locales/as/as_test.go | 1120 +++ .../go-playground/locales/as_IN/as_IN.go | 667 ++ .../go-playground/locales/as_IN/as_IN_test.go | 1120 +++ .../go-playground/locales/asa/asa.go | 520 ++ .../go-playground/locales/asa/asa_test.go | 1120 +++ .../go-playground/locales/asa_TZ/asa_TZ.go | 520 ++ .../locales/asa_TZ/asa_TZ_test.go | 1120 +++ .../go-playground/locales/ast/ast.go | 581 ++ .../go-playground/locales/ast/ast_test.go | 1120 +++ .../go-playground/locales/ast_ES/ast_ES.go | 581 ++ .../locales/ast_ES/ast_ES_test.go | 1120 +++ .../github.com/go-playground/locales/az/az.go | 628 ++ .../go-playground/locales/az/az_test.go | 1120 +++ .../go-playground/locales/az_Cyrl/az_Cyrl.go | 628 ++ .../locales/az_Cyrl/az_Cyrl_test.go | 1120 +++ .../locales/az_Cyrl_AZ/az_Cyrl_AZ.go | 628 ++ .../locales/az_Cyrl_AZ/az_Cyrl_AZ_test.go | 1120 +++ .../go-playground/locales/az_Latn/az_Latn.go | 628 ++ .../locales/az_Latn/az_Latn_test.go | 1120 +++ .../locales/az_Latn_AZ/az_Latn_AZ.go | 628 ++ .../locales/az_Latn_AZ/az_Latn_AZ_test.go | 1120 +++ .../go-playground/locales/bas/bas.go | 575 ++ .../go-playground/locales/bas/bas_test.go | 1120 +++ .../go-playground/locales/bas_CM/bas_CM.go | 575 ++ .../locales/bas_CM/bas_CM_test.go | 1120 +++ .../github.com/go-playground/locales/be/be.go | 658 ++ .../go-playground/locales/be/be_test.go | 1120 +++ .../go-playground/locales/be_BY/be_BY.go | 658 ++ .../go-playground/locales/be_BY/be_BY_test.go | 1120 +++ .../go-playground/locales/bem/bem.go | 561 ++ .../go-playground/locales/bem/bem_test.go | 1120 +++ .../go-playground/locales/bem_ZM/bem_ZM.go | 561 ++ .../locales/bem_ZM/bem_ZM_test.go | 1120 +++ .../go-playground/locales/bez/bez.go | 512 ++ .../go-playground/locales/bez/bez_test.go | 1120 +++ .../go-playground/locales/bez_TZ/bez_TZ.go | 512 ++ .../locales/bez_TZ/bez_TZ_test.go | 1120 +++ .../github.com/go-playground/locales/bg/bg.go | 568 ++ .../go-playground/locales/bg/bg_test.go | 1120 +++ .../go-playground/locales/bg_BG/bg_BG.go | 568 ++ .../go-playground/locales/bg_BG/bg_BG_test.go | 1120 +++ .../github.com/go-playground/locales/bm/bm.go | 506 ++ .../go-playground/locales/bm/bm_test.go | 1120 +++ .../go-playground/locales/bm_ML/bm_ML.go | 506 ++ .../go-playground/locales/bm_ML/bm_ML_test.go | 1120 +++ .../github.com/go-playground/locales/bn/bn.go | 658 ++ .../go-playground/locales/bn/bn_test.go | 1120 +++ .../go-playground/locales/bn_BD/bn_BD.go | 658 ++ .../go-playground/locales/bn_BD/bn_BD_test.go | 1120 +++ .../go-playground/locales/bn_IN/bn_IN.go | 658 ++ .../go-playground/locales/bn_IN/bn_IN_test.go | 1120 +++ .../github.com/go-playground/locales/bo/bo.go | 628 ++ .../go-playground/locales/bo/bo_test.go | 1120 +++ .../go-playground/locales/bo_CN/bo_CN.go | 628 ++ .../go-playground/locales/bo_CN/bo_CN_test.go | 1120 +++ .../go-playground/locales/bo_IN/bo_IN.go | 628 ++ .../go-playground/locales/bo_IN/bo_IN_test.go | 1120 +++ .../github.com/go-playground/locales/br/br.go | 608 ++ .../go-playground/locales/br/br_test.go | 1120 +++ .../go-playground/locales/br_FR/br_FR.go | 608 ++ .../go-playground/locales/br_FR/br_FR_test.go | 1120 +++ .../go-playground/locales/brx/brx.go | 653 ++ .../go-playground/locales/brx/brx_test.go | 1120 +++ .../go-playground/locales/brx_IN/brx_IN.go | 653 ++ .../locales/brx_IN/brx_IN_test.go | 1120 +++ .../github.com/go-playground/locales/bs/bs.go | 621 ++ .../go-playground/locales/bs/bs_test.go | 1120 +++ .../go-playground/locales/bs_Cyrl/bs_Cyrl.go | 636 ++ .../locales/bs_Cyrl/bs_Cyrl_test.go | 1120 +++ .../locales/bs_Cyrl_BA/bs_Cyrl_BA.go | 621 ++ .../locales/bs_Cyrl_BA/bs_Cyrl_BA_test.go | 1120 +++ .../go-playground/locales/bs_Latn/bs_Latn.go | 621 ++ .../locales/bs_Latn/bs_Latn_test.go | 1120 +++ .../locales/bs_Latn_BA/bs_Latn_BA.go | 621 ++ .../locales/bs_Latn_BA/bs_Latn_BA_test.go | 1120 +++ .../github.com/go-playground/locales/ca/ca.go | 578 ++ .../go-playground/locales/ca/ca_test.go | 1120 +++ .../go-playground/locales/ca_AD/ca_AD.go | 578 ++ .../go-playground/locales/ca_AD/ca_AD_test.go | 1120 +++ .../go-playground/locales/ca_ES/ca_ES.go | 578 ++ .../go-playground/locales/ca_ES/ca_ES_test.go | 1120 +++ .../locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go | 578 ++ .../ca_ES_VALENCIA/ca_ES_VALENCIA_test.go | 1120 +++ .../go-playground/locales/ca_FR/ca_FR.go | 578 ++ .../go-playground/locales/ca_FR/ca_FR_test.go | 1120 +++ .../go-playground/locales/ca_IT/ca_IT.go | 578 ++ .../go-playground/locales/ca_IT/ca_IT_test.go | 1120 +++ .../github.com/go-playground/locales/ce/ce.go | 439 + .../go-playground/locales/ce/ce_test.go | 1120 +++ .../go-playground/locales/ce_RU/ce_RU.go | 439 + .../go-playground/locales/ce_RU/ce_RU_test.go | 1120 +++ .../go-playground/locales/cgg/cgg.go | 515 ++ .../go-playground/locales/cgg/cgg_test.go | 1120 +++ .../go-playground/locales/cgg_UG/cgg_UG.go | 515 ++ .../locales/cgg_UG/cgg_UG_test.go | 1120 +++ .../go-playground/locales/chr/chr.go | 621 ++ .../go-playground/locales/chr/chr_test.go | 1120 +++ .../go-playground/locales/chr_US/chr_US.go | 621 ++ .../locales/chr_US/chr_US_test.go | 1120 +++ .../go-playground/locales/ckb/ckb.go | 644 ++ .../go-playground/locales/ckb/ckb_test.go | 1120 +++ .../go-playground/locales/ckb_IQ/ckb_IQ.go | 644 ++ .../locales/ckb_IQ/ckb_IQ_test.go | 1120 +++ .../go-playground/locales/ckb_IR/ckb_IR.go | 606 ++ .../locales/ckb_IR/ckb_IR_test.go | 1120 +++ .../go-playground/locales/cmd/README.md | 6 + .../go-playground/locales/cmd/currency.tmpl | 11 + .../go-playground/locales/cmd/data/.gitignore | 4 + .../locales/cmd/generate_resources.go | 2886 +++++++ .../go-playground/locales/cmd/locale_map.tmpl | 34 + .../go-playground/locales/cmd/tests.tmpl | 1123 +++ .../go-playground/locales/cmd/translator.tmpl | 950 +++ .../github.com/go-playground/locales/cs/cs.go | 620 ++ .../go-playground/locales/cs/cs_test.go | 1120 +++ .../go-playground/locales/cs_CZ/cs_CZ.go | 620 ++ .../go-playground/locales/cs_CZ/cs_CZ_test.go | 1120 +++ .../github.com/go-playground/locales/cu/cu.go | 594 ++ .../go-playground/locales/cu/cu_test.go | 1120 +++ .../go-playground/locales/cu_RU/cu_RU.go | 594 ++ .../go-playground/locales/cu_RU/cu_RU_test.go | 1120 +++ .../locales/currency/currency.go | 306 + .../github.com/go-playground/locales/cy/cy.go | 661 ++ .../go-playground/locales/cy/cy_test.go | 1120 +++ .../go-playground/locales/cy_GB/cy_GB.go | 661 ++ .../go-playground/locales/cy_GB/cy_GB_test.go | 1120 +++ .../github.com/go-playground/locales/da/da.go | 608 ++ .../go-playground/locales/da/da_test.go | 1120 +++ .../go-playground/locales/da_DK/da_DK.go | 608 ++ .../go-playground/locales/da_DK/da_DK_test.go | 1120 +++ .../go-playground/locales/da_GL/da_GL.go | 646 ++ .../go-playground/locales/da_GL/da_GL_test.go | 1120 +++ .../go-playground/locales/dav/dav.go | 518 ++ .../go-playground/locales/dav/dav_test.go | 1120 +++ .../go-playground/locales/dav_KE/dav_KE.go | 518 ++ .../locales/dav_KE/dav_KE_test.go | 1120 +++ .../github.com/go-playground/locales/de/de.go | 614 ++ .../go-playground/locales/de/de_test.go | 1120 +++ .../go-playground/locales/de_AT/de_AT.go | 633 ++ .../go-playground/locales/de_AT/de_AT_test.go | 1120 +++ .../go-playground/locales/de_BE/de_BE.go | 614 ++ .../go-playground/locales/de_BE/de_BE_test.go | 1120 +++ .../go-playground/locales/de_CH/de_CH.go | 623 ++ .../go-playground/locales/de_CH/de_CH_test.go | 1120 +++ .../go-playground/locales/de_DE/de_DE.go | 614 ++ .../go-playground/locales/de_DE/de_DE_test.go | 1120 +++ .../go-playground/locales/de_IT/de_IT.go | 614 ++ .../go-playground/locales/de_IT/de_IT_test.go | 1120 +++ .../go-playground/locales/de_LI/de_LI.go | 623 ++ .../go-playground/locales/de_LI/de_LI_test.go | 1120 +++ .../go-playground/locales/de_LU/de_LU.go | 614 ++ .../go-playground/locales/de_LU/de_LU_test.go | 1120 +++ .../go-playground/locales/dje/dje.go | 563 ++ .../go-playground/locales/dje/dje_test.go | 1120 +++ .../go-playground/locales/dje_NE/dje_NE.go | 563 ++ .../locales/dje_NE/dje_NE_test.go | 1120 +++ .../go-playground/locales/dsb/dsb.go | 574 ++ .../go-playground/locales/dsb/dsb_test.go | 1120 +++ .../go-playground/locales/dsb_DE/dsb_DE.go | 574 ++ .../locales/dsb_DE/dsb_DE_test.go | 1120 +++ .../go-playground/locales/dua/dua.go | 575 ++ .../go-playground/locales/dua/dua_test.go | 1120 +++ .../go-playground/locales/dua_CM/dua_CM.go | 575 ++ .../locales/dua_CM/dua_CM_test.go | 1120 +++ .../go-playground/locales/dyo/dyo.go | 569 ++ .../go-playground/locales/dyo/dyo_test.go | 1120 +++ .../go-playground/locales/dyo_SN/dyo_SN.go | 569 ++ .../locales/dyo_SN/dyo_SN_test.go | 1120 +++ .../github.com/go-playground/locales/dz/dz.go | 676 ++ .../go-playground/locales/dz/dz_test.go | 1120 +++ .../go-playground/locales/dz_BT/dz_BT.go | 676 ++ .../go-playground/locales/dz_BT/dz_BT_test.go | 1120 +++ .../go-playground/locales/ebu/ebu.go | 518 ++ .../go-playground/locales/ebu/ebu_test.go | 1120 +++ .../go-playground/locales/ebu_KE/ebu_KE.go | 518 ++ .../locales/ebu_KE/ebu_KE_test.go | 1120 +++ .../github.com/go-playground/locales/ee/ee.go | 564 ++ .../go-playground/locales/ee/ee_test.go | 1120 +++ .../go-playground/locales/ee_GH/ee_GH.go | 564 ++ .../go-playground/locales/ee_GH/ee_GH_test.go | 1120 +++ .../go-playground/locales/ee_TG/ee_TG.go | 520 ++ .../go-playground/locales/ee_TG/ee_TG_test.go | 1120 +++ .../github.com/go-playground/locales/el/el.go | 629 ++ .../go-playground/locales/el/el_test.go | 1120 +++ .../go-playground/locales/el_CY/el_CY.go | 629 ++ .../go-playground/locales/el_CY/el_CY_test.go | 1120 +++ .../go-playground/locales/el_GR/el_GR.go | 629 ++ .../go-playground/locales/el_GR/el_GR_test.go | 1120 +++ .../locales/en/benchmarks_test.go | 252 + .../github.com/go-playground/locales/en/en.go | 635 ++ .../go-playground/locales/en/en_test.go | 1120 +++ .../go-playground/locales/en_001/en_001.go | 645 ++ .../locales/en_001/en_001_test.go | 1120 +++ .../go-playground/locales/en_150/en_150.go | 592 ++ .../locales/en_150/en_150_test.go | 1120 +++ .../go-playground/locales/en_AG/en_AG.go | 645 ++ .../go-playground/locales/en_AG/en_AG_test.go | 1120 +++ .../go-playground/locales/en_AI/en_AI.go | 607 ++ .../go-playground/locales/en_AI/en_AI_test.go | 1120 +++ .../go-playground/locales/en_AS/en_AS.go | 635 ++ .../go-playground/locales/en_AS/en_AS_test.go | 1120 +++ .../go-playground/locales/en_AT/en_AT.go | 647 ++ .../go-playground/locales/en_AT/en_AT_test.go | 1120 +++ .../go-playground/locales/en_AU/en_AU.go | 597 ++ .../go-playground/locales/en_AU/en_AU_test.go | 1120 +++ .../go-playground/locales/en_BB/en_BB.go | 645 ++ .../go-playground/locales/en_BB/en_BB_test.go | 1120 +++ .../go-playground/locales/en_BE/en_BE.go | 606 ++ .../go-playground/locales/en_BE/en_BE_test.go | 1120 +++ .../go-playground/locales/en_BI/en_BI.go | 635 ++ .../go-playground/locales/en_BI/en_BI_test.go | 1120 +++ .../go-playground/locales/en_BM/en_BM.go | 645 ++ .../go-playground/locales/en_BM/en_BM_test.go | 1120 +++ .../go-playground/locales/en_BS/en_BS.go | 645 ++ .../go-playground/locales/en_BS/en_BS_test.go | 1120 +++ .../go-playground/locales/en_BW/en_BW.go | 620 ++ .../go-playground/locales/en_BW/en_BW_test.go | 1120 +++ .../go-playground/locales/en_BZ/en_BZ.go | 620 ++ .../go-playground/locales/en_BZ/en_BZ_test.go | 1120 +++ .../go-playground/locales/en_CA/en_CA.go | 646 ++ .../go-playground/locales/en_CA/en_CA_test.go | 1120 +++ .../go-playground/locales/en_CC/en_CC.go | 607 ++ .../go-playground/locales/en_CC/en_CC_test.go | 1120 +++ .../go-playground/locales/en_CH/en_CH.go | 639 ++ .../go-playground/locales/en_CH/en_CH_test.go | 1120 +++ .../go-playground/locales/en_CK/en_CK.go | 607 ++ .../go-playground/locales/en_CK/en_CK_test.go | 1120 +++ .../go-playground/locales/en_CM/en_CM.go | 607 ++ .../go-playground/locales/en_CM/en_CM_test.go | 1120 +++ .../go-playground/locales/en_CX/en_CX.go | 607 ++ .../go-playground/locales/en_CX/en_CX_test.go | 1120 +++ .../go-playground/locales/en_CY/en_CY.go | 635 ++ .../go-playground/locales/en_CY/en_CY_test.go | 1120 +++ .../go-playground/locales/en_DE/en_DE.go | 639 ++ .../go-playground/locales/en_DE/en_DE_test.go | 1120 +++ .../go-playground/locales/en_DG/en_DG.go | 597 ++ .../go-playground/locales/en_DG/en_DG_test.go | 1120 +++ .../go-playground/locales/en_DK/en_DK.go | 601 ++ .../go-playground/locales/en_DK/en_DK_test.go | 1120 +++ .../go-playground/locales/en_DM/en_DM.go | 645 ++ .../go-playground/locales/en_DM/en_DM_test.go | 1120 +++ .../go-playground/locales/en_ER/en_ER.go | 645 ++ .../go-playground/locales/en_ER/en_ER_test.go | 1120 +++ .../go-playground/locales/en_FI/en_FI.go | 591 ++ .../go-playground/locales/en_FI/en_FI_test.go | 1120 +++ .../go-playground/locales/en_FJ/en_FJ.go | 645 ++ .../go-playground/locales/en_FJ/en_FJ_test.go | 1120 +++ .../go-playground/locales/en_FK/en_FK.go | 597 ++ .../go-playground/locales/en_FK/en_FK_test.go | 1120 +++ .../go-playground/locales/en_FM/en_FM.go | 645 ++ .../go-playground/locales/en_FM/en_FM_test.go | 1120 +++ .../go-playground/locales/en_GB/en_GB.go | 607 ++ .../go-playground/locales/en_GB/en_GB_test.go | 1120 +++ .../go-playground/locales/en_GD/en_GD.go | 645 ++ .../go-playground/locales/en_GD/en_GD_test.go | 1120 +++ .../go-playground/locales/en_GG/en_GG.go | 607 ++ .../go-playground/locales/en_GG/en_GG_test.go | 1120 +++ .../go-playground/locales/en_GH/en_GH.go | 645 ++ .../go-playground/locales/en_GH/en_GH_test.go | 1120 +++ .../go-playground/locales/en_GI/en_GI.go | 597 ++ .../go-playground/locales/en_GI/en_GI_test.go | 1120 +++ .../go-playground/locales/en_GM/en_GM.go | 645 ++ .../go-playground/locales/en_GM/en_GM_test.go | 1120 +++ .../go-playground/locales/en_GU/en_GU.go | 635 ++ .../go-playground/locales/en_GU/en_GU_test.go | 1120 +++ .../go-playground/locales/en_GY/en_GY.go | 645 ++ .../go-playground/locales/en_GY/en_GY_test.go | 1120 +++ .../go-playground/locales/en_HK/en_HK.go | 597 ++ .../go-playground/locales/en_HK/en_HK_test.go | 1120 +++ .../go-playground/locales/en_IE/en_IE.go | 597 ++ .../go-playground/locales/en_IE/en_IE_test.go | 1120 +++ .../go-playground/locales/en_IL/en_IL.go | 581 ++ .../go-playground/locales/en_IL/en_IL_test.go | 1120 +++ .../go-playground/locales/en_IM/en_IM.go | 597 ++ .../go-playground/locales/en_IM/en_IM_test.go | 1120 +++ .../go-playground/locales/en_IN/en_IN.go | 646 ++ .../go-playground/locales/en_IN/en_IN_test.go | 1120 +++ .../go-playground/locales/en_IO/en_IO.go | 597 ++ .../go-playground/locales/en_IO/en_IO_test.go | 1120 +++ .../go-playground/locales/en_JE/en_JE.go | 597 ++ .../go-playground/locales/en_JE/en_JE_test.go | 1120 +++ .../go-playground/locales/en_JM/en_JM.go | 635 ++ .../go-playground/locales/en_JM/en_JM_test.go | 1120 +++ .../go-playground/locales/en_KE/en_KE.go | 607 ++ .../go-playground/locales/en_KE/en_KE_test.go | 1120 +++ .../go-playground/locales/en_KI/en_KI.go | 645 ++ .../go-playground/locales/en_KI/en_KI_test.go | 1120 +++ .../go-playground/locales/en_KN/en_KN.go | 645 ++ .../go-playground/locales/en_KN/en_KN_test.go | 1120 +++ .../go-playground/locales/en_KY/en_KY.go | 645 ++ .../go-playground/locales/en_KY/en_KY_test.go | 1120 +++ .../go-playground/locales/en_LC/en_LC.go | 645 ++ .../go-playground/locales/en_LC/en_LC_test.go | 1120 +++ .../go-playground/locales/en_LR/en_LR.go | 645 ++ .../go-playground/locales/en_LR/en_LR_test.go | 1120 +++ .../go-playground/locales/en_LS/en_LS.go | 645 ++ .../go-playground/locales/en_LS/en_LS_test.go | 1120 +++ .../go-playground/locales/en_MG/en_MG.go | 607 ++ .../go-playground/locales/en_MG/en_MG_test.go | 1120 +++ .../go-playground/locales/en_MH/en_MH.go | 635 ++ .../go-playground/locales/en_MH/en_MH_test.go | 1120 +++ .../go-playground/locales/en_MO/en_MO.go | 607 ++ .../go-playground/locales/en_MO/en_MO_test.go | 1120 +++ .../go-playground/locales/en_MP/en_MP.go | 635 ++ .../go-playground/locales/en_MP/en_MP_test.go | 1120 +++ .../go-playground/locales/en_MS/en_MS.go | 607 ++ .../go-playground/locales/en_MS/en_MS_test.go | 1120 +++ .../go-playground/locales/en_MT/en_MT.go | 605 ++ .../go-playground/locales/en_MT/en_MT_test.go | 1120 +++ .../go-playground/locales/en_MU/en_MU.go | 607 ++ .../go-playground/locales/en_MU/en_MU_test.go | 1120 +++ .../go-playground/locales/en_MW/en_MW.go | 645 ++ .../go-playground/locales/en_MW/en_MW_test.go | 1120 +++ .../go-playground/locales/en_MY/en_MY.go | 645 ++ .../go-playground/locales/en_MY/en_MY_test.go | 1120 +++ .../go-playground/locales/en_NA/en_NA.go | 645 ++ .../go-playground/locales/en_NA/en_NA_test.go | 1120 +++ .../go-playground/locales/en_NF/en_NF.go | 607 ++ .../go-playground/locales/en_NF/en_NF_test.go | 1120 +++ .../go-playground/locales/en_NG/en_NG.go | 645 ++ .../go-playground/locales/en_NG/en_NG_test.go | 1120 +++ .../go-playground/locales/en_NL/en_NL.go | 647 ++ .../go-playground/locales/en_NL/en_NL_test.go | 1120 +++ .../go-playground/locales/en_NR/en_NR.go | 607 ++ .../go-playground/locales/en_NR/en_NR_test.go | 1120 +++ .../go-playground/locales/en_NU/en_NU.go | 607 ++ .../go-playground/locales/en_NU/en_NU_test.go | 1120 +++ .../go-playground/locales/en_NZ/en_NZ.go | 609 ++ .../go-playground/locales/en_NZ/en_NZ_test.go | 1120 +++ .../go-playground/locales/en_PG/en_PG.go | 645 ++ .../go-playground/locales/en_PG/en_PG_test.go | 1120 +++ .../go-playground/locales/en_PH/en_PH.go | 645 ++ .../go-playground/locales/en_PH/en_PH_test.go | 1120 +++ .../go-playground/locales/en_PK/en_PK.go | 601 ++ .../go-playground/locales/en_PK/en_PK_test.go | 1120 +++ .../go-playground/locales/en_PN/en_PN.go | 607 ++ .../go-playground/locales/en_PN/en_PN_test.go | 1120 +++ .../go-playground/locales/en_PR/en_PR.go | 635 ++ .../go-playground/locales/en_PR/en_PR_test.go | 1120 +++ .../go-playground/locales/en_PW/en_PW.go | 645 ++ .../go-playground/locales/en_PW/en_PW_test.go | 1120 +++ .../go-playground/locales/en_RW/en_RW.go | 607 ++ .../go-playground/locales/en_RW/en_RW_test.go | 1120 +++ .../go-playground/locales/en_SB/en_SB.go | 645 ++ .../go-playground/locales/en_SB/en_SB_test.go | 1120 +++ .../go-playground/locales/en_SC/en_SC.go | 607 ++ .../go-playground/locales/en_SC/en_SC_test.go | 1120 +++ .../go-playground/locales/en_SD/en_SD.go | 645 ++ .../go-playground/locales/en_SD/en_SD_test.go | 1120 +++ .../go-playground/locales/en_SE/en_SE.go | 656 ++ .../go-playground/locales/en_SE/en_SE_test.go | 1120 +++ .../go-playground/locales/en_SG/en_SG.go | 597 ++ .../go-playground/locales/en_SG/en_SG_test.go | 1120 +++ .../go-playground/locales/en_SH/en_SH.go | 607 ++ .../go-playground/locales/en_SH/en_SH_test.go | 1120 +++ .../go-playground/locales/en_SI/en_SI.go | 630 ++ .../go-playground/locales/en_SI/en_SI_test.go | 1120 +++ .../go-playground/locales/en_SL/en_SL.go | 645 ++ .../go-playground/locales/en_SL/en_SL_test.go | 1120 +++ .../go-playground/locales/en_SS/en_SS.go | 645 ++ .../go-playground/locales/en_SS/en_SS_test.go | 1120 +++ .../go-playground/locales/en_SX/en_SX.go | 607 ++ .../go-playground/locales/en_SX/en_SX_test.go | 1120 +++ .../go-playground/locales/en_SZ/en_SZ.go | 645 ++ .../go-playground/locales/en_SZ/en_SZ_test.go | 1120 +++ .../go-playground/locales/en_TC/en_TC.go | 645 ++ .../go-playground/locales/en_TC/en_TC_test.go | 1120 +++ .../go-playground/locales/en_TK/en_TK.go | 607 ++ .../go-playground/locales/en_TK/en_TK_test.go | 1120 +++ .../go-playground/locales/en_TO/en_TO.go | 645 ++ .../go-playground/locales/en_TO/en_TO_test.go | 1120 +++ .../go-playground/locales/en_TT/en_TT.go | 645 ++ .../go-playground/locales/en_TT/en_TT_test.go | 1120 +++ .../go-playground/locales/en_TV/en_TV.go | 607 ++ .../go-playground/locales/en_TV/en_TV_test.go | 1120 +++ .../go-playground/locales/en_TZ/en_TZ.go | 607 ++ .../go-playground/locales/en_TZ/en_TZ_test.go | 1120 +++ .../go-playground/locales/en_UG/en_UG.go | 607 ++ .../go-playground/locales/en_UG/en_UG_test.go | 1120 +++ .../go-playground/locales/en_UM/en_UM.go | 635 ++ .../go-playground/locales/en_UM/en_UM_test.go | 1120 +++ .../go-playground/locales/en_US/en_US.go | 635 ++ .../go-playground/locales/en_US/en_US_test.go | 1120 +++ .../locales/en_US_POSIX/en_US_POSIX.go | 610 ++ .../locales/en_US_POSIX/en_US_POSIX_test.go | 1120 +++ .../go-playground/locales/en_VC/en_VC.go | 645 ++ .../go-playground/locales/en_VC/en_VC_test.go | 1120 +++ .../go-playground/locales/en_VG/en_VG.go | 607 ++ .../go-playground/locales/en_VG/en_VG_test.go | 1120 +++ .../go-playground/locales/en_VI/en_VI.go | 635 ++ .../go-playground/locales/en_VI/en_VI_test.go | 1120 +++ .../go-playground/locales/en_VU/en_VU.go | 645 ++ .../go-playground/locales/en_VU/en_VU_test.go | 1120 +++ .../go-playground/locales/en_WS/en_WS.go | 645 ++ .../go-playground/locales/en_WS/en_WS_test.go | 1120 +++ .../go-playground/locales/en_ZA/en_ZA.go | 627 ++ .../go-playground/locales/en_ZA/en_ZA_test.go | 1120 +++ .../go-playground/locales/en_ZM/en_ZM.go | 645 ++ .../go-playground/locales/en_ZM/en_ZM_test.go | 1120 +++ .../go-playground/locales/en_ZW/en_ZW.go | 610 ++ .../go-playground/locales/en_ZW/en_ZW_test.go | 1120 +++ .../github.com/go-playground/locales/eo/eo.go | 586 ++ .../go-playground/locales/eo/eo_test.go | 1120 +++ .../go-playground/locales/eo_001/eo_001.go | 586 ++ .../locales/eo_001/eo_001_test.go | 1120 +++ .../github.com/go-playground/locales/es/es.go | 572 ++ .../go-playground/locales/es/es_test.go | 1120 +++ .../go-playground/locales/es_419/es_419.go | 583 ++ .../locales/es_419/es_419_test.go | 1120 +++ .../go-playground/locales/es_AR/es_AR.go | 589 ++ .../go-playground/locales/es_AR/es_AR_test.go | 1120 +++ .../go-playground/locales/es_BO/es_BO.go | 573 ++ .../go-playground/locales/es_BO/es_BO_test.go | 1120 +++ .../go-playground/locales/es_BR/es_BR.go | 572 ++ .../go-playground/locales/es_BR/es_BR_test.go | 1120 +++ .../go-playground/locales/es_CL/es_CL.go | 589 ++ .../go-playground/locales/es_CL/es_CL_test.go | 1120 +++ .../go-playground/locales/es_CO/es_CO.go | 645 ++ .../go-playground/locales/es_CO/es_CO_test.go | 1120 +++ .../go-playground/locales/es_CR/es_CR.go | 578 ++ .../go-playground/locales/es_CR/es_CR_test.go | 1120 +++ .../go-playground/locales/es_CU/es_CU.go | 572 ++ .../go-playground/locales/es_CU/es_CU_test.go | 1120 +++ .../go-playground/locales/es_DO/es_DO.go | 630 ++ .../go-playground/locales/es_DO/es_DO_test.go | 1120 +++ .../go-playground/locales/es_EA/es_EA.go | 572 ++ .../go-playground/locales/es_EA/es_EA_test.go | 1120 +++ .../go-playground/locales/es_EC/es_EC.go | 569 ++ .../go-playground/locales/es_EC/es_EC_test.go | 1120 +++ .../go-playground/locales/es_ES/es_ES.go | 572 ++ .../go-playground/locales/es_ES/es_ES_test.go | 1120 +++ .../go-playground/locales/es_GQ/es_GQ.go | 569 ++ .../go-playground/locales/es_GQ/es_GQ_test.go | 1120 +++ .../go-playground/locales/es_GT/es_GT.go | 550 ++ .../go-playground/locales/es_GT/es_GT_test.go | 1120 +++ .../go-playground/locales/es_HN/es_HN.go | 581 ++ .../go-playground/locales/es_HN/es_HN_test.go | 1120 +++ .../go-playground/locales/es_IC/es_IC.go | 572 ++ .../go-playground/locales/es_IC/es_IC_test.go | 1120 +++ .../go-playground/locales/es_MX/es_MX.go | 588 ++ .../go-playground/locales/es_MX/es_MX_test.go | 1120 +++ .../go-playground/locales/es_NI/es_NI.go | 572 ++ .../go-playground/locales/es_NI/es_NI_test.go | 1120 +++ .../go-playground/locales/es_PA/es_PA.go | 644 ++ .../go-playground/locales/es_PA/es_PA_test.go | 1120 +++ .../go-playground/locales/es_PE/es_PE.go | 578 ++ .../go-playground/locales/es_PE/es_PE_test.go | 1120 +++ .../go-playground/locales/es_PH/es_PH.go | 624 ++ .../go-playground/locales/es_PH/es_PH_test.go | 1120 +++ .../go-playground/locales/es_PR/es_PR.go | 644 ++ .../go-playground/locales/es_PR/es_PR_test.go | 1120 +++ .../go-playground/locales/es_PY/es_PY.go | 585 ++ .../go-playground/locales/es_PY/es_PY_test.go | 1120 +++ .../go-playground/locales/es_SV/es_SV.go | 572 ++ .../go-playground/locales/es_SV/es_SV_test.go | 1120 +++ .../go-playground/locales/es_US/es_US.go | 624 ++ .../go-playground/locales/es_US/es_US_test.go | 1120 +++ .../go-playground/locales/es_UY/es_UY.go | 589 ++ .../go-playground/locales/es_UY/es_UY_test.go | 1120 +++ .../go-playground/locales/es_VE/es_VE.go | 621 ++ .../go-playground/locales/es_VE/es_VE_test.go | 1120 +++ .../github.com/go-playground/locales/et/et.go | 603 ++ .../go-playground/locales/et/et_test.go | 1120 +++ .../go-playground/locales/et_EE/et_EE.go | 603 ++ .../go-playground/locales/et_EE/et_EE_test.go | 1120 +++ .../github.com/go-playground/locales/eu/eu.go | 607 ++ .../go-playground/locales/eu/eu_test.go | 1120 +++ .../go-playground/locales/eu/ue_test.go | 42 + .../go-playground/locales/eu_ES/eu_ES.go | 607 ++ .../go-playground/locales/eu_ES/eu_ES_test.go | 1120 +++ .../go-playground/locales/ewo/ewo.go | 571 ++ .../go-playground/locales/ewo/ewo_test.go | 1120 +++ .../go-playground/locales/ewo_CM/ewo_CM.go | 571 ++ .../locales/ewo_CM/ewo_CM_test.go | 1120 +++ .../github.com/go-playground/locales/fa/fa.go | 602 ++ .../go-playground/locales/fa/fa_test.go | 1120 +++ .../go-playground/locales/fa_AF/fa_AF.go | 602 ++ .../go-playground/locales/fa_AF/fa_AF_test.go | 1120 +++ .../go-playground/locales/fa_IR/fa_IR.go | 602 ++ .../go-playground/locales/fa_IR/fa_IR_test.go | 1120 +++ .../github.com/go-playground/locales/ff/ff.go | 517 ++ .../go-playground/locales/ff/ff_test.go | 1120 +++ .../go-playground/locales/ff_CM/ff_CM.go | 517 ++ .../go-playground/locales/ff_CM/ff_CM_test.go | 1120 +++ .../go-playground/locales/ff_GN/ff_GN.go | 517 ++ .../go-playground/locales/ff_GN/ff_GN_test.go | 1120 +++ .../go-playground/locales/ff_MR/ff_MR.go | 555 ++ .../go-playground/locales/ff_MR/ff_MR_test.go | 1120 +++ .../go-playground/locales/ff_SN/ff_SN.go | 517 ++ .../go-playground/locales/ff_SN/ff_SN_test.go | 1120 +++ .../github.com/go-playground/locales/fi/fi.go | 580 ++ .../go-playground/locales/fi/fi_test.go | 1120 +++ .../go-playground/locales/fi_FI/fi_FI.go | 580 ++ .../go-playground/locales/fi_FI/fi_FI_test.go | 1120 +++ .../go-playground/locales/fil/fil.go | 645 ++ .../go-playground/locales/fil/fil_test.go | 1120 +++ .../go-playground/locales/fil_PH/fil_PH.go | 645 ++ .../locales/fil_PH/fil_PH_test.go | 1120 +++ .../github.com/go-playground/locales/fo/fo.go | 610 ++ .../go-playground/locales/fo/fo_test.go | 1120 +++ .../go-playground/locales/fo_DK/fo_DK.go | 610 ++ .../go-playground/locales/fo_DK/fo_DK_test.go | 1120 +++ .../go-playground/locales/fo_FO/fo_FO.go | 610 ++ .../go-playground/locales/fo_FO/fo_FO_test.go | 1120 +++ .../github.com/go-playground/locales/fr/fr.go | 619 ++ .../go-playground/locales/fr/fr_test.go | 1120 +++ .../go-playground/locales/fr_BE/fr_BE.go | 614 ++ .../go-playground/locales/fr_BE/fr_BE_test.go | 1120 +++ .../go-playground/locales/fr_BF/fr_BF.go | 619 ++ .../go-playground/locales/fr_BF/fr_BF_test.go | 1120 +++ .../go-playground/locales/fr_BI/fr_BI.go | 619 ++ .../go-playground/locales/fr_BI/fr_BI_test.go | 1120 +++ .../go-playground/locales/fr_BJ/fr_BJ.go | 619 ++ .../go-playground/locales/fr_BJ/fr_BJ_test.go | 1120 +++ .../go-playground/locales/fr_BL/fr_BL.go | 619 ++ .../go-playground/locales/fr_BL/fr_BL_test.go | 1120 +++ .../go-playground/locales/fr_CA/fr_CA.go | 571 ++ .../go-playground/locales/fr_CA/fr_CA_test.go | 1120 +++ .../go-playground/locales/fr_CD/fr_CD.go | 619 ++ .../go-playground/locales/fr_CD/fr_CD_test.go | 1120 +++ .../go-playground/locales/fr_CF/fr_CF.go | 619 ++ .../go-playground/locales/fr_CF/fr_CF_test.go | 1120 +++ .../go-playground/locales/fr_CG/fr_CG.go | 619 ++ .../go-playground/locales/fr_CG/fr_CG_test.go | 1120 +++ .../go-playground/locales/fr_CH/fr_CH.go | 627 ++ .../go-playground/locales/fr_CH/fr_CH_test.go | 1120 +++ .../go-playground/locales/fr_CI/fr_CI.go | 619 ++ .../go-playground/locales/fr_CI/fr_CI_test.go | 1120 +++ .../go-playground/locales/fr_CM/fr_CM.go | 619 ++ .../go-playground/locales/fr_CM/fr_CM_test.go | 1120 +++ .../go-playground/locales/fr_DJ/fr_DJ.go | 657 ++ .../go-playground/locales/fr_DJ/fr_DJ_test.go | 1120 +++ .../go-playground/locales/fr_DZ/fr_DZ.go | 657 ++ .../go-playground/locales/fr_DZ/fr_DZ_test.go | 1120 +++ .../go-playground/locales/fr_FR/fr_FR.go | 619 ++ .../go-playground/locales/fr_FR/fr_FR_test.go | 1120 +++ .../go-playground/locales/fr_GA/fr_GA.go | 619 ++ .../go-playground/locales/fr_GA/fr_GA_test.go | 1120 +++ .../go-playground/locales/fr_GF/fr_GF.go | 619 ++ .../go-playground/locales/fr_GF/fr_GF_test.go | 1120 +++ .../go-playground/locales/fr_GN/fr_GN.go | 619 ++ .../go-playground/locales/fr_GN/fr_GN_test.go | 1120 +++ .../go-playground/locales/fr_GP/fr_GP.go | 619 ++ .../go-playground/locales/fr_GP/fr_GP_test.go | 1120 +++ .../go-playground/locales/fr_GQ/fr_GQ.go | 619 ++ .../go-playground/locales/fr_GQ/fr_GQ_test.go | 1120 +++ .../go-playground/locales/fr_HT/fr_HT.go | 619 ++ .../go-playground/locales/fr_HT/fr_HT_test.go | 1120 +++ .../go-playground/locales/fr_KM/fr_KM.go | 619 ++ .../go-playground/locales/fr_KM/fr_KM_test.go | 1120 +++ .../go-playground/locales/fr_LU/fr_LU.go | 613 ++ .../go-playground/locales/fr_LU/fr_LU_test.go | 1120 +++ .../go-playground/locales/fr_MA/fr_MA.go | 613 ++ .../go-playground/locales/fr_MA/fr_MA_test.go | 1120 +++ .../go-playground/locales/fr_MC/fr_MC.go | 619 ++ .../go-playground/locales/fr_MC/fr_MC_test.go | 1120 +++ .../go-playground/locales/fr_MF/fr_MF.go | 619 ++ .../go-playground/locales/fr_MF/fr_MF_test.go | 1120 +++ .../go-playground/locales/fr_MG/fr_MG.go | 619 ++ .../go-playground/locales/fr_MG/fr_MG_test.go | 1120 +++ .../go-playground/locales/fr_ML/fr_ML.go | 619 ++ .../go-playground/locales/fr_ML/fr_ML_test.go | 1120 +++ .../go-playground/locales/fr_MQ/fr_MQ.go | 619 ++ .../go-playground/locales/fr_MQ/fr_MQ_test.go | 1120 +++ .../go-playground/locales/fr_MR/fr_MR.go | 657 ++ .../go-playground/locales/fr_MR/fr_MR_test.go | 1120 +++ .../go-playground/locales/fr_MU/fr_MU.go | 619 ++ .../go-playground/locales/fr_MU/fr_MU_test.go | 1120 +++ .../go-playground/locales/fr_NC/fr_NC.go | 619 ++ .../go-playground/locales/fr_NC/fr_NC_test.go | 1120 +++ .../go-playground/locales/fr_NE/fr_NE.go | 619 ++ .../go-playground/locales/fr_NE/fr_NE_test.go | 1120 +++ .../go-playground/locales/fr_PF/fr_PF.go | 619 ++ .../go-playground/locales/fr_PF/fr_PF_test.go | 1120 +++ .../go-playground/locales/fr_PM/fr_PM.go | 619 ++ .../go-playground/locales/fr_PM/fr_PM_test.go | 1120 +++ .../go-playground/locales/fr_RE/fr_RE.go | 619 ++ .../go-playground/locales/fr_RE/fr_RE_test.go | 1120 +++ .../go-playground/locales/fr_RW/fr_RW.go | 619 ++ .../go-playground/locales/fr_RW/fr_RW_test.go | 1120 +++ .../go-playground/locales/fr_SC/fr_SC.go | 619 ++ .../go-playground/locales/fr_SC/fr_SC_test.go | 1120 +++ .../go-playground/locales/fr_SN/fr_SN.go | 619 ++ .../go-playground/locales/fr_SN/fr_SN_test.go | 1120 +++ .../go-playground/locales/fr_SY/fr_SY.go | 657 ++ .../go-playground/locales/fr_SY/fr_SY_test.go | 1120 +++ .../go-playground/locales/fr_TD/fr_TD.go | 657 ++ .../go-playground/locales/fr_TD/fr_TD_test.go | 1120 +++ .../go-playground/locales/fr_TG/fr_TG.go | 619 ++ .../go-playground/locales/fr_TG/fr_TG_test.go | 1120 +++ .../go-playground/locales/fr_TN/fr_TN.go | 657 ++ .../go-playground/locales/fr_TN/fr_TN_test.go | 1120 +++ .../go-playground/locales/fr_VU/fr_VU.go | 657 ++ .../go-playground/locales/fr_VU/fr_VU_test.go | 1120 +++ .../go-playground/locales/fr_WF/fr_WF.go | 619 ++ .../go-playground/locales/fr_WF/fr_WF_test.go | 1120 +++ .../go-playground/locales/fr_YT/fr_YT.go | 619 ++ .../go-playground/locales/fr_YT/fr_YT_test.go | 1120 +++ .../go-playground/locales/fur/fur.go | 613 ++ .../go-playground/locales/fur/fur_test.go | 1120 +++ .../go-playground/locales/fur_IT/fur_IT.go | 613 ++ .../locales/fur_IT/fur_IT_test.go | 1120 +++ .../github.com/go-playground/locales/fy/fy.go | 606 ++ .../go-playground/locales/fy/fy_test.go | 1120 +++ .../go-playground/locales/fy_NL/fy_NL.go | 606 ++ .../go-playground/locales/fy_NL/fy_NL_test.go | 1120 +++ .../github.com/go-playground/locales/ga/ga.go | 645 ++ .../go-playground/locales/ga/ga_test.go | 1120 +++ .../go-playground/locales/ga_IE/ga_IE.go | 645 ++ .../go-playground/locales/ga_IE/ga_IE_test.go | 1120 +++ .../github.com/go-playground/locales/gd/gd.go | 599 ++ .../go-playground/locales/gd/gd_test.go | 1120 +++ .../go-playground/locales/gd_GB/gd_GB.go | 599 ++ .../go-playground/locales/gd_GB/gd_GB_test.go | 1120 +++ .../github.com/go-playground/locales/gl/gl.go | 610 ++ .../go-playground/locales/gl/gl_test.go | 1120 +++ .../go-playground/locales/gl_ES/gl_ES.go | 610 ++ .../go-playground/locales/gl_ES/gl_ES_test.go | 1120 +++ .../go-playground/locales/gsw/gsw.go | 614 ++ .../go-playground/locales/gsw/gsw_test.go | 1120 +++ .../go-playground/locales/gsw_CH/gsw_CH.go | 614 ++ .../locales/gsw_CH/gsw_CH_test.go | 1120 +++ .../go-playground/locales/gsw_FR/gsw_FR.go | 614 ++ .../locales/gsw_FR/gsw_FR_test.go | 1120 +++ .../go-playground/locales/gsw_LI/gsw_LI.go | 614 ++ .../locales/gsw_LI/gsw_LI_test.go | 1120 +++ .../github.com/go-playground/locales/gu/gu.go | 663 ++ .../go-playground/locales/gu/gu_test.go | 1120 +++ .../go-playground/locales/gu_IN/gu_IN.go | 663 ++ .../go-playground/locales/gu_IN/gu_IN_test.go | 1120 +++ .../go-playground/locales/guz/guz.go | 518 ++ .../go-playground/locales/guz/guz_test.go | 1120 +++ .../go-playground/locales/guz_KE/guz_KE.go | 518 ++ .../locales/guz_KE/guz_KE_test.go | 1120 +++ .../github.com/go-playground/locales/gv/gv.go | 538 ++ .../go-playground/locales/gv/gv_test.go | 1120 +++ .../go-playground/locales/gv_IM/gv_IM.go | 538 ++ .../go-playground/locales/gv_IM/gv_IM_test.go | 1120 +++ .../github.com/go-playground/locales/ha/ha.go | 587 ++ .../go-playground/locales/ha/ha_test.go | 1120 +++ .../go-playground/locales/ha_GH/ha_GH.go | 587 ++ .../go-playground/locales/ha_GH/ha_GH_test.go | 1120 +++ .../go-playground/locales/ha_NE/ha_NE.go | 587 ++ .../go-playground/locales/ha_NE/ha_NE_test.go | 1120 +++ .../go-playground/locales/ha_NG/ha_NG.go | 587 ++ .../go-playground/locales/ha_NG/ha_NG_test.go | 1120 +++ .../go-playground/locales/haw/haw.go | 621 ++ .../go-playground/locales/haw/haw_test.go | 1120 +++ .../go-playground/locales/haw_US/haw_US.go | 621 ++ .../locales/haw_US/haw_US_test.go | 1120 +++ .../github.com/go-playground/locales/he/he.go | 603 ++ .../go-playground/locales/he/he_test.go | 1120 +++ .../go-playground/locales/he_IL/he_IL.go | 603 ++ .../go-playground/locales/he_IL/he_IL_test.go | 1120 +++ .../github.com/go-playground/locales/hi/hi.go | 675 ++ .../go-playground/locales/hi/hi_test.go | 1120 +++ .../go-playground/locales/hi_IN/hi_IN.go | 675 ++ .../go-playground/locales/hi_IN/hi_IN_test.go | 1120 +++ .../github.com/go-playground/locales/hr/hr.go | 629 ++ .../go-playground/locales/hr/hr_test.go | 1120 +++ .../go-playground/locales/hr_BA/hr_BA.go | 619 ++ .../go-playground/locales/hr_BA/hr_BA_test.go | 1120 +++ .../go-playground/locales/hr_HR/hr_HR.go | 629 ++ .../go-playground/locales/hr_HR/hr_HR_test.go | 1120 +++ .../go-playground/locales/hsb/hsb.go | 576 ++ .../go-playground/locales/hsb/hsb_test.go | 1120 +++ .../go-playground/locales/hsb_DE/hsb_DE.go | 576 ++ .../locales/hsb_DE/hsb_DE_test.go | 1120 +++ .../github.com/go-playground/locales/hu/hu.go | 600 ++ .../go-playground/locales/hu/hu_test.go | 1120 +++ .../go-playground/locales/hu_HU/hu_HU.go | 600 ++ .../go-playground/locales/hu_HU/hu_HU_test.go | 1120 +++ .../github.com/go-playground/locales/hy/hy.go | 638 ++ .../go-playground/locales/hy/hy_test.go | 1120 +++ .../go-playground/locales/hy_AM/hy_AM.go | 638 ++ .../go-playground/locales/hy_AM/hy_AM_test.go | 1120 +++ .../github.com/go-playground/locales/id/id.go | 583 ++ .../go-playground/locales/id/id_test.go | 1120 +++ .../go-playground/locales/id_ID/id_ID.go | 583 ++ .../go-playground/locales/id_ID/id_ID_test.go | 1120 +++ .../github.com/go-playground/locales/ig/ig.go | 594 ++ .../go-playground/locales/ig/ig_test.go | 1120 +++ .../go-playground/locales/ig_NG/ig_NG.go | 594 ++ .../go-playground/locales/ig_NG/ig_NG_test.go | 1120 +++ .../github.com/go-playground/locales/ii/ii.go | 629 ++ .../go-playground/locales/ii/ii_test.go | 1120 +++ .../go-playground/locales/ii_CN/ii_CN.go | 629 ++ .../go-playground/locales/ii_CN/ii_CN_test.go | 1120 +++ .../github.com/go-playground/locales/is/is.go | 595 ++ .../go-playground/locales/is/is_test.go | 1120 +++ .../go-playground/locales/is_IS/is_IS.go | 595 ++ .../go-playground/locales/is_IS/is_IS_test.go | 1120 +++ .../github.com/go-playground/locales/it/it.go | 611 ++ .../go-playground/locales/it/it_test.go | 1120 +++ .../go-playground/locales/it_CH/it_CH.go | 620 ++ .../go-playground/locales/it_CH/it_CH_test.go | 1120 +++ .../go-playground/locales/it_IT/it_IT.go | 611 ++ .../go-playground/locales/it_IT/it_IT_test.go | 1120 +++ .../go-playground/locales/it_SM/it_SM.go | 611 ++ .../go-playground/locales/it_SM/it_SM_test.go | 1120 +++ .../github.com/go-playground/locales/ja/ja.go | 583 ++ .../go-playground/locales/ja/ja_test.go | 1120 +++ .../go-playground/locales/ja_JP/ja_JP.go | 583 ++ .../go-playground/locales/ja_JP/ja_JP_test.go | 1120 +++ .../go-playground/locales/jgo/jgo.go | 606 ++ .../go-playground/locales/jgo/jgo_test.go | 1120 +++ .../go-playground/locales/jgo_CM/jgo_CM.go | 606 ++ .../locales/jgo_CM/jgo_CM_test.go | 1120 +++ .../go-playground/locales/jmc/jmc.go | 517 ++ .../go-playground/locales/jmc/jmc_test.go | 1120 +++ .../go-playground/locales/jmc_TZ/jmc_TZ.go | 517 ++ .../locales/jmc_TZ/jmc_TZ_test.go | 1120 +++ .../github.com/go-playground/locales/ka/ka.go | 625 ++ .../go-playground/locales/ka/ka_test.go | 1120 +++ .../go-playground/locales/ka_GE/ka_GE.go | 625 ++ .../go-playground/locales/ka_GE/ka_GE_test.go | 1120 +++ .../go-playground/locales/kab/kab.go | 547 ++ .../go-playground/locales/kab/kab_test.go | 1120 +++ .../go-playground/locales/kab_DZ/kab_DZ.go | 547 ++ .../locales/kab_DZ/kab_DZ_test.go | 1120 +++ .../go-playground/locales/kam/kam.go | 518 ++ .../go-playground/locales/kam/kam_test.go | 1120 +++ .../go-playground/locales/kam_KE/kam_KE.go | 518 ++ .../locales/kam_KE/kam_KE_test.go | 1120 +++ .../go-playground/locales/kde/kde.go | 518 ++ .../go-playground/locales/kde/kde_test.go | 1120 +++ .../go-playground/locales/kde_TZ/kde_TZ.go | 518 ++ .../locales/kde_TZ/kde_TZ_test.go | 1120 +++ .../go-playground/locales/kea/kea.go | 583 ++ .../go-playground/locales/kea/kea_test.go | 1120 +++ .../go-playground/locales/kea_CV/kea_CV.go | 583 ++ .../locales/kea_CV/kea_CV_test.go | 1120 +++ .../go-playground/locales/khq/khq.go | 500 ++ .../go-playground/locales/khq/khq_test.go | 1120 +++ .../go-playground/locales/khq_ML/khq_ML.go | 500 ++ .../locales/khq_ML/khq_ML_test.go | 1120 +++ .../github.com/go-playground/locales/ki/ki.go | 518 ++ .../go-playground/locales/ki/ki_test.go | 1120 +++ .../go-playground/locales/ki_KE/ki_KE.go | 518 ++ .../go-playground/locales/ki_KE/ki_KE_test.go | 1120 +++ .../github.com/go-playground/locales/kk/kk.go | 621 ++ .../go-playground/locales/kk/kk_test.go | 1120 +++ .../go-playground/locales/kk_KZ/kk_KZ.go | 621 ++ .../go-playground/locales/kk_KZ/kk_KZ_test.go | 1120 +++ .../go-playground/locales/kkj/kkj.go | 450 ++ .../go-playground/locales/kkj/kkj_test.go | 1120 +++ .../go-playground/locales/kkj_CM/kkj_CM.go | 450 ++ .../locales/kkj_CM/kkj_CM_test.go | 1120 +++ .../github.com/go-playground/locales/kl/kl.go | 649 ++ .../go-playground/locales/kl/kl_test.go | 1120 +++ .../go-playground/locales/kl_GL/kl_GL.go | 649 ++ .../go-playground/locales/kl_GL/kl_GL_test.go | 1120 +++ .../go-playground/locales/kln/kln.go | 518 ++ .../go-playground/locales/kln/kln_test.go | 1120 +++ .../go-playground/locales/kln_KE/kln_KE.go | 518 ++ .../locales/kln_KE/kln_KE_test.go | 1120 +++ .../github.com/go-playground/locales/km/km.go | 606 ++ .../go-playground/locales/km/km_test.go | 1120 +++ .../go-playground/locales/km_KH/km_KH.go | 606 ++ .../go-playground/locales/km_KH/km_KH_test.go | 1120 +++ .../github.com/go-playground/locales/kn/kn.go | 641 ++ .../go-playground/locales/kn/kn_test.go | 1120 +++ .../go-playground/locales/kn_IN/kn_IN.go | 641 ++ .../go-playground/locales/kn_IN/kn_IN_test.go | 1120 +++ .../github.com/go-playground/locales/ko/ko.go | 599 ++ .../go-playground/locales/ko/ko_test.go | 1120 +++ .../go-playground/locales/ko_KP/ko_KP.go | 599 ++ .../go-playground/locales/ko_KP/ko_KP_test.go | 1120 +++ .../go-playground/locales/ko_KR/ko_KR.go | 599 ++ .../go-playground/locales/ko_KR/ko_KR_test.go | 1120 +++ .../go-playground/locales/kok/kok.go | 648 ++ .../go-playground/locales/kok/kok_test.go | 1120 +++ .../go-playground/locales/kok_IN/kok_IN.go | 648 ++ .../locales/kok_IN/kok_IN_test.go | 1120 +++ .../github.com/go-playground/locales/ks/ks.go | 659 ++ .../go-playground/locales/ks/ks_test.go | 1120 +++ .../go-playground/locales/ks_IN/ks_IN.go | 659 ++ .../go-playground/locales/ks_IN/ks_IN_test.go | 1120 +++ .../go-playground/locales/ksb/ksb.go | 512 ++ .../go-playground/locales/ksb/ksb_test.go | 1120 +++ .../go-playground/locales/ksb_TZ/ksb_TZ.go | 512 ++ .../locales/ksb_TZ/ksb_TZ_test.go | 1120 +++ .../go-playground/locales/ksf/ksf.go | 545 ++ .../go-playground/locales/ksf/ksf_test.go | 1120 +++ .../go-playground/locales/ksf_CM/ksf_CM.go | 545 ++ .../locales/ksf_CM/ksf_CM_test.go | 1120 +++ .../go-playground/locales/ksh/ksh.go | 598 ++ .../go-playground/locales/ksh/ksh_test.go | 1120 +++ .../go-playground/locales/ksh_DE/ksh_DE.go | 598 ++ .../locales/ksh_DE/ksh_DE_test.go | 1120 +++ .../github.com/go-playground/locales/kw/kw.go | 517 ++ .../go-playground/locales/kw/kw_test.go | 1120 +++ .../go-playground/locales/kw_GB/kw_GB.go | 517 ++ .../go-playground/locales/kw_GB/kw_GB_test.go | 1120 +++ .../github.com/go-playground/locales/ky/ky.go | 598 ++ .../go-playground/locales/ky/ky_test.go | 1120 +++ .../go-playground/locales/ky_KG/ky_KG.go | 598 ++ .../go-playground/locales/ky_KG/ky_KG_test.go | 1120 +++ .../go-playground/locales/lag/lag.go | 505 ++ .../go-playground/locales/lag/lag_test.go | 1120 +++ .../go-playground/locales/lag_TZ/lag_TZ.go | 505 ++ .../locales/lag_TZ/lag_TZ_test.go | 1120 +++ .../github.com/go-playground/locales/lb/lb.go | 592 ++ .../go-playground/locales/lb/lb_test.go | 1120 +++ .../go-playground/locales/lb_LU/lb_LU.go | 592 ++ .../go-playground/locales/lb_LU/lb_LU_test.go | 1120 +++ .../github.com/go-playground/locales/lg/lg.go | 510 ++ .../go-playground/locales/lg/lg_test.go | 1120 +++ .../go-playground/locales/lg_UG/lg_UG.go | 510 ++ .../go-playground/locales/lg_UG/lg_UG_test.go | 1120 +++ .../go-playground/locales/lkt/lkt.go | 521 ++ .../go-playground/locales/lkt/lkt_test.go | 1120 +++ .../go-playground/locales/lkt_US/lkt_US.go | 521 ++ .../locales/lkt_US/lkt_US_test.go | 1120 +++ .../github.com/go-playground/locales/ln/ln.go | 551 ++ .../go-playground/locales/ln/ln_test.go | 1120 +++ .../go-playground/locales/ln_AO/ln_AO.go | 551 ++ .../go-playground/locales/ln_AO/ln_AO_test.go | 1120 +++ .../go-playground/locales/ln_CD/ln_CD.go | 551 ++ .../go-playground/locales/ln_CD/ln_CD_test.go | 1120 +++ .../go-playground/locales/ln_CF/ln_CF.go | 551 ++ .../go-playground/locales/ln_CF/ln_CF_test.go | 1120 +++ .../go-playground/locales/ln_CG/ln_CG.go | 551 ++ .../go-playground/locales/ln_CG/ln_CG_test.go | 1120 +++ .../github.com/go-playground/locales/lo/lo.go | 524 ++ .../go-playground/locales/lo/lo_test.go | 1120 +++ .../go-playground/locales/lo_LA/lo_LA.go | 524 ++ .../go-playground/locales/lo_LA/lo_LA_test.go | 1120 +++ .../github.com/go-playground/locales/logo.png | Bin 0 -> 37360 bytes .../go-playground/locales/lrc/lrc.go | 588 ++ .../go-playground/locales/lrc/lrc_test.go | 1120 +++ .../go-playground/locales/lrc_IQ/lrc_IQ.go | 626 ++ .../locales/lrc_IQ/lrc_IQ_test.go | 1120 +++ .../go-playground/locales/lrc_IR/lrc_IR.go | 588 ++ .../locales/lrc_IR/lrc_IR_test.go | 1120 +++ .../github.com/go-playground/locales/lt/lt.go | 667 ++ .../go-playground/locales/lt/lt_test.go | 1120 +++ .../go-playground/locales/lt_LT/lt_LT.go | 667 ++ .../go-playground/locales/lt_LT/lt_LT_test.go | 1120 +++ .../github.com/go-playground/locales/lu/lu.go | 532 ++ .../go-playground/locales/lu/lu_test.go | 1120 +++ .../go-playground/locales/lu_CD/lu_CD.go | 532 ++ .../go-playground/locales/lu_CD/lu_CD_test.go | 1120 +++ .../go-playground/locales/luo/luo.go | 505 ++ .../go-playground/locales/luo/luo_test.go | 1120 +++ .../go-playground/locales/luo_KE/luo_KE.go | 505 ++ .../locales/luo_KE/luo_KE_test.go | 1120 +++ .../go-playground/locales/luy/luy.go | 510 ++ .../go-playground/locales/luy/luy_test.go | 1120 +++ .../go-playground/locales/luy_KE/luy_KE.go | 510 ++ .../locales/luy_KE/luy_KE_test.go | 1120 +++ .../github.com/go-playground/locales/lv/lv.go | 628 ++ .../go-playground/locales/lv/lv_test.go | 1120 +++ .../go-playground/locales/lv_LV/lv_LV.go | 628 ++ .../go-playground/locales/lv_LV/lv_LV_test.go | 1120 +++ .../go-playground/locales/mas/mas.go | 524 ++ .../go-playground/locales/mas/mas_test.go | 1120 +++ .../go-playground/locales/mas_KE/mas_KE.go | 524 ++ .../locales/mas_KE/mas_KE_test.go | 1120 +++ .../go-playground/locales/mas_TZ/mas_TZ.go | 524 ++ .../locales/mas_TZ/mas_TZ_test.go | 1120 +++ .../go-playground/locales/mer/mer.go | 518 ++ .../go-playground/locales/mer/mer_test.go | 1120 +++ .../go-playground/locales/mer_KE/mer_KE.go | 518 ++ .../locales/mer_KE/mer_KE_test.go | 1120 +++ .../go-playground/locales/mfe/mfe.go | 484 ++ .../go-playground/locales/mfe/mfe_test.go | 1120 +++ .../go-playground/locales/mfe_MU/mfe_MU.go | 484 ++ .../locales/mfe_MU/mfe_MU_test.go | 1120 +++ .../github.com/go-playground/locales/mg/mg.go | 586 ++ .../go-playground/locales/mg/mg_test.go | 1120 +++ .../go-playground/locales/mg_MG/mg_MG.go | 586 ++ .../go-playground/locales/mg_MG/mg_MG_test.go | 1120 +++ .../go-playground/locales/mgh/mgh.go | 497 ++ .../go-playground/locales/mgh/mgh_test.go | 1120 +++ .../go-playground/locales/mgh_MZ/mgh_MZ.go | 497 ++ .../locales/mgh_MZ/mgh_MZ_test.go | 1120 +++ .../go-playground/locales/mgo/mgo.go | 607 ++ .../go-playground/locales/mgo/mgo_test.go | 1120 +++ .../go-playground/locales/mgo_CM/mgo_CM.go | 607 ++ .../locales/mgo_CM/mgo_CM_test.go | 1120 +++ .../github.com/go-playground/locales/mk/mk.go | 613 ++ .../go-playground/locales/mk/mk_test.go | 1120 +++ .../go-playground/locales/mk_MK/mk_MK.go | 613 ++ .../go-playground/locales/mk_MK/mk_MK_test.go | 1120 +++ .../github.com/go-playground/locales/ml/ml.go | 641 ++ .../go-playground/locales/ml/ml_test.go | 1120 +++ .../go-playground/locales/ml_IN/ml_IN.go | 641 ++ .../go-playground/locales/ml_IN/ml_IN_test.go | 1120 +++ .../github.com/go-playground/locales/mn/mn.go | 625 ++ .../go-playground/locales/mn/mn_test.go | 1120 +++ .../go-playground/locales/mn_MN/mn_MN.go | 625 ++ .../go-playground/locales/mn_MN/mn_MN_test.go | 1120 +++ .../github.com/go-playground/locales/mr/mr.go | 645 ++ .../go-playground/locales/mr/mr_test.go | 1120 +++ .../go-playground/locales/mr_IN/mr_IN.go | 645 ++ .../go-playground/locales/mr_IN/mr_IN_test.go | 1120 +++ .../github.com/go-playground/locales/ms/ms.go | 627 ++ .../go-playground/locales/ms/ms_test.go | 1120 +++ .../go-playground/locales/ms_BN/ms_BN.go | 637 ++ .../go-playground/locales/ms_BN/ms_BN_test.go | 1120 +++ .../go-playground/locales/ms_MY/ms_MY.go | 627 ++ .../go-playground/locales/ms_MY/ms_MY_test.go | 1120 +++ .../go-playground/locales/ms_SG/ms_SG.go | 627 ++ .../go-playground/locales/ms_SG/ms_SG_test.go | 1120 +++ .../github.com/go-playground/locales/mt/mt.go | 596 ++ .../go-playground/locales/mt/mt_test.go | 1120 +++ .../go-playground/locales/mt_MT/mt_MT.go | 596 ++ .../go-playground/locales/mt_MT/mt_MT_test.go | 1120 +++ .../go-playground/locales/mua/mua.go | 570 ++ .../go-playground/locales/mua/mua_test.go | 1120 +++ .../go-playground/locales/mua_CM/mua_CM.go | 570 ++ .../locales/mua_CM/mua_CM_test.go | 1120 +++ .../github.com/go-playground/locales/my/my.go | 593 ++ .../go-playground/locales/my/my_test.go | 1120 +++ .../go-playground/locales/my_MM/my_MM.go | 593 ++ .../go-playground/locales/my_MM/my_MM_test.go | 1120 +++ .../go-playground/locales/mzn/mzn.go | 256 + .../go-playground/locales/mzn/mzn_test.go | 1120 +++ .../go-playground/locales/mzn_IR/mzn_IR.go | 256 + .../locales/mzn_IR/mzn_IR_test.go | 1120 +++ .../go-playground/locales/naq/naq.go | 557 ++ .../go-playground/locales/naq/naq_test.go | 1120 +++ .../go-playground/locales/naq_NA/naq_NA.go | 557 ++ .../locales/naq_NA/naq_NA_test.go | 1120 +++ .../github.com/go-playground/locales/nb/nb.go | 619 ++ .../go-playground/locales/nb/nb_test.go | 1120 +++ .../go-playground/locales/nb_NO/nb_NO.go | 619 ++ .../go-playground/locales/nb_NO/nb_NO_test.go | 1120 +++ .../go-playground/locales/nb_SJ/nb_SJ.go | 619 ++ .../go-playground/locales/nb_SJ/nb_SJ_test.go | 1120 +++ .../github.com/go-playground/locales/nd/nd.go | 523 ++ .../go-playground/locales/nd/nd_test.go | 1120 +++ .../go-playground/locales/nd_ZW/nd_ZW.go | 523 ++ .../go-playground/locales/nd_ZW/nd_ZW_test.go | 1120 +++ .../go-playground/locales/nds/nds.go | 576 ++ .../go-playground/locales/nds/nds_test.go | 1120 +++ .../go-playground/locales/nds_DE/nds_DE.go | 576 ++ .../locales/nds_DE/nds_DE_test.go | 1120 +++ .../go-playground/locales/nds_NL/nds_NL.go | 576 ++ .../locales/nds_NL/nds_NL_test.go | 1120 +++ .../github.com/go-playground/locales/ne/ne.go | 620 ++ .../go-playground/locales/ne/ne_test.go | 1120 +++ .../go-playground/locales/ne_IN/ne_IN.go | 658 ++ .../go-playground/locales/ne_IN/ne_IN_test.go | 1120 +++ .../go-playground/locales/ne_NP/ne_NP.go | 620 ++ .../go-playground/locales/ne_NP/ne_NP_test.go | 1120 +++ .../github.com/go-playground/locales/nl/nl.go | 604 ++ .../go-playground/locales/nl/nl_test.go | 1120 +++ .../go-playground/locales/nl_AW/nl_AW.go | 604 ++ .../go-playground/locales/nl_AW/nl_AW_test.go | 1120 +++ .../go-playground/locales/nl_BE/nl_BE.go | 600 ++ .../go-playground/locales/nl_BE/nl_BE_test.go | 1120 +++ .../go-playground/locales/nl_BQ/nl_BQ.go | 604 ++ .../go-playground/locales/nl_BQ/nl_BQ_test.go | 1120 +++ .../go-playground/locales/nl_CW/nl_CW.go | 604 ++ .../go-playground/locales/nl_CW/nl_CW_test.go | 1120 +++ .../go-playground/locales/nl_NL/nl_NL.go | 604 ++ .../go-playground/locales/nl_NL/nl_NL_test.go | 1120 +++ .../go-playground/locales/nl_SR/nl_SR.go | 604 ++ .../go-playground/locales/nl_SR/nl_SR_test.go | 1120 +++ .../go-playground/locales/nl_SX/nl_SX.go | 604 ++ .../go-playground/locales/nl_SX/nl_SX_test.go | 1120 +++ .../go-playground/locales/nmg/nmg.go | 570 ++ .../go-playground/locales/nmg/nmg_test.go | 1120 +++ .../go-playground/locales/nmg_CM/nmg_CM.go | 570 ++ .../locales/nmg_CM/nmg_CM_test.go | 1120 +++ .../github.com/go-playground/locales/nn/nn.go | 609 ++ .../go-playground/locales/nn/nn_test.go | 1120 +++ .../go-playground/locales/nn_NO/nn_NO.go | 609 ++ .../go-playground/locales/nn_NO/nn_NO_test.go | 1120 +++ .../go-playground/locales/nnh/nnh.go | 489 ++ .../go-playground/locales/nnh/nnh_test.go | 1120 +++ .../go-playground/locales/nnh_CM/nnh_CM.go | 489 ++ .../locales/nnh_CM/nnh_CM_test.go | 1120 +++ .../go-playground/locales/nus/nus.go | 614 ++ .../go-playground/locales/nus/nus_test.go | 1120 +++ .../go-playground/locales/nus_SS/nus_SS.go | 614 ++ .../locales/nus_SS/nus_SS_test.go | 1120 +++ .../go-playground/locales/nyn/nyn.go | 515 ++ .../go-playground/locales/nyn/nyn_test.go | 1120 +++ .../go-playground/locales/nyn_UG/nyn_UG.go | 515 ++ .../locales/nyn_UG/nyn_UG_test.go | 1120 +++ .../github.com/go-playground/locales/om/om.go | 631 ++ .../go-playground/locales/om/om_test.go | 1120 +++ .../go-playground/locales/om_ET/om_ET.go | 631 ++ .../go-playground/locales/om_ET/om_ET_test.go | 1120 +++ .../go-playground/locales/om_KE/om_KE.go | 593 ++ .../go-playground/locales/om_KE/om_KE_test.go | 1120 +++ .../github.com/go-playground/locales/or/or.go | 648 ++ .../go-playground/locales/or/or_test.go | 1120 +++ .../go-playground/locales/or_IN/or_IN.go | 648 ++ .../go-playground/locales/or_IN/or_IN_test.go | 1120 +++ .../github.com/go-playground/locales/os/os.go | 615 ++ .../go-playground/locales/os/os_test.go | 1120 +++ .../go-playground/locales/os_GE/os_GE.go | 615 ++ .../go-playground/locales/os_GE/os_GE_test.go | 1120 +++ .../go-playground/locales/os_RU/os_RU.go | 615 ++ .../go-playground/locales/os_RU/os_RU_test.go | 1120 +++ .../github.com/go-playground/locales/pa/pa.go | 653 ++ .../go-playground/locales/pa/pa_test.go | 1120 +++ .../go-playground/locales/pa_Arab/pa_Arab.go | 643 ++ .../locales/pa_Arab/pa_Arab_test.go | 1120 +++ .../locales/pa_Arab_PK/pa_Arab_PK.go | 653 ++ .../locales/pa_Arab_PK/pa_Arab_PK_test.go | 1120 +++ .../go-playground/locales/pa_Guru/pa_Guru.go | 653 ++ .../locales/pa_Guru/pa_Guru_test.go | 1120 +++ .../locales/pa_Guru_IN/pa_Guru_IN.go | 653 ++ .../locales/pa_Guru_IN/pa_Guru_IN_test.go | 1120 +++ .../github.com/go-playground/locales/pl/pl.go | 636 ++ .../go-playground/locales/pl/pl_test.go | 1120 +++ .../go-playground/locales/pl_PL/pl_PL.go | 636 ++ .../go-playground/locales/pl_PL/pl_PL_test.go | 1120 +++ .../go-playground/locales/prg/prg.go | 611 ++ .../go-playground/locales/prg/prg_test.go | 1120 +++ .../go-playground/locales/prg_001/prg_001.go | 611 ++ .../locales/prg_001/prg_001_test.go | 1120 +++ .../github.com/go-playground/locales/ps/ps.go | 590 ++ .../go-playground/locales/ps/ps_test.go | 1120 +++ .../go-playground/locales/ps_AF/ps_AF.go | 590 ++ .../go-playground/locales/ps_AF/ps_AF_test.go | 1120 +++ .../github.com/go-playground/locales/pt/pt.go | 612 ++ .../go-playground/locales/pt/pt_test.go | 1120 +++ .../go-playground/locales/pt_AO/pt_AO.go | 612 ++ .../go-playground/locales/pt_AO/pt_AO_test.go | 1120 +++ .../go-playground/locales/pt_BR/pt_BR.go | 612 ++ .../go-playground/locales/pt_BR/pt_BR_test.go | 1120 +++ .../go-playground/locales/pt_CH/pt_CH.go | 612 ++ .../go-playground/locales/pt_CH/pt_CH_test.go | 1120 +++ .../go-playground/locales/pt_CV/pt_CV.go | 612 ++ .../go-playground/locales/pt_CV/pt_CV_test.go | 1120 +++ .../go-playground/locales/pt_GQ/pt_GQ.go | 612 ++ .../go-playground/locales/pt_GQ/pt_GQ_test.go | 1120 +++ .../go-playground/locales/pt_GW/pt_GW.go | 612 ++ .../go-playground/locales/pt_GW/pt_GW_test.go | 1120 +++ .../go-playground/locales/pt_LU/pt_LU.go | 612 ++ .../go-playground/locales/pt_LU/pt_LU_test.go | 1120 +++ .../go-playground/locales/pt_MO/pt_MO.go | 650 ++ .../go-playground/locales/pt_MO/pt_MO_test.go | 1120 +++ .../go-playground/locales/pt_MZ/pt_MZ.go | 612 ++ .../go-playground/locales/pt_MZ/pt_MZ_test.go | 1120 +++ .../go-playground/locales/pt_PT/pt_PT.go | 623 ++ .../go-playground/locales/pt_PT/pt_PT_test.go | 1120 +++ .../go-playground/locales/pt_ST/pt_ST.go | 612 ++ .../go-playground/locales/pt_ST/pt_ST_test.go | 1120 +++ .../go-playground/locales/pt_TL/pt_TL.go | 612 ++ .../go-playground/locales/pt_TL/pt_TL_test.go | 1120 +++ .../github.com/go-playground/locales/qu/qu.go | 598 ++ .../go-playground/locales/qu/qu_test.go | 1120 +++ .../go-playground/locales/qu_BO/qu_BO.go | 598 ++ .../go-playground/locales/qu_BO/qu_BO_test.go | 1120 +++ .../go-playground/locales/qu_EC/qu_EC.go | 598 ++ .../go-playground/locales/qu_EC/qu_EC_test.go | 1120 +++ .../go-playground/locales/qu_PE/qu_PE.go | 598 ++ .../go-playground/locales/qu_PE/qu_PE_test.go | 1120 +++ .../github.com/go-playground/locales/rm/rm.go | 619 ++ .../go-playground/locales/rm/rm_test.go | 1120 +++ .../go-playground/locales/rm_CH/rm_CH.go | 619 ++ .../go-playground/locales/rm_CH/rm_CH_test.go | 1120 +++ .../github.com/go-playground/locales/rn/rn.go | 559 ++ .../go-playground/locales/rn/rn_test.go | 1120 +++ .../go-playground/locales/rn_BI/rn_BI.go | 559 ++ .../go-playground/locales/rn_BI/rn_BI_test.go | 1120 +++ .../github.com/go-playground/locales/ro/ro.go | 624 ++ .../go-playground/locales/ro/ro_test.go | 1120 +++ .../go-playground/locales/ro_MD/ro_MD.go | 624 ++ .../go-playground/locales/ro_MD/ro_MD_test.go | 1120 +++ .../go-playground/locales/ro_RO/ro_RO.go | 624 ++ .../go-playground/locales/ro_RO/ro_RO_test.go | 1120 +++ .../go-playground/locales/rof/rof.go | 517 ++ .../go-playground/locales/rof/rof_test.go | 1120 +++ .../go-playground/locales/rof_TZ/rof_TZ.go | 517 ++ .../locales/rof_TZ/rof_TZ_test.go | 1120 +++ .../go-playground/locales/root/root.go | 410 + .../go-playground/locales/root/root_test.go | 1120 +++ .../github.com/go-playground/locales/ru/ru.go | 631 ++ .../go-playground/locales/ru/ru_test.go | 1120 +++ .../go-playground/locales/ru_BY/ru_BY.go | 631 ++ .../go-playground/locales/ru_BY/ru_BY_test.go | 1120 +++ .../go-playground/locales/ru_KG/ru_KG.go | 631 ++ .../go-playground/locales/ru_KG/ru_KG_test.go | 1120 +++ .../go-playground/locales/ru_KZ/ru_KZ.go | 631 ++ .../go-playground/locales/ru_KZ/ru_KZ_test.go | 1120 +++ .../go-playground/locales/ru_MD/ru_MD.go | 631 ++ .../go-playground/locales/ru_MD/ru_MD_test.go | 1120 +++ .../go-playground/locales/ru_RU/ru_RU.go | 631 ++ .../go-playground/locales/ru_RU/ru_RU_test.go | 1281 +++ .../go-playground/locales/ru_UA/ru_UA.go | 647 ++ .../go-playground/locales/ru_UA/ru_UA_test.go | 1120 +++ .../github.com/go-playground/locales/rules.go | 293 + .../github.com/go-playground/locales/rw/rw.go | 595 ++ .../go-playground/locales/rw/rw_test.go | 1120 +++ .../go-playground/locales/rw_RW/rw_RW.go | 595 ++ .../go-playground/locales/rw_RW/rw_RW_test.go | 1120 +++ .../go-playground/locales/rwk/rwk.go | 512 ++ .../go-playground/locales/rwk/rwk_test.go | 1120 +++ .../go-playground/locales/rwk_TZ/rwk_TZ.go | 512 ++ .../locales/rwk_TZ/rwk_TZ_test.go | 1120 +++ .../go-playground/locales/sah/sah.go | 579 ++ .../go-playground/locales/sah/sah_test.go | 1120 +++ .../go-playground/locales/sah_RU/sah_RU.go | 579 ++ .../locales/sah_RU/sah_RU_test.go | 1120 +++ .../go-playground/locales/saq/saq.go | 525 ++ .../go-playground/locales/saq/saq_test.go | 1120 +++ .../go-playground/locales/saq_KE/saq_KE.go | 525 ++ .../locales/saq_KE/saq_KE_test.go | 1120 +++ .../go-playground/locales/sbp/sbp.go | 566 ++ .../go-playground/locales/sbp/sbp_test.go | 1120 +++ .../go-playground/locales/sbp_TZ/sbp_TZ.go | 566 ++ .../locales/sbp_TZ/sbp_TZ_test.go | 1120 +++ .../github.com/go-playground/locales/se/se.go | 609 ++ .../go-playground/locales/se/se_test.go | 1120 +++ .../go-playground/locales/se_FI/se_FI.go | 609 ++ .../go-playground/locales/se_FI/se_FI_test.go | 1120 +++ .../go-playground/locales/se_NO/se_NO.go | 609 ++ .../go-playground/locales/se_NO/se_NO_test.go | 1120 +++ .../go-playground/locales/se_SE/se_SE.go | 609 ++ .../go-playground/locales/se_SE/se_SE_test.go | 1120 +++ .../go-playground/locales/seh/seh.go | 508 ++ .../go-playground/locales/seh/seh_test.go | 1120 +++ .../go-playground/locales/seh_MZ/seh_MZ.go | 508 ++ .../locales/seh_MZ/seh_MZ_test.go | 1120 +++ .../go-playground/locales/ses/ses.go | 500 ++ .../go-playground/locales/ses/ses_test.go | 1120 +++ .../go-playground/locales/ses_ML/ses_ML.go | 500 ++ .../locales/ses_ML/ses_ML_test.go | 1120 +++ .../github.com/go-playground/locales/sg/sg.go | 502 ++ .../go-playground/locales/sg/sg_test.go | 1120 +++ .../go-playground/locales/sg_CF/sg_CF.go | 502 ++ .../go-playground/locales/sg_CF/sg_CF_test.go | 1120 +++ .../go-playground/locales/shi/shi.go | 424 + .../go-playground/locales/shi/shi_test.go | 1120 +++ .../locales/shi_Latn/shi_Latn.go | 424 + .../locales/shi_Latn/shi_Latn_test.go | 1120 +++ .../locales/shi_Latn_MA/shi_Latn_MA.go | 424 + .../locales/shi_Latn_MA/shi_Latn_MA_test.go | 1120 +++ .../locales/shi_Tfng/shi_Tfng.go | 424 + .../locales/shi_Tfng/shi_Tfng_test.go | 1120 +++ .../locales/shi_Tfng_MA/shi_Tfng_MA.go | 424 + .../locales/shi_Tfng_MA/shi_Tfng_MA_test.go | 1120 +++ .../github.com/go-playground/locales/si/si.go | 609 ++ .../go-playground/locales/si/si_test.go | 1120 +++ .../go-playground/locales/si_LK/si_LK.go | 609 ++ .../go-playground/locales/si_LK/si_LK_test.go | 1120 +++ .../github.com/go-playground/locales/sk/sk.go | 612 ++ .../go-playground/locales/sk/sk_test.go | 1120 +++ .../go-playground/locales/sk_SK/sk_SK.go | 612 ++ .../go-playground/locales/sk_SK/sk_SK_test.go | 1120 +++ .../github.com/go-playground/locales/sl/sl.go | 648 ++ .../go-playground/locales/sl/sl_test.go | 1120 +++ .../go-playground/locales/sl_SI/sl_SI.go | 648 ++ .../go-playground/locales/sl_SI/sl_SI_test.go | 1120 +++ .../go-playground/locales/smn/smn.go | 573 ++ .../go-playground/locales/smn/smn_test.go | 1120 +++ .../go-playground/locales/smn_FI/smn_FI.go | 573 ++ .../locales/smn_FI/smn_FI_test.go | 1120 +++ .../github.com/go-playground/locales/sn/sn.go | 594 ++ .../go-playground/locales/sn/sn_test.go | 1120 +++ .../go-playground/locales/sn_ZW/sn_ZW.go | 594 ++ .../go-playground/locales/sn_ZW/sn_ZW_test.go | 1120 +++ .../github.com/go-playground/locales/so/so.go | 572 ++ .../go-playground/locales/so/so_test.go | 1120 +++ .../go-playground/locales/so_DJ/so_DJ.go | 572 ++ .../go-playground/locales/so_DJ/so_DJ_test.go | 1120 +++ .../go-playground/locales/so_ET/so_ET.go | 572 ++ .../go-playground/locales/so_ET/so_ET_test.go | 1120 +++ .../go-playground/locales/so_KE/so_KE.go | 534 ++ .../go-playground/locales/so_KE/so_KE_test.go | 1120 +++ .../go-playground/locales/so_SO/so_SO.go | 572 ++ .../go-playground/locales/so_SO/so_SO_test.go | 1120 +++ .../github.com/go-playground/locales/sq/sq.go | 646 ++ .../go-playground/locales/sq/sq_test.go | 1120 +++ .../go-playground/locales/sq_AL/sq_AL.go | 646 ++ .../go-playground/locales/sq_AL/sq_AL_test.go | 1120 +++ .../go-playground/locales/sq_MK/sq_MK.go | 608 ++ .../go-playground/locales/sq_MK/sq_MK_test.go | 1120 +++ .../go-playground/locales/sq_XK/sq_XK.go | 608 ++ .../go-playground/locales/sq_XK/sq_XK_test.go | 1120 +++ .../github.com/go-playground/locales/sr/sr.go | 638 ++ .../go-playground/locales/sr/sr_test.go | 1120 +++ .../go-playground/locales/sr_Cyrl/sr_Cyrl.go | 638 ++ .../locales/sr_Cyrl/sr_Cyrl_test.go | 1120 +++ .../locales/sr_Cyrl_BA/sr_Cyrl_BA.go | 638 ++ .../locales/sr_Cyrl_BA/sr_Cyrl_BA_test.go | 1120 +++ .../locales/sr_Cyrl_ME/sr_Cyrl_ME.go | 638 ++ .../locales/sr_Cyrl_ME/sr_Cyrl_ME_test.go | 1120 +++ .../locales/sr_Cyrl_RS/sr_Cyrl_RS.go | 638 ++ .../locales/sr_Cyrl_RS/sr_Cyrl_RS_test.go | 1120 +++ .../locales/sr_Cyrl_XK/sr_Cyrl_XK.go | 638 ++ .../locales/sr_Cyrl_XK/sr_Cyrl_XK_test.go | 1120 +++ .../go-playground/locales/sr_Latn/sr_Latn.go | 638 ++ .../locales/sr_Latn/sr_Latn_test.go | 1120 +++ .../locales/sr_Latn_BA/sr_Latn_BA.go | 638 ++ .../locales/sr_Latn_BA/sr_Latn_BA_test.go | 1120 +++ .../locales/sr_Latn_ME/sr_Latn_ME.go | 638 ++ .../locales/sr_Latn_ME/sr_Latn_ME_test.go | 1120 +++ .../locales/sr_Latn_RS/sr_Latn_RS.go | 638 ++ .../locales/sr_Latn_RS/sr_Latn_RS_test.go | 1120 +++ .../locales/sr_Latn_XK/sr_Latn_XK.go | 638 ++ .../locales/sr_Latn_XK/sr_Latn_XK_test.go | 1120 +++ .../github.com/go-playground/locales/sv/sv.go | 620 ++ .../go-playground/locales/sv/sv_test.go | 1120 +++ .../go-playground/locales/sv_AX/sv_AX.go | 620 ++ .../go-playground/locales/sv_AX/sv_AX_test.go | 1120 +++ .../go-playground/locales/sv_FI/sv_FI.go | 619 ++ .../go-playground/locales/sv_FI/sv_FI_test.go | 1120 +++ .../go-playground/locales/sv_SE/sv_SE.go | 620 ++ .../go-playground/locales/sv_SE/sv_SE_test.go | 1120 +++ .../github.com/go-playground/locales/sw/sw.go | 605 ++ .../go-playground/locales/sw/sw_test.go | 1120 +++ .../go-playground/locales/sw_CD/sw_CD.go | 605 ++ .../go-playground/locales/sw_CD/sw_CD_test.go | 1120 +++ .../go-playground/locales/sw_KE/sw_KE.go | 605 ++ .../go-playground/locales/sw_KE/sw_KE_test.go | 1120 +++ .../go-playground/locales/sw_TZ/sw_TZ.go | 605 ++ .../go-playground/locales/sw_TZ/sw_TZ_test.go | 1120 +++ .../go-playground/locales/sw_UG/sw_UG.go | 605 ++ .../go-playground/locales/sw_UG/sw_UG_test.go | 1120 +++ .../github.com/go-playground/locales/ta/ta.go | 643 ++ .../go-playground/locales/ta/ta_test.go | 1120 +++ .../go-playground/locales/ta_IN/ta_IN.go | 643 ++ .../go-playground/locales/ta_IN/ta_IN_test.go | 1120 +++ .../go-playground/locales/ta_LK/ta_LK.go | 603 ++ .../go-playground/locales/ta_LK/ta_LK_test.go | 1120 +++ .../go-playground/locales/ta_MY/ta_MY.go | 642 ++ .../go-playground/locales/ta_MY/ta_MY_test.go | 1120 +++ .../go-playground/locales/ta_SG/ta_SG.go | 642 ++ .../go-playground/locales/ta_SG/ta_SG_test.go | 1120 +++ .../github.com/go-playground/locales/te/te.go | 670 ++ .../go-playground/locales/te/te_test.go | 1120 +++ .../go-playground/locales/te_IN/te_IN.go | 670 ++ .../go-playground/locales/te_IN/te_IN_test.go | 1120 +++ .../go-playground/locales/teo/teo.go | 525 ++ .../go-playground/locales/teo/teo_test.go | 1120 +++ .../go-playground/locales/teo_KE/teo_KE.go | 525 ++ .../locales/teo_KE/teo_KE_test.go | 1120 +++ .../go-playground/locales/teo_UG/teo_UG.go | 525 ++ .../locales/teo_UG/teo_UG_test.go | 1120 +++ .../github.com/go-playground/locales/th/th.go | 584 ++ .../go-playground/locales/th/th_test.go | 1120 +++ .../go-playground/locales/th_TH/th_TH.go | 584 ++ .../go-playground/locales/th_TH/th_TH_test.go | 1120 +++ .../github.com/go-playground/locales/ti/ti.go | 643 ++ .../go-playground/locales/ti/ti_test.go | 1120 +++ .../go-playground/locales/ti_ER/ti_ER.go | 643 ++ .../go-playground/locales/ti_ER/ti_ER_test.go | 1120 +++ .../go-playground/locales/ti_ET/ti_ET.go | 643 ++ .../go-playground/locales/ti_ET/ti_ET_test.go | 1120 +++ .../github.com/go-playground/locales/tk/tk.go | 592 ++ .../go-playground/locales/tk/tk_test.go | 1120 +++ .../go-playground/locales/tk_TM/tk_TM.go | 592 ++ .../go-playground/locales/tk_TM/tk_TM_test.go | 1120 +++ .../github.com/go-playground/locales/to/to.go | 622 ++ .../go-playground/locales/to/to_test.go | 1120 +++ .../go-playground/locales/to_TO/to_TO.go | 622 ++ .../go-playground/locales/to_TO/to_TO_test.go | 1120 +++ .../github.com/go-playground/locales/tr/tr.go | 614 ++ .../go-playground/locales/tr/tr_test.go | 1120 +++ .../go-playground/locales/tr_CY/tr_CY.go | 652 ++ .../go-playground/locales/tr_CY/tr_CY_test.go | 1120 +++ .../go-playground/locales/tr_TR/tr_TR.go | 614 ++ .../go-playground/locales/tr_TR/tr_TR_test.go | 1120 +++ .../go-playground/locales/twq/twq.go | 563 ++ .../go-playground/locales/twq/twq_test.go | 1120 +++ .../go-playground/locales/twq_NE/twq_NE.go | 563 ++ .../locales/twq_NE/twq_NE_test.go | 1120 +++ .../go-playground/locales/tzm/tzm.go | 440 + .../go-playground/locales/tzm/tzm_test.go | 1120 +++ .../go-playground/locales/tzm_MA/tzm_MA.go | 440 + .../locales/tzm_MA/tzm_MA_test.go | 1120 +++ .../github.com/go-playground/locales/ug/ug.go | 643 ++ .../go-playground/locales/ug/ug_test.go | 1120 +++ .../go-playground/locales/ug_CN/ug_CN.go | 643 ++ .../go-playground/locales/ug_CN/ug_CN_test.go | 1120 +++ .../github.com/go-playground/locales/uk/uk.go | 653 ++ .../go-playground/locales/uk/uk_test.go | 1120 +++ .../go-playground/locales/uk_UA/uk_UA.go | 653 ++ .../go-playground/locales/uk_UA/uk_UA_test.go | 1120 +++ .../github.com/go-playground/locales/ur/ur.go | 622 ++ .../go-playground/locales/ur/ur_test.go | 1120 +++ .../go-playground/locales/ur_IN/ur_IN.go | 656 ++ .../go-playground/locales/ur_IN/ur_IN_test.go | 1120 +++ .../go-playground/locales/ur_PK/ur_PK.go | 622 ++ .../go-playground/locales/ur_PK/ur_PK_test.go | 1120 +++ .../github.com/go-playground/locales/uz/uz.go | 601 ++ .../go-playground/locales/uz/uz_test.go | 1120 +++ .../go-playground/locales/uz_Arab/uz_Arab.go | 592 ++ .../locales/uz_Arab/uz_Arab_test.go | 1120 +++ .../locales/uz_Arab_AF/uz_Arab_AF.go | 601 ++ .../locales/uz_Arab_AF/uz_Arab_AF_test.go | 1120 +++ .../go-playground/locales/uz_Cyrl/uz_Cyrl.go | 622 ++ .../locales/uz_Cyrl/uz_Cyrl_test.go | 1120 +++ .../locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go | 601 ++ .../locales/uz_Cyrl_UZ/uz_Cyrl_UZ_test.go | 1120 +++ .../go-playground/locales/uz_Latn/uz_Latn.go | 601 ++ .../locales/uz_Latn/uz_Latn_test.go | 1120 +++ .../locales/uz_Latn_UZ/uz_Latn_UZ.go | 601 ++ .../locales/uz_Latn_UZ/uz_Latn_UZ_test.go | 1120 +++ .../go-playground/locales/vai/vai.go | 584 ++ .../go-playground/locales/vai/vai_test.go | 1120 +++ .../locales/vai_Latn/vai_Latn.go | 584 ++ .../locales/vai_Latn/vai_Latn_test.go | 1120 +++ .../locales/vai_Latn_LR/vai_Latn_LR.go | 584 ++ .../locales/vai_Latn_LR/vai_Latn_LR_test.go | 1120 +++ .../locales/vai_Vaii/vai_Vaii.go | 584 ++ .../locales/vai_Vaii/vai_Vaii_test.go | 1120 +++ .../locales/vai_Vaii_LR/vai_Vaii_LR.go | 584 ++ .../locales/vai_Vaii_LR/vai_Vaii_LR_test.go | 1120 +++ .../github.com/go-playground/locales/vi/vi.go | 588 ++ .../go-playground/locales/vi/vi_test.go | 1120 +++ .../go-playground/locales/vi_VN/vi_VN.go | 588 ++ .../go-playground/locales/vi_VN/vi_VN_test.go | 1120 +++ .../github.com/go-playground/locales/vo/vo.go | 411 + .../go-playground/locales/vo/vo_test.go | 1120 +++ .../go-playground/locales/vo_001/vo_001.go | 411 + .../locales/vo_001/vo_001_test.go | 1120 +++ .../go-playground/locales/vun/vun.go | 517 ++ .../go-playground/locales/vun/vun_test.go | 1120 +++ .../go-playground/locales/vun_TZ/vun_TZ.go | 517 ++ .../locales/vun_TZ/vun_TZ_test.go | 1120 +++ .../go-playground/locales/wae/wae.go | 395 + .../go-playground/locales/wae/wae_test.go | 1120 +++ .../go-playground/locales/wae_CH/wae_CH.go | 395 + .../locales/wae_CH/wae_CH_test.go | 1120 +++ .../go-playground/locales/xog/xog.go | 520 ++ .../go-playground/locales/xog/xog_test.go | 1120 +++ .../go-playground/locales/xog_UG/xog_UG.go | 520 ++ .../locales/xog_UG/xog_UG_test.go | 1120 +++ .../go-playground/locales/yav/yav.go | 572 ++ .../go-playground/locales/yav/yav_test.go | 1120 +++ .../go-playground/locales/yav_CM/yav_CM.go | 572 ++ .../locales/yav_CM/yav_CM_test.go | 1120 +++ .../github.com/go-playground/locales/yi/yi.go | 505 ++ .../go-playground/locales/yi/yi_test.go | 1120 +++ .../go-playground/locales/yi_001/yi_001.go | 505 ++ .../locales/yi_001/yi_001_test.go | 1120 +++ .../github.com/go-playground/locales/yo/yo.go | 585 ++ .../go-playground/locales/yo/yo_test.go | 1120 +++ .../go-playground/locales/yo_BJ/yo_BJ.go | 585 ++ .../go-playground/locales/yo_BJ/yo_BJ_test.go | 1120 +++ .../go-playground/locales/yo_NG/yo_NG.go | 585 ++ .../go-playground/locales/yo_NG/yo_NG_test.go | 1120 +++ .../go-playground/locales/yue/yue.go | 606 ++ .../go-playground/locales/yue/yue_test.go | 1120 +++ .../go-playground/locales/yue_HK/yue_HK.go | 606 ++ .../locales/yue_HK/yue_HK_test.go | 1120 +++ .../go-playground/locales/zgh/zgh.go | 573 ++ .../go-playground/locales/zgh/zgh_test.go | 1120 +++ .../go-playground/locales/zgh_MA/zgh_MA.go | 573 ++ .../locales/zgh_MA/zgh_MA_test.go | 1120 +++ .../github.com/go-playground/locales/zh/zh.go | 604 ++ .../go-playground/locales/zh/zh_test.go | 1120 +++ .../go-playground/locales/zh_Hans/zh_Hans.go | 604 ++ .../locales/zh_Hans/zh_Hans_test.go | 1120 +++ .../locales/zh_Hans_CN/zh_Hans_CN.go | 604 ++ .../locales/zh_Hans_CN/zh_Hans_CN_test.go | 1120 +++ .../locales/zh_Hans_HK/zh_Hans_HK.go | 604 ++ .../locales/zh_Hans_HK/zh_Hans_HK_test.go | 1120 +++ .../locales/zh_Hans_MO/zh_Hans_MO.go | 604 ++ .../locales/zh_Hans_MO/zh_Hans_MO_test.go | 1120 +++ .../locales/zh_Hans_SG/zh_Hans_SG.go | 614 ++ .../locales/zh_Hans_SG/zh_Hans_SG_test.go | 1120 +++ .../go-playground/locales/zh_Hant/zh_Hant.go | 606 ++ .../locales/zh_Hant/zh_Hant_test.go | 1120 +++ .../locales/zh_Hant_HK/zh_Hant_HK.go | 573 ++ .../locales/zh_Hant_HK/zh_Hant_HK_test.go | 1120 +++ .../locales/zh_Hant_MO/zh_Hant_MO.go | 604 ++ .../locales/zh_Hant_MO/zh_Hant_MO_test.go | 1120 +++ .../locales/zh_Hant_TW/zh_Hant_TW.go | 604 ++ .../locales/zh_Hant_TW/zh_Hant_TW_test.go | 1120 +++ .../github.com/go-playground/locales/zu/zu.go | 595 ++ .../go-playground/locales/zu/zu_test.go | 1120 +++ .../go-playground/locales/zu_ZA/zu_ZA.go | 595 ++ .../go-playground/locales/zu_ZA/zu_ZA_test.go | 1120 +++ .../universal-translator/.gitignore | 24 + .../universal-translator/LICENSE | 21 + .../universal-translator/README.md | 90 + .../universal-translator/benchmarks_test.go | 110 + .../universal-translator/errors.go | 148 + .../examples/basic/main.go | 70 + .../examples/file-formats/cardinal.json | 16 + .../examples/file-formats/ordinal.json | 30 + .../file-formats/plain-substitution.json | 27 + .../examples/file-formats/range.json | 16 + .../examples/full-no-files/home.tmpl | 35 + .../examples/full-no-files/main.go | 210 + .../examples/full-with-files/home.tmpl | 35 + .../examples/full-with-files/main.go | 207 + .../full-with-files/translations/en/home.json | 16 + .../full-with-files/translations/fr/home.json | 16 + .../universal-translator/import_export.go | 274 + .../import_export_test.go | 789 ++ .../universal-translator/logo.png | Bin 0 -> 16598 bytes .../universal-translator/testdata/.gitignore | 11 + .../testdata/bad-translation1.json | 7 + .../testdata/bad-translation2.json | 7 + .../testdata/bad-translation3.json | 7 + .../testdata/bad-translation4.json | 9 + .../testdata/bad-translation5.json | 9 + .../testdata/bad-translation6.json | 9 + .../testdata/nested1/nested1.json | 12 + .../testdata/nested1/nested2/nested2.json | 17 + .../nested1/nested2/unrelated-file.txt | 0 .../universal-translator/translator.go | 420 + .../universal-translator/translator_test.go | 858 ++ .../universal_translator.go | 113 + .../validator.v9/.github/CONTRIBUTING.md | 9 + .../validator.v9/.github/ISSUE_TEMPLATE.md | 13 + .../.github/PULL_REQUEST_TEMPLATE.md | 13 + .../go-playground/validator.v9/.gitignore | 29 + .../go-playground/validator.v9/LICENSE | 22 + .../go-playground/validator.v9/README.md | 139 + .../validator.v9/_examples/custom/main.go | 51 + .../gin-upgrading-overriding/main.go | 10 + .../gin-upgrading-overriding/v8_to_v9.go | 50 + .../validator.v9/_examples/simple/main.go | 101 + .../_examples/struct-level/main.go | 109 + .../_examples/translations/main.go | 129 + .../go-playground/validator.v9/baked_in.go | 1469 ++++ .../validator.v9/benchmarks_test.go | 1080 +++ .../go-playground/validator.v9/cache.go | 267 + .../go-playground/validator.v9/doc.go | 841 ++ .../go-playground/validator.v9/errors.go | 270 + .../validator.v9/examples_test.go | 83 + .../go-playground/validator.v9/field_level.go | 69 + .../go-playground/validator.v9/logo.png | Bin 0 -> 13443 bytes .../go-playground/validator.v9/regexes.go | 63 + .../validator.v9/struct_level.go | 166 + .../validator.v9/translations.go | 11 + .../validator.v9/translations/en/en.go | 1306 +++ .../validator.v9/translations/en/en_test.go | 585 ++ .../go-playground/validator.v9/util.go | 257 + .../go-playground/validator.v9/validator.go | 444 ++ .../validator.v9/validator_instance.go | 535 ++ .../validator.v9/validator_test.go | 7081 +++++++++++++++++ 1656 files changed, 1292457 insertions(+), 358 deletions(-) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/README.md create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/create.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/paging/paging.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/recoverypoints.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationalertsettings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationevents.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationfabrics.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationjobs.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationlogicalnetworks.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationnetworkmappings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationnetworks.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationpolicies.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectableitems.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotecteditems.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectioncontainermappings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectioncontainers.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationrecoveryplans.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationrecoveryservicesproviders.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationstorageclassificationmappings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationstorageclassifications.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationvcenters.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/version.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/appliancedefinitions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/appliances.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/version.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/accesscontrolrecords.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/alerts.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backuppolicies.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backups.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backupschedules.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/bandwidthsettings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/cloudappliances.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/devices.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/devicesettings.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/hardwarecomponentgroups.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/jobs.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/managers.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/storageaccountcredentials.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/version.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/volumecontainers.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/volumes.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/functions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/inputs.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/outputs.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/streamingjobs.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/subscriptions.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/transformations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/version.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/buildTerraform.sh create mode 100644 vendor/github.com/Azure/go-autorest/autorest/retriablerequest.go create mode 100644 vendor/github.com/go-playground/locales/.gitignore create mode 100644 vendor/github.com/go-playground/locales/LICENSE create mode 100644 vendor/github.com/go-playground/locales/README.md create mode 100644 vendor/github.com/go-playground/locales/af/af.go create mode 100644 vendor/github.com/go-playground/locales/af/af_test.go create mode 100644 vendor/github.com/go-playground/locales/af_NA/af_NA.go create mode 100644 vendor/github.com/go-playground/locales/af_NA/af_NA_test.go create mode 100644 vendor/github.com/go-playground/locales/af_ZA/af_ZA.go create mode 100644 vendor/github.com/go-playground/locales/af_ZA/af_ZA_test.go create mode 100644 vendor/github.com/go-playground/locales/agq/agq.go create mode 100644 vendor/github.com/go-playground/locales/agq/agq_test.go create mode 100644 vendor/github.com/go-playground/locales/agq_CM/agq_CM.go create mode 100644 vendor/github.com/go-playground/locales/agq_CM/agq_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/ak/ak.go create mode 100644 vendor/github.com/go-playground/locales/ak/ak_test.go create mode 100644 vendor/github.com/go-playground/locales/ak_GH/ak_GH.go create mode 100644 vendor/github.com/go-playground/locales/ak_GH/ak_GH_test.go create mode 100644 vendor/github.com/go-playground/locales/am/am.go create mode 100644 vendor/github.com/go-playground/locales/am/am_test.go create mode 100644 vendor/github.com/go-playground/locales/am_ET/am_ET.go create mode 100644 vendor/github.com/go-playground/locales/am_ET/am_ET_test.go create mode 100644 vendor/github.com/go-playground/locales/ar/ar.go create mode 100644 vendor/github.com/go-playground/locales/ar/ar_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_001/ar_001.go create mode 100644 vendor/github.com/go-playground/locales/ar_001/ar_001_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_AE/ar_AE.go create mode 100644 vendor/github.com/go-playground/locales/ar_AE/ar_AE_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_BH/ar_BH.go create mode 100644 vendor/github.com/go-playground/locales/ar_BH/ar_BH_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_DJ/ar_DJ.go create mode 100644 vendor/github.com/go-playground/locales/ar_DJ/ar_DJ_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_DZ/ar_DZ.go create mode 100644 vendor/github.com/go-playground/locales/ar_DZ/ar_DZ_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_EG/ar_EG.go create mode 100644 vendor/github.com/go-playground/locales/ar_EG/ar_EG_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_EH/ar_EH.go create mode 100644 vendor/github.com/go-playground/locales/ar_EH/ar_EH_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_ER/ar_ER.go create mode 100644 vendor/github.com/go-playground/locales/ar_ER/ar_ER_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_IL/ar_IL.go create mode 100644 vendor/github.com/go-playground/locales/ar_IL/ar_IL_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_IQ/ar_IQ.go create mode 100644 vendor/github.com/go-playground/locales/ar_IQ/ar_IQ_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_JO/ar_JO.go create mode 100644 vendor/github.com/go-playground/locales/ar_JO/ar_JO_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_KM/ar_KM.go create mode 100644 vendor/github.com/go-playground/locales/ar_KM/ar_KM_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_KW/ar_KW.go create mode 100644 vendor/github.com/go-playground/locales/ar_KW/ar_KW_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_LB/ar_LB.go create mode 100644 vendor/github.com/go-playground/locales/ar_LB/ar_LB_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_LY/ar_LY.go create mode 100644 vendor/github.com/go-playground/locales/ar_LY/ar_LY_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_MA/ar_MA.go create mode 100644 vendor/github.com/go-playground/locales/ar_MA/ar_MA_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_MR/ar_MR.go create mode 100644 vendor/github.com/go-playground/locales/ar_MR/ar_MR_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_OM/ar_OM.go create mode 100644 vendor/github.com/go-playground/locales/ar_OM/ar_OM_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_PS/ar_PS.go create mode 100644 vendor/github.com/go-playground/locales/ar_PS/ar_PS_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_QA/ar_QA.go create mode 100644 vendor/github.com/go-playground/locales/ar_QA/ar_QA_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_SA/ar_SA.go create mode 100644 vendor/github.com/go-playground/locales/ar_SA/ar_SA_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_SD/ar_SD.go create mode 100644 vendor/github.com/go-playground/locales/ar_SD/ar_SD_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_SO/ar_SO.go create mode 100644 vendor/github.com/go-playground/locales/ar_SO/ar_SO_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_SS/ar_SS.go create mode 100644 vendor/github.com/go-playground/locales/ar_SS/ar_SS_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_SY/ar_SY.go create mode 100644 vendor/github.com/go-playground/locales/ar_SY/ar_SY_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_TD/ar_TD.go create mode 100644 vendor/github.com/go-playground/locales/ar_TD/ar_TD_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_TN/ar_TN.go create mode 100644 vendor/github.com/go-playground/locales/ar_TN/ar_TN_test.go create mode 100644 vendor/github.com/go-playground/locales/ar_YE/ar_YE.go create mode 100644 vendor/github.com/go-playground/locales/ar_YE/ar_YE_test.go create mode 100644 vendor/github.com/go-playground/locales/as/as.go create mode 100644 vendor/github.com/go-playground/locales/as/as_test.go create mode 100644 vendor/github.com/go-playground/locales/as_IN/as_IN.go create mode 100644 vendor/github.com/go-playground/locales/as_IN/as_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/asa/asa.go create mode 100644 vendor/github.com/go-playground/locales/asa/asa_test.go create mode 100644 vendor/github.com/go-playground/locales/asa_TZ/asa_TZ.go create mode 100644 vendor/github.com/go-playground/locales/asa_TZ/asa_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/ast/ast.go create mode 100644 vendor/github.com/go-playground/locales/ast/ast_test.go create mode 100644 vendor/github.com/go-playground/locales/ast_ES/ast_ES.go create mode 100644 vendor/github.com/go-playground/locales/ast_ES/ast_ES_test.go create mode 100644 vendor/github.com/go-playground/locales/az/az.go create mode 100644 vendor/github.com/go-playground/locales/az/az_test.go create mode 100644 vendor/github.com/go-playground/locales/az_Cyrl/az_Cyrl.go create mode 100644 vendor/github.com/go-playground/locales/az_Cyrl/az_Cyrl_test.go create mode 100644 vendor/github.com/go-playground/locales/az_Cyrl_AZ/az_Cyrl_AZ.go create mode 100644 vendor/github.com/go-playground/locales/az_Cyrl_AZ/az_Cyrl_AZ_test.go create mode 100644 vendor/github.com/go-playground/locales/az_Latn/az_Latn.go create mode 100644 vendor/github.com/go-playground/locales/az_Latn/az_Latn_test.go create mode 100644 vendor/github.com/go-playground/locales/az_Latn_AZ/az_Latn_AZ.go create mode 100644 vendor/github.com/go-playground/locales/az_Latn_AZ/az_Latn_AZ_test.go create mode 100644 vendor/github.com/go-playground/locales/bas/bas.go create mode 100644 vendor/github.com/go-playground/locales/bas/bas_test.go create mode 100644 vendor/github.com/go-playground/locales/bas_CM/bas_CM.go create mode 100644 vendor/github.com/go-playground/locales/bas_CM/bas_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/be/be.go create mode 100644 vendor/github.com/go-playground/locales/be/be_test.go create mode 100644 vendor/github.com/go-playground/locales/be_BY/be_BY.go create mode 100644 vendor/github.com/go-playground/locales/be_BY/be_BY_test.go create mode 100644 vendor/github.com/go-playground/locales/bem/bem.go create mode 100644 vendor/github.com/go-playground/locales/bem/bem_test.go create mode 100644 vendor/github.com/go-playground/locales/bem_ZM/bem_ZM.go create mode 100644 vendor/github.com/go-playground/locales/bem_ZM/bem_ZM_test.go create mode 100644 vendor/github.com/go-playground/locales/bez/bez.go create mode 100644 vendor/github.com/go-playground/locales/bez/bez_test.go create mode 100644 vendor/github.com/go-playground/locales/bez_TZ/bez_TZ.go create mode 100644 vendor/github.com/go-playground/locales/bez_TZ/bez_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/bg/bg.go create mode 100644 vendor/github.com/go-playground/locales/bg/bg_test.go create mode 100644 vendor/github.com/go-playground/locales/bg_BG/bg_BG.go create mode 100644 vendor/github.com/go-playground/locales/bg_BG/bg_BG_test.go create mode 100644 vendor/github.com/go-playground/locales/bm/bm.go create mode 100644 vendor/github.com/go-playground/locales/bm/bm_test.go create mode 100644 vendor/github.com/go-playground/locales/bm_ML/bm_ML.go create mode 100644 vendor/github.com/go-playground/locales/bm_ML/bm_ML_test.go create mode 100644 vendor/github.com/go-playground/locales/bn/bn.go create mode 100644 vendor/github.com/go-playground/locales/bn/bn_test.go create mode 100644 vendor/github.com/go-playground/locales/bn_BD/bn_BD.go create mode 100644 vendor/github.com/go-playground/locales/bn_BD/bn_BD_test.go create mode 100644 vendor/github.com/go-playground/locales/bn_IN/bn_IN.go create mode 100644 vendor/github.com/go-playground/locales/bn_IN/bn_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/bo/bo.go create mode 100644 vendor/github.com/go-playground/locales/bo/bo_test.go create mode 100644 vendor/github.com/go-playground/locales/bo_CN/bo_CN.go create mode 100644 vendor/github.com/go-playground/locales/bo_CN/bo_CN_test.go create mode 100644 vendor/github.com/go-playground/locales/bo_IN/bo_IN.go create mode 100644 vendor/github.com/go-playground/locales/bo_IN/bo_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/br/br.go create mode 100644 vendor/github.com/go-playground/locales/br/br_test.go create mode 100644 vendor/github.com/go-playground/locales/br_FR/br_FR.go create mode 100644 vendor/github.com/go-playground/locales/br_FR/br_FR_test.go create mode 100644 vendor/github.com/go-playground/locales/brx/brx.go create mode 100644 vendor/github.com/go-playground/locales/brx/brx_test.go create mode 100644 vendor/github.com/go-playground/locales/brx_IN/brx_IN.go create mode 100644 vendor/github.com/go-playground/locales/brx_IN/brx_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/bs/bs.go create mode 100644 vendor/github.com/go-playground/locales/bs/bs_test.go create mode 100644 vendor/github.com/go-playground/locales/bs_Cyrl/bs_Cyrl.go create mode 100644 vendor/github.com/go-playground/locales/bs_Cyrl/bs_Cyrl_test.go create mode 100644 vendor/github.com/go-playground/locales/bs_Cyrl_BA/bs_Cyrl_BA.go create mode 100644 vendor/github.com/go-playground/locales/bs_Cyrl_BA/bs_Cyrl_BA_test.go create mode 100644 vendor/github.com/go-playground/locales/bs_Latn/bs_Latn.go create mode 100644 vendor/github.com/go-playground/locales/bs_Latn/bs_Latn_test.go create mode 100644 vendor/github.com/go-playground/locales/bs_Latn_BA/bs_Latn_BA.go create mode 100644 vendor/github.com/go-playground/locales/bs_Latn_BA/bs_Latn_BA_test.go create mode 100644 vendor/github.com/go-playground/locales/ca/ca.go create mode 100644 vendor/github.com/go-playground/locales/ca/ca_test.go create mode 100644 vendor/github.com/go-playground/locales/ca_AD/ca_AD.go create mode 100644 vendor/github.com/go-playground/locales/ca_AD/ca_AD_test.go create mode 100644 vendor/github.com/go-playground/locales/ca_ES/ca_ES.go create mode 100644 vendor/github.com/go-playground/locales/ca_ES/ca_ES_test.go create mode 100644 vendor/github.com/go-playground/locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go create mode 100644 vendor/github.com/go-playground/locales/ca_ES_VALENCIA/ca_ES_VALENCIA_test.go create mode 100644 vendor/github.com/go-playground/locales/ca_FR/ca_FR.go create mode 100644 vendor/github.com/go-playground/locales/ca_FR/ca_FR_test.go create mode 100644 vendor/github.com/go-playground/locales/ca_IT/ca_IT.go create mode 100644 vendor/github.com/go-playground/locales/ca_IT/ca_IT_test.go create mode 100644 vendor/github.com/go-playground/locales/ce/ce.go create mode 100644 vendor/github.com/go-playground/locales/ce/ce_test.go create mode 100644 vendor/github.com/go-playground/locales/ce_RU/ce_RU.go create mode 100644 vendor/github.com/go-playground/locales/ce_RU/ce_RU_test.go create mode 100644 vendor/github.com/go-playground/locales/cgg/cgg.go create mode 100644 vendor/github.com/go-playground/locales/cgg/cgg_test.go create mode 100644 vendor/github.com/go-playground/locales/cgg_UG/cgg_UG.go create mode 100644 vendor/github.com/go-playground/locales/cgg_UG/cgg_UG_test.go create mode 100644 vendor/github.com/go-playground/locales/chr/chr.go create mode 100644 vendor/github.com/go-playground/locales/chr/chr_test.go create mode 100644 vendor/github.com/go-playground/locales/chr_US/chr_US.go create mode 100644 vendor/github.com/go-playground/locales/chr_US/chr_US_test.go create mode 100644 vendor/github.com/go-playground/locales/ckb/ckb.go create mode 100644 vendor/github.com/go-playground/locales/ckb/ckb_test.go create mode 100644 vendor/github.com/go-playground/locales/ckb_IQ/ckb_IQ.go create mode 100644 vendor/github.com/go-playground/locales/ckb_IQ/ckb_IQ_test.go create mode 100644 vendor/github.com/go-playground/locales/ckb_IR/ckb_IR.go create mode 100644 vendor/github.com/go-playground/locales/ckb_IR/ckb_IR_test.go create mode 100644 vendor/github.com/go-playground/locales/cmd/README.md create mode 100644 vendor/github.com/go-playground/locales/cmd/currency.tmpl create mode 100644 vendor/github.com/go-playground/locales/cmd/data/.gitignore create mode 100644 vendor/github.com/go-playground/locales/cmd/generate_resources.go create mode 100644 vendor/github.com/go-playground/locales/cmd/locale_map.tmpl create mode 100644 vendor/github.com/go-playground/locales/cmd/tests.tmpl create mode 100644 vendor/github.com/go-playground/locales/cmd/translator.tmpl create mode 100644 vendor/github.com/go-playground/locales/cs/cs.go create mode 100644 vendor/github.com/go-playground/locales/cs/cs_test.go create mode 100644 vendor/github.com/go-playground/locales/cs_CZ/cs_CZ.go create mode 100644 vendor/github.com/go-playground/locales/cs_CZ/cs_CZ_test.go create mode 100644 vendor/github.com/go-playground/locales/cu/cu.go create mode 100644 vendor/github.com/go-playground/locales/cu/cu_test.go create mode 100644 vendor/github.com/go-playground/locales/cu_RU/cu_RU.go create mode 100644 vendor/github.com/go-playground/locales/cu_RU/cu_RU_test.go create mode 100644 vendor/github.com/go-playground/locales/currency/currency.go create mode 100644 vendor/github.com/go-playground/locales/cy/cy.go create mode 100644 vendor/github.com/go-playground/locales/cy/cy_test.go create mode 100644 vendor/github.com/go-playground/locales/cy_GB/cy_GB.go create mode 100644 vendor/github.com/go-playground/locales/cy_GB/cy_GB_test.go create mode 100644 vendor/github.com/go-playground/locales/da/da.go create mode 100644 vendor/github.com/go-playground/locales/da/da_test.go create mode 100644 vendor/github.com/go-playground/locales/da_DK/da_DK.go create mode 100644 vendor/github.com/go-playground/locales/da_DK/da_DK_test.go create mode 100644 vendor/github.com/go-playground/locales/da_GL/da_GL.go create mode 100644 vendor/github.com/go-playground/locales/da_GL/da_GL_test.go create mode 100644 vendor/github.com/go-playground/locales/dav/dav.go create mode 100644 vendor/github.com/go-playground/locales/dav/dav_test.go create mode 100644 vendor/github.com/go-playground/locales/dav_KE/dav_KE.go create mode 100644 vendor/github.com/go-playground/locales/dav_KE/dav_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/de/de.go create mode 100644 vendor/github.com/go-playground/locales/de/de_test.go create mode 100644 vendor/github.com/go-playground/locales/de_AT/de_AT.go create mode 100644 vendor/github.com/go-playground/locales/de_AT/de_AT_test.go create mode 100644 vendor/github.com/go-playground/locales/de_BE/de_BE.go create mode 100644 vendor/github.com/go-playground/locales/de_BE/de_BE_test.go create mode 100644 vendor/github.com/go-playground/locales/de_CH/de_CH.go create mode 100644 vendor/github.com/go-playground/locales/de_CH/de_CH_test.go create mode 100644 vendor/github.com/go-playground/locales/de_DE/de_DE.go create mode 100644 vendor/github.com/go-playground/locales/de_DE/de_DE_test.go create mode 100644 vendor/github.com/go-playground/locales/de_IT/de_IT.go create mode 100644 vendor/github.com/go-playground/locales/de_IT/de_IT_test.go create mode 100644 vendor/github.com/go-playground/locales/de_LI/de_LI.go create mode 100644 vendor/github.com/go-playground/locales/de_LI/de_LI_test.go create mode 100644 vendor/github.com/go-playground/locales/de_LU/de_LU.go create mode 100644 vendor/github.com/go-playground/locales/de_LU/de_LU_test.go create mode 100644 vendor/github.com/go-playground/locales/dje/dje.go create mode 100644 vendor/github.com/go-playground/locales/dje/dje_test.go create mode 100644 vendor/github.com/go-playground/locales/dje_NE/dje_NE.go create mode 100644 vendor/github.com/go-playground/locales/dje_NE/dje_NE_test.go create mode 100644 vendor/github.com/go-playground/locales/dsb/dsb.go create mode 100644 vendor/github.com/go-playground/locales/dsb/dsb_test.go create mode 100644 vendor/github.com/go-playground/locales/dsb_DE/dsb_DE.go create mode 100644 vendor/github.com/go-playground/locales/dsb_DE/dsb_DE_test.go create mode 100644 vendor/github.com/go-playground/locales/dua/dua.go create mode 100644 vendor/github.com/go-playground/locales/dua/dua_test.go create mode 100644 vendor/github.com/go-playground/locales/dua_CM/dua_CM.go create mode 100644 vendor/github.com/go-playground/locales/dua_CM/dua_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/dyo/dyo.go create mode 100644 vendor/github.com/go-playground/locales/dyo/dyo_test.go create mode 100644 vendor/github.com/go-playground/locales/dyo_SN/dyo_SN.go create mode 100644 vendor/github.com/go-playground/locales/dyo_SN/dyo_SN_test.go create mode 100644 vendor/github.com/go-playground/locales/dz/dz.go create mode 100644 vendor/github.com/go-playground/locales/dz/dz_test.go create mode 100644 vendor/github.com/go-playground/locales/dz_BT/dz_BT.go create mode 100644 vendor/github.com/go-playground/locales/dz_BT/dz_BT_test.go create mode 100644 vendor/github.com/go-playground/locales/ebu/ebu.go create mode 100644 vendor/github.com/go-playground/locales/ebu/ebu_test.go create mode 100644 vendor/github.com/go-playground/locales/ebu_KE/ebu_KE.go create mode 100644 vendor/github.com/go-playground/locales/ebu_KE/ebu_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/ee/ee.go create mode 100644 vendor/github.com/go-playground/locales/ee/ee_test.go create mode 100644 vendor/github.com/go-playground/locales/ee_GH/ee_GH.go create mode 100644 vendor/github.com/go-playground/locales/ee_GH/ee_GH_test.go create mode 100644 vendor/github.com/go-playground/locales/ee_TG/ee_TG.go create mode 100644 vendor/github.com/go-playground/locales/ee_TG/ee_TG_test.go create mode 100644 vendor/github.com/go-playground/locales/el/el.go create mode 100644 vendor/github.com/go-playground/locales/el/el_test.go create mode 100644 vendor/github.com/go-playground/locales/el_CY/el_CY.go create mode 100644 vendor/github.com/go-playground/locales/el_CY/el_CY_test.go create mode 100644 vendor/github.com/go-playground/locales/el_GR/el_GR.go create mode 100644 vendor/github.com/go-playground/locales/el_GR/el_GR_test.go create mode 100644 vendor/github.com/go-playground/locales/en/benchmarks_test.go create mode 100644 vendor/github.com/go-playground/locales/en/en.go create mode 100644 vendor/github.com/go-playground/locales/en/en_test.go create mode 100644 vendor/github.com/go-playground/locales/en_001/en_001.go create mode 100644 vendor/github.com/go-playground/locales/en_001/en_001_test.go create mode 100644 vendor/github.com/go-playground/locales/en_150/en_150.go create mode 100644 vendor/github.com/go-playground/locales/en_150/en_150_test.go create mode 100644 vendor/github.com/go-playground/locales/en_AG/en_AG.go create mode 100644 vendor/github.com/go-playground/locales/en_AG/en_AG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_AI/en_AI.go create mode 100644 vendor/github.com/go-playground/locales/en_AI/en_AI_test.go create mode 100644 vendor/github.com/go-playground/locales/en_AS/en_AS.go create mode 100644 vendor/github.com/go-playground/locales/en_AS/en_AS_test.go create mode 100644 vendor/github.com/go-playground/locales/en_AT/en_AT.go create mode 100644 vendor/github.com/go-playground/locales/en_AT/en_AT_test.go create mode 100644 vendor/github.com/go-playground/locales/en_AU/en_AU.go create mode 100644 vendor/github.com/go-playground/locales/en_AU/en_AU_test.go create mode 100644 vendor/github.com/go-playground/locales/en_BB/en_BB.go create mode 100644 vendor/github.com/go-playground/locales/en_BB/en_BB_test.go create mode 100644 vendor/github.com/go-playground/locales/en_BE/en_BE.go create mode 100644 vendor/github.com/go-playground/locales/en_BE/en_BE_test.go create mode 100644 vendor/github.com/go-playground/locales/en_BI/en_BI.go create mode 100644 vendor/github.com/go-playground/locales/en_BI/en_BI_test.go create mode 100644 vendor/github.com/go-playground/locales/en_BM/en_BM.go create mode 100644 vendor/github.com/go-playground/locales/en_BM/en_BM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_BS/en_BS.go create mode 100644 vendor/github.com/go-playground/locales/en_BS/en_BS_test.go create mode 100644 vendor/github.com/go-playground/locales/en_BW/en_BW.go create mode 100644 vendor/github.com/go-playground/locales/en_BW/en_BW_test.go create mode 100644 vendor/github.com/go-playground/locales/en_BZ/en_BZ.go create mode 100644 vendor/github.com/go-playground/locales/en_BZ/en_BZ_test.go create mode 100644 vendor/github.com/go-playground/locales/en_CA/en_CA.go create mode 100644 vendor/github.com/go-playground/locales/en_CA/en_CA_test.go create mode 100644 vendor/github.com/go-playground/locales/en_CC/en_CC.go create mode 100644 vendor/github.com/go-playground/locales/en_CC/en_CC_test.go create mode 100644 vendor/github.com/go-playground/locales/en_CH/en_CH.go create mode 100644 vendor/github.com/go-playground/locales/en_CH/en_CH_test.go create mode 100644 vendor/github.com/go-playground/locales/en_CK/en_CK.go create mode 100644 vendor/github.com/go-playground/locales/en_CK/en_CK_test.go create mode 100644 vendor/github.com/go-playground/locales/en_CM/en_CM.go create mode 100644 vendor/github.com/go-playground/locales/en_CM/en_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_CX/en_CX.go create mode 100644 vendor/github.com/go-playground/locales/en_CX/en_CX_test.go create mode 100644 vendor/github.com/go-playground/locales/en_CY/en_CY.go create mode 100644 vendor/github.com/go-playground/locales/en_CY/en_CY_test.go create mode 100644 vendor/github.com/go-playground/locales/en_DE/en_DE.go create mode 100644 vendor/github.com/go-playground/locales/en_DE/en_DE_test.go create mode 100644 vendor/github.com/go-playground/locales/en_DG/en_DG.go create mode 100644 vendor/github.com/go-playground/locales/en_DG/en_DG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_DK/en_DK.go create mode 100644 vendor/github.com/go-playground/locales/en_DK/en_DK_test.go create mode 100644 vendor/github.com/go-playground/locales/en_DM/en_DM.go create mode 100644 vendor/github.com/go-playground/locales/en_DM/en_DM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_ER/en_ER.go create mode 100644 vendor/github.com/go-playground/locales/en_ER/en_ER_test.go create mode 100644 vendor/github.com/go-playground/locales/en_FI/en_FI.go create mode 100644 vendor/github.com/go-playground/locales/en_FI/en_FI_test.go create mode 100644 vendor/github.com/go-playground/locales/en_FJ/en_FJ.go create mode 100644 vendor/github.com/go-playground/locales/en_FJ/en_FJ_test.go create mode 100644 vendor/github.com/go-playground/locales/en_FK/en_FK.go create mode 100644 vendor/github.com/go-playground/locales/en_FK/en_FK_test.go create mode 100644 vendor/github.com/go-playground/locales/en_FM/en_FM.go create mode 100644 vendor/github.com/go-playground/locales/en_FM/en_FM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_GB/en_GB.go create mode 100644 vendor/github.com/go-playground/locales/en_GB/en_GB_test.go create mode 100644 vendor/github.com/go-playground/locales/en_GD/en_GD.go create mode 100644 vendor/github.com/go-playground/locales/en_GD/en_GD_test.go create mode 100644 vendor/github.com/go-playground/locales/en_GG/en_GG.go create mode 100644 vendor/github.com/go-playground/locales/en_GG/en_GG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_GH/en_GH.go create mode 100644 vendor/github.com/go-playground/locales/en_GH/en_GH_test.go create mode 100644 vendor/github.com/go-playground/locales/en_GI/en_GI.go create mode 100644 vendor/github.com/go-playground/locales/en_GI/en_GI_test.go create mode 100644 vendor/github.com/go-playground/locales/en_GM/en_GM.go create mode 100644 vendor/github.com/go-playground/locales/en_GM/en_GM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_GU/en_GU.go create mode 100644 vendor/github.com/go-playground/locales/en_GU/en_GU_test.go create mode 100644 vendor/github.com/go-playground/locales/en_GY/en_GY.go create mode 100644 vendor/github.com/go-playground/locales/en_GY/en_GY_test.go create mode 100644 vendor/github.com/go-playground/locales/en_HK/en_HK.go create mode 100644 vendor/github.com/go-playground/locales/en_HK/en_HK_test.go create mode 100644 vendor/github.com/go-playground/locales/en_IE/en_IE.go create mode 100644 vendor/github.com/go-playground/locales/en_IE/en_IE_test.go create mode 100644 vendor/github.com/go-playground/locales/en_IL/en_IL.go create mode 100644 vendor/github.com/go-playground/locales/en_IL/en_IL_test.go create mode 100644 vendor/github.com/go-playground/locales/en_IM/en_IM.go create mode 100644 vendor/github.com/go-playground/locales/en_IM/en_IM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_IN/en_IN.go create mode 100644 vendor/github.com/go-playground/locales/en_IN/en_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/en_IO/en_IO.go create mode 100644 vendor/github.com/go-playground/locales/en_IO/en_IO_test.go create mode 100644 vendor/github.com/go-playground/locales/en_JE/en_JE.go create mode 100644 vendor/github.com/go-playground/locales/en_JE/en_JE_test.go create mode 100644 vendor/github.com/go-playground/locales/en_JM/en_JM.go create mode 100644 vendor/github.com/go-playground/locales/en_JM/en_JM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_KE/en_KE.go create mode 100644 vendor/github.com/go-playground/locales/en_KE/en_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/en_KI/en_KI.go create mode 100644 vendor/github.com/go-playground/locales/en_KI/en_KI_test.go create mode 100644 vendor/github.com/go-playground/locales/en_KN/en_KN.go create mode 100644 vendor/github.com/go-playground/locales/en_KN/en_KN_test.go create mode 100644 vendor/github.com/go-playground/locales/en_KY/en_KY.go create mode 100644 vendor/github.com/go-playground/locales/en_KY/en_KY_test.go create mode 100644 vendor/github.com/go-playground/locales/en_LC/en_LC.go create mode 100644 vendor/github.com/go-playground/locales/en_LC/en_LC_test.go create mode 100644 vendor/github.com/go-playground/locales/en_LR/en_LR.go create mode 100644 vendor/github.com/go-playground/locales/en_LR/en_LR_test.go create mode 100644 vendor/github.com/go-playground/locales/en_LS/en_LS.go create mode 100644 vendor/github.com/go-playground/locales/en_LS/en_LS_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MG/en_MG.go create mode 100644 vendor/github.com/go-playground/locales/en_MG/en_MG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MH/en_MH.go create mode 100644 vendor/github.com/go-playground/locales/en_MH/en_MH_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MO/en_MO.go create mode 100644 vendor/github.com/go-playground/locales/en_MO/en_MO_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MP/en_MP.go create mode 100644 vendor/github.com/go-playground/locales/en_MP/en_MP_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MS/en_MS.go create mode 100644 vendor/github.com/go-playground/locales/en_MS/en_MS_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MT/en_MT.go create mode 100644 vendor/github.com/go-playground/locales/en_MT/en_MT_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MU/en_MU.go create mode 100644 vendor/github.com/go-playground/locales/en_MU/en_MU_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MW/en_MW.go create mode 100644 vendor/github.com/go-playground/locales/en_MW/en_MW_test.go create mode 100644 vendor/github.com/go-playground/locales/en_MY/en_MY.go create mode 100644 vendor/github.com/go-playground/locales/en_MY/en_MY_test.go create mode 100644 vendor/github.com/go-playground/locales/en_NA/en_NA.go create mode 100644 vendor/github.com/go-playground/locales/en_NA/en_NA_test.go create mode 100644 vendor/github.com/go-playground/locales/en_NF/en_NF.go create mode 100644 vendor/github.com/go-playground/locales/en_NF/en_NF_test.go create mode 100644 vendor/github.com/go-playground/locales/en_NG/en_NG.go create mode 100644 vendor/github.com/go-playground/locales/en_NG/en_NG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_NL/en_NL.go create mode 100644 vendor/github.com/go-playground/locales/en_NL/en_NL_test.go create mode 100644 vendor/github.com/go-playground/locales/en_NR/en_NR.go create mode 100644 vendor/github.com/go-playground/locales/en_NR/en_NR_test.go create mode 100644 vendor/github.com/go-playground/locales/en_NU/en_NU.go create mode 100644 vendor/github.com/go-playground/locales/en_NU/en_NU_test.go create mode 100644 vendor/github.com/go-playground/locales/en_NZ/en_NZ.go create mode 100644 vendor/github.com/go-playground/locales/en_NZ/en_NZ_test.go create mode 100644 vendor/github.com/go-playground/locales/en_PG/en_PG.go create mode 100644 vendor/github.com/go-playground/locales/en_PG/en_PG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_PH/en_PH.go create mode 100644 vendor/github.com/go-playground/locales/en_PH/en_PH_test.go create mode 100644 vendor/github.com/go-playground/locales/en_PK/en_PK.go create mode 100644 vendor/github.com/go-playground/locales/en_PK/en_PK_test.go create mode 100644 vendor/github.com/go-playground/locales/en_PN/en_PN.go create mode 100644 vendor/github.com/go-playground/locales/en_PN/en_PN_test.go create mode 100644 vendor/github.com/go-playground/locales/en_PR/en_PR.go create mode 100644 vendor/github.com/go-playground/locales/en_PR/en_PR_test.go create mode 100644 vendor/github.com/go-playground/locales/en_PW/en_PW.go create mode 100644 vendor/github.com/go-playground/locales/en_PW/en_PW_test.go create mode 100644 vendor/github.com/go-playground/locales/en_RW/en_RW.go create mode 100644 vendor/github.com/go-playground/locales/en_RW/en_RW_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SB/en_SB.go create mode 100644 vendor/github.com/go-playground/locales/en_SB/en_SB_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SC/en_SC.go create mode 100644 vendor/github.com/go-playground/locales/en_SC/en_SC_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SD/en_SD.go create mode 100644 vendor/github.com/go-playground/locales/en_SD/en_SD_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SE/en_SE.go create mode 100644 vendor/github.com/go-playground/locales/en_SE/en_SE_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SG/en_SG.go create mode 100644 vendor/github.com/go-playground/locales/en_SG/en_SG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SH/en_SH.go create mode 100644 vendor/github.com/go-playground/locales/en_SH/en_SH_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SI/en_SI.go create mode 100644 vendor/github.com/go-playground/locales/en_SI/en_SI_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SL/en_SL.go create mode 100644 vendor/github.com/go-playground/locales/en_SL/en_SL_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SS/en_SS.go create mode 100644 vendor/github.com/go-playground/locales/en_SS/en_SS_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SX/en_SX.go create mode 100644 vendor/github.com/go-playground/locales/en_SX/en_SX_test.go create mode 100644 vendor/github.com/go-playground/locales/en_SZ/en_SZ.go create mode 100644 vendor/github.com/go-playground/locales/en_SZ/en_SZ_test.go create mode 100644 vendor/github.com/go-playground/locales/en_TC/en_TC.go create mode 100644 vendor/github.com/go-playground/locales/en_TC/en_TC_test.go create mode 100644 vendor/github.com/go-playground/locales/en_TK/en_TK.go create mode 100644 vendor/github.com/go-playground/locales/en_TK/en_TK_test.go create mode 100644 vendor/github.com/go-playground/locales/en_TO/en_TO.go create mode 100644 vendor/github.com/go-playground/locales/en_TO/en_TO_test.go create mode 100644 vendor/github.com/go-playground/locales/en_TT/en_TT.go create mode 100644 vendor/github.com/go-playground/locales/en_TT/en_TT_test.go create mode 100644 vendor/github.com/go-playground/locales/en_TV/en_TV.go create mode 100644 vendor/github.com/go-playground/locales/en_TV/en_TV_test.go create mode 100644 vendor/github.com/go-playground/locales/en_TZ/en_TZ.go create mode 100644 vendor/github.com/go-playground/locales/en_TZ/en_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/en_UG/en_UG.go create mode 100644 vendor/github.com/go-playground/locales/en_UG/en_UG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_UM/en_UM.go create mode 100644 vendor/github.com/go-playground/locales/en_UM/en_UM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_US/en_US.go create mode 100644 vendor/github.com/go-playground/locales/en_US/en_US_test.go create mode 100644 vendor/github.com/go-playground/locales/en_US_POSIX/en_US_POSIX.go create mode 100644 vendor/github.com/go-playground/locales/en_US_POSIX/en_US_POSIX_test.go create mode 100644 vendor/github.com/go-playground/locales/en_VC/en_VC.go create mode 100644 vendor/github.com/go-playground/locales/en_VC/en_VC_test.go create mode 100644 vendor/github.com/go-playground/locales/en_VG/en_VG.go create mode 100644 vendor/github.com/go-playground/locales/en_VG/en_VG_test.go create mode 100644 vendor/github.com/go-playground/locales/en_VI/en_VI.go create mode 100644 vendor/github.com/go-playground/locales/en_VI/en_VI_test.go create mode 100644 vendor/github.com/go-playground/locales/en_VU/en_VU.go create mode 100644 vendor/github.com/go-playground/locales/en_VU/en_VU_test.go create mode 100644 vendor/github.com/go-playground/locales/en_WS/en_WS.go create mode 100644 vendor/github.com/go-playground/locales/en_WS/en_WS_test.go create mode 100644 vendor/github.com/go-playground/locales/en_ZA/en_ZA.go create mode 100644 vendor/github.com/go-playground/locales/en_ZA/en_ZA_test.go create mode 100644 vendor/github.com/go-playground/locales/en_ZM/en_ZM.go create mode 100644 vendor/github.com/go-playground/locales/en_ZM/en_ZM_test.go create mode 100644 vendor/github.com/go-playground/locales/en_ZW/en_ZW.go create mode 100644 vendor/github.com/go-playground/locales/en_ZW/en_ZW_test.go create mode 100644 vendor/github.com/go-playground/locales/eo/eo.go create mode 100644 vendor/github.com/go-playground/locales/eo/eo_test.go create mode 100644 vendor/github.com/go-playground/locales/eo_001/eo_001.go create mode 100644 vendor/github.com/go-playground/locales/eo_001/eo_001_test.go create mode 100644 vendor/github.com/go-playground/locales/es/es.go create mode 100644 vendor/github.com/go-playground/locales/es/es_test.go create mode 100644 vendor/github.com/go-playground/locales/es_419/es_419.go create mode 100644 vendor/github.com/go-playground/locales/es_419/es_419_test.go create mode 100644 vendor/github.com/go-playground/locales/es_AR/es_AR.go create mode 100644 vendor/github.com/go-playground/locales/es_AR/es_AR_test.go create mode 100644 vendor/github.com/go-playground/locales/es_BO/es_BO.go create mode 100644 vendor/github.com/go-playground/locales/es_BO/es_BO_test.go create mode 100644 vendor/github.com/go-playground/locales/es_BR/es_BR.go create mode 100644 vendor/github.com/go-playground/locales/es_BR/es_BR_test.go create mode 100644 vendor/github.com/go-playground/locales/es_CL/es_CL.go create mode 100644 vendor/github.com/go-playground/locales/es_CL/es_CL_test.go create mode 100644 vendor/github.com/go-playground/locales/es_CO/es_CO.go create mode 100644 vendor/github.com/go-playground/locales/es_CO/es_CO_test.go create mode 100644 vendor/github.com/go-playground/locales/es_CR/es_CR.go create mode 100644 vendor/github.com/go-playground/locales/es_CR/es_CR_test.go create mode 100644 vendor/github.com/go-playground/locales/es_CU/es_CU.go create mode 100644 vendor/github.com/go-playground/locales/es_CU/es_CU_test.go create mode 100644 vendor/github.com/go-playground/locales/es_DO/es_DO.go create mode 100644 vendor/github.com/go-playground/locales/es_DO/es_DO_test.go create mode 100644 vendor/github.com/go-playground/locales/es_EA/es_EA.go create mode 100644 vendor/github.com/go-playground/locales/es_EA/es_EA_test.go create mode 100644 vendor/github.com/go-playground/locales/es_EC/es_EC.go create mode 100644 vendor/github.com/go-playground/locales/es_EC/es_EC_test.go create mode 100644 vendor/github.com/go-playground/locales/es_ES/es_ES.go create mode 100644 vendor/github.com/go-playground/locales/es_ES/es_ES_test.go create mode 100644 vendor/github.com/go-playground/locales/es_GQ/es_GQ.go create mode 100644 vendor/github.com/go-playground/locales/es_GQ/es_GQ_test.go create mode 100644 vendor/github.com/go-playground/locales/es_GT/es_GT.go create mode 100644 vendor/github.com/go-playground/locales/es_GT/es_GT_test.go create mode 100644 vendor/github.com/go-playground/locales/es_HN/es_HN.go create mode 100644 vendor/github.com/go-playground/locales/es_HN/es_HN_test.go create mode 100644 vendor/github.com/go-playground/locales/es_IC/es_IC.go create mode 100644 vendor/github.com/go-playground/locales/es_IC/es_IC_test.go create mode 100644 vendor/github.com/go-playground/locales/es_MX/es_MX.go create mode 100644 vendor/github.com/go-playground/locales/es_MX/es_MX_test.go create mode 100644 vendor/github.com/go-playground/locales/es_NI/es_NI.go create mode 100644 vendor/github.com/go-playground/locales/es_NI/es_NI_test.go create mode 100644 vendor/github.com/go-playground/locales/es_PA/es_PA.go create mode 100644 vendor/github.com/go-playground/locales/es_PA/es_PA_test.go create mode 100644 vendor/github.com/go-playground/locales/es_PE/es_PE.go create mode 100644 vendor/github.com/go-playground/locales/es_PE/es_PE_test.go create mode 100644 vendor/github.com/go-playground/locales/es_PH/es_PH.go create mode 100644 vendor/github.com/go-playground/locales/es_PH/es_PH_test.go create mode 100644 vendor/github.com/go-playground/locales/es_PR/es_PR.go create mode 100644 vendor/github.com/go-playground/locales/es_PR/es_PR_test.go create mode 100644 vendor/github.com/go-playground/locales/es_PY/es_PY.go create mode 100644 vendor/github.com/go-playground/locales/es_PY/es_PY_test.go create mode 100644 vendor/github.com/go-playground/locales/es_SV/es_SV.go create mode 100644 vendor/github.com/go-playground/locales/es_SV/es_SV_test.go create mode 100644 vendor/github.com/go-playground/locales/es_US/es_US.go create mode 100644 vendor/github.com/go-playground/locales/es_US/es_US_test.go create mode 100644 vendor/github.com/go-playground/locales/es_UY/es_UY.go create mode 100644 vendor/github.com/go-playground/locales/es_UY/es_UY_test.go create mode 100644 vendor/github.com/go-playground/locales/es_VE/es_VE.go create mode 100644 vendor/github.com/go-playground/locales/es_VE/es_VE_test.go create mode 100644 vendor/github.com/go-playground/locales/et/et.go create mode 100644 vendor/github.com/go-playground/locales/et/et_test.go create mode 100644 vendor/github.com/go-playground/locales/et_EE/et_EE.go create mode 100644 vendor/github.com/go-playground/locales/et_EE/et_EE_test.go create mode 100644 vendor/github.com/go-playground/locales/eu/eu.go create mode 100644 vendor/github.com/go-playground/locales/eu/eu_test.go create mode 100644 vendor/github.com/go-playground/locales/eu/ue_test.go create mode 100644 vendor/github.com/go-playground/locales/eu_ES/eu_ES.go create mode 100644 vendor/github.com/go-playground/locales/eu_ES/eu_ES_test.go create mode 100644 vendor/github.com/go-playground/locales/ewo/ewo.go create mode 100644 vendor/github.com/go-playground/locales/ewo/ewo_test.go create mode 100644 vendor/github.com/go-playground/locales/ewo_CM/ewo_CM.go create mode 100644 vendor/github.com/go-playground/locales/ewo_CM/ewo_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/fa/fa.go create mode 100644 vendor/github.com/go-playground/locales/fa/fa_test.go create mode 100644 vendor/github.com/go-playground/locales/fa_AF/fa_AF.go create mode 100644 vendor/github.com/go-playground/locales/fa_AF/fa_AF_test.go create mode 100644 vendor/github.com/go-playground/locales/fa_IR/fa_IR.go create mode 100644 vendor/github.com/go-playground/locales/fa_IR/fa_IR_test.go create mode 100644 vendor/github.com/go-playground/locales/ff/ff.go create mode 100644 vendor/github.com/go-playground/locales/ff/ff_test.go create mode 100644 vendor/github.com/go-playground/locales/ff_CM/ff_CM.go create mode 100644 vendor/github.com/go-playground/locales/ff_CM/ff_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/ff_GN/ff_GN.go create mode 100644 vendor/github.com/go-playground/locales/ff_GN/ff_GN_test.go create mode 100644 vendor/github.com/go-playground/locales/ff_MR/ff_MR.go create mode 100644 vendor/github.com/go-playground/locales/ff_MR/ff_MR_test.go create mode 100644 vendor/github.com/go-playground/locales/ff_SN/ff_SN.go create mode 100644 vendor/github.com/go-playground/locales/ff_SN/ff_SN_test.go create mode 100644 vendor/github.com/go-playground/locales/fi/fi.go create mode 100644 vendor/github.com/go-playground/locales/fi/fi_test.go create mode 100644 vendor/github.com/go-playground/locales/fi_FI/fi_FI.go create mode 100644 vendor/github.com/go-playground/locales/fi_FI/fi_FI_test.go create mode 100644 vendor/github.com/go-playground/locales/fil/fil.go create mode 100644 vendor/github.com/go-playground/locales/fil/fil_test.go create mode 100644 vendor/github.com/go-playground/locales/fil_PH/fil_PH.go create mode 100644 vendor/github.com/go-playground/locales/fil_PH/fil_PH_test.go create mode 100644 vendor/github.com/go-playground/locales/fo/fo.go create mode 100644 vendor/github.com/go-playground/locales/fo/fo_test.go create mode 100644 vendor/github.com/go-playground/locales/fo_DK/fo_DK.go create mode 100644 vendor/github.com/go-playground/locales/fo_DK/fo_DK_test.go create mode 100644 vendor/github.com/go-playground/locales/fo_FO/fo_FO.go create mode 100644 vendor/github.com/go-playground/locales/fo_FO/fo_FO_test.go create mode 100644 vendor/github.com/go-playground/locales/fr/fr.go create mode 100644 vendor/github.com/go-playground/locales/fr/fr_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_BE/fr_BE.go create mode 100644 vendor/github.com/go-playground/locales/fr_BE/fr_BE_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_BF/fr_BF.go create mode 100644 vendor/github.com/go-playground/locales/fr_BF/fr_BF_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_BI/fr_BI.go create mode 100644 vendor/github.com/go-playground/locales/fr_BI/fr_BI_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_BJ/fr_BJ.go create mode 100644 vendor/github.com/go-playground/locales/fr_BJ/fr_BJ_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_BL/fr_BL.go create mode 100644 vendor/github.com/go-playground/locales/fr_BL/fr_BL_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_CA/fr_CA.go create mode 100644 vendor/github.com/go-playground/locales/fr_CA/fr_CA_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_CD/fr_CD.go create mode 100644 vendor/github.com/go-playground/locales/fr_CD/fr_CD_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_CF/fr_CF.go create mode 100644 vendor/github.com/go-playground/locales/fr_CF/fr_CF_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_CG/fr_CG.go create mode 100644 vendor/github.com/go-playground/locales/fr_CG/fr_CG_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_CH/fr_CH.go create mode 100644 vendor/github.com/go-playground/locales/fr_CH/fr_CH_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_CI/fr_CI.go create mode 100644 vendor/github.com/go-playground/locales/fr_CI/fr_CI_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_CM/fr_CM.go create mode 100644 vendor/github.com/go-playground/locales/fr_CM/fr_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_DJ/fr_DJ.go create mode 100644 vendor/github.com/go-playground/locales/fr_DJ/fr_DJ_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_DZ/fr_DZ.go create mode 100644 vendor/github.com/go-playground/locales/fr_DZ/fr_DZ_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_FR/fr_FR.go create mode 100644 vendor/github.com/go-playground/locales/fr_FR/fr_FR_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_GA/fr_GA.go create mode 100644 vendor/github.com/go-playground/locales/fr_GA/fr_GA_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_GF/fr_GF.go create mode 100644 vendor/github.com/go-playground/locales/fr_GF/fr_GF_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_GN/fr_GN.go create mode 100644 vendor/github.com/go-playground/locales/fr_GN/fr_GN_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_GP/fr_GP.go create mode 100644 vendor/github.com/go-playground/locales/fr_GP/fr_GP_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_GQ/fr_GQ.go create mode 100644 vendor/github.com/go-playground/locales/fr_GQ/fr_GQ_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_HT/fr_HT.go create mode 100644 vendor/github.com/go-playground/locales/fr_HT/fr_HT_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_KM/fr_KM.go create mode 100644 vendor/github.com/go-playground/locales/fr_KM/fr_KM_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_LU/fr_LU.go create mode 100644 vendor/github.com/go-playground/locales/fr_LU/fr_LU_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_MA/fr_MA.go create mode 100644 vendor/github.com/go-playground/locales/fr_MA/fr_MA_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_MC/fr_MC.go create mode 100644 vendor/github.com/go-playground/locales/fr_MC/fr_MC_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_MF/fr_MF.go create mode 100644 vendor/github.com/go-playground/locales/fr_MF/fr_MF_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_MG/fr_MG.go create mode 100644 vendor/github.com/go-playground/locales/fr_MG/fr_MG_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_ML/fr_ML.go create mode 100644 vendor/github.com/go-playground/locales/fr_ML/fr_ML_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_MQ/fr_MQ.go create mode 100644 vendor/github.com/go-playground/locales/fr_MQ/fr_MQ_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_MR/fr_MR.go create mode 100644 vendor/github.com/go-playground/locales/fr_MR/fr_MR_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_MU/fr_MU.go create mode 100644 vendor/github.com/go-playground/locales/fr_MU/fr_MU_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_NC/fr_NC.go create mode 100644 vendor/github.com/go-playground/locales/fr_NC/fr_NC_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_NE/fr_NE.go create mode 100644 vendor/github.com/go-playground/locales/fr_NE/fr_NE_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_PF/fr_PF.go create mode 100644 vendor/github.com/go-playground/locales/fr_PF/fr_PF_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_PM/fr_PM.go create mode 100644 vendor/github.com/go-playground/locales/fr_PM/fr_PM_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_RE/fr_RE.go create mode 100644 vendor/github.com/go-playground/locales/fr_RE/fr_RE_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_RW/fr_RW.go create mode 100644 vendor/github.com/go-playground/locales/fr_RW/fr_RW_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_SC/fr_SC.go create mode 100644 vendor/github.com/go-playground/locales/fr_SC/fr_SC_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_SN/fr_SN.go create mode 100644 vendor/github.com/go-playground/locales/fr_SN/fr_SN_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_SY/fr_SY.go create mode 100644 vendor/github.com/go-playground/locales/fr_SY/fr_SY_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_TD/fr_TD.go create mode 100644 vendor/github.com/go-playground/locales/fr_TD/fr_TD_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_TG/fr_TG.go create mode 100644 vendor/github.com/go-playground/locales/fr_TG/fr_TG_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_TN/fr_TN.go create mode 100644 vendor/github.com/go-playground/locales/fr_TN/fr_TN_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_VU/fr_VU.go create mode 100644 vendor/github.com/go-playground/locales/fr_VU/fr_VU_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_WF/fr_WF.go create mode 100644 vendor/github.com/go-playground/locales/fr_WF/fr_WF_test.go create mode 100644 vendor/github.com/go-playground/locales/fr_YT/fr_YT.go create mode 100644 vendor/github.com/go-playground/locales/fr_YT/fr_YT_test.go create mode 100644 vendor/github.com/go-playground/locales/fur/fur.go create mode 100644 vendor/github.com/go-playground/locales/fur/fur_test.go create mode 100644 vendor/github.com/go-playground/locales/fur_IT/fur_IT.go create mode 100644 vendor/github.com/go-playground/locales/fur_IT/fur_IT_test.go create mode 100644 vendor/github.com/go-playground/locales/fy/fy.go create mode 100644 vendor/github.com/go-playground/locales/fy/fy_test.go create mode 100644 vendor/github.com/go-playground/locales/fy_NL/fy_NL.go create mode 100644 vendor/github.com/go-playground/locales/fy_NL/fy_NL_test.go create mode 100644 vendor/github.com/go-playground/locales/ga/ga.go create mode 100644 vendor/github.com/go-playground/locales/ga/ga_test.go create mode 100644 vendor/github.com/go-playground/locales/ga_IE/ga_IE.go create mode 100644 vendor/github.com/go-playground/locales/ga_IE/ga_IE_test.go create mode 100644 vendor/github.com/go-playground/locales/gd/gd.go create mode 100644 vendor/github.com/go-playground/locales/gd/gd_test.go create mode 100644 vendor/github.com/go-playground/locales/gd_GB/gd_GB.go create mode 100644 vendor/github.com/go-playground/locales/gd_GB/gd_GB_test.go create mode 100644 vendor/github.com/go-playground/locales/gl/gl.go create mode 100644 vendor/github.com/go-playground/locales/gl/gl_test.go create mode 100644 vendor/github.com/go-playground/locales/gl_ES/gl_ES.go create mode 100644 vendor/github.com/go-playground/locales/gl_ES/gl_ES_test.go create mode 100644 vendor/github.com/go-playground/locales/gsw/gsw.go create mode 100644 vendor/github.com/go-playground/locales/gsw/gsw_test.go create mode 100644 vendor/github.com/go-playground/locales/gsw_CH/gsw_CH.go create mode 100644 vendor/github.com/go-playground/locales/gsw_CH/gsw_CH_test.go create mode 100644 vendor/github.com/go-playground/locales/gsw_FR/gsw_FR.go create mode 100644 vendor/github.com/go-playground/locales/gsw_FR/gsw_FR_test.go create mode 100644 vendor/github.com/go-playground/locales/gsw_LI/gsw_LI.go create mode 100644 vendor/github.com/go-playground/locales/gsw_LI/gsw_LI_test.go create mode 100644 vendor/github.com/go-playground/locales/gu/gu.go create mode 100644 vendor/github.com/go-playground/locales/gu/gu_test.go create mode 100644 vendor/github.com/go-playground/locales/gu_IN/gu_IN.go create mode 100644 vendor/github.com/go-playground/locales/gu_IN/gu_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/guz/guz.go create mode 100644 vendor/github.com/go-playground/locales/guz/guz_test.go create mode 100644 vendor/github.com/go-playground/locales/guz_KE/guz_KE.go create mode 100644 vendor/github.com/go-playground/locales/guz_KE/guz_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/gv/gv.go create mode 100644 vendor/github.com/go-playground/locales/gv/gv_test.go create mode 100644 vendor/github.com/go-playground/locales/gv_IM/gv_IM.go create mode 100644 vendor/github.com/go-playground/locales/gv_IM/gv_IM_test.go create mode 100644 vendor/github.com/go-playground/locales/ha/ha.go create mode 100644 vendor/github.com/go-playground/locales/ha/ha_test.go create mode 100644 vendor/github.com/go-playground/locales/ha_GH/ha_GH.go create mode 100644 vendor/github.com/go-playground/locales/ha_GH/ha_GH_test.go create mode 100644 vendor/github.com/go-playground/locales/ha_NE/ha_NE.go create mode 100644 vendor/github.com/go-playground/locales/ha_NE/ha_NE_test.go create mode 100644 vendor/github.com/go-playground/locales/ha_NG/ha_NG.go create mode 100644 vendor/github.com/go-playground/locales/ha_NG/ha_NG_test.go create mode 100644 vendor/github.com/go-playground/locales/haw/haw.go create mode 100644 vendor/github.com/go-playground/locales/haw/haw_test.go create mode 100644 vendor/github.com/go-playground/locales/haw_US/haw_US.go create mode 100644 vendor/github.com/go-playground/locales/haw_US/haw_US_test.go create mode 100644 vendor/github.com/go-playground/locales/he/he.go create mode 100644 vendor/github.com/go-playground/locales/he/he_test.go create mode 100644 vendor/github.com/go-playground/locales/he_IL/he_IL.go create mode 100644 vendor/github.com/go-playground/locales/he_IL/he_IL_test.go create mode 100644 vendor/github.com/go-playground/locales/hi/hi.go create mode 100644 vendor/github.com/go-playground/locales/hi/hi_test.go create mode 100644 vendor/github.com/go-playground/locales/hi_IN/hi_IN.go create mode 100644 vendor/github.com/go-playground/locales/hi_IN/hi_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/hr/hr.go create mode 100644 vendor/github.com/go-playground/locales/hr/hr_test.go create mode 100644 vendor/github.com/go-playground/locales/hr_BA/hr_BA.go create mode 100644 vendor/github.com/go-playground/locales/hr_BA/hr_BA_test.go create mode 100644 vendor/github.com/go-playground/locales/hr_HR/hr_HR.go create mode 100644 vendor/github.com/go-playground/locales/hr_HR/hr_HR_test.go create mode 100644 vendor/github.com/go-playground/locales/hsb/hsb.go create mode 100644 vendor/github.com/go-playground/locales/hsb/hsb_test.go create mode 100644 vendor/github.com/go-playground/locales/hsb_DE/hsb_DE.go create mode 100644 vendor/github.com/go-playground/locales/hsb_DE/hsb_DE_test.go create mode 100644 vendor/github.com/go-playground/locales/hu/hu.go create mode 100644 vendor/github.com/go-playground/locales/hu/hu_test.go create mode 100644 vendor/github.com/go-playground/locales/hu_HU/hu_HU.go create mode 100644 vendor/github.com/go-playground/locales/hu_HU/hu_HU_test.go create mode 100644 vendor/github.com/go-playground/locales/hy/hy.go create mode 100644 vendor/github.com/go-playground/locales/hy/hy_test.go create mode 100644 vendor/github.com/go-playground/locales/hy_AM/hy_AM.go create mode 100644 vendor/github.com/go-playground/locales/hy_AM/hy_AM_test.go create mode 100644 vendor/github.com/go-playground/locales/id/id.go create mode 100644 vendor/github.com/go-playground/locales/id/id_test.go create mode 100644 vendor/github.com/go-playground/locales/id_ID/id_ID.go create mode 100644 vendor/github.com/go-playground/locales/id_ID/id_ID_test.go create mode 100644 vendor/github.com/go-playground/locales/ig/ig.go create mode 100644 vendor/github.com/go-playground/locales/ig/ig_test.go create mode 100644 vendor/github.com/go-playground/locales/ig_NG/ig_NG.go create mode 100644 vendor/github.com/go-playground/locales/ig_NG/ig_NG_test.go create mode 100644 vendor/github.com/go-playground/locales/ii/ii.go create mode 100644 vendor/github.com/go-playground/locales/ii/ii_test.go create mode 100644 vendor/github.com/go-playground/locales/ii_CN/ii_CN.go create mode 100644 vendor/github.com/go-playground/locales/ii_CN/ii_CN_test.go create mode 100644 vendor/github.com/go-playground/locales/is/is.go create mode 100644 vendor/github.com/go-playground/locales/is/is_test.go create mode 100644 vendor/github.com/go-playground/locales/is_IS/is_IS.go create mode 100644 vendor/github.com/go-playground/locales/is_IS/is_IS_test.go create mode 100644 vendor/github.com/go-playground/locales/it/it.go create mode 100644 vendor/github.com/go-playground/locales/it/it_test.go create mode 100644 vendor/github.com/go-playground/locales/it_CH/it_CH.go create mode 100644 vendor/github.com/go-playground/locales/it_CH/it_CH_test.go create mode 100644 vendor/github.com/go-playground/locales/it_IT/it_IT.go create mode 100644 vendor/github.com/go-playground/locales/it_IT/it_IT_test.go create mode 100644 vendor/github.com/go-playground/locales/it_SM/it_SM.go create mode 100644 vendor/github.com/go-playground/locales/it_SM/it_SM_test.go create mode 100644 vendor/github.com/go-playground/locales/ja/ja.go create mode 100644 vendor/github.com/go-playground/locales/ja/ja_test.go create mode 100644 vendor/github.com/go-playground/locales/ja_JP/ja_JP.go create mode 100644 vendor/github.com/go-playground/locales/ja_JP/ja_JP_test.go create mode 100644 vendor/github.com/go-playground/locales/jgo/jgo.go create mode 100644 vendor/github.com/go-playground/locales/jgo/jgo_test.go create mode 100644 vendor/github.com/go-playground/locales/jgo_CM/jgo_CM.go create mode 100644 vendor/github.com/go-playground/locales/jgo_CM/jgo_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/jmc/jmc.go create mode 100644 vendor/github.com/go-playground/locales/jmc/jmc_test.go create mode 100644 vendor/github.com/go-playground/locales/jmc_TZ/jmc_TZ.go create mode 100644 vendor/github.com/go-playground/locales/jmc_TZ/jmc_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/ka/ka.go create mode 100644 vendor/github.com/go-playground/locales/ka/ka_test.go create mode 100644 vendor/github.com/go-playground/locales/ka_GE/ka_GE.go create mode 100644 vendor/github.com/go-playground/locales/ka_GE/ka_GE_test.go create mode 100644 vendor/github.com/go-playground/locales/kab/kab.go create mode 100644 vendor/github.com/go-playground/locales/kab/kab_test.go create mode 100644 vendor/github.com/go-playground/locales/kab_DZ/kab_DZ.go create mode 100644 vendor/github.com/go-playground/locales/kab_DZ/kab_DZ_test.go create mode 100644 vendor/github.com/go-playground/locales/kam/kam.go create mode 100644 vendor/github.com/go-playground/locales/kam/kam_test.go create mode 100644 vendor/github.com/go-playground/locales/kam_KE/kam_KE.go create mode 100644 vendor/github.com/go-playground/locales/kam_KE/kam_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/kde/kde.go create mode 100644 vendor/github.com/go-playground/locales/kde/kde_test.go create mode 100644 vendor/github.com/go-playground/locales/kde_TZ/kde_TZ.go create mode 100644 vendor/github.com/go-playground/locales/kde_TZ/kde_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/kea/kea.go create mode 100644 vendor/github.com/go-playground/locales/kea/kea_test.go create mode 100644 vendor/github.com/go-playground/locales/kea_CV/kea_CV.go create mode 100644 vendor/github.com/go-playground/locales/kea_CV/kea_CV_test.go create mode 100644 vendor/github.com/go-playground/locales/khq/khq.go create mode 100644 vendor/github.com/go-playground/locales/khq/khq_test.go create mode 100644 vendor/github.com/go-playground/locales/khq_ML/khq_ML.go create mode 100644 vendor/github.com/go-playground/locales/khq_ML/khq_ML_test.go create mode 100644 vendor/github.com/go-playground/locales/ki/ki.go create mode 100644 vendor/github.com/go-playground/locales/ki/ki_test.go create mode 100644 vendor/github.com/go-playground/locales/ki_KE/ki_KE.go create mode 100644 vendor/github.com/go-playground/locales/ki_KE/ki_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/kk/kk.go create mode 100644 vendor/github.com/go-playground/locales/kk/kk_test.go create mode 100644 vendor/github.com/go-playground/locales/kk_KZ/kk_KZ.go create mode 100644 vendor/github.com/go-playground/locales/kk_KZ/kk_KZ_test.go create mode 100644 vendor/github.com/go-playground/locales/kkj/kkj.go create mode 100644 vendor/github.com/go-playground/locales/kkj/kkj_test.go create mode 100644 vendor/github.com/go-playground/locales/kkj_CM/kkj_CM.go create mode 100644 vendor/github.com/go-playground/locales/kkj_CM/kkj_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/kl/kl.go create mode 100644 vendor/github.com/go-playground/locales/kl/kl_test.go create mode 100644 vendor/github.com/go-playground/locales/kl_GL/kl_GL.go create mode 100644 vendor/github.com/go-playground/locales/kl_GL/kl_GL_test.go create mode 100644 vendor/github.com/go-playground/locales/kln/kln.go create mode 100644 vendor/github.com/go-playground/locales/kln/kln_test.go create mode 100644 vendor/github.com/go-playground/locales/kln_KE/kln_KE.go create mode 100644 vendor/github.com/go-playground/locales/kln_KE/kln_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/km/km.go create mode 100644 vendor/github.com/go-playground/locales/km/km_test.go create mode 100644 vendor/github.com/go-playground/locales/km_KH/km_KH.go create mode 100644 vendor/github.com/go-playground/locales/km_KH/km_KH_test.go create mode 100644 vendor/github.com/go-playground/locales/kn/kn.go create mode 100644 vendor/github.com/go-playground/locales/kn/kn_test.go create mode 100644 vendor/github.com/go-playground/locales/kn_IN/kn_IN.go create mode 100644 vendor/github.com/go-playground/locales/kn_IN/kn_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/ko/ko.go create mode 100644 vendor/github.com/go-playground/locales/ko/ko_test.go create mode 100644 vendor/github.com/go-playground/locales/ko_KP/ko_KP.go create mode 100644 vendor/github.com/go-playground/locales/ko_KP/ko_KP_test.go create mode 100644 vendor/github.com/go-playground/locales/ko_KR/ko_KR.go create mode 100644 vendor/github.com/go-playground/locales/ko_KR/ko_KR_test.go create mode 100644 vendor/github.com/go-playground/locales/kok/kok.go create mode 100644 vendor/github.com/go-playground/locales/kok/kok_test.go create mode 100644 vendor/github.com/go-playground/locales/kok_IN/kok_IN.go create mode 100644 vendor/github.com/go-playground/locales/kok_IN/kok_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/ks/ks.go create mode 100644 vendor/github.com/go-playground/locales/ks/ks_test.go create mode 100644 vendor/github.com/go-playground/locales/ks_IN/ks_IN.go create mode 100644 vendor/github.com/go-playground/locales/ks_IN/ks_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/ksb/ksb.go create mode 100644 vendor/github.com/go-playground/locales/ksb/ksb_test.go create mode 100644 vendor/github.com/go-playground/locales/ksb_TZ/ksb_TZ.go create mode 100644 vendor/github.com/go-playground/locales/ksb_TZ/ksb_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/ksf/ksf.go create mode 100644 vendor/github.com/go-playground/locales/ksf/ksf_test.go create mode 100644 vendor/github.com/go-playground/locales/ksf_CM/ksf_CM.go create mode 100644 vendor/github.com/go-playground/locales/ksf_CM/ksf_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/ksh/ksh.go create mode 100644 vendor/github.com/go-playground/locales/ksh/ksh_test.go create mode 100644 vendor/github.com/go-playground/locales/ksh_DE/ksh_DE.go create mode 100644 vendor/github.com/go-playground/locales/ksh_DE/ksh_DE_test.go create mode 100644 vendor/github.com/go-playground/locales/kw/kw.go create mode 100644 vendor/github.com/go-playground/locales/kw/kw_test.go create mode 100644 vendor/github.com/go-playground/locales/kw_GB/kw_GB.go create mode 100644 vendor/github.com/go-playground/locales/kw_GB/kw_GB_test.go create mode 100644 vendor/github.com/go-playground/locales/ky/ky.go create mode 100644 vendor/github.com/go-playground/locales/ky/ky_test.go create mode 100644 vendor/github.com/go-playground/locales/ky_KG/ky_KG.go create mode 100644 vendor/github.com/go-playground/locales/ky_KG/ky_KG_test.go create mode 100644 vendor/github.com/go-playground/locales/lag/lag.go create mode 100644 vendor/github.com/go-playground/locales/lag/lag_test.go create mode 100644 vendor/github.com/go-playground/locales/lag_TZ/lag_TZ.go create mode 100644 vendor/github.com/go-playground/locales/lag_TZ/lag_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/lb/lb.go create mode 100644 vendor/github.com/go-playground/locales/lb/lb_test.go create mode 100644 vendor/github.com/go-playground/locales/lb_LU/lb_LU.go create mode 100644 vendor/github.com/go-playground/locales/lb_LU/lb_LU_test.go create mode 100644 vendor/github.com/go-playground/locales/lg/lg.go create mode 100644 vendor/github.com/go-playground/locales/lg/lg_test.go create mode 100644 vendor/github.com/go-playground/locales/lg_UG/lg_UG.go create mode 100644 vendor/github.com/go-playground/locales/lg_UG/lg_UG_test.go create mode 100644 vendor/github.com/go-playground/locales/lkt/lkt.go create mode 100644 vendor/github.com/go-playground/locales/lkt/lkt_test.go create mode 100644 vendor/github.com/go-playground/locales/lkt_US/lkt_US.go create mode 100644 vendor/github.com/go-playground/locales/lkt_US/lkt_US_test.go create mode 100644 vendor/github.com/go-playground/locales/ln/ln.go create mode 100644 vendor/github.com/go-playground/locales/ln/ln_test.go create mode 100644 vendor/github.com/go-playground/locales/ln_AO/ln_AO.go create mode 100644 vendor/github.com/go-playground/locales/ln_AO/ln_AO_test.go create mode 100644 vendor/github.com/go-playground/locales/ln_CD/ln_CD.go create mode 100644 vendor/github.com/go-playground/locales/ln_CD/ln_CD_test.go create mode 100644 vendor/github.com/go-playground/locales/ln_CF/ln_CF.go create mode 100644 vendor/github.com/go-playground/locales/ln_CF/ln_CF_test.go create mode 100644 vendor/github.com/go-playground/locales/ln_CG/ln_CG.go create mode 100644 vendor/github.com/go-playground/locales/ln_CG/ln_CG_test.go create mode 100644 vendor/github.com/go-playground/locales/lo/lo.go create mode 100644 vendor/github.com/go-playground/locales/lo/lo_test.go create mode 100644 vendor/github.com/go-playground/locales/lo_LA/lo_LA.go create mode 100644 vendor/github.com/go-playground/locales/lo_LA/lo_LA_test.go create mode 100644 vendor/github.com/go-playground/locales/logo.png create mode 100644 vendor/github.com/go-playground/locales/lrc/lrc.go create mode 100644 vendor/github.com/go-playground/locales/lrc/lrc_test.go create mode 100644 vendor/github.com/go-playground/locales/lrc_IQ/lrc_IQ.go create mode 100644 vendor/github.com/go-playground/locales/lrc_IQ/lrc_IQ_test.go create mode 100644 vendor/github.com/go-playground/locales/lrc_IR/lrc_IR.go create mode 100644 vendor/github.com/go-playground/locales/lrc_IR/lrc_IR_test.go create mode 100644 vendor/github.com/go-playground/locales/lt/lt.go create mode 100644 vendor/github.com/go-playground/locales/lt/lt_test.go create mode 100644 vendor/github.com/go-playground/locales/lt_LT/lt_LT.go create mode 100644 vendor/github.com/go-playground/locales/lt_LT/lt_LT_test.go create mode 100644 vendor/github.com/go-playground/locales/lu/lu.go create mode 100644 vendor/github.com/go-playground/locales/lu/lu_test.go create mode 100644 vendor/github.com/go-playground/locales/lu_CD/lu_CD.go create mode 100644 vendor/github.com/go-playground/locales/lu_CD/lu_CD_test.go create mode 100644 vendor/github.com/go-playground/locales/luo/luo.go create mode 100644 vendor/github.com/go-playground/locales/luo/luo_test.go create mode 100644 vendor/github.com/go-playground/locales/luo_KE/luo_KE.go create mode 100644 vendor/github.com/go-playground/locales/luo_KE/luo_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/luy/luy.go create mode 100644 vendor/github.com/go-playground/locales/luy/luy_test.go create mode 100644 vendor/github.com/go-playground/locales/luy_KE/luy_KE.go create mode 100644 vendor/github.com/go-playground/locales/luy_KE/luy_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/lv/lv.go create mode 100644 vendor/github.com/go-playground/locales/lv/lv_test.go create mode 100644 vendor/github.com/go-playground/locales/lv_LV/lv_LV.go create mode 100644 vendor/github.com/go-playground/locales/lv_LV/lv_LV_test.go create mode 100644 vendor/github.com/go-playground/locales/mas/mas.go create mode 100644 vendor/github.com/go-playground/locales/mas/mas_test.go create mode 100644 vendor/github.com/go-playground/locales/mas_KE/mas_KE.go create mode 100644 vendor/github.com/go-playground/locales/mas_KE/mas_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/mas_TZ/mas_TZ.go create mode 100644 vendor/github.com/go-playground/locales/mas_TZ/mas_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/mer/mer.go create mode 100644 vendor/github.com/go-playground/locales/mer/mer_test.go create mode 100644 vendor/github.com/go-playground/locales/mer_KE/mer_KE.go create mode 100644 vendor/github.com/go-playground/locales/mer_KE/mer_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/mfe/mfe.go create mode 100644 vendor/github.com/go-playground/locales/mfe/mfe_test.go create mode 100644 vendor/github.com/go-playground/locales/mfe_MU/mfe_MU.go create mode 100644 vendor/github.com/go-playground/locales/mfe_MU/mfe_MU_test.go create mode 100644 vendor/github.com/go-playground/locales/mg/mg.go create mode 100644 vendor/github.com/go-playground/locales/mg/mg_test.go create mode 100644 vendor/github.com/go-playground/locales/mg_MG/mg_MG.go create mode 100644 vendor/github.com/go-playground/locales/mg_MG/mg_MG_test.go create mode 100644 vendor/github.com/go-playground/locales/mgh/mgh.go create mode 100644 vendor/github.com/go-playground/locales/mgh/mgh_test.go create mode 100644 vendor/github.com/go-playground/locales/mgh_MZ/mgh_MZ.go create mode 100644 vendor/github.com/go-playground/locales/mgh_MZ/mgh_MZ_test.go create mode 100644 vendor/github.com/go-playground/locales/mgo/mgo.go create mode 100644 vendor/github.com/go-playground/locales/mgo/mgo_test.go create mode 100644 vendor/github.com/go-playground/locales/mgo_CM/mgo_CM.go create mode 100644 vendor/github.com/go-playground/locales/mgo_CM/mgo_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/mk/mk.go create mode 100644 vendor/github.com/go-playground/locales/mk/mk_test.go create mode 100644 vendor/github.com/go-playground/locales/mk_MK/mk_MK.go create mode 100644 vendor/github.com/go-playground/locales/mk_MK/mk_MK_test.go create mode 100644 vendor/github.com/go-playground/locales/ml/ml.go create mode 100644 vendor/github.com/go-playground/locales/ml/ml_test.go create mode 100644 vendor/github.com/go-playground/locales/ml_IN/ml_IN.go create mode 100644 vendor/github.com/go-playground/locales/ml_IN/ml_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/mn/mn.go create mode 100644 vendor/github.com/go-playground/locales/mn/mn_test.go create mode 100644 vendor/github.com/go-playground/locales/mn_MN/mn_MN.go create mode 100644 vendor/github.com/go-playground/locales/mn_MN/mn_MN_test.go create mode 100644 vendor/github.com/go-playground/locales/mr/mr.go create mode 100644 vendor/github.com/go-playground/locales/mr/mr_test.go create mode 100644 vendor/github.com/go-playground/locales/mr_IN/mr_IN.go create mode 100644 vendor/github.com/go-playground/locales/mr_IN/mr_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/ms/ms.go create mode 100644 vendor/github.com/go-playground/locales/ms/ms_test.go create mode 100644 vendor/github.com/go-playground/locales/ms_BN/ms_BN.go create mode 100644 vendor/github.com/go-playground/locales/ms_BN/ms_BN_test.go create mode 100644 vendor/github.com/go-playground/locales/ms_MY/ms_MY.go create mode 100644 vendor/github.com/go-playground/locales/ms_MY/ms_MY_test.go create mode 100644 vendor/github.com/go-playground/locales/ms_SG/ms_SG.go create mode 100644 vendor/github.com/go-playground/locales/ms_SG/ms_SG_test.go create mode 100644 vendor/github.com/go-playground/locales/mt/mt.go create mode 100644 vendor/github.com/go-playground/locales/mt/mt_test.go create mode 100644 vendor/github.com/go-playground/locales/mt_MT/mt_MT.go create mode 100644 vendor/github.com/go-playground/locales/mt_MT/mt_MT_test.go create mode 100644 vendor/github.com/go-playground/locales/mua/mua.go create mode 100644 vendor/github.com/go-playground/locales/mua/mua_test.go create mode 100644 vendor/github.com/go-playground/locales/mua_CM/mua_CM.go create mode 100644 vendor/github.com/go-playground/locales/mua_CM/mua_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/my/my.go create mode 100644 vendor/github.com/go-playground/locales/my/my_test.go create mode 100644 vendor/github.com/go-playground/locales/my_MM/my_MM.go create mode 100644 vendor/github.com/go-playground/locales/my_MM/my_MM_test.go create mode 100644 vendor/github.com/go-playground/locales/mzn/mzn.go create mode 100644 vendor/github.com/go-playground/locales/mzn/mzn_test.go create mode 100644 vendor/github.com/go-playground/locales/mzn_IR/mzn_IR.go create mode 100644 vendor/github.com/go-playground/locales/mzn_IR/mzn_IR_test.go create mode 100644 vendor/github.com/go-playground/locales/naq/naq.go create mode 100644 vendor/github.com/go-playground/locales/naq/naq_test.go create mode 100644 vendor/github.com/go-playground/locales/naq_NA/naq_NA.go create mode 100644 vendor/github.com/go-playground/locales/naq_NA/naq_NA_test.go create mode 100644 vendor/github.com/go-playground/locales/nb/nb.go create mode 100644 vendor/github.com/go-playground/locales/nb/nb_test.go create mode 100644 vendor/github.com/go-playground/locales/nb_NO/nb_NO.go create mode 100644 vendor/github.com/go-playground/locales/nb_NO/nb_NO_test.go create mode 100644 vendor/github.com/go-playground/locales/nb_SJ/nb_SJ.go create mode 100644 vendor/github.com/go-playground/locales/nb_SJ/nb_SJ_test.go create mode 100644 vendor/github.com/go-playground/locales/nd/nd.go create mode 100644 vendor/github.com/go-playground/locales/nd/nd_test.go create mode 100644 vendor/github.com/go-playground/locales/nd_ZW/nd_ZW.go create mode 100644 vendor/github.com/go-playground/locales/nd_ZW/nd_ZW_test.go create mode 100644 vendor/github.com/go-playground/locales/nds/nds.go create mode 100644 vendor/github.com/go-playground/locales/nds/nds_test.go create mode 100644 vendor/github.com/go-playground/locales/nds_DE/nds_DE.go create mode 100644 vendor/github.com/go-playground/locales/nds_DE/nds_DE_test.go create mode 100644 vendor/github.com/go-playground/locales/nds_NL/nds_NL.go create mode 100644 vendor/github.com/go-playground/locales/nds_NL/nds_NL_test.go create mode 100644 vendor/github.com/go-playground/locales/ne/ne.go create mode 100644 vendor/github.com/go-playground/locales/ne/ne_test.go create mode 100644 vendor/github.com/go-playground/locales/ne_IN/ne_IN.go create mode 100644 vendor/github.com/go-playground/locales/ne_IN/ne_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/ne_NP/ne_NP.go create mode 100644 vendor/github.com/go-playground/locales/ne_NP/ne_NP_test.go create mode 100644 vendor/github.com/go-playground/locales/nl/nl.go create mode 100644 vendor/github.com/go-playground/locales/nl/nl_test.go create mode 100644 vendor/github.com/go-playground/locales/nl_AW/nl_AW.go create mode 100644 vendor/github.com/go-playground/locales/nl_AW/nl_AW_test.go create mode 100644 vendor/github.com/go-playground/locales/nl_BE/nl_BE.go create mode 100644 vendor/github.com/go-playground/locales/nl_BE/nl_BE_test.go create mode 100644 vendor/github.com/go-playground/locales/nl_BQ/nl_BQ.go create mode 100644 vendor/github.com/go-playground/locales/nl_BQ/nl_BQ_test.go create mode 100644 vendor/github.com/go-playground/locales/nl_CW/nl_CW.go create mode 100644 vendor/github.com/go-playground/locales/nl_CW/nl_CW_test.go create mode 100644 vendor/github.com/go-playground/locales/nl_NL/nl_NL.go create mode 100644 vendor/github.com/go-playground/locales/nl_NL/nl_NL_test.go create mode 100644 vendor/github.com/go-playground/locales/nl_SR/nl_SR.go create mode 100644 vendor/github.com/go-playground/locales/nl_SR/nl_SR_test.go create mode 100644 vendor/github.com/go-playground/locales/nl_SX/nl_SX.go create mode 100644 vendor/github.com/go-playground/locales/nl_SX/nl_SX_test.go create mode 100644 vendor/github.com/go-playground/locales/nmg/nmg.go create mode 100644 vendor/github.com/go-playground/locales/nmg/nmg_test.go create mode 100644 vendor/github.com/go-playground/locales/nmg_CM/nmg_CM.go create mode 100644 vendor/github.com/go-playground/locales/nmg_CM/nmg_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/nn/nn.go create mode 100644 vendor/github.com/go-playground/locales/nn/nn_test.go create mode 100644 vendor/github.com/go-playground/locales/nn_NO/nn_NO.go create mode 100644 vendor/github.com/go-playground/locales/nn_NO/nn_NO_test.go create mode 100644 vendor/github.com/go-playground/locales/nnh/nnh.go create mode 100644 vendor/github.com/go-playground/locales/nnh/nnh_test.go create mode 100644 vendor/github.com/go-playground/locales/nnh_CM/nnh_CM.go create mode 100644 vendor/github.com/go-playground/locales/nnh_CM/nnh_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/nus/nus.go create mode 100644 vendor/github.com/go-playground/locales/nus/nus_test.go create mode 100644 vendor/github.com/go-playground/locales/nus_SS/nus_SS.go create mode 100644 vendor/github.com/go-playground/locales/nus_SS/nus_SS_test.go create mode 100644 vendor/github.com/go-playground/locales/nyn/nyn.go create mode 100644 vendor/github.com/go-playground/locales/nyn/nyn_test.go create mode 100644 vendor/github.com/go-playground/locales/nyn_UG/nyn_UG.go create mode 100644 vendor/github.com/go-playground/locales/nyn_UG/nyn_UG_test.go create mode 100644 vendor/github.com/go-playground/locales/om/om.go create mode 100644 vendor/github.com/go-playground/locales/om/om_test.go create mode 100644 vendor/github.com/go-playground/locales/om_ET/om_ET.go create mode 100644 vendor/github.com/go-playground/locales/om_ET/om_ET_test.go create mode 100644 vendor/github.com/go-playground/locales/om_KE/om_KE.go create mode 100644 vendor/github.com/go-playground/locales/om_KE/om_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/or/or.go create mode 100644 vendor/github.com/go-playground/locales/or/or_test.go create mode 100644 vendor/github.com/go-playground/locales/or_IN/or_IN.go create mode 100644 vendor/github.com/go-playground/locales/or_IN/or_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/os/os.go create mode 100644 vendor/github.com/go-playground/locales/os/os_test.go create mode 100644 vendor/github.com/go-playground/locales/os_GE/os_GE.go create mode 100644 vendor/github.com/go-playground/locales/os_GE/os_GE_test.go create mode 100644 vendor/github.com/go-playground/locales/os_RU/os_RU.go create mode 100644 vendor/github.com/go-playground/locales/os_RU/os_RU_test.go create mode 100644 vendor/github.com/go-playground/locales/pa/pa.go create mode 100644 vendor/github.com/go-playground/locales/pa/pa_test.go create mode 100644 vendor/github.com/go-playground/locales/pa_Arab/pa_Arab.go create mode 100644 vendor/github.com/go-playground/locales/pa_Arab/pa_Arab_test.go create mode 100644 vendor/github.com/go-playground/locales/pa_Arab_PK/pa_Arab_PK.go create mode 100644 vendor/github.com/go-playground/locales/pa_Arab_PK/pa_Arab_PK_test.go create mode 100644 vendor/github.com/go-playground/locales/pa_Guru/pa_Guru.go create mode 100644 vendor/github.com/go-playground/locales/pa_Guru/pa_Guru_test.go create mode 100644 vendor/github.com/go-playground/locales/pa_Guru_IN/pa_Guru_IN.go create mode 100644 vendor/github.com/go-playground/locales/pa_Guru_IN/pa_Guru_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/pl/pl.go create mode 100644 vendor/github.com/go-playground/locales/pl/pl_test.go create mode 100644 vendor/github.com/go-playground/locales/pl_PL/pl_PL.go create mode 100644 vendor/github.com/go-playground/locales/pl_PL/pl_PL_test.go create mode 100644 vendor/github.com/go-playground/locales/prg/prg.go create mode 100644 vendor/github.com/go-playground/locales/prg/prg_test.go create mode 100644 vendor/github.com/go-playground/locales/prg_001/prg_001.go create mode 100644 vendor/github.com/go-playground/locales/prg_001/prg_001_test.go create mode 100644 vendor/github.com/go-playground/locales/ps/ps.go create mode 100644 vendor/github.com/go-playground/locales/ps/ps_test.go create mode 100644 vendor/github.com/go-playground/locales/ps_AF/ps_AF.go create mode 100644 vendor/github.com/go-playground/locales/ps_AF/ps_AF_test.go create mode 100644 vendor/github.com/go-playground/locales/pt/pt.go create mode 100644 vendor/github.com/go-playground/locales/pt/pt_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_AO/pt_AO.go create mode 100644 vendor/github.com/go-playground/locales/pt_AO/pt_AO_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_BR/pt_BR.go create mode 100644 vendor/github.com/go-playground/locales/pt_BR/pt_BR_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_CH/pt_CH.go create mode 100644 vendor/github.com/go-playground/locales/pt_CH/pt_CH_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_CV/pt_CV.go create mode 100644 vendor/github.com/go-playground/locales/pt_CV/pt_CV_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_GQ/pt_GQ.go create mode 100644 vendor/github.com/go-playground/locales/pt_GQ/pt_GQ_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_GW/pt_GW.go create mode 100644 vendor/github.com/go-playground/locales/pt_GW/pt_GW_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_LU/pt_LU.go create mode 100644 vendor/github.com/go-playground/locales/pt_LU/pt_LU_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_MO/pt_MO.go create mode 100644 vendor/github.com/go-playground/locales/pt_MO/pt_MO_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_MZ/pt_MZ.go create mode 100644 vendor/github.com/go-playground/locales/pt_MZ/pt_MZ_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_PT/pt_PT.go create mode 100644 vendor/github.com/go-playground/locales/pt_PT/pt_PT_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_ST/pt_ST.go create mode 100644 vendor/github.com/go-playground/locales/pt_ST/pt_ST_test.go create mode 100644 vendor/github.com/go-playground/locales/pt_TL/pt_TL.go create mode 100644 vendor/github.com/go-playground/locales/pt_TL/pt_TL_test.go create mode 100644 vendor/github.com/go-playground/locales/qu/qu.go create mode 100644 vendor/github.com/go-playground/locales/qu/qu_test.go create mode 100644 vendor/github.com/go-playground/locales/qu_BO/qu_BO.go create mode 100644 vendor/github.com/go-playground/locales/qu_BO/qu_BO_test.go create mode 100644 vendor/github.com/go-playground/locales/qu_EC/qu_EC.go create mode 100644 vendor/github.com/go-playground/locales/qu_EC/qu_EC_test.go create mode 100644 vendor/github.com/go-playground/locales/qu_PE/qu_PE.go create mode 100644 vendor/github.com/go-playground/locales/qu_PE/qu_PE_test.go create mode 100644 vendor/github.com/go-playground/locales/rm/rm.go create mode 100644 vendor/github.com/go-playground/locales/rm/rm_test.go create mode 100644 vendor/github.com/go-playground/locales/rm_CH/rm_CH.go create mode 100644 vendor/github.com/go-playground/locales/rm_CH/rm_CH_test.go create mode 100644 vendor/github.com/go-playground/locales/rn/rn.go create mode 100644 vendor/github.com/go-playground/locales/rn/rn_test.go create mode 100644 vendor/github.com/go-playground/locales/rn_BI/rn_BI.go create mode 100644 vendor/github.com/go-playground/locales/rn_BI/rn_BI_test.go create mode 100644 vendor/github.com/go-playground/locales/ro/ro.go create mode 100644 vendor/github.com/go-playground/locales/ro/ro_test.go create mode 100644 vendor/github.com/go-playground/locales/ro_MD/ro_MD.go create mode 100644 vendor/github.com/go-playground/locales/ro_MD/ro_MD_test.go create mode 100644 vendor/github.com/go-playground/locales/ro_RO/ro_RO.go create mode 100644 vendor/github.com/go-playground/locales/ro_RO/ro_RO_test.go create mode 100644 vendor/github.com/go-playground/locales/rof/rof.go create mode 100644 vendor/github.com/go-playground/locales/rof/rof_test.go create mode 100644 vendor/github.com/go-playground/locales/rof_TZ/rof_TZ.go create mode 100644 vendor/github.com/go-playground/locales/rof_TZ/rof_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/root/root.go create mode 100644 vendor/github.com/go-playground/locales/root/root_test.go create mode 100644 vendor/github.com/go-playground/locales/ru/ru.go create mode 100644 vendor/github.com/go-playground/locales/ru/ru_test.go create mode 100644 vendor/github.com/go-playground/locales/ru_BY/ru_BY.go create mode 100644 vendor/github.com/go-playground/locales/ru_BY/ru_BY_test.go create mode 100644 vendor/github.com/go-playground/locales/ru_KG/ru_KG.go create mode 100644 vendor/github.com/go-playground/locales/ru_KG/ru_KG_test.go create mode 100644 vendor/github.com/go-playground/locales/ru_KZ/ru_KZ.go create mode 100644 vendor/github.com/go-playground/locales/ru_KZ/ru_KZ_test.go create mode 100644 vendor/github.com/go-playground/locales/ru_MD/ru_MD.go create mode 100644 vendor/github.com/go-playground/locales/ru_MD/ru_MD_test.go create mode 100644 vendor/github.com/go-playground/locales/ru_RU/ru_RU.go create mode 100644 vendor/github.com/go-playground/locales/ru_RU/ru_RU_test.go create mode 100644 vendor/github.com/go-playground/locales/ru_UA/ru_UA.go create mode 100644 vendor/github.com/go-playground/locales/ru_UA/ru_UA_test.go create mode 100644 vendor/github.com/go-playground/locales/rules.go create mode 100644 vendor/github.com/go-playground/locales/rw/rw.go create mode 100644 vendor/github.com/go-playground/locales/rw/rw_test.go create mode 100644 vendor/github.com/go-playground/locales/rw_RW/rw_RW.go create mode 100644 vendor/github.com/go-playground/locales/rw_RW/rw_RW_test.go create mode 100644 vendor/github.com/go-playground/locales/rwk/rwk.go create mode 100644 vendor/github.com/go-playground/locales/rwk/rwk_test.go create mode 100644 vendor/github.com/go-playground/locales/rwk_TZ/rwk_TZ.go create mode 100644 vendor/github.com/go-playground/locales/rwk_TZ/rwk_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/sah/sah.go create mode 100644 vendor/github.com/go-playground/locales/sah/sah_test.go create mode 100644 vendor/github.com/go-playground/locales/sah_RU/sah_RU.go create mode 100644 vendor/github.com/go-playground/locales/sah_RU/sah_RU_test.go create mode 100644 vendor/github.com/go-playground/locales/saq/saq.go create mode 100644 vendor/github.com/go-playground/locales/saq/saq_test.go create mode 100644 vendor/github.com/go-playground/locales/saq_KE/saq_KE.go create mode 100644 vendor/github.com/go-playground/locales/saq_KE/saq_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/sbp/sbp.go create mode 100644 vendor/github.com/go-playground/locales/sbp/sbp_test.go create mode 100644 vendor/github.com/go-playground/locales/sbp_TZ/sbp_TZ.go create mode 100644 vendor/github.com/go-playground/locales/sbp_TZ/sbp_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/se/se.go create mode 100644 vendor/github.com/go-playground/locales/se/se_test.go create mode 100644 vendor/github.com/go-playground/locales/se_FI/se_FI.go create mode 100644 vendor/github.com/go-playground/locales/se_FI/se_FI_test.go create mode 100644 vendor/github.com/go-playground/locales/se_NO/se_NO.go create mode 100644 vendor/github.com/go-playground/locales/se_NO/se_NO_test.go create mode 100644 vendor/github.com/go-playground/locales/se_SE/se_SE.go create mode 100644 vendor/github.com/go-playground/locales/se_SE/se_SE_test.go create mode 100644 vendor/github.com/go-playground/locales/seh/seh.go create mode 100644 vendor/github.com/go-playground/locales/seh/seh_test.go create mode 100644 vendor/github.com/go-playground/locales/seh_MZ/seh_MZ.go create mode 100644 vendor/github.com/go-playground/locales/seh_MZ/seh_MZ_test.go create mode 100644 vendor/github.com/go-playground/locales/ses/ses.go create mode 100644 vendor/github.com/go-playground/locales/ses/ses_test.go create mode 100644 vendor/github.com/go-playground/locales/ses_ML/ses_ML.go create mode 100644 vendor/github.com/go-playground/locales/ses_ML/ses_ML_test.go create mode 100644 vendor/github.com/go-playground/locales/sg/sg.go create mode 100644 vendor/github.com/go-playground/locales/sg/sg_test.go create mode 100644 vendor/github.com/go-playground/locales/sg_CF/sg_CF.go create mode 100644 vendor/github.com/go-playground/locales/sg_CF/sg_CF_test.go create mode 100644 vendor/github.com/go-playground/locales/shi/shi.go create mode 100644 vendor/github.com/go-playground/locales/shi/shi_test.go create mode 100644 vendor/github.com/go-playground/locales/shi_Latn/shi_Latn.go create mode 100644 vendor/github.com/go-playground/locales/shi_Latn/shi_Latn_test.go create mode 100644 vendor/github.com/go-playground/locales/shi_Latn_MA/shi_Latn_MA.go create mode 100644 vendor/github.com/go-playground/locales/shi_Latn_MA/shi_Latn_MA_test.go create mode 100644 vendor/github.com/go-playground/locales/shi_Tfng/shi_Tfng.go create mode 100644 vendor/github.com/go-playground/locales/shi_Tfng/shi_Tfng_test.go create mode 100644 vendor/github.com/go-playground/locales/shi_Tfng_MA/shi_Tfng_MA.go create mode 100644 vendor/github.com/go-playground/locales/shi_Tfng_MA/shi_Tfng_MA_test.go create mode 100644 vendor/github.com/go-playground/locales/si/si.go create mode 100644 vendor/github.com/go-playground/locales/si/si_test.go create mode 100644 vendor/github.com/go-playground/locales/si_LK/si_LK.go create mode 100644 vendor/github.com/go-playground/locales/si_LK/si_LK_test.go create mode 100644 vendor/github.com/go-playground/locales/sk/sk.go create mode 100644 vendor/github.com/go-playground/locales/sk/sk_test.go create mode 100644 vendor/github.com/go-playground/locales/sk_SK/sk_SK.go create mode 100644 vendor/github.com/go-playground/locales/sk_SK/sk_SK_test.go create mode 100644 vendor/github.com/go-playground/locales/sl/sl.go create mode 100644 vendor/github.com/go-playground/locales/sl/sl_test.go create mode 100644 vendor/github.com/go-playground/locales/sl_SI/sl_SI.go create mode 100644 vendor/github.com/go-playground/locales/sl_SI/sl_SI_test.go create mode 100644 vendor/github.com/go-playground/locales/smn/smn.go create mode 100644 vendor/github.com/go-playground/locales/smn/smn_test.go create mode 100644 vendor/github.com/go-playground/locales/smn_FI/smn_FI.go create mode 100644 vendor/github.com/go-playground/locales/smn_FI/smn_FI_test.go create mode 100644 vendor/github.com/go-playground/locales/sn/sn.go create mode 100644 vendor/github.com/go-playground/locales/sn/sn_test.go create mode 100644 vendor/github.com/go-playground/locales/sn_ZW/sn_ZW.go create mode 100644 vendor/github.com/go-playground/locales/sn_ZW/sn_ZW_test.go create mode 100644 vendor/github.com/go-playground/locales/so/so.go create mode 100644 vendor/github.com/go-playground/locales/so/so_test.go create mode 100644 vendor/github.com/go-playground/locales/so_DJ/so_DJ.go create mode 100644 vendor/github.com/go-playground/locales/so_DJ/so_DJ_test.go create mode 100644 vendor/github.com/go-playground/locales/so_ET/so_ET.go create mode 100644 vendor/github.com/go-playground/locales/so_ET/so_ET_test.go create mode 100644 vendor/github.com/go-playground/locales/so_KE/so_KE.go create mode 100644 vendor/github.com/go-playground/locales/so_KE/so_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/so_SO/so_SO.go create mode 100644 vendor/github.com/go-playground/locales/so_SO/so_SO_test.go create mode 100644 vendor/github.com/go-playground/locales/sq/sq.go create mode 100644 vendor/github.com/go-playground/locales/sq/sq_test.go create mode 100644 vendor/github.com/go-playground/locales/sq_AL/sq_AL.go create mode 100644 vendor/github.com/go-playground/locales/sq_AL/sq_AL_test.go create mode 100644 vendor/github.com/go-playground/locales/sq_MK/sq_MK.go create mode 100644 vendor/github.com/go-playground/locales/sq_MK/sq_MK_test.go create mode 100644 vendor/github.com/go-playground/locales/sq_XK/sq_XK.go create mode 100644 vendor/github.com/go-playground/locales/sq_XK/sq_XK_test.go create mode 100644 vendor/github.com/go-playground/locales/sr/sr.go create mode 100644 vendor/github.com/go-playground/locales/sr/sr_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl/sr_Cyrl.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl/sr_Cyrl_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl_BA/sr_Cyrl_BA.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl_BA/sr_Cyrl_BA_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl_ME/sr_Cyrl_ME.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl_ME/sr_Cyrl_ME_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl_RS/sr_Cyrl_RS.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl_RS/sr_Cyrl_RS_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl_XK/sr_Cyrl_XK.go create mode 100644 vendor/github.com/go-playground/locales/sr_Cyrl_XK/sr_Cyrl_XK_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn/sr_Latn.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn/sr_Latn_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn_BA/sr_Latn_BA.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn_BA/sr_Latn_BA_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn_ME/sr_Latn_ME.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn_ME/sr_Latn_ME_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn_RS/sr_Latn_RS.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn_RS/sr_Latn_RS_test.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn_XK/sr_Latn_XK.go create mode 100644 vendor/github.com/go-playground/locales/sr_Latn_XK/sr_Latn_XK_test.go create mode 100644 vendor/github.com/go-playground/locales/sv/sv.go create mode 100644 vendor/github.com/go-playground/locales/sv/sv_test.go create mode 100644 vendor/github.com/go-playground/locales/sv_AX/sv_AX.go create mode 100644 vendor/github.com/go-playground/locales/sv_AX/sv_AX_test.go create mode 100644 vendor/github.com/go-playground/locales/sv_FI/sv_FI.go create mode 100644 vendor/github.com/go-playground/locales/sv_FI/sv_FI_test.go create mode 100644 vendor/github.com/go-playground/locales/sv_SE/sv_SE.go create mode 100644 vendor/github.com/go-playground/locales/sv_SE/sv_SE_test.go create mode 100644 vendor/github.com/go-playground/locales/sw/sw.go create mode 100644 vendor/github.com/go-playground/locales/sw/sw_test.go create mode 100644 vendor/github.com/go-playground/locales/sw_CD/sw_CD.go create mode 100644 vendor/github.com/go-playground/locales/sw_CD/sw_CD_test.go create mode 100644 vendor/github.com/go-playground/locales/sw_KE/sw_KE.go create mode 100644 vendor/github.com/go-playground/locales/sw_KE/sw_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/sw_TZ/sw_TZ.go create mode 100644 vendor/github.com/go-playground/locales/sw_TZ/sw_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/sw_UG/sw_UG.go create mode 100644 vendor/github.com/go-playground/locales/sw_UG/sw_UG_test.go create mode 100644 vendor/github.com/go-playground/locales/ta/ta.go create mode 100644 vendor/github.com/go-playground/locales/ta/ta_test.go create mode 100644 vendor/github.com/go-playground/locales/ta_IN/ta_IN.go create mode 100644 vendor/github.com/go-playground/locales/ta_IN/ta_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/ta_LK/ta_LK.go create mode 100644 vendor/github.com/go-playground/locales/ta_LK/ta_LK_test.go create mode 100644 vendor/github.com/go-playground/locales/ta_MY/ta_MY.go create mode 100644 vendor/github.com/go-playground/locales/ta_MY/ta_MY_test.go create mode 100644 vendor/github.com/go-playground/locales/ta_SG/ta_SG.go create mode 100644 vendor/github.com/go-playground/locales/ta_SG/ta_SG_test.go create mode 100644 vendor/github.com/go-playground/locales/te/te.go create mode 100644 vendor/github.com/go-playground/locales/te/te_test.go create mode 100644 vendor/github.com/go-playground/locales/te_IN/te_IN.go create mode 100644 vendor/github.com/go-playground/locales/te_IN/te_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/teo/teo.go create mode 100644 vendor/github.com/go-playground/locales/teo/teo_test.go create mode 100644 vendor/github.com/go-playground/locales/teo_KE/teo_KE.go create mode 100644 vendor/github.com/go-playground/locales/teo_KE/teo_KE_test.go create mode 100644 vendor/github.com/go-playground/locales/teo_UG/teo_UG.go create mode 100644 vendor/github.com/go-playground/locales/teo_UG/teo_UG_test.go create mode 100644 vendor/github.com/go-playground/locales/th/th.go create mode 100644 vendor/github.com/go-playground/locales/th/th_test.go create mode 100644 vendor/github.com/go-playground/locales/th_TH/th_TH.go create mode 100644 vendor/github.com/go-playground/locales/th_TH/th_TH_test.go create mode 100644 vendor/github.com/go-playground/locales/ti/ti.go create mode 100644 vendor/github.com/go-playground/locales/ti/ti_test.go create mode 100644 vendor/github.com/go-playground/locales/ti_ER/ti_ER.go create mode 100644 vendor/github.com/go-playground/locales/ti_ER/ti_ER_test.go create mode 100644 vendor/github.com/go-playground/locales/ti_ET/ti_ET.go create mode 100644 vendor/github.com/go-playground/locales/ti_ET/ti_ET_test.go create mode 100644 vendor/github.com/go-playground/locales/tk/tk.go create mode 100644 vendor/github.com/go-playground/locales/tk/tk_test.go create mode 100644 vendor/github.com/go-playground/locales/tk_TM/tk_TM.go create mode 100644 vendor/github.com/go-playground/locales/tk_TM/tk_TM_test.go create mode 100644 vendor/github.com/go-playground/locales/to/to.go create mode 100644 vendor/github.com/go-playground/locales/to/to_test.go create mode 100644 vendor/github.com/go-playground/locales/to_TO/to_TO.go create mode 100644 vendor/github.com/go-playground/locales/to_TO/to_TO_test.go create mode 100644 vendor/github.com/go-playground/locales/tr/tr.go create mode 100644 vendor/github.com/go-playground/locales/tr/tr_test.go create mode 100644 vendor/github.com/go-playground/locales/tr_CY/tr_CY.go create mode 100644 vendor/github.com/go-playground/locales/tr_CY/tr_CY_test.go create mode 100644 vendor/github.com/go-playground/locales/tr_TR/tr_TR.go create mode 100644 vendor/github.com/go-playground/locales/tr_TR/tr_TR_test.go create mode 100644 vendor/github.com/go-playground/locales/twq/twq.go create mode 100644 vendor/github.com/go-playground/locales/twq/twq_test.go create mode 100644 vendor/github.com/go-playground/locales/twq_NE/twq_NE.go create mode 100644 vendor/github.com/go-playground/locales/twq_NE/twq_NE_test.go create mode 100644 vendor/github.com/go-playground/locales/tzm/tzm.go create mode 100644 vendor/github.com/go-playground/locales/tzm/tzm_test.go create mode 100644 vendor/github.com/go-playground/locales/tzm_MA/tzm_MA.go create mode 100644 vendor/github.com/go-playground/locales/tzm_MA/tzm_MA_test.go create mode 100644 vendor/github.com/go-playground/locales/ug/ug.go create mode 100644 vendor/github.com/go-playground/locales/ug/ug_test.go create mode 100644 vendor/github.com/go-playground/locales/ug_CN/ug_CN.go create mode 100644 vendor/github.com/go-playground/locales/ug_CN/ug_CN_test.go create mode 100644 vendor/github.com/go-playground/locales/uk/uk.go create mode 100644 vendor/github.com/go-playground/locales/uk/uk_test.go create mode 100644 vendor/github.com/go-playground/locales/uk_UA/uk_UA.go create mode 100644 vendor/github.com/go-playground/locales/uk_UA/uk_UA_test.go create mode 100644 vendor/github.com/go-playground/locales/ur/ur.go create mode 100644 vendor/github.com/go-playground/locales/ur/ur_test.go create mode 100644 vendor/github.com/go-playground/locales/ur_IN/ur_IN.go create mode 100644 vendor/github.com/go-playground/locales/ur_IN/ur_IN_test.go create mode 100644 vendor/github.com/go-playground/locales/ur_PK/ur_PK.go create mode 100644 vendor/github.com/go-playground/locales/ur_PK/ur_PK_test.go create mode 100644 vendor/github.com/go-playground/locales/uz/uz.go create mode 100644 vendor/github.com/go-playground/locales/uz/uz_test.go create mode 100644 vendor/github.com/go-playground/locales/uz_Arab/uz_Arab.go create mode 100644 vendor/github.com/go-playground/locales/uz_Arab/uz_Arab_test.go create mode 100644 vendor/github.com/go-playground/locales/uz_Arab_AF/uz_Arab_AF.go create mode 100644 vendor/github.com/go-playground/locales/uz_Arab_AF/uz_Arab_AF_test.go create mode 100644 vendor/github.com/go-playground/locales/uz_Cyrl/uz_Cyrl.go create mode 100644 vendor/github.com/go-playground/locales/uz_Cyrl/uz_Cyrl_test.go create mode 100644 vendor/github.com/go-playground/locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go create mode 100644 vendor/github.com/go-playground/locales/uz_Cyrl_UZ/uz_Cyrl_UZ_test.go create mode 100644 vendor/github.com/go-playground/locales/uz_Latn/uz_Latn.go create mode 100644 vendor/github.com/go-playground/locales/uz_Latn/uz_Latn_test.go create mode 100644 vendor/github.com/go-playground/locales/uz_Latn_UZ/uz_Latn_UZ.go create mode 100644 vendor/github.com/go-playground/locales/uz_Latn_UZ/uz_Latn_UZ_test.go create mode 100644 vendor/github.com/go-playground/locales/vai/vai.go create mode 100644 vendor/github.com/go-playground/locales/vai/vai_test.go create mode 100644 vendor/github.com/go-playground/locales/vai_Latn/vai_Latn.go create mode 100644 vendor/github.com/go-playground/locales/vai_Latn/vai_Latn_test.go create mode 100644 vendor/github.com/go-playground/locales/vai_Latn_LR/vai_Latn_LR.go create mode 100644 vendor/github.com/go-playground/locales/vai_Latn_LR/vai_Latn_LR_test.go create mode 100644 vendor/github.com/go-playground/locales/vai_Vaii/vai_Vaii.go create mode 100644 vendor/github.com/go-playground/locales/vai_Vaii/vai_Vaii_test.go create mode 100644 vendor/github.com/go-playground/locales/vai_Vaii_LR/vai_Vaii_LR.go create mode 100644 vendor/github.com/go-playground/locales/vai_Vaii_LR/vai_Vaii_LR_test.go create mode 100644 vendor/github.com/go-playground/locales/vi/vi.go create mode 100644 vendor/github.com/go-playground/locales/vi/vi_test.go create mode 100644 vendor/github.com/go-playground/locales/vi_VN/vi_VN.go create mode 100644 vendor/github.com/go-playground/locales/vi_VN/vi_VN_test.go create mode 100644 vendor/github.com/go-playground/locales/vo/vo.go create mode 100644 vendor/github.com/go-playground/locales/vo/vo_test.go create mode 100644 vendor/github.com/go-playground/locales/vo_001/vo_001.go create mode 100644 vendor/github.com/go-playground/locales/vo_001/vo_001_test.go create mode 100644 vendor/github.com/go-playground/locales/vun/vun.go create mode 100644 vendor/github.com/go-playground/locales/vun/vun_test.go create mode 100644 vendor/github.com/go-playground/locales/vun_TZ/vun_TZ.go create mode 100644 vendor/github.com/go-playground/locales/vun_TZ/vun_TZ_test.go create mode 100644 vendor/github.com/go-playground/locales/wae/wae.go create mode 100644 vendor/github.com/go-playground/locales/wae/wae_test.go create mode 100644 vendor/github.com/go-playground/locales/wae_CH/wae_CH.go create mode 100644 vendor/github.com/go-playground/locales/wae_CH/wae_CH_test.go create mode 100644 vendor/github.com/go-playground/locales/xog/xog.go create mode 100644 vendor/github.com/go-playground/locales/xog/xog_test.go create mode 100644 vendor/github.com/go-playground/locales/xog_UG/xog_UG.go create mode 100644 vendor/github.com/go-playground/locales/xog_UG/xog_UG_test.go create mode 100644 vendor/github.com/go-playground/locales/yav/yav.go create mode 100644 vendor/github.com/go-playground/locales/yav/yav_test.go create mode 100644 vendor/github.com/go-playground/locales/yav_CM/yav_CM.go create mode 100644 vendor/github.com/go-playground/locales/yav_CM/yav_CM_test.go create mode 100644 vendor/github.com/go-playground/locales/yi/yi.go create mode 100644 vendor/github.com/go-playground/locales/yi/yi_test.go create mode 100644 vendor/github.com/go-playground/locales/yi_001/yi_001.go create mode 100644 vendor/github.com/go-playground/locales/yi_001/yi_001_test.go create mode 100644 vendor/github.com/go-playground/locales/yo/yo.go create mode 100644 vendor/github.com/go-playground/locales/yo/yo_test.go create mode 100644 vendor/github.com/go-playground/locales/yo_BJ/yo_BJ.go create mode 100644 vendor/github.com/go-playground/locales/yo_BJ/yo_BJ_test.go create mode 100644 vendor/github.com/go-playground/locales/yo_NG/yo_NG.go create mode 100644 vendor/github.com/go-playground/locales/yo_NG/yo_NG_test.go create mode 100644 vendor/github.com/go-playground/locales/yue/yue.go create mode 100644 vendor/github.com/go-playground/locales/yue/yue_test.go create mode 100644 vendor/github.com/go-playground/locales/yue_HK/yue_HK.go create mode 100644 vendor/github.com/go-playground/locales/yue_HK/yue_HK_test.go create mode 100644 vendor/github.com/go-playground/locales/zgh/zgh.go create mode 100644 vendor/github.com/go-playground/locales/zgh/zgh_test.go create mode 100644 vendor/github.com/go-playground/locales/zgh_MA/zgh_MA.go create mode 100644 vendor/github.com/go-playground/locales/zgh_MA/zgh_MA_test.go create mode 100644 vendor/github.com/go-playground/locales/zh/zh.go create mode 100644 vendor/github.com/go-playground/locales/zh/zh_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans/zh_Hans.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans/zh_Hans_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans_CN/zh_Hans_CN.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans_CN/zh_Hans_CN_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans_HK/zh_Hans_HK.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans_HK/zh_Hans_HK_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans_MO/zh_Hans_MO.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans_MO/zh_Hans_MO_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans_SG/zh_Hans_SG.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hans_SG/zh_Hans_SG_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hant/zh_Hant.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hant/zh_Hant_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hant_HK/zh_Hant_HK.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hant_HK/zh_Hant_HK_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hant_MO/zh_Hant_MO.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hant_MO/zh_Hant_MO_test.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hant_TW/zh_Hant_TW.go create mode 100644 vendor/github.com/go-playground/locales/zh_Hant_TW/zh_Hant_TW_test.go create mode 100644 vendor/github.com/go-playground/locales/zu/zu.go create mode 100644 vendor/github.com/go-playground/locales/zu/zu_test.go create mode 100644 vendor/github.com/go-playground/locales/zu_ZA/zu_ZA.go create mode 100644 vendor/github.com/go-playground/locales/zu_ZA/zu_ZA_test.go create mode 100644 vendor/github.com/go-playground/universal-translator/.gitignore create mode 100644 vendor/github.com/go-playground/universal-translator/LICENSE create mode 100644 vendor/github.com/go-playground/universal-translator/README.md create mode 100644 vendor/github.com/go-playground/universal-translator/benchmarks_test.go create mode 100644 vendor/github.com/go-playground/universal-translator/errors.go create mode 100644 vendor/github.com/go-playground/universal-translator/examples/basic/main.go create mode 100644 vendor/github.com/go-playground/universal-translator/examples/file-formats/cardinal.json create mode 100644 vendor/github.com/go-playground/universal-translator/examples/file-formats/ordinal.json create mode 100644 vendor/github.com/go-playground/universal-translator/examples/file-formats/plain-substitution.json create mode 100644 vendor/github.com/go-playground/universal-translator/examples/file-formats/range.json create mode 100644 vendor/github.com/go-playground/universal-translator/examples/full-no-files/home.tmpl create mode 100644 vendor/github.com/go-playground/universal-translator/examples/full-no-files/main.go create mode 100644 vendor/github.com/go-playground/universal-translator/examples/full-with-files/home.tmpl create mode 100644 vendor/github.com/go-playground/universal-translator/examples/full-with-files/main.go create mode 100644 vendor/github.com/go-playground/universal-translator/examples/full-with-files/translations/en/home.json create mode 100644 vendor/github.com/go-playground/universal-translator/examples/full-with-files/translations/fr/home.json create mode 100644 vendor/github.com/go-playground/universal-translator/import_export.go create mode 100644 vendor/github.com/go-playground/universal-translator/import_export_test.go create mode 100644 vendor/github.com/go-playground/universal-translator/logo.png create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/.gitignore create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/bad-translation1.json create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/bad-translation2.json create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/bad-translation3.json create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/bad-translation4.json create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/bad-translation5.json create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/bad-translation6.json create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/nested1/nested1.json create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/nested1/nested2/nested2.json create mode 100644 vendor/github.com/go-playground/universal-translator/testdata/nested1/nested2/unrelated-file.txt create mode 100644 vendor/github.com/go-playground/universal-translator/translator.go create mode 100644 vendor/github.com/go-playground/universal-translator/translator_test.go create mode 100644 vendor/github.com/go-playground/universal-translator/universal_translator.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/.github/CONTRIBUTING.md create mode 100644 vendor/gopkg.in/go-playground/validator.v9/.github/ISSUE_TEMPLATE.md create mode 100644 vendor/gopkg.in/go-playground/validator.v9/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 vendor/gopkg.in/go-playground/validator.v9/.gitignore create mode 100644 vendor/gopkg.in/go-playground/validator.v9/LICENSE create mode 100644 vendor/gopkg.in/go-playground/validator.v9/README.md create mode 100644 vendor/gopkg.in/go-playground/validator.v9/_examples/custom/main.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/_examples/gin-upgrading-overriding/main.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/_examples/gin-upgrading-overriding/v8_to_v9.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/_examples/simple/main.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/_examples/struct-level/main.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/_examples/translations/main.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/baked_in.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/cache.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/doc.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/errors.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/examples_test.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/field_level.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/logo.png create mode 100644 vendor/gopkg.in/go-playground/validator.v9/regexes.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/struct_level.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/translations.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/translations/en/en.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/translations/en/en_test.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/util.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/validator.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/validator_instance.go create mode 100644 vendor/gopkg.in/go-playground/validator.v9/validator_test.go diff --git a/glide.lock b/glide.lock index 442bf4d126..ac8d4ef0df 100644 --- a/glide.lock +++ b/glide.lock @@ -1,8 +1,8 @@ -hash: 8e720201075f5eebf4b50fb6a4d6c57dc59f1416ac16f9013429f0931b6685b4 -updated: 2017-06-01T12:33:17.417859757-04:00 +hash: 67f0e13bc8656b6069da7262fee9163e3791a894814f702a0c43431b97b4c724 +updated: 2017-07-05T13:40:43.051816462-07:00 imports: - name: github.com/Azure/azure-sdk-for-go - version: 2629e2dfcfeab50896230140542c3b9d89b35ae1 + version: 59c277f1b488b81b1a5f944212f25b69bea8ece3 subpackages: - arm/compute - arm/network @@ -11,7 +11,7 @@ imports: - arm/storage - storage - name: github.com/Azure/go-autorest - version: 58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d + version: 10791a4516e77c53ab10f198f144804cca3d5b43 subpackages: - autorest - autorest/adal @@ -23,6 +23,12 @@ imports: version: 6c8dedd55f8a2e41f605de6d5d66e51ed1f299fc - name: github.com/ghodss/yaml version: 0ca9ea5df5451ffdf184b4428c902747c2c11cd7 +- name: github.com/go-playground/locales + version: 1e5f1161c6416a5ff48840eb8724a394e48cc534 + subpackages: + - currency +- name: github.com/go-playground/universal-translator + version: b32fa301c9fe55953584134cb6853a13c87ec0a1 - name: github.com/inconshreveable/mousetrap version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 - name: github.com/mitchellh/go-homedir @@ -48,6 +54,8 @@ imports: - windows - windows/registry - windows/svc/eventlog +- name: gopkg.in/go-playground/validator.v9 + version: fb68f39656d7ebf8aa339ad4917aa0c260ecc237 - name: gopkg.in/yaml.v2 version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b testImports: diff --git a/glide.yaml b/glide.yaml index 1dbad96e6d..edbaabbf38 100644 --- a/glide.yaml +++ b/glide.yaml @@ -31,6 +31,10 @@ import: version: 4cdb38c072b86bf795d2c81de50784d9fdd6eb77 - package: github.com/spf13/pflag version: e57e3eeb33f795204c1ca35f56c44f83227c6e66 +- package: gopkg.in/go-playground/validator.v9 + version: v9.4.0 +- package: github.com/go-playground/universal-translator + version: v0.16.0 testImport: - package: github.com/onsi/gomega version: ^1.1.0 diff --git a/pkg/api/v20170701/types.go b/pkg/api/v20170701/types.go index 392096f293..7b3ba5f3ff 100644 --- a/pkg/api/v20170701/types.go +++ b/pkg/api/v20170701/types.go @@ -5,6 +5,9 @@ import ( "strings" ) +// The validate tag is used for validation +// Reference to gopkg.in/go-playground/validator.v9 + // ResourcePurchasePlan defines resource plan as required by ARM // for billing purposes. type ResourcePurchasePlan struct { @@ -18,7 +21,7 @@ type ResourcePurchasePlan struct { // resource definition in a JSON template. type ContainerService struct { ID string `json:"id,omitempty"` - Location string `json:"location,omitempty"` + Location string `json:"location,omitempty" validate:"required"` Name string `json:"name,omitempty"` Plan *ResourcePurchasePlan `json:"plan,omitempty"` Tags map[string]string `json:"tags,omitempty"` @@ -30,10 +33,10 @@ type ContainerService struct { // Properties represents the ACS cluster definition type Properties struct { ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` - OrchestratorProfile *OrchestratorProfile `json:"orchestratorProfile,omitempty"` - MasterProfile *MasterProfile `json:"masterProfile,omitempty"` - AgentPoolProfiles []*AgentPoolProfile `json:"agentPoolProfiles,omitempty"` - LinuxProfile *LinuxProfile `json:"linuxProfile,omitempty"` + OrchestratorProfile *OrchestratorProfile `json:"orchestratorProfile,omitempty" validate:"required"` + MasterProfile *MasterProfile `json:"masterProfile,omitempty" validate:"required"` + AgentPoolProfiles []*AgentPoolProfile `json:"agentPoolProfiles,omitempty" validate:"dive,required"` + LinuxProfile *LinuxProfile `json:"linuxProfile,omitempty" validate:"required"` WindowsProfile *WindowsProfile `json:"windowsProfile,omitempty"` ServicePrincipalProfile *ServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"` CustomProfile *CustomProfile `json:"customProfile,omitempty"` @@ -50,8 +53,8 @@ type Properties struct { // is the name of the secret. // (optional) is the version of the secret (default: the latest version) type ServicePrincipalProfile struct { - ClientID string `json:"clientId,omitempty"` - Secret string `json:"secret,omitempty"` + ClientID string `json:"clientId,omitempty" validate:"required"` + Secret string `json:"secret,omitempty" validate:"required"` } // CustomProfile specifies custom properties that are used for @@ -62,19 +65,19 @@ type CustomProfile struct { // LinuxProfile represents the Linux configuration passed to the cluster type LinuxProfile struct { - AdminUsername string `json:"adminUsername"` + AdminUsername string `json:"adminUsername" validate:"required"` SSH struct { PublicKeys []struct { KeyData string `json:"keyData"` - } `json:"publicKeys"` - } `json:"ssh"` + } `json:"publicKeys" validate:"required,len=1"` + } `json:"ssh" validate:"required"` } // WindowsProfile represents the Windows configuration passed to the cluster type WindowsProfile struct { - AdminUsername string `json:"adminUsername,omitempty"` - AdminPassword string `json:"adminPassword,omitempty"` + AdminUsername string `json:"adminUsername,omitempty" validate:"required"` + AdminPassword string `json:"adminPassword,omitempty" validate:"required"` } // ProvisioningState represents the current state of container service resource. @@ -98,19 +101,19 @@ const ( // OrchestratorProfile contains Orchestrator properties type OrchestratorProfile struct { - OrchestratorType OrchestratorType `json:"orchestratorType"` + OrchestratorType OrchestratorType `json:"orchestratorType" validate:"required"` OrchestratorVersion OrchestratorVersion `json:"orchestratorVersion"` } // MasterProfile represents the definition of master cluster type MasterProfile struct { - Count int `json:"count"` - DNSPrefix string `json:"dnsPrefix"` - VMSize string `json:"vmSize"` - OSDiskSizeGB int `json:"osDiskSizeGB,omitempty"` + Count int `json:"count" validate:"required,eq=1|eq=3|eq=5"` + DNSPrefix string `json:"dnsPrefix" validate:"required"` + VMSize string `json:"vmSize" validate:"required"` + OSDiskSizeGB int `json:"osDiskSizeGB,omitempty" validate:"min=0,max=1023"` VnetSubnetID string `json:"vnetSubnetID,omitempty"` FirstConsecutiveStaticIP string `json:"firstConsecutiveStaticIP,omitempty"` - StorageProfile string `json:"storageProfile,omitempty"` + StorageProfile string `json:"storageProfile,omitempty" validate:"eq=StorageAccount|eq=ManagedDisks|len=0"` // subnet is internal subnet string @@ -124,14 +127,14 @@ type MasterProfile struct { // daemons that register with the master and offer resources to // host applications in containers. type AgentPoolProfile struct { - Name string `json:"name"` - Count int `json:"count"` - VMSize string `json:"vmSize"` - OSDiskSizeGB int `json:"osDiskSizeGB,omitempty"` + Name string `json:"name" validate:"required"` + Count int `json:"count" validate:"required,min=1,max=100"` + VMSize string `json:"vmSize" validate:"required"` + OSDiskSizeGB int `json:"osDiskSizeGB,omitempty" validate:"min=0,max=1023"` DNSPrefix string `json:"dnsPrefix"` FQDN string `json:"fqdn"` - Ports []int `json:"ports,omitempty"` - StorageProfile string `json:"storageProfile"` + Ports []int `json:"ports,omitempty" validate:"dive,min=1,max=65535"` + StorageProfile string `json:"storageProfile" validate:"eq=StorageAccount|eq=ManagedDisks|len=0"` VnetSubnetID string `json:"vnetSubnetID,omitempty"` // OSType is the operating system type for agents // Set as nullable to support backward compat because diff --git a/pkg/api/v20170701/validate.go b/pkg/api/v20170701/validate.go index d93438e14b..9a8df70b64 100644 --- a/pkg/api/v20170701/validate.go +++ b/pkg/api/v20170701/validate.go @@ -5,10 +5,21 @@ import ( "fmt" "net" "regexp" + "strings" + + validator "gopkg.in/go-playground/validator.v9" ) +var validate *validator.Validate + +func init() { + validate = validator.New() +} + // Validate implements APIObject func (o *OrchestratorProfile) Validate() error { + // Don't need to call validate.Struct(o) + // It is handled by Properties.Validate() switch o.OrchestratorType { case Swarm: case DCOS: @@ -39,52 +50,29 @@ func (o *OrchestratorProfile) Validate() error { // Validate implements APIObject func (m *MasterProfile) Validate() error { - if m.Count != 1 && m.Count != 3 && m.Count != 5 { - return fmt.Errorf("MasterProfile count needs to be 1, 3, or 5") - } - if e := validateName(m.DNSPrefix, "MasterProfile.DNSPrefix"); e != nil { - return e - } + // Don't need to call validate.Struct(m) + // It is handled by Properties.Validate() if e := validateDNSName(m.DNSPrefix); e != nil { return e } - if e := validateName(m.VMSize, "MasterProfile.VMSize"); e != nil { - return e - } - if m.OSDiskSizeGB != 0 && (m.OSDiskSizeGB < MinDiskSizeGB || m.OSDiskSizeGB > MaxDiskSizeGB) { - return fmt.Errorf("Invalid master os disk size of %d specified. The range of valid values are [%d, %d]", m.OSDiskSizeGB, MinDiskSizeGB, MaxDiskSizeGB) - } - if e := validateStorageProfile(m.StorageProfile); e != nil { - return e - } return nil } // Validate implements APIObject func (a *AgentPoolProfile) Validate(orchestratorType OrchestratorType) error { - if e := validateName(a.Name, "AgentPoolProfile.Name"); e != nil { - return e - } + // Don't need to call validate.Struct(a) + // It is handled by Properties.Validate() if e := validatePoolName(a.Name); e != nil { return e } - if a.Count < MinAgentCount || a.Count > MaxAgentCount { - return fmt.Errorf("AgentPoolProfile count needs to be in the range [%d,%d]", MinAgentCount, MaxAgentCount) - } - if e := validateName(a.VMSize, "AgentPoolProfile.VMSize"); e != nil { - return e - } // Kubernetes don't allow agent DNSPrefix if orchestratorType == Kubernetes { // The line below need to be removed after June 2017 a.DNSPrefix = "" - if e := validateNameEmpty(a.DNSPrefix, "AgentPoolProfile.DNSPrefix"); e != nil { + if e := validate.Var(a.DNSPrefix, "len=0"); e != nil { return e } } - if a.OSDiskSizeGB != 0 && (a.OSDiskSizeGB < MinDiskSizeGB || a.OSDiskSizeGB > MaxDiskSizeGB) { - return fmt.Errorf("Invalid os disk size of %d specified. The range of valid values are [%d, %d]", a.OSDiskSizeGB, MinDiskSizeGB, MaxDiskSizeGB) - } if a.DNSPrefix != "" { if e := validateDNSName(a.DNSPrefix); e != nil { return e @@ -93,11 +81,6 @@ func (a *AgentPoolProfile) Validate(orchestratorType OrchestratorType) error { if e := validateUniquePorts(a.Ports, a.Name); e != nil { return e } - for _, port := range a.Ports { - if port < MinPort || port > MaxPort { - return fmt.Errorf("AgentPoolProfile Ports must be in the range[%d, %d]", MinPort, MaxPort) - } - } } else { a.Ports = []int{80, 443, 8080} } @@ -106,36 +89,60 @@ func (a *AgentPoolProfile) Validate(orchestratorType OrchestratorType) error { return fmt.Errorf("AgentPoolProfile.Ports must be empty when AgentPoolProfile.DNSPrefix is empty") } } - if e := validateStorageProfile(a.StorageProfile); e != nil { - return e - } return nil } // Validate implements APIObject func (l *LinuxProfile) Validate() error { - if e := validateName(l.AdminUsername, "LinuxProfile.AdminUsername"); e != nil { - return e - } - if len(l.SSH.PublicKeys) != 1 { - return errors.New("LinuxProfile.PublicKeys requires only 1 SSH Key") - } - if e := validateName(l.SSH.PublicKeys[0].KeyData, "LinuxProfile.PublicKeys.KeyData"); e != nil { - return e + // Don't need to call validate.Struct(l) + // It is handled by Properties.Validate() + if e := validate.Var(l.SSH.PublicKeys[0].KeyData, "required"); e != nil { + return fmt.Errorf("KeyData in LinuxProfile.SSH.PublicKeys cannot be empty string") } return nil } +func handleValidationErrors(e validator.ValidationErrors) error { + err := e[0] + ns := err.Namespace() + switch ns { + case "Properties.OrchestratorProfile", "Properties.MasterProfile", + "Properties.MasterProfile.DNSPrefix", "Properties.MasterProfile.VMSize", + "Properties.LinuxProfile", "Properties.ServicePrincipalProfile.ClientID", + "Properties.ServicePrincipalProfile.Secret", "Properties.WindowsProfile.AdminUsername", + "Properties.WindowsProfile.AdminPassword": + return fmt.Errorf("missing %s", ns) + case "Properties.MasterProfile.Count": + return fmt.Errorf("MasterProfile count needs to be 1, 3, or 5") + case "Properties.MasterProfile.OSDiskSizeGB": + return fmt.Errorf("Invalid os disk size of %d specified. The range of valid values are [%d, %d]", err.Value().(int), MinDiskSizeGB, MaxDiskSizeGB) + case "Properties.MasterProfile.StorageProfile": + return fmt.Errorf("Unknown storageProfile '%s'. Specify either %s or %s", err.Value().(string), StorageAccount, ManagedDisks) + default: + if strings.HasPrefix(ns, "Properties.AgentPoolProfiles") { + switch { + case strings.HasSuffix(ns, ".Name") || strings.HasSuffix(ns, "VMSize"): + return fmt.Errorf("missing %s", ns) + case strings.HasSuffix(ns, ".Count"): + return fmt.Errorf("AgentPoolProfile count needs to be in the range [%d,%d]", MinAgentCount, MaxAgentCount) + case strings.HasSuffix(ns, ".OSDiskSizeGB"): + return fmt.Errorf("Invalid os disk size of %d specified. The range of valid values are [%d, %d]", err.Value().(int), MinDiskSizeGB, MaxDiskSizeGB) + case strings.Contains(ns, ".Ports"): + return fmt.Errorf("AgentPoolProfile Ports must be in the range[%d, %d]", MinPort, MaxPort) + case strings.HasSuffix(ns, ".StorageProfile"): + return fmt.Errorf("Unknown storageProfile '%s'. Specify either %s or %s", err.Value().(string), StorageAccount, ManagedDisks) + default: + break + } + } + } + return fmt.Errorf("Namespace %s is not caught, %+v", ns, e) +} + // Validate implements APIObject func (a *Properties) Validate() error { - if a.OrchestratorProfile == nil { - return fmt.Errorf("missing OrchestratorProfile") - } - if a.MasterProfile == nil { - return fmt.Errorf("missing MasterProfile") - } - if a.LinuxProfile == nil { - return fmt.Errorf("missing LinuxProfile") + if e := validate.Struct(a); e != nil { + return handleValidationErrors(e.(validator.ValidationErrors)) } if e := a.OrchestratorProfile.Validate(); e != nil { return e @@ -150,27 +157,12 @@ func (a *Properties) Validate() error { if a.ServicePrincipalProfile == nil { return fmt.Errorf("missing ServicePrincipalProfile") } - if len(a.ServicePrincipalProfile.ClientID) == 0 { - return fmt.Errorf("the service principal client ID must be specified with Orchestrator %s", a.OrchestratorProfile.OrchestratorType) - } - if len(a.ServicePrincipalProfile.Secret) == 0 { - return fmt.Errorf("the service principal client secrect must be specified with Orchestrator %s", a.OrchestratorProfile.OrchestratorType) - } } for _, agentPoolProfile := range a.AgentPoolProfiles { if e := agentPoolProfile.Validate(a.OrchestratorProfile.OrchestratorType); e != nil { return e } - switch agentPoolProfile.StorageProfile { - case StorageAccount: - case ManagedDisks: - case "": - default: - { - return fmt.Errorf("unknown storage type '%s' for agent pool '%s'. Specify either %s, or %s", agentPoolProfile.StorageProfile, agentPoolProfile.Name, StorageAccount, ManagedDisks) - } - } if agentPoolProfile.OSType == Windows { if a.WindowsProfile == nil { @@ -201,20 +193,6 @@ func (a *Properties) Validate() error { return nil } -func validateNameEmpty(name string, label string) error { - if name != "" { - return fmt.Errorf("%s must be an empty value", label) - } - return nil -} - -func validateName(name string, label string) error { - if name == "" { - return fmt.Errorf("%s must be a non-empty value", label) - } - return nil -} - func validatePoolName(poolName string) error { // we will cap at length of 12 and all lowercase letters since this makes up the VMName poolNameRegex := `^([a-z][a-z0-9]{0,11})$` @@ -252,19 +230,6 @@ func validateUniqueProfileNames(profiles []*AgentPoolProfile) error { return nil } -func validateStorageProfile(storageProfile string) error { - switch storageProfile { - case StorageAccount: - case ManagedDisks: - case "": - default: - { - return fmt.Errorf("Unknown storageProfile '%s'. Specify either %s or %s", storageProfile, StorageAccount, ManagedDisks) - } - } - return nil -} - func validateUniquePorts(ports []int, name string) error { portMap := make(map[int]bool) for _, port := range ports { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/.travis.yml b/vendor/github.com/Azure/azure-sdk-for-go/.travis.yml index cd0c0802d2..123091326b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/.travis.yml +++ b/vendor/github.com/Azure/azure-sdk-for-go/.travis.yml @@ -31,3 +31,5 @@ script: - go vet ./storage/... - test -z "$(golint ./Gododir/... | tee /dev/stderr)" - go vet ./Gododir/... + - bash buildTerraform.sh + \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/Gododir/gen.go b/vendor/github.com/Azure/azure-sdk-for-go/Gododir/gen.go index 6b68f16ebc..d6839cfe88 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/Gododir/gen.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/Gododir/gen.go @@ -279,6 +279,11 @@ var ( // Extension: md, Swagger: "backupManagement", }, + { + Name: "recoveryservicessiterecovery", + Version: "2016-08-10", + Swagger: "service", + }, { Name: "redis", Version: "2016-04-01", @@ -306,6 +311,10 @@ var ( Name: "locks", Version: "2016-09-01", }, + { + Name: "managedapplications", + Version: "2016-09-01-preview", + }, { Name: "policy", Version: "2016-12-01", @@ -359,12 +368,16 @@ var ( Name: "storageimportexport", Version: "2016-11-01", }, - // { - // Too soon to release - // Name: "storsimple8000series", - // Version: "2017-06-01". - // Swagger: "storsimple", - // }, + { + Name: "storsimple8000series", + Version: "2017-06-01", + Swagger: "storsimple", + }, + { + Name: "streamanalytics", + Swagger: "compositeStreamAnalytics", + Modeler: compSwagger, + }, // { // error in the modeler // Name: "timeseriesinsights", @@ -556,7 +569,10 @@ func generate(service *service) { "-Namespace", service.Name, "-OutputDirectory", service.Output, "-Modeler", string(service.Modeler), - "-pv", sdkVersion, + "-PackageVersion", sdkVersion, + } + if testGen { + commandArgs = append([]string{"-LEGACY"}, commandArgs...) } // default to the current directory diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/version.go index 94b9607062..9c375771f2 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/advisor/version.go @@ -20,10 +20,10 @@ package advisor // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-advisor/2017-04-19" + return "Azure-SDK-For-Go/v10.1.0-beta arm-advisor/2017-04-19" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/version.go index e801840792..c8f01a6135 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/analysisservices/version.go @@ -20,10 +20,10 @@ package analysisservices // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-analysisservices/2016-05-16" + return "Azure-SDK-For-Go/v10.1.0-beta arm-analysisservices/2016-05-16" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/version.go index 53a1c459ec..e788b71345 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/apimanagement/version.go @@ -20,10 +20,10 @@ package apimanagement // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-apimanagement/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-apimanagement/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/version.go index d8e37bc801..312b5345e8 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/appinsights/version.go @@ -20,10 +20,10 @@ package appinsights // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-appinsights/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-appinsights/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/version.go index f6b65dcd35..dad681833e 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/authorization/version.go @@ -20,10 +20,10 @@ package authorization // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-authorization/2015-07-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-authorization/2015-07-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go index 5a144eb099..5369eb9599 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/automation/version.go @@ -20,10 +20,10 @@ package automation // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-automation/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-automation/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/version.go index 2c0c5959e5..b921dd7994 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/batch/version.go @@ -20,10 +20,10 @@ package batch // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-batch/2017-01-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-batch/2017-01-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/version.go index 6ef3da8302..5394ea3eec 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/billing/version.go @@ -20,10 +20,10 @@ package billing // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-billing/2017-04-24-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-billing/2017-04-24-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go index afea5d8416..20a61d9c5c 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cdn/version.go @@ -20,10 +20,10 @@ package cdn // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-cdn/2016-10-02" + return "Azure-SDK-For-Go/v10.1.0-beta arm-cdn/2016-10-02" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/version.go index cba03d5e9d..cb67a2f9e5 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/cognitiveservices/version.go @@ -20,10 +20,10 @@ package cognitiveservices // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-cognitiveservices/2016-02-01-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-cognitiveservices/2016-02-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/version.go index 185b4c56df..071a3609c2 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/commerce/version.go @@ -20,10 +20,10 @@ package commerce // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-commerce/2015-06-01-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-commerce/2015-06-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go index a5318ebf79..b109440fe3 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go @@ -20,10 +20,10 @@ package compute // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-compute/2016-04-30-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-compute/2016-04-30-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/version.go index a4e9f43a4b..eea4583ea5 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/consumption/version.go @@ -20,10 +20,10 @@ package consumption // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-consumption/2017-04-24-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-consumption/2017-04-24-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go index e586a01ce7..88072968bd 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go @@ -20,10 +20,10 @@ package containerregistry // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-containerregistry/2017-03-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-containerregistry/2017-03-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go index a678060b4b..b20ab1d6bf 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/containerservice/version.go @@ -20,10 +20,10 @@ package containerservice // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-containerservice/2017-01-31" + return "Azure-SDK-For-Go/v10.1.0-beta arm-containerservice/2017-01-31" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/version.go index ed2f00824d..e520b3c014 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/customer-insights/version.go @@ -20,10 +20,10 @@ package customerinsights // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-customerinsights/2017-01-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-customerinsights/2017-01-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/version.go index 5d627a4dce..5fd97ef7b0 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-analytics/account/version.go @@ -20,10 +20,10 @@ package account // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-account/2016-11-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-account/2016-11-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/version.go index 5d627a4dce..5fd97ef7b0 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/datalake-store/account/version.go @@ -20,10 +20,10 @@ package account // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-account/2016-11-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-account/2016-11-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/version.go index 32062bdcfa..e5eeeb84a5 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/devtestlabs/version.go @@ -20,10 +20,10 @@ package devtestlabs // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-devtestlabs/2016-05-15" + return "Azure-SDK-For-Go/v10.1.0-beta arm-devtestlabs/2016-05-15" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go index a78b351a0e..07ff63ca76 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/disk/version.go @@ -20,10 +20,10 @@ package disk // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-disk/2016-04-30-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-disk/2016-04-30-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/version.go index 054f065276..2ce2f8cfb1 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/dns/version.go @@ -20,10 +20,10 @@ package dns // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-dns/2016-04-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-dns/2016-04-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/version.go index dbbd4d7b1f..08bed111f7 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/documentdb/version.go @@ -20,10 +20,10 @@ package documentdb // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-documentdb/2015-04-08" + return "Azure-SDK-For-Go/v10.1.0-beta arm-documentdb/2015-04-08" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go index 58298d4ebf..8665649517 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/eventhub/version.go @@ -20,10 +20,10 @@ package eventhub // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-eventhub/2015-08-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-eventhub/2015-08-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/check/check.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/check/check.go index 91c84513b8..762e8c3d47 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/check/check.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/check/check.go @@ -49,7 +49,7 @@ func main() { return } ac := storage.NewAccountsClient(c["AZURE_SUBSCRIPTION_ID"]) - ac.Authorizer = spt + ac.Authorizer = autorest.NewBearerAuthorizer(spt) ac.Sender = autorest.CreateSender( autorest.WithLogging(log.New(os.Stdout, "sdk-example: ", log.LstdFlags))) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/create/create.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/create/create.go index 0cf3cf8723..48ef886fd7 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/create/create.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/create/create.go @@ -7,6 +7,7 @@ import ( "github.com/Azure/azure-sdk-for-go/arm/examples/helpers" "github.com/Azure/azure-sdk-for-go/arm/storage" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/to" ) @@ -31,7 +32,7 @@ func main() { } ac := storage.NewAccountsClient(c["AZURE_SUBSCRIPTION_ID"]) - ac.Authorizer = spt + ac.Authorizer = autorest.NewBearerAuthorizer(spt) cna, err := ac.CheckNameAvailability( storage.AccountCheckNameAvailabilityParameters{ @@ -53,7 +54,10 @@ func main() { Tier: storage.Standard}, Location: to.StringPtr("westus")} cancel := make(chan struct{}) - if _, err = ac.Create(resourceGroup, name, cp, cancel); err != nil { + + _, errchan := ac.Create(resourceGroup, name, cp, cancel) + err = <-errchan + if err != nil { fmt.Printf("Create '%s' storage account failed: %v\n", name, err) return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/README.md b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/README.md new file mode 100644 index 0000000000..348aad4cd0 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/README.md @@ -0,0 +1,34 @@ +# Example Accessing the Azure DNS API + +## Prerequisites + +1. Create an Azure Resource Group. The code assumes `delete-dns` as the name: `az group create -l westus -n delete-dns` + +2. Create a Service Principal to access the resource group for example with the Azure CLI +``` +az ad sp create-for-rbac --role contributor --scopes /subscriptions//resourceGroups/delete-dns + +{ + "appId": "", + "displayName": "", + "name": "", + "password": "", + "tenant": "" +} +``` +3. Set the following environment variables from the service principal +- AZURE_CLIENT_ID= +- AZURE_CLIENT_SECRET= +- AZURE_SUBSCRIPTION_ID= +- AZURE_TENANT_ID= + +You can query the subscription id for your subscription with: `az account show --query id` + +4. Get the dependencies +- go get github.com/Azure/go-autorest/autorest +- go get github.com/Azure/go-autorest/autorest/azure +- github.com/Azure/azure-sdk-for-go/arm + +## Run the sample + +Execute with `go run create.go` \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/create.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/create.go new file mode 100644 index 0000000000..d8c9effe26 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/create.go @@ -0,0 +1,194 @@ +package main + +import ( + "fmt" + "log" + "os" + + "github.com/Azure/azure-sdk-for-go/arm/dns" + "github.com/Azure/azure-sdk-for-go/arm/examples/helpers" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" +) + +func main() { + resourceGroup := "delete-dns" + + c := map[string]string{ + "AZURE_CLIENT_ID": os.Getenv("AZURE_CLIENT_ID"), + "AZURE_CLIENT_SECRET": os.Getenv("AZURE_CLIENT_SECRET"), + "AZURE_SUBSCRIPTION_ID": os.Getenv("AZURE_SUBSCRIPTION_ID"), + "AZURE_TENANT_ID": os.Getenv("AZURE_TENANT_ID")} + if err := checkEnvVar(&c); err != nil { + log.Fatalf("Error: %v", err) + return + } + spt, err := helpers.NewServicePrincipalTokenFromCredentials(c, azure.PublicCloud.ResourceManagerEndpoint) + if err != nil { + log.Fatalf("Error: %v", err) + return + } + + dc := dns.NewZonesClient(c["AZURE_SUBSCRIPTION_ID"]) + dc.Authorizer = autorest.NewBearerAuthorizer(spt) + rc := dns.NewRecordSetsClient(c["AZURE_SUBSCRIPTION_ID"]) + rc.Authorizer = autorest.NewBearerAuthorizer(spt) + + newZoneName := "xtoph-test.local" + + zoneParam := &dns.Zone{ + Location: to.StringPtr("global"), + ZoneProperties: &dns.ZoneProperties{ + MaxNumberOfRecordSets: to.Int64Ptr(1), + NumberOfRecordSets: to.Int64Ptr(1), + // NameServers: [ "my-nameserver.xtoph.com" ] + }, + } + + newZone, err := dc.CreateOrUpdate(resourceGroup, newZoneName, *zoneParam, "", "") + if err != nil { + log.Fatalf("Couldn't create Zone %s Error: %v\n", newZoneName, err) + return + } + fmt.Printf("Status: %s\n", newZone.Status) + + fmt.Printf("New Zone Created\n") + + rrparams := &dns.RecordSet{ + RecordSetProperties: &dns.RecordSetProperties{ + TTL: to.Int64Ptr(1000), + ARecords: &[]dns.ARecord{ + {Ipv4Address: to.StringPtr("2.2.2.2")}, + }, + }, + } + + fmt.Printf("Creating A Rec\n") + + aRecName := "newTestARecordFromAPI" + _, err = rc.CreateOrUpdate(resourceGroup, newZoneName, aRecName, dns.A, *rrparams, "", "") + if err != nil { + log.Fatalf("Error creating Cname: %s, %v", newZoneName, err) + return + } + + cnameparams := &dns.RecordSet{ + RecordSetProperties: &dns.RecordSetProperties{ + TTL: to.Int64Ptr(1000), + CnameRecord: &dns.CnameRecord{ + Cname: to.StringPtr("my-new-cname"), + }, + }, + } + + fmt.Printf("Creating CName\n") + cnameRecordName := "newTestCNameRecordFromAPI" + _, err = rc.CreateOrUpdate(resourceGroup, newZoneName, cnameRecordName, dns.CNAME, *cnameparams, "", "") + if err != nil { + log.Fatalf("Error creating Cname: %s, %v", newZoneName, err) + return + } + + zone, err := dc.Get(resourceGroup, newZoneName) + + if err != nil { + log.Fatalf("Error getting zone: %s, %v", newZoneName, err) + return + } + + fmt.Printf("Nameservers for %s \n", *zone.Name) + + for _, ns := range *zone.NameServers { + fmt.Printf("%s\n", ns) + } + + fmt.Printf("Recordsets for %s \n", *zone.Name) + + var top int32 + top = 10 + rrsets, err := rc.ListByDNSZone(resourceGroup, newZoneName, &top) + if err != nil { + log.Fatalf("Error: %v", err) + return + } + + for _, rrset := range *rrsets.Value { + fmt.Printf("Recordset: %s Type: %s\n", *rrset.Name, *rrset.Type) + + switch *rrset.Type { + case "Microsoft.Network/dnszones/A": + printARecords(rrset) + case "Microsoft.Network/dnszones/CNAME": + printCNames(rrset) + case "Microsoft.Network/dnszones/NS": + printNS(rrset) + case "Microsoft.Network/dnszones/SOA": + printSOA(rrset) + } + } + + fmt.Printf("*** Cleaning up *** ") + rc.Delete(resourceGroup, newZoneName, cnameRecordName, dns.CNAME, "") + rc.Delete(resourceGroup, newZoneName, aRecName, dns.A, "") + dc.Delete(resourceGroup, newZoneName, "", nil) + fmt.Printf("done\n") + +} + +func printNS(rrset dns.RecordSet) { + fmt.Printf("*** NS Record ***\n") + if rrset.NsRecords != nil { + for _, ns := range *rrset.NsRecords { + fmt.Printf("Nameserver: %s\n", *ns.Nsdname) + } + } else { + fmt.Printf("*** None ***\n") + } +} + +func printSOA(rrset dns.RecordSet) { + fmt.Printf("*** SOA Record ***\n") + + if rrset.SoaRecord != nil { + fmt.Printf("Email: %s\n", *rrset.SoaRecord.Email) + fmt.Printf("Host: %s\n", *rrset.SoaRecord.Host) + } else { + fmt.Printf("*** None ***\n") + } + +} + +func printCNames(rrset dns.RecordSet) { + fmt.Printf("*** CNAME Record ***\n") + if rrset.CnameRecord != nil { + fmt.Printf("Cname %s\n", *rrset.CnameRecord.Cname) + } else { + fmt.Printf("*** None ***\n") + } + +} +func printARecords(rrset dns.RecordSet) { + fmt.Printf("*** A Records ***\n") + if rrset.ARecords != nil { + for _, arec := range *rrset.ARecords { + fmt.Printf("record %s\n", *arec.Ipv4Address) + } + } else { + fmt.Printf("*** None ***\n") + } + +} + +func checkEnvVar(envVars *map[string]string) error { + var missingVars []string + for varName, value := range *envVars { + if value == "" { + missingVars = append(missingVars, varName) + } + } + if len(missingVars) > 0 { + return fmt.Errorf("Missing environment variables %v", missingVars) + } + return nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/paging/paging.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/paging/paging.go new file mode 100644 index 0000000000..cc0f10b1a6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/dns/paging/paging.go @@ -0,0 +1,201 @@ +package main + +import ( + "fmt" + "log" + "os" + "strconv" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "github.com/xtophs/azure-sdk-for-go/arm/dns" + "github.com/xtophs/azure-sdk-for-go/arm/examples/helpers" +) + +func main() { + resourceGroup := "delete-dns" + + c := map[string]string{ + "AZURE_CLIENT_ID": os.Getenv("AZURE_CLIENT_ID"), + "AZURE_CLIENT_SECRET": os.Getenv("AZURE_CLIENT_SECRET"), + "AZURE_SUBSCRIPTION_ID": os.Getenv("AZURE_SUBSCRIPTION_ID"), + "AZURE_TENANT_ID": os.Getenv("AZURE_TENANT_ID")} + if err := checkEnvVar(&c); err != nil { + log.Fatalf("Error: %v", err) + return + } + spt, err := helpers.NewServicePrincipalTokenFromCredentials(c, azure.PublicCloud.ResourceManagerEndpoint) + if err != nil { + log.Fatalf("Error: %v", err) + return + } + + dc := dns.NewZonesClient(c["AZURE_SUBSCRIPTION_ID"]) + dc.Authorizer = autorest.NewBearerAuthorizer(spt) + rc := dns.NewRecordSetsClient(c["AZURE_SUBSCRIPTION_ID"]) + rc.Authorizer = autorest.NewBearerAuthorizer(spt) + + newZoneName := "xtoph-test.local" + + zoneParam := &dns.Zone{ + Location: to.StringPtr("global"), + ZoneProperties: &dns.ZoneProperties{ + MaxNumberOfRecordSets: to.Int64Ptr(1), + NumberOfRecordSets: to.Int64Ptr(1), + }, + } + + newZone, err := dc.CreateOrUpdate(resourceGroup, newZoneName, *zoneParam, "", "") + if err != nil { + log.Fatalf("Couldn't create Zone %s Error: %v\n", newZoneName, err) + return + } + fmt.Printf("Status: %s\n", newZone.Status) + + fmt.Printf("New Zone Created\n") + + for i := 0; i < 12; i++ { + cnameRecordName := "www1" + strconv.Itoa(i) + cnameparams := &dns.RecordSet{ + Name: &cnameRecordName, + ID: &cnameRecordName, + RecordSetProperties: &dns.RecordSetProperties{ + TTL: to.Int64Ptr(1000), + CnameRecord: &dns.CnameRecord{ + Cname: to.StringPtr("alias." + newZoneName), + }, + }, + } + + fmt.Printf("Creating CName %q\n", cnameRecordName) + _, err = rc.CreateOrUpdate(resourceGroup, newZoneName, cnameRecordName, dns.CNAME, *cnameparams, "", "*") + if err != nil { + log.Fatalf("Error creating Cname: %s, %v", newZoneName, err) + break + } + } + + zone, err := dc.Get(resourceGroup, newZoneName) + + if err != nil { + log.Fatalf("Error getting zone: %s, %v", newZoneName, err) + return + } + + fmt.Printf("Nameservers for %s \n", *zone.Name) + + for _, ns := range *zone.NameServers { + fmt.Printf("%s\n", ns) + } + + fmt.Printf("Recordsets for %s \n", *zone.Name) + + var top int32 + top = 10 + page := 0 + rrsets := make([]dns.RecordSet, 0) + result, err := rc.ListByDNSZone(resourceGroup, newZoneName, &top) + if err != nil { + log.Fatalf("Error: %v", err) + return + } + appendListRecordSetsResult(&rrsets, result, &rc, &page) + + printResults(&rrsets) + + fmt.Printf("*** Cleaning up *** ") + defer dc.Delete(resourceGroup, newZoneName, "", nil) + fmt.Printf("done\n") +} + +func printResults(rrsets *[]dns.RecordSet) { + for _, rrset := range *rrsets { + fmt.Printf("Recordset: %s Type: %s\n", *rrset.Name, *rrset.Type) + switch *rrset.Type { + case "Microsoft.Network/dnszones/A": + printARecords(rrset) + case "Microsoft.Network/dnszones/CNAME": + printCNames(rrset) + case "Microsoft.Network/dnszones/NS": + printNS(rrset) + case "Microsoft.Network/dnszones/SOA": + printSOA(rrset) + } + } + + fmt.Printf("Got %d records\n", len(*rrsets)) + +} + +func appendListRecordSetsResult(rrsets *[]dns.RecordSet, result dns.RecordSetListResult, rc *dns.RecordSetsClient, page *int) { + for _, rset := range *result.Value { + *rrsets = append(*rrsets, rset) + } + + if result.NextLink != nil { + fmt.Printf("Fetching more from %q\n", *result.NextLink) + result, _ := rc.ListByDNSZoneNextResults(result) + // TODO Error handling + *page++ + appendListRecordSetsResult(rrsets, result, rc, page) + + } +} + +func printNS(rrset dns.RecordSet) { + fmt.Printf("*** NS Record ***\n") + if rrset.NsRecords != nil { + for _, ns := range *rrset.NsRecords { + fmt.Printf("Nameserver: %s\n", *ns.Nsdname) + } + } else { + fmt.Printf("*** None ***\n") + } +} + +func printSOA(rrset dns.RecordSet) { + fmt.Printf("*** SOA Record ***\n") + + if rrset.SoaRecord != nil { + fmt.Printf("Email: %s\n", *rrset.SoaRecord.Email) + fmt.Printf("Host: %s\n", *rrset.SoaRecord.Host) + } else { + fmt.Printf("*** None ***\n") + } + +} + +func printCNames(rrset dns.RecordSet) { + fmt.Printf("*** CNAME Record Name: %q ID: %q ***\n", *rrset.Name, *rrset.ID) + if rrset.CnameRecord != nil { + fmt.Printf("Cname %s\n", *rrset.CnameRecord.Cname) + } else { + fmt.Printf("*** None ***\n") + } + +} +func printARecords(rrset dns.RecordSet) { + fmt.Printf("*** A Record Name: %q ID: %q ***\n", *rrset.Name, *rrset.ID) + if rrset.ARecords != nil { + for _, arec := range *rrset.ARecords { + fmt.Printf("record %s\n", *arec.Ipv4Address) + } + } else { + fmt.Printf("*** None ***\n") + } + +} + +func checkEnvVar(envVars *map[string]string) error { + var missingVars []string + for varName, value := range *envVars { + if value == "" { + missingVars = append(missingVars, varName) + } + } + if len(missingVars) > 0 { + return fmt.Errorf("Missing environment variables %v", missingVars) + } + return nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go index 24c76dcfa3..f883215ef4 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/examples/helpers/helpers.go @@ -3,7 +3,7 @@ package helpers import ( "encoding/json" "fmt" - + "github.com/Azure/go-autorest/autorest/adal" "github.com/Azure/go-autorest/autorest/azure" ) @@ -20,12 +20,12 @@ func ToJSON(v interface{}) (string, error) { // NewServicePrincipalTokenFromCredentials creates a new ServicePrincipalToken using values of the // passed credentials map. -func NewServicePrincipalTokenFromCredentials(c map[string]string, scope string) (*azure.ServicePrincipalToken, error) { - oauthConfig, err := azure.PublicCloud.OAuthConfigForTenant(c["AZURE_TENANT_ID"]) +func NewServicePrincipalTokenFromCredentials(c map[string]string, scope string) (*adal.ServicePrincipalToken, error) { + oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, c["AZURE_TENANT_ID"]) if err != nil { panic(err) } - return azure.NewServicePrincipalToken(*oauthConfig, c["AZURE_CLIENT_ID"], c["AZURE_CLIENT_SECRET"], scope) + return adal.NewServicePrincipalToken(*oauthConfig, c["AZURE_CLIENT_ID"], c["AZURE_CLIENT_SECRET"], scope) } func ensureValueStrings(mapOfInterface map[string]interface{}) map[string]string { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/version.go index 1283f0d758..3133880f20 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/graphrbac/version.go @@ -20,10 +20,10 @@ package graphrbac // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-graphrbac/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-graphrbac/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/version.go index 9346b53d71..57271c4c24 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/hdinsight/version.go @@ -20,10 +20,10 @@ package hdinsight // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-hdinsight/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-hdinsight/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/version.go index 7a1506ff50..2978f2dd05 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/insights/version.go @@ -20,10 +20,10 @@ package insights // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-insights/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-insights/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/version.go index 4d79e09d0f..35e1647271 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/intune/version.go @@ -20,10 +20,10 @@ package intune // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-intune/2015-01-14-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-intune/2015-01-14-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/version.go index f827c53a91..569f19b634 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/iothub/version.go @@ -20,10 +20,10 @@ package iothub // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-iothub/2016-02-03" + return "Azure-SDK-For-Go/v10.1.0-beta arm-iothub/2016-02-03" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go index cf5e06aad4..70f5ddb895 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/keyvault/version.go @@ -20,10 +20,10 @@ package keyvault // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-keyvault/2015-06-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-keyvault/2015-06-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/version.go index 6415a25667..26bc655a48 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/logic/version.go @@ -20,10 +20,10 @@ package logic // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-logic/2016-06-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-logic/2016-06-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/version.go index 6aca3510b4..54647fb164 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/commitmentplans/version.go @@ -20,10 +20,10 @@ package commitmentplans // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-commitmentplans/2016-05-01-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-commitmentplans/2016-05-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/version.go index a9aec92019..431da2ea74 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/machinelearning/webservices/version.go @@ -20,10 +20,10 @@ package webservices // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-webservices/2017-01-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-webservices/2017-01-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/version.go index 32be126596..dfafa114f2 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/mediaservices/version.go @@ -20,10 +20,10 @@ package mediaservices // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-mediaservices/2015-10-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-mediaservices/2015-10-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/version.go index af6758f7e4..3cb2c5aef0 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/mobileengagement/version.go @@ -20,10 +20,10 @@ package mobileengagement // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-mobileengagement/2014-12-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-mobileengagement/2014-12-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/version.go index 2b23857278..4f0588ae39 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/monitor/version.go @@ -20,10 +20,10 @@ package monitor // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-monitor/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-monitor/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go index 50b836179f..c4e26e5d28 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go @@ -20,10 +20,10 @@ package network // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-network/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-network/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/version.go index d1c5746f14..deb4bddc85 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/notificationhubs/version.go @@ -20,10 +20,10 @@ package notificationhubs // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-notificationhubs/2017-04-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-notificationhubs/2017-04-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go index ad6ad74e5a..ee8f152ebf 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/operationalinsights/version.go @@ -20,10 +20,10 @@ package operationalinsights // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-operationalinsights/2015-11-01-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-operationalinsights/2015-11-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/version.go index 83a32bd170..d745b204d8 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/powerbiembedded/version.go @@ -20,10 +20,10 @@ package powerbiembedded // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-powerbiembedded/2016-01-29" + return "Azure-SDK-For-Go/v10.1.0-beta arm-powerbiembedded/2016-01-29" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/version.go index 4299a0ef65..bba9befd01 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservices/version.go @@ -20,10 +20,10 @@ package recoveryservices // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-recoveryservices/2016-06-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-recoveryservices/2016-06-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/version.go index 9b084bb2f9..fd29eca65e 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicesbackup/version.go @@ -20,10 +20,10 @@ package recoveryservicesbackup // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-recoveryservicesbackup/2016-12-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-recoveryservicesbackup/2016-12-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/client.go new file mode 100644 index 0000000000..306afcc277 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/client.go @@ -0,0 +1,56 @@ +// Package recoveryservicessiterecovery implements the Azure ARM Recoveryservicessiterecovery service API version +// 2016-08-10. +// +// +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Recoveryservicessiterecovery + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Recoveryservicessiterecovery. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string + ResourceGroupName string + ResourceName string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string, resourceGroupName string, resourceName string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/models.go new file mode 100644 index 0000000000..20115820ef --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/models.go @@ -0,0 +1,2832 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// A2ARpRecoveryPointType enumerates the values for a2a rp recovery point type. +type A2ARpRecoveryPointType string + +const ( + // Latest specifies the latest state for a2a rp recovery point type. + Latest A2ARpRecoveryPointType = "Latest" + // LatestApplicationConsistent specifies the latest application consistent state for a2a rp recovery point type. + LatestApplicationConsistent A2ARpRecoveryPointType = "LatestApplicationConsistent" + // LatestCrashConsistent specifies the latest crash consistent state for a2a rp recovery point type. + LatestCrashConsistent A2ARpRecoveryPointType = "LatestCrashConsistent" + // LatestProcessed specifies the latest processed state for a2a rp recovery point type. + LatestProcessed A2ARpRecoveryPointType = "LatestProcessed" +) + +// AlternateLocationRecoveryOption enumerates the values for alternate location recovery option. +type AlternateLocationRecoveryOption string + +const ( + // CreateVMIfNotFound specifies the create vm if not found state for alternate location recovery option. + CreateVMIfNotFound AlternateLocationRecoveryOption = "CreateVmIfNotFound" + // NoAction specifies the no action state for alternate location recovery option. + NoAction AlternateLocationRecoveryOption = "NoAction" +) + +// DataSyncStatus enumerates the values for data sync status. +type DataSyncStatus string + +const ( + // ForDownTime specifies the for down time state for data sync status. + ForDownTime DataSyncStatus = "ForDownTime" + // ForSynchronization specifies the for synchronization state for data sync status. + ForSynchronization DataSyncStatus = "ForSynchronization" +) + +// DisableProtectionReason enumerates the values for disable protection reason. +type DisableProtectionReason string + +const ( + // MigrationComplete specifies the migration complete state for disable protection reason. + MigrationComplete DisableProtectionReason = "MigrationComplete" + // NotSpecified specifies the not specified state for disable protection reason. + NotSpecified DisableProtectionReason = "NotSpecified" +) + +// FailoverDeploymentModel enumerates the values for failover deployment model. +type FailoverDeploymentModel string + +const ( + // Classic specifies the classic state for failover deployment model. + Classic FailoverDeploymentModel = "Classic" + // NotApplicable specifies the not applicable state for failover deployment model. + NotApplicable FailoverDeploymentModel = "NotApplicable" + // ResourceManager specifies the resource manager state for failover deployment model. + ResourceManager FailoverDeploymentModel = "ResourceManager" +) + +// HyperVReplicaAzureRpRecoveryPointType enumerates the values for hyper v replica azure rp recovery point type. +type HyperVReplicaAzureRpRecoveryPointType string + +const ( + // HyperVReplicaAzureRpRecoveryPointTypeLatest specifies the hyper v replica azure rp recovery point type latest + // state for hyper v replica azure rp recovery point type. + HyperVReplicaAzureRpRecoveryPointTypeLatest HyperVReplicaAzureRpRecoveryPointType = "Latest" + // HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent specifies the hyper v replica azure rp recovery + // point type latest application consistent state for hyper v replica azure rp recovery point type. + HyperVReplicaAzureRpRecoveryPointTypeLatestApplicationConsistent HyperVReplicaAzureRpRecoveryPointType = "LatestApplicationConsistent" + // HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed specifies the hyper v replica azure rp recovery point type + // latest processed state for hyper v replica azure rp recovery point type. + HyperVReplicaAzureRpRecoveryPointTypeLatestProcessed HyperVReplicaAzureRpRecoveryPointType = "LatestProcessed" +) + +// InMageV2RpRecoveryPointType enumerates the values for in mage v2 rp recovery point type. +type InMageV2RpRecoveryPointType string + +const ( + // InMageV2RpRecoveryPointTypeLatest specifies the in mage v2 rp recovery point type latest state for in mage v2 rp + // recovery point type. + InMageV2RpRecoveryPointTypeLatest InMageV2RpRecoveryPointType = "Latest" + // InMageV2RpRecoveryPointTypeLatestApplicationConsistent specifies the in mage v2 rp recovery point type latest + // application consistent state for in mage v2 rp recovery point type. + InMageV2RpRecoveryPointTypeLatestApplicationConsistent InMageV2RpRecoveryPointType = "LatestApplicationConsistent" + // InMageV2RpRecoveryPointTypeLatestCrashConsistent specifies the in mage v2 rp recovery point type latest crash + // consistent state for in mage v2 rp recovery point type. + InMageV2RpRecoveryPointTypeLatestCrashConsistent InMageV2RpRecoveryPointType = "LatestCrashConsistent" + // InMageV2RpRecoveryPointTypeLatestProcessed specifies the in mage v2 rp recovery point type latest processed + // state for in mage v2 rp recovery point type. + InMageV2RpRecoveryPointTypeLatestProcessed InMageV2RpRecoveryPointType = "LatestProcessed" +) + +// LicenseType enumerates the values for license type. +type LicenseType string + +const ( + // LicenseTypeNoLicenseType specifies the license type no license type state for license type. + LicenseTypeNoLicenseType LicenseType = "NoLicenseType" + // LicenseTypeNotSpecified specifies the license type not specified state for license type. + LicenseTypeNotSpecified LicenseType = "NotSpecified" + // LicenseTypeWindowsServer specifies the license type windows server state for license type. + LicenseTypeWindowsServer LicenseType = "WindowsServer" +) + +// PossibleOperationsDirections enumerates the values for possible operations directions. +type PossibleOperationsDirections string + +const ( + // PrimaryToRecovery specifies the primary to recovery state for possible operations directions. + PrimaryToRecovery PossibleOperationsDirections = "PrimaryToRecovery" + // RecoveryToPrimary specifies the recovery to primary state for possible operations directions. + RecoveryToPrimary PossibleOperationsDirections = "RecoveryToPrimary" +) + +// RecoveryPlanActionLocation enumerates the values for recovery plan action location. +type RecoveryPlanActionLocation string + +const ( + // Primary specifies the primary state for recovery plan action location. + Primary RecoveryPlanActionLocation = "Primary" + // Recovery specifies the recovery state for recovery plan action location. + Recovery RecoveryPlanActionLocation = "Recovery" +) + +// RecoveryPlanGroupType enumerates the values for recovery plan group type. +type RecoveryPlanGroupType string + +const ( + // Boot specifies the boot state for recovery plan group type. + Boot RecoveryPlanGroupType = "Boot" + // Failover specifies the failover state for recovery plan group type. + Failover RecoveryPlanGroupType = "Failover" + // Shutdown specifies the shutdown state for recovery plan group type. + Shutdown RecoveryPlanGroupType = "Shutdown" +) + +// ReplicationProtectedItemOperation enumerates the values for replication protected item operation. +type ReplicationProtectedItemOperation string + +const ( + // ChangePit specifies the change pit state for replication protected item operation. + ChangePit ReplicationProtectedItemOperation = "ChangePit" + // Commit specifies the commit state for replication protected item operation. + Commit ReplicationProtectedItemOperation = "Commit" + // CompleteMigration specifies the complete migration state for replication protected item operation. + CompleteMigration ReplicationProtectedItemOperation = "CompleteMigration" + // DisableProtection specifies the disable protection state for replication protected item operation. + DisableProtection ReplicationProtectedItemOperation = "DisableProtection" + // Failback specifies the failback state for replication protected item operation. + Failback ReplicationProtectedItemOperation = "Failback" + // FinalizeFailback specifies the finalize failback state for replication protected item operation. + FinalizeFailback ReplicationProtectedItemOperation = "FinalizeFailback" + // PlannedFailover specifies the planned failover state for replication protected item operation. + PlannedFailover ReplicationProtectedItemOperation = "PlannedFailover" + // RepairReplication specifies the repair replication state for replication protected item operation. + RepairReplication ReplicationProtectedItemOperation = "RepairReplication" + // ReverseReplicate specifies the reverse replicate state for replication protected item operation. + ReverseReplicate ReplicationProtectedItemOperation = "ReverseReplicate" + // SwitchProtection specifies the switch protection state for replication protected item operation. + SwitchProtection ReplicationProtectedItemOperation = "SwitchProtection" + // TestFailover specifies the test failover state for replication protected item operation. + TestFailover ReplicationProtectedItemOperation = "TestFailover" + // TestFailoverCleanup specifies the test failover cleanup state for replication protected item operation. + TestFailoverCleanup ReplicationProtectedItemOperation = "TestFailoverCleanup" + // UnplannedFailover specifies the unplanned failover state for replication protected item operation. + UnplannedFailover ReplicationProtectedItemOperation = "UnplannedFailover" +) + +// RpInMageRecoveryPointType enumerates the values for rp in mage recovery point type. +type RpInMageRecoveryPointType string + +const ( + // Custom specifies the custom state for rp in mage recovery point type. + Custom RpInMageRecoveryPointType = "Custom" + // LatestTag specifies the latest tag state for rp in mage recovery point type. + LatestTag RpInMageRecoveryPointType = "LatestTag" + // LatestTime specifies the latest time state for rp in mage recovery point type. + LatestTime RpInMageRecoveryPointType = "LatestTime" +) + +// SetMultiVMSyncStatus enumerates the values for set multi vm sync status. +type SetMultiVMSyncStatus string + +const ( + // Disable specifies the disable state for set multi vm sync status. + Disable SetMultiVMSyncStatus = "Disable" + // Enable specifies the enable state for set multi vm sync status. + Enable SetMultiVMSyncStatus = "Enable" +) + +// SourceSiteOperations enumerates the values for source site operations. +type SourceSiteOperations string + +const ( + // NotRequired specifies the not required state for source site operations. + NotRequired SourceSiteOperations = "NotRequired" + // Required specifies the required state for source site operations. + Required SourceSiteOperations = "Required" +) + +// A2AApplyRecoveryPointInput is applyRecoveryPoint input specific to A2A provider. +type A2AApplyRecoveryPointInput struct { +} + +// A2AContainerCreationInput is a2A cloud creation input. +type A2AContainerCreationInput struct { +} + +// A2AEnableProtectionInput is a2A enable protection input. +type A2AEnableProtectionInput struct { + FabricObjectID *string `json:"fabricObjectId,omitempty"` + RecoveryContainerID *string `json:"recoveryContainerId,omitempty"` + RecoveryResourceGroupID *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryCloudServiceID *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryAvailabilitySetID *string `json:"recoveryAvailabilitySetId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` +} + +// A2AEventDetails is model class for event details of a A2A event. +type A2AEventDetails struct { + ProtectedItemName *string `json:"protectedItemName,omitempty"` + FabricObjectID *string `json:"fabricObjectId,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + FabricLocation *string `json:"fabricLocation,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` + RemoteFabricLocation *string `json:"remoteFabricLocation,omitempty"` +} + +// A2AFailoverProviderInput is a2A provider specific input for failover. +type A2AFailoverProviderInput struct { + RecoveryPointID *string `json:"recoveryPointId,omitempty"` + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` +} + +// A2APolicyCreationInput is a2A Policy creation input. +type A2APolicyCreationInput struct { + RecoveryPointHistory *int32 `json:"recoveryPointHistory,omitempty"` + CrashConsistentFrequencyInMinutes *int32 `json:"crashConsistentFrequencyInMinutes,omitempty"` + AppConsistentFrequencyInMinutes *int32 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus,omitempty"` +} + +// A2APolicyDetails is a2A specific policy details. +type A2APolicyDetails struct { + RecoveryPointThresholdInMinutes *int32 `json:"recoveryPointThresholdInMinutes,omitempty"` + RecoveryPointHistory *int32 `json:"recoveryPointHistory,omitempty"` + AppConsistentFrequencyInMinutes *int32 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + CrashConsistentFrequencyInMinutes *int32 `json:"crashConsistentFrequencyInMinutes,omitempty"` +} + +// A2AProtectedDiskDetails is a2A protected disk details. +type A2AProtectedDiskDetails struct { + DiskURI *string `json:"diskUri,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + RecoveryAzureStorageAccountID *string `json:"recoveryAzureStorageAccountId,omitempty"` + PrimaryStagingAzureStorageAccountID *string `json:"primaryStagingAzureStorageAccountId,omitempty"` + PrimaryDiskAzureStorageAccountID *string `json:"primaryDiskAzureStorageAccountId,omitempty"` + RecoveryDiskURI *string `json:"recoveryDiskUri,omitempty"` + DiskType *string `json:"diskType,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + MonitoringPercentageCompletion *int32 `json:"monitoringPercentageCompletion,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + DataPendingInStagingStorageAccountInMB *float64 `json:"dataPendingInStagingStorageAccountInMB,omitempty"` + DataPendingAtSourceAgentInMB *float64 `json:"dataPendingAtSourceAgentInMB,omitempty"` +} + +// A2AReplicationDetails is a2A provider specific settings. +type A2AReplicationDetails struct { + FabricObjectID *string `json:"fabricObjectId,omitempty"` + MultiVMGroupID *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + ManagementID *string `json:"managementId,omitempty"` + ProtectedDisks *[]A2AProtectedDiskDetails `json:"protectedDisks,omitempty"` + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` + OsType *string `json:"osType,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureResourceGroupID *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryCloudService *string `json:"recoveryCloudService,omitempty"` + RecoveryAvailabilitySet *string `json:"recoveryAvailabilitySet,omitempty"` + SelectedRecoveryAzureNetworkID *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMSyncedConfigDetails *AzureToAzureVMSyncedConfigDetails `json:"vmSyncedConfigDetails,omitempty"` + MonitoringPercentageCompletion *int32 `json:"monitoringPercentageCompletion,omitempty"` + MonitoringJobType *string `json:"monitoringJobType,omitempty"` + LastHeartbeat *date.Time `json:"lastHeartbeat,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + IsReplicationAgentUpdateRequired *bool `json:"isReplicationAgentUpdateRequired,omitempty"` + RecoveryFabricObjectID *string `json:"recoveryFabricObjectId,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + LifecycleID *string `json:"lifecycleId,omitempty"` +} + +// A2AReprotectInput is azure specific reprotect input. +type A2AReprotectInput struct { + RecoveryContainerID *string `json:"recoveryContainerId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + RecoveryResourceGroupID *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryCloudServiceID *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryAvailabilitySetID *string `json:"recoveryAvailabilitySetId,omitempty"` + PolicyID *string `json:"policyId,omitempty"` +} + +// A2ASwitchProtectionInput is a2A specific switch protection input. +type A2ASwitchProtectionInput struct { + RecoveryContainerID *string `json:"recoveryContainerId,omitempty"` + VMDisks *[]A2AVMDiskInputDetails `json:"vmDisks,omitempty"` + RecoveryResourceGroupID *string `json:"recoveryResourceGroupId,omitempty"` + RecoveryCloudServiceID *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryAvailabilitySetID *string `json:"recoveryAvailabilitySetId,omitempty"` + PolicyID *string `json:"policyId,omitempty"` +} + +// A2AUpdateReplicationProtectedItemInput is inMage Azure V2 input to update replication protected item. +type A2AUpdateReplicationProtectedItemInput struct { + RecoveryCloudServiceID *string `json:"recoveryCloudServiceId,omitempty"` + RecoveryResourceGroupID *string `json:"recoveryResourceGroupId,omitempty"` +} + +// A2AVMDiskInputDetails is azure VM disk input details. +type A2AVMDiskInputDetails struct { + DiskURI *string `json:"diskUri,omitempty"` + RecoveryAzureStorageAccountID *string `json:"recoveryAzureStorageAccountId,omitempty"` + PrimaryStagingAzureStorageAccountID *string `json:"primaryStagingAzureStorageAccountId,omitempty"` +} + +// AddVCenterRequest is input required to add vCenter. +type AddVCenterRequest struct { + Properties *AddVCenterRequestProperties `json:"properties,omitempty"` +} + +// AddVCenterRequestProperties is the properties of an add vCenter request. +type AddVCenterRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + Port *string `json:"port,omitempty"` + RunAsAccountID *string `json:"runAsAccountId,omitempty"` +} + +// Alert is implements the Alert class. +type Alert struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *AlertProperties `json:"properties,omitempty"` +} + +// AlertCollection is collection of alerts. +type AlertCollection struct { + autorest.Response `json:"-"` + Value *[]Alert `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// AlertCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client AlertCollection) AlertCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// AlertProperties is the proprties of an alert. +type AlertProperties struct { + SendToOwners *string `json:"sendToOwners,omitempty"` + CustomEmailAddresses *[]string `json:"customEmailAddresses,omitempty"` + Locale *string `json:"locale,omitempty"` +} + +// ApplyRecoveryPointInput is input to apply recovery point. +type ApplyRecoveryPointInput struct { + Properties *ApplyRecoveryPointInputProperties `json:"properties,omitempty"` +} + +// ApplyRecoveryPointInputProperties is input properties to apply recovery point. +type ApplyRecoveryPointInputProperties struct { + RecoveryPointID *string `json:"recoveryPointId,omitempty"` + ProviderSpecificDetails *ApplyRecoveryPointProviderSpecificInput `json:"providerSpecificDetails,omitempty"` +} + +// ApplyRecoveryPointProviderSpecificInput is provider specific input for apply recovery point. +type ApplyRecoveryPointProviderSpecificInput struct { +} + +// ARMException is ARM inner exception class. +type ARMException struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` + Details *[]ARMExceptionDetails `json:"details,omitempty"` + Innererror *ARMInnerError `json:"innererror,omitempty"` +} + +// ARMExceptionDetails is service based exception details. +type ARMExceptionDetails struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + ClientRequestID *string `json:"clientRequestId,omitempty"` + ActivityID *string `json:"activityId,omitempty"` + Target *string `json:"target,omitempty"` +} + +// ARMInnerError is ARM internal error class for providing additional debug data. +type ARMInnerError struct { + Trace *string `json:"trace,omitempty"` + Source *string `json:"source,omitempty"` + MethodStatus *MethodCallStatus `json:"methodStatus,omitempty"` + CloudID *string `json:"cloudId,omitempty"` + HVHostID *string `json:"hVHostId,omitempty"` + HVClusterID *string `json:"hVClusterId,omitempty"` + NetworkID *string `json:"networkId,omitempty"` + VMID *string `json:"vmId,omitempty"` + FabricID *string `json:"fabricId,omitempty"` + LiveID *string `json:"liveId,omitempty"` + ContainerID *string `json:"containerId,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + SubscriptionID *string `json:"subscriptionId,omitempty"` + SerializedSRSLogContext *string `json:"serializedSRSLogContext,omitempty"` +} + +// AsrJobDetails is this class represents job details based on specific job type. +type AsrJobDetails struct { + AffectedObjectDetails *map[string]*string `json:"affectedObjectDetails,omitempty"` +} + +// ASRTask is task of the Job. +type ASRTask struct { + TaskID *string `json:"taskId,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + AllowedActions *[]string `json:"allowedActions,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + TaskType *string `json:"taskType,omitempty"` + CustomDetails *TaskTypeDetails `json:"customDetails,omitempty"` + GroupTaskCustomDetails *GroupTaskDetails `json:"groupTaskCustomDetails,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` +} + +// AutomationRunbookTaskDetails is this class represents the task details for an automation runbook. +type AutomationRunbookTaskDetails struct { + Name *string `json:"name,omitempty"` + CloudServiceName *string `json:"cloudServiceName,omitempty"` + SubscriptionID *string `json:"subscriptionId,omitempty"` + AccountName *string `json:"accountName,omitempty"` + RunbookID *string `json:"runbookId,omitempty"` + RunbookName *string `json:"runbookName,omitempty"` + JobID *string `json:"jobId,omitempty"` + JobOutput *string `json:"jobOutput,omitempty"` + IsPrimarySideScript *bool `json:"isPrimarySideScript,omitempty"` +} + +// AzureFabricCreationInput is fabric provider specific settings. +type AzureFabricCreationInput struct { + Location *string `json:"location,omitempty"` +} + +// AzureFabricSpecificDetails is azure Fabric Specific Details. +type AzureFabricSpecificDetails struct { + Location *string `json:"location,omitempty"` + ContainerIds *[]string `json:"containerIds,omitempty"` +} + +// AzureToAzureCreateNetworkMappingInput is create network mappings input properties/behaviour specific to Azure to +// Azure Network mapping. +type AzureToAzureCreateNetworkMappingInput struct { + PrimaryNetworkID *string `json:"primaryNetworkId,omitempty"` +} + +// AzureToAzureNetworkMappingSettings is a2A Network Mapping fabric specific settings. +type AzureToAzureNetworkMappingSettings struct { + PrimaryFabricLocation *string `json:"primaryFabricLocation,omitempty"` + RecoveryFabricLocation *string `json:"recoveryFabricLocation,omitempty"` +} + +// AzureToAzureUpdateNetworkMappingInput is updates network mappings input. +type AzureToAzureUpdateNetworkMappingInput struct { + PrimaryNetworkID *string `json:"primaryNetworkId,omitempty"` +} + +// AzureToAzureVMSyncedConfigDetails is azure to Azure VM synced configuration details. +type AzureToAzureVMSyncedConfigDetails struct { + Tags *map[string]*string `json:"tags,omitempty"` + RoleAssignments *[]RoleAssignment `json:"roleAssignments,omitempty"` + InputEndpoints *[]InputEndpoint `json:"inputEndpoints,omitempty"` +} + +// AzureVMDiskDetails is disk details for E2A provider. +type AzureVMDiskDetails struct { + VhdType *string `json:"vhdType,omitempty"` + VhdID *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + MaxSizeMB *string `json:"maxSizeMB,omitempty"` + TargetDiskLocation *string `json:"targetDiskLocation,omitempty"` + TargetDiskName *string `json:"targetDiskName,omitempty"` + LunID *string `json:"lunId,omitempty"` +} + +// ConfigurationSettings is replication provider specific settings. +type ConfigurationSettings struct { +} + +// ConfigureAlertRequest is request to configure alerts for the system. +type ConfigureAlertRequest struct { + Properties *ConfigureAlertRequestProperties `json:"properties,omitempty"` +} + +// ConfigureAlertRequestProperties is properties of a configure alert request. +type ConfigureAlertRequestProperties struct { + SendToOwners *string `json:"sendToOwners,omitempty"` + CustomEmailAddresses *[]string `json:"customEmailAddresses,omitempty"` + Locale *string `json:"locale,omitempty"` +} + +// ConsistencyCheckTaskDetails is this class contains monitoring details of all the inconsistent Protected Entites in +// Vmm. +type ConsistencyCheckTaskDetails struct { + VMDetails *[]InconsistentVMDetails `json:"vmDetails,omitempty"` +} + +// CreateNetworkMappingInput is create network mappings input. +type CreateNetworkMappingInput struct { + Properties *CreateNetworkMappingInputProperties `json:"properties,omitempty"` +} + +// CreateNetworkMappingInputProperties is common input details for network mapping operation. +type CreateNetworkMappingInputProperties struct { + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkID *string `json:"recoveryNetworkId,omitempty"` + FabricSpecificDetails *FabricSpecificCreateNetworkMappingInput `json:"fabricSpecificDetails,omitempty"` +} + +// CreatePolicyInput is protection profile input. +type CreatePolicyInput struct { + Properties *CreatePolicyInputProperties `json:"properties,omitempty"` +} + +// CreatePolicyInputProperties is policy creation properties. +type CreatePolicyInputProperties struct { + ProviderSpecificInput *PolicyProviderSpecificInput `json:"providerSpecificInput,omitempty"` +} + +// CreateProtectionContainerInput is create protection container input. +type CreateProtectionContainerInput struct { + Properties *CreateProtectionContainerInputProperties `json:"properties,omitempty"` +} + +// CreateProtectionContainerInputProperties is create protection container input properties. +type CreateProtectionContainerInputProperties struct { + ProviderSpecificInput *[]ReplicationProviderSpecificContainerCreationInput `json:"providerSpecificInput,omitempty"` +} + +// CreateProtectionContainerMappingInput is configure pairing input. +type CreateProtectionContainerMappingInput struct { + Properties *CreateProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} + +// CreateProtectionContainerMappingInputProperties is configure pairing input properties. +type CreateProtectionContainerMappingInputProperties struct { + TargetProtectionContainerID *string `json:"targetProtectionContainerId,omitempty"` + PolicyID *string `json:"PolicyId,omitempty"` + ProviderSpecificInput *ReplicationProviderSpecificContainerMappingInput `json:"providerSpecificInput,omitempty"` +} + +// CreateRecoveryPlanInput is create recovery plan input class. +type CreateRecoveryPlanInput struct { + Properties *CreateRecoveryPlanInputProperties `json:"properties,omitempty"` +} + +// CreateRecoveryPlanInputProperties is recovery plan creation properties. +type CreateRecoveryPlanInputProperties struct { + PrimaryFabricID *string `json:"primaryFabricId,omitempty"` + RecoveryFabricID *string `json:"recoveryFabricId,omitempty"` + FailoverDeploymentModel FailoverDeploymentModel `json:"failoverDeploymentModel,omitempty"` + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` +} + +// CurrentScenarioDetails is current scenario details of the protected entity. +type CurrentScenarioDetails struct { + ScenarioName *string `json:"scenarioName,omitempty"` + JobID *string `json:"jobId,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` +} + +// DataStore is the datastore details of the MT. +type DataStore struct { + SymbolicName *string `json:"symbolicName,omitempty"` + UUID *string `json:"uuid,omitempty"` + Capacity *string `json:"capacity,omitempty"` + FreeSpace *string `json:"freeSpace,omitempty"` + Type *string `json:"type,omitempty"` +} + +// DisableProtectionInput is disable protection input. +type DisableProtectionInput struct { + Properties *DisableProtectionInputProperties `json:"properties,omitempty"` +} + +// DisableProtectionInputProperties is disable protection input properties. +type DisableProtectionInputProperties struct { + DisableProtectionReason DisableProtectionReason `json:"disableProtectionReason,omitempty"` + ReplicationProviderInput *DisableProtectionProviderSpecificInput `json:"replicationProviderInput,omitempty"` +} + +// DisableProtectionProviderSpecificInput is disable protection provider specific input. +type DisableProtectionProviderSpecificInput struct { +} + +// DiscoverProtectableItemRequest is request to add a physical machine as a protectable item in a container. +type DiscoverProtectableItemRequest struct { + Properties *DiscoverProtectableItemRequestProperties `json:"properties,omitempty"` +} + +// DiscoverProtectableItemRequestProperties is discover protectable item properties. +type DiscoverProtectableItemRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + OsType *string `json:"osType,omitempty"` +} + +// DiskDetails is onprem disk details data. +type DiskDetails struct { + MaxSizeMB *int64 `json:"maxSizeMB,omitempty"` + VhdType *string `json:"vhdType,omitempty"` + VhdID *string `json:"vhdId,omitempty"` + VhdName *string `json:"vhdName,omitempty"` +} + +// DiskVolumeDetails is volume details. +type DiskVolumeDetails struct { + Label *string `json:"label,omitempty"` + Name *string `json:"name,omitempty"` +} + +// Display is contains the localized display information for this particular operation / action. These value will be +// used by several clients for (1) custom role definitions for RBAC; (2) complex query filters for the event service; +// and (3) audit history / records for management operations. +type Display struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` + Description *string `json:"description,omitempty"` +} + +// EnableProtectionInput is enable protection input. +type EnableProtectionInput struct { + Properties *EnableProtectionInputProperties `json:"properties,omitempty"` +} + +// EnableProtectionInputProperties is enable protection input properties. +type EnableProtectionInputProperties struct { + PolicyID *string `json:"policyId,omitempty"` + ProtectableItemID *string `json:"protectableItemId,omitempty"` + ProviderSpecificDetails *EnableProtectionProviderSpecificInput `json:"providerSpecificDetails,omitempty"` +} + +// EnableProtectionProviderSpecificInput is enable protection provider specific input. +type EnableProtectionProviderSpecificInput struct { +} + +// EncryptionDetails is encryption details for the fabric. +type EncryptionDetails struct { + KekState *string `json:"kekState,omitempty"` + KekCertThumbprint *string `json:"kekCertThumbprint,omitempty"` + KekCertExpiryDate *date.Time `json:"kekCertExpiryDate,omitempty"` +} + +// Event is implements the Event class. +type Event struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *EventProperties `json:"properties,omitempty"` +} + +// EventCollection is collection of fabric details. +type EventCollection struct { + autorest.Response `json:"-"` + Value *[]Event `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// EventCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client EventCollection) EventCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// EventProperties is the properties of a monitoring event. +type EventProperties struct { + EventCode *string `json:"eventCode,omitempty"` + Description *string `json:"description,omitempty"` + EventType *string `json:"eventType,omitempty"` + AffectedObjectFriendlyName *string `json:"affectedObjectFriendlyName,omitempty"` + Severity *string `json:"severity,omitempty"` + TimeOfOccurrence *date.Time `json:"timeOfOccurrence,omitempty"` + FabricID *string `json:"fabricId,omitempty"` + ProviderSpecificDetails *EventProviderSpecificDetails `json:"providerSpecificDetails,omitempty"` + EventSpecificDetails *EventSpecificDetails `json:"eventSpecificDetails,omitempty"` + HealthErrors *[]HealthError `json:"healthErrors,omitempty"` +} + +// EventProviderSpecificDetails is model class for provider specific details for an event. +type EventProviderSpecificDetails struct { +} + +// EventSpecificDetails is model class for event specific details for an event. +type EventSpecificDetails struct { +} + +// ExportJobDetails is this class represents details for export jobs workflow. +type ExportJobDetails struct { + AffectedObjectDetails *map[string]*string `json:"affectedObjectDetails,omitempty"` + BlobURI *string `json:"blobUri,omitempty"` + SasToken *string `json:"sasToken,omitempty"` +} + +// Fabric is fabric definition. +type Fabric struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *FabricProperties `json:"properties,omitempty"` +} + +// FabricCollection is collection of fabric details. +type FabricCollection struct { + autorest.Response `json:"-"` + Value *[]Fabric `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// FabricCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client FabricCollection) FabricCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// FabricCreationInput is site details provided during the time of site creation +type FabricCreationInput struct { + Properties *FabricCreationInputProperties `json:"properties,omitempty"` +} + +// FabricCreationInputProperties is properties of site details provided during the time of site creation +type FabricCreationInputProperties struct { + CustomDetails *FabricSpecificCreationInput `json:"customDetails,omitempty"` +} + +// FabricProperties is fabric properties. +type FabricProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + RolloverEncryptionDetails *EncryptionDetails `json:"rolloverEncryptionDetails,omitempty"` + InternalIdentifier *string `json:"internalIdentifier,omitempty"` + BcdrState *string `json:"bcdrState,omitempty"` + CustomDetails *FabricSpecificDetails `json:"customDetails,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + Health *string `json:"health,omitempty"` +} + +// FabricReplicationGroupTaskDetails is this class represents the fabric replication group task details. +type FabricReplicationGroupTaskDetails struct { + SkippedReason *string `json:"skippedReason,omitempty"` + SkippedReasonString *string `json:"skippedReasonString,omitempty"` + JobTask *JobEntity `json:"jobTask,omitempty"` +} + +// FabricSpecificCreateNetworkMappingInput is input details specific to fabrics during Network Mapping. +type FabricSpecificCreateNetworkMappingInput struct { +} + +// FabricSpecificCreationInput is fabric provider specific settings. +type FabricSpecificCreationInput struct { +} + +// FabricSpecificDetails is fabric specific details. +type FabricSpecificDetails struct { +} + +// FabricSpecificUpdateNetworkMappingInput is input details specific to fabrics during Network Mapping. +type FabricSpecificUpdateNetworkMappingInput struct { +} + +// FailoverProcessServerRequest is request to failover a process server. +type FailoverProcessServerRequest struct { + Properties *FailoverProcessServerRequestProperties `json:"properties,omitempty"` +} + +// FailoverProcessServerRequestProperties is the properties of the Failover Process Server request. +type FailoverProcessServerRequestProperties struct { + ContainerName *string `json:"containerName,omitempty"` + SourceProcessServerID *string `json:"sourceProcessServerId,omitempty"` + TargetProcessServerID *string `json:"targetProcessServerId,omitempty"` + VmsToMigrate *[]string `json:"vmsToMigrate,omitempty"` + UpdateType *string `json:"updateType,omitempty"` +} + +// GroupTaskDetails is this class represents the group task details when parent child relationship exists in the drill +// down. +type GroupTaskDetails struct { + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` +} + +// HealthError is the health error class. +type HealthError struct { + ErrorLevel *string `json:"errorLevel,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + CreationTimeUtc *date.Time `json:"creationTimeUtc,omitempty"` + RecoveryProviderErrorMessage *string `json:"recoveryProviderErrorMessage,omitempty"` + EntityID *string `json:"entityId,omitempty"` +} + +// HyperVReplica2012EventDetails is model class for event details of a HyperVReplica E2E event. +type HyperVReplica2012EventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` +} + +// HyperVReplica2012R2EventDetails is model class for event details of a HyperVReplica blue E2E event. +type HyperVReplica2012R2EventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` +} + +// HyperVReplicaAzureApplyRecoveryPointInput is applyRecoveryPoint input specific to HyperVReplicaAzure provider. +type HyperVReplicaAzureApplyRecoveryPointInput struct { + VaultLocation *string `json:"vaultLocation,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` +} + +// HyperVReplicaAzureEnableProtectionInput is azure specific enable protection input. +type HyperVReplicaAzureEnableProtectionInput struct { + HvHostVMID *string `json:"hvHostVmId,omitempty"` + VMName *string `json:"vmName,omitempty"` + OsType *string `json:"osType,omitempty"` + VhdID *string `json:"vhdId,omitempty"` + TargetStorageAccountID *string `json:"targetStorageAccountId,omitempty"` + TargetAzureNetworkID *string `json:"targetAzureNetworkId,omitempty"` + TargetAzureSubnetID *string `json:"targetAzureSubnetId,omitempty"` + EnableRDPOnTargetOption *string `json:"enableRDPOnTargetOption,omitempty"` + TargetAzureVMName *string `json:"targetAzureVmName,omitempty"` + LogStorageAccountID *string `json:"logStorageAccountId,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + TargetAzureV1ResourceGroupID *string `json:"targetAzureV1ResourceGroupId,omitempty"` + TargetAzureV2ResourceGroupID *string `json:"targetAzureV2ResourceGroupId,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` +} + +// HyperVReplicaAzureEventDetails is model class for event details of a HyperVReplica E2A event. +type HyperVReplicaAzureEventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` +} + +// HyperVReplicaAzureFailbackProviderInput is hvrA provider specific input for failback. +type HyperVReplicaAzureFailbackProviderInput struct { + DataSyncOption *string `json:"dataSyncOption,omitempty"` + RecoveryVMCreationOption *string `json:"recoveryVmCreationOption,omitempty"` + ProviderIDForAlternateRecovery *string `json:"providerIdForAlternateRecovery,omitempty"` +} + +// HyperVReplicaAzureFailoverProviderInput is hvrA provider specific input for failover. +type HyperVReplicaAzureFailoverProviderInput struct { + VaultLocation *string `json:"vaultLocation,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + RecoveryPointID *string `json:"recoveryPointId,omitempty"` +} + +// HyperVReplicaAzurePolicyDetails is hyper-V Replica Azure specific protection profile details. +type HyperVReplicaAzurePolicyDetails struct { + RecoveryPointHistoryDurationInHours *int32 `json:"recoveryPointHistoryDurationInHours,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int32 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + ReplicationInterval *int32 `json:"replicationInterval,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + Encryption *string `json:"encryption,omitempty"` + ActiveStorageAccountID *string `json:"activeStorageAccountId,omitempty"` +} + +// HyperVReplicaAzurePolicyInput is hyper-V Replica Azure specific input for creating a protection profile. +type HyperVReplicaAzurePolicyInput struct { + RecoveryPointHistoryDuration *int32 `json:"recoveryPointHistoryDuration,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int32 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + ReplicationInterval *int32 `json:"replicationInterval,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + Encryption *string `json:"encryption,omitempty"` + StorageAccounts *[]string `json:"storageAccounts,omitempty"` +} + +// HyperVReplicaAzureReplicationDetails is hyper V Replica Azure provider specific settings. +type HyperVReplicaAzureReplicationDetails struct { + AzureVMDiskDetails *[]AzureVMDiskDetails `json:"azureVMDiskDetails,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RecoveryAzureStorageAccount *string `json:"recoveryAzureStorageAccount,omitempty"` + RecoveryAzureLogStorageAccountID *string `json:"recoveryAzureLogStorageAccountId,omitempty"` + LastReplicatedTime *date.Time `json:"lastReplicatedTime,omitempty"` + VMID *string `json:"vmId,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + SelectedRecoveryAzureNetworkID *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + Encryption *string `json:"encryption,omitempty"` + OSDetails *OSDetails `json:"oSDetails,omitempty"` + SourceVMRAMSizeInMB *int32 `json:"sourceVmRAMSizeInMB,omitempty"` + SourceVMCPUCount *int32 `json:"sourceVmCPUCount,omitempty"` + EnableRDPOnTargetOption *string `json:"enableRDPOnTargetOption,omitempty"` + RecoveryAzureResourceGroupID *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAvailabilitySetID *string `json:"recoveryAvailabilitySetId,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` +} + +// HyperVReplicaAzureReprotectInput is azure specific reprotect input. +type HyperVReplicaAzureReprotectInput struct { + HvHostVMID *string `json:"hvHostVmId,omitempty"` + VMName *string `json:"vmName,omitempty"` + OsType *string `json:"osType,omitempty"` + VHDID *string `json:"vHDId,omitempty"` + StorageAccountID *string `json:"storageAccountId,omitempty"` + LogStorageAccountID *string `json:"logStorageAccountId,omitempty"` +} + +// HyperVReplicaAzureUpdateReplicationProtectedItemInput is hyperV replica Azure input to update replication protected +// item. +type HyperVReplicaAzureUpdateReplicationProtectedItemInput struct { + RecoveryAzureV1ResourceGroupID *string `json:"recoveryAzureV1ResourceGroupId,omitempty"` + RecoveryAzureV2ResourceGroupID *string `json:"recoveryAzureV2ResourceGroupId,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` +} + +// HyperVReplicaBaseEventDetails is abstract model class for event details of a HyperVReplica E2E event. +type HyperVReplicaBaseEventDetails struct { + ContainerName *string `json:"containerName,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + RemoteContainerName *string `json:"remoteContainerName,omitempty"` + RemoteFabricName *string `json:"remoteFabricName,omitempty"` +} + +// HyperVReplicaBasePolicyDetails is base class for HyperVReplica policy details. +type HyperVReplicaBasePolicyDetails struct { + RecoveryPoints *int32 `json:"recoveryPoints,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int32 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + ReplicationPort *int32 `json:"replicationPort,omitempty"` + AllowedAuthenticationType *int32 `json:"allowedAuthenticationType,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` +} + +// HyperVReplicaBaseReplicationDetails is hyper V replica provider specific settings base class. +type HyperVReplicaBaseReplicationDetails struct { + LastReplicatedTime *date.Time `json:"lastReplicatedTime,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMID *string `json:"vmId,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` +} + +// HyperVReplicaBluePolicyDetails is hyper-V Replica Blue specific protection profile details. +type HyperVReplicaBluePolicyDetails struct { + ReplicationFrequencyInSeconds *int32 `json:"replicationFrequencyInSeconds,omitempty"` + RecoveryPoints *int32 `json:"recoveryPoints,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int32 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + ReplicationPort *int32 `json:"replicationPort,omitempty"` + AllowedAuthenticationType *int32 `json:"allowedAuthenticationType,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` +} + +// HyperVReplicaBluePolicyInput is hyperV Replica Blue policy input. +type HyperVReplicaBluePolicyInput struct { + ReplicationFrequencyInSeconds *int32 `json:"replicationFrequencyInSeconds,omitempty"` + RecoveryPoints *int32 `json:"recoveryPoints,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int32 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + ReplicationPort *int32 `json:"replicationPort,omitempty"` + AllowedAuthenticationType *int32 `json:"allowedAuthenticationType,omitempty"` + ReplicaDeletion *string `json:"replicaDeletion,omitempty"` +} + +// HyperVReplicaBlueReplicationDetails is hyperV replica 2012 R2 (Blue) replication details. +type HyperVReplicaBlueReplicationDetails struct { + LastReplicatedTime *date.Time `json:"lastReplicatedTime,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMID *string `json:"vmId,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` +} + +// HyperVReplicaPolicyDetails is hyper-V Replica Blue specific protection profile details. +type HyperVReplicaPolicyDetails struct { + RecoveryPoints *int32 `json:"recoveryPoints,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int32 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + ReplicationPort *int32 `json:"replicationPort,omitempty"` + AllowedAuthenticationType *int32 `json:"allowedAuthenticationType,omitempty"` + ReplicaDeletionOption *string `json:"replicaDeletionOption,omitempty"` +} + +// HyperVReplicaPolicyInput is hyper-V Replica specific protection profile Input. +type HyperVReplicaPolicyInput struct { + RecoveryPoints *int32 `json:"recoveryPoints,omitempty"` + ApplicationConsistentSnapshotFrequencyInHours *int32 `json:"applicationConsistentSnapshotFrequencyInHours,omitempty"` + Compression *string `json:"compression,omitempty"` + InitialReplicationMethod *string `json:"initialReplicationMethod,omitempty"` + OnlineReplicationStartTime *string `json:"onlineReplicationStartTime,omitempty"` + OfflineReplicationImportPath *string `json:"offlineReplicationImportPath,omitempty"` + OfflineReplicationExportPath *string `json:"offlineReplicationExportPath,omitempty"` + ReplicationPort *int32 `json:"replicationPort,omitempty"` + AllowedAuthenticationType *int32 `json:"allowedAuthenticationType,omitempty"` + ReplicaDeletion *string `json:"replicaDeletion,omitempty"` +} + +// HyperVReplicaReplicationDetails is hyperV replica 2012 replication details. +type HyperVReplicaReplicationDetails struct { + LastReplicatedTime *date.Time `json:"lastReplicatedTime,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + VMID *string `json:"vmId,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + InitialReplicationDetails *InitialReplicationDetails `json:"initialReplicationDetails,omitempty"` + VMDiskDetails *[]DiskDetails `json:"vMDiskDetails,omitempty"` +} + +// HyperVSiteDetails is hyperVSite fabric specific details. +type HyperVSiteDetails struct { +} + +// HyperVVirtualMachineDetails is hyper V replica provider specific settings +type HyperVVirtualMachineDetails struct { + SourceItemID *string `json:"sourceItemId,omitempty"` + Generation *string `json:"generation,omitempty"` + OsDetails *OSDetails `json:"osDetails,omitempty"` + DiskDetails *[]DiskDetails `json:"diskDetails,omitempty"` +} + +// InconsistentVMDetails is this class stores the monitoring details for consistency check of inconsistent Protected +// Entity. +type InconsistentVMDetails struct { + VMName *string `json:"vmName,omitempty"` + CloudName *string `json:"cloudName,omitempty"` + Details *[]string `json:"details,omitempty"` + ErrorIds *[]string `json:"errorIds,omitempty"` +} + +// InitialReplicationDetails is initial replication details. +type InitialReplicationDetails struct { + InitialReplicationType *string `json:"initialReplicationType,omitempty"` + InitialReplicationProgressPercentage *string `json:"initialReplicationProgressPercentage,omitempty"` +} + +// InlineWorkflowTaskDetails is this class represents the inline workflow task details. +type InlineWorkflowTaskDetails struct { + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + WorkflowIds *[]string `json:"workflowIds,omitempty"` +} + +// InMageAgentDetails is the details of the InMage agent. +type InMageAgentDetails struct { + AgentVersion *string `json:"agentVersion,omitempty"` + AgentUpdateStatus *string `json:"agentUpdateStatus,omitempty"` + PostUpdateRebootStatus *string `json:"postUpdateRebootStatus,omitempty"` +} + +// InMageAzureV2ApplyRecoveryPointInput is applyRecoveryPoint input specific to InMageAzureV2 provider. +type InMageAzureV2ApplyRecoveryPointInput struct { + VaultLocation *string `json:"vaultLocation,omitempty"` +} + +// InMageAzureV2EnableProtectionInput is vMware Azure specific enable protection input. +type InMageAzureV2EnableProtectionInput struct { + MasterTargetID *string `json:"masterTargetId,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + StorageAccountID *string `json:"storageAccountId,omitempty"` + RunAsAccountID *string `json:"runAsAccountId,omitempty"` + MultiVMGroupID *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` + TargetAzureNetworkID *string `json:"targetAzureNetworkId,omitempty"` + TargetAzureSubnetID *string `json:"targetAzureSubnetId,omitempty"` + EnableRDPOnTargetOption *string `json:"enableRDPOnTargetOption,omitempty"` + TargetAzureVMName *string `json:"targetAzureVmName,omitempty"` + LogStorageAccountID *string `json:"logStorageAccountId,omitempty"` + TargetAzureV1ResourceGroupID *string `json:"targetAzureV1ResourceGroupId,omitempty"` + TargetAzureV2ResourceGroupID *string `json:"targetAzureV2ResourceGroupId,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` +} + +// InMageAzureV2EventDetails is model class for event details of a VMwareAzureV2 event. +type InMageAzureV2EventDetails struct { + EventType *string `json:"eventType,omitempty"` + Category *string `json:"category,omitempty"` + Component *string `json:"component,omitempty"` + CorrectiveAction *string `json:"correctiveAction,omitempty"` + Details *string `json:"details,omitempty"` + Summary *string `json:"summary,omitempty"` + SiteName *string `json:"siteName,omitempty"` +} + +// InMageAzureV2FailoverProviderInput is inMageAzureV2 provider specific input for failover. +type InMageAzureV2FailoverProviderInput struct { + VaultLocation *string `json:"vaultLocation,omitempty"` + RecoveryPointID *string `json:"recoveryPointId,omitempty"` +} + +// InMageAzureV2PolicyDetails is inMage Azure v2 specific protection profile details. +type InMageAzureV2PolicyDetails struct { + CrashConsistentFrequencyInMinutes *int32 `json:"crashConsistentFrequencyInMinutes,omitempty"` + RecoveryPointThresholdInMinutes *int32 `json:"recoveryPointThresholdInMinutes,omitempty"` + RecoveryPointHistory *int32 `json:"recoveryPointHistory,omitempty"` + AppConsistentFrequencyInMinutes *int32 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` +} + +// InMageAzureV2PolicyInput is vMWare Azure specific protection profile Input. +type InMageAzureV2PolicyInput struct { + RecoveryPointThresholdInMinutes *int32 `json:"recoveryPointThresholdInMinutes,omitempty"` + RecoveryPointHistory *int32 `json:"recoveryPointHistory,omitempty"` + CrashConsistentFrequencyInMinutes *int32 `json:"crashConsistentFrequencyInMinutes,omitempty"` + AppConsistentFrequencyInMinutes *int32 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus,omitempty"` +} + +// InMageAzureV2ProtectedDiskDetails is inMageAzureV2 protected disk details. +type InMageAzureV2ProtectedDiskDetails struct { + DiskID *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + HealthErrorCode *string `json:"healthErrorCode,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncProgressPercentage *int32 `json:"resyncProgressPercentage,omitempty"` + ResyncDurationInSeconds *int64 `json:"resyncDurationInSeconds,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + FileSystemCapacityInBytes *int64 `json:"fileSystemCapacityInBytes,omitempty"` + SourceDataInMegaBytes *float64 `json:"sourceDataInMegaBytes,omitempty"` + PsDataInMegaBytes *float64 `json:"psDataInMegaBytes,omitempty"` + TargetDataInMegaBytes *float64 `json:"targetDataInMegaBytes,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` +} + +// InMageAzureV2ReplicationDetails is inMageAzureV2 provider specific settings +type InMageAzureV2ReplicationDetails struct { + InfrastructureVMID *string `json:"infrastructureVmId,omitempty"` + VCenterInfrastructureID *string `json:"vCenterInfrastructureId,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + VMID *string `json:"vmId,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + ResyncProgressPercentage *int32 `json:"resyncProgressPercentage,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + CompressedDataRateInMB *float64 `json:"compressedDataRateInMB,omitempty"` + UncompressedDataRateInMB *float64 `json:"uncompressedDataRateInMB,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + IsAgentUpdateRequired *string `json:"isAgentUpdateRequired,omitempty"` + IsRebootAfterUpdateRequired *string `json:"isRebootAfterUpdateRequired,omitempty"` + LastHeartbeat *date.Time `json:"lastHeartbeat,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + MultiVMGroupID *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + ProtectedDisks *[]InMageAzureV2ProtectedDiskDetails `json:"protectedDisks,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + MasterTargetID *string `json:"masterTargetId,omitempty"` + SourceVMCPUCount *int32 `json:"sourceVmCPUCount,omitempty"` + SourceVMRAMSizeInMB *int32 `json:"sourceVmRAMSizeInMB,omitempty"` + OsType *string `json:"osType,omitempty"` + VhdName *string `json:"vhdName,omitempty"` + OsDiskID *string `json:"osDiskId,omitempty"` + AzureVMDiskDetails *[]AzureVMDiskDetails `json:"azureVMDiskDetails,omitempty"` + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + RecoveryAzureStorageAccount *string `json:"recoveryAzureStorageAccount,omitempty"` + RecoveryAzureLogStorageAccountID *string `json:"recoveryAzureLogStorageAccountId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + SelectedRecoveryAzureNetworkID *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + EnableRDPOnTargetOption *string `json:"enableRDPOnTargetOption,omitempty"` + Datastores *[]string `json:"datastores,omitempty"` + TargetVMID *string `json:"targetVmId,omitempty"` + RecoveryAzureResourceGroupID *string `json:"recoveryAzureResourceGroupId,omitempty"` + RecoveryAvailabilitySetID *string `json:"recoveryAvailabilitySetId,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` +} + +// InMageAzureV2ReprotectInput is inMageAzureV2 specific provider input. +type InMageAzureV2ReprotectInput struct { + MasterTargetID *string `json:"masterTargetId,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + StorageAccountID *string `json:"storageAccountId,omitempty"` + RunAsAccountID *string `json:"runAsAccountId,omitempty"` + PolicyID *string `json:"policyId,omitempty"` + LogStorageAccountID *string `json:"logStorageAccountId,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` +} + +// InMageAzureV2UpdateReplicationProtectedItemInput is inMage Azure V2 input to update replication protected item. +type InMageAzureV2UpdateReplicationProtectedItemInput struct { + RecoveryAzureV1ResourceGroupID *string `json:"recoveryAzureV1ResourceGroupId,omitempty"` + RecoveryAzureV2ResourceGroupID *string `json:"recoveryAzureV2ResourceGroupId,omitempty"` + UseManagedDisks *string `json:"useManagedDisks,omitempty"` +} + +// InMageBasePolicyDetails is base class for the policies of providers using InMage replication. +type InMageBasePolicyDetails struct { + RecoveryPointThresholdInMinutes *int32 `json:"recoveryPointThresholdInMinutes,omitempty"` + RecoveryPointHistory *int32 `json:"recoveryPointHistory,omitempty"` + AppConsistentFrequencyInMinutes *int32 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` +} + +// InMageDisableProtectionProviderSpecificInput is inMage disable protection provider specific input. +type InMageDisableProtectionProviderSpecificInput struct { + ReplicaVMDeletionStatus *string `json:"replicaVmDeletionStatus,omitempty"` +} + +// InMageDiskDetails is vMware/Physical specific Disk Details +type InMageDiskDetails struct { + DiskID *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + DiskSizeInMB *string `json:"diskSizeInMB,omitempty"` + DiskType *string `json:"diskType,omitempty"` + DiskConfiguration *string `json:"diskConfiguration,omitempty"` + VolumeList *[]DiskVolumeDetails `json:"volumeList,omitempty"` +} + +// InMageDiskExclusionInput is diskExclusionInput when doing enable protection of virtual machine in InMage provider. +type InMageDiskExclusionInput struct { + VolumeOptions *[]InMageVolumeExclusionOptions `json:"volumeOptions,omitempty"` + DiskSignatureOptions *[]InMageDiskSignatureExclusionOptions `json:"diskSignatureOptions,omitempty"` +} + +// InMageDiskSignatureExclusionOptions is guest disk signature based disk exclusion option when doing enable protection +// of virtual machine in InMage provider. +type InMageDiskSignatureExclusionOptions struct { + DiskSignature *string `json:"diskSignature,omitempty"` +} + +// InMageEnableProtectionInput is vMware Azure specific enable protection input. +type InMageEnableProtectionInput struct { + VMFriendlyName *string `json:"vmFriendlyName,omitempty"` + MasterTargetID *string `json:"masterTargetId,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + RetentionDrive *string `json:"retentionDrive,omitempty"` + RunAsAccountID *string `json:"runAsAccountId,omitempty"` + MultiVMGroupID *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + DatastoreName *string `json:"datastoreName,omitempty"` + DiskExclusionInput *InMageDiskExclusionInput `json:"diskExclusionInput,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` +} + +// InMageFailoverProviderInput is provider specific input for InMage failover. +type InMageFailoverProviderInput struct { + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + RecoveryPointID *string `json:"recoveryPointId,omitempty"` +} + +// InMagePolicyDetails is inMage specific protection profile details. +type InMagePolicyDetails struct { + RecoveryPointThresholdInMinutes *int32 `json:"recoveryPointThresholdInMinutes,omitempty"` + RecoveryPointHistory *int32 `json:"recoveryPointHistory,omitempty"` + AppConsistentFrequencyInMinutes *int32 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` +} + +// InMagePolicyInput is vMWare Azure specific protection profile Input. +type InMagePolicyInput struct { + RecoveryPointThresholdInMinutes *int32 `json:"recoveryPointThresholdInMinutes,omitempty"` + RecoveryPointHistory *int32 `json:"recoveryPointHistory,omitempty"` + AppConsistentFrequencyInMinutes *int32 `json:"appConsistentFrequencyInMinutes,omitempty"` + MultiVMSyncStatus SetMultiVMSyncStatus `json:"multiVmSyncStatus,omitempty"` +} + +// InMageProtectedDiskDetails is inMage protected disk details. +type InMageProtectedDiskDetails struct { + DiskID *string `json:"diskId,omitempty"` + DiskName *string `json:"diskName,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + HealthErrorCode *string `json:"healthErrorCode,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + ResyncRequired *string `json:"resyncRequired,omitempty"` + ResyncProgressPercentage *int32 `json:"resyncProgressPercentage,omitempty"` + ResyncDurationInSeconds *int64 `json:"resyncDurationInSeconds,omitempty"` + DiskCapacityInBytes *int64 `json:"diskCapacityInBytes,omitempty"` + FileSystemCapacityInBytes *int64 `json:"fileSystemCapacityInBytes,omitempty"` + SourceDataInMB *float64 `json:"sourceDataInMB,omitempty"` + PsDataInMB *float64 `json:"psDataInMB,omitempty"` + TargetDataInMB *float64 `json:"targetDataInMB,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` +} + +// InMageReplicationDetails is inMage provider specific settings +type InMageReplicationDetails struct { + ActiveSiteType *string `json:"activeSiteType,omitempty"` + SourceVMCPUCount *int32 `json:"sourceVmCPUCount,omitempty"` + SourceVMRAMSizeInMB *int32 `json:"sourceVmRAMSizeInMB,omitempty"` + OsDetails *OSDiskDetails `json:"osDetails,omitempty"` + ProtectionStage *string `json:"protectionStage,omitempty"` + VMID *string `json:"vmId,omitempty"` + VMProtectionState *string `json:"vmProtectionState,omitempty"` + VMProtectionStateDescription *string `json:"vmProtectionStateDescription,omitempty"` + ResyncDetails *InitialReplicationDetails `json:"resyncDetails,omitempty"` + RetentionWindowStart *date.Time `json:"retentionWindowStart,omitempty"` + RetentionWindowEnd *date.Time `json:"retentionWindowEnd,omitempty"` + CompressedDataRateInMB *float64 `json:"compressedDataRateInMB,omitempty"` + UncompressedDataRateInMB *float64 `json:"uncompressedDataRateInMB,omitempty"` + RpoInSeconds *int64 `json:"rpoInSeconds,omitempty"` + ProtectedDisks *[]InMageProtectedDiskDetails `json:"protectedDisks,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LastHeartbeat *date.Time `json:"lastHeartbeat,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + MasterTargetID *string `json:"masterTargetId,omitempty"` + ConsistencyPoints *map[string]*date.Time `json:"consistencyPoints,omitempty"` + DiskResized *string `json:"diskResized,omitempty"` + RebootAfterUpdateStatus *string `json:"rebootAfterUpdateStatus,omitempty"` + MultiVMGroupID *string `json:"multiVmGroupId,omitempty"` + MultiVMGroupName *string `json:"multiVmGroupName,omitempty"` + MultiVMSyncStatus *string `json:"multiVmSyncStatus,omitempty"` + AgentDetails *InMageAgentDetails `json:"agentDetails,omitempty"` + VCenterInfrastructureID *string `json:"vCenterInfrastructureId,omitempty"` + InfrastructureVMID *string `json:"infrastructureVmId,omitempty"` + VMNics *[]VMNicDetails `json:"vmNics,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + AzureStorageAccountID *string `json:"azureStorageAccountId,omitempty"` + Datastores *[]string `json:"datastores,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` +} + +// InMageReprotectInput is inMageAzureV2 specific provider input. +type InMageReprotectInput struct { + MasterTargetID *string `json:"masterTargetId,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + RetentionDrive *string `json:"retentionDrive,omitempty"` + RunAsAccountID *string `json:"runAsAccountId,omitempty"` + DatastoreName *string `json:"datastoreName,omitempty"` + DiskExclusionInput *InMageDiskExclusionInput `json:"diskExclusionInput,omitempty"` + ProfileID *string `json:"profileId,omitempty"` + DisksToInclude *[]string `json:"disksToInclude,omitempty"` +} + +// InMageVolumeExclusionOptions is guest disk signature based disk exclusion option when doing enable protection of +// virtual machine in InMage provider. +type InMageVolumeExclusionOptions struct { + VolumeLabel *string `json:"volumeLabel,omitempty"` + OnlyExcludeIfSingleVolume *string `json:"OnlyExcludeIfSingleVolume,omitempty"` +} + +// InputEndpoint is azure VM input endpoint details. +type InputEndpoint struct { + EndpointName *string `json:"endpointName,omitempty"` + PrivatePort *int32 `json:"privatePort,omitempty"` + PublicPort *int32 `json:"publicPort,omitempty"` + Protocol *string `json:"protocol,omitempty"` +} + +// Job is job details. +type Job struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *JobProperties `json:"properties,omitempty"` + Status *string `json:"status,omitempty"` + Error *ARMException `json:"error,omitempty"` + StartTime *string `json:"startTime,omitempty"` + EndTime *string `json:"endTime,omitempty"` +} + +// JobCollection is collection of jobs. +type JobCollection struct { + autorest.Response `json:"-"` + Value *[]Job `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// JobCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client JobCollection) JobCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// JobDetails is job details based on specific job type. +type JobDetails struct { + AffectedObjectDetails *map[string]*string `json:"affectedObjectDetails,omitempty"` +} + +// JobEntity is this class contains the minimal job details required to navigate to the desired drill down. +type JobEntity struct { + JobID *string `json:"jobId,omitempty"` + JobFriendlyName *string `json:"jobFriendlyName,omitempty"` + TargetObjectID *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + JobScenarioName *string `json:"jobScenarioName,omitempty"` +} + +// JobErrorDetails is this class contains the error details per object. +type JobErrorDetails struct { + ServiceErrorDetails *ServiceError `json:"serviceErrorDetails,omitempty"` + ProviderErrorDetails *ProviderError `json:"providerErrorDetails,omitempty"` + ErrorLevel *string `json:"errorLevel,omitempty"` + CreationTime *date.Time `json:"creationTime,omitempty"` + TaskID *string `json:"taskId,omitempty"` +} + +// JobProperties is job custom data details. +type JobProperties struct { + ActivityID *string `json:"activityId,omitempty"` + ScenarioName *string `json:"scenarioName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + State *string `json:"state,omitempty"` + StateDescription *string `json:"stateDescription,omitempty"` + Tasks *[]ASRTask `json:"tasks,omitempty"` + Errors *[]JobErrorDetails `json:"errors,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + AllowedActions *[]string `json:"allowedActions,omitempty"` + TargetObjectID *string `json:"targetObjectId,omitempty"` + TargetObjectName *string `json:"targetObjectName,omitempty"` + TargetInstanceType *string `json:"targetInstanceType,omitempty"` + CustomDetails *JobDetails `json:"customDetails,omitempty"` +} + +// JobQueryParameter is query parameter to enumerate jobs. +type JobQueryParameter struct { + StartTime *string `json:"startTime,omitempty"` + EndTime *string `json:"endTime,omitempty"` + FabricID *string `json:"fabricId,omitempty"` + AffectedObjectTypes *[]string `json:"affectedObjectTypes,omitempty"` + JobStatus *[]string `json:"jobStatus,omitempty"` +} + +// JobStatusEventDetails is model class for event details of a job status event. +type JobStatusEventDetails struct { + JobID *string `json:"jobId,omitempty"` + JobFriendlyName *string `json:"jobFriendlyName,omitempty"` + JobStatus *string `json:"jobStatus,omitempty"` + AffectedObjectType *string `json:"affectedObjectType,omitempty"` +} + +// JobTaskDetails is this class represents a task which is actually a workflow so that one can navigate to its +// individual drill down. +type JobTaskDetails struct { + JobTask *JobEntity `json:"jobTask,omitempty"` +} + +// LogicalNetwork is logical network data model. +type LogicalNetwork struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *LogicalNetworkProperties `json:"properties,omitempty"` +} + +// LogicalNetworkCollection is list of logical networks. +type LogicalNetworkCollection struct { + autorest.Response `json:"-"` + Value *[]LogicalNetwork `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// LogicalNetworkCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client LogicalNetworkCollection) LogicalNetworkCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// LogicalNetworkProperties is logical Network Properties. +type LogicalNetworkProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + NetworkVirtualizationStatus *string `json:"networkVirtualizationStatus,omitempty"` + LogicalNetworkUsage *string `json:"logicalNetworkUsage,omitempty"` + LogicalNetworkDefinitionsStatus *string `json:"logicalNetworkDefinitionsStatus,omitempty"` +} + +// ManualActionTaskDetails is this class represents the manual action task details. +type ManualActionTaskDetails struct { + Name *string `json:"name,omitempty"` + Instructions *string `json:"instructions,omitempty"` + Observation *string `json:"observation,omitempty"` +} + +// MasterTargetServer is details of a Master Target Server. +type MasterTargetServer struct { + ID *string `json:"id,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + OsType *string `json:"osType,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + LastHeartbeat *date.Time `json:"lastHeartbeat,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` + RetentionVolumes *[]RetentionVolume `json:"retentionVolumes,omitempty"` + DataStores *[]DataStore `json:"dataStores,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` +} + +// MethodCallStatus is reports method status where exception was raised. +type MethodCallStatus struct { + IsVirtual *string `json:"isVirtual,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + ContainsGenericParameters *string `json:"containsGenericParameters,omitempty"` +} + +// MobilityServiceUpdate is the Mobility Service update details. +type MobilityServiceUpdate struct { + Version *string `json:"version,omitempty"` + RebootStatus *string `json:"rebootStatus,omitempty"` + OsType *string `json:"osType,omitempty"` +} + +// Network is network model. +type Network struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *NetworkProperties `json:"properties,omitempty"` +} + +// NetworkCollection is list of networks. +type NetworkCollection struct { + autorest.Response `json:"-"` + Value *[]Network `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// NetworkCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client NetworkCollection) NetworkCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// NetworkMapping is network Mapping model. Ideally it should have been possible to inherit this class from prev +// version in InheritedModels as long as there is no difference in structure or method signature. Since there were no +// base Models for certain fields and methods viz NetworkMappingProperties and Load with required return type, the +// class has been introduced in its entirety with references to base models to facilitate exensions in subsequent +// versions. +type NetworkMapping struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *NetworkMappingProperties `json:"properties,omitempty"` +} + +// NetworkMappingCollection is list of network mappings. As with NetworkMapping, it should be possible to reuse a prev +// version of this class. It doesn't seem likely this class could be anything more than a slightly bespoke collection +// of NetworkMapping. Hence it makes sense to override Load with Base.NetworkMapping instead of existing +// CurrentVersion.NetworkMapping. +type NetworkMappingCollection struct { + autorest.Response `json:"-"` + Value *[]NetworkMapping `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// NetworkMappingCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client NetworkMappingCollection) NetworkMappingCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// NetworkMappingFabricSpecificSettings is network Mapping fabric specific settings. +type NetworkMappingFabricSpecificSettings struct { +} + +// NetworkMappingProperties is network Mapping Properties. +type NetworkMappingProperties struct { + State *string `json:"state,omitempty"` + PrimaryNetworkFriendlyName *string `json:"primaryNetworkFriendlyName,omitempty"` + PrimaryNetworkID *string `json:"primaryNetworkId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + RecoveryNetworkFriendlyName *string `json:"recoveryNetworkFriendlyName,omitempty"` + RecoveryNetworkID *string `json:"recoveryNetworkId,omitempty"` + RecoveryFabricArmID *string `json:"recoveryFabricArmId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + FabricSpecificSettings *NetworkMappingFabricSpecificSettings `json:"fabricSpecificSettings,omitempty"` +} + +// NetworkProperties is network Properties +type NetworkProperties struct { + FabricType *string `json:"fabricType,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` +} + +// OperationsDiscovery is operations discovery class. +type OperationsDiscovery struct { + Name *string `json:"name,omitempty"` + Display *Display `json:"display,omitempty"` + Origin *string `json:"origin,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +// OperationsDiscoveryCollection is collection of ClientDiscovery details. +type OperationsDiscoveryCollection struct { + autorest.Response `json:"-"` + Value *[]OperationsDiscovery `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationsDiscoveryCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationsDiscoveryCollection) OperationsDiscoveryCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// OSDetails is disk Details. +type OSDetails struct { + OsType *string `json:"osType,omitempty"` + ProductType *string `json:"productType,omitempty"` + OsEdition *string `json:"osEdition,omitempty"` + OSVersion *string `json:"oSVersion,omitempty"` + OSMajorVersion *string `json:"oSMajorVersion,omitempty"` + OSMinorVersion *string `json:"oSMinorVersion,omitempty"` +} + +// OSDiskDetails is details of the OS Disk. +type OSDiskDetails struct { + OsVhdID *string `json:"osVhdId,omitempty"` + OsType *string `json:"osType,omitempty"` + VhdName *string `json:"vhdName,omitempty"` +} + +// PlannedFailoverInput is input definition for planned failover. +type PlannedFailoverInput struct { + Properties *PlannedFailoverInputProperties `json:"properties,omitempty"` +} + +// PlannedFailoverInputProperties is input definition for planned failover input properties. +type PlannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails *ProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +// Policy is protection profile details. +type Policy struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *PolicyProperties `json:"properties,omitempty"` +} + +// PolicyCollection is protection Profile Collection details. +type PolicyCollection struct { + autorest.Response `json:"-"` + Value *[]Policy `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// PolicyCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client PolicyCollection) PolicyCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// PolicyProperties is protection profile custom data details. +type PolicyProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ProviderSpecificDetails *PolicyProviderSpecificDetails `json:"providerSpecificDetails,omitempty"` +} + +// PolicyProviderSpecificDetails is base class for Provider specific details for policies. +type PolicyProviderSpecificDetails struct { +} + +// PolicyProviderSpecificInput is base class for provider specific input +type PolicyProviderSpecificInput struct { +} + +// ProcessServer is details of the Process Server. +type ProcessServer struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ID *string `json:"id,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + OsType *string `json:"osType,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + LastHeartbeat *date.Time `json:"lastHeartbeat,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` + MobilityServiceUpdates *[]MobilityServiceUpdate `json:"mobilityServiceUpdates,omitempty"` + HostID *string `json:"hostId,omitempty"` + MachineCount *string `json:"machineCount,omitempty"` + ReplicationPairCount *string `json:"replicationPairCount,omitempty"` + SystemLoad *string `json:"systemLoad,omitempty"` + SystemLoadStatus *string `json:"systemLoadStatus,omitempty"` + CPULoad *string `json:"cpuLoad,omitempty"` + CPULoadStatus *string `json:"cpuLoadStatus,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + MemoryUsageStatus *string `json:"memoryUsageStatus,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + SpaceUsageStatus *string `json:"spaceUsageStatus,omitempty"` + PsServiceStatus *string `json:"psServiceStatus,omitempty"` + SslCertExpiryDate *date.Time `json:"sslCertExpiryDate,omitempty"` + SslCertExpiryRemainingDays *int32 `json:"sslCertExpiryRemainingDays,omitempty"` +} + +// ProtectableItem is replication protected item +type ProtectableItem struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *ProtectableItemProperties `json:"properties,omitempty"` +} + +// ProtectableItemCollection is protectable item collection. +type ProtectableItemCollection struct { + autorest.Response `json:"-"` + Value *[]ProtectableItem `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ProtectableItemCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ProtectableItemCollection) ProtectableItemCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ProtectableItemProperties is replication protected item custom data details. +type ProtectableItemProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ReplicationProtectedItemID *string `json:"replicationProtectedItemId,omitempty"` + RecoveryServicesProviderID *string `json:"recoveryServicesProviderId,omitempty"` + ProtectionReadinessErrors *[]string `json:"protectionReadinessErrors,omitempty"` + SupportedReplicationProviders *[]string `json:"supportedReplicationProviders,omitempty"` + CustomDetails *ConfigurationSettings `json:"customDetails,omitempty"` +} + +// ProtectedItemsQueryParameter is query parameter to enumerate protected items. +type ProtectedItemsQueryParameter struct { + SourceFabricName *string `json:"sourceFabricName,omitempty"` + RecoveryPlanName *string `json:"recoveryPlanName,omitempty"` +} + +// ProtectionContainer is protection container details. +type ProtectionContainer struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *ProtectionContainerProperties `json:"properties,omitempty"` +} + +// ProtectionContainerCollection is protection Container collection. +type ProtectionContainerCollection struct { + autorest.Response `json:"-"` + Value *[]ProtectionContainer `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ProtectionContainerCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ProtectionContainerCollection) ProtectionContainerCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ProtectionContainerFabricSpecificDetails is base class for fabric specific details of container. +type ProtectionContainerFabricSpecificDetails struct { + InstanceType *string `json:"instanceType,omitempty"` +} + +// ProtectionContainerMapping is protection container mapping object. +type ProtectionContainerMapping struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *ProtectionContainerMappingProperties `json:"properties,omitempty"` +} + +// ProtectionContainerMappingCollection is protection container mapping collection class. +type ProtectionContainerMappingCollection struct { + autorest.Response `json:"-"` + Value *[]ProtectionContainerMapping `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ProtectionContainerMappingCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ProtectionContainerMappingCollection) ProtectionContainerMappingCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ProtectionContainerMappingProperties is protection container mapping properties. +type ProtectionContainerMappingProperties struct { + TargetProtectionContainerID *string `json:"targetProtectionContainerId,omitempty"` + TargetProtectionContainerFriendlyName *string `json:"targetProtectionContainerFriendlyName,omitempty"` + ProviderSpecificDetails *ProtectionContainerMappingProviderSpecificDetails `json:"providerSpecificDetails,omitempty"` + Health *string `json:"health,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` + PolicyID *string `json:"policyId,omitempty"` + State *string `json:"state,omitempty"` + SourceProtectionContainerFriendlyName *string `json:"sourceProtectionContainerFriendlyName,omitempty"` + SourceFabricFriendlyName *string `json:"sourceFabricFriendlyName,omitempty"` + TargetFabricFriendlyName *string `json:"targetFabricFriendlyName,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` +} + +// ProtectionContainerMappingProviderSpecificDetails is container mapping provider specific details. +type ProtectionContainerMappingProviderSpecificDetails struct { + InstanceType *string `json:"instanceType,omitempty"` +} + +// ProtectionContainerProperties is protection profile custom data details. +type ProtectionContainerProperties struct { + FabricFriendlyName *string `json:"fabricFriendlyName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + FabricType *string `json:"fabricType,omitempty"` + ProtectedItemCount *int32 `json:"protectedItemCount,omitempty"` + PairingStatus *string `json:"pairingStatus,omitempty"` + Role *string `json:"role,omitempty"` + FabricSpecificDetails *ProtectionContainerFabricSpecificDetails `json:"fabricSpecificDetails,omitempty"` +} + +// ProviderError is this class contains the error details per object. +type ProviderError struct { + ErrorCode *int32 `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ErrorID *string `json:"errorId,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` +} + +// ProviderSpecificFailoverInput is provider specific failover input. +type ProviderSpecificFailoverInput struct { +} + +// RecoveryPlan is recovery plan details. +type RecoveryPlan struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *RecoveryPlanProperties `json:"properties,omitempty"` +} + +// RecoveryPlanA2AFailoverInput is recovery plan A2A failover input. +type RecoveryPlanA2AFailoverInput struct { + RecoveryPointType A2ARpRecoveryPointType `json:"recoveryPointType,omitempty"` + CloudServiceCreationOption *string `json:"cloudServiceCreationOption,omitempty"` +} + +// RecoveryPlanAction is recovery plan action details. +type RecoveryPlanAction struct { + ActionName *string `json:"actionName,omitempty"` + FailoverTypes *[]ReplicationProtectedItemOperation `json:"failoverTypes,omitempty"` + FailoverDirections *[]PossibleOperationsDirections `json:"failoverDirections,omitempty"` + CustomDetails *RecoveryPlanActionDetails `json:"customDetails,omitempty"` +} + +// RecoveryPlanActionDetails is recovery plan action custom details. +type RecoveryPlanActionDetails struct { +} + +// RecoveryPlanAutomationRunbookActionDetails is recovery plan Automation runbook action details. +type RecoveryPlanAutomationRunbookActionDetails struct { + RunbookID *string `json:"runbookId,omitempty"` + Timeout *string `json:"timeout,omitempty"` + FabricLocation RecoveryPlanActionLocation `json:"fabricLocation,omitempty"` +} + +// RecoveryPlanCollection is recovery plan collection details. +type RecoveryPlanCollection struct { + autorest.Response `json:"-"` + Value *[]RecoveryPlan `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// RecoveryPlanCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client RecoveryPlanCollection) RecoveryPlanCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RecoveryPlanGroup is recovery plan group details. +type RecoveryPlanGroup struct { + GroupType RecoveryPlanGroupType `json:"groupType,omitempty"` + ReplicationProtectedItems *[]RecoveryPlanProtectedItem `json:"replicationProtectedItems,omitempty"` + StartGroupActions *[]RecoveryPlanAction `json:"startGroupActions,omitempty"` + EndGroupActions *[]RecoveryPlanAction `json:"endGroupActions,omitempty"` +} + +// RecoveryPlanGroupTaskDetails is this class represents the recovery plan group task. +type RecoveryPlanGroupTaskDetails struct { + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + Name *string `json:"name,omitempty"` + GroupID *string `json:"groupId,omitempty"` + RpGroupType *string `json:"rpGroupType,omitempty"` +} + +// RecoveryPlanHyperVReplicaAzureFailbackInput is recovery plan HVR Azure failback input. +type RecoveryPlanHyperVReplicaAzureFailbackInput struct { + DataSyncOption DataSyncStatus `json:"dataSyncOption,omitempty"` + RecoveryVMCreationOption AlternateLocationRecoveryOption `json:"recoveryVmCreationOption,omitempty"` +} + +// RecoveryPlanHyperVReplicaAzureFailoverInput is recovery plan HVR Azure failover input. +type RecoveryPlanHyperVReplicaAzureFailoverInput struct { + VaultLocation *string `json:"vaultLocation,omitempty"` + PrimaryKekCertificatePfx *string `json:"primaryKekCertificatePfx,omitempty"` + SecondaryKekCertificatePfx *string `json:"secondaryKekCertificatePfx,omitempty"` + RecoveryPointType HyperVReplicaAzureRpRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +// RecoveryPlanInMageAzureV2FailoverInput is recovery plan InMageAzureV2 failover input. +type RecoveryPlanInMageAzureV2FailoverInput struct { + VaultLocation *string `json:"vaultLocation,omitempty"` + RecoveryPointType InMageV2RpRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +// RecoveryPlanInMageFailoverInput is recovery plan InMage failover input. +type RecoveryPlanInMageFailoverInput struct { + RecoveryPointType RpInMageRecoveryPointType `json:"recoveryPointType,omitempty"` +} + +// RecoveryPlanManualActionDetails is recovery plan manual action details. +type RecoveryPlanManualActionDetails struct { + Description *string `json:"description,omitempty"` +} + +// RecoveryPlanPlannedFailoverInput is recovery plan planned failover input. +type RecoveryPlanPlannedFailoverInput struct { + Properties *RecoveryPlanPlannedFailoverInputProperties `json:"properties,omitempty"` +} + +// RecoveryPlanPlannedFailoverInputProperties is recovery plan planned failover input properties. +type RecoveryPlanPlannedFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection,omitempty"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +// RecoveryPlanProperties is recovery plan custom details. +type RecoveryPlanProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + PrimaryFabricID *string `json:"primaryFabricId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + RecoveryFabricID *string `json:"recoveryFabricId,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + FailoverDeploymentModel *string `json:"failoverDeploymentModel,omitempty"` + ReplicationProviders *[]string `json:"replicationProviders,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + LastPlannedFailoverTime *date.Time `json:"lastPlannedFailoverTime,omitempty"` + LastTestFailoverTime *date.Time `json:"lastTestFailoverTime,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + CurrentScenarioStatus *string `json:"currentScenarioStatus,omitempty"` + CurrentScenarioStatusDescription *string `json:"currentScenarioStatusDescription,omitempty"` + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` +} + +// RecoveryPlanProtectedItem is recovery plan protected item. +type RecoveryPlanProtectedItem struct { + ID *string `json:"id,omitempty"` + VirtualMachineID *string `json:"virtualMachineId,omitempty"` +} + +// RecoveryPlanProviderSpecificFailoverInput is recovery plan provider specific failover input base class. +type RecoveryPlanProviderSpecificFailoverInput struct { +} + +// RecoveryPlanScriptActionDetails is recovery plan script action details. +type RecoveryPlanScriptActionDetails struct { + Path *string `json:"path,omitempty"` + Timeout *string `json:"timeout,omitempty"` + FabricLocation RecoveryPlanActionLocation `json:"fabricLocation,omitempty"` +} + +// RecoveryPlanShutdownGroupTaskDetails is this class represents the recovery plan shutdown group task details. +type RecoveryPlanShutdownGroupTaskDetails struct { + ChildTasks *[]ASRTask `json:"childTasks,omitempty"` + Name *string `json:"name,omitempty"` + GroupID *string `json:"groupId,omitempty"` + RpGroupType *string `json:"rpGroupType,omitempty"` +} + +// RecoveryPlanTestFailoverCleanupInput is recovery plan test failover cleanup input. +type RecoveryPlanTestFailoverCleanupInput struct { + Properties *RecoveryPlanTestFailoverCleanupInputProperties `json:"properties,omitempty"` +} + +// RecoveryPlanTestFailoverCleanupInputProperties is recovery plan test failover cleanup input properties. +type RecoveryPlanTestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} + +// RecoveryPlanTestFailoverInput is recovery plan test failover input. +type RecoveryPlanTestFailoverInput struct { + Properties *RecoveryPlanTestFailoverInputProperties `json:"properties,omitempty"` +} + +// RecoveryPlanTestFailoverInputProperties is recovery plan test failover input properties. +type RecoveryPlanTestFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + NetworkID *string `json:"networkId,omitempty"` + SkipTestFailoverCleanup *string `json:"skipTestFailoverCleanup,omitempty"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +// RecoveryPlanUnplannedFailoverInput is recovery plan unplanned failover input. +type RecoveryPlanUnplannedFailoverInput struct { + Properties *RecoveryPlanUnplannedFailoverInputProperties `json:"properties,omitempty"` +} + +// RecoveryPlanUnplannedFailoverInputProperties is recovery plan unplanned failover input properties. +type RecoveryPlanUnplannedFailoverInputProperties struct { + FailoverDirection PossibleOperationsDirections `json:"failoverDirection,omitempty"` + SourceSiteOperations SourceSiteOperations `json:"sourceSiteOperations,omitempty"` + ProviderSpecificDetails *[]RecoveryPlanProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +// RecoveryPoint is base class representing a recovery point. +type RecoveryPoint struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *RecoveryPointProperties `json:"properties,omitempty"` +} + +// RecoveryPointCollection is collection of recovery point details. +type RecoveryPointCollection struct { + autorest.Response `json:"-"` + Value *[]RecoveryPoint `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// RecoveryPointCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client RecoveryPointCollection) RecoveryPointCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RecoveryPointProperties is recovery point properties. +type RecoveryPointProperties struct { + RecoveryPointTime *date.Time `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` +} + +// RecoveryServicesProvider is provider details. +type RecoveryServicesProvider struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *RecoveryServicesProviderProperties `json:"properties,omitempty"` +} + +// RecoveryServicesProviderCollection is collection of providers. +type RecoveryServicesProviderCollection struct { + autorest.Response `json:"-"` + Value *[]RecoveryServicesProvider `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// RecoveryServicesProviderCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client RecoveryServicesProviderCollection) RecoveryServicesProviderCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// RecoveryServicesProviderProperties is recovery services provider properties. +type RecoveryServicesProviderProperties struct { + FabricType *string `json:"fabricType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProviderVersion *string `json:"providerVersion,omitempty"` + ServerVersion *string `json:"serverVersion,omitempty"` + ProviderVersionState *string `json:"providerVersionState,omitempty"` + ProviderVersionExpiryDate *date.Time `json:"providerVersionExpiryDate,omitempty"` + FabricFriendlyName *string `json:"fabricFriendlyName,omitempty"` + LastHeartBeat *date.Time `json:"lastHeartBeat,omitempty"` + ConnectionStatus *string `json:"connectionStatus,omitempty"` + ProtectedItemCount *int32 `json:"protectedItemCount,omitempty"` + AllowedScenarios *[]string `json:"allowedScenarios,omitempty"` + HealthErrorDetails *[]HealthError `json:"healthErrorDetails,omitempty"` +} + +// RemoveProtectionContainerMappingInput is container unpairing input. +type RemoveProtectionContainerMappingInput struct { + Properties *RemoveProtectionContainerMappingInputProperties `json:"properties,omitempty"` +} + +// RemoveProtectionContainerMappingInputProperties is unpairing input properties. +type RemoveProtectionContainerMappingInputProperties struct { + ProviderSpecificInput *ReplicationProviderContainerUnmappingInput `json:"providerSpecificInput,omitempty"` +} + +// RenewCertificateInput is certificate renewal input. +type RenewCertificateInput struct { + Properties *RenewCertificateInputProperties `json:"properties,omitempty"` +} + +// RenewCertificateInputProperties is renew Certificate input properties. +type RenewCertificateInputProperties struct { + RenewCertificateType *string `json:"renewCertificateType,omitempty"` +} + +// ReplicationGroupDetails is replication group details. This will be used in case of San and Wvr. +type ReplicationGroupDetails struct { +} + +// ReplicationProtectedItem is replication protected item. +type ReplicationProtectedItem struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *ReplicationProtectedItemProperties `json:"properties,omitempty"` +} + +// ReplicationProtectedItemCollection is replication protected item collection. +type ReplicationProtectedItemCollection struct { + autorest.Response `json:"-"` + Value *[]ReplicationProtectedItem `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ReplicationProtectedItemCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ReplicationProtectedItemCollection) ReplicationProtectedItemCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ReplicationProtectedItemProperties is replication protected item custom data details. +type ReplicationProtectedItemProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectedItemType *string `json:"protectedItemType,omitempty"` + ProtectableItemID *string `json:"protectableItemId,omitempty"` + RecoveryServicesProviderID *string `json:"recoveryServicesProviderId,omitempty"` + PrimaryFabricFriendlyName *string `json:"primaryFabricFriendlyName,omitempty"` + RecoveryFabricFriendlyName *string `json:"recoveryFabricFriendlyName,omitempty"` + RecoveryFabricID *string `json:"recoveryFabricId,omitempty"` + PrimaryProtectionContainerFriendlyName *string `json:"primaryProtectionContainerFriendlyName,omitempty"` + RecoveryProtectionContainerFriendlyName *string `json:"recoveryProtectionContainerFriendlyName,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + ProtectionStateDescription *string `json:"protectionStateDescription,omitempty"` + ActiveLocation *string `json:"activeLocation,omitempty"` + TestFailoverState *string `json:"testFailoverState,omitempty"` + TestFailoverStateDescription *string `json:"testFailoverStateDescription,omitempty"` + AllowedOperations *[]string `json:"allowedOperations,omitempty"` + ReplicationHealth *string `json:"replicationHealth,omitempty"` + ReplicationHealthErrors *[]HealthError `json:"replicationHealthErrors,omitempty"` + PolicyID *string `json:"policyId,omitempty"` + PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"` + LastSuccessfulFailoverTime *date.Time `json:"lastSuccessfulFailoverTime,omitempty"` + LastSuccessfulTestFailoverTime *date.Time `json:"lastSuccessfulTestFailoverTime,omitempty"` + CurrentScenario *CurrentScenarioDetails `json:"currentScenario,omitempty"` + FailoverRecoveryPointID *string `json:"failoverRecoveryPointId,omitempty"` + ProviderSpecificDetails *ReplicationProviderSpecificSettings `json:"providerSpecificDetails,omitempty"` + RecoveryContainerID *string `json:"recoveryContainerId,omitempty"` +} + +// ReplicationProviderContainerUnmappingInput is provider specific input for unpairing operations. +type ReplicationProviderContainerUnmappingInput struct { + InstanceType *string `json:"instanceType,omitempty"` +} + +// ReplicationProviderSpecificContainerCreationInput is provider specific input for container creation operation. +type ReplicationProviderSpecificContainerCreationInput struct { +} + +// ReplicationProviderSpecificContainerMappingInput is provider specific input for pairing operations. +type ReplicationProviderSpecificContainerMappingInput struct { + InstanceType *string `json:"instanceType,omitempty"` +} + +// ReplicationProviderSpecificSettings is replication provider specific settings. +type ReplicationProviderSpecificSettings struct { +} + +// Resource is azure resource. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` +} + +// ResumeJobParams is resume job params. +type ResumeJobParams struct { + Properties *ResumeJobParamsProperties `json:"properties,omitempty"` +} + +// ResumeJobParamsProperties is resume job properties. +type ResumeJobParamsProperties struct { + Comments *string `json:"comments,omitempty"` +} + +// RetentionVolume is the retention details of the MT. +type RetentionVolume struct { + VolumeName *string `json:"volumeName,omitempty"` + CapacityInBytes *int64 `json:"capacityInBytes,omitempty"` + FreeSpaceInBytes *int64 `json:"freeSpaceInBytes,omitempty"` + ThresholdPercentage *int32 `json:"thresholdPercentage,omitempty"` +} + +// ReverseReplicationInput is reverse replication input. +type ReverseReplicationInput struct { + Properties *ReverseReplicationInputProperties `json:"properties,omitempty"` +} + +// ReverseReplicationInputProperties is reverse replication input properties. +type ReverseReplicationInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + ProviderSpecificDetails *ReverseReplicationProviderSpecificInput `json:"providerSpecificDetails,omitempty"` +} + +// ReverseReplicationProviderSpecificInput is provider specific reverse replication input. +type ReverseReplicationProviderSpecificInput struct { +} + +// RoleAssignment is azure role assignment details. +type RoleAssignment struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Scope *string `json:"scope,omitempty"` + PrincipalID *string `json:"principalId,omitempty"` + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` +} + +// RunAsAccount is CS Accounts Details. +type RunAsAccount struct { + AccountID *string `json:"accountId,omitempty"` + AccountName *string `json:"accountName,omitempty"` +} + +// SanEnableProtectionInput is san enable protection provider specific input. +type SanEnableProtectionInput struct { +} + +// ScriptActionTaskDetails is this class represents the script action task details. +type ScriptActionTaskDetails struct { + Name *string `json:"name,omitempty"` + Path *string `json:"path,omitempty"` + Output *string `json:"output,omitempty"` + IsPrimarySideScript *bool `json:"isPrimarySideScript,omitempty"` +} + +// ServiceError is ASR error model +type ServiceError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + PossibleCauses *string `json:"possibleCauses,omitempty"` + RecommendedAction *string `json:"recommendedAction,omitempty"` + ActivityID *string `json:"activityId,omitempty"` +} + +// StorageClassification is storage object definition. +type StorageClassification struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *StorageClassificationProperties `json:"properties,omitempty"` +} + +// StorageClassificationCollection is collection of storage details. +type StorageClassificationCollection struct { + autorest.Response `json:"-"` + Value *[]StorageClassification `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// StorageClassificationCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client StorageClassificationCollection) StorageClassificationCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// StorageClassificationMapping is storage mapping object. +type StorageClassificationMapping struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *StorageClassificationMappingProperties `json:"properties,omitempty"` +} + +// StorageClassificationMappingCollection is collection of storage mapping details. +type StorageClassificationMappingCollection struct { + autorest.Response `json:"-"` + Value *[]StorageClassificationMapping `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// StorageClassificationMappingCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client StorageClassificationMappingCollection) StorageClassificationMappingCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// StorageClassificationMappingInput is storage mapping input. +type StorageClassificationMappingInput struct { + Properties *StorageMappingInputProperties `json:"properties,omitempty"` +} + +// StorageClassificationMappingProperties is storage mapping properties. +type StorageClassificationMappingProperties struct { + TargetStorageClassificationID *string `json:"targetStorageClassificationId,omitempty"` +} + +// StorageClassificationProperties is storage object properties. +type StorageClassificationProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` +} + +// StorageMappingInputProperties is storage mapping input properties. +type StorageMappingInputProperties struct { + TargetStorageClassificationID *string `json:"targetStorageClassificationId,omitempty"` +} + +// Subnet is subnets of the network. +type Subnet struct { + Name *string `json:"name,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + AddressList *[]string `json:"addressList,omitempty"` +} + +// SwitchProtectionInput is switch protection input. +type SwitchProtectionInput struct { + Properties *SwitchProtectionInputProperties `json:"properties,omitempty"` +} + +// SwitchProtectionInputProperties is switch protection input properties. +type SwitchProtectionInputProperties struct { + ReplicationProtectedItemName *string `json:"replicationProtectedItemName,omitempty"` + ProviderSpecificDetails *SwitchProtectionProviderSpecificInput `json:"providerSpecificDetails,omitempty"` +} + +// SwitchProtectionJobDetails is this class represents details for switch protection job. +type SwitchProtectionJobDetails struct { + AffectedObjectDetails *map[string]*string `json:"affectedObjectDetails,omitempty"` + NewReplicationProtectedItemID *string `json:"newReplicationProtectedItemId,omitempty"` +} + +// SwitchProtectionProviderSpecificInput is provider specific switch protection input. +type SwitchProtectionProviderSpecificInput struct { +} + +// TaskTypeDetails is task details based on specific task type. +type TaskTypeDetails struct { +} + +// TestFailoverCleanupInput is input definition for test failover cleanup. +type TestFailoverCleanupInput struct { + Properties *TestFailoverCleanupInputProperties `json:"properties,omitempty"` +} + +// TestFailoverCleanupInputProperties is input definition for test failover cleanup input properties. +type TestFailoverCleanupInputProperties struct { + Comments *string `json:"comments,omitempty"` +} + +// TestFailoverInput is input definition for planned failover. +type TestFailoverInput struct { + Properties *TestFailoverInputProperties `json:"properties,omitempty"` +} + +// TestFailoverInputProperties is input definition for planned failover input properties. +type TestFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + NetworkID *string `json:"networkId,omitempty"` + SkipTestFailoverCleanup *string `json:"skipTestFailoverCleanup,omitempty"` + ProviderSpecificDetails *ProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +// TestFailoverJobDetails is this class represents the details for a test failover job. +type TestFailoverJobDetails struct { + AffectedObjectDetails *map[string]*string `json:"affectedObjectDetails,omitempty"` + TestFailoverStatus *string `json:"testFailoverStatus,omitempty"` + Comments *string `json:"comments,omitempty"` + NetworkName *string `json:"networkName,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + NetworkType *string `json:"networkType,omitempty"` + ProtectedItemDetails *[]TestFailoverReplicationProtectedItemDetails `json:"protectedItemDetails,omitempty"` +} + +// TestFailoverReplicationProtectedItemDetails is test failover details for a replication protected item. +type TestFailoverReplicationProtectedItemDetails struct { + Name *string `json:"name,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + TestVMName *string `json:"testVmName,omitempty"` + TestVMFriendlyName *string `json:"testVmFriendlyName,omitempty"` + NetworkConnectionStatus *string `json:"networkConnectionStatus,omitempty"` + NetworkFriendlyName *string `json:"networkFriendlyName,omitempty"` + Subnet *string `json:"subnet,omitempty"` +} + +// UnplannedFailoverInput is input definition for planned failover. +type UnplannedFailoverInput struct { + Properties *UnplannedFailoverInputProperties `json:"properties,omitempty"` +} + +// UnplannedFailoverInputProperties is input definition for planned failover input properties. +type UnplannedFailoverInputProperties struct { + FailoverDirection *string `json:"failoverDirection,omitempty"` + SourceSiteOperations *string `json:"sourceSiteOperations,omitempty"` + ProviderSpecificDetails *ProviderSpecificFailoverInput `json:"providerSpecificDetails,omitempty"` +} + +// UpdateMobilityServiceRequest is request to update the mobility service on a protected item. +type UpdateMobilityServiceRequest struct { + Properties *UpdateMobilityServiceRequestProperties `json:"properties,omitempty"` +} + +// UpdateMobilityServiceRequestProperties is the properties of an update mobility service request. +type UpdateMobilityServiceRequestProperties struct { + RunAsAccountID *string `json:"runAsAccountId,omitempty"` +} + +// UpdateNetworkMappingInput is update network mapping input. +type UpdateNetworkMappingInput struct { + Properties *UpdateNetworkMappingInputProperties `json:"properties,omitempty"` +} + +// UpdateNetworkMappingInputProperties is common input details for network mapping operation. +type UpdateNetworkMappingInputProperties struct { + RecoveryFabricName *string `json:"recoveryFabricName,omitempty"` + RecoveryNetworkID *string `json:"recoveryNetworkId,omitempty"` + FabricSpecificDetails *FabricSpecificUpdateNetworkMappingInput `json:"fabricSpecificDetails,omitempty"` +} + +// UpdatePolicyInput is update protection profile input. +type UpdatePolicyInput struct { + Properties *UpdatePolicyInputProperties `json:"properties,omitempty"` +} + +// UpdatePolicyInputProperties is policy update properties. +type UpdatePolicyInputProperties struct { + ReplicationProviderSettings *PolicyProviderSpecificInput `json:"replicationProviderSettings,omitempty"` +} + +// UpdateRecoveryPlanInput is update recovery plan input class. +type UpdateRecoveryPlanInput struct { + Properties *UpdateRecoveryPlanInputProperties `json:"properties,omitempty"` +} + +// UpdateRecoveryPlanInputProperties is recovery plan updation properties. +type UpdateRecoveryPlanInputProperties struct { + Groups *[]RecoveryPlanGroup `json:"groups,omitempty"` +} + +// UpdateReplicationProtectedItemInput is update replication protected item input. +type UpdateReplicationProtectedItemInput struct { + Properties *UpdateReplicationProtectedItemInputProperties `json:"properties,omitempty"` +} + +// UpdateReplicationProtectedItemInputProperties is update protected item input properties. +type UpdateReplicationProtectedItemInputProperties struct { + RecoveryAzureVMName *string `json:"recoveryAzureVMName,omitempty"` + RecoveryAzureVMSize *string `json:"recoveryAzureVMSize,omitempty"` + SelectedRecoveryAzureNetworkID *string `json:"selectedRecoveryAzureNetworkId,omitempty"` + EnableRDPOnTargetOption *string `json:"enableRDPOnTargetOption,omitempty"` + VMNics *[]VMNicInputDetails `json:"vmNics,omitempty"` + LicenseType LicenseType `json:"licenseType,omitempty"` + RecoveryAvailabilitySetID *string `json:"recoveryAvailabilitySetId,omitempty"` + ProviderSpecificDetails *UpdateReplicationProtectedItemProviderInput `json:"providerSpecificDetails,omitempty"` +} + +// UpdateReplicationProtectedItemProviderInput is update replication protected item provider specific input. +type UpdateReplicationProtectedItemProviderInput struct { +} + +// UpdateVCenterRequest is input required to update vCenter. +type UpdateVCenterRequest struct { + Properties *UpdateVCenterRequestProperties `json:"properties,omitempty"` +} + +// UpdateVCenterRequestProperties is the properties of an update vCenter request. +type UpdateVCenterRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + Port *string `json:"port,omitempty"` + RunAsAccountID *string `json:"runAsAccountId,omitempty"` +} + +// VCenter is vCenter definition. +type VCenter struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Properties *VCenterProperties `json:"properties,omitempty"` +} + +// VCenterCollection is collection of vCenter details. +type VCenterCollection struct { + autorest.Response `json:"-"` + Value *[]VCenter `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// VCenterCollectionPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client VCenterCollection) VCenterCollectionPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// VCenterProperties is vCenter properties. +type VCenterProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + InternalID *string `json:"internalId,omitempty"` + LastHeartbeat *date.Time `json:"lastHeartbeat,omitempty"` + DiscoveryStatus *string `json:"discoveryStatus,omitempty"` + ProcessServerID *string `json:"processServerId,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InfrastructureID *string `json:"infrastructureId,omitempty"` + Port *string `json:"port,omitempty"` + RunAsAccountID *string `json:"runAsAccountId,omitempty"` + FabricArmResourceName *string `json:"fabricArmResourceName,omitempty"` +} + +// VirtualMachineTaskDetails is this class represents the virtual machine task details. +type VirtualMachineTaskDetails struct { + SkippedReason *string `json:"skippedReason,omitempty"` + SkippedReasonString *string `json:"skippedReasonString,omitempty"` + JobTask *JobEntity `json:"jobTask,omitempty"` +} + +// VmmDetails is VMM fabric specific details. +type VmmDetails struct { +} + +// VmmToAzureCreateNetworkMappingInput is create network mappings input properties/behaviour specific to Vmm to Azure +// Network mapping. +type VmmToAzureCreateNetworkMappingInput struct { +} + +// VmmToAzureNetworkMappingSettings is e2A Network Mapping fabric specific settings. +type VmmToAzureNetworkMappingSettings struct { +} + +// VmmToAzureUpdateNetworkMappingInput is update network mappings input properties/behaviour specific to vmm to azure. +type VmmToAzureUpdateNetworkMappingInput struct { +} + +// VmmToVmmCreateNetworkMappingInput is create network mappings input properties/behaviour specific to vmm to vmm +// Network mapping. +type VmmToVmmCreateNetworkMappingInput struct { +} + +// VmmToVmmNetworkMappingSettings is e2E Network Mapping fabric specific settings. +type VmmToVmmNetworkMappingSettings struct { +} + +// VmmToVmmUpdateNetworkMappingInput is update network mappings input properties/behaviour specific to vmm to vmm. +type VmmToVmmUpdateNetworkMappingInput struct { +} + +// VMNicDetails is hyper V VM network details. +type VMNicDetails struct { + NicID *string `json:"nicId,omitempty"` + ReplicaNicID *string `json:"replicaNicId,omitempty"` + SourceNicArmID *string `json:"sourceNicArmId,omitempty"` + VMSubnetName *string `json:"vMSubnetName,omitempty"` + VMNetworkName *string `json:"vMNetworkName,omitempty"` + RecoveryVMNetworkID *string `json:"recoveryVMNetworkId,omitempty"` + RecoveryVMSubnetName *string `json:"recoveryVMSubnetName,omitempty"` + IPAddressType *string `json:"ipAddressType,omitempty"` + PrimaryNicStaticIPAddress *string `json:"primaryNicStaticIPAddress,omitempty"` + ReplicaNicStaticIPAddress *string `json:"replicaNicStaticIPAddress,omitempty"` + SelectionType *string `json:"selectionType,omitempty"` +} + +// VMNicInputDetails is hyper V VM network input details. +type VMNicInputDetails struct { + NicID *string `json:"nicId,omitempty"` + RecoveryVMSubnetName *string `json:"recoveryVMSubnetName,omitempty"` + ReplicaNicStaticIPAddress *string `json:"replicaNicStaticIPAddress,omitempty"` + SelectionType *string `json:"selectionType,omitempty"` +} + +// VMNicUpdatesTaskDetails is this class represents the vm NicUpdates task details. +type VMNicUpdatesTaskDetails struct { + VMID *string `json:"vmId,omitempty"` + NicID *string `json:"nicId,omitempty"` + Name *string `json:"name,omitempty"` +} + +// VMwareDetails is store the fabric details specific to the VMware fabric. +type VMwareDetails struct { + ProcessServers *[]ProcessServer `json:"processServers,omitempty"` + MasterTargetServers *[]MasterTargetServer `json:"masterTargetServers,omitempty"` + RunAsAccounts *[]RunAsAccount `json:"runAsAccounts,omitempty"` + ReplicationPairCount *string `json:"replicationPairCount,omitempty"` + ProcessServerCount *string `json:"processServerCount,omitempty"` + AgentCount *string `json:"agentCount,omitempty"` + ProtectedServers *string `json:"protectedServers,omitempty"` + SystemLoad *string `json:"systemLoad,omitempty"` + SystemLoadStatus *string `json:"systemLoadStatus,omitempty"` + CPULoad *string `json:"cpuLoad,omitempty"` + CPULoadStatus *string `json:"cpuLoadStatus,omitempty"` + TotalMemoryInBytes *int64 `json:"totalMemoryInBytes,omitempty"` + AvailableMemoryInBytes *int64 `json:"availableMemoryInBytes,omitempty"` + MemoryUsageStatus *string `json:"memoryUsageStatus,omitempty"` + TotalSpaceInBytes *int64 `json:"totalSpaceInBytes,omitempty"` + AvailableSpaceInBytes *int64 `json:"availableSpaceInBytes,omitempty"` + SpaceUsageStatus *string `json:"spaceUsageStatus,omitempty"` + WebLoad *string `json:"webLoad,omitempty"` + WebLoadStatus *string `json:"webLoadStatus,omitempty"` + DatabaseServerLoad *string `json:"databaseServerLoad,omitempty"` + DatabaseServerLoadStatus *string `json:"databaseServerLoadStatus,omitempty"` + CsServiceStatus *string `json:"csServiceStatus,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + HostName *string `json:"hostName,omitempty"` + LastHeartbeat *date.Time `json:"lastHeartbeat,omitempty"` + VersionStatus *string `json:"versionStatus,omitempty"` + SslCertExpiryDate *date.Time `json:"sslCertExpiryDate,omitempty"` + SslCertExpiryRemainingDays *int32 `json:"sslCertExpiryRemainingDays,omitempty"` + PsTemplateVersion *string `json:"psTemplateVersion,omitempty"` +} + +// VMwareVirtualMachineDetails is vMware provider specific settings +type VMwareVirtualMachineDetails struct { + AgentGeneratedID *string `json:"agentGeneratedId,omitempty"` + AgentInstalled *string `json:"agentInstalled,omitempty"` + OsType *string `json:"osType,omitempty"` + AgentVersion *string `json:"agentVersion,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + PoweredOn *string `json:"poweredOn,omitempty"` + VCenterInfrastructureID *string `json:"vCenterInfrastructureId,omitempty"` + DiscoveryType *string `json:"discoveryType,omitempty"` + DiskDetails *[]InMageDiskDetails `json:"diskDetails,omitempty"` + ValidationErrors *[]HealthError `json:"validationErrors,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/operations.go new file mode 100644 index 0000000000..50e58e1ea6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/operations.go @@ -0,0 +1,170 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the Recoveryservicessiterecovery service. +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string, resourceGroupName string, resourceName string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// List operation to return the list of available operations. +func (client OperationsClient) List() (result OperationsDiscoveryCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/operations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationsDiscoveryCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults OperationsDiscoveryCollection) (result OperationsDiscoveryCollection, err error) { + req, err := lastResults.OperationsDiscoveryCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client OperationsClient) ListComplete(cancel <-chan struct{}) (<-chan OperationsDiscovery, <-chan error) { + resultChan := make(chan OperationsDiscovery) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/recoverypoints.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/recoverypoints.go new file mode 100644 index 0000000000..b279e5c471 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/recoverypoints.go @@ -0,0 +1,247 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// RecoveryPointsClient is the client for the RecoveryPoints methods of the Recoveryservicessiterecovery service. +type RecoveryPointsClient struct { + ManagementClient +} + +// NewRecoveryPointsClient creates an instance of the RecoveryPointsClient client. +func NewRecoveryPointsClient(subscriptionID string, resourceGroupName string, resourceName string) RecoveryPointsClient { + return NewRecoveryPointsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewRecoveryPointsClientWithBaseURI creates an instance of the RecoveryPointsClient client. +func NewRecoveryPointsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) RecoveryPointsClient { + return RecoveryPointsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Get get the details of specified recovery point. +// +// fabricName is the fabric name. protectionContainerName is the protection container name. replicatedProtectedItemName +// is the replication protected item's name. recoveryPointName is the recovery point name. +func (client RecoveryPointsClient) Get(fabricName string, protectionContainerName string, replicatedProtectedItemName string, recoveryPointName string) (result RecoveryPoint, err error) { + req, err := client.GetPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, recoveryPointName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RecoveryPointsClient) GetPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, recoveryPointName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "recoveryPointName": autorest.Encode("path", recoveryPointName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/recoveryPoints/{recoveryPointName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client RecoveryPointsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client RecoveryPointsClient) GetResponder(resp *http.Response) (result RecoveryPoint, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationProtectedItems lists the available recovery points for a replication protected item. +// +// fabricName is the fabric name. protectionContainerName is the protection container name. replicatedProtectedItemName +// is the replication protected item's name. +func (client RecoveryPointsClient) ListByReplicationProtectedItems(fabricName string, protectionContainerName string, replicatedProtectedItemName string) (result RecoveryPointCollection, err error) { + req, err := client.ListByReplicationProtectedItemsPreparer(fabricName, protectionContainerName, replicatedProtectedItemName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "ListByReplicationProtectedItems", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationProtectedItemsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "ListByReplicationProtectedItems", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationProtectedItemsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "ListByReplicationProtectedItems", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationProtectedItemsPreparer prepares the ListByReplicationProtectedItems request. +func (client RecoveryPointsClient) ListByReplicationProtectedItemsPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/recoveryPoints", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationProtectedItemsSender sends the ListByReplicationProtectedItems request. The method will close the +// http.Response Body if it receives an error. +func (client RecoveryPointsClient) ListByReplicationProtectedItemsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationProtectedItemsResponder handles the response to the ListByReplicationProtectedItems request. The method always +// closes the http.Response Body. +func (client RecoveryPointsClient) ListByReplicationProtectedItemsResponder(resp *http.Response) (result RecoveryPointCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationProtectedItemsNextResults retrieves the next set of results, if any. +func (client RecoveryPointsClient) ListByReplicationProtectedItemsNextResults(lastResults RecoveryPointCollection) (result RecoveryPointCollection, err error) { + req, err := lastResults.RecoveryPointCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "ListByReplicationProtectedItems", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationProtectedItemsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "ListByReplicationProtectedItems", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationProtectedItemsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.RecoveryPointsClient", "ListByReplicationProtectedItems", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationProtectedItemsComplete gets all elements from the list without paging. +func (client RecoveryPointsClient) ListByReplicationProtectedItemsComplete(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cancel <-chan struct{}) (<-chan RecoveryPoint, <-chan error) { + resultChan := make(chan RecoveryPoint) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationProtectedItems(fabricName, protectionContainerName, replicatedProtectedItemName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationProtectedItemsNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationalertsettings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationalertsettings.go new file mode 100644 index 0000000000..62c6cd0a68 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationalertsettings.go @@ -0,0 +1,307 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationAlertSettingsClient is the client for the ReplicationAlertSettings methods of the +// Recoveryservicessiterecovery service. +type ReplicationAlertSettingsClient struct { + ManagementClient +} + +// NewReplicationAlertSettingsClient creates an instance of the ReplicationAlertSettingsClient client. +func NewReplicationAlertSettingsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationAlertSettingsClient { + return NewReplicationAlertSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationAlertSettingsClientWithBaseURI creates an instance of the ReplicationAlertSettingsClient client. +func NewReplicationAlertSettingsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationAlertSettingsClient { + return ReplicationAlertSettingsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Create create or update an email notification(alert) configuration. +// +// alertSettingName is the name of the email notification(alert) configuration. request is the input to configure the +// email notification(alert). +func (client ReplicationAlertSettingsClient) Create(alertSettingName string, request ConfigureAlertRequest) (result Alert, err error) { + req, err := client.CreatePreparer(alertSettingName, request) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ReplicationAlertSettingsClient) CreatePreparer(alertSettingName string, request ConfigureAlertRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertSettingName": autorest.Encode("path", alertSettingName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationAlertSettings/{alertSettingName}", pathParameters), + autorest.WithJSON(request), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationAlertSettingsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationAlertSettingsClient) CreateResponder(resp *http.Response) (result Alert, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the details of the specified email notification(alert) configuration. +// +// alertSettingName is the name of the email notification configuration. +func (client ReplicationAlertSettingsClient) Get(alertSettingName string) (result Alert, err error) { + req, err := client.GetPreparer(alertSettingName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationAlertSettingsClient) GetPreparer(alertSettingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertSettingName": autorest.Encode("path", alertSettingName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationAlertSettings/{alertSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationAlertSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationAlertSettingsClient) GetResponder(resp *http.Response) (result Alert, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the list of email notification(alert) configurations for the vault. . +func (client ReplicationAlertSettingsClient) List() (result AlertCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationAlertSettingsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationAlertSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationAlertSettingsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationAlertSettingsClient) ListResponder(resp *http.Response) (result AlertCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationAlertSettingsClient) ListNextResults(lastResults AlertCollection) (result AlertCollection, err error) { + req, err := lastResults.AlertCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationAlertSettingsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationAlertSettingsClient) ListComplete(cancel <-chan struct{}) (<-chan Alert, <-chan error) { + resultChan := make(chan Alert) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationevents.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationevents.go new file mode 100644 index 0000000000..976f445be3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationevents.go @@ -0,0 +1,237 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationEventsClient is the client for the ReplicationEvents methods of the Recoveryservicessiterecovery service. +type ReplicationEventsClient struct { + ManagementClient +} + +// NewReplicationEventsClient creates an instance of the ReplicationEventsClient client. +func NewReplicationEventsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationEventsClient { + return NewReplicationEventsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationEventsClientWithBaseURI creates an instance of the ReplicationEventsClient client. +func NewReplicationEventsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationEventsClient { + return ReplicationEventsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Get the operation to get the details of an Azure Site recovery event. +// +// eventName is the name of the Azure Site Recovery event. +func (client ReplicationEventsClient) Get(eventName string) (result Event, err error) { + req, err := client.GetPreparer(eventName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationEventsClient) GetPreparer(eventName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "eventName": autorest.Encode("path", eventName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationEvents/{eventName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationEventsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationEventsClient) GetResponder(resp *http.Response) (result Event, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the list of Azure Site Recovery events for the vault. +func (client ReplicationEventsClient) List() (result EventCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationEventsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationEvents", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationEventsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationEventsClient) ListResponder(resp *http.Response) (result EventCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationEventsClient) ListNextResults(lastResults EventCollection) (result EventCollection, err error) { + req, err := lastResults.EventCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationEventsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationEventsClient) ListComplete(cancel <-chan struct{}) (<-chan Event, <-chan error) { + resultChan := make(chan Event) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationfabrics.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationfabrics.go new file mode 100644 index 0000000000..1a83fd3448 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationfabrics.go @@ -0,0 +1,741 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationFabricsClient is the client for the ReplicationFabrics methods of the Recoveryservicessiterecovery +// service. +type ReplicationFabricsClient struct { + ManagementClient +} + +// NewReplicationFabricsClient creates an instance of the ReplicationFabricsClient client. +func NewReplicationFabricsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationFabricsClient { + return NewReplicationFabricsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationFabricsClientWithBaseURI creates an instance of the ReplicationFabricsClient client. +func NewReplicationFabricsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationFabricsClient { + return ReplicationFabricsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// CheckConsistency the operation to perform a consistency check on the fabric. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// fabricName is fabric name. +func (client ReplicationFabricsClient) CheckConsistency(fabricName string, cancel <-chan struct{}) (<-chan Fabric, <-chan error) { + resultChan := make(chan Fabric, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Fabric + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CheckConsistencyPreparer(fabricName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "CheckConsistency", nil, "Failure preparing request") + return + } + + resp, err := client.CheckConsistencySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "CheckConsistency", resp, "Failure sending request") + return + } + + result, err = client.CheckConsistencyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "CheckConsistency", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CheckConsistencyPreparer prepares the CheckConsistency request. +func (client ReplicationFabricsClient) CheckConsistencyPreparer(fabricName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/checkConsistency", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CheckConsistencySender sends the CheckConsistency request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationFabricsClient) CheckConsistencySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CheckConsistencyResponder handles the response to the CheckConsistency request. The method always +// closes the http.Response Body. +func (client ReplicationFabricsClient) CheckConsistencyResponder(resp *http.Response) (result Fabric, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Create the operation to create an Azure Site Recovery fabric (for e.g. Hyper-V site) This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is name of the ASR fabric. input is fabric creation input. +func (client ReplicationFabricsClient) Create(fabricName string, input FabricCreationInput, cancel <-chan struct{}) (<-chan Fabric, <-chan error) { + resultChan := make(chan Fabric, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Fabric + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(fabricName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationFabricsClient) CreatePreparer(fabricName string, input FabricCreationInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationFabricsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationFabricsClient) CreateResponder(resp *http.Response) (result Fabric, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete or remove an Azure Site Recovery fabric. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// fabricName is ASR fabric to delete +func (client ReplicationFabricsClient) Delete(fabricName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(fabricName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationFabricsClient) DeletePreparer(fabricName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/remove", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationFabricsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationFabricsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of an Azure Site Recovery fabric. +// +// fabricName is fabric name. +func (client ReplicationFabricsClient) Get(fabricName string) (result Fabric, err error) { + req, err := client.GetPreparer(fabricName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationFabricsClient) GetPreparer(fabricName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationFabricsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationFabricsClient) GetResponder(resp *http.Response) (result Fabric, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of the Azure Site Recovery fabrics in the vault. +func (client ReplicationFabricsClient) List() (result FabricCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationFabricsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationFabricsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationFabricsClient) ListResponder(resp *http.Response) (result FabricCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationFabricsClient) ListNextResults(lastResults FabricCollection) (result FabricCollection, err error) { + req, err := lastResults.FabricCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationFabricsClient) ListComplete(cancel <-chan struct{}) (<-chan Fabric, <-chan error) { + resultChan := make(chan Fabric) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Purge the operation to purge(force delete) an Azure Site Recovery fabric. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// fabricName is ASR fabric to purge. +func (client ReplicationFabricsClient) Purge(fabricName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.PurgePreparer(fabricName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Purge", nil, "Failure preparing request") + return + } + + resp, err := client.PurgeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Purge", resp, "Failure sending request") + return + } + + result, err = client.PurgeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "Purge", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// PurgePreparer prepares the Purge request. +func (client ReplicationFabricsClient) PurgePreparer(fabricName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// PurgeSender sends the Purge request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationFabricsClient) PurgeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client ReplicationFabricsClient) PurgeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ReassociateGateway the operation to move replications from a process server to another process server. This method +// may poll for completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// fabricName is the name of the fabric containing the process server. failoverProcessServerRequest is the input to the +// failover process server operation. +func (client ReplicationFabricsClient) ReassociateGateway(fabricName string, failoverProcessServerRequest FailoverProcessServerRequest, cancel <-chan struct{}) (<-chan Fabric, <-chan error) { + resultChan := make(chan Fabric, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Fabric + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ReassociateGatewayPreparer(fabricName, failoverProcessServerRequest, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "ReassociateGateway", nil, "Failure preparing request") + return + } + + resp, err := client.ReassociateGatewaySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "ReassociateGateway", resp, "Failure sending request") + return + } + + result, err = client.ReassociateGatewayResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "ReassociateGateway", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ReassociateGatewayPreparer prepares the ReassociateGateway request. +func (client ReplicationFabricsClient) ReassociateGatewayPreparer(fabricName string, failoverProcessServerRequest FailoverProcessServerRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/reassociateGateway", pathParameters), + autorest.WithJSON(failoverProcessServerRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ReassociateGatewaySender sends the ReassociateGateway request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationFabricsClient) ReassociateGatewaySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ReassociateGatewayResponder handles the response to the ReassociateGateway request. The method always +// closes the http.Response Body. +func (client ReplicationFabricsClient) ReassociateGatewayResponder(resp *http.Response) (result Fabric, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RenewCertificate renews the connection certificate for the ASR replication fabric. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is fabric name to renew certs for. renewCertificate is renew certificate input. +func (client ReplicationFabricsClient) RenewCertificate(fabricName string, renewCertificate RenewCertificateInput, cancel <-chan struct{}) (<-chan Fabric, <-chan error) { + resultChan := make(chan Fabric, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Fabric + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.RenewCertificatePreparer(fabricName, renewCertificate, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "RenewCertificate", nil, "Failure preparing request") + return + } + + resp, err := client.RenewCertificateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "RenewCertificate", resp, "Failure sending request") + return + } + + result, err = client.RenewCertificateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationFabricsClient", "RenewCertificate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// RenewCertificatePreparer prepares the RenewCertificate request. +func (client ReplicationFabricsClient) RenewCertificatePreparer(fabricName string, renewCertificate RenewCertificateInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/renewCertificate", pathParameters), + autorest.WithJSON(renewCertificate), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// RenewCertificateSender sends the RenewCertificate request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationFabricsClient) RenewCertificateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// RenewCertificateResponder handles the response to the RenewCertificate request. The method always +// closes the http.Response Body. +func (client ReplicationFabricsClient) RenewCertificateResponder(resp *http.Response) (result Fabric, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationjobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationjobs.go new file mode 100644 index 0000000000..d1c955b445 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationjobs.go @@ -0,0 +1,577 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationJobsClient is the client for the ReplicationJobs methods of the Recoveryservicessiterecovery service. +type ReplicationJobsClient struct { + ManagementClient +} + +// NewReplicationJobsClient creates an instance of the ReplicationJobsClient client. +func NewReplicationJobsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationJobsClient { + return NewReplicationJobsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationJobsClientWithBaseURI creates an instance of the ReplicationJobsClient client. +func NewReplicationJobsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationJobsClient { + return ReplicationJobsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Cancel the operation to cancel an Azure Site Recovery job. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// jobName is job indentifier. +func (client ReplicationJobsClient) Cancel(jobName string, cancel <-chan struct{}) (<-chan Job, <-chan error) { + resultChan := make(chan Job, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Job + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CancelPreparer(jobName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Cancel", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CancelPreparer prepares the Cancel request. +func (client ReplicationJobsClient) CancelPreparer(jobName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationJobs/{jobName}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationJobsClient) CancelSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client ReplicationJobsClient) CancelResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Export the operation to export the details of the Azure Site Recovery jobs of the vault. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// jobQueryParameter is job query filter. +func (client ReplicationJobsClient) Export(jobQueryParameter JobQueryParameter, cancel <-chan struct{}) (<-chan Job, <-chan error) { + resultChan := make(chan Job, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Job + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ExportPreparer(jobQueryParameter, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Export", nil, "Failure preparing request") + return + } + + resp, err := client.ExportSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Export", resp, "Failure sending request") + return + } + + result, err = client.ExportResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Export", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ExportPreparer prepares the Export request. +func (client ReplicationJobsClient) ExportPreparer(jobQueryParameter JobQueryParameter, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationJobs/export", pathParameters), + autorest.WithJSON(jobQueryParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ExportSender sends the Export request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationJobsClient) ExportSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ExportResponder handles the response to the Export request. The method always +// closes the http.Response Body. +func (client ReplicationJobsClient) ExportResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get get the details of an Azure Site Recovery job. +// +// jobName is job identifier +func (client ReplicationJobsClient) Get(jobName string) (result Job, err error) { + req, err := client.GetPreparer(jobName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationJobsClient) GetPreparer(jobName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationJobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationJobsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationJobsClient) GetResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the list of Azure Site Recovery Jobs for the vault. +// +// filter is oData filter options. +func (client ReplicationJobsClient) List(filter string) (result JobCollection, err error) { + req, err := client.ListPreparer(filter) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationJobsClient) ListPreparer(filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationJobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationJobsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationJobsClient) ListResponder(resp *http.Response) (result JobCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationJobsClient) ListNextResults(lastResults JobCollection) (result JobCollection, err error) { + req, err := lastResults.JobCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationJobsClient) ListComplete(filter string, cancel <-chan struct{}) (<-chan Job, <-chan error) { + resultChan := make(chan Job) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List(filter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Restart the operation to restart an Azure Site Recovery job. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// jobName is job identifier. +func (client ReplicationJobsClient) Restart(jobName string, cancel <-chan struct{}) (<-chan Job, <-chan error) { + resultChan := make(chan Job, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Job + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.RestartPreparer(jobName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Restart", nil, "Failure preparing request") + return + } + + resp, err := client.RestartSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Restart", resp, "Failure sending request") + return + } + + result, err = client.RestartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Restart", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// RestartPreparer prepares the Restart request. +func (client ReplicationJobsClient) RestartPreparer(jobName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationJobs/{jobName}/restart", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// RestartSender sends the Restart request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationJobsClient) RestartSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// RestartResponder handles the response to the Restart request. The method always +// closes the http.Response Body. +func (client ReplicationJobsClient) RestartResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Resume the operation to resume an Azure Site Recovery job This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// jobName is job identifier. resumeJobParams is resume rob comments. +func (client ReplicationJobsClient) Resume(jobName string, resumeJobParams ResumeJobParams, cancel <-chan struct{}) (<-chan Job, <-chan error) { + resultChan := make(chan Job, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Job + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ResumePreparer(jobName, resumeJobParams, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Resume", nil, "Failure preparing request") + return + } + + resp, err := client.ResumeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Resume", resp, "Failure sending request") + return + } + + result, err = client.ResumeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationJobsClient", "Resume", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ResumePreparer prepares the Resume request. +func (client ReplicationJobsClient) ResumePreparer(jobName string, resumeJobParams ResumeJobParams, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationJobs/{jobName}/resume", pathParameters), + autorest.WithJSON(resumeJobParams), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ResumeSender sends the Resume request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationJobsClient) ResumeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ResumeResponder handles the response to the Resume request. The method always +// closes the http.Response Body. +func (client ReplicationJobsClient) ResumeResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationlogicalnetworks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationlogicalnetworks.go new file mode 100644 index 0000000000..9868e505b5 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationlogicalnetworks.go @@ -0,0 +1,242 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationLogicalNetworksClient is the client for the ReplicationLogicalNetworks methods of the +// Recoveryservicessiterecovery service. +type ReplicationLogicalNetworksClient struct { + ManagementClient +} + +// NewReplicationLogicalNetworksClient creates an instance of the ReplicationLogicalNetworksClient client. +func NewReplicationLogicalNetworksClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationLogicalNetworksClient { + return NewReplicationLogicalNetworksClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationLogicalNetworksClientWithBaseURI creates an instance of the ReplicationLogicalNetworksClient client. +func NewReplicationLogicalNetworksClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationLogicalNetworksClient { + return ReplicationLogicalNetworksClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Get gets the details of a logical network. +// +// fabricName is server Id. logicalNetworkName is logical network name. +func (client ReplicationLogicalNetworksClient) Get(fabricName string, logicalNetworkName string) (result LogicalNetwork, err error) { + req, err := client.GetPreparer(fabricName, logicalNetworkName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationLogicalNetworksClient) GetPreparer(fabricName string, logicalNetworkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "logicalNetworkName": autorest.Encode("path", logicalNetworkName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationLogicalNetworks/{logicalNetworkName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLogicalNetworksClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationLogicalNetworksClient) GetResponder(resp *http.Response) (result LogicalNetwork, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationFabrics lists all the logical networks of the Azure Site Recovery fabric +// +// fabricName is server Id. +func (client ReplicationLogicalNetworksClient) ListByReplicationFabrics(fabricName string) (result LogicalNetworkCollection, err error) { + req, err := client.ListByReplicationFabricsPreparer(fabricName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request. +func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsPreparer(fabricName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationLogicalNetworks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always +// closes the http.Response Body. +func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsResponder(resp *http.Response) (result LogicalNetworkCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationFabricsNextResults retrieves the next set of results, if any. +func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsNextResults(lastResults LogicalNetworkCollection) (result LogicalNetworkCollection, err error) { + req, err := lastResults.LogicalNetworkCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationLogicalNetworksClient", "ListByReplicationFabrics", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationFabricsComplete gets all elements from the list without paging. +func (client ReplicationLogicalNetworksClient) ListByReplicationFabricsComplete(fabricName string, cancel <-chan struct{}) (<-chan LogicalNetwork, <-chan error) { + resultChan := make(chan LogicalNetwork) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationFabrics(fabricName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationFabricsNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationnetworkmappings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationnetworkmappings.go new file mode 100644 index 0000000000..d1c87d7a41 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationnetworkmappings.go @@ -0,0 +1,636 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationNetworkMappingsClient is the client for the ReplicationNetworkMappings methods of the +// Recoveryservicessiterecovery service. +type ReplicationNetworkMappingsClient struct { + ManagementClient +} + +// NewReplicationNetworkMappingsClient creates an instance of the ReplicationNetworkMappingsClient client. +func NewReplicationNetworkMappingsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationNetworkMappingsClient { + return NewReplicationNetworkMappingsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationNetworkMappingsClientWithBaseURI creates an instance of the ReplicationNetworkMappingsClient client. +func NewReplicationNetworkMappingsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationNetworkMappingsClient { + return ReplicationNetworkMappingsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Create the operation to create an ASR network mapping. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// fabricName is primary fabric name. networkName is primary network name. networkMappingName is network mapping name. +// input is create network mapping input. +func (client ReplicationNetworkMappingsClient) Create(fabricName string, networkName string, networkMappingName string, input CreateNetworkMappingInput, cancel <-chan struct{}) (<-chan NetworkMapping, <-chan error) { + resultChan := make(chan NetworkMapping, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result NetworkMapping + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(fabricName, networkName, networkMappingName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationNetworkMappingsClient) CreatePreparer(fabricName string, networkName string, networkMappingName string, input CreateNetworkMappingInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "networkMappingName": autorest.Encode("path", networkMappingName), + "networkName": autorest.Encode("path", networkName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationNetworks/{networkName}/replicationNetworkMappings/{networkMappingName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworkMappingsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationNetworkMappingsClient) CreateResponder(resp *http.Response) (result NetworkMapping, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete a network mapping. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is primary fabric name. networkName is primary network name. networkMappingName is ARM Resource Name for +// network mapping. +func (client ReplicationNetworkMappingsClient) Delete(fabricName string, networkName string, networkMappingName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(fabricName, networkName, networkMappingName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationNetworkMappingsClient) DeletePreparer(fabricName string, networkName string, networkMappingName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "networkMappingName": autorest.Encode("path", networkMappingName), + "networkName": autorest.Encode("path", networkName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationNetworks/{networkName}/replicationNetworkMappings/{networkMappingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworkMappingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationNetworkMappingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of an ASR network mapping +// +// fabricName is primary fabric name. networkName is primary network name. networkMappingName is network mapping name. +func (client ReplicationNetworkMappingsClient) Get(fabricName string, networkName string, networkMappingName string) (result NetworkMapping, err error) { + req, err := client.GetPreparer(fabricName, networkName, networkMappingName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationNetworkMappingsClient) GetPreparer(fabricName string, networkName string, networkMappingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "networkMappingName": autorest.Encode("path", networkMappingName), + "networkName": autorest.Encode("path", networkName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationNetworks/{networkName}/replicationNetworkMappings/{networkMappingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworkMappingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationNetworkMappingsClient) GetResponder(resp *http.Response) (result NetworkMapping, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all ASR network mappings in the vault. +func (client ReplicationNetworkMappingsClient) List() (result NetworkMappingCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationNetworkMappingsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationNetworkMappings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworkMappingsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationNetworkMappingsClient) ListResponder(resp *http.Response) (result NetworkMappingCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationNetworkMappingsClient) ListNextResults(lastResults NetworkMappingCollection) (result NetworkMappingCollection, err error) { + req, err := lastResults.NetworkMappingCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationNetworkMappingsClient) ListComplete(cancel <-chan struct{}) (<-chan NetworkMapping, <-chan error) { + resultChan := make(chan NetworkMapping) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationNetworks lists all ASR network mappings for the specified network. +// +// fabricName is primary fabric name. networkName is primary network name. +func (client ReplicationNetworkMappingsClient) ListByReplicationNetworks(fabricName string, networkName string) (result NetworkMappingCollection, err error) { + req, err := client.ListByReplicationNetworksPreparer(fabricName, networkName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "ListByReplicationNetworks", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationNetworksSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "ListByReplicationNetworks", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationNetworksResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "ListByReplicationNetworks", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationNetworksPreparer prepares the ListByReplicationNetworks request. +func (client ReplicationNetworkMappingsClient) ListByReplicationNetworksPreparer(fabricName string, networkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "networkName": autorest.Encode("path", networkName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationNetworks/{networkName}/replicationNetworkMappings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationNetworksSender sends the ListByReplicationNetworks request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworkMappingsClient) ListByReplicationNetworksSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationNetworksResponder handles the response to the ListByReplicationNetworks request. The method always +// closes the http.Response Body. +func (client ReplicationNetworkMappingsClient) ListByReplicationNetworksResponder(resp *http.Response) (result NetworkMappingCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationNetworksNextResults retrieves the next set of results, if any. +func (client ReplicationNetworkMappingsClient) ListByReplicationNetworksNextResults(lastResults NetworkMappingCollection) (result NetworkMappingCollection, err error) { + req, err := lastResults.NetworkMappingCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "ListByReplicationNetworks", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationNetworksSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "ListByReplicationNetworks", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationNetworksResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "ListByReplicationNetworks", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationNetworksComplete gets all elements from the list without paging. +func (client ReplicationNetworkMappingsClient) ListByReplicationNetworksComplete(fabricName string, networkName string, cancel <-chan struct{}) (<-chan NetworkMapping, <-chan error) { + resultChan := make(chan NetworkMapping) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationNetworks(fabricName, networkName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationNetworksNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Update the operation to update an ASR network mapping. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// fabricName is primary fabric name. networkName is primary network name. networkMappingName is network mapping name. +// input is update network mapping input. +func (client ReplicationNetworkMappingsClient) Update(fabricName string, networkName string, networkMappingName string, input UpdateNetworkMappingInput, cancel <-chan struct{}) (<-chan NetworkMapping, <-chan error) { + resultChan := make(chan NetworkMapping, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result NetworkMapping + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(fabricName, networkName, networkMappingName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworkMappingsClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdatePreparer prepares the Update request. +func (client ReplicationNetworkMappingsClient) UpdatePreparer(fabricName string, networkName string, networkMappingName string, input UpdateNetworkMappingInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "networkMappingName": autorest.Encode("path", networkMappingName), + "networkName": autorest.Encode("path", networkName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationNetworks/{networkName}/replicationNetworkMappings/{networkMappingName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworkMappingsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ReplicationNetworkMappingsClient) UpdateResponder(resp *http.Response) (result NetworkMapping, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationnetworks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationnetworks.go new file mode 100644 index 0000000000..c98903712f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationnetworks.go @@ -0,0 +1,374 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationNetworksClient is the client for the ReplicationNetworks methods of the Recoveryservicessiterecovery +// service. +type ReplicationNetworksClient struct { + ManagementClient +} + +// NewReplicationNetworksClient creates an instance of the ReplicationNetworksClient client. +func NewReplicationNetworksClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationNetworksClient { + return NewReplicationNetworksClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationNetworksClientWithBaseURI creates an instance of the ReplicationNetworksClient client. +func NewReplicationNetworksClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationNetworksClient { + return ReplicationNetworksClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Get gets the details of a network. +// +// fabricName is server Id. networkName is primary network name. +func (client ReplicationNetworksClient) Get(fabricName string, networkName string) (result Network, err error) { + req, err := client.GetPreparer(fabricName, networkName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationNetworksClient) GetPreparer(fabricName string, networkName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "networkName": autorest.Encode("path", networkName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationNetworks/{networkName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworksClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationNetworksClient) GetResponder(resp *http.Response) (result Network, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the networks available in a vault +func (client ReplicationNetworksClient) List() (result NetworkCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationNetworksClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationNetworks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworksClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationNetworksClient) ListResponder(resp *http.Response) (result NetworkCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationNetworksClient) ListNextResults(lastResults NetworkCollection) (result NetworkCollection, err error) { + req, err := lastResults.NetworkCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationNetworksClient) ListComplete(cancel <-chan struct{}) (<-chan Network, <-chan error) { + resultChan := make(chan Network) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationFabrics lists the networks available for a fabric. +// +// fabricName is fabric name +func (client ReplicationNetworksClient) ListByReplicationFabrics(fabricName string) (result NetworkCollection, err error) { + req, err := client.ListByReplicationFabricsPreparer(fabricName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "ListByReplicationFabrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "ListByReplicationFabrics", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "ListByReplicationFabrics", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request. +func (client ReplicationNetworksClient) ListByReplicationFabricsPreparer(fabricName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationNetworks", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationNetworksClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always +// closes the http.Response Body. +func (client ReplicationNetworksClient) ListByReplicationFabricsResponder(resp *http.Response) (result NetworkCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationFabricsNextResults retrieves the next set of results, if any. +func (client ReplicationNetworksClient) ListByReplicationFabricsNextResults(lastResults NetworkCollection) (result NetworkCollection, err error) { + req, err := lastResults.NetworkCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "ListByReplicationFabrics", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "ListByReplicationFabrics", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationNetworksClient", "ListByReplicationFabrics", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationFabricsComplete gets all elements from the list without paging. +func (client ReplicationNetworksClient) ListByReplicationFabricsComplete(fabricName string, cancel <-chan struct{}) (<-chan Network, <-chan error) { + resultChan := make(chan Network) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationFabrics(fabricName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationFabricsNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationpolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationpolicies.go new file mode 100644 index 0000000000..65c33e160b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationpolicies.go @@ -0,0 +1,487 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationPoliciesClient is the client for the ReplicationPolicies methods of the Recoveryservicessiterecovery +// service. +type ReplicationPoliciesClient struct { + ManagementClient +} + +// NewReplicationPoliciesClient creates an instance of the ReplicationPoliciesClient client. +func NewReplicationPoliciesClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationPoliciesClient { + return NewReplicationPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationPoliciesClientWithBaseURI creates an instance of the ReplicationPoliciesClient client. +func NewReplicationPoliciesClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationPoliciesClient { + return ReplicationPoliciesClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Create the operation to create a replication policy This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// policyName is replication policy name input is create policy input +func (client ReplicationPoliciesClient) Create(policyName string, input CreatePolicyInput, cancel <-chan struct{}) (<-chan Policy, <-chan error) { + resultChan := make(chan Policy, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Policy + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(policyName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationPoliciesClient) CreatePreparer(policyName string, input CreatePolicyInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyName": autorest.Encode("path", policyName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationPolicies/{policyName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationPoliciesClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationPoliciesClient) CreateResponder(resp *http.Response) (result Policy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete a replication policy. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// policyName is replication policy name. +func (client ReplicationPoliciesClient) Delete(policyName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(policyName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationPoliciesClient) DeletePreparer(policyName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyName": autorest.Encode("path", policyName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationPoliciesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationPoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of a replication policy. +// +// policyName is replication policy name. +func (client ReplicationPoliciesClient) Get(policyName string) (result Policy, err error) { + req, err := client.GetPreparer(policyName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationPoliciesClient) GetPreparer(policyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyName": autorest.Encode("path", policyName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationPolicies/{policyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationPoliciesClient) GetResponder(resp *http.Response) (result Policy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the replication policies for a vault. +func (client ReplicationPoliciesClient) List() (result PolicyCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationPoliciesClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationPoliciesClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationPoliciesClient) ListResponder(resp *http.Response) (result PolicyCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationPoliciesClient) ListNextResults(lastResults PolicyCollection) (result PolicyCollection, err error) { + req, err := lastResults.PolicyCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationPoliciesClient) ListComplete(cancel <-chan struct{}) (<-chan Policy, <-chan error) { + resultChan := make(chan Policy) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Update the operation to update a replication policy. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// policyName is protection profile Id. input is update Protection Profile Input +func (client ReplicationPoliciesClient) Update(policyName string, input UpdatePolicyInput, cancel <-chan struct{}) (<-chan Policy, <-chan error) { + resultChan := make(chan Policy, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result Policy + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(policyName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationPoliciesClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdatePreparer prepares the Update request. +func (client ReplicationPoliciesClient) UpdatePreparer(policyName string, input UpdatePolicyInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "policyName": autorest.Encode("path", policyName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationPolicies/{policyName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationPoliciesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ReplicationPoliciesClient) UpdateResponder(resp *http.Response) (result Policy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectableitems.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectableitems.go new file mode 100644 index 0000000000..4542935bb0 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectableitems.go @@ -0,0 +1,245 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationProtectableItemsClient is the client for the ReplicationProtectableItems methods of the +// Recoveryservicessiterecovery service. +type ReplicationProtectableItemsClient struct { + ManagementClient +} + +// NewReplicationProtectableItemsClient creates an instance of the ReplicationProtectableItemsClient client. +func NewReplicationProtectableItemsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectableItemsClient { + return NewReplicationProtectableItemsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationProtectableItemsClientWithBaseURI creates an instance of the ReplicationProtectableItemsClient client. +func NewReplicationProtectableItemsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectableItemsClient { + return ReplicationProtectableItemsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Get the operation to get the details of a protectable item. +// +// fabricName is fabric name. protectionContainerName is protection container name. protectableItemName is protectable +// item name. +func (client ReplicationProtectableItemsClient) Get(fabricName string, protectionContainerName string, protectableItemName string) (result ProtectableItem, err error) { + req, err := client.GetPreparer(fabricName, protectionContainerName, protectableItemName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationProtectableItemsClient) GetPreparer(fabricName string, protectionContainerName string, protectableItemName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectableItemName": autorest.Encode("path", protectableItemName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectableItems/{protectableItemName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectableItemsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationProtectableItemsClient) GetResponder(resp *http.Response) (result ProtectableItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationProtectionContainers lists the protectable items in a protection container. +// +// fabricName is fabric name. protectionContainerName is protection container name. +func (client ReplicationProtectableItemsClient) ListByReplicationProtectionContainers(fabricName string, protectionContainerName string) (result ProtectableItemCollection, err error) { + req, err := client.ListByReplicationProtectionContainersPreparer(fabricName, protectionContainerName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationProtectionContainersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "ListByReplicationProtectionContainers", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationProtectionContainersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationProtectionContainersPreparer prepares the ListByReplicationProtectionContainers request. +func (client ReplicationProtectableItemsClient) ListByReplicationProtectionContainersPreparer(fabricName string, protectionContainerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectableItems", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationProtectionContainersSender sends the ListByReplicationProtectionContainers request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectableItemsClient) ListByReplicationProtectionContainersSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationProtectionContainersResponder handles the response to the ListByReplicationProtectionContainers request. The method always +// closes the http.Response Body. +func (client ReplicationProtectableItemsClient) ListByReplicationProtectionContainersResponder(resp *http.Response) (result ProtectableItemCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationProtectionContainersNextResults retrieves the next set of results, if any. +func (client ReplicationProtectableItemsClient) ListByReplicationProtectionContainersNextResults(lastResults ProtectableItemCollection) (result ProtectableItemCollection, err error) { + req, err := lastResults.ProtectableItemCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationProtectionContainersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "ListByReplicationProtectionContainers", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationProtectionContainersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectableItemsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationProtectionContainersComplete gets all elements from the list without paging. +func (client ReplicationProtectableItemsClient) ListByReplicationProtectionContainersComplete(fabricName string, protectionContainerName string, cancel <-chan struct{}) (<-chan ProtectableItem, <-chan error) { + resultChan := make(chan ProtectableItem) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationProtectionContainers(fabricName, protectionContainerName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationProtectionContainersNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotecteditems.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotecteditems.go new file mode 100644 index 0000000000..178768b99e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotecteditems.go @@ -0,0 +1,1536 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ReplicationProtectedItemsClient is the client for the ReplicationProtectedItems methods of the +// Recoveryservicessiterecovery service. +type ReplicationProtectedItemsClient struct { + ManagementClient +} + +// NewReplicationProtectedItemsClient creates an instance of the ReplicationProtectedItemsClient client. +func NewReplicationProtectedItemsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectedItemsClient { + return NewReplicationProtectedItemsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationProtectedItemsClientWithBaseURI creates an instance of the ReplicationProtectedItemsClient client. +func NewReplicationProtectedItemsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectedItemsClient { + return ReplicationProtectedItemsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// ApplyRecoveryPoint the operation to change the recovery point of a failed over replication protected item. This +// method may poll for completion. Polling can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// fabricName is the ARM fabric name. protectionContainerName is the protection container name. +// replicatedProtectedItemName is the replicated protected item's name. applyRecoveryPointInput is the +// ApplyRecoveryPointInput. +func (client ReplicationProtectedItemsClient) ApplyRecoveryPoint(fabricName string, protectionContainerName string, replicatedProtectedItemName string, applyRecoveryPointInput ApplyRecoveryPointInput, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ApplyRecoveryPointPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, applyRecoveryPointInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ApplyRecoveryPoint", nil, "Failure preparing request") + return + } + + resp, err := client.ApplyRecoveryPointSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ApplyRecoveryPoint", resp, "Failure sending request") + return + } + + result, err = client.ApplyRecoveryPointResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ApplyRecoveryPoint", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ApplyRecoveryPointPreparer prepares the ApplyRecoveryPoint request. +func (client ReplicationProtectedItemsClient) ApplyRecoveryPointPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, applyRecoveryPointInput ApplyRecoveryPointInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/applyRecoveryPoint", pathParameters), + autorest.WithJSON(applyRecoveryPointInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ApplyRecoveryPointSender sends the ApplyRecoveryPoint request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) ApplyRecoveryPointSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ApplyRecoveryPointResponder handles the response to the ApplyRecoveryPoint request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) ApplyRecoveryPointResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Create the operation to create an ASR replication protected item (Enable replication). This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is name of the fabric. protectionContainerName is protection container name. replicatedProtectedItemName +// is a name for the replication protected item. input is enable Protection Input. +func (client ReplicationProtectedItemsClient) Create(fabricName string, protectionContainerName string, replicatedProtectedItemName string, input EnableProtectionInput, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(fabricName, protectionContainerName, replicatedProtectedItemName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationProtectedItemsClient) CreatePreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, input EnableProtectionInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) CreateResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to disable replication on a replication protected item. This will also remove the item. This +// method may poll for completion. Polling can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// fabricName is fabric name. protectionContainerName is protection container name. replicatedProtectedItemName is +// replication protected item name. disableProtectionInput is disable protection input. +func (client ReplicationProtectedItemsClient) Delete(fabricName string, protectionContainerName string, replicatedProtectedItemName string, disableProtectionInput DisableProtectionInput, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(fabricName, protectionContainerName, replicatedProtectedItemName, disableProtectionInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationProtectedItemsClient) DeletePreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, disableProtectionInput DisableProtectionInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/remove", pathParameters), + autorest.WithJSON(disableProtectionInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// FailoverCommit operation to commit the failover of the replication protected item. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is unique fabric name. protectionContainerName is protection container name. replicatedProtectedItemName +// is replication protected item name. +func (client ReplicationProtectedItemsClient) FailoverCommit(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.FailoverCommitPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "FailoverCommit", nil, "Failure preparing request") + return + } + + resp, err := client.FailoverCommitSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "FailoverCommit", resp, "Failure sending request") + return + } + + result, err = client.FailoverCommitResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "FailoverCommit", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// FailoverCommitPreparer prepares the FailoverCommit request. +func (client ReplicationProtectedItemsClient) FailoverCommitPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/failoverCommit", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// FailoverCommitSender sends the FailoverCommit request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) FailoverCommitSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// FailoverCommitResponder handles the response to the FailoverCommit request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) FailoverCommitResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the details of an ASR replication protected item. +// +// fabricName is fabric unique name. protectionContainerName is protection container name. replicatedProtectedItemName +// is replication protected item name. +func (client ReplicationProtectedItemsClient) Get(fabricName string, protectionContainerName string, replicatedProtectedItemName string) (result ReplicationProtectedItem, err error) { + req, err := client.GetPreparer(fabricName, protectionContainerName, replicatedProtectedItemName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationProtectedItemsClient) GetPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) GetResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets the list of ASR replication protected items in the vault. +// +// skipToken is the pagination token. Possible values: "FabricId" or "FabricId_CloudId" or null filter is oData filter +// options. +func (client ReplicationProtectedItemsClient) List(skipToken string, filter string) (result ReplicationProtectedItemCollection, err error) { + req, err := client.ListPreparer(skipToken, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationProtectedItemsClient) ListPreparer(skipToken string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(skipToken) > 0 { + queryParameters["skipToken"] = autorest.Encode("query", skipToken) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationProtectedItems", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) ListResponder(resp *http.Response) (result ReplicationProtectedItemCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationProtectedItemsClient) ListNextResults(lastResults ReplicationProtectedItemCollection) (result ReplicationProtectedItemCollection, err error) { + req, err := lastResults.ReplicationProtectedItemCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationProtectedItemsClient) ListComplete(skipToken string, filter string, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List(skipToken, filter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationProtectionContainers gets the list of ASR replication protected items in the protection container. +// +// fabricName is fabric name. protectionContainerName is protection container name. +func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainers(fabricName string, protectionContainerName string) (result ReplicationProtectedItemCollection, err error) { + req, err := client.ListByReplicationProtectionContainersPreparer(fabricName, protectionContainerName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationProtectionContainersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationProtectionContainersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationProtectionContainersPreparer prepares the ListByReplicationProtectionContainers request. +func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersPreparer(fabricName string, protectionContainerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationProtectionContainersSender sends the ListByReplicationProtectionContainers request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationProtectionContainersResponder handles the response to the ListByReplicationProtectionContainers request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersResponder(resp *http.Response) (result ReplicationProtectedItemCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationProtectionContainersNextResults retrieves the next set of results, if any. +func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersNextResults(lastResults ReplicationProtectedItemCollection) (result ReplicationProtectedItemCollection, err error) { + req, err := lastResults.ReplicationProtectedItemCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationProtectionContainersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationProtectionContainersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationProtectionContainersComplete gets all elements from the list without paging. +func (client ReplicationProtectedItemsClient) ListByReplicationProtectionContainersComplete(fabricName string, protectionContainerName string, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationProtectionContainers(fabricName, protectionContainerName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationProtectionContainersNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// PlannedFailover operation to initiate a planned failover of the replication protected item. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is unique fabric name. protectionContainerName is protection container name. replicatedProtectedItemName +// is replication protected item name. failoverInput is disable protection input. +func (client ReplicationProtectedItemsClient) PlannedFailover(fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput PlannedFailoverInput, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.PlannedFailoverPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "PlannedFailover", nil, "Failure preparing request") + return + } + + resp, err := client.PlannedFailoverSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "PlannedFailover", resp, "Failure sending request") + return + } + + result, err = client.PlannedFailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "PlannedFailover", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// PlannedFailoverPreparer prepares the PlannedFailover request. +func (client ReplicationProtectedItemsClient) PlannedFailoverPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput PlannedFailoverInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/plannedFailover", pathParameters), + autorest.WithJSON(failoverInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// PlannedFailoverSender sends the PlannedFailover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) PlannedFailoverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// PlannedFailoverResponder handles the response to the PlannedFailover request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) PlannedFailoverResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Purge the operation to delete or purge a replication protected item. This operation will force delete the +// replication protected item. Use the remove operation on replication protected item to perform a clean disable +// replication for the item. This method may poll for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is fabric name. protectionContainerName is protection container name. replicatedProtectedItemName is +// replication protected item name. +func (client ReplicationProtectedItemsClient) Purge(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.PurgePreparer(fabricName, protectionContainerName, replicatedProtectedItemName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Purge", nil, "Failure preparing request") + return + } + + resp, err := client.PurgeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Purge", resp, "Failure sending request") + return + } + + result, err = client.PurgeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Purge", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// PurgePreparer prepares the Purge request. +func (client ReplicationProtectedItemsClient) PurgePreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// PurgeSender sends the Purge request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) PurgeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) PurgeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// RepairReplication the operation to start resynchronize/repair replication for a replication protected item requiring +// resynchronization. This method may poll for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is the name of the fabric. protectionContainerName is the name of the container. +// replicatedProtectedItemName is the name of the replication protected item. +func (client ReplicationProtectedItemsClient) RepairReplication(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.RepairReplicationPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "RepairReplication", nil, "Failure preparing request") + return + } + + resp, err := client.RepairReplicationSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "RepairReplication", resp, "Failure sending request") + return + } + + result, err = client.RepairReplicationResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "RepairReplication", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// RepairReplicationPreparer prepares the RepairReplication request. +func (client ReplicationProtectedItemsClient) RepairReplicationPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/repairReplication", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// RepairReplicationSender sends the RepairReplication request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) RepairReplicationSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// RepairReplicationResponder handles the response to the RepairReplication request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) RepairReplicationResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Reprotect operation to reprotect or reverse replicate a failed over replication protected item. This method may poll +// for completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is unique fabric name. protectionContainerName is protection container name. replicatedProtectedItemName +// is replication protected item name. rrInput is disable protection input. +func (client ReplicationProtectedItemsClient) Reprotect(fabricName string, protectionContainerName string, replicatedProtectedItemName string, rrInput ReverseReplicationInput, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ReprotectPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, rrInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Reprotect", nil, "Failure preparing request") + return + } + + resp, err := client.ReprotectSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Reprotect", resp, "Failure sending request") + return + } + + result, err = client.ReprotectResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Reprotect", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ReprotectPreparer prepares the Reprotect request. +func (client ReplicationProtectedItemsClient) ReprotectPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, rrInput ReverseReplicationInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/reProtect", pathParameters), + autorest.WithJSON(rrInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ReprotectSender sends the Reprotect request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) ReprotectSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ReprotectResponder handles the response to the Reprotect request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) ReprotectResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// TestFailover operation to perform a test failover of the replication protected item. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is unique fabric name. protectionContainerName is protection container name. replicatedProtectedItemName +// is replication protected item name. failoverInput is test failover input. +func (client ReplicationProtectedItemsClient) TestFailover(fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput TestFailoverInput, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.TestFailoverPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "TestFailover", nil, "Failure preparing request") + return + } + + resp, err := client.TestFailoverSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "TestFailover", resp, "Failure sending request") + return + } + + result, err = client.TestFailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "TestFailover", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// TestFailoverPreparer prepares the TestFailover request. +func (client ReplicationProtectedItemsClient) TestFailoverPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput TestFailoverInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/testFailover", pathParameters), + autorest.WithJSON(failoverInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// TestFailoverSender sends the TestFailover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) TestFailoverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// TestFailoverResponder handles the response to the TestFailover request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) TestFailoverResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// TestFailoverCleanup operation to clean up the test failover of a replication protected item. This method may poll +// for completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is unique fabric name. protectionContainerName is protection container name. replicatedProtectedItemName +// is replication protected item name. cleanupInput is test failover cleanup input. +func (client ReplicationProtectedItemsClient) TestFailoverCleanup(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cleanupInput TestFailoverCleanupInput, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: cleanupInput, + Constraints: []validation.Constraint{{Target: "cleanupInput.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "TestFailoverCleanup") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.TestFailoverCleanupPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, cleanupInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "TestFailoverCleanup", nil, "Failure preparing request") + return + } + + resp, err := client.TestFailoverCleanupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "TestFailoverCleanup", resp, "Failure sending request") + return + } + + result, err = client.TestFailoverCleanupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "TestFailoverCleanup", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// TestFailoverCleanupPreparer prepares the TestFailoverCleanup request. +func (client ReplicationProtectedItemsClient) TestFailoverCleanupPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, cleanupInput TestFailoverCleanupInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/testFailoverCleanup", pathParameters), + autorest.WithJSON(cleanupInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// TestFailoverCleanupSender sends the TestFailoverCleanup request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) TestFailoverCleanupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// TestFailoverCleanupResponder handles the response to the TestFailoverCleanup request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) TestFailoverCleanupResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UnplannedFailover operation to initiate a failover of the replication protected item. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is unique fabric name. protectionContainerName is protection container name. replicatedProtectedItemName +// is replication protected item name. failoverInput is disable protection input. +func (client ReplicationProtectedItemsClient) UnplannedFailover(fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput UnplannedFailoverInput, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UnplannedFailoverPreparer(fabricName, protectionContainerName, replicatedProtectedItemName, failoverInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "UnplannedFailover", nil, "Failure preparing request") + return + } + + resp, err := client.UnplannedFailoverSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "UnplannedFailover", resp, "Failure sending request") + return + } + + result, err = client.UnplannedFailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "UnplannedFailover", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UnplannedFailoverPreparer prepares the UnplannedFailover request. +func (client ReplicationProtectedItemsClient) UnplannedFailoverPreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, failoverInput UnplannedFailoverInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}/unplannedFailover", pathParameters), + autorest.WithJSON(failoverInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UnplannedFailoverSender sends the UnplannedFailover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) UnplannedFailoverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UnplannedFailoverResponder handles the response to the UnplannedFailover request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) UnplannedFailoverResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update the operation to update the recovery settings of an ASR replication protected item. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is fabric name. protectionContainerName is protection container name. replicatedProtectedItemName is +// replication protected item name. updateProtectionInput is update protection input. +func (client ReplicationProtectedItemsClient) Update(fabricName string, protectionContainerName string, replicatedProtectedItemName string, updateProtectionInput UpdateReplicationProtectedItemInput, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(fabricName, protectionContainerName, replicatedProtectedItemName, updateProtectionInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdatePreparer prepares the Update request. +func (client ReplicationProtectedItemsClient) UpdatePreparer(fabricName string, protectionContainerName string, replicatedProtectedItemName string, updateProtectionInput UpdateReplicationProtectedItemInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicatedProtectedItemName": autorest.Encode("path", replicatedProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicatedProtectedItemName}", pathParameters), + autorest.WithJSON(updateProtectionInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) UpdateResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateMobilityService the operation to update(push update) the installed mobility service software on a replication +// protected item to the latest available version. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is the name of the fabric containing the protected item. protectionContainerName is the name of the +// container containing the protected item. replicationProtectedItemName is the name of the protected item on which the +// agent is to be updated. updateMobilityServiceRequest is request to update the mobility service on the protected +// item. +func (client ReplicationProtectedItemsClient) UpdateMobilityService(fabricName string, protectionContainerName string, replicationProtectedItemName string, updateMobilityServiceRequest UpdateMobilityServiceRequest, cancel <-chan struct{}) (<-chan ReplicationProtectedItem, <-chan error) { + resultChan := make(chan ReplicationProtectedItem, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ReplicationProtectedItem + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UpdateMobilityServicePreparer(fabricName, protectionContainerName, replicationProtectedItemName, updateMobilityServiceRequest, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "UpdateMobilityService", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateMobilityServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "UpdateMobilityService", resp, "Failure sending request") + return + } + + result, err = client.UpdateMobilityServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectedItemsClient", "UpdateMobilityService", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdateMobilityServicePreparer prepares the UpdateMobilityService request. +func (client ReplicationProtectedItemsClient) UpdateMobilityServicePreparer(fabricName string, protectionContainerName string, replicationProtectedItemName string, updateMobilityServiceRequest UpdateMobilityServiceRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "replicationProtectedItemName": autorest.Encode("path", replicationProtectedItemName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectedItems/{replicationProtectedItemName}/updateMobilityService", pathParameters), + autorest.WithJSON(updateMobilityServiceRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateMobilityServiceSender sends the UpdateMobilityService request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectedItemsClient) UpdateMobilityServiceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateMobilityServiceResponder handles the response to the UpdateMobilityService request. The method always +// closes the http.Response Body. +func (client ReplicationProtectedItemsClient) UpdateMobilityServiceResponder(resp *http.Response) (result ReplicationProtectedItem, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectioncontainermappings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectioncontainermappings.go new file mode 100644 index 0000000000..39dcbab45a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectioncontainermappings.go @@ -0,0 +1,639 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationProtectionContainerMappingsClient is the client for the ReplicationProtectionContainerMappings methods of +// the Recoveryservicessiterecovery service. +type ReplicationProtectionContainerMappingsClient struct { + ManagementClient +} + +// NewReplicationProtectionContainerMappingsClient creates an instance of the +// ReplicationProtectionContainerMappingsClient client. +func NewReplicationProtectionContainerMappingsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectionContainerMappingsClient { + return NewReplicationProtectionContainerMappingsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationProtectionContainerMappingsClientWithBaseURI creates an instance of the +// ReplicationProtectionContainerMappingsClient client. +func NewReplicationProtectionContainerMappingsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectionContainerMappingsClient { + return ReplicationProtectionContainerMappingsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Create the operation to create a protection container mapping. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// fabricName is fabric name. protectionContainerName is protection container name. mappingName is protection container +// mapping name. creationInput is mapping creation input. +func (client ReplicationProtectionContainerMappingsClient) Create(fabricName string, protectionContainerName string, mappingName string, creationInput CreateProtectionContainerMappingInput, cancel <-chan struct{}) (<-chan ProtectionContainerMapping, <-chan error) { + resultChan := make(chan ProtectionContainerMapping, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ProtectionContainerMapping + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(fabricName, protectionContainerName, mappingName, creationInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationProtectionContainerMappingsClient) CreatePreparer(fabricName string, protectionContainerName string, mappingName string, creationInput CreateProtectionContainerMappingInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "mappingName": autorest.Encode("path", mappingName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings/{mappingName}", pathParameters), + autorest.WithJSON(creationInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainerMappingsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainerMappingsClient) CreateResponder(resp *http.Response) (result ProtectionContainerMapping, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete or remove a protection container mapping. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// fabricName is fabric name. protectionContainerName is protection container name. mappingName is protection container +// mapping name. removalInput is removal input. +func (client ReplicationProtectionContainerMappingsClient) Delete(fabricName string, protectionContainerName string, mappingName string, removalInput RemoveProtectionContainerMappingInput, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(fabricName, protectionContainerName, mappingName, removalInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationProtectionContainerMappingsClient) DeletePreparer(fabricName string, protectionContainerName string, mappingName string, removalInput RemoveProtectionContainerMappingInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "mappingName": autorest.Encode("path", mappingName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings/{mappingName}/remove", pathParameters), + autorest.WithJSON(removalInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainerMappingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainerMappingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of a protection container mapping. +// +// fabricName is fabric name. protectionContainerName is protection container name. mappingName is protection Container +// mapping name. +func (client ReplicationProtectionContainerMappingsClient) Get(fabricName string, protectionContainerName string, mappingName string) (result ProtectionContainerMapping, err error) { + req, err := client.GetPreparer(fabricName, protectionContainerName, mappingName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationProtectionContainerMappingsClient) GetPreparer(fabricName string, protectionContainerName string, mappingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "mappingName": autorest.Encode("path", mappingName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings/{mappingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainerMappingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainerMappingsClient) GetResponder(resp *http.Response) (result ProtectionContainerMapping, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the protection container mappings in the vault. +func (client ReplicationProtectionContainerMappingsClient) List() (result ProtectionContainerMappingCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationProtectionContainerMappingsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationProtectionContainerMappings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainerMappingsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainerMappingsClient) ListResponder(resp *http.Response) (result ProtectionContainerMappingCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationProtectionContainerMappingsClient) ListNextResults(lastResults ProtectionContainerMappingCollection) (result ProtectionContainerMappingCollection, err error) { + req, err := lastResults.ProtectionContainerMappingCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationProtectionContainerMappingsClient) ListComplete(cancel <-chan struct{}) (<-chan ProtectionContainerMapping, <-chan error) { + resultChan := make(chan ProtectionContainerMapping) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationProtectionContainers lists the protection container mappings for a protection container. +// +// fabricName is fabric name. protectionContainerName is protection container name. +func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainers(fabricName string, protectionContainerName string) (result ProtectionContainerMappingCollection, err error) { + req, err := client.ListByReplicationProtectionContainersPreparer(fabricName, protectionContainerName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationProtectionContainersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationProtectionContainersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationProtectionContainersPreparer prepares the ListByReplicationProtectionContainers request. +func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersPreparer(fabricName string, protectionContainerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationProtectionContainersSender sends the ListByReplicationProtectionContainers request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationProtectionContainersResponder handles the response to the ListByReplicationProtectionContainers request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersResponder(resp *http.Response) (result ProtectionContainerMappingCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationProtectionContainersNextResults retrieves the next set of results, if any. +func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersNextResults(lastResults ProtectionContainerMappingCollection) (result ProtectionContainerMappingCollection, err error) { + req, err := lastResults.ProtectionContainerMappingCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationProtectionContainersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationProtectionContainersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "ListByReplicationProtectionContainers", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationProtectionContainersComplete gets all elements from the list without paging. +func (client ReplicationProtectionContainerMappingsClient) ListByReplicationProtectionContainersComplete(fabricName string, protectionContainerName string, cancel <-chan struct{}) (<-chan ProtectionContainerMapping, <-chan error) { + resultChan := make(chan ProtectionContainerMapping) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationProtectionContainers(fabricName, protectionContainerName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationProtectionContainersNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Purge the operation to purge(force delete) a protection container mapping This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// fabricName is fabric name. protectionContainerName is protection container name. mappingName is protection container +// mapping name. +func (client ReplicationProtectionContainerMappingsClient) Purge(fabricName string, protectionContainerName string, mappingName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.PurgePreparer(fabricName, protectionContainerName, mappingName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Purge", nil, "Failure preparing request") + return + } + + resp, err := client.PurgeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Purge", resp, "Failure sending request") + return + } + + result, err = client.PurgeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainerMappingsClient", "Purge", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// PurgePreparer prepares the Purge request. +func (client ReplicationProtectionContainerMappingsClient) PurgePreparer(fabricName string, protectionContainerName string, mappingName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "mappingName": autorest.Encode("path", mappingName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/replicationProtectionContainerMappings/{mappingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// PurgeSender sends the Purge request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainerMappingsClient) PurgeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainerMappingsClient) PurgeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectioncontainers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectioncontainers.go new file mode 100644 index 0000000000..2d52e9ef39 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationprotectioncontainers.go @@ -0,0 +1,717 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationProtectionContainersClient is the client for the ReplicationProtectionContainers methods of the +// Recoveryservicessiterecovery service. +type ReplicationProtectionContainersClient struct { + ManagementClient +} + +// NewReplicationProtectionContainersClient creates an instance of the ReplicationProtectionContainersClient client. +func NewReplicationProtectionContainersClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectionContainersClient { + return NewReplicationProtectionContainersClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationProtectionContainersClientWithBaseURI creates an instance of the ReplicationProtectionContainersClient +// client. +func NewReplicationProtectionContainersClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationProtectionContainersClient { + return ReplicationProtectionContainersClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Create operation to create a protection container. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is unique fabric ARM name. protectionContainerName is unique protection container ARM name. creationInput +// is creation input. +func (client ReplicationProtectionContainersClient) Create(fabricName string, protectionContainerName string, creationInput CreateProtectionContainerInput, cancel <-chan struct{}) (<-chan ProtectionContainer, <-chan error) { + resultChan := make(chan ProtectionContainer, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ProtectionContainer + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(fabricName, protectionContainerName, creationInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationProtectionContainersClient) CreatePreparer(fabricName string, protectionContainerName string, creationInput CreateProtectionContainerInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}", pathParameters), + autorest.WithJSON(creationInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainersClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainersClient) CreateResponder(resp *http.Response) (result ProtectionContainer, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete operation to remove a protection container. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is unique fabric ARM name. protectionContainerName is unique protection container ARM name. +func (client ReplicationProtectionContainersClient) Delete(fabricName string, protectionContainerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(fabricName, protectionContainerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationProtectionContainersClient) DeletePreparer(fabricName string, protectionContainerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/remove", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DiscoverProtectableItem the operation to a add a protectable item to a protection container(Add physical server.) +// This method may poll for completion. Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is the name of the fabric. protectionContainerName is the name of the protection container. +// discoverProtectableItemRequest is the request object to add a protectable item. +func (client ReplicationProtectionContainersClient) DiscoverProtectableItem(fabricName string, protectionContainerName string, discoverProtectableItemRequest DiscoverProtectableItemRequest, cancel <-chan struct{}) (<-chan ProtectionContainer, <-chan error) { + resultChan := make(chan ProtectionContainer, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ProtectionContainer + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DiscoverProtectableItemPreparer(fabricName, protectionContainerName, discoverProtectableItemRequest, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "DiscoverProtectableItem", nil, "Failure preparing request") + return + } + + resp, err := client.DiscoverProtectableItemSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "DiscoverProtectableItem", resp, "Failure sending request") + return + } + + result, err = client.DiscoverProtectableItemResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "DiscoverProtectableItem", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DiscoverProtectableItemPreparer prepares the DiscoverProtectableItem request. +func (client ReplicationProtectionContainersClient) DiscoverProtectableItemPreparer(fabricName string, protectionContainerName string, discoverProtectableItemRequest DiscoverProtectableItemRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/discoverProtectableItem", pathParameters), + autorest.WithJSON(discoverProtectableItemRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DiscoverProtectableItemSender sends the DiscoverProtectableItem request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainersClient) DiscoverProtectableItemSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DiscoverProtectableItemResponder handles the response to the DiscoverProtectableItem request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainersClient) DiscoverProtectableItemResponder(resp *http.Response) (result ProtectionContainer, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the details of a protection container. +// +// fabricName is fabric name. protectionContainerName is protection container name. +func (client ReplicationProtectionContainersClient) Get(fabricName string, protectionContainerName string) (result ProtectionContainer, err error) { + req, err := client.GetPreparer(fabricName, protectionContainerName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationProtectionContainersClient) GetPreparer(fabricName string, protectionContainerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainersClient) GetResponder(resp *http.Response) (result ProtectionContainer, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the protection containers in a vault. +func (client ReplicationProtectionContainersClient) List() (result ProtectionContainerCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationProtectionContainersClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationProtectionContainers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainersClient) ListResponder(resp *http.Response) (result ProtectionContainerCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationProtectionContainersClient) ListNextResults(lastResults ProtectionContainerCollection) (result ProtectionContainerCollection, err error) { + req, err := lastResults.ProtectionContainerCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationProtectionContainersClient) ListComplete(cancel <-chan struct{}) (<-chan ProtectionContainer, <-chan error) { + resultChan := make(chan ProtectionContainer) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationFabrics lists the protection containers in the specified fabric. +// +// fabricName is fabric name. +func (client ReplicationProtectionContainersClient) ListByReplicationFabrics(fabricName string) (result ProtectionContainerCollection, err error) { + req, err := client.ListByReplicationFabricsPreparer(fabricName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "ListByReplicationFabrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "ListByReplicationFabrics", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "ListByReplicationFabrics", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request. +func (client ReplicationProtectionContainersClient) ListByReplicationFabricsPreparer(fabricName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainersClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainersClient) ListByReplicationFabricsResponder(resp *http.Response) (result ProtectionContainerCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationFabricsNextResults retrieves the next set of results, if any. +func (client ReplicationProtectionContainersClient) ListByReplicationFabricsNextResults(lastResults ProtectionContainerCollection) (result ProtectionContainerCollection, err error) { + req, err := lastResults.ProtectionContainerCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "ListByReplicationFabrics", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "ListByReplicationFabrics", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "ListByReplicationFabrics", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationFabricsComplete gets all elements from the list without paging. +func (client ReplicationProtectionContainersClient) ListByReplicationFabricsComplete(fabricName string, cancel <-chan struct{}) (<-chan ProtectionContainer, <-chan error) { + resultChan := make(chan ProtectionContainer) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationFabrics(fabricName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationFabricsNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// SwitchProtection operation to switch protection from one container to another or one replication provider to +// another. This method may poll for completion. Polling can be canceled by passing the cancel channel argument. The +// channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is unique fabric name. protectionContainerName is protection container name. switchInput is switch +// protection input. +func (client ReplicationProtectionContainersClient) SwitchProtection(fabricName string, protectionContainerName string, switchInput SwitchProtectionInput, cancel <-chan struct{}) (<-chan ProtectionContainer, <-chan error) { + resultChan := make(chan ProtectionContainer, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ProtectionContainer + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.SwitchProtectionPreparer(fabricName, protectionContainerName, switchInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "SwitchProtection", nil, "Failure preparing request") + return + } + + resp, err := client.SwitchProtectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "SwitchProtection", resp, "Failure sending request") + return + } + + result, err = client.SwitchProtectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationProtectionContainersClient", "SwitchProtection", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// SwitchProtectionPreparer prepares the SwitchProtection request. +func (client ReplicationProtectionContainersClient) SwitchProtectionPreparer(fabricName string, protectionContainerName string, switchInput SwitchProtectionInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "protectionContainerName": autorest.Encode("path", protectionContainerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationProtectionContainers/{protectionContainerName}/switchprotection", pathParameters), + autorest.WithJSON(switchInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// SwitchProtectionSender sends the SwitchProtection request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationProtectionContainersClient) SwitchProtectionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// SwitchProtectionResponder handles the response to the SwitchProtection request. The method always +// closes the http.Response Body. +func (client ReplicationProtectionContainersClient) SwitchProtectionResponder(resp *http.Response) (result ProtectionContainer, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationrecoveryplans.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationrecoveryplans.go new file mode 100644 index 0000000000..c7cc115062 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationrecoveryplans.go @@ -0,0 +1,1044 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ReplicationRecoveryPlansClient is the client for the ReplicationRecoveryPlans methods of the +// Recoveryservicessiterecovery service. +type ReplicationRecoveryPlansClient struct { + ManagementClient +} + +// NewReplicationRecoveryPlansClient creates an instance of the ReplicationRecoveryPlansClient client. +func NewReplicationRecoveryPlansClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryPlansClient { + return NewReplicationRecoveryPlansClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationRecoveryPlansClientWithBaseURI creates an instance of the ReplicationRecoveryPlansClient client. +func NewReplicationRecoveryPlansClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryPlansClient { + return ReplicationRecoveryPlansClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Create the operation to create a recovery plan. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. input is recovery Plan creation input. +func (client ReplicationRecoveryPlansClient) Create(recoveryPlanName string, input CreateRecoveryPlanInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: input, + Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "input.Properties.PrimaryFabricID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "input.Properties.RecoveryFabricID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "input.Properties.Groups", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Create") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result RecoveryPlan + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(recoveryPlanName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationRecoveryPlansClient) CreatePreparer(recoveryPlanName string, input CreateRecoveryPlanInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) CreateResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a recovery plan. This method may poll for completion. Polling can be canceled by passing the cancel +// channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. +func (client ReplicationRecoveryPlansClient) Delete(recoveryPlanName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(recoveryPlanName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationRecoveryPlansClient) DeletePreparer(recoveryPlanName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// FailoverCommit the operation to commit the fail over of a recovery plan. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. +func (client ReplicationRecoveryPlansClient) FailoverCommit(recoveryPlanName string, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result RecoveryPlan + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.FailoverCommitPreparer(recoveryPlanName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "FailoverCommit", nil, "Failure preparing request") + return + } + + resp, err := client.FailoverCommitSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "FailoverCommit", resp, "Failure sending request") + return + } + + result, err = client.FailoverCommitResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "FailoverCommit", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// FailoverCommitPreparer prepares the FailoverCommit request. +func (client ReplicationRecoveryPlansClient) FailoverCommitPreparer(recoveryPlanName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/failoverCommit", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// FailoverCommitSender sends the FailoverCommit request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) FailoverCommitSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// FailoverCommitResponder handles the response to the FailoverCommit request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) FailoverCommitResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the details of the recovery plan. +// +// recoveryPlanName is name of the recovery plan. +func (client ReplicationRecoveryPlansClient) Get(recoveryPlanName string) (result RecoveryPlan, err error) { + req, err := client.GetPreparer(recoveryPlanName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationRecoveryPlansClient) GetPreparer(recoveryPlanName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) GetResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the recovery plans in the vault. +func (client ReplicationRecoveryPlansClient) List() (result RecoveryPlanCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationRecoveryPlansClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) ListResponder(resp *http.Response) (result RecoveryPlanCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationRecoveryPlansClient) ListNextResults(lastResults RecoveryPlanCollection) (result RecoveryPlanCollection, err error) { + req, err := lastResults.RecoveryPlanCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationRecoveryPlansClient) ListComplete(cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// PlannedFailover the operation to start the planned failover of a recovery plan. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. input is failover input. +func (client ReplicationRecoveryPlansClient) PlannedFailover(recoveryPlanName string, input RecoveryPlanPlannedFailoverInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: input, + Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "PlannedFailover") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result RecoveryPlan + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.PlannedFailoverPreparer(recoveryPlanName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", nil, "Failure preparing request") + return + } + + resp, err := client.PlannedFailoverSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", resp, "Failure sending request") + return + } + + result, err = client.PlannedFailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// PlannedFailoverPreparer prepares the PlannedFailover request. +func (client ReplicationRecoveryPlansClient) PlannedFailoverPreparer(recoveryPlanName string, input RecoveryPlanPlannedFailoverInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/plannedFailover", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// PlannedFailoverSender sends the PlannedFailover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) PlannedFailoverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// PlannedFailoverResponder handles the response to the PlannedFailover request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) PlannedFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Reprotect the operation to reprotect(reverse replicate) a recovery plan. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. +func (client ReplicationRecoveryPlansClient) Reprotect(recoveryPlanName string, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result RecoveryPlan + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ReprotectPreparer(recoveryPlanName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Reprotect", nil, "Failure preparing request") + return + } + + resp, err := client.ReprotectSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Reprotect", resp, "Failure sending request") + return + } + + result, err = client.ReprotectResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Reprotect", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ReprotectPreparer prepares the Reprotect request. +func (client ReplicationRecoveryPlansClient) ReprotectPreparer(recoveryPlanName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/reProtect", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ReprotectSender sends the Reprotect request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) ReprotectSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ReprotectResponder handles the response to the Reprotect request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) ReprotectResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// TestFailover the operation to start the test failover of a recovery plan. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. input is failover input. +func (client ReplicationRecoveryPlansClient) TestFailover(recoveryPlanName string, input RecoveryPlanTestFailoverInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: input, + Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "input.Properties.NetworkType", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailover") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result RecoveryPlan + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.TestFailoverPreparer(recoveryPlanName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailover", nil, "Failure preparing request") + return + } + + resp, err := client.TestFailoverSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailover", resp, "Failure sending request") + return + } + + result, err = client.TestFailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailover", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// TestFailoverPreparer prepares the TestFailover request. +func (client ReplicationRecoveryPlansClient) TestFailoverPreparer(recoveryPlanName string, input RecoveryPlanTestFailoverInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/testFailover", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// TestFailoverSender sends the TestFailover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) TestFailoverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// TestFailoverResponder handles the response to the TestFailover request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) TestFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// TestFailoverCleanup the operation to cleanup test failover of a recovery plan. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. input is test failover cleanup input. +func (client ReplicationRecoveryPlansClient) TestFailoverCleanup(recoveryPlanName string, input RecoveryPlanTestFailoverCleanupInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: input, + Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result RecoveryPlan + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.TestFailoverCleanupPreparer(recoveryPlanName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", nil, "Failure preparing request") + return + } + + resp, err := client.TestFailoverCleanupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", resp, "Failure sending request") + return + } + + result, err = client.TestFailoverCleanupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// TestFailoverCleanupPreparer prepares the TestFailoverCleanup request. +func (client ReplicationRecoveryPlansClient) TestFailoverCleanupPreparer(recoveryPlanName string, input RecoveryPlanTestFailoverCleanupInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/testFailoverCleanup", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// TestFailoverCleanupSender sends the TestFailoverCleanup request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) TestFailoverCleanupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// TestFailoverCleanupResponder handles the response to the TestFailoverCleanup request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) TestFailoverCleanupResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UnplannedFailover the operation to start the failover of a recovery plan. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. input is failover input. +func (client ReplicationRecoveryPlansClient) UnplannedFailover(recoveryPlanName string, input RecoveryPlanUnplannedFailoverInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: input, + Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result RecoveryPlan + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UnplannedFailoverPreparer(recoveryPlanName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", nil, "Failure preparing request") + return + } + + resp, err := client.UnplannedFailoverSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", resp, "Failure sending request") + return + } + + result, err = client.UnplannedFailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UnplannedFailoverPreparer prepares the UnplannedFailover request. +func (client ReplicationRecoveryPlansClient) UnplannedFailoverPreparer(recoveryPlanName string, input RecoveryPlanUnplannedFailoverInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/unplannedFailover", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UnplannedFailoverSender sends the UnplannedFailover request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) UnplannedFailoverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UnplannedFailoverResponder handles the response to the UnplannedFailover request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) UnplannedFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update the operation to update a recovery plan. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// recoveryPlanName is recovery plan name. input is update recovery plan input +func (client ReplicationRecoveryPlansClient) Update(recoveryPlanName string, input UpdateRecoveryPlanInput, cancel <-chan struct{}) (<-chan RecoveryPlan, <-chan error) { + resultChan := make(chan RecoveryPlan, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result RecoveryPlan + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(recoveryPlanName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryPlansClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdatePreparer prepares the Update request. +func (client ReplicationRecoveryPlansClient) UpdatePreparer(recoveryPlanName string, input UpdateRecoveryPlanInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "recoveryPlanName": autorest.Encode("path", recoveryPlanName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryPlansClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryPlansClient) UpdateResponder(resp *http.Response) (result RecoveryPlan, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationrecoveryservicesproviders.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationrecoveryservicesproviders.go new file mode 100644 index 0000000000..c6c73402db --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationrecoveryservicesproviders.go @@ -0,0 +1,626 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationRecoveryServicesProvidersClient is the client for the ReplicationRecoveryServicesProviders methods of the +// Recoveryservicessiterecovery service. +type ReplicationRecoveryServicesProvidersClient struct { + ManagementClient +} + +// NewReplicationRecoveryServicesProvidersClient creates an instance of the ReplicationRecoveryServicesProvidersClient +// client. +func NewReplicationRecoveryServicesProvidersClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryServicesProvidersClient { + return NewReplicationRecoveryServicesProvidersClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationRecoveryServicesProvidersClientWithBaseURI creates an instance of the +// ReplicationRecoveryServicesProvidersClient client. +func NewReplicationRecoveryServicesProvidersClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryServicesProvidersClient { + return ReplicationRecoveryServicesProvidersClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Delete the operation to removes/delete(unregister) a recovery services provider from the vault This method may poll +// for completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is fabric name. providerName is recovery services provider name. +func (client ReplicationRecoveryServicesProvidersClient) Delete(fabricName string, providerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(fabricName, providerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationRecoveryServicesProvidersClient) DeletePreparer(fabricName string, providerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders/{providerName}/remove", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryServicesProvidersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryServicesProvidersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of registered recovery services provider. +// +// fabricName is fabric name. providerName is recovery services provider name +func (client ReplicationRecoveryServicesProvidersClient) Get(fabricName string, providerName string) (result RecoveryServicesProvider, err error) { + req, err := client.GetPreparer(fabricName, providerName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationRecoveryServicesProvidersClient) GetPreparer(fabricName string, providerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders/{providerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryServicesProvidersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryServicesProvidersClient) GetResponder(resp *http.Response) (result RecoveryServicesProvider, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the registered recovery services providers in the vault +func (client ReplicationRecoveryServicesProvidersClient) List() (result RecoveryServicesProviderCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationRecoveryServicesProvidersClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryServicesProviders", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryServicesProvidersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryServicesProvidersClient) ListResponder(resp *http.Response) (result RecoveryServicesProviderCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationRecoveryServicesProvidersClient) ListNextResults(lastResults RecoveryServicesProviderCollection) (result RecoveryServicesProviderCollection, err error) { + req, err := lastResults.RecoveryServicesProviderCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationRecoveryServicesProvidersClient) ListComplete(cancel <-chan struct{}) (<-chan RecoveryServicesProvider, <-chan error) { + resultChan := make(chan RecoveryServicesProvider) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationFabrics lists the registered recovery services providers for the specified fabric. +// +// fabricName is fabric name +func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabrics(fabricName string) (result RecoveryServicesProviderCollection, err error) { + req, err := client.ListByReplicationFabricsPreparer(fabricName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request. +func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsPreparer(fabricName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsResponder(resp *http.Response) (result RecoveryServicesProviderCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationFabricsNextResults retrieves the next set of results, if any. +func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsNextResults(lastResults RecoveryServicesProviderCollection) (result RecoveryServicesProviderCollection, err error) { + req, err := lastResults.RecoveryServicesProviderCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "ListByReplicationFabrics", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationFabricsComplete gets all elements from the list without paging. +func (client ReplicationRecoveryServicesProvidersClient) ListByReplicationFabricsComplete(fabricName string, cancel <-chan struct{}) (<-chan RecoveryServicesProvider, <-chan error) { + resultChan := make(chan RecoveryServicesProvider) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationFabrics(fabricName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationFabricsNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Purge the operation to purge(force delete) a recovery services provider from the vault. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is fabric name. providerName is recovery services provider name. +func (client ReplicationRecoveryServicesProvidersClient) Purge(fabricName string, providerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.PurgePreparer(fabricName, providerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Purge", nil, "Failure preparing request") + return + } + + resp, err := client.PurgeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Purge", resp, "Failure sending request") + return + } + + result, err = client.PurgeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "Purge", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// PurgePreparer prepares the Purge request. +func (client ReplicationRecoveryServicesProvidersClient) PurgePreparer(fabricName string, providerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders/{providerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// PurgeSender sends the Purge request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryServicesProvidersClient) PurgeSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// PurgeResponder handles the response to the Purge request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryServicesProvidersClient) PurgeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// RefreshProvider the operation to refresh the information from the recovery services provider. This method may poll +// for completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is fabric name. providerName is recovery services provider name. +func (client ReplicationRecoveryServicesProvidersClient) RefreshProvider(fabricName string, providerName string, cancel <-chan struct{}) (<-chan RecoveryServicesProvider, <-chan error) { + resultChan := make(chan RecoveryServicesProvider, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result RecoveryServicesProvider + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.RefreshProviderPreparer(fabricName, providerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "RefreshProvider", nil, "Failure preparing request") + return + } + + resp, err := client.RefreshProviderSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "RefreshProvider", resp, "Failure sending request") + return + } + + result, err = client.RefreshProviderResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationRecoveryServicesProvidersClient", "RefreshProvider", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// RefreshProviderPreparer prepares the RefreshProvider request. +func (client ReplicationRecoveryServicesProvidersClient) RefreshProviderPreparer(fabricName string, providerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "providerName": autorest.Encode("path", providerName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationRecoveryServicesProviders/{providerName}/refreshProvider", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// RefreshProviderSender sends the RefreshProvider request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationRecoveryServicesProvidersClient) RefreshProviderSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// RefreshProviderResponder handles the response to the RefreshProvider request. The method always +// closes the http.Response Body. +func (client ReplicationRecoveryServicesProvidersClient) RefreshProviderResponder(resp *http.Response) (result RecoveryServicesProvider, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationstorageclassificationmappings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationstorageclassificationmappings.go new file mode 100644 index 0000000000..5a02249477 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationstorageclassificationmappings.go @@ -0,0 +1,552 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationStorageClassificationMappingsClient is the client for the ReplicationStorageClassificationMappings +// methods of the Recoveryservicessiterecovery service. +type ReplicationStorageClassificationMappingsClient struct { + ManagementClient +} + +// NewReplicationStorageClassificationMappingsClient creates an instance of the +// ReplicationStorageClassificationMappingsClient client. +func NewReplicationStorageClassificationMappingsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationStorageClassificationMappingsClient { + return NewReplicationStorageClassificationMappingsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationStorageClassificationMappingsClientWithBaseURI creates an instance of the +// ReplicationStorageClassificationMappingsClient client. +func NewReplicationStorageClassificationMappingsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationStorageClassificationMappingsClient { + return ReplicationStorageClassificationMappingsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Create the operation to create a storage classification mapping. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// fabricName is fabric name. storageClassificationName is storage classification name. +// storageClassificationMappingName is storage classification mapping name. pairingInput is pairing input. +func (client ReplicationStorageClassificationMappingsClient) Create(fabricName string, storageClassificationName string, storageClassificationMappingName string, pairingInput StorageClassificationMappingInput, cancel <-chan struct{}) (<-chan StorageClassificationMapping, <-chan error) { + resultChan := make(chan StorageClassificationMapping, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result StorageClassificationMapping + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(fabricName, storageClassificationName, storageClassificationMappingName, pairingInput, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationStorageClassificationMappingsClient) CreatePreparer(fabricName string, storageClassificationName string, storageClassificationMappingName string, pairingInput StorageClassificationMappingInput, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "storageClassificationMappingName": autorest.Encode("path", storageClassificationMappingName), + "storageClassificationName": autorest.Encode("path", storageClassificationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationStorageClassifications/{storageClassificationName}/replicationStorageClassificationMappings/{storageClassificationMappingName}", pathParameters), + autorest.WithJSON(pairingInput), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationStorageClassificationMappingsClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationStorageClassificationMappingsClient) CreateResponder(resp *http.Response) (result StorageClassificationMapping, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete a storage classification mapping. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// fabricName is fabric name. storageClassificationName is storage classification name. +// storageClassificationMappingName is storage classification mapping name. +func (client ReplicationStorageClassificationMappingsClient) Delete(fabricName string, storageClassificationName string, storageClassificationMappingName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(fabricName, storageClassificationName, storageClassificationMappingName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationStorageClassificationMappingsClient) DeletePreparer(fabricName string, storageClassificationName string, storageClassificationMappingName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "storageClassificationMappingName": autorest.Encode("path", storageClassificationMappingName), + "storageClassificationName": autorest.Encode("path", storageClassificationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationStorageClassifications/{storageClassificationName}/replicationStorageClassificationMappings/{storageClassificationMappingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationStorageClassificationMappingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationStorageClassificationMappingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the specified storage classification mapping. +// +// fabricName is fabric name. storageClassificationName is storage classification name. +// storageClassificationMappingName is storage classification mapping name. +func (client ReplicationStorageClassificationMappingsClient) Get(fabricName string, storageClassificationName string, storageClassificationMappingName string) (result StorageClassificationMapping, err error) { + req, err := client.GetPreparer(fabricName, storageClassificationName, storageClassificationMappingName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationStorageClassificationMappingsClient) GetPreparer(fabricName string, storageClassificationName string, storageClassificationMappingName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "storageClassificationMappingName": autorest.Encode("path", storageClassificationMappingName), + "storageClassificationName": autorest.Encode("path", storageClassificationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationStorageClassifications/{storageClassificationName}/replicationStorageClassificationMappings/{storageClassificationMappingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationStorageClassificationMappingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationStorageClassificationMappingsClient) GetResponder(resp *http.Response) (result StorageClassificationMapping, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the storage classification mappings in the vault. +func (client ReplicationStorageClassificationMappingsClient) List() (result StorageClassificationMappingCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationStorageClassificationMappingsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationStorageClassificationMappings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationStorageClassificationMappingsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationStorageClassificationMappingsClient) ListResponder(resp *http.Response) (result StorageClassificationMappingCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationStorageClassificationMappingsClient) ListNextResults(lastResults StorageClassificationMappingCollection) (result StorageClassificationMappingCollection, err error) { + req, err := lastResults.StorageClassificationMappingCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationStorageClassificationMappingsClient) ListComplete(cancel <-chan struct{}) (<-chan StorageClassificationMapping, <-chan error) { + resultChan := make(chan StorageClassificationMapping) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationStorageClassifications lists the storage classification mappings for the fabric. +// +// fabricName is fabric name. storageClassificationName is storage classfication name. +func (client ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassifications(fabricName string, storageClassificationName string) (result StorageClassificationMappingCollection, err error) { + req, err := client.ListByReplicationStorageClassificationsPreparer(fabricName, storageClassificationName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "ListByReplicationStorageClassifications", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationStorageClassificationsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "ListByReplicationStorageClassifications", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationStorageClassificationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "ListByReplicationStorageClassifications", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationStorageClassificationsPreparer prepares the ListByReplicationStorageClassifications request. +func (client ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsPreparer(fabricName string, storageClassificationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "storageClassificationName": autorest.Encode("path", storageClassificationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationStorageClassifications/{storageClassificationName}/replicationStorageClassificationMappings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationStorageClassificationsSender sends the ListByReplicationStorageClassifications request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationStorageClassificationsResponder handles the response to the ListByReplicationStorageClassifications request. The method always +// closes the http.Response Body. +func (client ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsResponder(resp *http.Response) (result StorageClassificationMappingCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationStorageClassificationsNextResults retrieves the next set of results, if any. +func (client ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsNextResults(lastResults StorageClassificationMappingCollection) (result StorageClassificationMappingCollection, err error) { + req, err := lastResults.StorageClassificationMappingCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "ListByReplicationStorageClassifications", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationStorageClassificationsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "ListByReplicationStorageClassifications", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationStorageClassificationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationMappingsClient", "ListByReplicationStorageClassifications", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationStorageClassificationsComplete gets all elements from the list without paging. +func (client ReplicationStorageClassificationMappingsClient) ListByReplicationStorageClassificationsComplete(fabricName string, storageClassificationName string, cancel <-chan struct{}) (<-chan StorageClassificationMapping, <-chan error) { + resultChan := make(chan StorageClassificationMapping) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationStorageClassifications(fabricName, storageClassificationName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationStorageClassificationsNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationstorageclassifications.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationstorageclassifications.go new file mode 100644 index 0000000000..58a8340cb2 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationstorageclassifications.go @@ -0,0 +1,376 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationStorageClassificationsClient is the client for the ReplicationStorageClassifications methods of the +// Recoveryservicessiterecovery service. +type ReplicationStorageClassificationsClient struct { + ManagementClient +} + +// NewReplicationStorageClassificationsClient creates an instance of the ReplicationStorageClassificationsClient +// client. +func NewReplicationStorageClassificationsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationStorageClassificationsClient { + return NewReplicationStorageClassificationsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationStorageClassificationsClientWithBaseURI creates an instance of the +// ReplicationStorageClassificationsClient client. +func NewReplicationStorageClassificationsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationStorageClassificationsClient { + return ReplicationStorageClassificationsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Get gets the details of the specified storage classification. +// +// fabricName is fabric name. storageClassificationName is storage classification name. +func (client ReplicationStorageClassificationsClient) Get(fabricName string, storageClassificationName string) (result StorageClassification, err error) { + req, err := client.GetPreparer(fabricName, storageClassificationName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationStorageClassificationsClient) GetPreparer(fabricName string, storageClassificationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "storageClassificationName": autorest.Encode("path", storageClassificationName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationStorageClassifications/{storageClassificationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationStorageClassificationsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationStorageClassificationsClient) GetResponder(resp *http.Response) (result StorageClassification, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the storage classifications in the vault. +func (client ReplicationStorageClassificationsClient) List() (result StorageClassificationCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationStorageClassificationsClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationStorageClassifications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationStorageClassificationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationStorageClassificationsClient) ListResponder(resp *http.Response) (result StorageClassificationCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationStorageClassificationsClient) ListNextResults(lastResults StorageClassificationCollection) (result StorageClassificationCollection, err error) { + req, err := lastResults.StorageClassificationCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationStorageClassificationsClient) ListComplete(cancel <-chan struct{}) (<-chan StorageClassification, <-chan error) { + resultChan := make(chan StorageClassification) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationFabrics lists the storage classifications available in the specified fabric. +// +// fabricName is site name of interest. +func (client ReplicationStorageClassificationsClient) ListByReplicationFabrics(fabricName string) (result StorageClassificationCollection, err error) { + req, err := client.ListByReplicationFabricsPreparer(fabricName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request. +func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsPreparer(fabricName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationStorageClassifications", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always +// closes the http.Response Body. +func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsResponder(resp *http.Response) (result StorageClassificationCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationFabricsNextResults retrieves the next set of results, if any. +func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsNextResults(lastResults StorageClassificationCollection) (result StorageClassificationCollection, err error) { + req, err := lastResults.StorageClassificationCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationStorageClassificationsClient", "ListByReplicationFabrics", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationFabricsComplete gets all elements from the list without paging. +func (client ReplicationStorageClassificationsClient) ListByReplicationFabricsComplete(fabricName string, cancel <-chan struct{}) (<-chan StorageClassification, <-chan error) { + resultChan := make(chan StorageClassification) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationFabrics(fabricName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationFabricsNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationvcenters.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationvcenters.go new file mode 100644 index 0000000000..5c73f978cb --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/replicationvcenters.go @@ -0,0 +1,628 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ReplicationvCentersClient is the client for the ReplicationvCenters methods of the Recoveryservicessiterecovery +// service. +type ReplicationvCentersClient struct { + ManagementClient +} + +// NewReplicationvCentersClient creates an instance of the ReplicationvCentersClient client. +func NewReplicationvCentersClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationvCentersClient { + return NewReplicationvCentersClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) +} + +// NewReplicationvCentersClientWithBaseURI creates an instance of the ReplicationvCentersClient client. +func NewReplicationvCentersClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationvCentersClient { + return ReplicationvCentersClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} +} + +// Create the operation to create a vCenter object.. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is fabric name. vCenterName is vCenter name. addVCenterRequest is the input to the add vCenter operation. +func (client ReplicationvCentersClient) Create(fabricName string, vCenterName string, addVCenterRequest AddVCenterRequest, cancel <-chan struct{}) (<-chan VCenter, <-chan error) { + resultChan := make(chan VCenter, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VCenter + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreatePreparer(fabricName, vCenterName, addVCenterRequest, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Create", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreatePreparer prepares the Create request. +func (client ReplicationvCentersClient) CreatePreparer(fabricName string, vCenterName string, addVCenterRequest AddVCenterRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vCenterName": autorest.Encode("path", vCenterName), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationvCenters/{vCenterName}", pathParameters), + autorest.WithJSON(addVCenterRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationvCentersClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ReplicationvCentersClient) CreateResponder(resp *http.Response) (result VCenter, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to remove(unregister) a registered vCenter server from the vault. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// fabricName is fabric name. vCenterName is vCenter name. +func (client ReplicationvCentersClient) Delete(fabricName string, vCenterName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(fabricName, vCenterName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ReplicationvCentersClient) DeletePreparer(fabricName string, vCenterName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vCenterName": autorest.Encode("path", vCenterName), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationvCenters/{vCenterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationvCentersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReplicationvCentersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of a registered vCenter server(Add vCenter server.) +// +// fabricName is fabric name. vCenterName is vCenter name. +func (client ReplicationvCentersClient) Get(fabricName string, vCenterName string) (result VCenter, err error) { + req, err := client.GetPreparer(fabricName, vCenterName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReplicationvCentersClient) GetPreparer(fabricName string, vCenterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vCenterName": autorest.Encode("path", vCenterName), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationvCenters/{vCenterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationvCentersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReplicationvCentersClient) GetResponder(resp *http.Response) (result VCenter, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the vCenter servers registered in the vault. +func (client ReplicationvCentersClient) List() (result VCenterCollection, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReplicationvCentersClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationvCenters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationvCentersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReplicationvCentersClient) ListResponder(resp *http.Response) (result VCenterCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client ReplicationvCentersClient) ListNextResults(lastResults VCenterCollection) (result VCenterCollection, err error) { + req, err := lastResults.VCenterCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client ReplicationvCentersClient) ListComplete(cancel <-chan struct{}) (<-chan VCenter, <-chan error) { + resultChan := make(chan VCenter) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByReplicationFabrics lists the vCenter servers registered in a fabric. +// +// fabricName is fabric name. +func (client ReplicationvCentersClient) ListByReplicationFabrics(fabricName string) (result VCenterCollection, err error) { + req, err := client.ListByReplicationFabricsPreparer(fabricName) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", resp, "Failure sending request") + return + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", resp, "Failure responding to request") + } + + return +} + +// ListByReplicationFabricsPreparer prepares the ListByReplicationFabrics request. +func (client ReplicationvCentersClient) ListByReplicationFabricsPreparer(fabricName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationvCenters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByReplicationFabricsSender sends the ListByReplicationFabrics request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationvCentersClient) ListByReplicationFabricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByReplicationFabricsResponder handles the response to the ListByReplicationFabrics request. The method always +// closes the http.Response Body. +func (client ReplicationvCentersClient) ListByReplicationFabricsResponder(resp *http.Response) (result VCenterCollection, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByReplicationFabricsNextResults retrieves the next set of results, if any. +func (client ReplicationvCentersClient) ListByReplicationFabricsNextResults(lastResults VCenterCollection) (result VCenterCollection, err error) { + req, err := lastResults.VCenterCollectionPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByReplicationFabricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", resp, "Failure sending next results request") + } + + result, err = client.ListByReplicationFabricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "ListByReplicationFabrics", resp, "Failure responding to next results request") + } + + return +} + +// ListByReplicationFabricsComplete gets all elements from the list without paging. +func (client ReplicationvCentersClient) ListByReplicationFabricsComplete(fabricName string, cancel <-chan struct{}) (<-chan VCenter, <-chan error) { + resultChan := make(chan VCenter) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByReplicationFabrics(fabricName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByReplicationFabricsNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Update the operation to update a registered vCenter. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP requests. +// +// fabricName is fabric name. vCenterName is vCeneter name updateVCenterRequest is the input to the update vCenter +// operation. +func (client ReplicationvCentersClient) Update(fabricName string, vCenterName string, updateVCenterRequest UpdateVCenterRequest, cancel <-chan struct{}) (<-chan VCenter, <-chan error) { + resultChan := make(chan VCenter, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result VCenter + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UpdatePreparer(fabricName, vCenterName, updateVCenterRequest, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "recoveryservicessiterecovery.ReplicationvCentersClient", "Update", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdatePreparer prepares the Update request. +func (client ReplicationvCentersClient) UpdatePreparer(fabricName string, vCenterName string, updateVCenterRequest UpdateVCenterRequest, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fabricName": autorest.Encode("path", fabricName), + "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), + "resourceName": autorest.Encode("path", client.ResourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vCenterName": autorest.Encode("path", vCenterName), + } + + const APIVersion = "2016-08-10" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/replicationvCenters/{vCenterName}", pathParameters), + autorest.WithJSON(updateVCenterRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ReplicationvCentersClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ReplicationvCentersClient) UpdateResponder(resp *http.Response) (result VCenter, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/version.go new file mode 100644 index 0000000000..b421bc269c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/recoveryservicessiterecovery/version.go @@ -0,0 +1,28 @@ +package recoveryservicessiterecovery + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.1.0-beta arm-recoveryservicessiterecovery/2016-08-10" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.1.0-beta" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go index c5a6a48ad7..68fa93ef42 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/redis/version.go @@ -20,10 +20,10 @@ package redis // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-redis/2016-04-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-redis/2016-04-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/version.go index 0dae982aa2..c913811b31 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/relay/version.go @@ -20,10 +20,10 @@ package relay // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-relay/2016-07-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-relay/2016-07-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/version.go index fe1838892a..9e41cbb5d7 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resourcehealth/version.go @@ -20,10 +20,10 @@ package resourcehealth // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-resourcehealth/2015-01-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-resourcehealth/2015-01-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/version.go index 5dde5a3b31..921d5f8d4d 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/features/version.go @@ -20,10 +20,10 @@ package features // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-features/2015-12-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-features/2015-12-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/version.go index 6ef40f955c..d46fa07331 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/links/version.go @@ -20,10 +20,10 @@ package links // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-links/2016-09-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-links/2016-09-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/version.go index 1647dac6ac..e091adb172 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/locks/version.go @@ -20,10 +20,10 @@ package locks // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-locks/2016-09-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-locks/2016-09-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/appliancedefinitions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/appliancedefinitions.go new file mode 100644 index 0000000000..216ce25c5d --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/appliancedefinitions.go @@ -0,0 +1,720 @@ +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ApplianceDefinitionsClient is the ARM managed applications (appliances) +type ApplianceDefinitionsClient struct { + ManagementClient +} + +// NewApplianceDefinitionsClient creates an instance of the +// ApplianceDefinitionsClient client. +func NewApplianceDefinitionsClient(subscriptionID string) ApplianceDefinitionsClient { + return NewApplianceDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewApplianceDefinitionsClientWithBaseURI creates an instance of the +// ApplianceDefinitionsClient client. +func NewApplianceDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) ApplianceDefinitionsClient { + return ApplianceDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new appliance definition. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. applianceDefinitionName is the name of the appliance +// definition. parameters is parameters supplied to the create or update an +// appliance definition. +func (client ApplianceDefinitionsClient) CreateOrUpdate(resourceGroupName string, applianceDefinitionName string, parameters ApplianceDefinition, cancel <-chan struct{}) (<-chan ApplianceDefinition, <-chan error) { + resultChan := make(chan ApplianceDefinition, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: applianceDefinitionName, + Constraints: []validation.Constraint{{Target: "applianceDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applianceDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplianceDefinitionProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ApplianceDefinitionProperties.Authorizations", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ApplianceDefinitionProperties.PackageFileURI", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "managedapplications.ApplianceDefinitionsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ApplianceDefinition + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, applianceDefinitionName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ApplianceDefinitionsClient) CreateOrUpdatePreparer(resourceGroupName string, applianceDefinitionName string, parameters ApplianceDefinition, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceDefinitionName": autorest.Encode("path", applianceDefinitionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applianceDefinitions/{applianceDefinitionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ApplianceDefinitionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ApplianceDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result ApplianceDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateByID creates a new appliance definition. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// applianceDefinitionID is the fully qualified ID of the appliance definition, +// including the appliance name and the appliance definition resource type. Use +// the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applianceDefinitions/{applianceDefinition-name} +// parameters is parameters supplied to the create or update an appliance +// definition. +func (client ApplianceDefinitionsClient) CreateOrUpdateByID(applianceDefinitionID string, parameters ApplianceDefinition, cancel <-chan struct{}) (<-chan ApplianceDefinition, <-chan error) { + resultChan := make(chan ApplianceDefinition, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplianceDefinitionProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ApplianceDefinitionProperties.Authorizations", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ApplianceDefinitionProperties.PackageFileURI", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "managedapplications.ApplianceDefinitionsClient", "CreateOrUpdateByID") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result ApplianceDefinition + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdateByIDPreparer(applianceDefinitionID, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "CreateOrUpdateByID", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "CreateOrUpdateByID", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "CreateOrUpdateByID", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request. +func (client ApplianceDefinitionsClient) CreateOrUpdateByIDPreparer(applianceDefinitionID string, parameters ApplianceDefinition, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceDefinitionId": applianceDefinitionID, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applianceDefinitionId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplianceDefinitionsClient) CreateOrUpdateByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always +// closes the http.Response Body. +func (client ApplianceDefinitionsClient) CreateOrUpdateByIDResponder(resp *http.Response) (result ApplianceDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the appliance definition. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. applianceDefinitionName is the name of the appliance definition +// to delete. +func (client ApplianceDefinitionsClient) Delete(resourceGroupName string, applianceDefinitionName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: applianceDefinitionName, + Constraints: []validation.Constraint{{Target: "applianceDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applianceDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "managedapplications.ApplianceDefinitionsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, applianceDefinitionName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client ApplianceDefinitionsClient) DeletePreparer(resourceGroupName string, applianceDefinitionName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceDefinitionName": autorest.Encode("path", applianceDefinitionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applianceDefinitions/{applianceDefinitionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ApplianceDefinitionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ApplianceDefinitionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByID deletes the appliance definition. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// applianceDefinitionID is the fully qualified ID of the appliance definition, +// including the appliance name and the appliance definition resource type. Use +// the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applianceDefinitions/{applianceDefinition-name} +func (client ApplianceDefinitionsClient) DeleteByID(applianceDefinitionID string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeleteByIDPreparer(applianceDefinitionID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "DeleteByID", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByIDSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "DeleteByID", resp, "Failure sending request") + return + } + + result, err = client.DeleteByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "DeleteByID", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeleteByIDPreparer prepares the DeleteByID request. +func (client ApplianceDefinitionsClient) DeleteByIDPreparer(applianceDefinitionID string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceDefinitionId": applianceDefinitionID, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applianceDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteByIDSender sends the DeleteByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplianceDefinitionsClient) DeleteByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteByIDResponder handles the response to the DeleteByID request. The method always +// closes the http.Response Body. +func (client ApplianceDefinitionsClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the appliance definition. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. applianceDefinitionName is the name of the appliance +// definition. +func (client ApplianceDefinitionsClient) Get(resourceGroupName string, applianceDefinitionName string) (result ApplianceDefinition, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: applianceDefinitionName, + Constraints: []validation.Constraint{{Target: "applianceDefinitionName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applianceDefinitionName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "managedapplications.ApplianceDefinitionsClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, applianceDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ApplianceDefinitionsClient) GetPreparer(resourceGroupName string, applianceDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceDefinitionName": autorest.Encode("path", applianceDefinitionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applianceDefinitions/{applianceDefinitionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ApplianceDefinitionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ApplianceDefinitionsClient) GetResponder(resp *http.Response) (result ApplianceDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID gets the appliance definition. +// +// applianceDefinitionID is the fully qualified ID of the appliance definition, +// including the appliance name and the appliance definition resource type. Use +// the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/applianceDefinitions/{applianceDefinition-name} +func (client ApplianceDefinitionsClient) GetByID(applianceDefinitionID string) (result ApplianceDefinition, err error) { + req, err := client.GetByIDPreparer(applianceDefinitionID) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client ApplianceDefinitionsClient) GetByIDPreparer(applianceDefinitionID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceDefinitionId": applianceDefinitionID, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applianceDefinitionId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client ApplianceDefinitionsClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client ApplianceDefinitionsClient) GetByIDResponder(resp *http.Response) (result ApplianceDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists the appliance definitions in a resource group. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. +func (client ApplianceDefinitionsClient) ListByResourceGroup(resourceGroupName string) (result ApplianceDefinitionListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "managedapplications.ApplianceDefinitionsClient", "ListByResourceGroup") + } + + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ApplianceDefinitionsClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/applianceDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ApplianceDefinitionsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ApplianceDefinitionsClient) ListByResourceGroupResponder(resp *http.Response) (result ApplianceDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client ApplianceDefinitionsClient) ListByResourceGroupNextResults(lastResults ApplianceDefinitionListResult) (result ApplianceDefinitionListResult, err error) { + req, err := lastResults.ApplianceDefinitionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.ApplianceDefinitionsClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroupComplete gets all elements from the list without paging. +func (client ApplianceDefinitionsClient) ListByResourceGroupComplete(resourceGroupName string, cancel <-chan struct{}) (<-chan ApplianceDefinition, <-chan error) { + resultChan := make(chan ApplianceDefinition) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByResourceGroup(resourceGroupName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByResourceGroupNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/appliances.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/appliances.go new file mode 100644 index 0000000000..ca3737c778 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/appliances.go @@ -0,0 +1,1008 @@ +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AppliancesClient is the ARM managed applications (appliances) +type AppliancesClient struct { + ManagementClient +} + +// NewAppliancesClient creates an instance of the AppliancesClient client. +func NewAppliancesClient(subscriptionID string) AppliancesClient { + return NewAppliancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAppliancesClientWithBaseURI creates an instance of the AppliancesClient +// client. +func NewAppliancesClientWithBaseURI(baseURI string, subscriptionID string) AppliancesClient { + return AppliancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates a new appliance. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. applianceName is the name of the appliance. parameters is +// parameters supplied to the create or update an appliance. +func (client AppliancesClient) CreateOrUpdate(resourceGroupName string, applianceName string, parameters Appliance, cancel <-chan struct{}) (<-chan Appliance, <-chan error) { + resultChan := make(chan Appliance, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: applianceName, + Constraints: []validation.Constraint{{Target: "applianceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applianceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplianceProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ApplianceProperties.ManagedResourceGroupID", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.Plan", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Publisher", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Kind", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "managedapplications.AppliancesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Appliance + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(resourceGroupName, applianceName, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AppliancesClient) CreateOrUpdatePreparer(resourceGroupName string, applianceName string, parameters Appliance, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceName": autorest.Encode("path", applianceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/appliances/{applianceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AppliancesClient) CreateOrUpdateResponder(resp *http.Response) (result Appliance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateByID creates a new appliance. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// applianceID is the fully qualified ID of the appliance, including the +// appliance name and the appliance resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/appliances/{appliance-name} +// parameters is parameters supplied to the create or update an appliance. +func (client AppliancesClient) CreateOrUpdateByID(applianceID string, parameters Appliance, cancel <-chan struct{}) (<-chan Appliance, <-chan error) { + resultChan := make(chan Appliance, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ApplianceProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ApplianceProperties.ManagedResourceGroupID", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.Plan", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Plan.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Publisher", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Product", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Plan.Version", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Kind", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "managedapplications.AppliancesClient", "CreateOrUpdateByID") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Appliance + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdateByIDPreparer(applianceID, parameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "CreateOrUpdateByID", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "CreateOrUpdateByID", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "CreateOrUpdateByID", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request. +func (client AppliancesClient) CreateOrUpdateByIDPreparer(applianceID string, parameters Appliance, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceId": applianceID, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applianceId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) CreateOrUpdateByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always +// closes the http.Response Body. +func (client AppliancesClient) CreateOrUpdateByIDResponder(resp *http.Response) (result Appliance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the appliance. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. applianceName is the name of the appliance. +func (client AppliancesClient) Delete(resourceGroupName string, applianceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: applianceName, + Constraints: []validation.Constraint{{Target: "applianceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applianceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "managedapplications.AppliancesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, applianceName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client AppliancesClient) DeletePreparer(resourceGroupName string, applianceName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceName": autorest.Encode("path", applianceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/appliances/{applianceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AppliancesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByID deletes the appliance. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// applianceID is the fully qualified ID of the appliance, including the +// appliance name and the appliance resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/appliances/{appliance-name} +func (client AppliancesClient) DeleteByID(applianceID string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeleteByIDPreparer(applianceID, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "DeleteByID", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByIDSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "DeleteByID", resp, "Failure sending request") + return + } + + result, err = client.DeleteByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "DeleteByID", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeleteByIDPreparer prepares the DeleteByID request. +func (client AppliancesClient) DeleteByIDPreparer(applianceID string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceId": applianceID, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applianceId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteByIDSender sends the DeleteByID request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) DeleteByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteByIDResponder handles the response to the DeleteByID request. The method always +// closes the http.Response Body. +func (client AppliancesClient) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the appliance. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. applianceName is the name of the appliance. +func (client AppliancesClient) Get(resourceGroupName string, applianceName string) (result Appliance, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: applianceName, + Constraints: []validation.Constraint{{Target: "applianceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applianceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "managedapplications.AppliancesClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, applianceName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AppliancesClient) GetPreparer(resourceGroupName string, applianceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceName": autorest.Encode("path", applianceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/appliances/{applianceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AppliancesClient) GetResponder(resp *http.Response) (result Appliance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID gets the appliance. +// +// applianceID is the fully qualified ID of the appliance, including the +// appliance name and the appliance resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/appliances/{appliance-name} +func (client AppliancesClient) GetByID(applianceID string) (result Appliance, err error) { + req, err := client.GetByIDPreparer(applianceID) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client AppliancesClient) GetByIDPreparer(applianceID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceId": applianceID, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applianceId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client AppliancesClient) GetByIDResponder(resp *http.Response) (result Appliance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup gets all the appliances within a resource group. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. +func (client AppliancesClient) ListByResourceGroup(resourceGroupName string) (result ApplianceListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "managedapplications.AppliancesClient", "ListByResourceGroup") + } + + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client AppliancesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/appliances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client AppliancesClient) ListByResourceGroupResponder(resp *http.Response) (result ApplianceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client AppliancesClient) ListByResourceGroupNextResults(lastResults ApplianceListResult) (result ApplianceListResult, err error) { + req, err := lastResults.ApplianceListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroupComplete gets all elements from the list without paging. +func (client AppliancesClient) ListByResourceGroupComplete(resourceGroupName string, cancel <-chan struct{}) (<-chan Appliance, <-chan error) { + resultChan := make(chan Appliance) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByResourceGroup(resourceGroupName) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByResourceGroupNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListBySubscription gets all the appliances within a subscription. +func (client AppliancesClient) ListBySubscription() (result ApplianceListResult, err error) { + req, err := client.ListBySubscriptionPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListBySubscription", resp, "Failure responding to request") + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client AppliancesClient) ListBySubscriptionPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Solutions/appliances", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client AppliancesClient) ListBySubscriptionResponder(resp *http.Response) (result ApplianceListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListBySubscriptionNextResults retrieves the next set of results, if any. +func (client AppliancesClient) ListBySubscriptionNextResults(lastResults ApplianceListResult) (result ApplianceListResult, err error) { + req, err := lastResults.ApplianceListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListBySubscription", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListBySubscription", resp, "Failure sending next results request") + } + + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "ListBySubscription", resp, "Failure responding to next results request") + } + + return +} + +// ListBySubscriptionComplete gets all elements from the list without paging. +func (client AppliancesClient) ListBySubscriptionComplete(cancel <-chan struct{}) (<-chan Appliance, <-chan error) { + resultChan := make(chan Appliance) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListBySubscription() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListBySubscriptionNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Update updates an existing appliance. The only value that can be updated via +// PATCH currently is the tags. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. applianceName is the name of the appliance. parameters is +// parameters supplied to update an existing appliance. +func (client AppliancesClient) Update(resourceGroupName string, applianceName string, parameters *Appliance) (result Appliance, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: applianceName, + Constraints: []validation.Constraint{{Target: "applianceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "applianceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "managedapplications.AppliancesClient", "Update") + } + + req, err := client.UpdatePreparer(resourceGroupName, applianceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AppliancesClient) UpdatePreparer(resourceGroupName string, applianceName string, parameters *Appliance) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceName": autorest.Encode("path", applianceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Solutions/appliances/{applianceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AppliancesClient) UpdateResponder(resp *http.Response) (result Appliance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateByID updates an existing appliance. The only value that can be updated +// via PATCH currently is the tags. +// +// applianceID is the fully qualified ID of the appliance, including the +// appliance name and the appliance resource type. Use the format, +// /subscriptions/{guid}/resourceGroups/{resource-group-name}/Microsoft.Solutions/appliances/{appliance-name} +// parameters is parameters supplied to update an existing appliance. +func (client AppliancesClient) UpdateByID(applianceID string, parameters *Appliance) (result Appliance, err error) { + req, err := client.UpdateByIDPreparer(applianceID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "UpdateByID", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "UpdateByID", resp, "Failure sending request") + return + } + + result, err = client.UpdateByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "managedapplications.AppliancesClient", "UpdateByID", resp, "Failure responding to request") + } + + return +} + +// UpdateByIDPreparer prepares the UpdateByID request. +func (client AppliancesClient) UpdateByIDPreparer(applianceID string, parameters *Appliance) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "applianceId": applianceID, + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{applianceId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare(&http.Request{}) +} + +// UpdateByIDSender sends the UpdateByID request. The method will close the +// http.Response Body if it receives an error. +func (client AppliancesClient) UpdateByIDSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateByIDResponder handles the response to the UpdateByID request. The method always +// closes the http.Response Body. +func (client AppliancesClient) UpdateByIDResponder(resp *http.Response) (result Appliance, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/client.go new file mode 100644 index 0000000000..0176ab2c7e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/client.go @@ -0,0 +1,53 @@ +// Package managedapplications implements the Azure ARM Managedapplications +// service API version 2016-09-01-preview. +// +// ARM managed applications (appliances) +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Managedapplications + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Managedapplications. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/models.go new file mode 100644 index 0000000000..4819f0c11f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/models.go @@ -0,0 +1,275 @@ +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// ApplianceArtifactType enumerates the values for appliance artifact type. +type ApplianceArtifactType string + +const ( + // Custom specifies the custom state for appliance artifact type. + Custom ApplianceArtifactType = "Custom" + // Template specifies the template state for appliance artifact type. + Template ApplianceArtifactType = "Template" +) + +// ApplianceLockLevel enumerates the values for appliance lock level. +type ApplianceLockLevel string + +const ( + // CanNotDelete specifies the can not delete state for appliance lock + // level. + CanNotDelete ApplianceLockLevel = "CanNotDelete" + // None specifies the none state for appliance lock level. + None ApplianceLockLevel = "None" + // ReadOnly specifies the read only state for appliance lock level. + ReadOnly ApplianceLockLevel = "ReadOnly" +) + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Accepted specifies the accepted state for provisioning state. + Accepted ProvisioningState = "Accepted" + // Canceled specifies the canceled state for provisioning state. + Canceled ProvisioningState = "Canceled" + // Created specifies the created state for provisioning state. + Created ProvisioningState = "Created" + // Creating specifies the creating state for provisioning state. + Creating ProvisioningState = "Creating" + // Deleted specifies the deleted state for provisioning state. + Deleted ProvisioningState = "Deleted" + // Deleting specifies the deleting state for provisioning state. + Deleting ProvisioningState = "Deleting" + // Failed specifies the failed state for provisioning state. + Failed ProvisioningState = "Failed" + // Ready specifies the ready state for provisioning state. + Ready ProvisioningState = "Ready" + // Running specifies the running state for provisioning state. + Running ProvisioningState = "Running" + // Succeeded specifies the succeeded state for provisioning state. + Succeeded ProvisioningState = "Succeeded" + // Updating specifies the updating state for provisioning state. + Updating ProvisioningState = "Updating" +) + +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // SystemAssigned specifies the system assigned state for resource identity + // type. + SystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// Appliance is information about appliance. +type Appliance struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + ManagedBy *string `json:"managedBy,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Identity *Identity `json:"identity,omitempty"` + *ApplianceProperties `json:"properties,omitempty"` + Plan *Plan `json:"plan,omitempty"` + Kind *string `json:"kind,omitempty"` +} + +// ApplianceArtifact is appliance artifact. +type ApplianceArtifact struct { + Name *string `json:"name,omitempty"` + URI *string `json:"uri,omitempty"` + Type ApplianceArtifactType `json:"type,omitempty"` +} + +// ApplianceDefinition is information about appliance definition. +type ApplianceDefinition struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + ManagedBy *string `json:"managedBy,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Identity *Identity `json:"identity,omitempty"` + *ApplianceDefinitionProperties `json:"properties,omitempty"` +} + +// ApplianceDefinitionListResult is list of appliance definitions. +type ApplianceDefinitionListResult struct { + autorest.Response `json:"-"` + Value *[]ApplianceDefinition `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplianceDefinitionListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ApplianceDefinitionListResult) ApplianceDefinitionListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// ApplianceDefinitionProperties is the appliance definition properties. +type ApplianceDefinitionProperties struct { + LockLevel ApplianceLockLevel `json:"lockLevel,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Authorizations *[]ApplianceProviderAuthorization `json:"authorizations,omitempty"` + Artifacts *[]ApplianceArtifact `json:"artifacts,omitempty"` + Description *string `json:"description,omitempty"` + PackageFileURI *string `json:"packageFileUri,omitempty"` +} + +// ApplianceListResult is list of appliances. +type ApplianceListResult struct { + autorest.Response `json:"-"` + Value *[]Appliance `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplianceListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client ApplianceListResult) ApplianceListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// AppliancePatchable is information about appliance. +type AppliancePatchable struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + ManagedBy *string `json:"managedBy,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Identity *Identity `json:"identity,omitempty"` + *AppliancePropertiesPatchable `json:"properties,omitempty"` + Plan *PlanPatchable `json:"plan,omitempty"` + Kind *string `json:"kind,omitempty"` +} + +// ApplianceProperties is the appliance properties. +type ApplianceProperties struct { + ManagedResourceGroupID *string `json:"managedResourceGroupId,omitempty"` + ApplianceDefinitionID *string `json:"applianceDefinitionId,omitempty"` + Parameters *map[string]interface{} `json:"parameters,omitempty"` + Outputs *map[string]interface{} `json:"outputs,omitempty"` + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + UIDefinitionURI *string `json:"uiDefinitionUri,omitempty"` +} + +// AppliancePropertiesPatchable is the appliance properties. +type AppliancePropertiesPatchable struct { + ManagedResourceGroupID *string `json:"managedResourceGroupId,omitempty"` + ApplianceDefinitionID *string `json:"applianceDefinitionId,omitempty"` + Parameters *map[string]interface{} `json:"parameters,omitempty"` + Outputs *map[string]interface{} `json:"outputs,omitempty"` + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + UIDefinitionURI *string `json:"uiDefinitionUri,omitempty"` +} + +// ApplianceProviderAuthorization is the appliance provider authorization. +type ApplianceProviderAuthorization struct { + PrincipalID *string `json:"principalId,omitempty"` + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` +} + +// ErrorResponse is error reponse indicates ARM appliance is not able to +// process the incoming request. The reason is provided in the error message. +type ErrorResponse struct { + HTTPStatus *string `json:"httpStatus,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// GenericResource is resource information. +type GenericResource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + ManagedBy *string `json:"managedBy,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Identity *Identity `json:"identity,omitempty"` +} + +// Identity is identity for the resource. +type Identity struct { + PrincipalID *string `json:"principalId,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + Type ResourceIdentityType `json:"type,omitempty"` +} + +// Plan is plan for the appliance. +type Plan struct { + Name *string `json:"name,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Product *string `json:"product,omitempty"` + PromotionCode *string `json:"promotionCode,omitempty"` + Version *string `json:"version,omitempty"` +} + +// PlanPatchable is plan for the appliance. +type PlanPatchable struct { + Name *string `json:"name,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Product *string `json:"product,omitempty"` + PromotionCode *string `json:"promotionCode,omitempty"` + Version *string `json:"version,omitempty"` +} + +// Resource is resource information. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// Sku is SKU for the resource. +type Sku struct { + Name *string `json:"name,omitempty"` + Tier *string `json:"tier,omitempty"` + Size *string `json:"size,omitempty"` + Family *string `json:"family,omitempty"` + Model *string `json:"model,omitempty"` + Capacity *int32 `json:"capacity,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/version.go new file mode 100644 index 0000000000..9eca292ff8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/managedapplications/version.go @@ -0,0 +1,29 @@ +package managedapplications + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.1.0-beta arm-managedapplications/2016-09-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.1.0-beta" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/version.go index 8b263f2468..8c2c482539 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/policy/version.go @@ -20,10 +20,10 @@ package policy // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-policy/2016-12-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-policy/2016-12-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go index 9987888569..23741e489f 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go @@ -20,10 +20,10 @@ package resources // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-resources/2016-09-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-resources/2016-09-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go index d624dd9808..bc02789007 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go @@ -20,10 +20,10 @@ package subscriptions // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-subscriptions/2016-06-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-subscriptions/2016-06-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go index 9744571f62..0cc1eab601 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/scheduler/version.go @@ -20,10 +20,10 @@ package scheduler // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-scheduler/2016-03-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-scheduler/2016-03-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/search/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/search/version.go index 8045337d8a..a7cfb885b7 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/search/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/search/version.go @@ -20,10 +20,10 @@ package search // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-search/2015-08-19" + return "Azure-SDK-For-Go/v10.1.0-beta arm-search/2015-08-19" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/version.go index 4ee4f34583..fb30d790a9 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servermanagement/version.go @@ -20,10 +20,10 @@ package servermanagement // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-servermanagement/2016-07-01-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-servermanagement/2016-07-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/version.go index 92fbab1cce..fc3b41c5f7 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/service-map/version.go @@ -20,10 +20,10 @@ package servicemap // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-servicemap/2015-11-01-preview" + return "Azure-SDK-For-Go/v10.1.0-beta arm-servicemap/2015-11-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go index 163910ee4a..0a96a353e6 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicebus/version.go @@ -20,10 +20,10 @@ package servicebus // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-servicebus/2015-08-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-servicebus/2015-08-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/version.go index 585f817586..48f171e9f9 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/servicefabric/version.go @@ -20,10 +20,10 @@ package servicefabric // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-servicefabric/2016-09-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-servicefabric/2016-09-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go index 37edb97165..e04a0254df 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/sql/version.go @@ -20,10 +20,10 @@ package sql // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-sql/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-sql/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go index ac97c159fa..d2f85f9c9c 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go @@ -20,10 +20,10 @@ package storage // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-storage/2016-12-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-storage/2016-12-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/version.go index cfe538a84b..a6f0ff66b6 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storageimportexport/version.go @@ -20,10 +20,10 @@ package storageimportexport // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-storageimportexport/2016-11-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-storageimportexport/2016-11-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/accesscontrolrecords.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/accesscontrolrecords.go new file mode 100644 index 0000000000..a24d9f87c6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/accesscontrolrecords.go @@ -0,0 +1,385 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AccessControlRecordsClient is the client for the AccessControlRecords +// methods of the Storsimple8000series service. +type AccessControlRecordsClient struct { + ManagementClient +} + +// NewAccessControlRecordsClient creates an instance of the +// AccessControlRecordsClient client. +func NewAccessControlRecordsClient(subscriptionID string) AccessControlRecordsClient { + return NewAccessControlRecordsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccessControlRecordsClientWithBaseURI creates an instance of the +// AccessControlRecordsClient client. +func NewAccessControlRecordsClientWithBaseURI(baseURI string, subscriptionID string) AccessControlRecordsClient { + return AccessControlRecordsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or Updates an access control record. This method may +// poll for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// accessControlRecordName is the name of the access control record. parameters +// is the access control record to be added or updated. resourceGroupName is +// the resource group name managerName is the manager name +func (client AccessControlRecordsClient) CreateOrUpdate(accessControlRecordName string, parameters AccessControlRecord, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan AccessControlRecord, <-chan error) { + resultChan := make(chan AccessControlRecord, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AccessControlRecordProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.AccessControlRecordProperties.InitiatorName", Name: validation.Null, Rule: true, Chain: nil}}}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.AccessControlRecordsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result AccessControlRecord + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(accessControlRecordName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client AccessControlRecordsClient) CreateOrUpdatePreparer(accessControlRecordName string, parameters AccessControlRecord, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessControlRecordName": accessControlRecordName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/accessControlRecords/{accessControlRecordName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client AccessControlRecordsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client AccessControlRecordsClient) CreateOrUpdateResponder(resp *http.Response) (result AccessControlRecord, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the access control record. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// accessControlRecordName is the name of the access control record to delete. +// resourceGroupName is the resource group name managerName is the manager name +func (client AccessControlRecordsClient) Delete(accessControlRecordName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.AccessControlRecordsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(accessControlRecordName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client AccessControlRecordsClient) DeletePreparer(accessControlRecordName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessControlRecordName": accessControlRecordName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/accessControlRecords/{accessControlRecordName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client AccessControlRecordsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client AccessControlRecordsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the properties of the specified access control record name. +// +// accessControlRecordName is name of access control record to be fetched. +// resourceGroupName is the resource group name managerName is the manager name +func (client AccessControlRecordsClient) Get(accessControlRecordName string, resourceGroupName string, managerName string) (result AccessControlRecord, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.AccessControlRecordsClient", "Get") + } + + req, err := client.GetPreparer(accessControlRecordName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccessControlRecordsClient) GetPreparer(accessControlRecordName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "accessControlRecordName": accessControlRecordName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/accessControlRecords/{accessControlRecordName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AccessControlRecordsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccessControlRecordsClient) GetResponder(resp *http.Response) (result AccessControlRecord, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManager retrieves all the access control records in a manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client AccessControlRecordsClient) ListByManager(resourceGroupName string, managerName string) (result AccessControlRecordList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.AccessControlRecordsClient", "ListByManager") + } + + req, err := client.ListByManagerPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "ListByManager", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "ListByManager", resp, "Failure sending request") + return + } + + result, err = client.ListByManagerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AccessControlRecordsClient", "ListByManager", resp, "Failure responding to request") + } + + return +} + +// ListByManagerPreparer prepares the ListByManager request. +func (client AccessControlRecordsClient) ListByManagerPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/accessControlRecords", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByManagerSender sends the ListByManager request. The method will close the +// http.Response Body if it receives an error. +func (client AccessControlRecordsClient) ListByManagerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByManagerResponder handles the response to the ListByManager request. The method always +// closes the http.Response Body. +func (client AccessControlRecordsClient) ListByManagerResponder(resp *http.Response) (result AccessControlRecordList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/alerts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/alerts.go new file mode 100644 index 0000000000..1cc671db26 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/alerts.go @@ -0,0 +1,341 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// AlertsClient is the client for the Alerts methods of the +// Storsimple8000series service. +type AlertsClient struct { + ManagementClient +} + +// NewAlertsClient creates an instance of the AlertsClient client. +func NewAlertsClient(subscriptionID string) AlertsClient { + return NewAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertsClientWithBaseURI creates an instance of the AlertsClient client. +func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string) AlertsClient { + return AlertsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Clear clear the alerts. +// +// parameters is the clear alert request. resourceGroupName is the resource +// group name managerName is the manager name +func (client AlertsClient) Clear(parameters ClearAlertRequest, resourceGroupName string, managerName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Alerts", Name: validation.Null, Rule: true, Chain: nil}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.AlertsClient", "Clear") + } + + req, err := client.ClearPreparer(parameters, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "Clear", nil, "Failure preparing request") + return + } + + resp, err := client.ClearSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "Clear", resp, "Failure sending request") + return + } + + result, err = client.ClearResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "Clear", resp, "Failure responding to request") + } + + return +} + +// ClearPreparer prepares the Clear request. +func (client AlertsClient) ClearPreparer(parameters ClearAlertRequest, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/clearAlerts", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ClearSender sends the Clear request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ClearSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ClearResponder handles the response to the Clear request. The method always +// closes the http.Response Body. +func (client AlertsClient) ClearResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByManager retrieves all the alerts in a manager. +// +// resourceGroupName is the resource group name managerName is the manager name +// filter is oData Filter options +func (client AlertsClient) ListByManager(resourceGroupName string, managerName string, filter string) (result AlertList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.AlertsClient", "ListByManager") + } + + req, err := client.ListByManagerPreparer(resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "ListByManager", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "ListByManager", resp, "Failure sending request") + return + } + + result, err = client.ListByManagerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "ListByManager", resp, "Failure responding to request") + } + + return +} + +// ListByManagerPreparer prepares the ListByManager request. +func (client AlertsClient) ListByManagerPreparer(resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/alerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByManagerSender sends the ListByManager request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ListByManagerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByManagerResponder handles the response to the ListByManager request. The method always +// closes the http.Response Body. +func (client AlertsClient) ListByManagerResponder(resp *http.Response) (result AlertList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagerNextResults retrieves the next set of results, if any. +func (client AlertsClient) ListByManagerNextResults(lastResults AlertList) (result AlertList, err error) { + req, err := lastResults.AlertListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "ListByManager", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByManagerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "ListByManager", resp, "Failure sending next results request") + } + + result, err = client.ListByManagerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "ListByManager", resp, "Failure responding to next results request") + } + + return +} + +// ListByManagerComplete gets all elements from the list without paging. +func (client AlertsClient) ListByManagerComplete(resourceGroupName string, managerName string, filter string, cancel <-chan struct{}) (<-chan Alert, <-chan error) { + resultChan := make(chan Alert) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByManager(resourceGroupName, managerName, filter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByManagerNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// SendTestEmail sends a test alert email. +// +// deviceName is the device name parameters is the send test alert email +// request. resourceGroupName is the resource group name managerName is the +// manager name +func (client AlertsClient) SendTestEmail(deviceName string, parameters SendTestAlertEmailRequest, resourceGroupName string, managerName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.EmailList", Name: validation.Null, Rule: true, Chain: nil}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.AlertsClient", "SendTestEmail") + } + + req, err := client.SendTestEmailPreparer(deviceName, parameters, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "SendTestEmail", nil, "Failure preparing request") + return + } + + resp, err := client.SendTestEmailSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "SendTestEmail", resp, "Failure sending request") + return + } + + result, err = client.SendTestEmailResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.AlertsClient", "SendTestEmail", resp, "Failure responding to request") + } + + return +} + +// SendTestEmailPreparer prepares the SendTestEmail request. +func (client AlertsClient) SendTestEmailPreparer(deviceName string, parameters SendTestAlertEmailRequest, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/sendTestAlertEmail", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// SendTestEmailSender sends the SendTestEmail request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) SendTestEmailSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// SendTestEmailResponder handles the response to the SendTestEmail request. The method always +// closes the http.Response Body. +func (client AlertsClient) SendTestEmailResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backuppolicies.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backuppolicies.go new file mode 100644 index 0000000000..caebc2855c --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backuppolicies.go @@ -0,0 +1,487 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BackupPoliciesClient is the client for the BackupPolicies methods of the +// Storsimple8000series service. +type BackupPoliciesClient struct { + ManagementClient +} + +// NewBackupPoliciesClient creates an instance of the BackupPoliciesClient +// client. +func NewBackupPoliciesClient(subscriptionID string) BackupPoliciesClient { + return NewBackupPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupPoliciesClientWithBaseURI creates an instance of the +// BackupPoliciesClient client. +func NewBackupPoliciesClientWithBaseURI(baseURI string, subscriptionID string) BackupPoliciesClient { + return BackupPoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// BackupNow backup the backup policy now. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name backupPolicyName is the backup policy name. +// backupType is the backup Type. This can be cloudSnapshot or localSnapshot. +// resourceGroupName is the resource group name managerName is the manager name +func (client BackupPoliciesClient) BackupNow(deviceName string, backupPolicyName string, backupType string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BackupPoliciesClient", "BackupNow") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.BackupNowPreparer(deviceName, backupPolicyName, backupType, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "BackupNow", nil, "Failure preparing request") + return + } + + resp, err := client.BackupNowSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "BackupNow", resp, "Failure sending request") + return + } + + result, err = client.BackupNowResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "BackupNow", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// BackupNowPreparer prepares the BackupNow request. +func (client BackupPoliciesClient) BackupNowPreparer(deviceName string, backupPolicyName string, backupType string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupPolicyName": backupPolicyName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "backupType": backupType, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies/{backupPolicyName}/backup", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// BackupNowSender sends the BackupNow request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) BackupNowSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// BackupNowResponder handles the response to the BackupNow request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) BackupNowResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// CreateOrUpdate creates or updates the backup policy. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// deviceName is the device name backupPolicyName is the name of the backup +// policy to be created/updated. parameters is the backup policy. +// resourceGroupName is the resource group name managerName is the manager name +func (client BackupPoliciesClient) CreateOrUpdate(deviceName string, backupPolicyName string, parameters BackupPolicy, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan BackupPolicy, <-chan error) { + resultChan := make(chan BackupPolicy, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.BackupPolicyProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.BackupPolicyProperties.VolumeIds", Name: validation.Null, Rule: true, Chain: nil}}}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BackupPoliciesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result BackupPolicy + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(deviceName, backupPolicyName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupPoliciesClient) CreateOrUpdatePreparer(deviceName string, backupPolicyName string, parameters BackupPolicy, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupPolicyName": backupPolicyName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies/{backupPolicyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) CreateOrUpdateResponder(resp *http.Response) (result BackupPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the backup policy. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name backupPolicyName is the name of the backup +// policy. resourceGroupName is the resource group name managerName is the +// manager name +func (client BackupPoliciesClient) Delete(deviceName string, backupPolicyName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BackupPoliciesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(deviceName, backupPolicyName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client BackupPoliciesClient) DeletePreparer(deviceName string, backupPolicyName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupPolicyName": backupPolicyName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies/{backupPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified backup policy name. +// +// deviceName is the device name backupPolicyName is the name of backup policy +// to be fetched. resourceGroupName is the resource group name managerName is +// the manager name +func (client BackupPoliciesClient) Get(deviceName string, backupPolicyName string, resourceGroupName string, managerName string) (result BackupPolicy, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.BackupPoliciesClient", "Get") + } + + req, err := client.GetPreparer(deviceName, backupPolicyName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupPoliciesClient) GetPreparer(deviceName string, backupPolicyName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupPolicyName": backupPolicyName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies/{backupPolicyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) GetResponder(resp *http.Response) (result BackupPolicy, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDevice gets all the backup policies in a device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client BackupPoliciesClient) ListByDevice(deviceName string, resourceGroupName string, managerName string) (result BackupPolicyList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.BackupPoliciesClient", "ListByDevice") + } + + req, err := client.ListByDevicePreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "ListByDevice", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDeviceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "ListByDevice", resp, "Failure sending request") + return + } + + result, err = client.ListByDeviceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupPoliciesClient", "ListByDevice", resp, "Failure responding to request") + } + + return +} + +// ListByDevicePreparer prepares the ListByDevice request. +func (client BackupPoliciesClient) ListByDevicePreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByDeviceSender sends the ListByDevice request. The method will close the +// http.Response Body if it receives an error. +func (client BackupPoliciesClient) ListByDeviceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByDeviceResponder handles the response to the ListByDevice request. The method always +// closes the http.Response Body. +func (client BackupPoliciesClient) ListByDeviceResponder(resp *http.Response) (result BackupPolicyList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backups.go new file mode 100644 index 0000000000..d4ef8f2afc --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backups.go @@ -0,0 +1,489 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BackupsClient is the client for the Backups methods of the +// Storsimple8000series service. +type BackupsClient struct { + ManagementClient +} + +// NewBackupsClient creates an instance of the BackupsClient client. +func NewBackupsClient(subscriptionID string) BackupsClient { + return NewBackupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupsClientWithBaseURI creates an instance of the BackupsClient client. +func NewBackupsClientWithBaseURI(baseURI string, subscriptionID string) BackupsClient { + return BackupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Clone clones the backup element as a new volume. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// deviceName is the device name backupName is the backup name. +// backupElementName is the backup element name. parameters is the clone +// request object. resourceGroupName is the resource group name managerName is +// the manager name +func (client BackupsClient) Clone(deviceName string, backupName string, backupElementName string, parameters CloneRequest, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TargetDeviceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TargetVolumeName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TargetAccessControlRecordIds", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupElement", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.BackupElement.ElementID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupElement.ElementName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupElement.ElementType", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupElement.SizeInBytes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupElement.VolumeName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupElement.VolumeContainerID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BackupsClient", "Clone") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ClonePreparer(deviceName, backupName, backupElementName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Clone", nil, "Failure preparing request") + return + } + + resp, err := client.CloneSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Clone", resp, "Failure sending request") + return + } + + result, err = client.CloneResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Clone", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ClonePreparer prepares the Clone request. +func (client BackupsClient) ClonePreparer(deviceName string, backupName string, backupElementName string, parameters CloneRequest, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupElementName": backupElementName, + "backupName": backupName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backups/{backupName}/elements/{backupElementName}/clone", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CloneSender sends the Clone request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) CloneSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CloneResponder handles the response to the Clone request. The method always +// closes the http.Response Body. +func (client BackupsClient) CloneResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete deletes the backup. This method may poll for completion. Polling can +// be canceled by passing the cancel channel argument. The channel will be used +// to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name backupName is the backup name. +// resourceGroupName is the resource group name managerName is the manager name +func (client BackupsClient) Delete(deviceName string, backupName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BackupsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(deviceName, backupName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client BackupsClient) DeletePreparer(deviceName string, backupName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": backupName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backups/{backupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BackupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDevice retrieves all the backups in a device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name filter is oData Filter options +func (client BackupsClient) ListByDevice(deviceName string, resourceGroupName string, managerName string, filter string) (result BackupList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.BackupsClient", "ListByDevice") + } + + req, err := client.ListByDevicePreparer(deviceName, resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "ListByDevice", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDeviceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "ListByDevice", resp, "Failure sending request") + return + } + + result, err = client.ListByDeviceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "ListByDevice", resp, "Failure responding to request") + } + + return +} + +// ListByDevicePreparer prepares the ListByDevice request. +func (client BackupsClient) ListByDevicePreparer(deviceName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByDeviceSender sends the ListByDevice request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) ListByDeviceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByDeviceResponder handles the response to the ListByDevice request. The method always +// closes the http.Response Body. +func (client BackupsClient) ListByDeviceResponder(resp *http.Response) (result BackupList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDeviceNextResults retrieves the next set of results, if any. +func (client BackupsClient) ListByDeviceNextResults(lastResults BackupList) (result BackupList, err error) { + req, err := lastResults.BackupListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "ListByDevice", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByDeviceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "ListByDevice", resp, "Failure sending next results request") + } + + result, err = client.ListByDeviceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "ListByDevice", resp, "Failure responding to next results request") + } + + return +} + +// ListByDeviceComplete gets all elements from the list without paging. +func (client BackupsClient) ListByDeviceComplete(deviceName string, resourceGroupName string, managerName string, filter string, cancel <-chan struct{}) (<-chan Backup, <-chan error) { + resultChan := make(chan Backup) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByDevice(deviceName, resourceGroupName, managerName, filter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByDeviceNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Restore restores the backup on the device. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// deviceName is the device name backupName is the backupSet name +// resourceGroupName is the resource group name managerName is the manager name +func (client BackupsClient) Restore(deviceName string, backupName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BackupsClient", "Restore") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.RestorePreparer(deviceName, backupName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Restore", nil, "Failure preparing request") + return + } + + resp, err := client.RestoreSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Restore", resp, "Failure sending request") + return + } + + result, err = client.RestoreResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupsClient", "Restore", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// RestorePreparer prepares the Restore request. +func (client BackupsClient) RestorePreparer(deviceName string, backupName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupName": backupName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backups/{backupName}/restore", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// RestoreSender sends the Restore request. The method will close the +// http.Response Body if it receives an error. +func (client BackupsClient) RestoreSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// RestoreResponder handles the response to the Restore request. The method always +// closes the http.Response Body. +func (client BackupsClient) RestoreResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backupschedules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backupschedules.go new file mode 100644 index 0000000000..d68c9d2f9a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/backupschedules.go @@ -0,0 +1,400 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BackupSchedulesClient is the client for the BackupSchedules methods of the +// Storsimple8000series service. +type BackupSchedulesClient struct { + ManagementClient +} + +// NewBackupSchedulesClient creates an instance of the BackupSchedulesClient +// client. +func NewBackupSchedulesClient(subscriptionID string) BackupSchedulesClient { + return NewBackupSchedulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBackupSchedulesClientWithBaseURI creates an instance of the +// BackupSchedulesClient client. +func NewBackupSchedulesClientWithBaseURI(baseURI string, subscriptionID string) BackupSchedulesClient { + return BackupSchedulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the backup schedule. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// deviceName is the device name backupPolicyName is the backup policy name. +// backupScheduleName is the backup schedule name. parameters is the backup +// schedule. resourceGroupName is the resource group name managerName is the +// manager name +func (client BackupSchedulesClient) CreateOrUpdate(deviceName string, backupPolicyName string, backupScheduleName string, parameters BackupSchedule, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan BackupSchedule, <-chan error) { + resultChan := make(chan BackupSchedule, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.BackupScheduleProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.BackupScheduleProperties.ScheduleRecurrence", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.BackupScheduleProperties.ScheduleRecurrence.RecurrenceValue", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.BackupScheduleProperties.RetentionCount", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.BackupScheduleProperties.StartTime", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BackupSchedulesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result BackupSchedule + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(deviceName, backupPolicyName, backupScheduleName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BackupSchedulesClient) CreateOrUpdatePreparer(deviceName string, backupPolicyName string, backupScheduleName string, parameters BackupSchedule, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupPolicyName": backupPolicyName, + "backupScheduleName": backupScheduleName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies/{backupPolicyName}/schedules/{backupScheduleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client BackupSchedulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BackupSchedulesClient) CreateOrUpdateResponder(resp *http.Response) (result BackupSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the backup schedule. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name backupPolicyName is the backup policy name. +// backupScheduleName is the name the backup schedule. resourceGroupName is the +// resource group name managerName is the manager name +func (client BackupSchedulesClient) Delete(deviceName string, backupPolicyName string, backupScheduleName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BackupSchedulesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(deviceName, backupPolicyName, backupScheduleName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client BackupSchedulesClient) DeletePreparer(deviceName string, backupPolicyName string, backupScheduleName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupPolicyName": backupPolicyName, + "backupScheduleName": backupScheduleName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies/{backupPolicyName}/schedules/{backupScheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BackupSchedulesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BackupSchedulesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified backup schedule name. +// +// deviceName is the device name backupPolicyName is the backup policy name. +// backupScheduleName is the name of the backup schedule to be fetched +// resourceGroupName is the resource group name managerName is the manager name +func (client BackupSchedulesClient) Get(deviceName string, backupPolicyName string, backupScheduleName string, resourceGroupName string, managerName string) (result BackupSchedule, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.BackupSchedulesClient", "Get") + } + + req, err := client.GetPreparer(deviceName, backupPolicyName, backupScheduleName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BackupSchedulesClient) GetPreparer(deviceName string, backupPolicyName string, backupScheduleName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupPolicyName": backupPolicyName, + "backupScheduleName": backupScheduleName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies/{backupPolicyName}/schedules/{backupScheduleName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BackupSchedulesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BackupSchedulesClient) GetResponder(resp *http.Response) (result BackupSchedule, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBackupPolicy gets all the backup schedules in a backup policy. +// +// deviceName is the device name backupPolicyName is the backup policy name. +// resourceGroupName is the resource group name managerName is the manager name +func (client BackupSchedulesClient) ListByBackupPolicy(deviceName string, backupPolicyName string, resourceGroupName string, managerName string) (result BackupScheduleList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.BackupSchedulesClient", "ListByBackupPolicy") + } + + req, err := client.ListByBackupPolicyPreparer(deviceName, backupPolicyName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "ListByBackupPolicy", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBackupPolicySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "ListByBackupPolicy", resp, "Failure sending request") + return + } + + result, err = client.ListByBackupPolicyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BackupSchedulesClient", "ListByBackupPolicy", resp, "Failure responding to request") + } + + return +} + +// ListByBackupPolicyPreparer prepares the ListByBackupPolicy request. +func (client BackupSchedulesClient) ListByBackupPolicyPreparer(deviceName string, backupPolicyName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "backupPolicyName": backupPolicyName, + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/backupPolicies/{backupPolicyName}/schedules", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByBackupPolicySender sends the ListByBackupPolicy request. The method will close the +// http.Response Body if it receives an error. +func (client BackupSchedulesClient) ListByBackupPolicySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByBackupPolicyResponder handles the response to the ListByBackupPolicy request. The method always +// closes the http.Response Body. +func (client BackupSchedulesClient) ListByBackupPolicyResponder(resp *http.Response) (result BackupScheduleList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/bandwidthsettings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/bandwidthsettings.go new file mode 100644 index 0000000000..ca266176ff --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/bandwidthsettings.go @@ -0,0 +1,384 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BandwidthSettingsClient is the client for the BandwidthSettings methods of +// the Storsimple8000series service. +type BandwidthSettingsClient struct { + ManagementClient +} + +// NewBandwidthSettingsClient creates an instance of the +// BandwidthSettingsClient client. +func NewBandwidthSettingsClient(subscriptionID string) BandwidthSettingsClient { + return NewBandwidthSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBandwidthSettingsClientWithBaseURI creates an instance of the +// BandwidthSettingsClient client. +func NewBandwidthSettingsClientWithBaseURI(baseURI string, subscriptionID string) BandwidthSettingsClient { + return BandwidthSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the bandwidth setting This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// bandwidthSettingName is the bandwidth setting name. parameters is the +// bandwidth setting to be added or updated. resourceGroupName is the resource +// group name managerName is the manager name +func (client BandwidthSettingsClient) CreateOrUpdate(bandwidthSettingName string, parameters BandwidthSetting, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan BandwidthSetting, <-chan error) { + resultChan := make(chan BandwidthSetting, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.BandwidthRateSettingProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.BandwidthRateSettingProperties.Schedules", Name: validation.Null, Rule: true, Chain: nil}}}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BandwidthSettingsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result BandwidthSetting + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(bandwidthSettingName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client BandwidthSettingsClient) CreateOrUpdatePreparer(bandwidthSettingName string, parameters BandwidthSetting, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bandwidthSettingName": bandwidthSettingName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/bandwidthSettings/{bandwidthSettingName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client BandwidthSettingsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client BandwidthSettingsClient) CreateOrUpdateResponder(resp *http.Response) (result BandwidthSetting, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the bandwidth setting This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// bandwidthSettingName is the name of the bandwidth setting. resourceGroupName +// is the resource group name managerName is the manager name +func (client BandwidthSettingsClient) Delete(bandwidthSettingName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.BandwidthSettingsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(bandwidthSettingName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client BandwidthSettingsClient) DeletePreparer(bandwidthSettingName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bandwidthSettingName": bandwidthSettingName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/bandwidthSettings/{bandwidthSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client BandwidthSettingsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client BandwidthSettingsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the properties of the specified bandwidth setting name. +// +// bandwidthSettingName is the name of bandwidth setting to be fetched. +// resourceGroupName is the resource group name managerName is the manager name +func (client BandwidthSettingsClient) Get(bandwidthSettingName string, resourceGroupName string, managerName string) (result BandwidthSetting, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.BandwidthSettingsClient", "Get") + } + + req, err := client.GetPreparer(bandwidthSettingName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client BandwidthSettingsClient) GetPreparer(bandwidthSettingName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "bandwidthSettingName": bandwidthSettingName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/bandwidthSettings/{bandwidthSettingName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client BandwidthSettingsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client BandwidthSettingsClient) GetResponder(resp *http.Response) (result BandwidthSetting, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManager retrieves all the bandwidth setting in a manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client BandwidthSettingsClient) ListByManager(resourceGroupName string, managerName string) (result BandwidthSettingList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.BandwidthSettingsClient", "ListByManager") + } + + req, err := client.ListByManagerPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "ListByManager", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "ListByManager", resp, "Failure sending request") + return + } + + result, err = client.ListByManagerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.BandwidthSettingsClient", "ListByManager", resp, "Failure responding to request") + } + + return +} + +// ListByManagerPreparer prepares the ListByManager request. +func (client BandwidthSettingsClient) ListByManagerPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/bandwidthSettings", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByManagerSender sends the ListByManager request. The method will close the +// http.Response Body if it receives an error. +func (client BandwidthSettingsClient) ListByManagerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByManagerResponder handles the response to the ListByManager request. The method always +// closes the http.Response Body. +func (client BandwidthSettingsClient) ListByManagerResponder(resp *http.Response) (result BandwidthSettingList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/client.go new file mode 100644 index 0000000000..5a2d2648aa --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/client.go @@ -0,0 +1,53 @@ +// Package storsimple8000series implements the Azure ARM Storsimple8000series +// service API version 2017-06-01. +// +// +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Storsimple8000series + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Storsimple8000series. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/cloudappliances.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/cloudappliances.go new file mode 100644 index 0000000000..8f364a1a12 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/cloudappliances.go @@ -0,0 +1,214 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// CloudAppliancesClient is the client for the CloudAppliances methods of the +// Storsimple8000series service. +type CloudAppliancesClient struct { + ManagementClient +} + +// NewCloudAppliancesClient creates an instance of the CloudAppliancesClient +// client. +func NewCloudAppliancesClient(subscriptionID string) CloudAppliancesClient { + return NewCloudAppliancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCloudAppliancesClientWithBaseURI creates an instance of the +// CloudAppliancesClient client. +func NewCloudAppliancesClientWithBaseURI(baseURI string, subscriptionID string) CloudAppliancesClient { + return CloudAppliancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListSupportedConfigurations lists supported cloud appliance models and +// supported configurations. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client CloudAppliancesClient) ListSupportedConfigurations(resourceGroupName string, managerName string) (result CloudApplianceConfigurationList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.CloudAppliancesClient", "ListSupportedConfigurations") + } + + req, err := client.ListSupportedConfigurationsPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.CloudAppliancesClient", "ListSupportedConfigurations", nil, "Failure preparing request") + return + } + + resp, err := client.ListSupportedConfigurationsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.CloudAppliancesClient", "ListSupportedConfigurations", resp, "Failure sending request") + return + } + + result, err = client.ListSupportedConfigurationsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.CloudAppliancesClient", "ListSupportedConfigurations", resp, "Failure responding to request") + } + + return +} + +// ListSupportedConfigurationsPreparer prepares the ListSupportedConfigurations request. +func (client CloudAppliancesClient) ListSupportedConfigurationsPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/cloudApplianceConfigurations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSupportedConfigurationsSender sends the ListSupportedConfigurations request. The method will close the +// http.Response Body if it receives an error. +func (client CloudAppliancesClient) ListSupportedConfigurationsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListSupportedConfigurationsResponder handles the response to the ListSupportedConfigurations request. The method always +// closes the http.Response Body. +func (client CloudAppliancesClient) ListSupportedConfigurationsResponder(resp *http.Response) (result CloudApplianceConfigurationList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Provision provisions cloud appliance. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// parameters is the cloud appliance resourceGroupName is the resource group +// name managerName is the manager name +func (client CloudAppliancesClient) Provision(parameters CloudAppliance, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.VnetRegion", Name: validation.Null, Rule: true, Chain: nil}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.CloudAppliancesClient", "Provision") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ProvisionPreparer(parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.CloudAppliancesClient", "Provision", nil, "Failure preparing request") + return + } + + resp, err := client.ProvisionSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.CloudAppliancesClient", "Provision", resp, "Failure sending request") + return + } + + result, err = client.ProvisionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.CloudAppliancesClient", "Provision", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ProvisionPreparer prepares the Provision request. +func (client CloudAppliancesClient) ProvisionPreparer(parameters CloudAppliance, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/provisionCloudAppliance", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ProvisionSender sends the Provision request. The method will close the +// http.Response Body if it receives an error. +func (client CloudAppliancesClient) ProvisionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ProvisionResponder handles the response to the Provision request. The method always +// closes the http.Response Body. +func (client CloudAppliancesClient) ProvisionResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/devices.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/devices.go new file mode 100644 index 0000000000..1e4d258234 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/devices.go @@ -0,0 +1,1304 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DevicesClient is the client for the Devices methods of the +// Storsimple8000series service. +type DevicesClient struct { + ManagementClient +} + +// NewDevicesClient creates an instance of the DevicesClient client. +func NewDevicesClient(subscriptionID string) DevicesClient { + return NewDevicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDevicesClientWithBaseURI creates an instance of the DevicesClient client. +func NewDevicesClientWithBaseURI(baseURI string, subscriptionID string) DevicesClient { + return DevicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// AuthorizeForServiceEncryptionKeyRollover authorizes the specified device for +// service data encryption key rollover. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) AuthorizeForServiceEncryptionKeyRollover(deviceName string, resourceGroupName string, managerName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "AuthorizeForServiceEncryptionKeyRollover") + } + + req, err := client.AuthorizeForServiceEncryptionKeyRolloverPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "AuthorizeForServiceEncryptionKeyRollover", nil, "Failure preparing request") + return + } + + resp, err := client.AuthorizeForServiceEncryptionKeyRolloverSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "AuthorizeForServiceEncryptionKeyRollover", resp, "Failure sending request") + return + } + + result, err = client.AuthorizeForServiceEncryptionKeyRolloverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "AuthorizeForServiceEncryptionKeyRollover", resp, "Failure responding to request") + } + + return +} + +// AuthorizeForServiceEncryptionKeyRolloverPreparer prepares the AuthorizeForServiceEncryptionKeyRollover request. +func (client DevicesClient) AuthorizeForServiceEncryptionKeyRolloverPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/authorizeForServiceEncryptionKeyRollover", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// AuthorizeForServiceEncryptionKeyRolloverSender sends the AuthorizeForServiceEncryptionKeyRollover request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) AuthorizeForServiceEncryptionKeyRolloverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// AuthorizeForServiceEncryptionKeyRolloverResponder handles the response to the AuthorizeForServiceEncryptionKeyRollover request. The method always +// closes the http.Response Body. +func (client DevicesClient) AuthorizeForServiceEncryptionKeyRolloverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Configure complete minimal setup before using the device. This method may +// poll for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// parameters is the minimal properties to configure a device. +// resourceGroupName is the resource group name managerName is the manager name +func (client DevicesClient) Configure(parameters ConfigureDeviceRequest, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ConfigureDeviceRequestProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ConfigureDeviceRequestProperties.FriendlyName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConfigureDeviceRequestProperties.CurrentDeviceName", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ConfigureDeviceRequestProperties.TimeZone", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "Configure") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ConfigurePreparer(parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Configure", nil, "Failure preparing request") + return + } + + resp, err := client.ConfigureSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Configure", resp, "Failure sending request") + return + } + + result, err = client.ConfigureResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Configure", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ConfigurePreparer prepares the Configure request. +func (client DevicesClient) ConfigurePreparer(parameters ConfigureDeviceRequest, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/configureDevice", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ConfigureSender sends the Configure request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) ConfigureSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ConfigureResponder handles the response to the Configure request. The method always +// closes the http.Response Body. +func (client DevicesClient) ConfigureResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Deactivate deactivates the device. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) Deactivate(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "Deactivate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeactivatePreparer(deviceName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Deactivate", nil, "Failure preparing request") + return + } + + resp, err := client.DeactivateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Deactivate", resp, "Failure sending request") + return + } + + result, err = client.DeactivateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Deactivate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeactivatePreparer prepares the Deactivate request. +func (client DevicesClient) DeactivatePreparer(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/deactivate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeactivateSender sends the Deactivate request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) DeactivateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeactivateResponder handles the response to the Deactivate request. The method always +// closes the http.Response Body. +func (client DevicesClient) DeactivateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Delete deletes the device. This method may poll for completion. Polling can +// be canceled by passing the cancel channel argument. The channel will be used +// to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) Delete(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(deviceName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client DevicesClient) DeletePreparer(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DevicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Failover failovers a set of volume containers from a specified source device +// to a target device. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// sourceDeviceName is the source device name on which failover is performed. +// parameters is failoverRequest containing the source device and the list of +// volume containers to be failed over. resourceGroupName is the resource group +// name managerName is the manager name +func (client DevicesClient) Failover(sourceDeviceName string, parameters FailoverRequest, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "Failover") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.FailoverPreparer(sourceDeviceName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Failover", nil, "Failure preparing request") + return + } + + resp, err := client.FailoverSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Failover", resp, "Failure sending request") + return + } + + result, err = client.FailoverResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Failover", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// FailoverPreparer prepares the Failover request. +func (client DevicesClient) FailoverPreparer(sourceDeviceName string, parameters FailoverRequest, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "sourceDeviceName": sourceDeviceName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{sourceDeviceName}/failover", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// FailoverSender sends the Failover request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) FailoverSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// FailoverResponder handles the response to the Failover request. The method always +// closes the http.Response Body. +func (client DevicesClient) FailoverResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the properties of the specified device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name expand is specify $expand=details to +// populate additional fields related to the device or $expand=rolloverdetails +// to populate additional fields related to the service data encryption key +// rollover on device +func (client DevicesClient) Get(deviceName string, resourceGroupName string, managerName string, expand string) (result Device, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "Get") + } + + req, err := client.GetPreparer(deviceName, resourceGroupName, managerName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client DevicesClient) GetPreparer(deviceName string, resourceGroupName string, managerName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DevicesClient) GetResponder(resp *http.Response) (result Device, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetUpdateSummary returns the update summary of the specified device name. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) GetUpdateSummary(deviceName string, resourceGroupName string, managerName string) (result Updates, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "GetUpdateSummary") + } + + req, err := client.GetUpdateSummaryPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "GetUpdateSummary", nil, "Failure preparing request") + return + } + + resp, err := client.GetUpdateSummarySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "GetUpdateSummary", resp, "Failure sending request") + return + } + + result, err = client.GetUpdateSummaryResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "GetUpdateSummary", resp, "Failure responding to request") + } + + return +} + +// GetUpdateSummaryPreparer prepares the GetUpdateSummary request. +func (client DevicesClient) GetUpdateSummaryPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/updateSummary/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetUpdateSummarySender sends the GetUpdateSummary request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) GetUpdateSummarySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetUpdateSummaryResponder handles the response to the GetUpdateSummary request. The method always +// closes the http.Response Body. +func (client DevicesClient) GetUpdateSummaryResponder(resp *http.Response) (result Updates, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// InstallUpdates downloads and installs the updates on the device. This method +// may poll for completion. Polling can be canceled by passing the cancel +// channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) InstallUpdates(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "InstallUpdates") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.InstallUpdatesPreparer(deviceName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "InstallUpdates", nil, "Failure preparing request") + return + } + + resp, err := client.InstallUpdatesSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "InstallUpdates", resp, "Failure sending request") + return + } + + result, err = client.InstallUpdatesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "InstallUpdates", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// InstallUpdatesPreparer prepares the InstallUpdates request. +func (client DevicesClient) InstallUpdatesPreparer(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/installUpdates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// InstallUpdatesSender sends the InstallUpdates request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) InstallUpdatesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// InstallUpdatesResponder handles the response to the InstallUpdates request. The method always +// closes the http.Response Body. +func (client DevicesClient) InstallUpdatesResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByManager returns the list of devices for the specified manager. +// +// resourceGroupName is the resource group name managerName is the manager name +// expand is specify $expand=details to populate additional fields related to +// the device or $expand=rolloverdetails to populate additional fields related +// to the service data encryption key rollover on device +func (client DevicesClient) ListByManager(resourceGroupName string, managerName string, expand string) (result DeviceList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "ListByManager") + } + + req, err := client.ListByManagerPreparer(resourceGroupName, managerName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListByManager", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListByManager", resp, "Failure sending request") + return + } + + result, err = client.ListByManagerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListByManager", resp, "Failure responding to request") + } + + return +} + +// ListByManagerPreparer prepares the ListByManager request. +func (client DevicesClient) ListByManagerPreparer(resourceGroupName string, managerName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByManagerSender sends the ListByManager request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) ListByManagerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByManagerResponder handles the response to the ListByManager request. The method always +// closes the http.Response Body. +func (client DevicesClient) ListByManagerResponder(resp *http.Response) (result DeviceList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListFailoverSets returns all failover sets for a given device and their +// eligibility for participating in a failover. A failover set refers to a set +// of volume containers that need to be failed-over as a single unit to +// maintain data integrity. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) ListFailoverSets(deviceName string, resourceGroupName string, managerName string) (result FailoverSetsList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "ListFailoverSets") + } + + req, err := client.ListFailoverSetsPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListFailoverSets", nil, "Failure preparing request") + return + } + + resp, err := client.ListFailoverSetsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListFailoverSets", resp, "Failure sending request") + return + } + + result, err = client.ListFailoverSetsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListFailoverSets", resp, "Failure responding to request") + } + + return +} + +// ListFailoverSetsPreparer prepares the ListFailoverSets request. +func (client DevicesClient) ListFailoverSetsPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/listFailoverSets", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListFailoverSetsSender sends the ListFailoverSets request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) ListFailoverSetsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListFailoverSetsResponder handles the response to the ListFailoverSets request. The method always +// closes the http.Response Body. +func (client DevicesClient) ListFailoverSetsResponder(resp *http.Response) (result FailoverSetsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListFailoverTargets given a list of volume containers to be failed over from +// a source device, this method returns the eligibility result, as a failover +// target, for all devices under that resource. +// +// sourceDeviceName is the source device name on which failover is performed. +// parameters is listFailoverTargetsRequest containing the list of volume +// containers to be failed over. resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) ListFailoverTargets(sourceDeviceName string, parameters ListFailoverTargetsRequest, resourceGroupName string, managerName string) (result FailoverTargetsList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "ListFailoverTargets") + } + + req, err := client.ListFailoverTargetsPreparer(sourceDeviceName, parameters, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListFailoverTargets", nil, "Failure preparing request") + return + } + + resp, err := client.ListFailoverTargetsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListFailoverTargets", resp, "Failure sending request") + return + } + + result, err = client.ListFailoverTargetsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListFailoverTargets", resp, "Failure responding to request") + } + + return +} + +// ListFailoverTargetsPreparer prepares the ListFailoverTargets request. +func (client DevicesClient) ListFailoverTargetsPreparer(sourceDeviceName string, parameters ListFailoverTargetsRequest, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "sourceDeviceName": sourceDeviceName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{sourceDeviceName}/listFailoverTargets", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListFailoverTargetsSender sends the ListFailoverTargets request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) ListFailoverTargetsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListFailoverTargetsResponder handles the response to the ListFailoverTargets request. The method always +// closes the http.Response Body. +func (client DevicesClient) ListFailoverTargetsResponder(resp *http.Response) (result FailoverTargetsList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinition gets the metric definitions for the specified device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) ListMetricDefinition(deviceName string, resourceGroupName string, managerName string) (result MetricDefinitionList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "ListMetricDefinition") + } + + req, err := client.ListMetricDefinitionPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListMetricDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListMetricDefinition", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListMetricDefinition", resp, "Failure responding to request") + } + + return +} + +// ListMetricDefinitionPreparer prepares the ListMetricDefinition request. +func (client DevicesClient) ListMetricDefinitionPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/metricsDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListMetricDefinitionSender sends the ListMetricDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) ListMetricDefinitionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListMetricDefinitionResponder handles the response to the ListMetricDefinition request. The method always +// closes the http.Response Body. +func (client DevicesClient) ListMetricDefinitionResponder(resp *http.Response) (result MetricDefinitionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics gets the metrics for the specified device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name filter is oData Filter options +func (client DevicesClient) ListMetrics(deviceName string, resourceGroupName string, managerName string, filter string) (result MetricList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "ListMetrics") + } + + req, err := client.ListMetricsPreparer(deviceName, resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ListMetrics", resp, "Failure responding to request") + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client DevicesClient) ListMetricsPreparer(deviceName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client DevicesClient) ListMetricsResponder(resp *http.Response) (result MetricList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ScanForUpdates scans for updates on the device. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DevicesClient) ScanForUpdates(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "ScanForUpdates") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ScanForUpdatesPreparer(deviceName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ScanForUpdates", nil, "Failure preparing request") + return + } + + resp, err := client.ScanForUpdatesSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ScanForUpdates", resp, "Failure sending request") + return + } + + result, err = client.ScanForUpdatesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "ScanForUpdates", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ScanForUpdatesPreparer prepares the ScanForUpdates request. +func (client DevicesClient) ScanForUpdatesPreparer(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/scanForUpdates", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ScanForUpdatesSender sends the ScanForUpdates request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) ScanForUpdatesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ScanForUpdatesResponder handles the response to the ScanForUpdates request. The method always +// closes the http.Response Body. +func (client DevicesClient) ScanForUpdatesResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update patches the device. +// +// deviceName is the device name parameters is patch representation of the +// device. resourceGroupName is the resource group name managerName is the +// manager name +func (client DevicesClient) Update(deviceName string, parameters DevicePatch, resourceGroupName string, managerName string) (result Device, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DevicesClient", "Update") + } + + req, err := client.UpdatePreparer(deviceName, parameters, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DevicesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DevicesClient) UpdatePreparer(deviceName string, parameters DevicePatch, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DevicesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DevicesClient) UpdateResponder(resp *http.Response) (result Device, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/devicesettings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/devicesettings.go new file mode 100644 index 0000000000..68bc6b0318 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/devicesettings.go @@ -0,0 +1,832 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// DeviceSettingsClient is the client for the DeviceSettings methods of the +// Storsimple8000series service. +type DeviceSettingsClient struct { + ManagementClient +} + +// NewDeviceSettingsClient creates an instance of the DeviceSettingsClient +// client. +func NewDeviceSettingsClient(subscriptionID string) DeviceSettingsClient { + return NewDeviceSettingsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDeviceSettingsClientWithBaseURI creates an instance of the +// DeviceSettingsClient client. +func NewDeviceSettingsClientWithBaseURI(baseURI string, subscriptionID string) DeviceSettingsClient { + return DeviceSettingsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdateAlertSettings creates or updates the alert settings of the +// specified device. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name parameters is the alert settings to be added +// or updated. resourceGroupName is the resource group name managerName is the +// manager name +func (client DeviceSettingsClient) CreateOrUpdateAlertSettings(deviceName string, parameters AlertSettings, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan AlertSettings, <-chan error) { + resultChan := make(chan AlertSettings, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.AlertNotificationProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "CreateOrUpdateAlertSettings") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result AlertSettings + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdateAlertSettingsPreparer(deviceName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "CreateOrUpdateAlertSettings", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateAlertSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "CreateOrUpdateAlertSettings", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateAlertSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "CreateOrUpdateAlertSettings", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdateAlertSettingsPreparer prepares the CreateOrUpdateAlertSettings request. +func (client DeviceSettingsClient) CreateOrUpdateAlertSettingsPreparer(deviceName string, parameters AlertSettings, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/alertSettings/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateAlertSettingsSender sends the CreateOrUpdateAlertSettings request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) CreateOrUpdateAlertSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateAlertSettingsResponder handles the response to the CreateOrUpdateAlertSettings request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) CreateOrUpdateAlertSettingsResponder(resp *http.Response) (result AlertSettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateTimeSettings creates or updates the time settings of the +// specified device. This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name parameters is the time settings to be added or +// updated. resourceGroupName is the resource group name managerName is the +// manager name +func (client DeviceSettingsClient) CreateOrUpdateTimeSettings(deviceName string, parameters TimeSettings, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan TimeSettings, <-chan error) { + resultChan := make(chan TimeSettings, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TimeSettingsProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.TimeSettingsProperties.TimeZone", Name: validation.Null, Rule: true, Chain: nil}}}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "CreateOrUpdateTimeSettings") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result TimeSettings + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdateTimeSettingsPreparer(deviceName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "CreateOrUpdateTimeSettings", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateTimeSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "CreateOrUpdateTimeSettings", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateTimeSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "CreateOrUpdateTimeSettings", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdateTimeSettingsPreparer prepares the CreateOrUpdateTimeSettings request. +func (client DeviceSettingsClient) CreateOrUpdateTimeSettingsPreparer(deviceName string, parameters TimeSettings, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/timeSettings/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateTimeSettingsSender sends the CreateOrUpdateTimeSettings request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) CreateOrUpdateTimeSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateTimeSettingsResponder handles the response to the CreateOrUpdateTimeSettings request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) CreateOrUpdateTimeSettingsResponder(resp *http.Response) (result TimeSettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetAlertSettings gets the alert settings of the specified device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DeviceSettingsClient) GetAlertSettings(deviceName string, resourceGroupName string, managerName string) (result AlertSettings, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "GetAlertSettings") + } + + req, err := client.GetAlertSettingsPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetAlertSettings", nil, "Failure preparing request") + return + } + + resp, err := client.GetAlertSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetAlertSettings", resp, "Failure sending request") + return + } + + result, err = client.GetAlertSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetAlertSettings", resp, "Failure responding to request") + } + + return +} + +// GetAlertSettingsPreparer prepares the GetAlertSettings request. +func (client DeviceSettingsClient) GetAlertSettingsPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/alertSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetAlertSettingsSender sends the GetAlertSettings request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) GetAlertSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetAlertSettingsResponder handles the response to the GetAlertSettings request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) GetAlertSettingsResponder(resp *http.Response) (result AlertSettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetNetworkSettings gets the network settings of the specified device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DeviceSettingsClient) GetNetworkSettings(deviceName string, resourceGroupName string, managerName string) (result NetworkSettings, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "GetNetworkSettings") + } + + req, err := client.GetNetworkSettingsPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetNetworkSettings", nil, "Failure preparing request") + return + } + + resp, err := client.GetNetworkSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetNetworkSettings", resp, "Failure sending request") + return + } + + result, err = client.GetNetworkSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetNetworkSettings", resp, "Failure responding to request") + } + + return +} + +// GetNetworkSettingsPreparer prepares the GetNetworkSettings request. +func (client DeviceSettingsClient) GetNetworkSettingsPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/networkSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetNetworkSettingsSender sends the GetNetworkSettings request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) GetNetworkSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetNetworkSettingsResponder handles the response to the GetNetworkSettings request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) GetNetworkSettingsResponder(resp *http.Response) (result NetworkSettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetSecuritySettings returns the Security properties of the specified device +// name. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DeviceSettingsClient) GetSecuritySettings(deviceName string, resourceGroupName string, managerName string) (result SecuritySettings, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "GetSecuritySettings") + } + + req, err := client.GetSecuritySettingsPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetSecuritySettings", nil, "Failure preparing request") + return + } + + resp, err := client.GetSecuritySettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetSecuritySettings", resp, "Failure sending request") + return + } + + result, err = client.GetSecuritySettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetSecuritySettings", resp, "Failure responding to request") + } + + return +} + +// GetSecuritySettingsPreparer prepares the GetSecuritySettings request. +func (client DeviceSettingsClient) GetSecuritySettingsPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSecuritySettingsSender sends the GetSecuritySettings request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) GetSecuritySettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetSecuritySettingsResponder handles the response to the GetSecuritySettings request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) GetSecuritySettingsResponder(resp *http.Response) (result SecuritySettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetTimeSettings gets the time settings of the specified device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DeviceSettingsClient) GetTimeSettings(deviceName string, resourceGroupName string, managerName string) (result TimeSettings, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "GetTimeSettings") + } + + req, err := client.GetTimeSettingsPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetTimeSettings", nil, "Failure preparing request") + return + } + + resp, err := client.GetTimeSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetTimeSettings", resp, "Failure sending request") + return + } + + result, err = client.GetTimeSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "GetTimeSettings", resp, "Failure responding to request") + } + + return +} + +// GetTimeSettingsPreparer prepares the GetTimeSettings request. +func (client DeviceSettingsClient) GetTimeSettingsPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/timeSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetTimeSettingsSender sends the GetTimeSettings request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) GetTimeSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetTimeSettingsResponder handles the response to the GetTimeSettings request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) GetTimeSettingsResponder(resp *http.Response) (result TimeSettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// SyncRemotemanagementCertificate sync Remote management Certificate between +// appliance and Service This method may poll for completion. Polling can be +// canceled by passing the cancel channel argument. The channel will be used to +// cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client DeviceSettingsClient) SyncRemotemanagementCertificate(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "SyncRemotemanagementCertificate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.SyncRemotemanagementCertificatePreparer(deviceName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "SyncRemotemanagementCertificate", nil, "Failure preparing request") + return + } + + resp, err := client.SyncRemotemanagementCertificateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "SyncRemotemanagementCertificate", resp, "Failure sending request") + return + } + + result, err = client.SyncRemotemanagementCertificateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "SyncRemotemanagementCertificate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// SyncRemotemanagementCertificatePreparer prepares the SyncRemotemanagementCertificate request. +func (client DeviceSettingsClient) SyncRemotemanagementCertificatePreparer(deviceName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default/syncRemoteManagementCertificate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// SyncRemotemanagementCertificateSender sends the SyncRemotemanagementCertificate request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) SyncRemotemanagementCertificateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// SyncRemotemanagementCertificateResponder handles the response to the SyncRemotemanagementCertificate request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) SyncRemotemanagementCertificateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// UpdateNetworkSettings updates the network settings on the specified device. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// deviceName is the device name parameters is the network settings to be +// updated. resourceGroupName is the resource group name managerName is the +// manager name +func (client DeviceSettingsClient) UpdateNetworkSettings(deviceName string, parameters NetworkSettingsPatch, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan NetworkSettings, <-chan error) { + resultChan := make(chan NetworkSettings, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "UpdateNetworkSettings") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result NetworkSettings + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UpdateNetworkSettingsPreparer(deviceName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "UpdateNetworkSettings", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateNetworkSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "UpdateNetworkSettings", resp, "Failure sending request") + return + } + + result, err = client.UpdateNetworkSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "UpdateNetworkSettings", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdateNetworkSettingsPreparer prepares the UpdateNetworkSettings request. +func (client DeviceSettingsClient) UpdateNetworkSettingsPreparer(deviceName string, parameters NetworkSettingsPatch, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/networkSettings/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateNetworkSettingsSender sends the UpdateNetworkSettings request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) UpdateNetworkSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateNetworkSettingsResponder handles the response to the UpdateNetworkSettings request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) UpdateNetworkSettingsResponder(resp *http.Response) (result NetworkSettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateSecuritySettings patch Security properties of the specified device +// name. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// deviceName is the device name parameters is the security settings properties +// to be patched. resourceGroupName is the resource group name managerName is +// the manager name +func (client DeviceSettingsClient) UpdateSecuritySettings(deviceName string, parameters SecuritySettingsPatch, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan SecuritySettings, <-chan error) { + resultChan := make(chan SecuritySettings, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.DeviceSettingsClient", "UpdateSecuritySettings") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result SecuritySettings + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.UpdateSecuritySettingsPreparer(deviceName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "UpdateSecuritySettings", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSecuritySettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "UpdateSecuritySettings", resp, "Failure sending request") + return + } + + result, err = client.UpdateSecuritySettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.DeviceSettingsClient", "UpdateSecuritySettings", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// UpdateSecuritySettingsPreparer prepares the UpdateSecuritySettings request. +func (client DeviceSettingsClient) UpdateSecuritySettingsPreparer(deviceName string, parameters SecuritySettingsPatch, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// UpdateSecuritySettingsSender sends the UpdateSecuritySettings request. The method will close the +// http.Response Body if it receives an error. +func (client DeviceSettingsClient) UpdateSecuritySettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// UpdateSecuritySettingsResponder handles the response to the UpdateSecuritySettings request. The method always +// closes the http.Response Body. +func (client DeviceSettingsClient) UpdateSecuritySettingsResponder(resp *http.Response) (result SecuritySettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/hardwarecomponentgroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/hardwarecomponentgroups.go new file mode 100644 index 0000000000..bce206034a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/hardwarecomponentgroups.go @@ -0,0 +1,219 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// HardwareComponentGroupsClient is the client for the HardwareComponentGroups +// methods of the Storsimple8000series service. +type HardwareComponentGroupsClient struct { + ManagementClient +} + +// NewHardwareComponentGroupsClient creates an instance of the +// HardwareComponentGroupsClient client. +func NewHardwareComponentGroupsClient(subscriptionID string) HardwareComponentGroupsClient { + return NewHardwareComponentGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHardwareComponentGroupsClientWithBaseURI creates an instance of the +// HardwareComponentGroupsClient client. +func NewHardwareComponentGroupsClientWithBaseURI(baseURI string, subscriptionID string) HardwareComponentGroupsClient { + return HardwareComponentGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ChangeControllerPowerState changes the power state of the controller. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// deviceName is the device name hardwareComponentGroupName is the hardware +// component group name. parameters is the controller power state change +// request. resourceGroupName is the resource group name managerName is the +// manager name +func (client HardwareComponentGroupsClient) ChangeControllerPowerState(deviceName string, hardwareComponentGroupName string, parameters ControllerPowerStateChangeRequest, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ControllerPowerStateChangeRequestProperties", Name: validation.Null, Rule: true, Chain: nil}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.HardwareComponentGroupsClient", "ChangeControllerPowerState") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.ChangeControllerPowerStatePreparer(deviceName, hardwareComponentGroupName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.HardwareComponentGroupsClient", "ChangeControllerPowerState", nil, "Failure preparing request") + return + } + + resp, err := client.ChangeControllerPowerStateSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.HardwareComponentGroupsClient", "ChangeControllerPowerState", resp, "Failure sending request") + return + } + + result, err = client.ChangeControllerPowerStateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.HardwareComponentGroupsClient", "ChangeControllerPowerState", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// ChangeControllerPowerStatePreparer prepares the ChangeControllerPowerState request. +func (client HardwareComponentGroupsClient) ChangeControllerPowerStatePreparer(deviceName string, hardwareComponentGroupName string, parameters ControllerPowerStateChangeRequest, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "hardwareComponentGroupName": hardwareComponentGroupName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/hardwareComponentGroups/{hardwareComponentGroupName}/changeControllerPowerState", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ChangeControllerPowerStateSender sends the ChangeControllerPowerState request. The method will close the +// http.Response Body if it receives an error. +func (client HardwareComponentGroupsClient) ChangeControllerPowerStateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ChangeControllerPowerStateResponder handles the response to the ChangeControllerPowerState request. The method always +// closes the http.Response Body. +func (client HardwareComponentGroupsClient) ChangeControllerPowerStateResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// ListByDevice lists the hardware component groups at device-level. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client HardwareComponentGroupsClient) ListByDevice(deviceName string, resourceGroupName string, managerName string) (result HardwareComponentGroupList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.HardwareComponentGroupsClient", "ListByDevice") + } + + req, err := client.ListByDevicePreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.HardwareComponentGroupsClient", "ListByDevice", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDeviceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.HardwareComponentGroupsClient", "ListByDevice", resp, "Failure sending request") + return + } + + result, err = client.ListByDeviceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.HardwareComponentGroupsClient", "ListByDevice", resp, "Failure responding to request") + } + + return +} + +// ListByDevicePreparer prepares the ListByDevice request. +func (client HardwareComponentGroupsClient) ListByDevicePreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/hardwareComponentGroups", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByDeviceSender sends the ListByDevice request. The method will close the +// http.Response Body if it receives an error. +func (client HardwareComponentGroupsClient) ListByDeviceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByDeviceResponder handles the response to the ListByDevice request. The method always +// closes the http.Response Body. +func (client HardwareComponentGroupsClient) ListByDeviceResponder(resp *http.Response) (result HardwareComponentGroupList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/jobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/jobs.go new file mode 100644 index 0000000000..5ab8a346b3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/jobs.go @@ -0,0 +1,504 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// JobsClient is the client for the Jobs methods of the Storsimple8000series +// service. +type JobsClient struct { + ManagementClient +} + +// NewJobsClient creates an instance of the JobsClient client. +func NewJobsClient(subscriptionID string) JobsClient { + return NewJobsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewJobsClientWithBaseURI creates an instance of the JobsClient client. +func NewJobsClientWithBaseURI(baseURI string, subscriptionID string) JobsClient { + return JobsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Cancel cancels a job on the device. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name jobName is the jobName. resourceGroupName is +// the resource group name managerName is the manager name +func (client JobsClient) Cancel(deviceName string, jobName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.JobsClient", "Cancel") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CancelPreparer(deviceName, jobName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "Cancel", nil, "Failure preparing request") + return + } + + resp, err := client.CancelSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "Cancel", resp, "Failure sending request") + return + } + + result, err = client.CancelResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "Cancel", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CancelPreparer prepares the Cancel request. +func (client JobsClient) CancelPreparer(deviceName string, jobName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "jobName": jobName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/jobs/{jobName}/cancel", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CancelSender sends the Cancel request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) CancelSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CancelResponder handles the response to the Cancel request. The method always +// closes the http.Response Body. +func (client JobsClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the details of the specified job name. +// +// deviceName is the device name jobName is the job Name. resourceGroupName is +// the resource group name managerName is the manager name +func (client JobsClient) Get(deviceName string, jobName string, resourceGroupName string, managerName string) (result Job, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.JobsClient", "Get") + } + + req, err := client.GetPreparer(deviceName, jobName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client JobsClient) GetPreparer(deviceName string, jobName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "jobName": jobName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/jobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client JobsClient) GetResponder(resp *http.Response) (result Job, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDevice gets all the jobs for specified device. With optional OData +// query parameters, a filtered set of jobs is returned. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name filter is oData Filter options +func (client JobsClient) ListByDevice(deviceName string, resourceGroupName string, managerName string, filter string) (result JobList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.JobsClient", "ListByDevice") + } + + req, err := client.ListByDevicePreparer(deviceName, resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByDevice", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDeviceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByDevice", resp, "Failure sending request") + return + } + + result, err = client.ListByDeviceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByDevice", resp, "Failure responding to request") + } + + return +} + +// ListByDevicePreparer prepares the ListByDevice request. +func (client JobsClient) ListByDevicePreparer(deviceName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/jobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByDeviceSender sends the ListByDevice request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) ListByDeviceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByDeviceResponder handles the response to the ListByDevice request. The method always +// closes the http.Response Body. +func (client JobsClient) ListByDeviceResponder(resp *http.Response) (result JobList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDeviceNextResults retrieves the next set of results, if any. +func (client JobsClient) ListByDeviceNextResults(lastResults JobList) (result JobList, err error) { + req, err := lastResults.JobListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByDevice", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByDeviceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByDevice", resp, "Failure sending next results request") + } + + result, err = client.ListByDeviceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByDevice", resp, "Failure responding to next results request") + } + + return +} + +// ListByDeviceComplete gets all elements from the list without paging. +func (client JobsClient) ListByDeviceComplete(deviceName string, resourceGroupName string, managerName string, filter string, cancel <-chan struct{}) (<-chan Job, <-chan error) { + resultChan := make(chan Job) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByDevice(deviceName, resourceGroupName, managerName, filter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByDeviceNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByManager gets all the jobs for the specified manager. With optional +// OData query parameters, a filtered set of jobs is returned. +// +// resourceGroupName is the resource group name managerName is the manager name +// filter is oData Filter options +func (client JobsClient) ListByManager(resourceGroupName string, managerName string, filter string) (result JobList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.JobsClient", "ListByManager") + } + + req, err := client.ListByManagerPreparer(resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByManager", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByManager", resp, "Failure sending request") + return + } + + result, err = client.ListByManagerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByManager", resp, "Failure responding to request") + } + + return +} + +// ListByManagerPreparer prepares the ListByManager request. +func (client JobsClient) ListByManagerPreparer(resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/jobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByManagerSender sends the ListByManager request. The method will close the +// http.Response Body if it receives an error. +func (client JobsClient) ListByManagerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByManagerResponder handles the response to the ListByManager request. The method always +// closes the http.Response Body. +func (client JobsClient) ListByManagerResponder(resp *http.Response) (result JobList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManagerNextResults retrieves the next set of results, if any. +func (client JobsClient) ListByManagerNextResults(lastResults JobList) (result JobList, err error) { + req, err := lastResults.JobListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByManager", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByManagerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByManager", resp, "Failure sending next results request") + } + + result, err = client.ListByManagerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.JobsClient", "ListByManager", resp, "Failure responding to next results request") + } + + return +} + +// ListByManagerComplete gets all elements from the list without paging. +func (client JobsClient) ListByManagerComplete(resourceGroupName string, managerName string, filter string, cancel <-chan struct{}) (<-chan Job, <-chan error) { + resultChan := make(chan Job) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByManager(resourceGroupName, managerName, filter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByManagerNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/managers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/managers.go new file mode 100644 index 0000000000..825668e47d --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/managers.go @@ -0,0 +1,1354 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ManagersClient is the client for the Managers methods of the +// Storsimple8000series service. +type ManagersClient struct { + ManagementClient +} + +// NewManagersClient creates an instance of the ManagersClient client. +func NewManagersClient(subscriptionID string) ManagersClient { + return NewManagersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewManagersClientWithBaseURI creates an instance of the ManagersClient +// client. +func NewManagersClientWithBaseURI(baseURI string, subscriptionID string) ManagersClient { + return ManagersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateExtendedInfo creates the extended info of the manager. +// +// parameters is the manager extended information. resourceGroupName is the +// resource group name managerName is the manager name +func (client ManagersClient) CreateExtendedInfo(parameters ManagerExtendedInfo, resourceGroupName string, managerName string) (result ManagerExtendedInfo, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagerExtendedInfoProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagerExtendedInfoProperties.IntegrityKey", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ManagerExtendedInfoProperties.Algorithm", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "CreateExtendedInfo") + } + + req, err := client.CreateExtendedInfoPreparer(parameters, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "CreateExtendedInfo", nil, "Failure preparing request") + return + } + + resp, err := client.CreateExtendedInfoSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "CreateExtendedInfo", resp, "Failure sending request") + return + } + + result, err = client.CreateExtendedInfoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "CreateExtendedInfo", resp, "Failure responding to request") + } + + return +} + +// CreateExtendedInfoPreparer prepares the CreateExtendedInfo request. +func (client ManagersClient) CreateExtendedInfoPreparer(parameters ManagerExtendedInfo, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/extendedInformation/vaultExtendedInfo", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateExtendedInfoSender sends the CreateExtendedInfo request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) CreateExtendedInfoSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateExtendedInfoResponder handles the response to the CreateExtendedInfo request. The method always +// closes the http.Response Body. +func (client ManagersClient) CreateExtendedInfoResponder(resp *http.Response) (result ManagerExtendedInfo, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate creates or updates the manager. +// +// parameters is the manager. resourceGroupName is the resource group name +// managerName is the manager name +func (client ManagersClient) CreateOrUpdate(parameters Manager, resourceGroupName string, managerName string) (result Manager, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ManagerProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagerProperties.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ManagerProperties.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "CreateOrUpdate") + } + + req, err := client.CreateOrUpdatePreparer(parameters, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ManagersClient) CreateOrUpdatePreparer(parameters Manager, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ManagersClient) CreateOrUpdateResponder(resp *http.Response) (result Manager, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) Delete(resourceGroupName string, managerName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "Delete") + } + + req, err := client.DeletePreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ManagersClient) DeletePreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ManagersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteExtendedInfo deletes the extended info of the manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) DeleteExtendedInfo(resourceGroupName string, managerName string) (result autorest.Response, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "DeleteExtendedInfo") + } + + req, err := client.DeleteExtendedInfoPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "DeleteExtendedInfo", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteExtendedInfoSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "DeleteExtendedInfo", resp, "Failure sending request") + return + } + + result, err = client.DeleteExtendedInfoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "DeleteExtendedInfo", resp, "Failure responding to request") + } + + return +} + +// DeleteExtendedInfoPreparer prepares the DeleteExtendedInfo request. +func (client ManagersClient) DeleteExtendedInfoPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/extendedInformation/vaultExtendedInfo", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteExtendedInfoSender sends the DeleteExtendedInfo request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) DeleteExtendedInfoSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteExtendedInfoResponder handles the response to the DeleteExtendedInfo request. The method always +// closes the http.Response Body. +func (client ManagersClient) DeleteExtendedInfoResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the properties of the specified manager name. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) Get(resourceGroupName string, managerName string) (result Manager, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "Get") + } + + req, err := client.GetPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ManagersClient) GetPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ManagersClient) GetResponder(resp *http.Response) (result Manager, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetActivationKey returns the activation key of the manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) GetActivationKey(resourceGroupName string, managerName string) (result Key, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "GetActivationKey") + } + + req, err := client.GetActivationKeyPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetActivationKey", nil, "Failure preparing request") + return + } + + resp, err := client.GetActivationKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetActivationKey", resp, "Failure sending request") + return + } + + result, err = client.GetActivationKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetActivationKey", resp, "Failure responding to request") + } + + return +} + +// GetActivationKeyPreparer prepares the GetActivationKey request. +func (client ManagersClient) GetActivationKeyPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/listActivationKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetActivationKeySender sends the GetActivationKey request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) GetActivationKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetActivationKeyResponder handles the response to the GetActivationKey request. The method always +// closes the http.Response Body. +func (client ManagersClient) GetActivationKeyResponder(resp *http.Response) (result Key, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetDevicePublicEncryptionKey returns the public encryption key of the +// device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client ManagersClient) GetDevicePublicEncryptionKey(deviceName string, resourceGroupName string, managerName string) (result PublicKey, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "GetDevicePublicEncryptionKey") + } + + req, err := client.GetDevicePublicEncryptionKeyPreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetDevicePublicEncryptionKey", nil, "Failure preparing request") + return + } + + resp, err := client.GetDevicePublicEncryptionKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetDevicePublicEncryptionKey", resp, "Failure sending request") + return + } + + result, err = client.GetDevicePublicEncryptionKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetDevicePublicEncryptionKey", resp, "Failure responding to request") + } + + return +} + +// GetDevicePublicEncryptionKeyPreparer prepares the GetDevicePublicEncryptionKey request. +func (client ManagersClient) GetDevicePublicEncryptionKeyPreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/publicEncryptionKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetDevicePublicEncryptionKeySender sends the GetDevicePublicEncryptionKey request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) GetDevicePublicEncryptionKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetDevicePublicEncryptionKeyResponder handles the response to the GetDevicePublicEncryptionKey request. The method always +// closes the http.Response Body. +func (client ManagersClient) GetDevicePublicEncryptionKeyResponder(resp *http.Response) (result PublicKey, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetEncryptionSettings returns the encryption settings of the manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) GetEncryptionSettings(resourceGroupName string, managerName string) (result EncryptionSettings, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "GetEncryptionSettings") + } + + req, err := client.GetEncryptionSettingsPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetEncryptionSettings", nil, "Failure preparing request") + return + } + + resp, err := client.GetEncryptionSettingsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetEncryptionSettings", resp, "Failure sending request") + return + } + + result, err = client.GetEncryptionSettingsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetEncryptionSettings", resp, "Failure responding to request") + } + + return +} + +// GetEncryptionSettingsPreparer prepares the GetEncryptionSettings request. +func (client ManagersClient) GetEncryptionSettingsPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/encryptionSettings/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetEncryptionSettingsSender sends the GetEncryptionSettings request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) GetEncryptionSettingsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetEncryptionSettingsResponder handles the response to the GetEncryptionSettings request. The method always +// closes the http.Response Body. +func (client ManagersClient) GetEncryptionSettingsResponder(resp *http.Response) (result EncryptionSettings, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetExtendedInfo returns the extended information of the specified manager +// name. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) GetExtendedInfo(resourceGroupName string, managerName string) (result ManagerExtendedInfo, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "GetExtendedInfo") + } + + req, err := client.GetExtendedInfoPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetExtendedInfo", nil, "Failure preparing request") + return + } + + resp, err := client.GetExtendedInfoSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetExtendedInfo", resp, "Failure sending request") + return + } + + result, err = client.GetExtendedInfoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetExtendedInfo", resp, "Failure responding to request") + } + + return +} + +// GetExtendedInfoPreparer prepares the GetExtendedInfo request. +func (client ManagersClient) GetExtendedInfoPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/extendedInformation/vaultExtendedInfo", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetExtendedInfoSender sends the GetExtendedInfo request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) GetExtendedInfoSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetExtendedInfoResponder handles the response to the GetExtendedInfo request. The method always +// closes the http.Response Body. +func (client ManagersClient) GetExtendedInfoResponder(resp *http.Response) (result ManagerExtendedInfo, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetPublicEncryptionKey returns the symmetric encrypted public encryption key +// of the manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) GetPublicEncryptionKey(resourceGroupName string, managerName string) (result SymmetricEncryptedSecret, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "GetPublicEncryptionKey") + } + + req, err := client.GetPublicEncryptionKeyPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetPublicEncryptionKey", nil, "Failure preparing request") + return + } + + resp, err := client.GetPublicEncryptionKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetPublicEncryptionKey", resp, "Failure sending request") + return + } + + result, err = client.GetPublicEncryptionKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "GetPublicEncryptionKey", resp, "Failure responding to request") + } + + return +} + +// GetPublicEncryptionKeyPreparer prepares the GetPublicEncryptionKey request. +func (client ManagersClient) GetPublicEncryptionKeyPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/listPublicEncryptionKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetPublicEncryptionKeySender sends the GetPublicEncryptionKey request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) GetPublicEncryptionKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetPublicEncryptionKeyResponder handles the response to the GetPublicEncryptionKey request. The method always +// closes the http.Response Body. +func (client ManagersClient) GetPublicEncryptionKeyResponder(resp *http.Response) (result SymmetricEncryptedSecret, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List retrieves all the managers in a subscription. +func (client ManagersClient) List() (result ManagerList, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ManagersClient) ListPreparer() (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StorSimple/managers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ManagersClient) ListResponder(resp *http.Response) (result ManagerList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup retrieves all the managers in a resource group. +// +// resourceGroupName is the resource group name +func (client ManagersClient) ListByResourceGroup(resourceGroupName string) (result ManagerList, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ManagersClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ManagersClient) ListByResourceGroupResponder(resp *http.Response) (result ManagerList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListFeatureSupportStatus lists the features and their support status +// +// resourceGroupName is the resource group name managerName is the manager name +// filter is oData Filter options +func (client ManagersClient) ListFeatureSupportStatus(resourceGroupName string, managerName string, filter string) (result FeatureList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "ListFeatureSupportStatus") + } + + req, err := client.ListFeatureSupportStatusPreparer(resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListFeatureSupportStatus", nil, "Failure preparing request") + return + } + + resp, err := client.ListFeatureSupportStatusSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListFeatureSupportStatus", resp, "Failure sending request") + return + } + + result, err = client.ListFeatureSupportStatusResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListFeatureSupportStatus", resp, "Failure responding to request") + } + + return +} + +// ListFeatureSupportStatusPreparer prepares the ListFeatureSupportStatus request. +func (client ManagersClient) ListFeatureSupportStatusPreparer(resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/features", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListFeatureSupportStatusSender sends the ListFeatureSupportStatus request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) ListFeatureSupportStatusSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListFeatureSupportStatusResponder handles the response to the ListFeatureSupportStatus request. The method always +// closes the http.Response Body. +func (client ManagersClient) ListFeatureSupportStatusResponder(resp *http.Response) (result FeatureList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinition gets the metric definitions for the specified manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) ListMetricDefinition(resourceGroupName string, managerName string) (result MetricDefinitionList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "ListMetricDefinition") + } + + req, err := client.ListMetricDefinitionPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListMetricDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListMetricDefinition", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListMetricDefinition", resp, "Failure responding to request") + } + + return +} + +// ListMetricDefinitionPreparer prepares the ListMetricDefinition request. +func (client ManagersClient) ListMetricDefinitionPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/metricsDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListMetricDefinitionSender sends the ListMetricDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) ListMetricDefinitionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListMetricDefinitionResponder handles the response to the ListMetricDefinition request. The method always +// closes the http.Response Body. +func (client ManagersClient) ListMetricDefinitionResponder(resp *http.Response) (result MetricDefinitionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics gets the metrics for the specified manager. +// +// resourceGroupName is the resource group name managerName is the manager name +// filter is oData Filter options +func (client ManagersClient) ListMetrics(resourceGroupName string, managerName string, filter string) (result MetricList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "ListMetrics") + } + + req, err := client.ListMetricsPreparer(resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "ListMetrics", resp, "Failure responding to request") + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client ManagersClient) ListMetricsPreparer(resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client ManagersClient) ListMetricsResponder(resp *http.Response) (result MetricList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// RegenerateActivationKey re-generates and returns the activation key of the +// manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client ManagersClient) RegenerateActivationKey(resourceGroupName string, managerName string) (result Key, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "RegenerateActivationKey") + } + + req, err := client.RegenerateActivationKeyPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "RegenerateActivationKey", nil, "Failure preparing request") + return + } + + resp, err := client.RegenerateActivationKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "RegenerateActivationKey", resp, "Failure sending request") + return + } + + result, err = client.RegenerateActivationKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "RegenerateActivationKey", resp, "Failure responding to request") + } + + return +} + +// RegenerateActivationKeyPreparer prepares the RegenerateActivationKey request. +func (client ManagersClient) RegenerateActivationKeyPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/regenerateActivationKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// RegenerateActivationKeySender sends the RegenerateActivationKey request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) RegenerateActivationKeySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// RegenerateActivationKeyResponder handles the response to the RegenerateActivationKey request. The method always +// closes the http.Response Body. +func (client ManagersClient) RegenerateActivationKeyResponder(resp *http.Response) (result Key, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the StorSimple Manager. +// +// parameters is the manager update parameters. resourceGroupName is the +// resource group name managerName is the manager name +func (client ManagersClient) Update(parameters ManagerPatch, resourceGroupName string, managerName string) (result Manager, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "Update") + } + + req, err := client.UpdatePreparer(parameters, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ManagersClient) UpdatePreparer(parameters ManagerPatch, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ManagersClient) UpdateResponder(resp *http.Response) (result Manager, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateExtendedInfo updates the extended info of the manager. +// +// parameters is the manager extended information. resourceGroupName is the +// resource group name managerName is the manager name ifMatch is pass the ETag +// of ExtendedInfo fetched from GET call +func (client ManagersClient) UpdateExtendedInfo(parameters ManagerExtendedInfo, resourceGroupName string, managerName string, ifMatch string) (result ManagerExtendedInfo, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.ManagersClient", "UpdateExtendedInfo") + } + + req, err := client.UpdateExtendedInfoPreparer(parameters, resourceGroupName, managerName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "UpdateExtendedInfo", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateExtendedInfoSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "UpdateExtendedInfo", resp, "Failure sending request") + return + } + + result, err = client.UpdateExtendedInfoResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.ManagersClient", "UpdateExtendedInfo", resp, "Failure responding to request") + } + + return +} + +// UpdateExtendedInfoPreparer prepares the UpdateExtendedInfo request. +func (client ManagersClient) UpdateExtendedInfoPreparer(parameters ManagerExtendedInfo, resourceGroupName string, managerName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/extendedInformation/vaultExtendedInfo", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters), + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + return preparer.Prepare(&http.Request{}) +} + +// UpdateExtendedInfoSender sends the UpdateExtendedInfo request. The method will close the +// http.Response Body if it receives an error. +func (client ManagersClient) UpdateExtendedInfoSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateExtendedInfoResponder handles the response to the UpdateExtendedInfo request. The method always +// closes the http.Response Body. +func (client ManagersClient) UpdateExtendedInfoResponder(resp *http.Response) (result ManagerExtendedInfo, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/models.go new file mode 100644 index 0000000000..98caf1bb40 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/models.go @@ -0,0 +1,1954 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// AlertEmailNotificationStatus enumerates the values for alert email +// notification status. +type AlertEmailNotificationStatus string + +const ( + // Disabled specifies the disabled state for alert email notification + // status. + Disabled AlertEmailNotificationStatus = "Disabled" + // Enabled specifies the enabled state for alert email notification status. + Enabled AlertEmailNotificationStatus = "Enabled" +) + +// AlertScope enumerates the values for alert scope. +type AlertScope string + +const ( + // AlertScopeDevice specifies the alert scope device state for alert scope. + AlertScopeDevice AlertScope = "Device" + // AlertScopeResource specifies the alert scope resource state for alert + // scope. + AlertScopeResource AlertScope = "Resource" +) + +// AlertSeverity enumerates the values for alert severity. +type AlertSeverity string + +const ( + // Critical specifies the critical state for alert severity. + Critical AlertSeverity = "Critical" + // Informational specifies the informational state for alert severity. + Informational AlertSeverity = "Informational" + // Warning specifies the warning state for alert severity. + Warning AlertSeverity = "Warning" +) + +// AlertSourceType enumerates the values for alert source type. +type AlertSourceType string + +const ( + // AlertSourceTypeDevice specifies the alert source type device state for + // alert source type. + AlertSourceTypeDevice AlertSourceType = "Device" + // AlertSourceTypeResource specifies the alert source type resource state + // for alert source type. + AlertSourceTypeResource AlertSourceType = "Resource" +) + +// AlertStatus enumerates the values for alert status. +type AlertStatus string + +const ( + // Active specifies the active state for alert status. + Active AlertStatus = "Active" + // Cleared specifies the cleared state for alert status. + Cleared AlertStatus = "Cleared" +) + +// AuthenticationType enumerates the values for authentication type. +type AuthenticationType string + +const ( + // Basic specifies the basic state for authentication type. + Basic AuthenticationType = "Basic" + // Invalid specifies the invalid state for authentication type. + Invalid AuthenticationType = "Invalid" + // None specifies the none state for authentication type. + None AuthenticationType = "None" + // NTLM specifies the ntlm state for authentication type. + NTLM AuthenticationType = "NTLM" +) + +// AuthorizationEligibility enumerates the values for authorization +// eligibility. +type AuthorizationEligibility string + +const ( + // Eligible specifies the eligible state for authorization eligibility. + Eligible AuthorizationEligibility = "Eligible" + // InEligible specifies the in eligible state for authorization + // eligibility. + InEligible AuthorizationEligibility = "InEligible" +) + +// AuthorizationStatus enumerates the values for authorization status. +type AuthorizationStatus string + +const ( + // AuthorizationStatusDisabled specifies the authorization status disabled + // state for authorization status. + AuthorizationStatusDisabled AuthorizationStatus = "Disabled" + // AuthorizationStatusEnabled specifies the authorization status enabled + // state for authorization status. + AuthorizationStatusEnabled AuthorizationStatus = "Enabled" +) + +// BackupJobCreationType enumerates the values for backup job creation type. +type BackupJobCreationType string + +const ( + // Adhoc specifies the adhoc state for backup job creation type. + Adhoc BackupJobCreationType = "Adhoc" + // BySchedule specifies the by schedule state for backup job creation type. + BySchedule BackupJobCreationType = "BySchedule" + // BySSM specifies the by ssm state for backup job creation type. + BySSM BackupJobCreationType = "BySSM" +) + +// BackupPolicyCreationType enumerates the values for backup policy creation +// type. +type BackupPolicyCreationType string + +const ( + // BackupPolicyCreationTypeBySaaS specifies the backup policy creation type + // by saa s state for backup policy creation type. + BackupPolicyCreationTypeBySaaS BackupPolicyCreationType = "BySaaS" + // BackupPolicyCreationTypeBySSM specifies the backup policy creation type + // by ssm state for backup policy creation type. + BackupPolicyCreationTypeBySSM BackupPolicyCreationType = "BySSM" +) + +// BackupStatus enumerates the values for backup status. +type BackupStatus string + +const ( + // BackupStatusDisabled specifies the backup status disabled state for + // backup status. + BackupStatusDisabled BackupStatus = "Disabled" + // BackupStatusEnabled specifies the backup status enabled state for backup + // status. + BackupStatusEnabled BackupStatus = "Enabled" +) + +// BackupType enumerates the values for backup type. +type BackupType string + +const ( + // CloudSnapshot specifies the cloud snapshot state for backup type. + CloudSnapshot BackupType = "CloudSnapshot" + // LocalSnapshot specifies the local snapshot state for backup type. + LocalSnapshot BackupType = "LocalSnapshot" +) + +// ControllerID enumerates the values for controller id. +type ControllerID string + +const ( + // ControllerIDController0 specifies the controller id controller 0 state + // for controller id. + ControllerIDController0 ControllerID = "Controller0" + // ControllerIDController1 specifies the controller id controller 1 state + // for controller id. + ControllerIDController1 ControllerID = "Controller1" + // ControllerIDNone specifies the controller id none state for controller + // id. + ControllerIDNone ControllerID = "None" + // ControllerIDUnknown specifies the controller id unknown state for + // controller id. + ControllerIDUnknown ControllerID = "Unknown" +) + +// ControllerPowerStateAction enumerates the values for controller power state +// action. +type ControllerPowerStateAction string + +const ( + // Restart specifies the restart state for controller power state action. + Restart ControllerPowerStateAction = "Restart" + // Shutdown specifies the shutdown state for controller power state action. + Shutdown ControllerPowerStateAction = "Shutdown" + // Start specifies the start state for controller power state action. + Start ControllerPowerStateAction = "Start" +) + +// ControllerStatus enumerates the values for controller status. +type ControllerStatus string + +const ( + // ControllerStatusFailure specifies the controller status failure state + // for controller status. + ControllerStatusFailure ControllerStatus = "Failure" + // ControllerStatusNotPresent specifies the controller status not present + // state for controller status. + ControllerStatusNotPresent ControllerStatus = "NotPresent" + // ControllerStatusOk specifies the controller status ok state for + // controller status. + ControllerStatusOk ControllerStatus = "Ok" + // ControllerStatusPoweredOff specifies the controller status powered off + // state for controller status. + ControllerStatusPoweredOff ControllerStatus = "PoweredOff" + // ControllerStatusRecovering specifies the controller status recovering + // state for controller status. + ControllerStatusRecovering ControllerStatus = "Recovering" + // ControllerStatusWarning specifies the controller status warning state + // for controller status. + ControllerStatusWarning ControllerStatus = "Warning" +) + +// DayOfWeek enumerates the values for day of week. +type DayOfWeek string + +const ( + // Friday specifies the friday state for day of week. + Friday DayOfWeek = "Friday" + // Monday specifies the monday state for day of week. + Monday DayOfWeek = "Monday" + // Saturday specifies the saturday state for day of week. + Saturday DayOfWeek = "Saturday" + // Sunday specifies the sunday state for day of week. + Sunday DayOfWeek = "Sunday" + // Thursday specifies the thursday state for day of week. + Thursday DayOfWeek = "Thursday" + // Tuesday specifies the tuesday state for day of week. + Tuesday DayOfWeek = "Tuesday" + // Wednesday specifies the wednesday state for day of week. + Wednesday DayOfWeek = "Wednesday" +) + +// DeviceConfigurationStatus enumerates the values for device configuration +// status. +type DeviceConfigurationStatus string + +const ( + // Complete specifies the complete state for device configuration status. + Complete DeviceConfigurationStatus = "Complete" + // Pending specifies the pending state for device configuration status. + Pending DeviceConfigurationStatus = "Pending" +) + +// DeviceStatus enumerates the values for device status. +type DeviceStatus string + +const ( + // Creating specifies the creating state for device status. + Creating DeviceStatus = "Creating" + // Deactivated specifies the deactivated state for device status. + Deactivated DeviceStatus = "Deactivated" + // Deactivating specifies the deactivating state for device status. + Deactivating DeviceStatus = "Deactivating" + // Deleted specifies the deleted state for device status. + Deleted DeviceStatus = "Deleted" + // MaintenanceMode specifies the maintenance mode state for device status. + MaintenanceMode DeviceStatus = "MaintenanceMode" + // Offline specifies the offline state for device status. + Offline DeviceStatus = "Offline" + // Online specifies the online state for device status. + Online DeviceStatus = "Online" + // Provisioning specifies the provisioning state for device status. + Provisioning DeviceStatus = "Provisioning" + // ReadyToSetup specifies the ready to setup state for device status. + ReadyToSetup DeviceStatus = "ReadyToSetup" + // RequiresAttention specifies the requires attention state for device + // status. + RequiresAttention DeviceStatus = "RequiresAttention" + // Unknown specifies the unknown state for device status. + Unknown DeviceStatus = "Unknown" +) + +// DeviceType enumerates the values for device type. +type DeviceType string + +const ( + // DeviceTypeInvalid specifies the device type invalid state for device + // type. + DeviceTypeInvalid DeviceType = "Invalid" + // DeviceTypeSeries8000PhysicalAppliance specifies the device type series + // 8000 physical appliance state for device type. + DeviceTypeSeries8000PhysicalAppliance DeviceType = "Series8000PhysicalAppliance" + // DeviceTypeSeries8000VirtualAppliance specifies the device type series + // 8000 virtual appliance state for device type. + DeviceTypeSeries8000VirtualAppliance DeviceType = "Series8000VirtualAppliance" +) + +// EncryptionAlgorithm enumerates the values for encryption algorithm. +type EncryptionAlgorithm string + +const ( + // EncryptionAlgorithmAES256 specifies the encryption algorithm aes256 + // state for encryption algorithm. + EncryptionAlgorithmAES256 EncryptionAlgorithm = "AES256" + // EncryptionAlgorithmNone specifies the encryption algorithm none state + // for encryption algorithm. + EncryptionAlgorithmNone EncryptionAlgorithm = "None" + // EncryptionAlgorithmRSAESPKCS1V15 specifies the encryption algorithm + // rsaespkcs1v15 state for encryption algorithm. + EncryptionAlgorithmRSAESPKCS1V15 EncryptionAlgorithm = "RSAES_PKCS1_v_1_5" +) + +// EncryptionStatus enumerates the values for encryption status. +type EncryptionStatus string + +const ( + // EncryptionStatusDisabled specifies the encryption status disabled state + // for encryption status. + EncryptionStatusDisabled EncryptionStatus = "Disabled" + // EncryptionStatusEnabled specifies the encryption status enabled state + // for encryption status. + EncryptionStatusEnabled EncryptionStatus = "Enabled" +) + +// FeatureSupportStatus enumerates the values for feature support status. +type FeatureSupportStatus string + +const ( + // NotAvailable specifies the not available state for feature support + // status. + NotAvailable FeatureSupportStatus = "NotAvailable" + // Supported specifies the supported state for feature support status. + Supported FeatureSupportStatus = "Supported" + // UnsupportedDeviceVersion specifies the unsupported device version state + // for feature support status. + UnsupportedDeviceVersion FeatureSupportStatus = "UnsupportedDeviceVersion" +) + +// HardwareComponentStatus enumerates the values for hardware component status. +type HardwareComponentStatus string + +const ( + // HardwareComponentStatusFailure specifies the hardware component status + // failure state for hardware component status. + HardwareComponentStatusFailure HardwareComponentStatus = "Failure" + // HardwareComponentStatusNotPresent specifies the hardware component + // status not present state for hardware component status. + HardwareComponentStatusNotPresent HardwareComponentStatus = "NotPresent" + // HardwareComponentStatusOk specifies the hardware component status ok + // state for hardware component status. + HardwareComponentStatusOk HardwareComponentStatus = "Ok" + // HardwareComponentStatusPoweredOff specifies the hardware component + // status powered off state for hardware component status. + HardwareComponentStatusPoweredOff HardwareComponentStatus = "PoweredOff" + // HardwareComponentStatusRecovering specifies the hardware component + // status recovering state for hardware component status. + HardwareComponentStatusRecovering HardwareComponentStatus = "Recovering" + // HardwareComponentStatusUnknown specifies the hardware component status + // unknown state for hardware component status. + HardwareComponentStatusUnknown HardwareComponentStatus = "Unknown" + // HardwareComponentStatusWarning specifies the hardware component status + // warning state for hardware component status. + HardwareComponentStatusWarning HardwareComponentStatus = "Warning" +) + +// InEligibilityCategory enumerates the values for in eligibility category. +type InEligibilityCategory string + +const ( + // DeviceNotOnline specifies the device not online state for in eligibility + // category. + DeviceNotOnline InEligibilityCategory = "DeviceNotOnline" + // NotSupportedAppliance specifies the not supported appliance state for in + // eligibility category. + NotSupportedAppliance InEligibilityCategory = "NotSupportedAppliance" + // RolloverPending specifies the rollover pending state for in eligibility + // category. + RolloverPending InEligibilityCategory = "RolloverPending" +) + +// ISCSIAndCloudStatus enumerates the values for iscsi and cloud status. +type ISCSIAndCloudStatus string + +const ( + // ISCSIAndCloudStatusCloudEnabled specifies the iscsi and cloud status + // cloud enabled state for iscsi and cloud status. + ISCSIAndCloudStatusCloudEnabled ISCSIAndCloudStatus = "CloudEnabled" + // ISCSIAndCloudStatusDisabled specifies the iscsi and cloud status + // disabled state for iscsi and cloud status. + ISCSIAndCloudStatusDisabled ISCSIAndCloudStatus = "Disabled" + // ISCSIAndCloudStatusIscsiAndCloudEnabled specifies the iscsi and cloud + // status iscsi and cloud enabled state for iscsi and cloud status. + ISCSIAndCloudStatusIscsiAndCloudEnabled ISCSIAndCloudStatus = "IscsiAndCloudEnabled" + // ISCSIAndCloudStatusIscsiEnabled specifies the iscsi and cloud status + // iscsi enabled state for iscsi and cloud status. + ISCSIAndCloudStatusIscsiEnabled ISCSIAndCloudStatus = "IscsiEnabled" +) + +// JobStatus enumerates the values for job status. +type JobStatus string + +const ( + // Canceled specifies the canceled state for job status. + Canceled JobStatus = "Canceled" + // Failed specifies the failed state for job status. + Failed JobStatus = "Failed" + // Running specifies the running state for job status. + Running JobStatus = "Running" + // Succeeded specifies the succeeded state for job status. + Succeeded JobStatus = "Succeeded" +) + +// JobType enumerates the values for job type. +type JobType string + +const ( + // CloneVolume specifies the clone volume state for job type. + CloneVolume JobType = "CloneVolume" + // CreateCloudAppliance specifies the create cloud appliance state for job + // type. + CreateCloudAppliance JobType = "CreateCloudAppliance" + // CreateLocallyPinnedVolume specifies the create locally pinned volume + // state for job type. + CreateLocallyPinnedVolume JobType = "CreateLocallyPinnedVolume" + // FailoverVolumeContainers specifies the failover volume containers state + // for job type. + FailoverVolumeContainers JobType = "FailoverVolumeContainers" + // InstallUpdates specifies the install updates state for job type. + InstallUpdates JobType = "InstallUpdates" + // ManualBackup specifies the manual backup state for job type. + ManualBackup JobType = "ManualBackup" + // ModifyVolume specifies the modify volume state for job type. + ModifyVolume JobType = "ModifyVolume" + // RestoreBackup specifies the restore backup state for job type. + RestoreBackup JobType = "RestoreBackup" + // ScheduledBackup specifies the scheduled backup state for job type. + ScheduledBackup JobType = "ScheduledBackup" + // SupportPackageLogs specifies the support package logs state for job + // type. + SupportPackageLogs JobType = "SupportPackageLogs" +) + +// KeyRolloverStatus enumerates the values for key rollover status. +type KeyRolloverStatus string + +const ( + // NotRequired specifies the not required state for key rollover status. + NotRequired KeyRolloverStatus = "NotRequired" + // Required specifies the required state for key rollover status. + Required KeyRolloverStatus = "Required" +) + +// Kind enumerates the values for kind. +type Kind string + +const ( + // Series8000 specifies the series 8000 state for kind. + Series8000 Kind = "Series8000" +) + +// ManagerType enumerates the values for manager type. +type ManagerType string + +const ( + // GardaV1 specifies the garda v1 state for manager type. + GardaV1 ManagerType = "GardaV1" + // HelsinkiV1 specifies the helsinki v1 state for manager type. + HelsinkiV1 ManagerType = "HelsinkiV1" +) + +// MetricAggregationType enumerates the values for metric aggregation type. +type MetricAggregationType string + +const ( + // MetricAggregationTypeAverage specifies the metric aggregation type + // average state for metric aggregation type. + MetricAggregationTypeAverage MetricAggregationType = "Average" + // MetricAggregationTypeLast specifies the metric aggregation type last + // state for metric aggregation type. + MetricAggregationTypeLast MetricAggregationType = "Last" + // MetricAggregationTypeMaximum specifies the metric aggregation type + // maximum state for metric aggregation type. + MetricAggregationTypeMaximum MetricAggregationType = "Maximum" + // MetricAggregationTypeMinimum specifies the metric aggregation type + // minimum state for metric aggregation type. + MetricAggregationTypeMinimum MetricAggregationType = "Minimum" + // MetricAggregationTypeNone specifies the metric aggregation type none + // state for metric aggregation type. + MetricAggregationTypeNone MetricAggregationType = "None" + // MetricAggregationTypeTotal specifies the metric aggregation type total + // state for metric aggregation type. + MetricAggregationTypeTotal MetricAggregationType = "Total" +) + +// MetricUnit enumerates the values for metric unit. +type MetricUnit string + +const ( + // Bytes specifies the bytes state for metric unit. + Bytes MetricUnit = "Bytes" + // BytesPerSecond specifies the bytes per second state for metric unit. + BytesPerSecond MetricUnit = "BytesPerSecond" + // Count specifies the count state for metric unit. + Count MetricUnit = "Count" + // CountPerSecond specifies the count per second state for metric unit. + CountPerSecond MetricUnit = "CountPerSecond" + // Percent specifies the percent state for metric unit. + Percent MetricUnit = "Percent" + // Seconds specifies the seconds state for metric unit. + Seconds MetricUnit = "Seconds" +) + +// MonitoringStatus enumerates the values for monitoring status. +type MonitoringStatus string + +const ( + // MonitoringStatusDisabled specifies the monitoring status disabled state + // for monitoring status. + MonitoringStatusDisabled MonitoringStatus = "Disabled" + // MonitoringStatusEnabled specifies the monitoring status enabled state + // for monitoring status. + MonitoringStatusEnabled MonitoringStatus = "Enabled" +) + +// NetInterfaceID enumerates the values for net interface id. +type NetInterfaceID string + +const ( + // NetInterfaceIDData0 specifies the net interface id data 0 state for net + // interface id. + NetInterfaceIDData0 NetInterfaceID = "Data0" + // NetInterfaceIDData1 specifies the net interface id data 1 state for net + // interface id. + NetInterfaceIDData1 NetInterfaceID = "Data1" + // NetInterfaceIDData2 specifies the net interface id data 2 state for net + // interface id. + NetInterfaceIDData2 NetInterfaceID = "Data2" + // NetInterfaceIDData3 specifies the net interface id data 3 state for net + // interface id. + NetInterfaceIDData3 NetInterfaceID = "Data3" + // NetInterfaceIDData4 specifies the net interface id data 4 state for net + // interface id. + NetInterfaceIDData4 NetInterfaceID = "Data4" + // NetInterfaceIDData5 specifies the net interface id data 5 state for net + // interface id. + NetInterfaceIDData5 NetInterfaceID = "Data5" + // NetInterfaceIDInvalid specifies the net interface id invalid state for + // net interface id. + NetInterfaceIDInvalid NetInterfaceID = "Invalid" +) + +// NetInterfaceStatus enumerates the values for net interface status. +type NetInterfaceStatus string + +const ( + // NetInterfaceStatusDisabled specifies the net interface status disabled + // state for net interface status. + NetInterfaceStatusDisabled NetInterfaceStatus = "Disabled" + // NetInterfaceStatusEnabled specifies the net interface status enabled + // state for net interface status. + NetInterfaceStatusEnabled NetInterfaceStatus = "Enabled" +) + +// NetworkMode enumerates the values for network mode. +type NetworkMode string + +const ( + // NetworkModeBOTH specifies the network mode both state for network mode. + NetworkModeBOTH NetworkMode = "BOTH" + // NetworkModeInvalid specifies the network mode invalid state for network + // mode. + NetworkModeInvalid NetworkMode = "Invalid" + // NetworkModeIPV4 specifies the network mode ipv4 state for network mode. + NetworkModeIPV4 NetworkMode = "IPV4" + // NetworkModeIPV6 specifies the network mode ipv6 state for network mode. + NetworkModeIPV6 NetworkMode = "IPV6" +) + +// OperationStatus enumerates the values for operation status. +type OperationStatus string + +const ( + // OperationStatusDeleting specifies the operation status deleting state + // for operation status. + OperationStatusDeleting OperationStatus = "Deleting" + // OperationStatusNone specifies the operation status none state for + // operation status. + OperationStatusNone OperationStatus = "None" + // OperationStatusRestoring specifies the operation status restoring state + // for operation status. + OperationStatusRestoring OperationStatus = "Restoring" + // OperationStatusUpdating specifies the operation status updating state + // for operation status. + OperationStatusUpdating OperationStatus = "Updating" +) + +// OwnerShipStatus enumerates the values for owner ship status. +type OwnerShipStatus string + +const ( + // NotOwned specifies the not owned state for owner ship status. + NotOwned OwnerShipStatus = "NotOwned" + // Owned specifies the owned state for owner ship status. + Owned OwnerShipStatus = "Owned" +) + +// RecurrenceType enumerates the values for recurrence type. +type RecurrenceType string + +const ( + // Daily specifies the daily state for recurrence type. + Daily RecurrenceType = "Daily" + // Hourly specifies the hourly state for recurrence type. + Hourly RecurrenceType = "Hourly" + // Minutes specifies the minutes state for recurrence type. + Minutes RecurrenceType = "Minutes" + // Weekly specifies the weekly state for recurrence type. + Weekly RecurrenceType = "Weekly" +) + +// RemoteManagementModeConfiguration enumerates the values for remote +// management mode configuration. +type RemoteManagementModeConfiguration string + +const ( + // RemoteManagementModeConfigurationDisabled specifies the remote + // management mode configuration disabled state for remote management mode + // configuration. + RemoteManagementModeConfigurationDisabled RemoteManagementModeConfiguration = "Disabled" + // RemoteManagementModeConfigurationHTTPSAndHTTPEnabled specifies the + // remote management mode configuration https and http enabled state for + // remote management mode configuration. + RemoteManagementModeConfigurationHTTPSAndHTTPEnabled RemoteManagementModeConfiguration = "HttpsAndHttpEnabled" + // RemoteManagementModeConfigurationHTTPSEnabled specifies the remote + // management mode configuration https enabled state for remote management + // mode configuration. + RemoteManagementModeConfigurationHTTPSEnabled RemoteManagementModeConfiguration = "HttpsEnabled" + // RemoteManagementModeConfigurationUnknown specifies the remote management + // mode configuration unknown state for remote management mode + // configuration. + RemoteManagementModeConfigurationUnknown RemoteManagementModeConfiguration = "Unknown" +) + +// ScheduledBackupStatus enumerates the values for scheduled backup status. +type ScheduledBackupStatus string + +const ( + // ScheduledBackupStatusDisabled specifies the scheduled backup status + // disabled state for scheduled backup status. + ScheduledBackupStatusDisabled ScheduledBackupStatus = "Disabled" + // ScheduledBackupStatusEnabled specifies the scheduled backup status + // enabled state for scheduled backup status. + ScheduledBackupStatusEnabled ScheduledBackupStatus = "Enabled" +) + +// ScheduleStatus enumerates the values for schedule status. +type ScheduleStatus string + +const ( + // ScheduleStatusDisabled specifies the schedule status disabled state for + // schedule status. + ScheduleStatusDisabled ScheduleStatus = "Disabled" + // ScheduleStatusEnabled specifies the schedule status enabled state for + // schedule status. + ScheduleStatusEnabled ScheduleStatus = "Enabled" +) + +// SslStatus enumerates the values for ssl status. +type SslStatus string + +const ( + // SslStatusDisabled specifies the ssl status disabled state for ssl + // status. + SslStatusDisabled SslStatus = "Disabled" + // SslStatusEnabled specifies the ssl status enabled state for ssl status. + SslStatusEnabled SslStatus = "Enabled" +) + +// TargetEligibilityResultCode enumerates the values for target eligibility +// result code. +type TargetEligibilityResultCode string + +const ( + // LocalToTieredVolumesConversionWarning specifies the local to tiered + // volumes conversion warning state for target eligibility result code. + LocalToTieredVolumesConversionWarning TargetEligibilityResultCode = "LocalToTieredVolumesConversionWarning" + // TargetAndSourceCannotBeSameError specifies the target and source cannot + // be same error state for target eligibility result code. + TargetAndSourceCannotBeSameError TargetEligibilityResultCode = "TargetAndSourceCannotBeSameError" + // TargetInsufficientCapacityError specifies the target insufficient + // capacity error state for target eligibility result code. + TargetInsufficientCapacityError TargetEligibilityResultCode = "TargetInsufficientCapacityError" + // TargetInsufficientLocalVolumeMemoryError specifies the target + // insufficient local volume memory error state for target eligibility + // result code. + TargetInsufficientLocalVolumeMemoryError TargetEligibilityResultCode = "TargetInsufficientLocalVolumeMemoryError" + // TargetInsufficientTieredVolumeMemoryError specifies the target + // insufficient tiered volume memory error state for target eligibility + // result code. + TargetInsufficientTieredVolumeMemoryError TargetEligibilityResultCode = "TargetInsufficientTieredVolumeMemoryError" + // TargetIsNotOnlineError specifies the target is not online error state + // for target eligibility result code. + TargetIsNotOnlineError TargetEligibilityResultCode = "TargetIsNotOnlineError" + // TargetSourceIncompatibleVersionError specifies the target source + // incompatible version error state for target eligibility result code. + TargetSourceIncompatibleVersionError TargetEligibilityResultCode = "TargetSourceIncompatibleVersionError" +) + +// TargetEligibilityStatus enumerates the values for target eligibility status. +type TargetEligibilityStatus string + +const ( + // TargetEligibilityStatusEligible specifies the target eligibility status + // eligible state for target eligibility status. + TargetEligibilityStatusEligible TargetEligibilityStatus = "Eligible" + // TargetEligibilityStatusNotEligible specifies the target eligibility + // status not eligible state for target eligibility status. + TargetEligibilityStatusNotEligible TargetEligibilityStatus = "NotEligible" +) + +// VirtualMachineAPIType enumerates the values for virtual machine api type. +type VirtualMachineAPIType string + +const ( + // Arm specifies the arm state for virtual machine api type. + Arm VirtualMachineAPIType = "Arm" + // Classic specifies the classic state for virtual machine api type. + Classic VirtualMachineAPIType = "Classic" +) + +// VolumeStatus enumerates the values for volume status. +type VolumeStatus string + +const ( + // VolumeStatusOffline specifies the volume status offline state for volume + // status. + VolumeStatusOffline VolumeStatus = "Offline" + // VolumeStatusOnline specifies the volume status online state for volume + // status. + VolumeStatusOnline VolumeStatus = "Online" +) + +// VolumeType enumerates the values for volume type. +type VolumeType string + +const ( + // Archival specifies the archival state for volume type. + Archival VolumeType = "Archival" + // LocallyPinned specifies the locally pinned state for volume type. + LocallyPinned VolumeType = "LocallyPinned" + // Tiered specifies the tiered state for volume type. + Tiered VolumeType = "Tiered" +) + +// AccessControlRecord is the access control record. +type AccessControlRecord struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *AccessControlRecordProperties `json:"properties,omitempty"` +} + +// AccessControlRecordList is the collection of access control records. +type AccessControlRecordList struct { + autorest.Response `json:"-"` + Value *[]AccessControlRecord `json:"value,omitempty"` +} + +// AccessControlRecordProperties is the properties of access control record. +type AccessControlRecordProperties struct { + InitiatorName *string `json:"initiatorName,omitempty"` + VolumeCount *int32 `json:"volumeCount,omitempty"` +} + +// AcsConfiguration is the ACS configuration. +type AcsConfiguration struct { + Namespace *string `json:"namespace,omitempty"` + Realm *string `json:"realm,omitempty"` + ServiceURL *string `json:"serviceUrl,omitempty"` +} + +// Alert is the alert. +type Alert struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *AlertProperties `json:"properties,omitempty"` +} + +// AlertErrorDetails is the details of the error for which the alert was raised +type AlertErrorDetails struct { + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Occurences *int32 `json:"occurences,omitempty"` +} + +// AlertFilter is the OData filters to be used for Alert +type AlertFilter struct { + Status AlertStatus `json:"status,omitempty"` + Severity AlertSeverity `json:"severity,omitempty"` + SourceType AlertSourceType `json:"sourceType,omitempty"` + SourceName *string `json:"sourceName,omitempty"` + AppearedOnTime *date.Time `json:"appearedOnTime,omitempty"` +} + +// AlertList is the collection of alerts. +type AlertList struct { + autorest.Response `json:"-"` + Value *[]Alert `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// AlertListPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client AlertList) AlertListPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// AlertNotificationProperties is the properties of the alert notification +// settings. +type AlertNotificationProperties struct { + EmailNotification AlertEmailNotificationStatus `json:"emailNotification,omitempty"` + AlertNotificationCulture *string `json:"alertNotificationCulture,omitempty"` + NotificationToServiceOwners AlertEmailNotificationStatus `json:"notificationToServiceOwners,omitempty"` + AdditionalRecipientEmailList *[]string `json:"additionalRecipientEmailList,omitempty"` +} + +// AlertProperties is the properties of alert +type AlertProperties struct { + Title *string `json:"title,omitempty"` + Scope AlertScope `json:"scope,omitempty"` + AlertType *string `json:"alertType,omitempty"` + AppearedAtTime *date.Time `json:"appearedAtTime,omitempty"` + AppearedAtSourceTime *date.Time `json:"appearedAtSourceTime,omitempty"` + ClearedAtTime *date.Time `json:"clearedAtTime,omitempty"` + ClearedAtSourceTime *date.Time `json:"clearedAtSourceTime,omitempty"` + Source *AlertSource `json:"source,omitempty"` + Recommendation *string `json:"recommendation,omitempty"` + ResolutionReason *string `json:"resolutionReason,omitempty"` + Severity AlertSeverity `json:"severity,omitempty"` + Status AlertStatus `json:"status,omitempty"` + ErrorDetails *AlertErrorDetails `json:"errorDetails,omitempty"` + DetailedInformation *map[string]*string `json:"detailedInformation,omitempty"` +} + +// AlertSettings is the alert settings. +type AlertSettings struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *AlertNotificationProperties `json:"properties,omitempty"` +} + +// AlertSource is the source details at which the alert was raised +type AlertSource struct { + Name *string `json:"name,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + AlertSourceType AlertSourceType `json:"alertSourceType,omitempty"` +} + +// AsymmetricEncryptedSecret is represent the secrets intended for encryption +// with asymmetric key pair. +type AsymmetricEncryptedSecret struct { + Value *string `json:"value,omitempty"` + EncryptionCertThumbprint *string `json:"encryptionCertThumbprint,omitempty"` + EncryptionAlgorithm EncryptionAlgorithm `json:"encryptionAlgorithm,omitempty"` +} + +// AvailableProviderOperation is represents available provider operation. +type AvailableProviderOperation struct { + Name *string `json:"name,omitempty"` + Display *AvailableProviderOperationDisplay `json:"display,omitempty"` + Origin *string `json:"origin,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +// AvailableProviderOperationDisplay is contains the localized display +// information for this particular operation/action. These value will be used +// by several clients for (a) custom role definitions for RBAC, (b) complex +// query filters for the event service and (c) audit history/records for +// management operations. +type AvailableProviderOperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` + Description *string `json:"description,omitempty"` +} + +// AvailableProviderOperationList is list of available provider operations. +type AvailableProviderOperationList struct { + autorest.Response `json:"-"` + Value *[]AvailableProviderOperation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// AvailableProviderOperationListPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client AvailableProviderOperationList) AvailableProviderOperationListPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// Backup is the backup. +type Backup struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *BackupProperties `json:"properties,omitempty"` +} + +// BackupElement is the backup element. +type BackupElement struct { + ElementID *string `json:"elementId,omitempty"` + ElementName *string `json:"elementName,omitempty"` + ElementType *string `json:"elementType,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` + VolumeContainerID *string `json:"volumeContainerId,omitempty"` + VolumeType VolumeType `json:"volumeType,omitempty"` +} + +// BackupFilter is the OData filters to be used for backups. +type BackupFilter struct { + BackupPolicyID *string `json:"backupPolicyId,omitempty"` + VolumeID *string `json:"volumeId,omitempty"` + CreatedTime *date.Time `json:"createdTime,omitempty"` +} + +// BackupList is the collection of backups. +type BackupList struct { + autorest.Response `json:"-"` + Value *[]Backup `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// BackupListPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client BackupList) BackupListPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// BackupPolicy is the backup policy. +type BackupPolicy struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *BackupPolicyProperties `json:"properties,omitempty"` +} + +// BackupPolicyList is the collection of backup policies. +type BackupPolicyList struct { + autorest.Response `json:"-"` + Value *[]BackupPolicy `json:"value,omitempty"` +} + +// BackupPolicyProperties is the properties of the backup policy. +type BackupPolicyProperties struct { + VolumeIds *[]string `json:"volumeIds,omitempty"` + NextBackupTime *date.Time `json:"nextBackupTime,omitempty"` + LastBackupTime *date.Time `json:"lastBackupTime,omitempty"` + SchedulesCount *int64 `json:"schedulesCount,omitempty"` + ScheduledBackupStatus ScheduledBackupStatus `json:"scheduledBackupStatus,omitempty"` + BackupPolicyCreationType BackupPolicyCreationType `json:"backupPolicyCreationType,omitempty"` + SsmHostName *string `json:"ssmHostName,omitempty"` +} + +// BackupProperties is the properties of the backup. +type BackupProperties struct { + CreatedOn *date.Time `json:"createdOn,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + BackupType BackupType `json:"backupType,omitempty"` + BackupJobCreationType BackupJobCreationType `json:"backupJobCreationType,omitempty"` + BackupPolicyID *string `json:"backupPolicyId,omitempty"` + SsmHostName *string `json:"ssmHostName,omitempty"` + Elements *[]BackupElement `json:"elements,omitempty"` +} + +// BackupSchedule is the backup schedule. +type BackupSchedule struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *BackupScheduleProperties `json:"properties,omitempty"` +} + +// BackupScheduleList is the backup schedule list. +type BackupScheduleList struct { + autorest.Response `json:"-"` + Value *[]BackupSchedule `json:"value,omitempty"` +} + +// BackupScheduleProperties is the properties of the backup schedule. +type BackupScheduleProperties struct { + ScheduleRecurrence *ScheduleRecurrence `json:"scheduleRecurrence,omitempty"` + BackupType BackupType `json:"backupType,omitempty"` + RetentionCount *int64 `json:"retentionCount,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + ScheduleStatus ScheduleStatus `json:"scheduleStatus,omitempty"` + LastSuccessfulRun *date.Time `json:"lastSuccessfulRun,omitempty"` +} + +// BandwidthRateSettingProperties is the properties of the bandwidth setting. +type BandwidthRateSettingProperties struct { + Schedules *[]BandwidthSchedule `json:"schedules,omitempty"` + VolumeCount *int32 `json:"volumeCount,omitempty"` +} + +// BandwidthSchedule is the schedule for bandwidth setting. +type BandwidthSchedule struct { + Start *Time `json:"start,omitempty"` + Stop *Time `json:"stop,omitempty"` + RateInMbps *int32 `json:"rateInMbps,omitempty"` + Days *[]DayOfWeek `json:"days,omitempty"` +} + +// BandwidthSetting is the bandwidth setting. +type BandwidthSetting struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *BandwidthRateSettingProperties `json:"properties,omitempty"` +} + +// BandwidthSettingList is the collection of bandwidth setting entities. +type BandwidthSettingList struct { + autorest.Response `json:"-"` + Value *[]BandwidthSetting `json:"value,omitempty"` +} + +// BaseModel is represents the base class for all other ARM object models +type BaseModel struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` +} + +// ChapSettings is the Challenge-Handshake Authentication Protocol (CHAP) +// settings. +type ChapSettings struct { + InitiatorUser *string `json:"initiatorUser,omitempty"` + InitiatorSecret *AsymmetricEncryptedSecret `json:"initiatorSecret,omitempty"` + TargetUser *string `json:"targetUser,omitempty"` + TargetSecret *AsymmetricEncryptedSecret `json:"targetSecret,omitempty"` +} + +// ClearAlertRequest is the request for clearing the alert +type ClearAlertRequest struct { + ResolutionMessage *string `json:"resolutionMessage,omitempty"` + Alerts *[]string `json:"alerts,omitempty"` +} + +// CloneRequest is the clone job request. +type CloneRequest struct { + TargetDeviceID *string `json:"targetDeviceId,omitempty"` + TargetVolumeName *string `json:"targetVolumeName,omitempty"` + TargetAccessControlRecordIds *[]string `json:"targetAccessControlRecordIds,omitempty"` + BackupElement *BackupElement `json:"backupElement,omitempty"` +} + +// CloudAppliance is the cloud appliance. +type CloudAppliance struct { + Name *string `json:"name,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetRegion *string `json:"vnetRegion,omitempty"` + IsVnetDNSConfigured *bool `json:"isVnetDnsConfigured,omitempty"` + IsVnetExpressConfigured *bool `json:"isVnetExpressConfigured,omitempty"` + SubnetName *string `json:"subnetName,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + StorageAccountType *string `json:"storageAccountType,omitempty"` + VMType *string `json:"vmType,omitempty"` + VMImageName *string `json:"vmImageName,omitempty"` + ModelNumber *string `json:"modelNumber,omitempty"` +} + +// CloudApplianceConfiguration is the cloud appliance configuration +type CloudApplianceConfiguration struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *CloudApplianceConfigurationProperties `json:"properties,omitempty"` +} + +// CloudApplianceConfigurationList is the cloud appliance configuration list +type CloudApplianceConfigurationList struct { + autorest.Response `json:"-"` + Value *[]CloudApplianceConfiguration `json:"value,omitempty"` +} + +// CloudApplianceConfigurationProperties is the properties of cloud appliance +// configuration. +type CloudApplianceConfigurationProperties struct { + ModelNumber *string `json:"modelNumber,omitempty"` + CloudPlatform *string `json:"cloudPlatform,omitempty"` + AcsConfiguration *AcsConfiguration `json:"acsConfiguration,omitempty"` + SupportedStorageAccountTypes *[]string `json:"supportedStorageAccountTypes,omitempty"` + SupportedRegions *[]string `json:"supportedRegions,omitempty"` + SupportedVMTypes *[]string `json:"supportedVmTypes,omitempty"` + SupportedVMImages *[]VMImage `json:"supportedVmImages,omitempty"` +} + +// CloudApplianceSettings is the cloud appliance settings. +type CloudApplianceSettings struct { + ServiceDataEncryptionKey *AsymmetricEncryptedSecret `json:"serviceDataEncryptionKey,omitempty"` + ChannelIntegrityKey *AsymmetricEncryptedSecret `json:"channelIntegrityKey,omitempty"` +} + +// ConfigureDeviceRequest is the mandatory device configuration request. +type ConfigureDeviceRequest struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *ConfigureDeviceRequestProperties `json:"properties,omitempty"` +} + +// ConfigureDeviceRequestProperties is the properties of the configure device +// request. +type ConfigureDeviceRequestProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + CurrentDeviceName *string `json:"currentDeviceName,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + DNSSettings *SecondaryDNSSettings `json:"dnsSettings,omitempty"` + NetworkInterfaceData0Settings *NetworkInterfaceData0Settings `json:"networkInterfaceData0Settings,omitempty"` +} + +// ControllerPowerStateChangeRequest is the controller power state change +// request. +type ControllerPowerStateChangeRequest struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *ControllerPowerStateChangeRequestProperties `json:"properties,omitempty"` +} + +// ControllerPowerStateChangeRequestProperties is the properties of the +// controller power state change request. +type ControllerPowerStateChangeRequestProperties struct { + Action ControllerPowerStateAction `json:"action,omitempty"` + ActiveController ControllerID `json:"activeController,omitempty"` + Controller0State ControllerStatus `json:"controller0State,omitempty"` + Controller1State ControllerStatus `json:"controller1State,omitempty"` +} + +// DataStatistics is the additional details related to the data related +// statistics of a job. Currently applicable only for Backup, Clone and Restore +// jobs. +type DataStatistics struct { + TotalData *int64 `json:"totalData,omitempty"` + ProcessedData *int64 `json:"processedData,omitempty"` + CloudData *int64 `json:"cloudData,omitempty"` + Throughput *int64 `json:"throughput,omitempty"` +} + +// Device is the StorSimple device. +type Device struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *DeviceProperties `json:"properties,omitempty"` +} + +// DeviceDetails is the additional device details regarding the end point count +// and volume container count. +type DeviceDetails struct { + EndpointCount *int32 `json:"endpointCount,omitempty"` + VolumeContainerCount *int32 `json:"volumeContainerCount,omitempty"` +} + +// DeviceList is the collection of devices. +type DeviceList struct { + autorest.Response `json:"-"` + Value *[]Device `json:"value,omitempty"` +} + +// DevicePatch is the device patch. +type DevicePatch struct { + *DevicePatchProperties `json:"properties,omitempty"` +} + +// DevicePatchProperties is the properties of the device patch. +type DevicePatchProperties struct { + DeviceDescription *string `json:"deviceDescription,omitempty"` +} + +// DeviceProperties is the properties of the StorSimple device. +type DeviceProperties struct { + FriendlyName *string `json:"friendlyName,omitempty"` + ActivationTime *date.Time `json:"activationTime,omitempty"` + Culture *string `json:"culture,omitempty"` + DeviceDescription *string `json:"deviceDescription,omitempty"` + DeviceSoftwareVersion *string `json:"deviceSoftwareVersion,omitempty"` + FriendlySoftwareName *string `json:"friendlySoftwareName,omitempty"` + DeviceConfigurationStatus DeviceConfigurationStatus `json:"deviceConfigurationStatus,omitempty"` + TargetIqn *string `json:"targetIqn,omitempty"` + ModelDescription *string `json:"modelDescription,omitempty"` + Status DeviceStatus `json:"status,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + DeviceType DeviceType `json:"deviceType,omitempty"` + ActiveController ControllerID `json:"activeController,omitempty"` + FriendlySoftwareVersion *string `json:"friendlySoftwareVersion,omitempty"` + AvailableLocalStorageInBytes *int64 `json:"availableLocalStorageInBytes,omitempty"` + AvailableTieredStorageInBytes *int64 `json:"availableTieredStorageInBytes,omitempty"` + ProvisionedTieredStorageInBytes *int64 `json:"provisionedTieredStorageInBytes,omitempty"` + ProvisionedLocalStorageInBytes *int64 `json:"provisionedLocalStorageInBytes,omitempty"` + ProvisionedVolumeSizeInBytes *int64 `json:"provisionedVolumeSizeInBytes,omitempty"` + UsingStorageInBytes *int64 `json:"usingStorageInBytes,omitempty"` + TotalTieredStorageInBytes *int64 `json:"totalTieredStorageInBytes,omitempty"` + AgentGroupVersion *int32 `json:"agentGroupVersion,omitempty"` + NetworkInterfaceCardCount *int32 `json:"networkInterfaceCardCount,omitempty"` + DeviceLocation *string `json:"deviceLocation,omitempty"` + VirtualMachineAPIType VirtualMachineAPIType `json:"virtualMachineApiType,omitempty"` + Details *DeviceDetails `json:"details,omitempty"` + RolloverDetails *DeviceRolloverDetails `json:"rolloverDetails,omitempty"` +} + +// DeviceRolloverDetails is the additional device details for the service data +// encryption key rollover. +type DeviceRolloverDetails struct { + AuthorizationEligibility AuthorizationEligibility `json:"authorizationEligibility,omitempty"` + AuthorizationStatus AuthorizationStatus `json:"authorizationStatus,omitempty"` + InEligibilityReason InEligibilityCategory `json:"inEligibilityReason,omitempty"` +} + +// DimensionFilter is the dimension filter. +type DimensionFilter struct { + Name *string `json:"name,omitempty"` + Values *string `json:"values,omitempty"` +} + +// DNSSettings is the DNS(Domain Name Server) settings of a device. +type DNSSettings struct { + PrimaryDNSServer *string `json:"primaryDnsServer,omitempty"` + PrimaryIpv6DNSServer *string `json:"primaryIpv6DnsServer,omitempty"` + SecondaryDNSServers *[]string `json:"secondaryDnsServers,omitempty"` + SecondaryIpv6DNSServers *[]string `json:"secondaryIpv6DnsServers,omitempty"` +} + +// EncryptionSettings is the encryption settings. +type EncryptionSettings struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *EncryptionSettingsProperties `json:"properties,omitempty"` +} + +// EncryptionSettingsProperties is the properties of encryption settings. +type EncryptionSettingsProperties struct { + EncryptionStatus EncryptionStatus `json:"encryptionStatus,omitempty"` + KeyRolloverStatus KeyRolloverStatus `json:"keyRolloverStatus,omitempty"` +} + +// FailoverRequest is the request object for triggering a failover of volume +// containers, from a source device to a target device. +type FailoverRequest struct { + TargetDeviceID *string `json:"targetDeviceId,omitempty"` + VolumeContainers *[]string `json:"volumeContainers,omitempty"` +} + +// FailoverSet is the failover set on a device. +type FailoverSet struct { + VolumeContainers *[]VolumeContainerFailoverMetadata `json:"volumeContainers,omitempty"` + EligibilityResult *FailoverSetEligibilityResult `json:"eligibilityResult,omitempty"` +} + +// FailoverSetEligibilityResult is the eligibility result of failover set, for +// failover. +type FailoverSetEligibilityResult struct { + IsEligibleForFailover *bool `json:"isEligibleForFailover,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// FailoverSetsList is the list of failover sets. +type FailoverSetsList struct { + autorest.Response `json:"-"` + Value *[]FailoverSet `json:"value,omitempty"` +} + +// FailoverTarget is represents the eligibility of a device as a failover +// target device. +type FailoverTarget struct { + DeviceID *string `json:"deviceId,omitempty"` + DeviceStatus DeviceStatus `json:"deviceStatus,omitempty"` + ModelDescription *string `json:"modelDescription,omitempty"` + DeviceSoftwareVersion *string `json:"deviceSoftwareVersion,omitempty"` + DataContainersCount *int32 `json:"dataContainersCount,omitempty"` + VolumesCount *int32 `json:"volumesCount,omitempty"` + AvailableLocalStorageInBytes *int64 `json:"availableLocalStorageInBytes,omitempty"` + AvailableTieredStorageInBytes *int64 `json:"availableTieredStorageInBytes,omitempty"` + DeviceLocation *string `json:"deviceLocation,omitempty"` + FriendlyDeviceSoftwareVersion *string `json:"friendlyDeviceSoftwareVersion,omitempty"` + EligibilityResult *TargetEligibilityResult `json:"eligibilityResult,omitempty"` +} + +// FailoverTargetsList is the list of all devices in a resource and their +// eligibility status as a failover target device. +type FailoverTargetsList struct { + autorest.Response `json:"-"` + Value *[]FailoverTarget `json:"value,omitempty"` +} + +// Feature is the feature. +type Feature struct { + Name *string `json:"name,omitempty"` + Status FeatureSupportStatus `json:"status,omitempty"` +} + +// FeatureFilter is the OData filter to be used for features. +type FeatureFilter struct { + DeviceID *string `json:"deviceId,omitempty"` +} + +// FeatureList is the collections of features. +type FeatureList struct { + autorest.Response `json:"-"` + Value *[]Feature `json:"value,omitempty"` +} + +// HardwareComponent is the hardware component. +type HardwareComponent struct { + ComponentID *string `json:"componentId,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Status HardwareComponentStatus `json:"status,omitempty"` + StatusDisplayName *string `json:"statusDisplayName,omitempty"` +} + +// HardwareComponentGroup is the hardware component group. +type HardwareComponentGroup struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *HardwareComponentGroupProperties `json:"properties,omitempty"` +} + +// HardwareComponentGroupList is the collection of hardware component groups. +type HardwareComponentGroupList struct { + autorest.Response `json:"-"` + Value *[]HardwareComponentGroup `json:"value,omitempty"` +} + +// HardwareComponentGroupProperties is the properties of hardware component +// group. +type HardwareComponentGroupProperties struct { + DisplayName *string `json:"displayName,omitempty"` + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` + Components *[]HardwareComponent `json:"components,omitempty"` +} + +// Job is the job. +type Job struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + Status JobStatus `json:"status,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + PercentComplete *int32 `json:"percentComplete,omitempty"` + Error *JobErrorDetails `json:"error,omitempty"` + *JobProperties `json:"properties,omitempty"` +} + +// JobErrorDetails is the job error details. Contains list of job error items. +type JobErrorDetails struct { + ErrorDetails *[]JobErrorItem `json:"errorDetails,omitempty"` + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// JobErrorItem is the job error items. +type JobErrorItem struct { + Recommendations *[]string `json:"recommendations,omitempty"` + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// JobFilter is the OData filter to be used for jobs. +type JobFilter struct { + Status *string `json:"status,omitempty"` + JobType *string `json:"jobType,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` +} + +// JobList is the collection of jobs. +type JobList struct { + autorest.Response `json:"-"` + Value *[]Job `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// JobListPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client JobList) JobListPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// JobProperties is the properties of the job. +type JobProperties struct { + JobType JobType `json:"jobType,omitempty"` + DataStats *DataStatistics `json:"dataStats,omitempty"` + EntityLabel *string `json:"entityLabel,omitempty"` + EntityType *string `json:"entityType,omitempty"` + JobStages *[]JobStage `json:"jobStages,omitempty"` + DeviceID *string `json:"deviceId,omitempty"` + IsCancellable *bool `json:"isCancellable,omitempty"` + BackupType BackupType `json:"backupType,omitempty"` + SourceDeviceID *string `json:"sourceDeviceId,omitempty"` + BackupPointInTime *date.Time `json:"backupPointInTime,omitempty"` +} + +// JobStage is the details about the specific stage of a job. +type JobStage struct { + Message *string `json:"message,omitempty"` + StageStatus JobStatus `json:"stageStatus,omitempty"` + Detail *string `json:"detail,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` +} + +// Key is the key. +type Key struct { + autorest.Response `json:"-"` + ActivationKey *string `json:"activationKey,omitempty"` +} + +// ListFailoverTargetsRequest is the request object for fetching the list of +// failover targets (eligible devices for failover). +type ListFailoverTargetsRequest struct { + VolumeContainers *[]string `json:"volumeContainers,omitempty"` +} + +// Manager is the StorSimple Manager. +type Manager struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *ManagerProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// ManagerExtendedInfo is the extended info of the manager. +type ManagerExtendedInfo struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *ManagerExtendedInfoProperties `json:"properties,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// ManagerExtendedInfoProperties is the properties of the manager extended +// info. +type ManagerExtendedInfoProperties struct { + Version *string `json:"version,omitempty"` + IntegrityKey *string `json:"integrityKey,omitempty"` + EncryptionKey *string `json:"encryptionKey,omitempty"` + EncryptionKeyThumbprint *string `json:"encryptionKeyThumbprint,omitempty"` + PortalCertificateThumbprint *string `json:"portalCertificateThumbprint,omitempty"` + Algorithm *string `json:"algorithm,omitempty"` +} + +// ManagerIntrinsicSettings is intrinsic settings which refers to the type of +// the Storsimple Manager. +type ManagerIntrinsicSettings struct { + Type ManagerType `json:"type,omitempty"` +} + +// ManagerList is the list of StorSimple Managers. +type ManagerList struct { + autorest.Response `json:"-"` + Value *[]Manager `json:"value,omitempty"` +} + +// ManagerPatch is the StorSimple Manager patch. +type ManagerPatch struct { + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ManagerProperties is the properties of the StorSimple Manager. +type ManagerProperties struct { + CisIntrinsicSettings *ManagerIntrinsicSettings `json:"cisIntrinsicSettings,omitempty"` + Sku *ManagerSku `json:"sku,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// ManagerSku is the Sku. +type ManagerSku struct { + Name *string `json:"name,omitempty"` +} + +// MetricAvailablity is the metric availability. +type MetricAvailablity struct { + TimeGrain *string `json:"timeGrain,omitempty"` + Retention *string `json:"retention,omitempty"` +} + +// MetricData is the metric data. +type MetricData struct { + TimeStamp *date.Time `json:"timeStamp,omitempty"` + Sum *float64 `json:"sum,omitempty"` + Count *int32 `json:"count,omitempty"` + Average *float64 `json:"average,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` +} + +// MetricDefinition is the monitoring metric definition. +type MetricDefinition struct { + Name *MetricName `json:"name,omitempty"` + Unit MetricUnit `json:"unit,omitempty"` + PrimaryAggregationType MetricAggregationType `json:"primaryAggregationType,omitempty"` + ResourceID *string `json:"resourceId,omitempty"` + MetricAvailabilities *[]MetricAvailablity `json:"metricAvailabilities,omitempty"` + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + Category *string `json:"category,omitempty"` + Type *string `json:"type,omitempty"` +} + +// MetricDefinitionList is the list of metric definitions. +type MetricDefinitionList struct { + autorest.Response `json:"-"` + Value *[]MetricDefinition `json:"value,omitempty"` +} + +// MetricDimension is the metric dimension. It indicates the source of the +// metric. +type MetricDimension struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} + +// MetricFilter is the OData filters to be used for metrics. +type MetricFilter struct { + Name *MetricNameFilter `json:"name,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Category *string `json:"category,omitempty"` + Dimensions *DimensionFilter `json:"dimensions,omitempty"` +} + +// MetricList is the metric list. +type MetricList struct { + autorest.Response `json:"-"` + Value *[]Metrics `json:"value,omitempty"` +} + +// MetricName is the metric name. +type MetricName struct { + Value *string `json:"value,omitempty"` + LocalizedValue *string `json:"localizedValue,omitempty"` +} + +// MetricNameFilter is the metric name filter, specifying the name of the +// metric to be filtered on. +type MetricNameFilter struct { + Value *string `json:"value,omitempty"` +} + +// Metrics is the monitoring metric. +type Metrics struct { + ResourceID *string `json:"resourceId,omitempty"` + StartTime *date.Time `json:"startTime,omitempty"` + EndTime *date.Time `json:"endTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + PrimaryAggregation MetricAggregationType `json:"primaryAggregation,omitempty"` + Name *MetricName `json:"name,omitempty"` + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + Unit MetricUnit `json:"unit,omitempty"` + Type *string `json:"type,omitempty"` + Values *[]MetricData `json:"values,omitempty"` +} + +// NetworkAdapterList is the collection of network adapters on the device. +type NetworkAdapterList struct { + Value *[]NetworkAdapters `json:"value,omitempty"` +} + +// NetworkAdapters is represents the network adapter on device. +type NetworkAdapters struct { + InterfaceID NetInterfaceID `json:"interfaceId,omitempty"` + NetInterfaceStatus NetInterfaceStatus `json:"netInterfaceStatus,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IscsiAndCloudStatus ISCSIAndCloudStatus `json:"iscsiAndCloudStatus,omitempty"` + Speed *int64 `json:"speed,omitempty"` + Mode NetworkMode `json:"mode,omitempty"` + NicIpv4Settings *NicIPv4 `json:"nicIpv4Settings,omitempty"` + NicIpv6Settings *NicIPv6 `json:"nicIpv6Settings,omitempty"` +} + +// NetworkInterfaceData0Settings is the 'Data 0' network interface card +// settings. +type NetworkInterfaceData0Settings struct { + ControllerZeroIP *string `json:"controllerZeroIp,omitempty"` + ControllerOneIP *string `json:"controllerOneIp,omitempty"` +} + +// NetworkSettings is represents the network settings of a device. +type NetworkSettings struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *NetworkSettingsProperties `json:"properties,omitempty"` +} + +// NetworkSettingsPatch is represents the patch request for the network +// settings of a device. +type NetworkSettingsPatch struct { + *NetworkSettingsPatchProperties `json:"properties,omitempty"` +} + +// NetworkSettingsPatchProperties is the properties of the network settings +// patch. +type NetworkSettingsPatchProperties struct { + DNSSettings *DNSSettings `json:"dnsSettings,omitempty"` + NetworkAdapters *NetworkAdapterList `json:"networkAdapters,omitempty"` +} + +// NetworkSettingsProperties is the properties of the network settings of +// device. +type NetworkSettingsProperties struct { + DNSSettings *DNSSettings `json:"dnsSettings,omitempty"` + NetworkAdapters *NetworkAdapterList `json:"networkAdapters,omitempty"` + WebproxySettings *WebproxySettings `json:"webproxySettings,omitempty"` +} + +// NicIPv4 is details related to the IPv4 address configuration. +type NicIPv4 struct { + Ipv4Address *string `json:"ipv4Address,omitempty"` + Ipv4Netmask *string `json:"ipv4Netmask,omitempty"` + Ipv4Gateway *string `json:"ipv4Gateway,omitempty"` + Controller0Ipv4Address *string `json:"controller0Ipv4Address,omitempty"` + Controller1Ipv4Address *string `json:"controller1Ipv4Address,omitempty"` +} + +// NicIPv6 is details related to the IPv6 address configuration. +type NicIPv6 struct { + Ipv6Address *string `json:"ipv6Address,omitempty"` + Ipv6Prefix *string `json:"ipv6Prefix,omitempty"` + Ipv6Gateway *string `json:"ipv6Gateway,omitempty"` + Controller0Ipv6Address *string `json:"controller0Ipv6Address,omitempty"` + Controller1Ipv6Address *string `json:"controller1Ipv6Address,omitempty"` +} + +// PublicKey is the public key. +type PublicKey struct { + autorest.Response `json:"-"` + Key *string `json:"key,omitempty"` +} + +// RemoteManagementSettings is the settings for remote management of a device. +type RemoteManagementSettings struct { + RemoteManagementMode RemoteManagementModeConfiguration `json:"remoteManagementMode,omitempty"` + RemoteManagementCertificate *string `json:"remoteManagementCertificate,omitempty"` +} + +// RemoteManagementSettingsPatch is the settings for updating remote management +// mode of the device. +type RemoteManagementSettingsPatch struct { + RemoteManagementMode RemoteManagementModeConfiguration `json:"remoteManagementMode,omitempty"` +} + +// Resource is the Azure Resource. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ScheduleRecurrence is the schedule recurrence. +type ScheduleRecurrence struct { + RecurrenceType RecurrenceType `json:"recurrenceType,omitempty"` + RecurrenceValue *int32 `json:"recurrenceValue,omitempty"` + WeeklyDaysList *[]DayOfWeek `json:"weeklyDaysList,omitempty"` +} + +// SecondaryDNSSettings is the secondary DNS settings. +type SecondaryDNSSettings struct { + SecondaryDNSServers *[]string `json:"secondaryDnsServers,omitempty"` +} + +// SecuritySettings is the security settings of a device. +type SecuritySettings struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *SecuritySettingsProperties `json:"properties,omitempty"` +} + +// SecuritySettingsPatch is represents the patch request for the security +// settings of a device. +type SecuritySettingsPatch struct { + *SecuritySettingsPatchProperties `json:"properties,omitempty"` +} + +// SecuritySettingsPatchProperties is the properties of the security settings +// patch. +type SecuritySettingsPatchProperties struct { + RemoteManagementSettings *RemoteManagementSettingsPatch `json:"remoteManagementSettings,omitempty"` + DeviceAdminPassword *AsymmetricEncryptedSecret `json:"deviceAdminPassword,omitempty"` + SnapshotPassword *AsymmetricEncryptedSecret `json:"snapshotPassword,omitempty"` + ChapSettings *ChapSettings `json:"chapSettings,omitempty"` + CloudApplianceSettings *CloudApplianceSettings `json:"cloudApplianceSettings,omitempty"` +} + +// SecuritySettingsProperties is the properties of security settings of a +// device. +type SecuritySettingsProperties struct { + RemoteManagementSettings *RemoteManagementSettings `json:"remoteManagementSettings,omitempty"` + ChapSettings *ChapSettings `json:"chapSettings,omitempty"` +} + +// SendTestAlertEmailRequest is the request for sending test alert email +type SendTestAlertEmailRequest struct { + EmailList *[]string `json:"emailList,omitempty"` +} + +// StorageAccountCredential is the storage account credential. +type StorageAccountCredential struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *StorageAccountCredentialProperties `json:"properties,omitempty"` +} + +// StorageAccountCredentialList is the collection of storage account credential +// entities. +type StorageAccountCredentialList struct { + autorest.Response `json:"-"` + Value *[]StorageAccountCredential `json:"value,omitempty"` +} + +// StorageAccountCredentialProperties is the storage account credential +// properties. +type StorageAccountCredentialProperties struct { + EndPoint *string `json:"endPoint,omitempty"` + SslStatus SslStatus `json:"sslStatus,omitempty"` + AccessKey *AsymmetricEncryptedSecret `json:"accessKey,omitempty"` + VolumesCount *int32 `json:"volumesCount,omitempty"` +} + +// SymmetricEncryptedSecret is represents the secrets encrypted using Symmetric +// Encryption Key. +type SymmetricEncryptedSecret struct { + autorest.Response `json:"-"` + Value *string `json:"value,omitempty"` + ValueCertificateThumbprint *string `json:"valueCertificateThumbprint,omitempty"` + EncryptionAlgorithm EncryptionAlgorithm `json:"encryptionAlgorithm,omitempty"` +} + +// TargetEligibilityErrorMessage is the error/warning message due to which the +// device is ineligible as a failover target device. +type TargetEligibilityErrorMessage struct { + Message *string `json:"message,omitempty"` + Resolution *string `json:"resolution,omitempty"` + ResultCode TargetEligibilityResultCode `json:"resultCode,omitempty"` +} + +// TargetEligibilityResult is the eligibility result of device, as a failover +// target device. +type TargetEligibilityResult struct { + EligibilityStatus TargetEligibilityStatus `json:"eligibilityStatus,omitempty"` + Messages *[]TargetEligibilityErrorMessage `json:"messages,omitempty"` +} + +// Time is the time. +type Time struct { + Hours *int32 `json:"hours,omitempty"` + Minutes *int32 `json:"minutes,omitempty"` + Seconds *int32 `json:"seconds,omitempty"` +} + +// TimeSettings is the time settings of a device. +type TimeSettings struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *TimeSettingsProperties `json:"properties,omitempty"` +} + +// TimeSettingsProperties is the properties of time settings of a device. +type TimeSettingsProperties struct { + TimeZone *string `json:"timeZone,omitempty"` + PrimaryTimeServer *string `json:"primaryTimeServer,omitempty"` + SecondaryTimeServer *[]string `json:"secondaryTimeServer,omitempty"` +} + +// Updates is the updates profile of a device. +type Updates struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *UpdatesProperties `json:"properties,omitempty"` +} + +// UpdatesProperties is the properties of the updates profile. +type UpdatesProperties struct { + RegularUpdatesAvailable *bool `json:"regularUpdatesAvailable,omitempty"` + MaintenanceModeUpdatesAvailable *bool `json:"maintenanceModeUpdatesAvailable,omitempty"` + IsUpdateInProgress *bool `json:"isUpdateInProgress,omitempty"` + LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` +} + +// VMImage is the virtual machine image. +type VMImage struct { + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` + Offer *string `json:"offer,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Sku *string `json:"sku,omitempty"` +} + +// Volume is the volume. +type Volume struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *VolumeProperties `json:"properties,omitempty"` +} + +// VolumeContainer is the volume container. +type VolumeContainer struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Kind Kind `json:"kind,omitempty"` + *VolumeContainerProperties `json:"properties,omitempty"` +} + +// VolumeContainerFailoverMetadata is the metadata of the volume container, +// that is being considered as part of a failover set. +type VolumeContainerFailoverMetadata struct { + VolumeContainerID *string `json:"volumeContainerId,omitempty"` + Volumes *[]VolumeFailoverMetadata `json:"volumes,omitempty"` +} + +// VolumeContainerList is the collection of volume container entities. +type VolumeContainerList struct { + autorest.Response `json:"-"` + Value *[]VolumeContainer `json:"value,omitempty"` +} + +// VolumeContainerProperties is the properties of volume container. +type VolumeContainerProperties struct { + EncryptionKey *AsymmetricEncryptedSecret `json:"encryptionKey,omitempty"` + EncryptionStatus EncryptionStatus `json:"encryptionStatus,omitempty"` + VolumeCount *int32 `json:"volumeCount,omitempty"` + StorageAccountCredentialID *string `json:"storageAccountCredentialId,omitempty"` + OwnerShipStatus OwnerShipStatus `json:"ownerShipStatus,omitempty"` + BandWidthRateInMbps *int32 `json:"bandWidthRateInMbps,omitempty"` + BandwidthSettingID *string `json:"bandwidthSettingId,omitempty"` + TotalCloudStorageUsageInBytes *int64 `json:"totalCloudStorageUsageInBytes,omitempty"` +} + +// VolumeFailoverMetadata is the metadata of a volume that has valid cloud +// snapshot. +type VolumeFailoverMetadata struct { + VolumeID *string `json:"volumeId,omitempty"` + VolumeType VolumeType `json:"volumeType,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + BackupCreatedDate *date.Time `json:"backupCreatedDate,omitempty"` + BackupElementID *string `json:"backupElementId,omitempty"` + BackupID *string `json:"backupId,omitempty"` + BackupPolicyID *string `json:"backupPolicyId,omitempty"` +} + +// VolumeList is the collection of volumes. +type VolumeList struct { + autorest.Response `json:"-"` + Value *[]Volume `json:"value,omitempty"` +} + +// VolumeProperties is the properties of volume. +type VolumeProperties struct { + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + VolumeType VolumeType `json:"volumeType,omitempty"` + VolumeContainerID *string `json:"volumeContainerId,omitempty"` + AccessControlRecordIds *[]string `json:"accessControlRecordIds,omitempty"` + VolumeStatus VolumeStatus `json:"volumeStatus,omitempty"` + OperationStatus OperationStatus `json:"operationStatus,omitempty"` + BackupStatus BackupStatus `json:"backupStatus,omitempty"` + MonitoringStatus MonitoringStatus `json:"monitoringStatus,omitempty"` + BackupPolicyIds *[]string `json:"backupPolicyIds,omitempty"` +} + +// WebproxySettings is the web proxy settings on the device. +type WebproxySettings struct { + ConnectionURI *string `json:"connectionUri,omitempty"` + Authentication AuthenticationType `json:"authentication,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/operations.go new file mode 100644 index 0000000000..0fa27df73a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/operations.go @@ -0,0 +1,169 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the +// Storsimple8000series service. +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available REST API operations of the +// Microsoft.Storsimple provider +func (client OperationsClient) List() (result AvailableProviderOperationList, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.StorSimple/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result AvailableProviderOperationList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults AvailableProviderOperationList) (result AvailableProviderOperationList, err error) { + req, err := lastResults.AvailableProviderOperationListPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "storsimple8000series.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "storsimple8000series.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client OperationsClient) ListComplete(cancel <-chan struct{}) (<-chan AvailableProviderOperation, <-chan error) { + resultChan := make(chan AvailableProviderOperation) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/storageaccountcredentials.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/storageaccountcredentials.go new file mode 100644 index 0000000000..97f50a4868 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/storageaccountcredentials.go @@ -0,0 +1,389 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// StorageAccountCredentialsClient is the client for the +// StorageAccountCredentials methods of the Storsimple8000series service. +type StorageAccountCredentialsClient struct { + ManagementClient +} + +// NewStorageAccountCredentialsClient creates an instance of the +// StorageAccountCredentialsClient client. +func NewStorageAccountCredentialsClient(subscriptionID string) StorageAccountCredentialsClient { + return NewStorageAccountCredentialsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewStorageAccountCredentialsClientWithBaseURI creates an instance of the +// StorageAccountCredentialsClient client. +func NewStorageAccountCredentialsClientWithBaseURI(baseURI string, subscriptionID string) StorageAccountCredentialsClient { + return StorageAccountCredentialsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the storage account credential. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// storageAccountCredentialName is the storage account credential name. +// parameters is the storage account credential to be added or updated. +// resourceGroupName is the resource group name managerName is the manager name +func (client StorageAccountCredentialsClient) CreateOrUpdate(storageAccountCredentialName string, parameters StorageAccountCredential, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan StorageAccountCredential, <-chan error) { + resultChan := make(chan StorageAccountCredential, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.StorageAccountCredentialProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.StorageAccountCredentialProperties.EndPoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.StorageAccountCredentialProperties.AccessKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.StorageAccountCredentialProperties.AccessKey.Value", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.StorageAccountCredentialsClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result StorageAccountCredential + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(storageAccountCredentialName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client StorageAccountCredentialsClient) CreateOrUpdatePreparer(storageAccountCredentialName string, parameters StorageAccountCredential, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "storageAccountCredentialName": storageAccountCredentialName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/storageAccountCredentials/{storageAccountCredentialName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client StorageAccountCredentialsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client StorageAccountCredentialsClient) CreateOrUpdateResponder(resp *http.Response) (result StorageAccountCredential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the storage account credential. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// storageAccountCredentialName is the name of the storage account credential. +// resourceGroupName is the resource group name managerName is the manager name +func (client StorageAccountCredentialsClient) Delete(storageAccountCredentialName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.StorageAccountCredentialsClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(storageAccountCredentialName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client StorageAccountCredentialsClient) DeletePreparer(storageAccountCredentialName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "storageAccountCredentialName": storageAccountCredentialName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/storageAccountCredentials/{storageAccountCredentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client StorageAccountCredentialsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client StorageAccountCredentialsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified storage account credential name. +// +// storageAccountCredentialName is the name of storage account credential to be +// fetched. resourceGroupName is the resource group name managerName is the +// manager name +func (client StorageAccountCredentialsClient) Get(storageAccountCredentialName string, resourceGroupName string, managerName string) (result StorageAccountCredential, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.StorageAccountCredentialsClient", "Get") + } + + req, err := client.GetPreparer(storageAccountCredentialName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client StorageAccountCredentialsClient) GetPreparer(storageAccountCredentialName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "storageAccountCredentialName": storageAccountCredentialName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/storageAccountCredentials/{storageAccountCredentialName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client StorageAccountCredentialsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client StorageAccountCredentialsClient) GetResponder(resp *http.Response) (result StorageAccountCredential, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByManager gets all the storage account credentials in a manager. +// +// resourceGroupName is the resource group name managerName is the manager name +func (client StorageAccountCredentialsClient) ListByManager(resourceGroupName string, managerName string) (result StorageAccountCredentialList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.StorageAccountCredentialsClient", "ListByManager") + } + + req, err := client.ListByManagerPreparer(resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "ListByManager", nil, "Failure preparing request") + return + } + + resp, err := client.ListByManagerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "ListByManager", resp, "Failure sending request") + return + } + + result, err = client.ListByManagerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.StorageAccountCredentialsClient", "ListByManager", resp, "Failure responding to request") + } + + return +} + +// ListByManagerPreparer prepares the ListByManager request. +func (client StorageAccountCredentialsClient) ListByManagerPreparer(resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/storageAccountCredentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByManagerSender sends the ListByManager request. The method will close the +// http.Response Body if it receives an error. +func (client StorageAccountCredentialsClient) ListByManagerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByManagerResponder handles the response to the ListByManager request. The method always +// closes the http.Response Body. +func (client StorageAccountCredentialsClient) ListByManagerResponder(resp *http.Response) (result StorageAccountCredentialList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/version.go new file mode 100644 index 0000000000..92e4d1fcc6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/version.go @@ -0,0 +1,29 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.1.0-beta arm-storsimple8000series/2017-06-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.1.0-beta" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/volumecontainers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/volumecontainers.go new file mode 100644 index 0000000000..6a5fee0cee --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/volumecontainers.go @@ -0,0 +1,548 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// VolumeContainersClient is the client for the VolumeContainers methods of the +// Storsimple8000series service. +type VolumeContainersClient struct { + ManagementClient +} + +// NewVolumeContainersClient creates an instance of the VolumeContainersClient +// client. +func NewVolumeContainersClient(subscriptionID string) VolumeContainersClient { + return NewVolumeContainersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVolumeContainersClientWithBaseURI creates an instance of the +// VolumeContainersClient client. +func NewVolumeContainersClientWithBaseURI(baseURI string, subscriptionID string) VolumeContainersClient { + return VolumeContainersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the volume container. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// deviceName is the device name volumeContainerName is the name of the volume +// container. parameters is the volume container to be added or updated. +// resourceGroupName is the resource group name managerName is the manager name +func (client VolumeContainersClient) CreateOrUpdate(deviceName string, volumeContainerName string, parameters VolumeContainer, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan VolumeContainer, <-chan error) { + resultChan := make(chan VolumeContainer, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.VolumeContainerProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.VolumeContainerProperties.EncryptionKey", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.VolumeContainerProperties.EncryptionKey.Value", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "parameters.VolumeContainerProperties.StorageAccountCredentialID", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.VolumeContainersClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result VolumeContainer + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(deviceName, volumeContainerName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VolumeContainersClient) CreateOrUpdatePreparer(deviceName string, volumeContainerName string, parameters VolumeContainer, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeContainersClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VolumeContainersClient) CreateOrUpdateResponder(resp *http.Response) (result VolumeContainer, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the volume container. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name volumeContainerName is the name of the volume +// container. resourceGroupName is the resource group name managerName is the +// manager name +func (client VolumeContainersClient) Delete(deviceName string, volumeContainerName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.VolumeContainersClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(deviceName, volumeContainerName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client VolumeContainersClient) DeletePreparer(deviceName string, volumeContainerName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeContainersClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VolumeContainersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified volume container name. +// +// deviceName is the device name volumeContainerName is the name of the volume +// container. resourceGroupName is the resource group name managerName is the +// manager name +func (client VolumeContainersClient) Get(deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (result VolumeContainer, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumeContainersClient", "Get") + } + + req, err := client.GetPreparer(deviceName, volumeContainerName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VolumeContainersClient) GetPreparer(deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeContainersClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VolumeContainersClient) GetResponder(resp *http.Response) (result VolumeContainer, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDevice gets all the volume containers in a device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client VolumeContainersClient) ListByDevice(deviceName string, resourceGroupName string, managerName string) (result VolumeContainerList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumeContainersClient", "ListByDevice") + } + + req, err := client.ListByDevicePreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListByDevice", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDeviceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListByDevice", resp, "Failure sending request") + return + } + + result, err = client.ListByDeviceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListByDevice", resp, "Failure responding to request") + } + + return +} + +// ListByDevicePreparer prepares the ListByDevice request. +func (client VolumeContainersClient) ListByDevicePreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByDeviceSender sends the ListByDevice request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeContainersClient) ListByDeviceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByDeviceResponder handles the response to the ListByDevice request. The method always +// closes the http.Response Body. +func (client VolumeContainersClient) ListByDeviceResponder(resp *http.Response) (result VolumeContainerList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinition gets the metric definitions for the specified volume +// container. +// +// deviceName is the device name volumeContainerName is the volume container +// name. resourceGroupName is the resource group name managerName is the +// manager name +func (client VolumeContainersClient) ListMetricDefinition(deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (result MetricDefinitionList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumeContainersClient", "ListMetricDefinition") + } + + req, err := client.ListMetricDefinitionPreparer(deviceName, volumeContainerName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListMetricDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListMetricDefinition", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListMetricDefinition", resp, "Failure responding to request") + } + + return +} + +// ListMetricDefinitionPreparer prepares the ListMetricDefinition request. +func (client VolumeContainersClient) ListMetricDefinitionPreparer(deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/metricsDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListMetricDefinitionSender sends the ListMetricDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeContainersClient) ListMetricDefinitionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListMetricDefinitionResponder handles the response to the ListMetricDefinition request. The method always +// closes the http.Response Body. +func (client VolumeContainersClient) ListMetricDefinitionResponder(resp *http.Response) (result MetricDefinitionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics gets the metrics for the specified volume container. +// +// deviceName is the device name volumeContainerName is the volume container +// name. resourceGroupName is the resource group name managerName is the +// manager name filter is oData Filter options +func (client VolumeContainersClient) ListMetrics(deviceName string, volumeContainerName string, resourceGroupName string, managerName string, filter string) (result MetricList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumeContainersClient", "ListMetrics") + } + + req, err := client.ListMetricsPreparer(deviceName, volumeContainerName, resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumeContainersClient", "ListMetrics", resp, "Failure responding to request") + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client VolumeContainersClient) ListMetricsPreparer(deviceName string, volumeContainerName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client VolumeContainersClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client VolumeContainersClient) ListMetricsResponder(resp *http.Response) (result MetricList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/volumes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/volumes.go new file mode 100644 index 0000000000..f6d438faa6 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storsimple8000series/volumes.go @@ -0,0 +1,626 @@ +package storsimple8000series + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// VolumesClient is the client for the Volumes methods of the +// Storsimple8000series service. +type VolumesClient struct { + ManagementClient +} + +// NewVolumesClient creates an instance of the VolumesClient client. +func NewVolumesClient(subscriptionID string) VolumesClient { + return NewVolumesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewVolumesClientWithBaseURI creates an instance of the VolumesClient client. +func NewVolumesClientWithBaseURI(baseURI string, subscriptionID string) VolumesClient { + return VolumesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates the volume. This method may poll for +// completion. Polling can be canceled by passing the cancel channel argument. +// The channel will be used to cancel polling and any outstanding HTTP +// requests. +// +// deviceName is the device name volumeContainerName is the volume container +// name. volumeName is the volume name. parameters is volume to be created or +// updated. resourceGroupName is the resource group name managerName is the +// manager name +func (client VolumesClient) CreateOrUpdate(deviceName string, volumeContainerName string, volumeName string, parameters Volume, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan Volume, <-chan error) { + resultChan := make(chan Volume, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.VolumeProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.VolumeProperties.SizeInBytes", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.VolumeProperties.AccessControlRecordIds", Name: validation.Null, Rule: true, Chain: nil}, + }}}}, + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.VolumesClient", "CreateOrUpdate") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result Volume + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrUpdatePreparer(deviceName, volumeContainerName, volumeName, parameters, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client VolumesClient) CreateOrUpdatePreparer(deviceName string, volumeContainerName string, volumeName string, parameters Volume, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + "volumeName": volumeName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client VolumesClient) CreateOrUpdateResponder(resp *http.Response) (result Volume, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes the volume. This method may poll for completion. Polling can +// be canceled by passing the cancel channel argument. The channel will be used +// to cancel polling and any outstanding HTTP requests. +// +// deviceName is the device name volumeContainerName is the volume container +// name. volumeName is the volume name. resourceGroupName is the resource group +// name managerName is the manager name +func (client VolumesClient) Delete(deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + errChan <- validation.NewErrorWithValidationError(err, "storsimple8000series.VolumesClient", "Delete") + close(errChan) + close(resultChan) + return resultChan, errChan + } + + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(deviceName, volumeContainerName, volumeName, resourceGroupName, managerName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client VolumesClient) DeletePreparer(deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + "volumeName": volumeName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client VolumesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns the properties of the specified volume name. +// +// deviceName is the device name volumeContainerName is the volume container +// name. volumeName is the volume name. resourceGroupName is the resource group +// name managerName is the manager name +func (client VolumesClient) Get(deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (result Volume, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumesClient", "Get") + } + + req, err := client.GetPreparer(deviceName, volumeContainerName, volumeName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client VolumesClient) GetPreparer(deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + "volumeName": volumeName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client VolumesClient) GetResponder(resp *http.Response) (result Volume, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByDevice retrieves all the volumes in a device. +// +// deviceName is the device name resourceGroupName is the resource group name +// managerName is the manager name +func (client VolumesClient) ListByDevice(deviceName string, resourceGroupName string, managerName string) (result VolumeList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumesClient", "ListByDevice") + } + + req, err := client.ListByDevicePreparer(deviceName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListByDevice", nil, "Failure preparing request") + return + } + + resp, err := client.ListByDeviceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListByDevice", resp, "Failure sending request") + return + } + + result, err = client.ListByDeviceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListByDevice", resp, "Failure responding to request") + } + + return +} + +// ListByDevicePreparer prepares the ListByDevice request. +func (client VolumesClient) ListByDevicePreparer(deviceName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByDeviceSender sends the ListByDevice request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) ListByDeviceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByDeviceResponder handles the response to the ListByDevice request. The method always +// closes the http.Response Body. +func (client VolumesClient) ListByDeviceResponder(resp *http.Response) (result VolumeList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByVolumeContainer retrieves all the volumes in a volume container. +// +// deviceName is the device name volumeContainerName is the volume container +// name. resourceGroupName is the resource group name managerName is the +// manager name +func (client VolumesClient) ListByVolumeContainer(deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (result VolumeList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumesClient", "ListByVolumeContainer") + } + + req, err := client.ListByVolumeContainerPreparer(deviceName, volumeContainerName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListByVolumeContainer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByVolumeContainerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListByVolumeContainer", resp, "Failure sending request") + return + } + + result, err = client.ListByVolumeContainerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListByVolumeContainer", resp, "Failure responding to request") + } + + return +} + +// ListByVolumeContainerPreparer prepares the ListByVolumeContainer request. +func (client VolumesClient) ListByVolumeContainerPreparer(deviceName string, volumeContainerName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByVolumeContainerSender sends the ListByVolumeContainer request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) ListByVolumeContainerSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByVolumeContainerResponder handles the response to the ListByVolumeContainer request. The method always +// closes the http.Response Body. +func (client VolumesClient) ListByVolumeContainerResponder(resp *http.Response) (result VolumeList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetricDefinition gets the metric definitions for the specified volume. +// +// deviceName is the device name volumeContainerName is the volume container +// name. volumeName is the volume name. resourceGroupName is the resource group +// name managerName is the manager name +func (client VolumesClient) ListMetricDefinition(deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (result MetricDefinitionList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumesClient", "ListMetricDefinition") + } + + req, err := client.ListMetricDefinitionPreparer(deviceName, volumeContainerName, volumeName, resourceGroupName, managerName) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListMetricDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListMetricDefinition", resp, "Failure sending request") + return + } + + result, err = client.ListMetricDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListMetricDefinition", resp, "Failure responding to request") + } + + return +} + +// ListMetricDefinitionPreparer prepares the ListMetricDefinition request. +func (client VolumesClient) ListMetricDefinitionPreparer(deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + "volumeName": volumeName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}/metricsDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListMetricDefinitionSender sends the ListMetricDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) ListMetricDefinitionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListMetricDefinitionResponder handles the response to the ListMetricDefinition request. The method always +// closes the http.Response Body. +func (client VolumesClient) ListMetricDefinitionResponder(resp *http.Response) (result MetricDefinitionList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListMetrics gets the metrics for the specified volume. +// +// deviceName is the device name volumeContainerName is the volume container +// name. volumeName is the volume name. resourceGroupName is the resource group +// name managerName is the manager name filter is oData Filter options +func (client VolumesClient) ListMetrics(deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string, filter string) (result MetricList, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: managerName, + Constraints: []validation.Constraint{{Target: "managerName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "managerName", Name: validation.MinLength, Rule: 2, Chain: nil}}}}); err != nil { + return result, validation.NewErrorWithValidationError(err, "storsimple8000series.VolumesClient", "ListMetrics") + } + + req, err := client.ListMetricsPreparer(deviceName, volumeContainerName, volumeName, resourceGroupName, managerName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListMetrics", nil, "Failure preparing request") + return + } + + resp, err := client.ListMetricsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListMetrics", resp, "Failure sending request") + return + } + + result, err = client.ListMetricsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "storsimple8000series.VolumesClient", "ListMetrics", resp, "Failure responding to request") + } + + return +} + +// ListMetricsPreparer prepares the ListMetrics request. +func (client VolumesClient) ListMetricsPreparer(deviceName string, volumeContainerName string, volumeName string, resourceGroupName string, managerName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deviceName": deviceName, + "managerName": managerName, + "resourceGroupName": resourceGroupName, + "subscriptionId": client.SubscriptionID, + "volumeContainerName": volumeContainerName, + "volumeName": volumeName, + } + + const APIVersion = "2017-06-01" + queryParameters := map[string]interface{}{ + "$filter": autorest.Encode("query", filter), + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/volumeContainers/{volumeContainerName}/volumes/{volumeName}/metrics", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListMetricsSender sends the ListMetrics request. The method will close the +// http.Response Body if it receives an error. +func (client VolumesClient) ListMetricsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListMetricsResponder handles the response to the ListMetrics request. The method always +// closes the http.Response Body. +func (client VolumesClient) ListMetricsResponder(resp *http.Response) (result MetricList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/client.go new file mode 100644 index 0000000000..78ba4ee72a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/client.go @@ -0,0 +1,53 @@ +// Package streamanalytics implements the Azure ARM Streamanalytics service API +// version . +// +// Composite Swagger for Stream Analytics Client +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Streamanalytics + DefaultBaseURI = "https://management.azure.com" +) + +// ManagementClient is the base client for Streamanalytics. +type ManagementClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the ManagementClient client. +func New(subscriptionID string) ManagementClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the ManagementClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { + return ManagementClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/functions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/functions.go new file mode 100644 index 0000000000..34cdce08f2 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/functions.go @@ -0,0 +1,670 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// FunctionsClient is the composite Swagger for Stream Analytics Client +type FunctionsClient struct { + ManagementClient +} + +// NewFunctionsClient creates an instance of the FunctionsClient client. +func NewFunctionsClient(subscriptionID string) FunctionsClient { + return NewFunctionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFunctionsClientWithBaseURI creates an instance of the FunctionsClient +// client. +func NewFunctionsClientWithBaseURI(baseURI string, subscriptionID string) FunctionsClient { + return FunctionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrReplace creates a function or replaces an already existing function +// under an existing streaming job. +// +// function is the definition of the function that will be used to create a new +// function or replace the existing one under the streaming job. +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. functionName is the +// name of the function. ifMatch is the ETag of the function. Omit this value +// to always overwrite the current function. Specify the last-seen ETag value +// to prevent accidentally overwritting concurrent changes. ifNoneMatch is set +// to '*' to allow a new function to be created, but to prevent updating an +// existing function. Other values will result in a 412 Pre-condition Failed +// response. +func (client FunctionsClient) CreateOrReplace(function Function, resourceGroupName string, jobName string, functionName string, ifMatch string, ifNoneMatch string) (result Function, err error) { + req, err := client.CreateOrReplacePreparer(function, resourceGroupName, jobName, functionName, ifMatch, ifNoneMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "CreateOrReplace", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrReplaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "CreateOrReplace", resp, "Failure sending request") + return + } + + result, err = client.CreateOrReplaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "CreateOrReplace", resp, "Failure responding to request") + } + + return +} + +// CreateOrReplacePreparer prepares the CreateOrReplace request. +func (client FunctionsClient) CreateOrReplacePreparer(function Function, resourceGroupName string, jobName string, functionName string, ifMatch string, ifNoneMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "functionName": autorest.Encode("path", functionName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/functions/{functionName}", pathParameters), + autorest.WithJSON(function), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + if len(ifNoneMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// CreateOrReplaceSender sends the CreateOrReplace request. The method will close the +// http.Response Body if it receives an error. +func (client FunctionsClient) CreateOrReplaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrReplaceResponder handles the response to the CreateOrReplace request. The method always +// closes the http.Response Body. +func (client FunctionsClient) CreateOrReplaceResponder(resp *http.Response) (result Function, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a function from the streaming job. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. functionName is the +// name of the function. +func (client FunctionsClient) Delete(resourceGroupName string, jobName string, functionName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, jobName, functionName) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FunctionsClient) DeletePreparer(resourceGroupName string, jobName string, functionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "functionName": autorest.Encode("path", functionName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/functions/{functionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FunctionsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FunctionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets details about the specified function. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. functionName is the +// name of the function. +func (client FunctionsClient) Get(resourceGroupName string, jobName string, functionName string) (result Function, err error) { + req, err := client.GetPreparer(resourceGroupName, jobName, functionName) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client FunctionsClient) GetPreparer(resourceGroupName string, jobName string, functionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "functionName": autorest.Encode("path", functionName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/functions/{functionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FunctionsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FunctionsClient) GetResponder(resp *http.Response) (result Function, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByStreamingJob lists all of the functions under the specified streaming +// job. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. selectParameter is the +// $select OData query parameter. This is a comma-separated list of structural +// properties to include in the response, or “*” to include all properties. By +// default, all properties are returned except diagnostics. Currently only +// accepts '*' as a valid value. +func (client FunctionsClient) ListByStreamingJob(resourceGroupName string, jobName string, selectParameter string) (result FunctionListResult, err error) { + req, err := client.ListByStreamingJobPreparer(resourceGroupName, jobName, selectParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "ListByStreamingJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByStreamingJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "ListByStreamingJob", resp, "Failure sending request") + return + } + + result, err = client.ListByStreamingJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "ListByStreamingJob", resp, "Failure responding to request") + } + + return +} + +// ListByStreamingJobPreparer prepares the ListByStreamingJob request. +func (client FunctionsClient) ListByStreamingJobPreparer(resourceGroupName string, jobName string, selectParameter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/functions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByStreamingJobSender sends the ListByStreamingJob request. The method will close the +// http.Response Body if it receives an error. +func (client FunctionsClient) ListByStreamingJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByStreamingJobResponder handles the response to the ListByStreamingJob request. The method always +// closes the http.Response Body. +func (client FunctionsClient) ListByStreamingJobResponder(resp *http.Response) (result FunctionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByStreamingJobNextResults retrieves the next set of results, if any. +func (client FunctionsClient) ListByStreamingJobNextResults(lastResults FunctionListResult) (result FunctionListResult, err error) { + req, err := lastResults.FunctionListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "ListByStreamingJob", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByStreamingJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "ListByStreamingJob", resp, "Failure sending next results request") + } + + result, err = client.ListByStreamingJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "ListByStreamingJob", resp, "Failure responding to next results request") + } + + return +} + +// ListByStreamingJobComplete gets all elements from the list without paging. +func (client FunctionsClient) ListByStreamingJobComplete(resourceGroupName string, jobName string, selectParameter string, cancel <-chan struct{}) (<-chan Function, <-chan error) { + resultChan := make(chan Function) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByStreamingJob(resourceGroupName, jobName, selectParameter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByStreamingJobNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// RetrieveDefaultDefinition retrieves the default definition of a function +// based on the parameters specified. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. functionName is the +// name of the function. functionRetrieveDefaultDefinitionParameters is +// parameters used to specify the type of function to retrieve the default +// definition for. +func (client FunctionsClient) RetrieveDefaultDefinition(resourceGroupName string, jobName string, functionName string, functionRetrieveDefaultDefinitionParameters *FunctionRetrieveDefaultDefinitionParameters) (result Function, err error) { + req, err := client.RetrieveDefaultDefinitionPreparer(resourceGroupName, jobName, functionName, functionRetrieveDefaultDefinitionParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "RetrieveDefaultDefinition", nil, "Failure preparing request") + return + } + + resp, err := client.RetrieveDefaultDefinitionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "RetrieveDefaultDefinition", resp, "Failure sending request") + return + } + + result, err = client.RetrieveDefaultDefinitionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "RetrieveDefaultDefinition", resp, "Failure responding to request") + } + + return +} + +// RetrieveDefaultDefinitionPreparer prepares the RetrieveDefaultDefinition request. +func (client FunctionsClient) RetrieveDefaultDefinitionPreparer(resourceGroupName string, jobName string, functionName string, functionRetrieveDefaultDefinitionParameters *FunctionRetrieveDefaultDefinitionParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "functionName": autorest.Encode("path", functionName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/functions/{functionName}/RetrieveDefaultDefinition", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if functionRetrieveDefaultDefinitionParameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(functionRetrieveDefaultDefinitionParameters)) + } + return preparer.Prepare(&http.Request{}) +} + +// RetrieveDefaultDefinitionSender sends the RetrieveDefaultDefinition request. The method will close the +// http.Response Body if it receives an error. +func (client FunctionsClient) RetrieveDefaultDefinitionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// RetrieveDefaultDefinitionResponder handles the response to the RetrieveDefaultDefinition request. The method always +// closes the http.Response Body. +func (client FunctionsClient) RetrieveDefaultDefinitionResponder(resp *http.Response) (result Function, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Test tests if the information provided for a function is valid. This can +// range from testing the connection to the underlying web service behind the +// function or making sure the function code provided is syntactically correct. +// This method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. functionName is the +// name of the function. function is if the function specified does not already +// exist, this parameter must contain the full function definition intended to +// be tested. If the function specified already exists, this parameter can be +// left null to test the existing function as is or if specified, the +// properties specified will overwrite the corresponding properties in the +// existing function (exactly like a PATCH operation) and the resulting +// function will be tested. +func (client FunctionsClient) Test(resourceGroupName string, jobName string, functionName string, function *Function, cancel <-chan struct{}) (<-chan ResourceTestStatus, <-chan error) { + resultChan := make(chan ResourceTestStatus, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ResourceTestStatus + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.TestPreparer(resourceGroupName, jobName, functionName, function, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Test", nil, "Failure preparing request") + return + } + + resp, err := client.TestSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Test", resp, "Failure sending request") + return + } + + result, err = client.TestResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Test", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// TestPreparer prepares the Test request. +func (client FunctionsClient) TestPreparer(resourceGroupName string, jobName string, functionName string, function *Function, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "functionName": autorest.Encode("path", functionName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/functions/{functionName}/test", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if function != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(function)) + } + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// TestSender sends the Test request. The method will close the +// http.Response Body if it receives an error. +func (client FunctionsClient) TestSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// TestResponder handles the response to the Test request. The method always +// closes the http.Response Body. +func (client FunctionsClient) TestResponder(resp *http.Response) (result ResourceTestStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing function under an existing streaming job. This +// can be used to partially update (ie. update one or two properties) a +// function without affecting the rest the job or function definition. +// +// function is a function object. The properties specified here will overwrite +// the corresponding properties in the existing function (ie. Those properties +// will be updated). Any properties that are set to null here will mean that +// the corresponding property in the existing function will remain the same and +// not change as a result of this PATCH operation. resourceGroupName is the +// name of the resource group that contains the resource. You can obtain this +// value from the Azure Resource Manager API or the portal. jobName is the name +// of the streaming job. functionName is the name of the function. ifMatch is +// the ETag of the function. Omit this value to always overwrite the current +// function. Specify the last-seen ETag value to prevent accidentally +// overwritting concurrent changes. +func (client FunctionsClient) Update(function Function, resourceGroupName string, jobName string, functionName string, ifMatch string) (result Function, err error) { + req, err := client.UpdatePreparer(function, resourceGroupName, jobName, functionName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.FunctionsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client FunctionsClient) UpdatePreparer(function Function, resourceGroupName string, jobName string, functionName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "functionName": autorest.Encode("path", functionName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/functions/{functionName}", pathParameters), + autorest.WithJSON(function), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client FunctionsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client FunctionsClient) UpdateResponder(resp *http.Response) (result Function, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/inputs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/inputs.go new file mode 100644 index 0000000000..5a224d670a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/inputs.go @@ -0,0 +1,588 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// InputsClient is the composite Swagger for Stream Analytics Client +type InputsClient struct { + ManagementClient +} + +// NewInputsClient creates an instance of the InputsClient client. +func NewInputsClient(subscriptionID string) InputsClient { + return NewInputsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInputsClientWithBaseURI creates an instance of the InputsClient client. +func NewInputsClientWithBaseURI(baseURI string, subscriptionID string) InputsClient { + return InputsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrReplace creates an input or replaces an already existing input under +// an existing streaming job. +// +// input is the definition of the input that will be used to create a new input +// or replace the existing one under the streaming job. resourceGroupName is +// the name of the resource group that contains the resource. You can obtain +// this value from the Azure Resource Manager API or the portal. jobName is the +// name of the streaming job. inputName is the name of the input. ifMatch is +// the ETag of the input. Omit this value to always overwrite the current +// input. Specify the last-seen ETag value to prevent accidentally overwritting +// concurrent changes. ifNoneMatch is set to '*' to allow a new input to be +// created, but to prevent updating an existing input. Other values will result +// in a 412 Pre-condition Failed response. +func (client InputsClient) CreateOrReplace(input Input, resourceGroupName string, jobName string, inputName string, ifMatch string, ifNoneMatch string) (result Input, err error) { + req, err := client.CreateOrReplacePreparer(input, resourceGroupName, jobName, inputName, ifMatch, ifNoneMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "CreateOrReplace", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrReplaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "CreateOrReplace", resp, "Failure sending request") + return + } + + result, err = client.CreateOrReplaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "CreateOrReplace", resp, "Failure responding to request") + } + + return +} + +// CreateOrReplacePreparer prepares the CreateOrReplace request. +func (client InputsClient) CreateOrReplacePreparer(input Input, resourceGroupName string, jobName string, inputName string, ifMatch string, ifNoneMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "inputName": autorest.Encode("path", inputName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/inputs/{inputName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + if len(ifNoneMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// CreateOrReplaceSender sends the CreateOrReplace request. The method will close the +// http.Response Body if it receives an error. +func (client InputsClient) CreateOrReplaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrReplaceResponder handles the response to the CreateOrReplace request. The method always +// closes the http.Response Body. +func (client InputsClient) CreateOrReplaceResponder(resp *http.Response) (result Input, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an input from the streaming job. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. inputName is the name +// of the input. +func (client InputsClient) Delete(resourceGroupName string, jobName string, inputName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, jobName, inputName) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client InputsClient) DeletePreparer(resourceGroupName string, jobName string, inputName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "inputName": autorest.Encode("path", inputName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/inputs/{inputName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client InputsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client InputsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets details about the specified input. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. inputName is the name +// of the input. +func (client InputsClient) Get(resourceGroupName string, jobName string, inputName string) (result Input, err error) { + req, err := client.GetPreparer(resourceGroupName, jobName, inputName) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InputsClient) GetPreparer(resourceGroupName string, jobName string, inputName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "inputName": autorest.Encode("path", inputName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/inputs/{inputName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client InputsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InputsClient) GetResponder(resp *http.Response) (result Input, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByStreamingJob lists all of the inputs under the specified streaming +// job. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. selectParameter is the +// $select OData query parameter. This is a comma-separated list of structural +// properties to include in the response, or “*” to include all properties. By +// default, all properties are returned except diagnostics. Currently only +// accepts '*' as a valid value. +func (client InputsClient) ListByStreamingJob(resourceGroupName string, jobName string, selectParameter string) (result InputListResult, err error) { + req, err := client.ListByStreamingJobPreparer(resourceGroupName, jobName, selectParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "ListByStreamingJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByStreamingJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "ListByStreamingJob", resp, "Failure sending request") + return + } + + result, err = client.ListByStreamingJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "ListByStreamingJob", resp, "Failure responding to request") + } + + return +} + +// ListByStreamingJobPreparer prepares the ListByStreamingJob request. +func (client InputsClient) ListByStreamingJobPreparer(resourceGroupName string, jobName string, selectParameter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/inputs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByStreamingJobSender sends the ListByStreamingJob request. The method will close the +// http.Response Body if it receives an error. +func (client InputsClient) ListByStreamingJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByStreamingJobResponder handles the response to the ListByStreamingJob request. The method always +// closes the http.Response Body. +func (client InputsClient) ListByStreamingJobResponder(resp *http.Response) (result InputListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByStreamingJobNextResults retrieves the next set of results, if any. +func (client InputsClient) ListByStreamingJobNextResults(lastResults InputListResult) (result InputListResult, err error) { + req, err := lastResults.InputListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "ListByStreamingJob", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByStreamingJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "ListByStreamingJob", resp, "Failure sending next results request") + } + + result, err = client.ListByStreamingJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "ListByStreamingJob", resp, "Failure responding to next results request") + } + + return +} + +// ListByStreamingJobComplete gets all elements from the list without paging. +func (client InputsClient) ListByStreamingJobComplete(resourceGroupName string, jobName string, selectParameter string, cancel <-chan struct{}) (<-chan Input, <-chan error) { + resultChan := make(chan Input) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByStreamingJob(resourceGroupName, jobName, selectParameter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByStreamingJobNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Test tests whether an input’s datasource is reachable and usable by the +// Azure Stream Analytics service. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. inputName is the name +// of the input. input is if the input specified does not already exist, this +// parameter must contain the full input definition intended to be tested. If +// the input specified already exists, this parameter can be left null to test +// the existing input as is or if specified, the properties specified will +// overwrite the corresponding properties in the existing input (exactly like a +// PATCH operation) and the resulting input will be tested. +func (client InputsClient) Test(resourceGroupName string, jobName string, inputName string, input *Input, cancel <-chan struct{}) (<-chan ResourceTestStatus, <-chan error) { + resultChan := make(chan ResourceTestStatus, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ResourceTestStatus + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.TestPreparer(resourceGroupName, jobName, inputName, input, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Test", nil, "Failure preparing request") + return + } + + resp, err := client.TestSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Test", resp, "Failure sending request") + return + } + + result, err = client.TestResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Test", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// TestPreparer prepares the Test request. +func (client InputsClient) TestPreparer(resourceGroupName string, jobName string, inputName string, input *Input, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "inputName": autorest.Encode("path", inputName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/inputs/{inputName}/test", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if input != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(input)) + } + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// TestSender sends the Test request. The method will close the +// http.Response Body if it receives an error. +func (client InputsClient) TestSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// TestResponder handles the response to the Test request. The method always +// closes the http.Response Body. +func (client InputsClient) TestResponder(resp *http.Response) (result ResourceTestStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing input under an existing streaming job. This can +// be used to partially update (ie. update one or two properties) an input +// without affecting the rest the job or input definition. +// +// input is an Input object. The properties specified here will overwrite the +// corresponding properties in the existing input (ie. Those properties will be +// updated). Any properties that are set to null here will mean that the +// corresponding property in the existing input will remain the same and not +// change as a result of this PATCH operation. resourceGroupName is the name of +// the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. jobName is the name of +// the streaming job. inputName is the name of the input. ifMatch is the ETag +// of the input. Omit this value to always overwrite the current input. Specify +// the last-seen ETag value to prevent accidentally overwritting concurrent +// changes. +func (client InputsClient) Update(input Input, resourceGroupName string, jobName string, inputName string, ifMatch string) (result Input, err error) { + req, err := client.UpdatePreparer(input, resourceGroupName, jobName, inputName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.InputsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client InputsClient) UpdatePreparer(input Input, resourceGroupName string, jobName string, inputName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "inputName": autorest.Encode("path", inputName), + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/inputs/{inputName}", pathParameters), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client InputsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client InputsClient) UpdateResponder(resp *http.Response) (result Input, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/models.go new file mode 100644 index 0000000000..bb3d04b6c3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/models.go @@ -0,0 +1,806 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "net/http" +) + +// CompatibilityLevel enumerates the values for compatibility level. +type CompatibilityLevel string + +const ( + // OneFullStopZero specifies the one full stop zero state for compatibility + // level. + OneFullStopZero CompatibilityLevel = "1.0" +) + +// Encoding enumerates the values for encoding. +type Encoding string + +const ( + // UTF8 specifies the utf8 state for encoding. + UTF8 Encoding = "UTF8" +) + +// EventsOutOfOrderPolicy enumerates the values for events out of order policy. +type EventsOutOfOrderPolicy string + +const ( + // Adjust specifies the adjust state for events out of order policy. + Adjust EventsOutOfOrderPolicy = "Adjust" + // Drop specifies the drop state for events out of order policy. + Drop EventsOutOfOrderPolicy = "Drop" +) + +// JSONOutputSerializationFormat enumerates the values for json output +// serialization format. +type JSONOutputSerializationFormat string + +const ( + // Array specifies the array state for json output serialization format. + Array JSONOutputSerializationFormat = "Array" + // LineSeparated specifies the line separated state for json output + // serialization format. + LineSeparated JSONOutputSerializationFormat = "LineSeparated" +) + +// OutputErrorPolicy enumerates the values for output error policy. +type OutputErrorPolicy string + +const ( + // OutputErrorPolicyDrop specifies the output error policy drop state for + // output error policy. + OutputErrorPolicyDrop OutputErrorPolicy = "Drop" + // OutputErrorPolicyStop specifies the output error policy stop state for + // output error policy. + OutputErrorPolicyStop OutputErrorPolicy = "Stop" +) + +// OutputStartMode enumerates the values for output start mode. +type OutputStartMode string + +const ( + // CustomTime specifies the custom time state for output start mode. + CustomTime OutputStartMode = "CustomTime" + // JobStartTime specifies the job start time state for output start mode. + JobStartTime OutputStartMode = "JobStartTime" + // LastOutputEventTime specifies the last output event time state for + // output start mode. + LastOutputEventTime OutputStartMode = "LastOutputEventTime" +) + +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // Standard specifies the standard state for sku name. + Standard SkuName = "Standard" +) + +// UdfType enumerates the values for udf type. +type UdfType string + +const ( + // Scalar specifies the scalar state for udf type. + Scalar UdfType = "Scalar" +) + +// AvroSerialization is describes how data from an input is serialized or how +// data is serialized when written to an output in Avro format. +type AvroSerialization struct { + Properties *map[string]interface{} `json:"properties,omitempty"` +} + +// AzureMachineLearningWebServiceFunctionBinding is the binding to an Azure +// Machine Learning web service. +type AzureMachineLearningWebServiceFunctionBinding struct { + *AzureMachineLearningWebServiceFunctionBindingProperties `json:"properties,omitempty"` +} + +// AzureMachineLearningWebServiceFunctionBindingProperties is the binding +// properties associated with an Azure Machine learning web service. +type AzureMachineLearningWebServiceFunctionBindingProperties struct { + Endpoint *string `json:"endpoint,omitempty"` + APIKey *string `json:"apiKey,omitempty"` + Inputs *AzureMachineLearningWebServiceInputs `json:"inputs,omitempty"` + Outputs *[]AzureMachineLearningWebServiceOutputColumn `json:"outputs,omitempty"` + BatchSize *int32 `json:"batchSize,omitempty"` +} + +// AzureMachineLearningWebServiceFunctionBindingRetrievalProperties is the +// binding retrieval properties associated with an Azure Machine learning web +// service. +type AzureMachineLearningWebServiceFunctionBindingRetrievalProperties struct { + ExecuteEndpoint *string `json:"executeEndpoint,omitempty"` + UdfType UdfType `json:"udfType,omitempty"` +} + +// AzureMachineLearningWebServiceFunctionRetrieveDefaultDefinitionParameters is +// the parameters needed to retrieve the default function definition for an +// Azure Machine Learning web service function. +type AzureMachineLearningWebServiceFunctionRetrieveDefaultDefinitionParameters struct { + *AzureMachineLearningWebServiceFunctionBindingRetrievalProperties `json:"bindingRetrievalProperties,omitempty"` +} + +// AzureMachineLearningWebServiceInputColumn is describes an input column for +// the Azure Machine Learning web service endpoint. +type AzureMachineLearningWebServiceInputColumn struct { + Name *string `json:"name,omitempty"` + DataType *string `json:"dataType,omitempty"` + MapTo *int32 `json:"mapTo,omitempty"` +} + +// AzureMachineLearningWebServiceInputs is the inputs for the Azure Machine +// Learning web service endpoint. +type AzureMachineLearningWebServiceInputs struct { + Name *string `json:"name,omitempty"` + ColumnNames *[]AzureMachineLearningWebServiceInputColumn `json:"columnNames,omitempty"` +} + +// AzureMachineLearningWebServiceOutputColumn is describes an output column for +// the Azure Machine Learning web service endpoint. +type AzureMachineLearningWebServiceOutputColumn struct { + Name *string `json:"name,omitempty"` + DataType *string `json:"dataType,omitempty"` +} + +// AzureSQLDatabaseDataSourceProperties is the properties that are associated +// with an Azure SQL database data source. +type AzureSQLDatabaseDataSourceProperties struct { + Server *string `json:"server,omitempty"` + Database *string `json:"database,omitempty"` + User *string `json:"user,omitempty"` + Password *string `json:"password,omitempty"` + Table *string `json:"table,omitempty"` +} + +// AzureSQLDatabaseOutputDataSource is describes an Azure SQL database output +// data source. +type AzureSQLDatabaseOutputDataSource struct { + *AzureSQLDatabaseOutputDataSourceProperties `json:"properties,omitempty"` +} + +// AzureSQLDatabaseOutputDataSourceProperties is the properties that are +// associated with an Azure SQL database output. +type AzureSQLDatabaseOutputDataSourceProperties struct { + Server *string `json:"server,omitempty"` + Database *string `json:"database,omitempty"` + User *string `json:"user,omitempty"` + Password *string `json:"password,omitempty"` + Table *string `json:"table,omitempty"` +} + +// AzureTableOutputDataSource is describes an Azure Table data source. +type AzureTableOutputDataSource struct { + *AzureTableOutputDataSourceProperties `json:"properties,omitempty"` +} + +// AzureTableOutputDataSourceProperties is the properties that are associated +// with an Azure Table output. +type AzureTableOutputDataSourceProperties struct { + AccountName *string `json:"accountName,omitempty"` + AccountKey *string `json:"accountKey,omitempty"` + Table *string `json:"table,omitempty"` + PartitionKey *string `json:"partitionKey,omitempty"` + RowKey *string `json:"rowKey,omitempty"` + ColumnsToRemove *[]string `json:"columnsToRemove,omitempty"` + BatchSize *int32 `json:"batchSize,omitempty"` +} + +// BlobDataSourceProperties is the properties that are associated with a blob +// data source. +type BlobDataSourceProperties struct { + StorageAccounts *[]StorageAccount `json:"storageAccounts,omitempty"` + Container *string `json:"container,omitempty"` + PathPattern *string `json:"pathPattern,omitempty"` + DateFormat *string `json:"dateFormat,omitempty"` + TimeFormat *string `json:"timeFormat,omitempty"` +} + +// BlobOutputDataSource is describes a blob output data source. +type BlobOutputDataSource struct { + *BlobOutputDataSourceProperties `json:"properties,omitempty"` +} + +// BlobOutputDataSourceProperties is the properties that are associated with a +// blob output. +type BlobOutputDataSourceProperties struct { + StorageAccounts *[]StorageAccount `json:"storageAccounts,omitempty"` + Container *string `json:"container,omitempty"` + PathPattern *string `json:"pathPattern,omitempty"` + DateFormat *string `json:"dateFormat,omitempty"` + TimeFormat *string `json:"timeFormat,omitempty"` +} + +// BlobReferenceInputDataSource is describes a blob input data source that +// contains reference data. +type BlobReferenceInputDataSource struct { + *BlobReferenceInputDataSourceProperties `json:"properties,omitempty"` +} + +// BlobReferenceInputDataSourceProperties is the properties that are associated +// with a blob input containing reference data. +type BlobReferenceInputDataSourceProperties struct { + StorageAccounts *[]StorageAccount `json:"storageAccounts,omitempty"` + Container *string `json:"container,omitempty"` + PathPattern *string `json:"pathPattern,omitempty"` + DateFormat *string `json:"dateFormat,omitempty"` + TimeFormat *string `json:"timeFormat,omitempty"` +} + +// BlobStreamInputDataSource is describes a blob input data source that +// contains stream data. +type BlobStreamInputDataSource struct { + *BlobStreamInputDataSourceProperties `json:"properties,omitempty"` +} + +// BlobStreamInputDataSourceProperties is the properties that are associated +// with a blob input containing stream data. +type BlobStreamInputDataSourceProperties struct { + StorageAccounts *[]StorageAccount `json:"storageAccounts,omitempty"` + Container *string `json:"container,omitempty"` + PathPattern *string `json:"pathPattern,omitempty"` + DateFormat *string `json:"dateFormat,omitempty"` + TimeFormat *string `json:"timeFormat,omitempty"` + SourcePartitionCount *int32 `json:"sourcePartitionCount,omitempty"` +} + +// CsvSerialization is describes how data from an input is serialized or how +// data is serialized when written to an output in CSV format. +type CsvSerialization struct { + *CsvSerializationProperties `json:"properties,omitempty"` +} + +// CsvSerializationProperties is the properties that are associated with the +// CSV serialization type. +type CsvSerializationProperties struct { + FieldDelimiter *string `json:"fieldDelimiter,omitempty"` + Encoding Encoding `json:"encoding,omitempty"` +} + +// DiagnosticCondition is condition applicable to the resource, or to the job +// overall, that warrant customer attention. +type DiagnosticCondition struct { + Since *string `json:"since,omitempty"` + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// Diagnostics is describes conditions applicable to the Input, Output, or the +// job overall, that warrant customer attention. +type Diagnostics struct { + Conditions *[]DiagnosticCondition `json:"conditions,omitempty"` +} + +// DocumentDbOutputDataSource is describes a DocumentDB data source. +type DocumentDbOutputDataSource struct { + *DocumentDbOutputDataSourceProperties `json:"properties,omitempty"` +} + +// DocumentDbOutputDataSourceProperties is the properties that are associated +// with a DocumentDB output. +type DocumentDbOutputDataSourceProperties struct { + AccountID *string `json:"accountId,omitempty"` + AccountKey *string `json:"accountKey,omitempty"` + Database *string `json:"database,omitempty"` + CollectionNamePattern *string `json:"collectionNamePattern,omitempty"` + PartitionKey *string `json:"partitionKey,omitempty"` + DocumentID *string `json:"documentId,omitempty"` +} + +// ErrorResponse is describes the error that occurred. +type ErrorResponse struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// EventHubDataSourceProperties is the common properties that are associated +// with Event Hub data sources. +type EventHubDataSourceProperties struct { + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"` + SharedAccessPolicyKey *string `json:"sharedAccessPolicyKey,omitempty"` + EventHubName *string `json:"eventHubName,omitempty"` +} + +// EventHubOutputDataSource is describes an Event Hub output data source. +type EventHubOutputDataSource struct { + *EventHubOutputDataSourceProperties `json:"properties,omitempty"` +} + +// EventHubOutputDataSourceProperties is the properties that are associated +// with an Event Hub output. +type EventHubOutputDataSourceProperties struct { + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"` + SharedAccessPolicyKey *string `json:"sharedAccessPolicyKey,omitempty"` + EventHubName *string `json:"eventHubName,omitempty"` + PartitionKey *string `json:"partitionKey,omitempty"` +} + +// EventHubStreamInputDataSource is describes an Event Hub input data source +// that contains stream data. +type EventHubStreamInputDataSource struct { + *EventHubStreamInputDataSourceProperties `json:"properties,omitempty"` +} + +// EventHubStreamInputDataSourceProperties is the properties that are +// associated with a Event Hub input containing stream data. +type EventHubStreamInputDataSourceProperties struct { + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"` + SharedAccessPolicyKey *string `json:"sharedAccessPolicyKey,omitempty"` + EventHubName *string `json:"eventHubName,omitempty"` + ConsumerGroupName *string `json:"consumerGroupName,omitempty"` +} + +// Function is a function object, containing all information associated with +// the named function. All functions are contained under a streaming job. +type Function struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Properties *FunctionProperties `json:"properties,omitempty"` +} + +// FunctionBinding is the physical binding of the function. For example, in the +// Azure Machine Learning web service’s case, this describes the endpoint. +type FunctionBinding struct { +} + +// FunctionInput is describes one input parameter of a function. +type FunctionInput struct { + DataType *string `json:"dataType,omitempty"` + IsConfigurationParameter *bool `json:"isConfigurationParameter,omitempty"` +} + +// FunctionListResult is object containing a list of functions under a +// streaming job. +type FunctionListResult struct { + autorest.Response `json:"-"` + Value *[]Function `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// FunctionListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client FunctionListResult) FunctionListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// FunctionOutput is describes the output of a function. +type FunctionOutput struct { + DataType *string `json:"dataType,omitempty"` +} + +// FunctionProperties is the properties that are associated with a function. +type FunctionProperties struct { + Etag *string `json:"etag,omitempty"` +} + +// FunctionRetrieveDefaultDefinitionParameters is parameters used to specify +// the type of function to retrieve the default definition for. +type FunctionRetrieveDefaultDefinitionParameters struct { +} + +// Input is an input object, containing all information associated with the +// named input. All inputs are contained under a streaming job. +type Input struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Properties *InputProperties `json:"properties,omitempty"` +} + +// InputListResult is object containing a list of inputs under a streaming job. +type InputListResult struct { + autorest.Response `json:"-"` + Value *[]Input `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// InputListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client InputListResult) InputListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// InputProperties is the properties that are associated with an input. +type InputProperties struct { + Serialization *Serialization `json:"serialization,omitempty"` + Diagnostics *Diagnostics `json:"diagnostics,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// IoTHubStreamInputDataSource is describes an IoT Hub input data source that +// contains stream data. +type IoTHubStreamInputDataSource struct { + *IoTHubStreamInputDataSourceProperties `json:"properties,omitempty"` +} + +// IoTHubStreamInputDataSourceProperties is the properties that are associated +// with a IoT Hub input containing stream data. +type IoTHubStreamInputDataSourceProperties struct { + IotHubNamespace *string `json:"iotHubNamespace,omitempty"` + SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"` + SharedAccessPolicyKey *string `json:"sharedAccessPolicyKey,omitempty"` + ConsumerGroupName *string `json:"consumerGroupName,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` +} + +// JavaScriptFunctionBinding is the binding to a JavaScript function. +type JavaScriptFunctionBinding struct { + *JavaScriptFunctionBindingProperties `json:"properties,omitempty"` +} + +// JavaScriptFunctionBindingProperties is the binding properties associated +// with a JavaScript function. +type JavaScriptFunctionBindingProperties struct { + Script *string `json:"script,omitempty"` +} + +// JavaScriptFunctionBindingRetrievalProperties is the binding retrieval +// properties associated with a JavaScript function. +type JavaScriptFunctionBindingRetrievalProperties struct { + Script *string `json:"script,omitempty"` + UdfType UdfType `json:"udfType,omitempty"` +} + +// JavaScriptFunctionRetrieveDefaultDefinitionParameters is the parameters +// needed to retrieve the default function definition for a JavaScript +// function. +type JavaScriptFunctionRetrieveDefaultDefinitionParameters struct { + *JavaScriptFunctionBindingRetrievalProperties `json:"bindingRetrievalProperties,omitempty"` +} + +// JSONSerialization is describes how data from an input is serialized or how +// data is serialized when written to an output in JSON format. +type JSONSerialization struct { + *JSONSerializationProperties `json:"properties,omitempty"` +} + +// JSONSerializationProperties is the properties that are associated with the +// JSON serialization type. +type JSONSerializationProperties struct { + Encoding Encoding `json:"encoding,omitempty"` + Format JSONOutputSerializationFormat `json:"format,omitempty"` +} + +// Operation is a Stream Analytics REST API operation +type Operation struct { + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay is contains the localized display information for this +// particular operation / action. +type OperationDisplay struct { + Provider *string `json:"provider,omitempty"` + Resource *string `json:"resource,omitempty"` + Operation *string `json:"operation,omitempty"` + Description *string `json:"description,omitempty"` +} + +// OperationListResult is result of the request to list Stream Analytics +// operations. It contains a list of operations and a URL link to get the next +// set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + Value *[]Operation `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// Output is an output object, containing all information associated with the +// named output. All outputs are contained under a streaming job. +type Output struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *OutputProperties `json:"properties,omitempty"` +} + +// OutputDataSource is describes the data source that output will be written +// to. +type OutputDataSource struct { +} + +// OutputListResult is object containing a list of outputs under a streaming +// job. +type OutputListResult struct { + autorest.Response `json:"-"` + Value *[]Output `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// OutputListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client OutputListResult) OutputListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// OutputProperties is the properties that are associated with an output. +type OutputProperties struct { + Datasource *OutputDataSource `json:"datasource,omitempty"` + Serialization *Serialization `json:"serialization,omitempty"` + Diagnostics *Diagnostics `json:"diagnostics,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// ReferenceInputDataSource is describes an input data source that contains +// reference data. +type ReferenceInputDataSource struct { +} + +// ReferenceInputProperties is the properties that are associated with an input +// containing reference data. +type ReferenceInputProperties struct { + Serialization *Serialization `json:"serialization,omitempty"` + Diagnostics *Diagnostics `json:"diagnostics,omitempty"` + Etag *string `json:"etag,omitempty"` + Datasource *ReferenceInputDataSource `json:"datasource,omitempty"` +} + +// Resource is the base resource model definition. +type Resource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` +} + +// ResourceTestStatus is describes the status of the test operation along with +// error information, if applicable. +type ResourceTestStatus struct { + autorest.Response `json:"-"` + Status *string `json:"status,omitempty"` + Error *ErrorResponse `json:"error,omitempty"` +} + +// ScalarFunctionConfiguration is describes the configuration of the scalar +// function. +type ScalarFunctionConfiguration struct { + Inputs *[]FunctionInput `json:"inputs,omitempty"` + Output *FunctionOutput `json:"output,omitempty"` + Binding *FunctionBinding `json:"binding,omitempty"` +} + +// ScalarFunctionProperties is the properties that are associated with a scalar +// function. +type ScalarFunctionProperties struct { + Etag *string `json:"etag,omitempty"` + *ScalarFunctionConfiguration `json:"properties,omitempty"` +} + +// Serialization is describes how data from an input is serialized or how data +// is serialized when written to an output. +type Serialization struct { +} + +// ServiceBusDataSourceProperties is the common properties that are associated +// with Service Bus data sources (Queues, Topics, Event Hubs, etc.). +type ServiceBusDataSourceProperties struct { + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"` + SharedAccessPolicyKey *string `json:"sharedAccessPolicyKey,omitempty"` +} + +// ServiceBusQueueOutputDataSource is describes a Service Bus Queue data +// source. +type ServiceBusQueueOutputDataSource struct { + *ServiceBusQueueOutputDataSourceProperties `json:"properties,omitempty"` +} + +// ServiceBusQueueOutputDataSourceProperties is the properties that are +// associated with a Service Bus Queue output. +type ServiceBusQueueOutputDataSourceProperties struct { + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"` + SharedAccessPolicyKey *string `json:"sharedAccessPolicyKey,omitempty"` + QueueName *string `json:"queueName,omitempty"` + PropertyColumns *[]string `json:"propertyColumns,omitempty"` +} + +// ServiceBusTopicOutputDataSource is describes a Service Bus Topic data +// source. +type ServiceBusTopicOutputDataSource struct { + *ServiceBusTopicOutputDataSourceProperties `json:"properties,omitempty"` +} + +// ServiceBusTopicOutputDataSourceProperties is the properties that are +// associated with a Service Bus Topic output. +type ServiceBusTopicOutputDataSourceProperties struct { + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + SharedAccessPolicyName *string `json:"sharedAccessPolicyName,omitempty"` + SharedAccessPolicyKey *string `json:"sharedAccessPolicyKey,omitempty"` + TopicName *string `json:"topicName,omitempty"` + PropertyColumns *[]string `json:"propertyColumns,omitempty"` +} + +// Sku is the properties that are associated with a SKU. +type Sku struct { + Name SkuName `json:"name,omitempty"` +} + +// StartStreamingJobParameters is parameters supplied to the Start Streaming +// Job operation. +type StartStreamingJobParameters struct { + OutputStartMode OutputStartMode `json:"outputStartMode,omitempty"` + OutputStartTime *date.Time `json:"outputStartTime,omitempty"` +} + +// StorageAccount is the properties that are associated with an Azure Storage +// account +type StorageAccount struct { + AccountName *string `json:"accountName,omitempty"` + AccountKey *string `json:"accountKey,omitempty"` +} + +// StreamingJob is a streamng job object, containing all information associated +// with the named streaming job. +type StreamingJob struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Location *string `json:"location,omitempty"` + Tags *map[string]*string `json:"tags,omitempty"` + *StreamingJobProperties `json:"properties,omitempty"` +} + +// StreamingJobListResult is object containing a list of streaming jobs. +type StreamingJobListResult struct { + autorest.Response `json:"-"` + Value *[]StreamingJob `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// StreamingJobListResultPreparer prepares a request to retrieve the next set of results. It returns +// nil if no more results exist. +func (client StreamingJobListResult) StreamingJobListResultPreparer() (*http.Request, error) { + if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { + return nil, nil + } + return autorest.Prepare(&http.Request{}, + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(client.NextLink))) +} + +// StreamingJobProperties is the properties that are associated with a +// streaming job. +type StreamingJobProperties struct { + Sku *Sku `json:"sku,omitempty"` + JobID *string `json:"jobId,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + JobState *string `json:"jobState,omitempty"` + OutputStartMode OutputStartMode `json:"outputStartMode,omitempty"` + OutputStartTime *date.Time `json:"outputStartTime,omitempty"` + LastOutputEventTime *date.Time `json:"lastOutputEventTime,omitempty"` + EventsOutOfOrderPolicy EventsOutOfOrderPolicy `json:"eventsOutOfOrderPolicy,omitempty"` + OutputErrorPolicy OutputErrorPolicy `json:"outputErrorPolicy,omitempty"` + EventsOutOfOrderMaxDelayInSeconds *int32 `json:"eventsOutOfOrderMaxDelayInSeconds,omitempty"` + EventsLateArrivalMaxDelayInSeconds *int32 `json:"eventsLateArrivalMaxDelayInSeconds,omitempty"` + DataLocale *string `json:"dataLocale,omitempty"` + CompatibilityLevel CompatibilityLevel `json:"compatibilityLevel,omitempty"` + CreatedDate *date.Time `json:"createdDate,omitempty"` + Inputs *[]Input `json:"inputs,omitempty"` + Transformation *Transformation `json:"transformation,omitempty"` + Outputs *[]Output `json:"outputs,omitempty"` + Functions *[]Function `json:"functions,omitempty"` + Etag *string `json:"etag,omitempty"` +} + +// StreamInputDataSource is describes an input data source that contains stream +// data. +type StreamInputDataSource struct { +} + +// StreamInputProperties is the properties that are associated with an input +// containing stream data. +type StreamInputProperties struct { + Serialization *Serialization `json:"serialization,omitempty"` + Diagnostics *Diagnostics `json:"diagnostics,omitempty"` + Etag *string `json:"etag,omitempty"` + Datasource *StreamInputDataSource `json:"datasource,omitempty"` +} + +// SubResource is the base sub-resource model definition. +type SubResource struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// SubscriptionQuota is describes the current quota for the subscription. +type SubscriptionQuota struct { + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *SubscriptionQuotaProperties `json:"properties,omitempty"` +} + +// SubscriptionQuotaProperties is describes the properties of the quota. +type SubscriptionQuotaProperties struct { + MaxCount *int32 `json:"maxCount,omitempty"` + CurrentCount *int32 `json:"currentCount,omitempty"` +} + +// SubscriptionQuotasListResult is result of the GetQuotas operation. It +// contains a list of quotas for the subscription in a particular region. +type SubscriptionQuotasListResult struct { + autorest.Response `json:"-"` + Value *[]SubscriptionQuota `json:"value,omitempty"` +} + +// Transformation is a transformation object, containing all information +// associated with the named transformation. All transformations are contained +// under a streaming job. +type Transformation struct { + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + *TransformationProperties `json:"properties,omitempty"` +} + +// TransformationProperties is the properties that are associated with a +// transformation. +type TransformationProperties struct { + StreamingUnits *int32 `json:"streamingUnits,omitempty"` + Query *string `json:"query,omitempty"` + Etag *string `json:"etag,omitempty"` +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/operations.go new file mode 100644 index 0000000000..dc0c7814df --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/operations.go @@ -0,0 +1,167 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OperationsClient is the composite Swagger for Stream Analytics Client +type OperationsClient struct { + ManagementClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient +// client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available Stream Analytics related operations. +func (client OperationsClient) List() (result OperationListResult, err error) { + req, err := client.ListPreparer() + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer() (*http.Request, error) { + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.StreamAnalytics/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client OperationsClient) ListNextResults(lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.OperationListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "streamanalytics.OperationsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "streamanalytics.OperationsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OperationsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client OperationsClient) ListComplete(cancel <-chan struct{}) (<-chan Operation, <-chan error) { + resultChan := make(chan Operation) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List() + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/outputs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/outputs.go new file mode 100644 index 0000000000..e26a22c93e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/outputs.go @@ -0,0 +1,588 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// OutputsClient is the composite Swagger for Stream Analytics Client +type OutputsClient struct { + ManagementClient +} + +// NewOutputsClient creates an instance of the OutputsClient client. +func NewOutputsClient(subscriptionID string) OutputsClient { + return NewOutputsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOutputsClientWithBaseURI creates an instance of the OutputsClient client. +func NewOutputsClientWithBaseURI(baseURI string, subscriptionID string) OutputsClient { + return OutputsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrReplace creates an output or replaces an already existing output +// under an existing streaming job. +// +// output is the definition of the output that will be used to create a new +// output or replace the existing one under the streaming job. +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. outputName is the name +// of the output. ifMatch is the ETag of the output. Omit this value to always +// overwrite the current output. Specify the last-seen ETag value to prevent +// accidentally overwritting concurrent changes. ifNoneMatch is set to '*' to +// allow a new output to be created, but to prevent updating an existing +// output. Other values will result in a 412 Pre-condition Failed response. +func (client OutputsClient) CreateOrReplace(output Output, resourceGroupName string, jobName string, outputName string, ifMatch string, ifNoneMatch string) (result Output, err error) { + req, err := client.CreateOrReplacePreparer(output, resourceGroupName, jobName, outputName, ifMatch, ifNoneMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "CreateOrReplace", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrReplaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "CreateOrReplace", resp, "Failure sending request") + return + } + + result, err = client.CreateOrReplaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "CreateOrReplace", resp, "Failure responding to request") + } + + return +} + +// CreateOrReplacePreparer prepares the CreateOrReplace request. +func (client OutputsClient) CreateOrReplacePreparer(output Output, resourceGroupName string, jobName string, outputName string, ifMatch string, ifNoneMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "outputName": autorest.Encode("path", outputName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/outputs/{outputName}", pathParameters), + autorest.WithJSON(output), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + if len(ifNoneMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// CreateOrReplaceSender sends the CreateOrReplace request. The method will close the +// http.Response Body if it receives an error. +func (client OutputsClient) CreateOrReplaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrReplaceResponder handles the response to the CreateOrReplace request. The method always +// closes the http.Response Body. +func (client OutputsClient) CreateOrReplaceResponder(resp *http.Response) (result Output, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an output from the streaming job. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. outputName is the name +// of the output. +func (client OutputsClient) Delete(resourceGroupName string, jobName string, outputName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, jobName, outputName) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OutputsClient) DeletePreparer(resourceGroupName string, jobName string, outputName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "outputName": autorest.Encode("path", outputName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/outputs/{outputName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client OutputsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client OutputsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets details about the specified output. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. outputName is the name +// of the output. +func (client OutputsClient) Get(resourceGroupName string, jobName string, outputName string) (result Output, err error) { + req, err := client.GetPreparer(resourceGroupName, jobName, outputName) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client OutputsClient) GetPreparer(resourceGroupName string, jobName string, outputName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "outputName": autorest.Encode("path", outputName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/outputs/{outputName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OutputsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OutputsClient) GetResponder(resp *http.Response) (result Output, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByStreamingJob lists all of the outputs under the specified streaming +// job. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. selectParameter is the +// $select OData query parameter. This is a comma-separated list of structural +// properties to include in the response, or “*” to include all properties. By +// default, all properties are returned except diagnostics. Currently only +// accepts '*' as a valid value. +func (client OutputsClient) ListByStreamingJob(resourceGroupName string, jobName string, selectParameter string) (result OutputListResult, err error) { + req, err := client.ListByStreamingJobPreparer(resourceGroupName, jobName, selectParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "ListByStreamingJob", nil, "Failure preparing request") + return + } + + resp, err := client.ListByStreamingJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "ListByStreamingJob", resp, "Failure sending request") + return + } + + result, err = client.ListByStreamingJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "ListByStreamingJob", resp, "Failure responding to request") + } + + return +} + +// ListByStreamingJobPreparer prepares the ListByStreamingJob request. +func (client OutputsClient) ListByStreamingJobPreparer(resourceGroupName string, jobName string, selectParameter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(selectParameter) > 0 { + queryParameters["$select"] = autorest.Encode("query", selectParameter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/outputs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByStreamingJobSender sends the ListByStreamingJob request. The method will close the +// http.Response Body if it receives an error. +func (client OutputsClient) ListByStreamingJobSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByStreamingJobResponder handles the response to the ListByStreamingJob request. The method always +// closes the http.Response Body. +func (client OutputsClient) ListByStreamingJobResponder(resp *http.Response) (result OutputListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByStreamingJobNextResults retrieves the next set of results, if any. +func (client OutputsClient) ListByStreamingJobNextResults(lastResults OutputListResult) (result OutputListResult, err error) { + req, err := lastResults.OutputListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "ListByStreamingJob", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByStreamingJobSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "ListByStreamingJob", resp, "Failure sending next results request") + } + + result, err = client.ListByStreamingJobResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "ListByStreamingJob", resp, "Failure responding to next results request") + } + + return +} + +// ListByStreamingJobComplete gets all elements from the list without paging. +func (client OutputsClient) ListByStreamingJobComplete(resourceGroupName string, jobName string, selectParameter string, cancel <-chan struct{}) (<-chan Output, <-chan error) { + resultChan := make(chan Output) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByStreamingJob(resourceGroupName, jobName, selectParameter) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByStreamingJobNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Test tests whether an output’s datasource is reachable and usable by the +// Azure Stream Analytics service. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. outputName is the name +// of the output. output is if the output specified does not already exist, +// this parameter must contain the full output definition intended to be +// tested. If the output specified already exists, this parameter can be left +// null to test the existing output as is or if specified, the properties +// specified will overwrite the corresponding properties in the existing output +// (exactly like a PATCH operation) and the resulting output will be tested. +func (client OutputsClient) Test(resourceGroupName string, jobName string, outputName string, output *Output, cancel <-chan struct{}) (<-chan ResourceTestStatus, <-chan error) { + resultChan := make(chan ResourceTestStatus, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result ResourceTestStatus + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.TestPreparer(resourceGroupName, jobName, outputName, output, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Test", nil, "Failure preparing request") + return + } + + resp, err := client.TestSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Test", resp, "Failure sending request") + return + } + + result, err = client.TestResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Test", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// TestPreparer prepares the Test request. +func (client OutputsClient) TestPreparer(resourceGroupName string, jobName string, outputName string, output *Output, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "outputName": autorest.Encode("path", outputName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/outputs/{outputName}/test", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if output != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(output)) + } + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// TestSender sends the Test request. The method will close the +// http.Response Body if it receives an error. +func (client OutputsClient) TestSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// TestResponder handles the response to the Test request. The method always +// closes the http.Response Body. +func (client OutputsClient) TestResponder(resp *http.Response) (result ResourceTestStatus, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing output under an existing streaming job. This can +// be used to partially update (ie. update one or two properties) an output +// without affecting the rest the job or output definition. +// +// output is an Output object. The properties specified here will overwrite the +// corresponding properties in the existing output (ie. Those properties will +// be updated). Any properties that are set to null here will mean that the +// corresponding property in the existing output will remain the same and not +// change as a result of this PATCH operation. resourceGroupName is the name of +// the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. jobName is the name of +// the streaming job. outputName is the name of the output. ifMatch is the ETag +// of the output. Omit this value to always overwrite the current output. +// Specify the last-seen ETag value to prevent accidentally overwritting +// concurrent changes. +func (client OutputsClient) Update(output Output, resourceGroupName string, jobName string, outputName string, ifMatch string) (result Output, err error) { + req, err := client.UpdatePreparer(output, resourceGroupName, jobName, outputName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.OutputsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client OutputsClient) UpdatePreparer(output Output, resourceGroupName string, jobName string, outputName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "outputName": autorest.Encode("path", outputName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/outputs/{outputName}", pathParameters), + autorest.WithJSON(output), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client OutputsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client OutputsClient) UpdateResponder(resp *http.Response) (result Output, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/streamingjobs.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/streamingjobs.go new file mode 100644 index 0000000000..1c6c2addc1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/streamingjobs.go @@ -0,0 +1,842 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// StreamingJobsClient is the composite Swagger for Stream Analytics Client +type StreamingJobsClient struct { + ManagementClient +} + +// NewStreamingJobsClient creates an instance of the StreamingJobsClient +// client. +func NewStreamingJobsClient(subscriptionID string) StreamingJobsClient { + return NewStreamingJobsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewStreamingJobsClientWithBaseURI creates an instance of the +// StreamingJobsClient client. +func NewStreamingJobsClientWithBaseURI(baseURI string, subscriptionID string) StreamingJobsClient { + return StreamingJobsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrReplace creates a streaming job or replaces an already existing +// streaming job. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. +// +// streamingJob is the definition of the streaming job that will be used to +// create a new streaming job or replace the existing one. resourceGroupName is +// the name of the resource group that contains the resource. You can obtain +// this value from the Azure Resource Manager API or the portal. jobName is the +// name of the streaming job. ifMatch is the ETag of the streaming job. Omit +// this value to always overwrite the current record set. Specify the last-seen +// ETag value to prevent accidentally overwritting concurrent changes. +// ifNoneMatch is set to '*' to allow a new streaming job to be created, but to +// prevent updating an existing record set. Other values will result in a 412 +// Pre-condition Failed response. +func (client StreamingJobsClient) CreateOrReplace(streamingJob StreamingJob, resourceGroupName string, jobName string, ifMatch string, ifNoneMatch string, cancel <-chan struct{}) (<-chan StreamingJob, <-chan error) { + resultChan := make(chan StreamingJob, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result StreamingJob + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.CreateOrReplacePreparer(streamingJob, resourceGroupName, jobName, ifMatch, ifNoneMatch, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "CreateOrReplace", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrReplaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "CreateOrReplace", resp, "Failure sending request") + return + } + + result, err = client.CreateOrReplaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "CreateOrReplace", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// CreateOrReplacePreparer prepares the CreateOrReplace request. +func (client StreamingJobsClient) CreateOrReplacePreparer(streamingJob StreamingJob, resourceGroupName string, jobName string, ifMatch string, ifNoneMatch string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}", pathParameters), + autorest.WithJSON(streamingJob), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + if len(ifNoneMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) + } + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// CreateOrReplaceSender sends the CreateOrReplace request. The method will close the +// http.Response Body if it receives an error. +func (client StreamingJobsClient) CreateOrReplaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// CreateOrReplaceResponder handles the response to the CreateOrReplace request. The method always +// closes the http.Response Body. +func (client StreamingJobsClient) CreateOrReplaceResponder(resp *http.Response) (result StreamingJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a streaming job. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. +func (client StreamingJobsClient) Delete(resourceGroupName string, jobName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.DeletePreparer(resourceGroupName, jobName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Delete", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// DeletePreparer prepares the Delete request. +func (client StreamingJobsClient) DeletePreparer(resourceGroupName string, jobName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client StreamingJobsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client StreamingJobsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets details about the specified streaming job. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. expand is the $expand +// OData query parameter. This is a comma-separated list of additional +// streaming job properties to include in the response, beyond the default set +// returned when this parameter is absent. The default set is all streaming job +// properties other than 'inputs', 'transformation', 'outputs', and +// 'functions'. +func (client StreamingJobsClient) Get(resourceGroupName string, jobName string, expand string) (result StreamingJob, err error) { + req, err := client.GetPreparer(resourceGroupName, jobName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client StreamingJobsClient) GetPreparer(resourceGroupName string, jobName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client StreamingJobsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client StreamingJobsClient) GetResponder(resp *http.Response) (result StreamingJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all of the streaming jobs in the given subscription. +// +// expand is the $expand OData query parameter. This is a comma-separated list +// of additional streaming job properties to include in the response, beyond +// the default set returned when this parameter is absent. The default set is +// all streaming job properties other than 'inputs', 'transformation', +// 'outputs', and 'functions'. +func (client StreamingJobsClient) List(expand string) (result StreamingJobListResult, err error) { + req, err := client.ListPreparer(expand) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client StreamingJobsClient) ListPreparer(expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StreamAnalytics/streamingjobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client StreamingJobsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client StreamingJobsClient) ListResponder(resp *http.Response) (result StreamingJobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListNextResults retrieves the next set of results, if any. +func (client StreamingJobsClient) ListNextResults(lastResults StreamingJobListResult) (result StreamingJobListResult, err error) { + req, err := lastResults.StreamingJobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "List", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "List", resp, "Failure sending next results request") + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "List", resp, "Failure responding to next results request") + } + + return +} + +// ListComplete gets all elements from the list without paging. +func (client StreamingJobsClient) ListComplete(expand string, cancel <-chan struct{}) (<-chan StreamingJob, <-chan error) { + resultChan := make(chan StreamingJob) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.List(expand) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// ListByResourceGroup lists all of the streaming jobs in the specified +// resource group. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. expand is the $expand OData query parameter. This is a +// comma-separated list of additional streaming job properties to include in +// the response, beyond the default set returned when this parameter is absent. +// The default set is all streaming job properties other than 'inputs', +// 'transformation', 'outputs', and 'functions'. +func (client StreamingJobsClient) ListByResourceGroup(resourceGroupName string, expand string) (result StreamingJobListResult, err error) { + req, err := client.ListByResourceGroupPreparer(resourceGroupName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client StreamingJobsClient) ListByResourceGroupPreparer(resourceGroupName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client StreamingJobsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client StreamingJobsClient) ListByResourceGroupResponder(resp *http.Response) (result StreamingJobListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupNextResults retrieves the next set of results, if any. +func (client StreamingJobsClient) ListByResourceGroupNextResults(lastResults StreamingJobListResult) (result StreamingJobListResult, err error) { + req, err := lastResults.StreamingJobListResultPreparer() + if err != nil { + return result, autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "ListByResourceGroup", nil, "Failure preparing next results request") + } + if req == nil { + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "ListByResourceGroup", resp, "Failure sending next results request") + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "ListByResourceGroup", resp, "Failure responding to next results request") + } + + return +} + +// ListByResourceGroupComplete gets all elements from the list without paging. +func (client StreamingJobsClient) ListByResourceGroupComplete(resourceGroupName string, expand string, cancel <-chan struct{}) (<-chan StreamingJob, <-chan error) { + resultChan := make(chan StreamingJob) + errChan := make(chan error, 1) + go func() { + defer func() { + close(resultChan) + close(errChan) + }() + list, err := client.ListByResourceGroup(resourceGroupName, expand) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + for list.NextLink != nil { + list, err = client.ListByResourceGroupNextResults(list) + if err != nil { + errChan <- err + return + } + if list.Value != nil { + for _, item := range *list.Value { + select { + case <-cancel: + return + case resultChan <- item: + // Intentionally left blank + } + } + } + } + }() + return resultChan, errChan +} + +// Start starts a streaming job. Once a job is started it will start processing +// input events and produce output. This method may poll for completion. +// Polling can be canceled by passing the cancel channel argument. The channel +// will be used to cancel polling and any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. startJobParameters is +// parameters applicable to a start streaming job operation. +func (client StreamingJobsClient) Start(resourceGroupName string, jobName string, startJobParameters *StartStreamingJobParameters, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.StartPreparer(resourceGroupName, jobName, startJobParameters, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Start", nil, "Failure preparing request") + return + } + + resp, err := client.StartSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Start", resp, "Failure sending request") + return + } + + result, err = client.StartResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Start", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// StartPreparer prepares the Start request. +func (client StreamingJobsClient) StartPreparer(resourceGroupName string, jobName string, startJobParameters *StartStreamingJobParameters, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if startJobParameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(startJobParameters)) + } + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client StreamingJobsClient) StartSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client StreamingJobsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stops a running streaming job. This will cause a running streaming job +// to stop processing input events and producing output. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. +func (client StreamingJobsClient) Stop(resourceGroupName string, jobName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { + resultChan := make(chan autorest.Response, 1) + errChan := make(chan error, 1) + go func() { + var err error + var result autorest.Response + defer func() { + if err != nil { + errChan <- err + } + resultChan <- result + close(resultChan) + close(errChan) + }() + req, err := client.StopPreparer(resourceGroupName, jobName, cancel) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Stop", resp, "Failure responding to request") + } + }() + return resultChan, errChan +} + +// StopPreparer prepares the Stop request. +func (client StreamingJobsClient) StopPreparer(resourceGroupName string, jobName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client StreamingJobsClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client StreamingJobsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Update updates an existing streaming job. This can be used to partially +// update (ie. update one or two properties) a streaming job without affecting +// the rest the job definition. +// +// streamingJob is a streaming job object. The properties specified here will +// overwrite the corresponding properties in the existing streaming job (ie. +// Those properties will be updated). Any properties that are set to null here +// will mean that the corresponding property in the existing input will remain +// the same and not change as a result of this PATCH operation. +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. ifMatch is the ETag of +// the streaming job. Omit this value to always overwrite the current record +// set. Specify the last-seen ETag value to prevent accidentally overwritting +// concurrent changes. +func (client StreamingJobsClient) Update(streamingJob StreamingJob, resourceGroupName string, jobName string, ifMatch string) (result StreamingJob, err error) { + req, err := client.UpdatePreparer(streamingJob, resourceGroupName, jobName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.StreamingJobsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client StreamingJobsClient) UpdatePreparer(streamingJob StreamingJob, resourceGroupName string, jobName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}", pathParameters), + autorest.WithJSON(streamingJob), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client StreamingJobsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client StreamingJobsClient) UpdateResponder(resp *http.Response) (result StreamingJob, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/subscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/subscriptions.go new file mode 100644 index 0000000000..4bde29076e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/subscriptions.go @@ -0,0 +1,109 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// SubscriptionsClient is the composite Swagger for Stream Analytics Client +type SubscriptionsClient struct { + ManagementClient +} + +// NewSubscriptionsClient creates an instance of the SubscriptionsClient +// client. +func NewSubscriptionsClient(subscriptionID string) SubscriptionsClient { + return NewSubscriptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionsClientWithBaseURI creates an instance of the +// SubscriptionsClient client. +func NewSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionsClient { + return SubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListQuotas retrieves the subscription's current quota information in a +// particular region. +// +// location is the region in which to retrieve the subscription's quota +// information. You can find out which regions Azure Stream Analytics is +// supported in here: https://azure.microsoft.com/en-us/regions/ +func (client SubscriptionsClient) ListQuotas(location string) (result SubscriptionQuotasListResult, err error) { + req, err := client.ListQuotasPreparer(location) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.SubscriptionsClient", "ListQuotas", nil, "Failure preparing request") + return + } + + resp, err := client.ListQuotasSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.SubscriptionsClient", "ListQuotas", resp, "Failure sending request") + return + } + + result, err = client.ListQuotasResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.SubscriptionsClient", "ListQuotas", resp, "Failure responding to request") + } + + return +} + +// ListQuotasPreparer prepares the ListQuotas request. +func (client SubscriptionsClient) ListQuotasPreparer(location string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.StreamAnalytics/locations/{location}/quotas", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ListQuotasSender sends the ListQuotas request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) ListQuotasSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ListQuotasResponder handles the response to the ListQuotas request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) ListQuotasResponder(resp *http.Response) (result SubscriptionQuotasListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/transformations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/transformations.go new file mode 100644 index 0000000000..67b8d858ba --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/transformations.go @@ -0,0 +1,284 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// TransformationsClient is the composite Swagger for Stream Analytics Client +type TransformationsClient struct { + ManagementClient +} + +// NewTransformationsClient creates an instance of the TransformationsClient +// client. +func NewTransformationsClient(subscriptionID string) TransformationsClient { + return NewTransformationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransformationsClientWithBaseURI creates an instance of the +// TransformationsClient client. +func NewTransformationsClientWithBaseURI(baseURI string, subscriptionID string) TransformationsClient { + return TransformationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrReplace creates a transformation or replaces an already existing +// transformation under an existing streaming job. +// +// transformation is the definition of the transformation that will be used to +// create a new transformation or replace the existing one under the streaming +// job. resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. transformationName is +// the name of the transformation. ifMatch is the ETag of the transformation. +// Omit this value to always overwrite the current transformation. Specify the +// last-seen ETag value to prevent accidentally overwritting concurrent +// changes. ifNoneMatch is set to '*' to allow a new transformation to be +// created, but to prevent updating an existing transformation. Other values +// will result in a 412 Pre-condition Failed response. +func (client TransformationsClient) CreateOrReplace(transformation Transformation, resourceGroupName string, jobName string, transformationName string, ifMatch string, ifNoneMatch string) (result Transformation, err error) { + req, err := client.CreateOrReplacePreparer(transformation, resourceGroupName, jobName, transformationName, ifMatch, ifNoneMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "CreateOrReplace", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrReplaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "CreateOrReplace", resp, "Failure sending request") + return + } + + result, err = client.CreateOrReplaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "CreateOrReplace", resp, "Failure responding to request") + } + + return +} + +// CreateOrReplacePreparer prepares the CreateOrReplace request. +func (client TransformationsClient) CreateOrReplacePreparer(transformation Transformation, resourceGroupName string, jobName string, transformationName string, ifMatch string, ifNoneMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "transformationName": autorest.Encode("path", transformationName), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/transformations/{transformationName}", pathParameters), + autorest.WithJSON(transformation), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + if len(ifNoneMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// CreateOrReplaceSender sends the CreateOrReplace request. The method will close the +// http.Response Body if it receives an error. +func (client TransformationsClient) CreateOrReplaceSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// CreateOrReplaceResponder handles the response to the CreateOrReplace request. The method always +// closes the http.Response Body. +func (client TransformationsClient) CreateOrReplaceResponder(resp *http.Response) (result Transformation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets details about the specified transformation. +// +// resourceGroupName is the name of the resource group that contains the +// resource. You can obtain this value from the Azure Resource Manager API or +// the portal. jobName is the name of the streaming job. transformationName is +// the name of the transformation. +func (client TransformationsClient) Get(resourceGroupName string, jobName string, transformationName string) (result Transformation, err error) { + req, err := client.GetPreparer(resourceGroupName, jobName, transformationName) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TransformationsClient) GetPreparer(resourceGroupName string, jobName string, transformationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "transformationName": autorest.Encode("path", transformationName), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/transformations/{transformationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client TransformationsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client TransformationsClient) GetResponder(resp *http.Response) (result Transformation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates an existing transformation under an existing streaming job. +// This can be used to partially update (ie. update one or two properties) a +// transformation without affecting the rest the job or transformation +// definition. +// +// transformation is a Transformation object. The properties specified here +// will overwrite the corresponding properties in the existing transformation +// (ie. Those properties will be updated). Any properties that are set to null +// here will mean that the corresponding property in the existing +// transformation will remain the same and not change as a result of this PATCH +// operation. resourceGroupName is the name of the resource group that contains +// the resource. You can obtain this value from the Azure Resource Manager API +// or the portal. jobName is the name of the streaming job. transformationName +// is the name of the transformation. ifMatch is the ETag of the +// transformation. Omit this value to always overwrite the current +// transformation. Specify the last-seen ETag value to prevent accidentally +// overwritting concurrent changes. +func (client TransformationsClient) Update(transformation Transformation, resourceGroupName string, jobName string, transformationName string, ifMatch string) (result Transformation, err error) { + req, err := client.UpdatePreparer(transformation, resourceGroupName, jobName, transformationName, ifMatch) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "streamanalytics.TransformationsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client TransformationsClient) UpdatePreparer(transformation Transformation, resourceGroupName string, jobName string, transformationName string, ifMatch string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "jobName": autorest.Encode("path", jobName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "transformationName": autorest.Encode("path", transformationName), + } + + const APIVersion = "2016-03-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StreamAnalytics/streamingjobs/{jobName}/transformations/{transformationName}", pathParameters), + autorest.WithJSON(transformation), + autorest.WithQueryParameters(queryParameters)) + if len(ifMatch) > 0 { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithHeader("If-Match", autorest.String(ifMatch))) + } + return preparer.Prepare(&http.Request{}) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client TransformationsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client TransformationsClient) UpdateResponder(resp *http.Response) (result Transformation, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/version.go new file mode 100644 index 0000000000..3d77951336 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/streamanalytics/version.go @@ -0,0 +1,29 @@ +package streamanalytics + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/v10.1.0-beta arm-streamanalytics/" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "v10.1.0-beta" +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go index eeb14d3fc2..20099f00d8 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go @@ -20,10 +20,10 @@ package trafficmanager // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-trafficmanager/2015-11-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-trafficmanager/2015-11-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/version.go index 4593788bed..1fbc7a1a2e 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/web/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/web/version.go @@ -20,10 +20,10 @@ package web // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-web/" + return "Azure-SDK-For-Go/v10.1.0-beta arm-web/" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/buildTerraform.sh b/vendor/github.com/Azure/azure-sdk-for-go/buildTerraform.sh new file mode 100644 index 0000000000..9c622dfdf9 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/buildTerraform.sh @@ -0,0 +1,36 @@ +# This script tries to build Terraform related packages, +# and find possible breaking changes regarding the Azure +# SDK for Go + +set -x + +# This should only run on cronjobs +if [ "cron" != $TRAVIS_EVENT_TYPE ]; then + exit 0 +fi + +# Only meant to run on latest go version +if [ "go version go1.8 linux/amd64" != "$(go version)" ]; then + exit 0 +fi + +go get github.com/kardianos/govendor +REALEXITSTATUS=0 + +packages=(github.com/hashicorp/terraform + github.com/terraform-providers/terraform-provider-azurerm + github.com/terraform-providers/terraform-provider-azure) + +for package in ${packages[*]}; do + go get $package + cd $GOPATH/src/$package + + # update to latest SDK + govendor update github.com/Azure/azure-sdk-for-go/... + + # try to build + make + REALEXITSTATUS=$(($REALEXITSTATUS+$?)) +done + +exit $REALEXITSTATUS diff --git a/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/version.go b/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/version.go index 261b26561b..f03a8c0673 100755 --- a/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/datalake-store/filesystem/version.go @@ -20,10 +20,10 @@ package filesystem // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-filesystem/2016-11-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-filesystem/2016-11-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/dataplane/keyvault/version.go b/vendor/github.com/Azure/azure-sdk-for-go/dataplane/keyvault/version.go index 05d3b354fa..0ac0f3d57d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/dataplane/keyvault/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/dataplane/keyvault/version.go @@ -20,10 +20,10 @@ package keyvault // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/v10.0.2-beta arm-keyvault/2016-10-01" + return "Azure-SDK-For-Go/v10.1.0-beta arm-keyvault/2016-10-01" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return "v10.0.2-beta" + return "v10.1.0-beta" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/glide.lock b/vendor/github.com/Azure/azure-sdk-for-go/glide.lock index 3ed83e2e7c..a2d93fc445 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/glide.lock +++ b/vendor/github.com/Azure/azure-sdk-for-go/glide.lock @@ -1,17 +1,17 @@ -hash: fc11c273a4bfae9a077f2238a4693fa3af3d815dfc1b1e9ec75d9eb8e6428993 -updated: 2017-05-04T15:24:51.52099-07:00 +hash: 7a8f8652a17526f090124ace3974ce9bff3d6d09a83ab94841d377c1125111f7 +updated: 2017-06-12T16:27:58.5460985-07:00 imports: - name: github.com/Azure/go-autorest - version: 58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d + version: "" subpackages: - autorest + - autorest/adal - autorest/azure - autorest/date - autorest/to - autorest/validation - - autorest/adal - name: github.com/dgrijalva/jwt-go - version: 2268707a8f0843315e2004ee4f1d021dc08baedf + version: a539ee1a749a2b895533f979515ac7e6e0f5b650 - name: github.com/howeyc/gopass version: bf9dde6d0d2c004a008c27aaee91170c786f6db8 - name: github.com/mattn/go-colorable @@ -33,15 +33,20 @@ imports: - name: github.com/satori/uuid version: 5bf94b69c6b68ee1b541973bb8e1144db23a194b - name: github.com/shopspring/decimal - version: 3526cd0bdb7f64e1178943b7dee81a0cc3d86a69 + version: 16a941821474ee3986fdbeab535a68a8aa5a85d2 +- name: github.com/xtophs/azure-sdk-for-go + version: 76fc90689773168d2b6b8ad02e42ab60fb1359b7 + subpackages: + - arm/dns + - arm/examples/helpers - name: golang.org/x/crypto - version: 5a033cc77e57eca05bdb50522851d29e03569cbe + version: e7ba82683099cae71475961448ab8f903ea77c26 subpackages: - pkcs12 - pkcs12/internal/rc2 - ssh/terminal - name: golang.org/x/sys - version: 9ccfe848b9db8435a24c424abbc07a921adf1df5 + version: 0b25a408a50076fbbcae6b7ac0ea5fbb0b085e79 subpackages: - unix - name: gopkg.in/check.v1 diff --git a/vendor/github.com/Azure/azure-sdk-for-go/glide.yaml b/vendor/github.com/Azure/azure-sdk-for-go/glide.yaml index efd3da4aad..b0208502af 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/glide.yaml +++ b/vendor/github.com/Azure/azure-sdk-for-go/glide.yaml @@ -1,7 +1,7 @@ package: github.com/Azure/azure-sdk-for-go import: - package: github.com/Azure/go-autorest - version: ~8.0.0 + version: ~8.1.0 subpackages: - /autorest - autorest/azure diff --git a/vendor/github.com/Azure/azure-sdk-for-go/management/version.go b/vendor/github.com/Azure/azure-sdk-for-go/management/version.go index a1035e189a..23c3b088d5 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/management/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/management/version.go @@ -1,5 +1,5 @@ package management var ( - sdkVersion = "10.0.2-beta" + sdkVersion = "v10.1.0-beta" ) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go index dd9eb386cb..b6cc0caab1 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go @@ -192,7 +192,7 @@ func (b *Blob) Get(options *GetBlobOptions) (io.ReadCloser, error) { if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { return nil, err } - if err := b.writePropoerties(resp.headers); err != nil { + if err := b.writeProperties(resp.headers, true); err != nil { return resp.body, err } return resp.body, nil @@ -212,7 +212,9 @@ func (b *Blob) GetRange(options *GetBlobRangeOptions) (io.ReadCloser, error) { if err := checkRespCode(resp.statusCode, []int{http.StatusPartialContent}); err != nil { return nil, err } - if err := b.writePropoerties(resp.headers); err != nil { + // Content-Length header should not be updated, as the service returns the range length + // (which is not alwys the full blob length) + if err := b.writeProperties(resp.headers, false); err != nil { return resp.body, err } return resp.body, nil @@ -322,18 +324,20 @@ func (b *Blob) GetProperties(options *GetBlobPropertiesOptions) error { if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { return err } - return b.writePropoerties(resp.headers) + return b.writeProperties(resp.headers, true) } -func (b *Blob) writePropoerties(h http.Header) error { +func (b *Blob) writeProperties(h http.Header, includeContentLen bool) error { var err error - var contentLength int64 - contentLengthStr := h.Get("Content-Length") - if contentLengthStr != "" { - contentLength, err = strconv.ParseInt(contentLengthStr, 0, 64) - if err != nil { - return err + contentLength := b.Properties.ContentLength + if includeContentLen { + contentLengthStr := h.Get("Content-Length") + if contentLengthStr != "" { + contentLength, err = strconv.ParseInt(contentLengthStr, 0, 64) + if err != nil { + return err + } } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob_test.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob_test.go index a70b518bf4..4cd872978a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob_test.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob_test.go @@ -445,6 +445,9 @@ func (s *StorageBlobSuite) TestGetBlobRange(c *chk.C) { }, } + err := b.GetProperties(nil) + c.Assert(err, chk.IsNil) + // Read 1-3 for _, r := range cases { resp, err := b.GetRange(&(r.options)) @@ -455,8 +458,8 @@ func (s *StorageBlobSuite) TestGetBlobRange(c *chk.C) { str := string(blobBody) c.Assert(str, chk.Equals, r.expected) - // Was content lenght properly updated...? - c.Assert(b.Properties.ContentLength, chk.Equals, int64(len(r.expected))) + // Was content length left untouched? + c.Assert(b.Properties.ContentLength, chk.Equals, int64(len(body))) } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blockblob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blockblob.go index 6a180d48d7..cb773abee0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/blockblob.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blockblob.go @@ -91,12 +91,21 @@ func (b *Blob) CreateBlockBlobFromReader(blob io.Reader, options *PutBlobOptions var n int64 var err error if blob != nil { - buf := &bytes.Buffer{} - n, err = io.Copy(buf, blob) - if err != nil { - return err + type lener interface { + Len() int } - blob = buf + // TODO(rjeczalik): handle io.ReadSeeker, in case blob is *os.File etc. + if l, ok := blob.(lener); ok { + n = int64(l.Len()) + } else { + var buf bytes.Buffer + n, err = io.Copy(&buf, blob) + if err != nil { + return err + } + blob = &buf + } + headers["Content-Length"] = strconv.FormatInt(n, 10) } b.Properties.ContentLength = n diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go index 8671e52eb7..678eff0365 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go @@ -75,19 +75,13 @@ type DefaultSender struct { // Send is the default retry strategy in the client func (ds *DefaultSender) Send(c *Client, req *http.Request) (resp *http.Response, err error) { - b := []byte{} - if req.Body != nil { - b, err = ioutil.ReadAll(req.Body) + rr := autorest.NewRetriableRequest(req) + for attempts := 0; attempts < ds.RetryAttempts; attempts++ { + err = rr.Prepare() if err != nil { return resp, err } - } - - for attempts := 0; attempts < ds.RetryAttempts; attempts++ { - if len(b) > 0 { - req.Body = ioutil.NopCloser(bytes.NewBuffer(b)) - } - resp, err = c.HTTPClient.Do(req) + resp, err = c.HTTPClient.Do(rr.Request()) if err != nil || !autorest.ResponseHasStatusCode(resp, ds.ValidStatusCodes...) { return resp, err } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/recordings/StorageBlobSuite/TestGetBlobRange.yaml b/vendor/github.com/Azure/azure-sdk-for-go/storage/recordings/StorageBlobSuite/TestGetBlobRange.yaml index c61350bb11..c3e30fe93b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/recordings/StorageBlobSuite/TestGetBlobRange.yaml +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/recordings/StorageBlobSuite/TestGetBlobRange.yaml @@ -7,11 +7,11 @@ interactions: form: {} headers: Authorization: - - SharedKey golangrocksonazure:9nu8qK4mFGC/UbUgj//IsZH4NainTKsjMiM8DO8A7Uk= + - SharedKey golangrocksonazure:pZ/A0l5JN6e0ezT8qnHyBkgRWCvirN0z7AcFSXZLZWY= User-Agent: - - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob + - Go/go1.8 (amd64-windows) azure-storage-go/10.0.2 api-version/2016-05-31 blob X-Ms-Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT X-Ms-Version: - 2016-05-31 url: https://golangrocksonazure.blob.core.windows.net/cnt-33storageblobsuitetestgetblo?restype=container @@ -20,15 +20,15 @@ interactions: body: "" headers: Date: - - Wed, 05 Apr 2017 22:33:04 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Etag: - - '"0x8D47C73BA218DA4"' + - '"0x8D4B833ADD22D8C"' Last-Modified: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 X-Ms-Request-Id: - - 5eac2cf9-0001-00d8-665c-aea568000000 + - 113a5b98-0001-005d-7f1c-eaf2bd000000 X-Ms-Version: - 2016-05-31 status: 201 Created @@ -38,15 +38,15 @@ interactions: form: {} headers: Authorization: - - SharedKey golangrocksonazure:avRKkLQKSRGQRUT0nQoWpYyobsr5W+aJVLl8j122A70= + - SharedKey golangrocksonazure:S/yvUFpg3v7olGm/w15D6AbZsRlYCnS/IXPOzZAPlIw= Content-Length: - "10" User-Agent: - - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob + - Go/go1.8 (amd64-windows) azure-storage-go/10.0.2 api-version/2016-05-31 blob X-Ms-Blob-Type: - BlockBlob X-Ms-Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT X-Ms-Version: - 2016-05-31 url: https://golangrocksonazure.blob.core.windows.net/cnt-33storageblobsuitetestgetblo/blob/33storageblobsuitetestgetblobrange @@ -57,15 +57,15 @@ interactions: Content-Md5: - eB5eJF1ptWaXm4bijSPyxw== Date: - - Wed, 05 Apr 2017 22:33:04 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Etag: - - '"0x8D47C73BA1451F6"' + - '"0x8D4B833ADE84B89"' Last-Modified: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 X-Ms-Request-Id: - - 5eac2d0c-0001-00d8-785c-aea568000000 + - 113a5ba2-0001-005d-071c-eaf2bd000000 X-Ms-Request-Server-Encrypted: - "false" X-Ms-Version: @@ -77,13 +77,60 @@ interactions: form: {} headers: Authorization: - - SharedKey golangrocksonazure:lFVzR4t40cNBijPob1rFkS/ZA9xlAaNDJurdN6+CHOk= + - SharedKey golangrocksonazure:5Tzr47WYoIDIptFgDwx8AX1l7JG7qTybS7ta5rEl0T8= + User-Agent: + - Go/go1.8 (amd64-windows) azure-storage-go/10.0.2 api-version/2016-05-31 blob + X-Ms-Date: + - Tue, 20 Jun 2017 23:25:46 GMT + X-Ms-Version: + - 2016-05-31 + url: https://golangrocksonazure.blob.core.windows.net/cnt-33storageblobsuitetestgetblo/blob/33storageblobsuitetestgetblobrange + method: HEAD + response: + body: "" + headers: + Accept-Ranges: + - bytes + Content-Length: + - "10" + Content-Md5: + - eB5eJF1ptWaXm4bijSPyxw== + Content-Type: + - application/octet-stream + Date: + - Tue, 20 Jun 2017 23:25:46 GMT + Etag: + - '"0x8D4B833ADE84B89"' + Last-Modified: + - Tue, 20 Jun 2017 23:25:46 GMT + Server: + - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 + X-Ms-Blob-Type: + - BlockBlob + X-Ms-Lease-State: + - available + X-Ms-Lease-Status: + - unlocked + X-Ms-Request-Id: + - 113a5ba7-0001-005d-0b1c-eaf2bd000000 + X-Ms-Server-Encrypted: + - "false" + X-Ms-Version: + - 2016-05-31 + status: 200 OK + code: 200 +- request: + body: "" + form: {} + headers: + Authorization: + - SharedKey golangrocksonazure:a93ItKcxLZLLci7k+1vTcD25OE3ItaS70O39rwW5Cmc= Range: - bytes=0-10 User-Agent: - - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob + - Go/go1.8 (amd64-windows) azure-storage-go/10.0.2 api-version/2016-05-31 blob X-Ms-Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT X-Ms-Range-Get-Content-Md5: - "false" X-Ms-Version: @@ -102,11 +149,11 @@ interactions: Content-Type: - application/octet-stream Date: - - Wed, 05 Apr 2017 22:33:04 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Etag: - - '"0x8D47C73BA1451F6"' + - '"0x8D4B833ADE84B89"' Last-Modified: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 X-Ms-Blob-Content-Md5: @@ -118,7 +165,7 @@ interactions: X-Ms-Lease-Status: - unlocked X-Ms-Request-Id: - - 5eac2d1d-0001-00d8-065c-aea568000000 + - 113a5bb0-0001-005d-121c-eaf2bd000000 X-Ms-Server-Encrypted: - "false" X-Ms-Version: @@ -130,13 +177,13 @@ interactions: form: {} headers: Authorization: - - SharedKey golangrocksonazure:oEk8/ERI3igcGa9njGqs+roCTHkYuUaK2MiydYMO9a4= + - SharedKey golangrocksonazure:m8RD+VJXRLV87dxPO/mJCFJPZzzD32MO3+dI2I7vU1s= Range: - bytes=1-3 User-Agent: - - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob + - Go/go1.8 (amd64-windows) azure-storage-go/10.0.2 api-version/2016-05-31 blob X-Ms-Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT X-Ms-Range-Get-Content-Md5: - "false" X-Ms-Version: @@ -155,11 +202,11 @@ interactions: Content-Type: - application/octet-stream Date: - - Wed, 05 Apr 2017 22:33:04 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Etag: - - '"0x8D47C73BA1451F6"' + - '"0x8D4B833ADE84B89"' Last-Modified: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 X-Ms-Blob-Content-Md5: @@ -171,7 +218,7 @@ interactions: X-Ms-Lease-Status: - unlocked X-Ms-Request-Id: - - 5eac2d3e-0001-00d8-225c-aea568000000 + - 113a5bb9-0001-005d-1b1c-eaf2bd000000 X-Ms-Server-Encrypted: - "false" X-Ms-Version: @@ -183,13 +230,13 @@ interactions: form: {} headers: Authorization: - - SharedKey golangrocksonazure:MbL6csYCAxYabbcUsptWzsxpx+l04t0e8xku6v0ULSQ= + - SharedKey golangrocksonazure:4OJ/SF1EZ/q2XRcVBYih1vE51mvqSdI+S7H4pW++JVw= Range: - bytes=3-10 User-Agent: - - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob + - Go/go1.8 (amd64-windows) azure-storage-go/10.0.2 api-version/2016-05-31 blob X-Ms-Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT X-Ms-Range-Get-Content-Md5: - "false" X-Ms-Version: @@ -208,11 +255,11 @@ interactions: Content-Type: - application/octet-stream Date: - - Wed, 05 Apr 2017 22:33:04 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Etag: - - '"0x8D47C73BA1451F6"' + - '"0x8D4B833ADE84B89"' Last-Modified: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 X-Ms-Blob-Content-Md5: @@ -224,7 +271,7 @@ interactions: X-Ms-Lease-Status: - unlocked X-Ms-Request-Id: - - 5eac2d4b-0001-00d8-2f5c-aea568000000 + - 113a5bc3-0001-005d-241c-eaf2bd000000 X-Ms-Server-Encrypted: - "false" X-Ms-Version: @@ -236,11 +283,11 @@ interactions: form: {} headers: Authorization: - - SharedKey golangrocksonazure:OGcfBLsvzDc8wWTIGpBzxsmOZGUDL8/T+HIgSUcHkWU= + - SharedKey golangrocksonazure:E3A+K0iwV7rVN+ok5ge/voez+59qknJ6sxUQIm8fGbg= User-Agent: - - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob + - Go/go1.8 (amd64-windows) azure-storage-go/10.0.2 api-version/2016-05-31 blob X-Ms-Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT X-Ms-Version: - 2016-05-31 url: https://golangrocksonazure.blob.core.windows.net/cnt-33storageblobsuitetestgetblo/blob/33storageblobsuitetestgetblobrange @@ -249,11 +296,11 @@ interactions: body: "" headers: Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 X-Ms-Request-Id: - - 5eac2d57-0001-00d8-3a5c-aea568000000 + - 113a5bd1-0001-005d-2d1c-eaf2bd000000 X-Ms-Version: - 2016-05-31 status: 202 Accepted @@ -263,11 +310,11 @@ interactions: form: {} headers: Authorization: - - SharedKey golangrocksonazure:aP7h0bJk2tRp12fcdHneFnVlWRhaS45ir7+Tqv3Bs2I= + - SharedKey golangrocksonazure:PavmFOyCeAplLXJTXPO6ImS49LAuAyWhYKomu0N/2pA= User-Agent: - - Go/go1.8 (amd64-windows) azure-storage-go/0.1.0 api-version/2016-05-31 blob + - Go/go1.8 (amd64-windows) azure-storage-go/10.0.2 api-version/2016-05-31 blob X-Ms-Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT X-Ms-Version: - 2016-05-31 url: https://golangrocksonazure.blob.core.windows.net/cnt-33storageblobsuitetestgetblo?restype=container @@ -276,11 +323,11 @@ interactions: body: "" headers: Date: - - Wed, 05 Apr 2017 22:33:05 GMT + - Tue, 20 Jun 2017 23:25:46 GMT Server: - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 X-Ms-Request-Id: - - 5eac2d6a-0001-00d8-4a5c-aea568000000 + - 113a5bd5-0001-005d-311c-eaf2bd000000 X-Ms-Version: - 2016-05-31 status: 202 Accepted diff --git a/vendor/github.com/Azure/go-autorest/autorest/retriablerequest.go b/vendor/github.com/Azure/go-autorest/autorest/retriablerequest.go new file mode 100644 index 0000000000..5cab8711b3 --- /dev/null +++ b/vendor/github.com/Azure/go-autorest/autorest/retriablerequest.go @@ -0,0 +1,77 @@ +package autorest + +import ( + "bytes" + "io" + "io/ioutil" + "net/http" +) + +// NOTE: the GetBody() method on the http.Request object is new in 1.8. +// at present we support 1.7 and 1.8 so for now the branches specific +// to 1.8 have been commented out. + +// RetriableRequest provides facilities for retrying an HTTP request. +type RetriableRequest struct { + req *http.Request + //rc io.ReadCloser + br *bytes.Reader + reset bool +} + +// NewRetriableRequest returns a wrapper around an HTTP request that support retry logic. +func NewRetriableRequest(req *http.Request) *RetriableRequest { + return &RetriableRequest{req: req} +} + +// Request returns the wrapped HTTP request. +func (rr *RetriableRequest) Request() *http.Request { + return rr.req +} + +// Prepare signals that the request is about to be sent. +func (rr *RetriableRequest) Prepare() (err error) { + // preserve the request body; this is to support retry logic as + // the underlying transport will always close the reqeust body + if rr.req.Body != nil { + if rr.reset { + /*if rr.rc != nil { + rr.req.Body = rr.rc + } else */if rr.br != nil { + _, err = rr.br.Seek(0, io.SeekStart) + } + rr.reset = false + if err != nil { + return err + } + } + /*if rr.req.GetBody != nil { + // this will allow us to preserve the body without having to + // make a copy. note we need to do this on each iteration + rr.rc, err = rr.req.GetBody() + if err != nil { + return err + } + } else */if rr.br == nil { + // fall back to making a copy (only do this once) + b := []byte{} + if rr.req.ContentLength > 0 { + b = make([]byte, rr.req.ContentLength) + _, err = io.ReadFull(rr.req.Body, b) + if err != nil { + return err + } + } else { + b, err = ioutil.ReadAll(rr.req.Body) + if err != nil { + return err + } + } + rr.br = bytes.NewReader(b) + rr.req.Body = ioutil.NopCloser(rr.br) + } + // indicates that the request body needs to be reset + rr.reset = true + } + return err +} diff --git a/vendor/github.com/Azure/go-autorest/autorest/sender.go b/vendor/github.com/Azure/go-autorest/autorest/sender.go index 9c0697815b..9b88f329a8 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/sender.go +++ b/vendor/github.com/Azure/go-autorest/autorest/sender.go @@ -1,9 +1,7 @@ package autorest import ( - "bytes" "fmt" - "io/ioutil" "log" "math" "net/http" @@ -175,8 +173,13 @@ func DoPollForStatusCodes(duration time.Duration, delay time.Duration, codes ... func DoRetryForAttempts(attempts int, backoff time.Duration) SendDecorator { return func(s Sender) Sender { return SenderFunc(func(r *http.Request) (resp *http.Response, err error) { + rr := NewRetriableRequest(r) for attempt := 0; attempt < attempts; attempt++ { - resp, err = s.Do(r) + err = rr.Prepare() + if err != nil { + return resp, err + } + resp, err = s.Do(rr.Request()) if err == nil { return resp, err } @@ -194,19 +197,15 @@ func DoRetryForAttempts(attempts int, backoff time.Duration) SendDecorator { func DoRetryForStatusCodes(attempts int, backoff time.Duration, codes ...int) SendDecorator { return func(s Sender) Sender { return SenderFunc(func(r *http.Request) (resp *http.Response, err error) { - b := []byte{} - if r.Body != nil { - b, err = ioutil.ReadAll(r.Body) - if err != nil { - return resp, err - } - } - + rr := NewRetriableRequest(r) // Increment to add the first call (attempts denotes number of retries) attempts++ for attempt := 0; attempt < attempts; attempt++ { - r.Body = ioutil.NopCloser(bytes.NewBuffer(b)) - resp, err = s.Do(r) + err = rr.Prepare() + if err != nil { + return resp, err + } + resp, err = s.Do(rr.Request()) if err != nil || !ResponseHasStatusCode(resp, codes...) { return resp, err } @@ -224,9 +223,14 @@ func DoRetryForStatusCodes(attempts int, backoff time.Duration, codes ...int) Se func DoRetryForDuration(d time.Duration, backoff time.Duration) SendDecorator { return func(s Sender) Sender { return SenderFunc(func(r *http.Request) (resp *http.Response, err error) { + rr := NewRetriableRequest(r) end := time.Now().Add(d) for attempt := 0; time.Now().Before(end); attempt++ { - resp, err = s.Do(r) + err = rr.Prepare() + if err != nil { + return resp, err + } + resp, err = s.Do(rr.Request()) if err == nil { return resp, err } diff --git a/vendor/github.com/go-playground/locales/.gitignore b/vendor/github.com/go-playground/locales/.gitignore new file mode 100644 index 0000000000..daf913b1b3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/go-playground/locales/LICENSE b/vendor/github.com/go-playground/locales/LICENSE new file mode 100644 index 0000000000..75854ac4f0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Go Playground + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/go-playground/locales/README.md b/vendor/github.com/go-playground/locales/README.md new file mode 100644 index 0000000000..ee268bd5a8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/README.md @@ -0,0 +1,172 @@ +## locales +![Project status](https://img.shields.io/badge/version-0.11.1-green.svg) +[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/locales/branches/master/badge.svg)](https://semaphoreci.com/joeybloggs/locales) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/locales)](https://goreportcard.com/report/github.com/go-playground/locales) +[![GoDoc](https://godoc.org/github.com/go-playground/locales?status.svg)](https://godoc.org/github.com/go-playground/locales) +![License](https://img.shields.io/dub/l/vibe-d.svg) +[![Gitter](https://badges.gitter.im/go-playground/locales.svg)](https://gitter.im/go-playground/locales?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + +Locales is a set of locales generated from the [Unicode CLDR Project](http://cldr.unicode.org/) which can be used independently or within +an i18n package; these were built for use with, but not exclusive to, [Universal Translator](https://github.com/go-playground/universal-translator). + +Features +-------- +- [x] Rules generated from the latest [CLDR](http://cldr.unicode.org/index/downloads) data, v30.0.3 +- [x] Contains Cardinal, Ordinal and Range Plural Rules +- [x] Contains Month, Weekday and Timezone translations built in +- [x] Contains Date & Time formatting functions +- [x] Contains Number, Currency, Accounting and Percent formatting functions +- [x] Supports the "Gregorian" calendar only ( my time isn't unlimited, had to draw the line somewhere ) + +Full Tests +-------------------- +I could sure use your help adding tests for every locale, it is a huge undertaking and I just don't have the free time to do it all at the moment; +any help would be **greatly appreciated!!!!** please see [issue](https://github.com/go-playground/locales/issues/1) for details. + +Installation +----------- + +Use go get + +```shell +go get github.com/go-playground/locales +``` + +NOTES +-------- +You'll notice most return types are []byte, this is because most of the time the results will be concatenated with a larger body +of text and can avoid some allocations if already appending to a byte array, otherwise just cast as string. + +Usage +------- +```go +package main + +import ( + "fmt" + "time" + + "github.com/go-playground/locales/currency" + "github.com/go-playground/locales/en_CA" +) + +func main() { + + loc, _ := time.LoadLocation("America/Toronto") + datetime := time.Date(2016, 02, 03, 9, 0, 1, 0, loc) + + l := en_CA.New() + + // Dates + fmt.Println(l.FmtDateFull(datetime)) + fmt.Println(l.FmtDateLong(datetime)) + fmt.Println(l.FmtDateMedium(datetime)) + fmt.Println(l.FmtDateShort(datetime)) + + // Times + fmt.Println(l.FmtTimeFull(datetime)) + fmt.Println(l.FmtTimeLong(datetime)) + fmt.Println(l.FmtTimeMedium(datetime)) + fmt.Println(l.FmtTimeShort(datetime)) + + // Months Wide + fmt.Println(l.MonthWide(time.January)) + fmt.Println(l.MonthWide(time.February)) + fmt.Println(l.MonthWide(time.March)) + // ... + + // Months Abbreviated + fmt.Println(l.MonthAbbreviated(time.January)) + fmt.Println(l.MonthAbbreviated(time.February)) + fmt.Println(l.MonthAbbreviated(time.March)) + // ... + + // Months Narrow + fmt.Println(l.MonthNarrow(time.January)) + fmt.Println(l.MonthNarrow(time.February)) + fmt.Println(l.MonthNarrow(time.March)) + // ... + + // Weekdays Wide + fmt.Println(l.WeekdayWide(time.Sunday)) + fmt.Println(l.WeekdayWide(time.Monday)) + fmt.Println(l.WeekdayWide(time.Tuesday)) + // ... + + // Weekdays Abbreviated + fmt.Println(l.WeekdayAbbreviated(time.Sunday)) + fmt.Println(l.WeekdayAbbreviated(time.Monday)) + fmt.Println(l.WeekdayAbbreviated(time.Tuesday)) + // ... + + // Weekdays Short + fmt.Println(l.WeekdayShort(time.Sunday)) + fmt.Println(l.WeekdayShort(time.Monday)) + fmt.Println(l.WeekdayShort(time.Tuesday)) + // ... + + // Weekdays Narrow + fmt.Println(l.WeekdayNarrow(time.Sunday)) + fmt.Println(l.WeekdayNarrow(time.Monday)) + fmt.Println(l.WeekdayNarrow(time.Tuesday)) + // ... + + var f64 float64 + + f64 = -10356.4523 + + // Number + fmt.Println(l.FmtNumber(f64, 2)) + + // Currency + fmt.Println(l.FmtCurrency(f64, 2, currency.CAD)) + fmt.Println(l.FmtCurrency(f64, 2, currency.USD)) + + // Accounting + fmt.Println(l.FmtAccounting(f64, 2, currency.CAD)) + fmt.Println(l.FmtAccounting(f64, 2, currency.USD)) + + f64 = 78.12 + + // Percent + fmt.Println(l.FmtPercent(f64, 0)) + + // Plural Rules for locale, so you know what rules you must cover + fmt.Println(l.PluralsCardinal()) + fmt.Println(l.PluralsOrdinal()) + + // Cardinal Plural Rules + fmt.Println(l.CardinalPluralRule(1, 0)) + fmt.Println(l.CardinalPluralRule(1.0, 0)) + fmt.Println(l.CardinalPluralRule(1.0, 1)) + fmt.Println(l.CardinalPluralRule(3, 0)) + + // Ordinal Plural Rules + fmt.Println(l.OrdinalPluralRule(21, 0)) // 21st + fmt.Println(l.OrdinalPluralRule(22, 0)) // 22nd + fmt.Println(l.OrdinalPluralRule(33, 0)) // 33rd + fmt.Println(l.OrdinalPluralRule(34, 0)) // 34th + + // Range Plural Rules + fmt.Println(l.RangePluralRule(1, 0, 1, 0)) // 1-1 + fmt.Println(l.RangePluralRule(1, 0, 2, 0)) // 1-2 + fmt.Println(l.RangePluralRule(5, 0, 8, 0)) // 5-8 +} +``` + +NOTES: +------- +These rules were generated from the [Unicode CLDR Project](http://cldr.unicode.org/), if you encounter any issues +I strongly encourage contributing to the CLDR project to get the locale information corrected and the next time +these locales are regenerated the fix will come with. + +I do however realize that time constraints are often important and so there are two options: + +1. Create your own locale, copy, paste and modify, and ensure it complies with the `Translator` interface. +2. Add an exception in the locale generation code directly and once regenerated, fix will be in place. + +Please to not make fixes inside the locale files, they WILL get overwritten when the locales are regenerated. + +License +------ +Distributed under MIT License, please see license file in code for more details. diff --git a/vendor/github.com/go-playground/locales/af/af.go b/vendor/github.com/go-playground/locales/af/af.go new file mode 100644 index 0000000000..f220fb68dc --- /dev/null +++ b/vendor/github.com/go-playground/locales/af/af.go @@ -0,0 +1,613 @@ +package af + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type af struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'af' locale +func New() locales.Translator { + return &af{ + locale: "af", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "R", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "Mrt.", "Apr.", "Mei", "Jun.", "Jul.", "Aug.", "Sep.", "Okt.", "Nov.", "Des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januarie", "Februarie", "Maart", "April", "Mei", "Junie", "Julie", "Augustus", "September", "Oktober", "November", "Desember"}, + daysAbbreviated: []string{"So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "W", "D", "V", "S"}, + daysShort: []string{"So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."}, + daysWide: []string{"Sondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrydag", "Saterdag"}, + periodsAbbreviated: []string{"vm.", "nm."}, + periodsNarrow: []string{"v", "n"}, + periodsWide: []string{"vm.", "nm."}, + erasAbbreviated: []string{"v.C.", "n.C."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"CST": "Sentrale standaardtyd", "WIT": "Oos-Indonesië-tyd", "WEZ": "Wes-Europese standaardtyd", "EDT": "Oostelike dagligtyd", "HECU": "Kuba-dagligtyd", "ACWST": "Australiese sentraal-Westelike standaard-tyd", "JDT": "Japan-dagligtyd", "MEZ": "Sentraal-Europese standaardtyd", "MDT": "MDT", "HNPMX": "Meksikaanse Pasifiese standaardtyd", "BOT": "Bolivia-tyd", "CHADT": "Chatham-dagligtyd", "NZST": "Nieu-Seeland-standaardtyd", "VET": "Venezuela-tyd", "OEZ": "Oos-Europese standaardtyd", "BT": "Bhoetan-tyd", "HNT": "Newfoundland-standaardtyd", "AEST": "Australiese Oostelike standaardtyd", "SRT": "Suriname-tyd", "EAT": "Oos-Afrika-tyd", "AWDT": "Australiese Westelike dagligtyd", "TMT": "Turkmenistan-standaardtyd", "ACDT": "Australiese sentrale dagligtyd", "SGT": "Singapoer-standaardtyd", "CAT": "Sentraal-Afrika-tyd", "WARST": "Wes-Argentinië-somertyd", "HEOG": "Wes-Groenland-somertyd", "HEPMX": "Meksikaanse Pasifiese dagligtyd", "ACWDT": "Australiese sentraal-Westelike dagligtyd", "COST": "Colombië-somertyd", "AKDT": "Alaska-dagligtyd", "PST": "Pasifiese standaardtyd", "HENOMX": "Noordwes-Meksiko-dagligtyd", "HNCU": "Kuba-standaardtyd", "CLST": "Chili-somertyd", "HAT": "Newfoundland-dagligtyd", "HEPM": "Sint-Pierre en Miquelon-dagligtyd", "UYT": "Uruguay-standaardtyd", "MYT": "Maleisië-tyd", "WART": "Wes-Argentinië-standaardtyd", "AST": "Atlantiese standaardtyd", "WAT": "Wes-Afrika-standaardtyd", "EST": "Oostelike standaardtyd", "WITA": "Sentraal Indonesië-tyd", "AWST": "Australiese Westelike standaardtyd", "WESZ": "Wes-Europese somertyd", "HNOG": "Wes-Groenland-standaardtyd", "HKT": "Hongkong-standaardtyd", "SAST": "Suid-Afrika-standaardtyd", "CDT": "Sentrale dagligtyd", "MST": "MST", "ART": "Argentinië-standaardtyd", "OESZ": "Oos-Europese somertyd", "ARST": "Argentinië-somertyd", "WAST": "Wes-Afrika-somertyd", "HEEG": "Oos-Groenland-somertyd", "∅∅∅": "∅∅∅", "HAST": "Hawaii-Aleusiër-standaardtyd", "JST": "Japan-standaardtyd", "MESZ": "Sentraal-Europese somertyd", "IST": "Indië-standaardtyd", "ECT": "Ecuador-tyd", "PDT": "Pasifiese dagligtyd", "GFT": "Frans-Guiana-tyd", "AKST": "Alaska-standaardtyd", "HNPM": "Sint-Pierre en Miquelon-standaardtyd", "LHDT": "Lord Howe-dagligtyd", "NZDT": "Nieu-Seeland-dagligtyd", "HKST": "Hongkong-somertyd", "HNNOMX": "Noordwes-Meksiko-standaardtyd", "HADT": "Hawaii-Aleusiër-dagligtyd", "COT": "Colombië-standaardtyd", "HNEG": "Oos-Groenland-standaardtyd", "ChST": "Chamorro-standaardtyd", "LHST": "Lord Howe-standaardtyd", "GYT": "Guyana-tyd", "CHAST": "Chatham-standaardtyd", "GMT": "Greenwich-mediaantyd", "ACST": "Australiese sentraal-standaardtyd", "WIB": "Wes-Indonesië-tyd", "CLT": "Chili-standaardtyd", "AEDT": "Australiese Oostelike dagligtyd", "UYST": "Uruguay-somertyd", "ADT": "Atlantiese dagligtyd", "TMST": "Turkmenistan-somertyd"}, + } +} + +// Locale returns the current translators string locale +func (af *af) Locale() string { + return af.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'af' +func (af *af) PluralsCardinal() []locales.PluralRule { + return af.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'af' +func (af *af) PluralsOrdinal() []locales.PluralRule { + return af.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'af' +func (af *af) PluralsRange() []locales.PluralRule { + return af.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'af' +func (af *af) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'af' +func (af *af) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'af' +func (af *af) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (af *af) MonthAbbreviated(month time.Month) string { + return af.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (af *af) MonthsAbbreviated() []string { + return af.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (af *af) MonthNarrow(month time.Month) string { + return af.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (af *af) MonthsNarrow() []string { + return af.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (af *af) MonthWide(month time.Month) string { + return af.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (af *af) MonthsWide() []string { + return af.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (af *af) WeekdayAbbreviated(weekday time.Weekday) string { + return af.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (af *af) WeekdaysAbbreviated() []string { + return af.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (af *af) WeekdayNarrow(weekday time.Weekday) string { + return af.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (af *af) WeekdaysNarrow() []string { + return af.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (af *af) WeekdayShort(weekday time.Weekday) string { + return af.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (af *af) WeekdaysShort() []string { + return af.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (af *af) WeekdayWide(weekday time.Weekday) string { + return af.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (af *af) WeekdaysWide() []string { + return af.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'af' and handles both Whole and Real numbers based on 'v' +func (af *af) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'af' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (af *af) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, af.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'af' +func (af *af) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := af.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, af.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'af' +// in accounting notation. +func (af *af) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := af.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, af.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, af.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, af.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'af' +func (af *af) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'af' +func (af *af) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'af' +func (af *af) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'af' +func (af *af) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, af.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'af' +func (af *af) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'af' +func (af *af) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'af' +func (af *af) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'af' +func (af *af) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := af.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/af/af_test.go b/vendor/github.com/go-playground/locales/af/af_test.go new file mode 100644 index 0000000000..84a36153ea --- /dev/null +++ b/vendor/github.com/go-playground/locales/af/af_test.go @@ -0,0 +1,1120 @@ +package af + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "af" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/af_NA/af_NA.go b/vendor/github.com/go-playground/locales/af_NA/af_NA.go new file mode 100644 index 0000000000..6be45a290b --- /dev/null +++ b/vendor/github.com/go-playground/locales/af_NA/af_NA.go @@ -0,0 +1,600 @@ +package af_NA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type af_NA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'af_NA' locale +func New() locales.Translator { + return &af_NA{ + locale: "af_NA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "$", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "Mrt.", "Apr.", "Mei", "Jun.", "Jul.", "Aug.", "Sep.", "Okt.", "Nov.", "Des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januarie", "Februarie", "Maart", "April", "Mei", "Junie", "Julie", "Augustus", "September", "Oktober", "November", "Desember"}, + daysAbbreviated: []string{"So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "W", "D", "V", "S"}, + daysShort: []string{"So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."}, + daysWide: []string{"Sondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrydag", "Saterdag"}, + periodsAbbreviated: []string{"vm.", "nm."}, + periodsNarrow: []string{"v", "n"}, + periodsWide: []string{"vm.", "nm."}, + erasAbbreviated: []string{"v.C.", "n.C."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"HNEG": "Oos-Groenland-standaardtyd", "HEEG": "Oos-Groenland-somertyd", "LHDT": "Lord Howe-dagligtyd", "SRT": "Suriname-tyd", "GYT": "Guyana-tyd", "ADT": "Atlantiese dagligtyd", "EST": "Oostelike standaardtyd", "COST": "Colombië-somertyd", "HNCU": "Kuba-standaardtyd", "WIT": "Oos-Indonesië-tyd", "HNPM": "Sint-Pierre en Miquelon-standaardtyd", "WESZ": "Wes-Europese somertyd", "TMT": "Turkmenistan-standaardtyd", "ACDT": "Australiese sentrale dagligtyd", "AKDT": "Alaska-dagligtyd", "WITA": "Sentraal Indonesië-tyd", "LHST": "Lord Howe-standaardtyd", "WIB": "Wes-Indonesië-tyd", "CST": "Sentrale standaardtyd", "OEZ": "Oos-Europese standaardtyd", "CLST": "Chili-somertyd", "COT": "Colombië-standaardtyd", "HENOMX": "Noordwes-Meksiko-dagligtyd", "CDT": "Sentrale dagligtyd", "CAT": "Sentraal-Afrika-tyd", "JDT": "Japan-dagligtyd", "EDT": "Oostelike dagligtyd", "ART": "Argentinië-standaardtyd", "MST": "MST", "ChST": "Chamorro-standaardtyd", "ECT": "Ecuador-tyd", "IST": "Indië-standaardtyd", "ACWDT": "Australiese sentraal-Westelike dagligtyd", "VET": "Venezuela-tyd", "AWST": "Australiese Westelike standaardtyd", "TMST": "Turkmenistan-somertyd", "AEDT": "Australiese Oostelike dagligtyd", "PST": "Pasifiese standaardtyd", "ACWST": "Australiese sentraal-Westelike standaard-tyd", "ACST": "Australiese sentraal-standaardtyd", "BT": "Bhoetan-tyd", "GFT": "Frans-Guiana-tyd", "HEPMX": "Meksikaanse Pasifiese dagligtyd", "CHAST": "Chatham-standaardtyd", "HADT": "Hawaii-Aleusiër-dagligtyd", "ARST": "Argentinië-somertyd", "MDT": "MDT", "WAT": "Wes-Afrika-standaardtyd", "WAST": "Wes-Afrika-somertyd", "HAST": "Hawaii-Aleusiër-standaardtyd", "MEZ": "Sentraal-Europese standaardtyd", "WART": "Wes-Argentinië-standaardtyd", "AST": "Atlantiese standaardtyd", "EAT": "Oos-Afrika-tyd", "HKST": "Hongkong-somertyd", "HAT": "Newfoundland-dagligtyd", "SAST": "Suid-Afrika-standaardtyd", "CHADT": "Chatham-dagligtyd", "OESZ": "Oos-Europese somertyd", "HNT": "Newfoundland-standaardtyd", "HEPM": "Sint-Pierre en Miquelon-dagligtyd", "NZDT": "Nieu-Seeland-dagligtyd", "MESZ": "Sentraal-Europese somertyd", "HNOG": "Wes-Groenland-standaardtyd", "HEOG": "Wes-Groenland-somertyd", "MYT": "Maleisië-tyd", "AKST": "Alaska-standaardtyd", "UYST": "Uruguay-somertyd", "CLT": "Chili-standaardtyd", "AEST": "Australiese Oostelike standaardtyd", "BOT": "Bolivia-tyd", "WEZ": "Wes-Europese standaardtyd", "GMT": "Greenwich-mediaantyd", "WARST": "Wes-Argentinië-somertyd", "PDT": "Pasifiese dagligtyd", "NZST": "Nieu-Seeland-standaardtyd", "JST": "Japan-standaardtyd", "HKT": "Hongkong-standaardtyd", "HECU": "Kuba-dagligtyd", "∅∅∅": "Brasilië somertyd", "AWDT": "Australiese Westelike dagligtyd", "SGT": "Singapoer-standaardtyd", "HNNOMX": "Noordwes-Meksiko-standaardtyd", "UYT": "Uruguay-standaardtyd", "HNPMX": "Meksikaanse Pasifiese standaardtyd"}, + } +} + +// Locale returns the current translators string locale +func (af *af_NA) Locale() string { + return af.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'af_NA' +func (af *af_NA) PluralsCardinal() []locales.PluralRule { + return af.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'af_NA' +func (af *af_NA) PluralsOrdinal() []locales.PluralRule { + return af.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'af_NA' +func (af *af_NA) PluralsRange() []locales.PluralRule { + return af.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'af_NA' +func (af *af_NA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'af_NA' +func (af *af_NA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'af_NA' +func (af *af_NA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (af *af_NA) MonthAbbreviated(month time.Month) string { + return af.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (af *af_NA) MonthsAbbreviated() []string { + return af.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (af *af_NA) MonthNarrow(month time.Month) string { + return af.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (af *af_NA) MonthsNarrow() []string { + return af.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (af *af_NA) MonthWide(month time.Month) string { + return af.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (af *af_NA) MonthsWide() []string { + return af.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (af *af_NA) WeekdayAbbreviated(weekday time.Weekday) string { + return af.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (af *af_NA) WeekdaysAbbreviated() []string { + return af.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (af *af_NA) WeekdayNarrow(weekday time.Weekday) string { + return af.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (af *af_NA) WeekdaysNarrow() []string { + return af.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (af *af_NA) WeekdayShort(weekday time.Weekday) string { + return af.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (af *af_NA) WeekdaysShort() []string { + return af.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (af *af_NA) WeekdayWide(weekday time.Weekday) string { + return af.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (af *af_NA) WeekdaysWide() []string { + return af.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'af_NA' and handles both Whole and Real numbers based on 'v' +func (af *af_NA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'af_NA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (af *af_NA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, af.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'af_NA' +func (af *af_NA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := af.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, af.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'af_NA' +// in accounting notation. +func (af *af_NA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := af.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, af.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, af.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, af.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'af_NA' +func (af *af_NA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'af_NA' +func (af *af_NA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'af_NA' +func (af *af_NA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'af_NA' +func (af *af_NA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, af.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'af_NA' +func (af *af_NA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'af_NA' +func (af *af_NA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'af_NA' +func (af *af_NA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'af_NA' +func (af *af_NA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := af.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/af_NA/af_NA_test.go b/vendor/github.com/go-playground/locales/af_NA/af_NA_test.go new file mode 100644 index 0000000000..ce7baee0a2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/af_NA/af_NA_test.go @@ -0,0 +1,1120 @@ +package af_NA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "af_NA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/af_ZA/af_ZA.go b/vendor/github.com/go-playground/locales/af_ZA/af_ZA.go new file mode 100644 index 0000000000..cb07b6adb5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/af_ZA/af_ZA.go @@ -0,0 +1,613 @@ +package af_ZA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type af_ZA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'af_ZA' locale +func New() locales.Translator { + return &af_ZA{ + locale: "af_ZA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "Mrt.", "Apr.", "Mei", "Jun.", "Jul.", "Aug.", "Sep.", "Okt.", "Nov.", "Des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januarie", "Februarie", "Maart", "April", "Mei", "Junie", "Julie", "Augustus", "September", "Oktober", "November", "Desember"}, + daysAbbreviated: []string{"So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "W", "D", "V", "S"}, + daysShort: []string{"So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."}, + daysWide: []string{"Sondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrydag", "Saterdag"}, + periodsAbbreviated: []string{"vm.", "nm."}, + periodsNarrow: []string{"v", "n"}, + periodsWide: []string{"vm.", "nm."}, + erasAbbreviated: []string{"v.C.", "n.C."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"HAT": "Newfoundland-dagligtyd", "∅∅∅": "∅∅∅", "AWST": "Australiese Westelike standaardtyd", "JDT": "Japan-dagligtyd", "MDT": "Berg-dagligtyd", "ECT": "Ecuador-tyd", "CLST": "Chili-somertyd", "EST": "Oostelike standaardtyd", "ACST": "Australiese sentraal-standaardtyd", "HENOMX": "Noordwes-Meksiko-dagligtyd", "SRT": "Suriname-tyd", "WIT": "Oos-Indonesië-tyd", "ACWDT": "Australiese sentraal-Westelike dagligtyd", "MEZ": "Sentraal-Europese standaardtyd", "WEZ": "Wes-Europese standaardtyd", "HKT": "Hongkong-standaardtyd", "COT": "Colombië-standaardtyd", "HNEG": "Oos-Groenland-standaardtyd", "UYT": "Uruguay-standaardtyd", "GYT": "Guyana-tyd", "HAST": "Hawaii-Aleusiër-standaardtyd", "NZST": "Nieu-Seeland-standaardtyd", "NZDT": "Nieu-Seeland-dagligtyd", "WART": "Wes-Argentinië-standaardtyd", "WITA": "Sentraal Indonesië-tyd", "AKST": "Alaska-standaardtyd", "WIB": "Wes-Indonesië-tyd", "SGT": "Singapoer-standaardtyd", "HNOG": "Wes-Groenland-standaardtyd", "EDT": "Oostelike dagligtyd", "HKST": "Hongkong-somertyd", "ADT": "Atlantiese dagligtyd", "BT": "Bhoetan-tyd", "UYST": "Uruguay-somertyd", "CHADT": "Chatham-dagligtyd", "VET": "Venezuela-tyd", "ChST": "Chamorro-standaardtyd", "LHST": "Lord Howe-standaardtyd", "CHAST": "Chatham-standaardtyd", "PDT": "Pasifiese dagligtyd", "WESZ": "Wes-Europese somertyd", "CLT": "Chili-standaardtyd", "WAST": "Wes-Afrika-somertyd", "AKDT": "Alaska-dagligtyd", "GFT": "Frans-Guiana-tyd", "HEPM": "Sint-Pierre en Miquelon-dagligtyd", "HECU": "Kuba-dagligtyd", "AWDT": "Australiese Westelike dagligtyd", "AST": "Atlantiese standaardtyd", "HNPMX": "Meksikaanse Pasifiese standaardtyd", "BOT": "Bolivia-tyd", "HEOG": "Wes-Groenland-somertyd", "GMT": "Greenwich-mediaantyd", "TMST": "Turkmenistan-somertyd", "ART": "Argentinië-standaardtyd", "HNCU": "Kuba-standaardtyd", "CAT": "Sentraal-Afrika-tyd", "ACWST": "Australiese sentraal-Westelike standaard-tyd", "JST": "Japan-standaardtyd", "OESZ": "Oos-Europese somertyd", "AEDT": "Australiese Oostelike dagligtyd", "HNPM": "Sint-Pierre en Miquelon-standaardtyd", "CDT": "Sentrale dagligtyd", "MESZ": "Sentraal-Europese somertyd", "HNNOMX": "Noordwes-Meksiko-standaardtyd", "HNT": "Newfoundland-standaardtyd", "MST": "Berg-standaardtyd", "HADT": "Hawaii-Aleusiër-dagligtyd", "MYT": "Maleisië-tyd", "ARST": "Argentinië-somertyd", "SAST": "Suid-Afrika-standaardtyd", "LHDT": "Lord Howe-dagligtyd", "WAT": "Wes-Afrika-standaardtyd", "ACDT": "Australiese sentrale dagligtyd", "AEST": "Australiese Oostelike standaardtyd", "EAT": "Oos-Afrika-tyd", "CST": "Sentrale standaardtyd", "WARST": "Wes-Argentinië-somertyd", "TMT": "Turkmenistan-standaardtyd", "COST": "Colombië-somertyd", "HEEG": "Oos-Groenland-somertyd", "HEPMX": "Meksikaanse Pasifiese dagligtyd", "PST": "Pasifiese standaardtyd", "IST": "Indië-standaardtyd", "OEZ": "Oos-Europese standaardtyd"}, + } +} + +// Locale returns the current translators string locale +func (af *af_ZA) Locale() string { + return af.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'af_ZA' +func (af *af_ZA) PluralsCardinal() []locales.PluralRule { + return af.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'af_ZA' +func (af *af_ZA) PluralsOrdinal() []locales.PluralRule { + return af.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'af_ZA' +func (af *af_ZA) PluralsRange() []locales.PluralRule { + return af.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'af_ZA' +func (af *af_ZA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'af_ZA' +func (af *af_ZA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'af_ZA' +func (af *af_ZA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (af *af_ZA) MonthAbbreviated(month time.Month) string { + return af.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (af *af_ZA) MonthsAbbreviated() []string { + return af.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (af *af_ZA) MonthNarrow(month time.Month) string { + return af.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (af *af_ZA) MonthsNarrow() []string { + return af.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (af *af_ZA) MonthWide(month time.Month) string { + return af.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (af *af_ZA) MonthsWide() []string { + return af.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (af *af_ZA) WeekdayAbbreviated(weekday time.Weekday) string { + return af.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (af *af_ZA) WeekdaysAbbreviated() []string { + return af.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (af *af_ZA) WeekdayNarrow(weekday time.Weekday) string { + return af.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (af *af_ZA) WeekdaysNarrow() []string { + return af.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (af *af_ZA) WeekdayShort(weekday time.Weekday) string { + return af.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (af *af_ZA) WeekdaysShort() []string { + return af.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (af *af_ZA) WeekdayWide(weekday time.Weekday) string { + return af.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (af *af_ZA) WeekdaysWide() []string { + return af.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'af_ZA' and handles both Whole and Real numbers based on 'v' +func (af *af_ZA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'af_ZA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (af *af_ZA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, af.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'af_ZA' +func (af *af_ZA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := af.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, af.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, af.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'af_ZA' +// in accounting notation. +func (af *af_ZA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := af.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, af.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(af.group) - 1; j >= 0; j-- { + b = append(b, af.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, af.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, af.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, af.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'af_ZA' +func (af *af_ZA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'af_ZA' +func (af *af_ZA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'af_ZA' +func (af *af_ZA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'af_ZA' +func (af *af_ZA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, af.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, af.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'af_ZA' +func (af *af_ZA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'af_ZA' +func (af *af_ZA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'af_ZA' +func (af *af_ZA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'af_ZA' +func (af *af_ZA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, af.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, af.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := af.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/af_ZA/af_ZA_test.go b/vendor/github.com/go-playground/locales/af_ZA/af_ZA_test.go new file mode 100644 index 0000000000..67ed4c668f --- /dev/null +++ b/vendor/github.com/go-playground/locales/af_ZA/af_ZA_test.go @@ -0,0 +1,1120 @@ +package af_ZA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "af_ZA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/agq/agq.go b/vendor/github.com/go-playground/locales/agq/agq.go new file mode 100644 index 0000000000..ce3e3c1591 --- /dev/null +++ b/vendor/github.com/go-playground/locales/agq/agq.go @@ -0,0 +1,563 @@ +package agq + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type agq struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'agq' locale +func New() locales.Translator { + return &agq{ + locale: "agq", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "nùm", "kɨz", "tɨd", "taa", "see", "nzu", "dum", "fɔe", "dzu", "lɔm", "kaa", "fwo"}, + monthsNarrow: []string{"", "n", "k", "t", "t", "s", "z", "k", "f", "d", "l", "c", "f"}, + monthsWide: []string{"", "ndzɔ̀ŋɔ̀nùm", "ndzɔ̀ŋɔ̀kƗ̀zùʔ", "ndzɔ̀ŋɔ̀tƗ̀dʉ̀ghà", "ndzɔ̀ŋɔ̀tǎafʉ̄ghā", "ndzɔ̀ŋèsèe", "ndzɔ̀ŋɔ̀nzùghò", "ndzɔ̀ŋɔ̀dùmlo", "ndzɔ̀ŋɔ̀kwîfɔ̀e", "ndzɔ̀ŋɔ̀tƗ̀fʉ̀ghàdzughù", "ndzɔ̀ŋɔ̀ghǔuwelɔ̀m", "ndzɔ̀ŋɔ̀chwaʔàkaa wo", "ndzɔ̀ŋèfwòo"}, + daysAbbreviated: []string{"nts", "kpa", "ghɔ", "tɔm", "ume", "ghɨ", "dzk"}, + daysNarrow: []string{"n", "k", "g", "t", "u", "g", "d"}, + daysWide: []string{"tsuʔntsɨ", "tsuʔukpà", "tsuʔughɔe", "tsuʔutɔ̀mlò", "tsuʔumè", "tsuʔughɨ̂m", "tsuʔndzɨkɔʔɔ"}, + periodsAbbreviated: []string{"a.g", "a.k"}, + periodsWide: []string{"a.g", "a.k"}, + erasAbbreviated: []string{"SK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Sěe Kɨ̀lesto", "Bǎa Kɨ̀lesto"}, + timezones: map[string]string{"SAST": "SAST", "EAT": "EAT", "AWDT": "AWDT", "AEST": "AEST", "SRT": "SRT", "PDT": "PDT", "ACWDT": "ACWDT", "MESZ": "MESZ", "WEZ": "WEZ", "MST": "MST", "GFT": "GFT", "CLT": "CLT", "HEEG": "HEEG", "HNPM": "HNPM", "HAT": "HAT", "CHAST": "CHAST", "ACWST": "ACWST", "JDT": "JDT", "OESZ": "OESZ", "ACDT": "ACDT", "COST": "COST", "HNT": "HNT", "CHADT": "CHADT", "BOT": "BOT", "MEZ": "MEZ", "MDT": "MDT", "ART": "ART", "EDT": "EDT", "HKT": "HKT", "HNPMX": "HNPMX", "WIB": "WIB", "VET": "VET", "HEPMX": "HEPMX", "∅∅∅": "∅∅∅", "CST": "CST", "JST": "JST", "ADT": "ADT", "MYT": "MYT", "HNEG": "HNEG", "LHDT": "LHDT", "HADT": "HADT", "WESZ": "WESZ", "GMT": "GMT", "TMST": "TMST", "HNNOMX": "HNNOMX", "BT": "BT", "WITA": "WITA", "ChST": "ChST", "AEDT": "AEDT", "HNCU": "HNCU", "CDT": "CDT", "WIT": "WIT", "AWST": "AWST", "NZDT": "NZDT", "OEZ": "OEZ", "WARST": "WARST", "SGT": "SGT", "CAT": "CAT", "IST": "IST", "HNOG": "HNOG", "CLST": "CLST", "HENOMX": "HENOMX", "HEOG": "HEOG", "AST": "AST", "ARST": "ARST", "HKST": "HKST", "NZST": "NZST", "TMT": "TMT", "HEPM": "HEPM", "LHST": "LHST", "ECT": "ECT", "AKST": "AKST", "AKDT": "AKDT", "UYT": "UYT", "HAST": "HAST", "WART": "WART", "WAT": "WAT", "UYST": "UYST", "GYT": "GYT", "HECU": "HECU", "PST": "PST", "WAST": "WAST", "EST": "EST", "ACST": "ACST", "COT": "COT"}, + } +} + +// Locale returns the current translators string locale +func (agq *agq) Locale() string { + return agq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'agq' +func (agq *agq) PluralsCardinal() []locales.PluralRule { + return agq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'agq' +func (agq *agq) PluralsOrdinal() []locales.PluralRule { + return agq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'agq' +func (agq *agq) PluralsRange() []locales.PluralRule { + return agq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'agq' +func (agq *agq) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'agq' +func (agq *agq) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'agq' +func (agq *agq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (agq *agq) MonthAbbreviated(month time.Month) string { + return agq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (agq *agq) MonthsAbbreviated() []string { + return agq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (agq *agq) MonthNarrow(month time.Month) string { + return agq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (agq *agq) MonthsNarrow() []string { + return agq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (agq *agq) MonthWide(month time.Month) string { + return agq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (agq *agq) MonthsWide() []string { + return agq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (agq *agq) WeekdayAbbreviated(weekday time.Weekday) string { + return agq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (agq *agq) WeekdaysAbbreviated() []string { + return agq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (agq *agq) WeekdayNarrow(weekday time.Weekday) string { + return agq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (agq *agq) WeekdaysNarrow() []string { + return agq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (agq *agq) WeekdayShort(weekday time.Weekday) string { + return agq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (agq *agq) WeekdaysShort() []string { + return agq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (agq *agq) WeekdayWide(weekday time.Weekday) string { + return agq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (agq *agq) WeekdaysWide() []string { + return agq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'agq' and handles both Whole and Real numbers based on 'v' +func (agq *agq) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, agq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(agq.group) - 1; j >= 0; j-- { + b = append(b, agq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, agq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'agq' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (agq *agq) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, agq.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, agq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, agq.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'agq' +func (agq *agq) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := agq.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, agq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(agq.group) - 1; j >= 0; j-- { + b = append(b, agq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, agq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, agq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'agq' +// in accounting notation. +func (agq *agq) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := agq.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, agq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(agq.group) - 1; j >= 0; j-- { + b = append(b, agq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, agq.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, agq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'agq' +func (agq *agq) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'agq' +func (agq *agq) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, agq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'agq' +func (agq *agq) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, agq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'agq' +func (agq *agq) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, agq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, agq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'agq' +func (agq *agq) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, agq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'agq' +func (agq *agq) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, agq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, agq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'agq' +func (agq *agq) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, agq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, agq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'agq' +func (agq *agq) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, agq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, agq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := agq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/agq/agq_test.go b/vendor/github.com/go-playground/locales/agq/agq_test.go new file mode 100644 index 0000000000..cb5082d58e --- /dev/null +++ b/vendor/github.com/go-playground/locales/agq/agq_test.go @@ -0,0 +1,1120 @@ +package agq + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "agq" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/agq_CM/agq_CM.go b/vendor/github.com/go-playground/locales/agq_CM/agq_CM.go new file mode 100644 index 0000000000..f79c4e6671 --- /dev/null +++ b/vendor/github.com/go-playground/locales/agq_CM/agq_CM.go @@ -0,0 +1,563 @@ +package agq_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type agq_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'agq_CM' locale +func New() locales.Translator { + return &agq_CM{ + locale: "agq_CM", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "nùm", "kɨz", "tɨd", "taa", "see", "nzu", "dum", "fɔe", "dzu", "lɔm", "kaa", "fwo"}, + monthsNarrow: []string{"", "n", "k", "t", "t", "s", "z", "k", "f", "d", "l", "c", "f"}, + monthsWide: []string{"", "ndzɔ̀ŋɔ̀nùm", "ndzɔ̀ŋɔ̀kƗ̀zùʔ", "ndzɔ̀ŋɔ̀tƗ̀dʉ̀ghà", "ndzɔ̀ŋɔ̀tǎafʉ̄ghā", "ndzɔ̀ŋèsèe", "ndzɔ̀ŋɔ̀nzùghò", "ndzɔ̀ŋɔ̀dùmlo", "ndzɔ̀ŋɔ̀kwîfɔ̀e", "ndzɔ̀ŋɔ̀tƗ̀fʉ̀ghàdzughù", "ndzɔ̀ŋɔ̀ghǔuwelɔ̀m", "ndzɔ̀ŋɔ̀chwaʔàkaa wo", "ndzɔ̀ŋèfwòo"}, + daysAbbreviated: []string{"nts", "kpa", "ghɔ", "tɔm", "ume", "ghɨ", "dzk"}, + daysNarrow: []string{"n", "k", "g", "t", "u", "g", "d"}, + daysWide: []string{"tsuʔntsɨ", "tsuʔukpà", "tsuʔughɔe", "tsuʔutɔ̀mlò", "tsuʔumè", "tsuʔughɨ̂m", "tsuʔndzɨkɔʔɔ"}, + periodsAbbreviated: []string{"a.g", "a.k"}, + periodsWide: []string{"a.g", "a.k"}, + erasAbbreviated: []string{"SK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Sěe Kɨ̀lesto", "Bǎa Kɨ̀lesto"}, + timezones: map[string]string{"TMT": "TMT", "WITA": "WITA", "HEPMX": "HEPMX", "AWDT": "AWDT", "CLST": "CLST", "HEOG": "HEOG", "HKST": "HKST", "HEEG": "HEEG", "GYT": "GYT", "ECT": "ECT", "GMT": "GMT", "WEZ": "WEZ", "WART": "WART", "HNOG": "HNOG", "ADT": "ADT", "ART": "ART", "LHST": "LHST", "LHDT": "LHDT", "AWST": "AWST", "HKT": "HKT", "VET": "VET", "MST": "MST", "BOT": "BOT", "CHADT": "CHADT", "NZST": "NZST", "HECU": "HECU", "EAT": "EAT", "WAT": "WAT", "COT": "COT", "HNNOMX": "HNNOMX", "GFT": "GFT", "HNPMX": "HNPMX", "CST": "CST", "EDT": "EDT", "HADT": "HADT", "ChST": "ChST", "SAST": "SAST", "WIT": "WIT", "WARST": "WARST", "SGT": "SGT", "CHAST": "CHAST", "PST": "PST", "JST": "JST", "OEZ": "OEZ", "HNCU": "HNCU", "WIB": "WIB", "CDT": "CDT", "HAT": "HAT", "HENOMX": "HENOMX", "BT": "BT", "AKST": "AKST", "HNPM": "HNPM", "IST": "IST", "TMST": "TMST", "EST": "EST", "MDT": "MDT", "AEDT": "AEDT", "HEPM": "HEPM", "NZDT": "NZDT", "CAT": "CAT", "AST": "AST", "UYST": "UYST", "PDT": "PDT", "JDT": "JDT", "WAST": "WAST", "ACST": "ACST", "ACDT": "ACDT", "AEST": "AEST", "AKDT": "AKDT", "UYT": "UYT", "HAST": "HAST", "CLT": "CLT", "ARST": "ARST", "COST": "COST", "HNT": "HNT", "HNEG": "HNEG", "SRT": "SRT", "ACWDT": "ACWDT", "OESZ": "OESZ", "MESZ": "MESZ", "WESZ": "WESZ", "MYT": "MYT", "∅∅∅": "∅∅∅", "ACWST": "ACWST", "MEZ": "MEZ"}, + } +} + +// Locale returns the current translators string locale +func (agq *agq_CM) Locale() string { + return agq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'agq_CM' +func (agq *agq_CM) PluralsCardinal() []locales.PluralRule { + return agq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'agq_CM' +func (agq *agq_CM) PluralsOrdinal() []locales.PluralRule { + return agq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'agq_CM' +func (agq *agq_CM) PluralsRange() []locales.PluralRule { + return agq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'agq_CM' +func (agq *agq_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'agq_CM' +func (agq *agq_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'agq_CM' +func (agq *agq_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (agq *agq_CM) MonthAbbreviated(month time.Month) string { + return agq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (agq *agq_CM) MonthsAbbreviated() []string { + return agq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (agq *agq_CM) MonthNarrow(month time.Month) string { + return agq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (agq *agq_CM) MonthsNarrow() []string { + return agq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (agq *agq_CM) MonthWide(month time.Month) string { + return agq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (agq *agq_CM) MonthsWide() []string { + return agq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (agq *agq_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return agq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (agq *agq_CM) WeekdaysAbbreviated() []string { + return agq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (agq *agq_CM) WeekdayNarrow(weekday time.Weekday) string { + return agq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (agq *agq_CM) WeekdaysNarrow() []string { + return agq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (agq *agq_CM) WeekdayShort(weekday time.Weekday) string { + return agq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (agq *agq_CM) WeekdaysShort() []string { + return agq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (agq *agq_CM) WeekdayWide(weekday time.Weekday) string { + return agq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (agq *agq_CM) WeekdaysWide() []string { + return agq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'agq_CM' and handles both Whole and Real numbers based on 'v' +func (agq *agq_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, agq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(agq.group) - 1; j >= 0; j-- { + b = append(b, agq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, agq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'agq_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (agq *agq_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, agq.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, agq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, agq.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'agq_CM' +func (agq *agq_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := agq.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, agq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(agq.group) - 1; j >= 0; j-- { + b = append(b, agq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, agq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, agq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'agq_CM' +// in accounting notation. +func (agq *agq_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := agq.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, agq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(agq.group) - 1; j >= 0; j-- { + b = append(b, agq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, agq.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, agq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'agq_CM' +func (agq *agq_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'agq_CM' +func (agq *agq_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, agq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'agq_CM' +func (agq *agq_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, agq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'agq_CM' +func (agq *agq_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, agq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, agq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'agq_CM' +func (agq *agq_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, agq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'agq_CM' +func (agq *agq_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, agq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, agq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'agq_CM' +func (agq *agq_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, agq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, agq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'agq_CM' +func (agq *agq_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, agq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, agq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := agq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/agq_CM/agq_CM_test.go b/vendor/github.com/go-playground/locales/agq_CM/agq_CM_test.go new file mode 100644 index 0000000000..bf4e46300e --- /dev/null +++ b/vendor/github.com/go-playground/locales/agq_CM/agq_CM_test.go @@ -0,0 +1,1120 @@ +package agq_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "agq_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ak/ak.go b/vendor/github.com/go-playground/locales/ak/ak.go new file mode 100644 index 0000000000..64872c8c5a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ak/ak.go @@ -0,0 +1,563 @@ +package ak + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ak struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ak' locale +func New() locales.Translator { + return &ak{ + locale: "ak", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GH₵", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "S-Ɔ", "K-Ɔ", "E-Ɔ", "E-O", "E-K", "O-A", "A-K", "D-Ɔ", "F-Ɛ", "Ɔ-A", "Ɔ-O", "M-Ɔ"}, + monthsWide: []string{"", "Sanda-Ɔpɛpɔn", "Kwakwar-Ɔgyefuo", "Ebɔw-Ɔbenem", "Ebɔbira-Oforisuo", "Esusow Aketseaba-Kɔtɔnimba", "Obirade-Ayɛwohomumu", "Ayɛwoho-Kitawonsa", "Difuu-Ɔsandaa", "Fankwa-Ɛbɔ", "Ɔbɛsɛ-Ahinime", "Ɔberɛfɛw-Obubuo", "Mumu-Ɔpɛnimba"}, + daysAbbreviated: []string{"Kwe", "Dwo", "Ben", "Wuk", "Yaw", "Fia", "Mem"}, + daysNarrow: []string{"K", "D", "B", "W", "Y", "F", "M"}, + daysWide: []string{"Kwesida", "Dwowda", "Benada", "Wukuda", "Yawda", "Fida", "Memeneda"}, + periodsAbbreviated: []string{"AN", "EW"}, + periodsWide: []string{"AN", "EW"}, + erasAbbreviated: []string{"AK", "KE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Ansa Kristo", "Kristo Ekyiri"}, + timezones: map[string]string{"COST": "COST", "GFT": "GFT", "UYT": "UYT", "WEZ": "WEZ", "ChST": "ChST", "AWST": "AWST", "ECT": "ECT", "NZST": "NZST", "WART": "WART", "WARST": "WARST", "HEOG": "HEOG", "WIB": "WIB", "CDT": "CDT", "CAT": "CAT", "HNOG": "HNOG", "EAT": "EAT", "PDT": "PDT", "WAST": "WAST", "HAT": "HAT", "HNCU": "HNCU", "AWDT": "AWDT", "MESZ": "MESZ", "CLT": "CLT", "HKT": "HKT", "ACST": "ACST", "SAST": "SAST", "AEST": "AEST", "CST": "CST", "PST": "PST", "VET": "VET", "OEZ": "OEZ", "EDT": "EDT", "HNEG": "HNEG", "SGT": "SGT", "EST": "EST", "HNT": "HNT", "SRT": "SRT", "GYT": "GYT", "HAST": "HAST", "ACWDT": "ACWDT", "JST": "JST", "MYT": "MYT", "MST": "MST", "COT": "COT", "WIT": "WIT", "IST": "IST", "GMT": "GMT", "OESZ": "OESZ", "WESZ": "WESZ", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "HNPM": "HNPM", "HADT": "HADT", "NZDT": "NZDT", "HEPM": "HEPM", "CLST": "CLST", "AST": "AST", "ARST": "ARST", "WAT": "WAT", "HEEG": "HEEG", "CHAST": "CHAST", "ACWST": "ACWST", "MDT": "MDT", "HKST": "HKST", "AEDT": "AEDT", "HECU": "HECU", "∅∅∅": "∅∅∅", "BOT": "BOT", "BT": "BT", "WITA": "WITA", "AKST": "AKST", "LHDT": "LHDT", "HNPMX": "HNPMX", "ADT": "ADT", "TMST": "TMST", "ART": "ART", "AKDT": "AKDT", "UYST": "UYST", "LHST": "LHST", "CHADT": "CHADT", "MEZ": "MEZ", "JDT": "JDT", "TMT": "TMT", "HENOMX": "HENOMX", "HEPMX": "HEPMX"}, + } +} + +// Locale returns the current translators string locale +func (ak *ak) Locale() string { + return ak.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ak' +func (ak *ak) PluralsCardinal() []locales.PluralRule { + return ak.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ak' +func (ak *ak) PluralsOrdinal() []locales.PluralRule { + return ak.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ak' +func (ak *ak) PluralsRange() []locales.PluralRule { + return ak.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ak' +func (ak *ak) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ak' +func (ak *ak) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ak' +func (ak *ak) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ak *ak) MonthAbbreviated(month time.Month) string { + return ak.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ak *ak) MonthsAbbreviated() []string { + return ak.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ak *ak) MonthNarrow(month time.Month) string { + return ak.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ak *ak) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ak *ak) MonthWide(month time.Month) string { + return ak.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ak *ak) MonthsWide() []string { + return ak.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ak *ak) WeekdayAbbreviated(weekday time.Weekday) string { + return ak.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ak *ak) WeekdaysAbbreviated() []string { + return ak.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ak *ak) WeekdayNarrow(weekday time.Weekday) string { + return ak.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ak *ak) WeekdaysNarrow() []string { + return ak.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ak *ak) WeekdayShort(weekday time.Weekday) string { + return ak.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ak *ak) WeekdaysShort() []string { + return ak.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ak *ak) WeekdayWide(weekday time.Weekday) string { + return ak.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ak *ak) WeekdaysWide() []string { + return ak.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ak' and handles both Whole and Real numbers based on 'v' +func (ak *ak) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ak' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ak *ak) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ak' +func (ak *ak) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ak.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ak.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ak.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ak.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ak.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ak' +// in accounting notation. +func (ak *ak) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ak.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ak.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ak.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ak.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ak.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ak' +func (ak *ak) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ak' +func (ak *ak) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ak.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ak' +func (ak *ak) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ak.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ak' +func (ak *ak) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ak.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ak.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ak' +func (ak *ak) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ak.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ak.periodsAbbreviated[0]...) + } else { + b = append(b, ak.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ak' +func (ak *ak) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ak.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ak.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ak.periodsAbbreviated[0]...) + } else { + b = append(b, ak.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ak' +func (ak *ak) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ak.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ak.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ak.periodsAbbreviated[0]...) + } else { + b = append(b, ak.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ak' +func (ak *ak) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ak.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ak.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ak.periodsAbbreviated[0]...) + } else { + b = append(b, ak.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ak.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ak/ak_test.go b/vendor/github.com/go-playground/locales/ak/ak_test.go new file mode 100644 index 0000000000..4199279ed1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ak/ak_test.go @@ -0,0 +1,1120 @@ +package ak + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ak" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ak_GH/ak_GH.go b/vendor/github.com/go-playground/locales/ak_GH/ak_GH.go new file mode 100644 index 0000000000..bba9f5cbdc --- /dev/null +++ b/vendor/github.com/go-playground/locales/ak_GH/ak_GH.go @@ -0,0 +1,563 @@ +package ak_GH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ak_GH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ak_GH' locale +func New() locales.Translator { + return &ak_GH{ + locale: "ak_GH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "S-Ɔ", "K-Ɔ", "E-Ɔ", "E-O", "E-K", "O-A", "A-K", "D-Ɔ", "F-Ɛ", "Ɔ-A", "Ɔ-O", "M-Ɔ"}, + monthsWide: []string{"", "Sanda-Ɔpɛpɔn", "Kwakwar-Ɔgyefuo", "Ebɔw-Ɔbenem", "Ebɔbira-Oforisuo", "Esusow Aketseaba-Kɔtɔnimba", "Obirade-Ayɛwohomumu", "Ayɛwoho-Kitawonsa", "Difuu-Ɔsandaa", "Fankwa-Ɛbɔ", "Ɔbɛsɛ-Ahinime", "Ɔberɛfɛw-Obubuo", "Mumu-Ɔpɛnimba"}, + daysAbbreviated: []string{"Kwe", "Dwo", "Ben", "Wuk", "Yaw", "Fia", "Mem"}, + daysNarrow: []string{"K", "D", "B", "W", "Y", "F", "M"}, + daysWide: []string{"Kwesida", "Dwowda", "Benada", "Wukuda", "Yawda", "Fida", "Memeneda"}, + periodsAbbreviated: []string{"AN", "EW"}, + periodsWide: []string{"AN", "EW"}, + erasAbbreviated: []string{"AK", "KE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Ansa Kristo", "Kristo Ekyiri"}, + timezones: map[string]string{"GMT": "GMT", "ADT": "ADT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "SRT": "SRT", "GYT": "GYT", "HNCU": "HNCU", "PST": "PST", "HADT": "HADT", "TMST": "TMST", "BT": "BT", "MST": "MST", "COT": "COT", "AEST": "AEST", "HNPM": "HNPM", "CDT": "CDT", "WIT": "WIT", "HEOG": "HEOG", "GFT": "GFT", "MEZ": "MEZ", "HKT": "HKT", "WITA": "WITA", "SAST": "SAST", "LHST": "LHST", "VET": "VET", "∅∅∅": "∅∅∅", "WART": "WART", "HNPMX": "HNPMX", "OEZ": "OEZ", "WEZ": "WEZ", "WAST": "WAST", "EST": "EST", "AEDT": "AEDT", "CST": "CST", "CHADT": "CHADT", "ACWST": "ACWST", "WAT": "WAT", "ACST": "ACST", "HNEG": "HNEG", "HNOG": "HNOG", "AST": "AST", "OESZ": "OESZ", "EDT": "EDT", "COST": "COST", "JST": "JST", "ECT": "ECT", "WESZ": "WESZ", "TMT": "TMT", "HEPM": "HEPM", "AKDT": "AKDT", "ChST": "ChST", "HEPMX": "HEPMX", "BOT": "BOT", "ACWDT": "ACWDT", "JDT": "JDT", "HNT": "HNT", "ART": "ART", "HKST": "HKST", "HAT": "HAT", "LHDT": "LHDT", "CHAST": "CHAST", "NZDT": "NZDT", "IST": "IST", "MESZ": "MESZ", "WARST": "WARST", "CLT": "CLT", "UYT": "UYT", "ARST": "ARST", "AKST": "AKST", "EAT": "EAT", "AWST": "AWST", "PDT": "PDT", "HAST": "HAST", "MYT": "MYT", "ACDT": "ACDT", "MDT": "MDT", "UYST": "UYST", "HECU": "HECU", "WIB": "WIB", "AWDT": "AWDT", "SGT": "SGT", "NZST": "NZST", "CAT": "CAT", "HEEG": "HEEG", "CLST": "CLST"}, + } +} + +// Locale returns the current translators string locale +func (ak *ak_GH) Locale() string { + return ak.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ak_GH' +func (ak *ak_GH) PluralsCardinal() []locales.PluralRule { + return ak.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ak_GH' +func (ak *ak_GH) PluralsOrdinal() []locales.PluralRule { + return ak.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ak_GH' +func (ak *ak_GH) PluralsRange() []locales.PluralRule { + return ak.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ak_GH' +func (ak *ak_GH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ak_GH' +func (ak *ak_GH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ak_GH' +func (ak *ak_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ak *ak_GH) MonthAbbreviated(month time.Month) string { + return ak.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ak *ak_GH) MonthsAbbreviated() []string { + return ak.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ak *ak_GH) MonthNarrow(month time.Month) string { + return ak.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ak *ak_GH) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ak *ak_GH) MonthWide(month time.Month) string { + return ak.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ak *ak_GH) MonthsWide() []string { + return ak.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ak *ak_GH) WeekdayAbbreviated(weekday time.Weekday) string { + return ak.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ak *ak_GH) WeekdaysAbbreviated() []string { + return ak.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ak *ak_GH) WeekdayNarrow(weekday time.Weekday) string { + return ak.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ak *ak_GH) WeekdaysNarrow() []string { + return ak.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ak *ak_GH) WeekdayShort(weekday time.Weekday) string { + return ak.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ak *ak_GH) WeekdaysShort() []string { + return ak.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ak *ak_GH) WeekdayWide(weekday time.Weekday) string { + return ak.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ak *ak_GH) WeekdaysWide() []string { + return ak.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ak_GH' and handles both Whole and Real numbers based on 'v' +func (ak *ak_GH) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ak_GH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ak *ak_GH) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ak_GH' +func (ak *ak_GH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ak.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ak.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ak.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ak.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ak.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ak_GH' +// in accounting notation. +func (ak *ak_GH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ak.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ak.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ak.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ak.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ak.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ak_GH' +func (ak *ak_GH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ak_GH' +func (ak *ak_GH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ak.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ak_GH' +func (ak *ak_GH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ak.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ak_GH' +func (ak *ak_GH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ak.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ak.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ak_GH' +func (ak *ak_GH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ak.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ak.periodsAbbreviated[0]...) + } else { + b = append(b, ak.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ak_GH' +func (ak *ak_GH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ak.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ak.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ak.periodsAbbreviated[0]...) + } else { + b = append(b, ak.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ak_GH' +func (ak *ak_GH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ak.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ak.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ak.periodsAbbreviated[0]...) + } else { + b = append(b, ak.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ak_GH' +func (ak *ak_GH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ak.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ak.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ak.periodsAbbreviated[0]...) + } else { + b = append(b, ak.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ak.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ak_GH/ak_GH_test.go b/vendor/github.com/go-playground/locales/ak_GH/ak_GH_test.go new file mode 100644 index 0000000000..515acbe847 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ak_GH/ak_GH_test.go @@ -0,0 +1,1120 @@ +package ak_GH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ak_GH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/am/am.go b/vendor/github.com/go-playground/locales/am/am.go new file mode 100644 index 0000000000..7aed451ef7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/am/am.go @@ -0,0 +1,643 @@ +package am + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type am struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'am' locale +func New() locales.Translator { + return &am{ + locale: "am", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ብር", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ጃንዩ", "ፌብሩ", "ማርች", "ኤፕሪ", "ሜይ", "ጁን", "ጁላይ", "ኦገስ", "ሴፕቴ", "ኦክቶ", "ኖቬም", "ዲሴም"}, + monthsNarrow: []string{"", "ጃ", "ፌ", "ማ", "ኤ", "ሜ", "ጁ", "ጁ", "ኦ", "ሴ", "ኦ", "ኖ", "ዲ"}, + monthsWide: []string{"", "ጃንዩወሪ", "ፌብሩወሪ", "ማርች", "ኤፕሪል", "ሜይ", "ጁን", "ጁላይ", "ኦገስት", "ሴፕቴምበር", "ኦክቶበር", "ኖቬምበር", "ዲሴምበር"}, + daysAbbreviated: []string{"እሑድ", "ሰኞ", "ማክሰ", "ረቡዕ", "ሐሙስ", "ዓርብ", "ቅዳሜ"}, + daysNarrow: []string{"እ", "ሰ", "ማ", "ረ", "ሐ", "ዓ", "ቅ"}, + daysShort: []string{"እ", "ሰ", "ማ", "ረ", "ሐ", "ዓ", "ቅ"}, + daysWide: []string{"እሑድ", "ሰኞ", "ማክሰኞ", "ረቡዕ", "ሐሙስ", "ዓርብ", "ቅዳሜ"}, + periodsAbbreviated: []string{"ጥዋት", "ከሰዓት"}, + periodsNarrow: []string{"ጠ", "ከ"}, + periodsWide: []string{"ጥዋት", "ከሰዓት"}, + erasAbbreviated: []string{"ዓ/ዓ", "ዓ/ም"}, + erasNarrow: []string{"ዓ/ዓ", "ዓ/ም"}, + erasWide: []string{"ዓመተ ዓለም", "ዓመተ ምሕረት"}, + timezones: map[string]string{"CHAST": "የቻታም መደበኛ ሰዓት", "CHADT": "የቻታም የቀን ብርሃን ሰዓት", "MESZ": "የመካከለኛው አውሮፓ ክረምት ሰዓት", "VET": "የቬኔዝዌላ ሰዓት", "COT": "የኮሎምቢያ መደበኛ ሰዓት", "CLST": "የቺሊ ክረምት ሰዓት", "HKT": "የሆንግ ኮንግ መደበኛ ሰዓት", "HAT": "የኒውፋውንድላንድ የቀን የሰዓት አቆጣጠር", "AEST": "የአውስትራሊያ ምዕራባዊ መደበኛ የሰዓት አቆጣጠር", "SAST": "የደቡብ አፍሪካ መደበኛ ሰዓት", "HNPMX": "የሜክሲኮ ፓሲፊክ መደበኛ ሰዓት አቆጣጠር", "BOT": "የቦሊቪያ ሰዓት", "CLT": "የቺሊ መደበኛ ሰዓት", "CAT": "የመካከለኛው አፍሪካ ሰዓት", "WEZ": "የምዕራባዊ አውሮፓ መደበኛ ሰዓት", "ACDT": "የአውስትራሊያ መካከለኛ የቀን ሰዓት አቆጣጠር", "WIB": "የምዕራባዊ ኢንዶኔዢያ ሰዓት", "HEOG": "የምዕራብ ግሪንላንድ ክረምት ሰዓት", "WESZ": "የምዕራባዊ አውሮፓ ክረምት ሰዓት", "WARST": "የአርጀንቲና ምስራቃዊ በጋ ሰዓት አቆጣጠር", "WAST": "የምዕራብ አፍሪካ ክረምት ሰዓት", "HEEG": "የምስራቅ ግሪንላንድ ክረምት ሰዓት", "AKDT": "የአላስካ የቀን ሰዓት አቆጣጠር", "PST": "የፓስፊክ መደበኛ ሰዓት አቆጣጠር", "JDT": "የጃፓን የቀን ብርሃን ሰዓት", "AST": "የአትላንቲክ መደበኛ የሰዓት አቆጣጠር", "WITA": "የመካከለኛው ኢንዶኔዢያ ሰዓት", "ChST": "የቻሞሮ መደበኛ ሰዓት", "UYT": "የኡራጓይ መደበኛ ሰዓት", "HNCU": "የኩባ መደበኛ ሰዓት", "NZDT": "የኒው ዚላንድ የቀን ብርሃን ሰዓት", "HNEG": "የምስራቅ ግሪንላንድ መደበኛ ሰዓት", "EDT": "የምዕራባዊ የቀን ሰዓት አቆጣጠር", "ACST": "የአውስትራሊያ መካከለኛ መደበኛ የሰዓት አቆጣጠር", "HNNOMX": "ሰሜናዊ ምእራብ የሜክሲኮ መደበኛ ሰዓት አቆጣጠር", "GFT": "የፈረንሳይ ጉያና ሰዓት", "HECU": "የኩባ የቀን ብርሃን ሰዓት", "PDT": "የፓስፊክ የቀን ሰዓት አቆጣጠር", "HNOG": "የምዕራብ ግሪንላንድ መደበኛ ሰዓት", "CST": "የመካከለኛ መደበኛ ሰዓት አቆጣጠር", "WIT": "የምስራቃዊ ኢንዶኔዢያ ሰዓት", "WAT": "የምዕራብ አፍሪካ መደበኛ ሰዓት", "AWDT": "የአውስትራሊያ ምስራቃዊ የቀን ሰዓት አቆጣጠር", "SGT": "የሲንጋፒር መደበኛ ሰዓት", "ECT": "የኢኳዶር ሰዓት", "ACWDT": "የአውስትራሊያ መካከለኛው ምስራቅ የቀን ሰዓት አቆጣጠር", "MEZ": "የመካከለኛው አውሮፓ መደበኛ ሰዓት", "∅∅∅": "∅∅∅", "AEDT": "የአውስትራሊያ ምዕራባዊ የቀን ሰዓት አቆጣጠር", "LHST": "የሎርድ ሆዌ መደበኛ የሰዓት አቆጣጠር", "HEPMX": "የሜክሲኮ ፓሲፊክ የቀን ሰዓት አቆጣጠር", "HAST": "የሃዋይ አሌኡት መደበኛ ሰዓት አቆጣጠር", "ACWST": "የአውስትራሊያ መካከለኛ ምስራቃዊ መደበኛ ሰዓት አቆጣጠር", "HENOMX": "ሰሜናዊ ምእራብ የሜክሲኮ የቀን ሰዓት አቆጣጠር", "EAT": "የምስራቅ አፍሪካ ሰዓት", "NZST": "የኒው ዚላንድ መደበኛ ሰዓት", "GYT": "የጉያና ሰዓት", "HADT": "የሃዋይ አሌኡት የቀን ሰዓት አቆጣጠር", "LHDT": "የሎርድ ሆዌ የቀን ሰዓት አቆጣጠር", "COST": "የኮሎምቢያ ክረምት ሰዓት", "HNPM": "ቅዱስ የፒዬር እና ሚኴሎን መደበኛ ሰዓት", "HEPM": "ቅዱስ የፒዬር እና ሚኴሎን የቀን ብርሃን ሰዓት", "OESZ": "የምስራቃዊ አውሮፓ ክረምት ሰዓት", "MYT": "የማሌይዢያ ሰዓት", "EST": "የምዕራባዊ መደበኛ የሰዓት አቆጣጠር", "BT": "የቡታን ሰዓት", "HNT": "የኒውፋውንድላንድ መደበኛ የሰዓት አቆጣጠር", "UYST": "የኡራጓይ ክረምት ሰዓት", "ADT": "የአትላንቲክ የቀን ሰዓት አቆጣጠር", "WART": "የምዕራባዊ አርጀንቲና መደበኛ ሰዓት አቆጣጠር", "TMST": "የቱርክመኒስታን ክረምት ሰዓት", "HKST": "የሆንግ ኮንግ ክረምት ሰዓት", "CDT": "የመካከለኛ የቀን ሰዓት አቆጣጠር", "JST": "የጃፓን መደበኛ ሰዓት", "OEZ": "የምስራቃዊ አውሮፓ መደበኛ ሰዓት", "MST": "MST", "ART": "የአርጀንቲና መደበኛ ሰዓት አቆጣጠር", "AKST": "የአላስካ መደበኛ የሰዓት አቆጣጠር", "AWST": "የአውስትራሊያ ምስራቃዊ መደበኛ ሰዓት አቆጣጠር", "IST": "የህንድ መደበኛ ሰዓት", "TMT": "የቱርክመኒስታን መደበኛ ሰዓት", "MDT": "MDT", "ARST": "የአርጀንቲና የበጋ ሰዓት አቆጣጠር", "SRT": "የሱሪናም ሰዓት", "GMT": "ግሪንዊች ማዕከላዊ ሰዓት"}, + } +} + +// Locale returns the current translators string locale +func (am *am) Locale() string { + return am.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'am' +func (am *am) PluralsCardinal() []locales.PluralRule { + return am.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'am' +func (am *am) PluralsOrdinal() []locales.PluralRule { + return am.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'am' +func (am *am) PluralsRange() []locales.PluralRule { + return am.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'am' +func (am *am) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'am' +func (am *am) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'am' +func (am *am) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := am.CardinalPluralRule(num1, v1) + end := am.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (am *am) MonthAbbreviated(month time.Month) string { + return am.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (am *am) MonthsAbbreviated() []string { + return am.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (am *am) MonthNarrow(month time.Month) string { + return am.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (am *am) MonthsNarrow() []string { + return am.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (am *am) MonthWide(month time.Month) string { + return am.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (am *am) MonthsWide() []string { + return am.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (am *am) WeekdayAbbreviated(weekday time.Weekday) string { + return am.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (am *am) WeekdaysAbbreviated() []string { + return am.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (am *am) WeekdayNarrow(weekday time.Weekday) string { + return am.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (am *am) WeekdaysNarrow() []string { + return am.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (am *am) WeekdayShort(weekday time.Weekday) string { + return am.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (am *am) WeekdaysShort() []string { + return am.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (am *am) WeekdayWide(weekday time.Weekday) string { + return am.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (am *am) WeekdaysWide() []string { + return am.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'am' and handles both Whole and Real numbers based on 'v' +func (am *am) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, am.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, am.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, am.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'am' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (am *am) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, am.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, am.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, am.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'am' +func (am *am) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := am.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, am.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, am.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, am.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, am.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'am' +// in accounting notation. +func (am *am) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := am.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, am.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, am.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, am.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, am.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, am.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'am' +func (am *am) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'am' +func (am *am) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, am.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'am' +func (am *am) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, am.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'am' +func (am *am) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, am.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0xe1, 0x8d, 0xa3}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, am.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'am' +func (am *am) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, am.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, am.periodsAbbreviated[0]...) + } else { + b = append(b, am.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'am' +func (am *am) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, am.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, am.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, am.periodsAbbreviated[0]...) + } else { + b = append(b, am.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'am' +func (am *am) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, am.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, am.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, am.periodsAbbreviated[0]...) + } else { + b = append(b, am.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'am' +func (am *am) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, am.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, am.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, am.periodsAbbreviated[0]...) + } else { + b = append(b, am.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := am.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/am/am_test.go b/vendor/github.com/go-playground/locales/am/am_test.go new file mode 100644 index 0000000000..a8c42769b4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/am/am_test.go @@ -0,0 +1,1120 @@ +package am + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "am" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/am_ET/am_ET.go b/vendor/github.com/go-playground/locales/am_ET/am_ET.go new file mode 100644 index 0000000000..e857ce7e19 --- /dev/null +++ b/vendor/github.com/go-playground/locales/am_ET/am_ET.go @@ -0,0 +1,643 @@ +package am_ET + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type am_ET struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'am_ET' locale +func New() locales.Translator { + return &am_ET{ + locale: "am_ET", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ጃንዩ", "ፌብሩ", "ማርች", "ኤፕሪ", "ሜይ", "ጁን", "ጁላይ", "ኦገስ", "ሴፕቴ", "ኦክቶ", "ኖቬም", "ዲሴም"}, + monthsNarrow: []string{"", "ጃ", "ፌ", "ማ", "ኤ", "ሜ", "ጁ", "ጁ", "ኦ", "ሴ", "ኦ", "ኖ", "ዲ"}, + monthsWide: []string{"", "ጃንዩወሪ", "ፌብሩወሪ", "ማርች", "ኤፕሪል", "ሜይ", "ጁን", "ጁላይ", "ኦገስት", "ሴፕቴምበር", "ኦክቶበር", "ኖቬምበር", "ዲሴምበር"}, + daysAbbreviated: []string{"እሑድ", "ሰኞ", "ማክሰ", "ረቡዕ", "ሐሙስ", "ዓርብ", "ቅዳሜ"}, + daysNarrow: []string{"እ", "ሰ", "ማ", "ረ", "ሐ", "ዓ", "ቅ"}, + daysShort: []string{"እ", "ሰ", "ማ", "ረ", "ሐ", "ዓ", "ቅ"}, + daysWide: []string{"እሑድ", "ሰኞ", "ማክሰኞ", "ረቡዕ", "ሐሙስ", "ዓርብ", "ቅዳሜ"}, + periodsAbbreviated: []string{"ጥዋት", "ከሰዓት"}, + periodsNarrow: []string{"ጠ", "ከ"}, + periodsWide: []string{"ጥዋት", "ከሰዓት"}, + erasAbbreviated: []string{"ዓ/ዓ", "ዓ/ም"}, + erasNarrow: []string{"ዓ/ዓ", "ዓ/ም"}, + erasWide: []string{"ዓመተ ዓለም", "ዓመተ ምሕረት"}, + timezones: map[string]string{"AWDT": "የአውስትራሊያ ምስራቃዊ የቀን ሰዓት አቆጣጠር", "SGT": "የሲንጋፒር መደበኛ ሰዓት", "CHADT": "የቻታም የቀን ብርሃን ሰዓት", "ACWDT": "የአውስትራሊያ መካከለኛው ምስራቅ የቀን ሰዓት አቆጣጠር", "UYT": "የኡራጓይ መደበኛ ሰዓት", "HEPMX": "የሜክሲኮ ፓሲፊክ የቀን ሰዓት አቆጣጠር", "BOT": "የቦሊቪያ ሰዓት", "VET": "የቬኔዝዌላ ሰዓት", "OESZ": "የምስራቃዊ አውሮፓ ክረምት ሰዓት", "UYST": "የኡራጓይ ክረምት ሰዓት", "HADT": "የሃዋይ አሌኡት የቀን ሰዓት አቆጣጠር", "WITA": "የመካከለኛው ኢንዶኔዢያ ሰዓት", "LHDT": "የሎርድ ሆዌ የቀን ሰዓት አቆጣጠር", "CLST": "የቺሊ ክረምት ሰዓት", "HEEG": "የምስራቅ ግሪንላንድ ክረምት ሰዓት", "AKDT": "የአላስካ የቀን ሰዓት አቆጣጠር", "HECU": "የኩባ የቀን ብርሃን ሰዓት", "MYT": "የማሌይዢያ ሰዓት", "TMT": "የቱርክመኒስታን መደበኛ ሰዓት", "HNPM": "ቅዱስ የፒዬር እና ሚኴሎን መደበኛ ሰዓት", "PDT": "የፓስፊክ የቀን ሰዓት አቆጣጠር", "NZDT": "የኒው ዚላንድ የቀን ብርሃን ሰዓት", "MEZ": "የመካከለኛው አውሮፓ መደበኛ ሰዓት", "MESZ": "የመካከለኛው አውሮፓ ክረምት ሰዓት", "HNT": "የኒውፋውንድላንድ መደበኛ የሰዓት አቆጣጠር", "ChST": "የቻሞሮ መደበኛ ሰዓት", "GYT": "የጉያና ሰዓት", "HNOG": "የምዕራብ ግሪንላንድ መደበኛ ሰዓት", "AST": "የአትላንቲክ መደበኛ የሰዓት አቆጣጠር", "HENOMX": "ሰሜናዊ ምእራብ የሜክሲኮ የቀን ሰዓት አቆጣጠር", "ACDT": "የአውስትራሊያ መካከለኛ የቀን ሰዓት አቆጣጠር", "WAT": "የምዕራብ አፍሪካ መደበኛ ሰዓት", "HNNOMX": "ሰሜናዊ ምእራብ የሜክሲኮ መደበኛ ሰዓት አቆጣጠር", "HAST": "የሃዋይ አሌኡት መደበኛ ሰዓት አቆጣጠር", "CAT": "የመካከለኛው አፍሪካ ሰዓት", "ARST": "የአርጀንቲና የበጋ ሰዓት አቆጣጠር", "EST": "የምዕራባዊ መደበኛ የሰዓት አቆጣጠር", "ART": "የአርጀንቲና መደበኛ ሰዓት አቆጣጠር", "MST": "MST", "HAT": "የኒውፋውንድላንድ የቀን የሰዓት አቆጣጠር", "IST": "የህንድ መደበኛ ሰዓት", "∅∅∅": "የአማዞን የቀን ሰዓት አቆጣጠር", "JST": "የጃፓን መደበኛ ሰዓት", "TMST": "የቱርክመኒስታን ክረምት ሰዓት", "NZST": "የኒው ዚላንድ መደበኛ ሰዓት", "BT": "የቡታን ሰዓት", "SAST": "የደቡብ አፍሪካ መደበኛ ሰዓት", "WIT": "የምስራቃዊ ኢንዶኔዢያ ሰዓት", "WART": "የምዕራባዊ አርጀንቲና መደበኛ ሰዓት አቆጣጠር", "HKST": "የሆንግ ኮንግ ክረምት ሰዓት", "COST": "የኮሎምቢያ ክረምት ሰዓት", "WIB": "የምዕራባዊ ኢንዶኔዢያ ሰዓት", "EAT": "የምስራቅ አፍሪካ ሰዓት", "CDT": "የመካከለኛ የቀን ሰዓት አቆጣጠር", "AWST": "የአውስትራሊያ ምስራቃዊ መደበኛ ሰዓት አቆጣጠር", "WAST": "የምዕራብ አፍሪካ ክረምት ሰዓት", "AEST": "የአውስትራሊያ ምዕራባዊ መደበኛ የሰዓት አቆጣጠር", "LHST": "የሎርድ ሆዌ መደበኛ የሰዓት አቆጣጠር", "HNCU": "የኩባ መደበኛ ሰዓት", "ADT": "የአትላንቲክ የቀን ሰዓት አቆጣጠር", "MDT": "MDT", "GFT": "የፈረንሳይ ጉያና ሰዓት", "AKST": "የአላስካ መደበኛ የሰዓት አቆጣጠር", "ACWST": "የአውስትራሊያ መካከለኛ ምስራቃዊ መደበኛ ሰዓት አቆጣጠር", "JDT": "የጃፓን የቀን ብርሃን ሰዓት", "OEZ": "የምስራቃዊ አውሮፓ መደበኛ ሰዓት", "WARST": "የአርጀንቲና ምስራቃዊ በጋ ሰዓት አቆጣጠር", "HEPM": "ቅዱስ የፒዬር እና ሚኴሎን የቀን ብርሃን ሰዓት", "CST": "የመካከለኛ መደበኛ ሰዓት አቆጣጠር", "PST": "የፓስፊክ መደበኛ ሰዓት አቆጣጠር", "ECT": "የኢኳዶር ሰዓት", "WESZ": "የምዕራባዊ አውሮፓ ክረምት ሰዓት", "CLT": "የቺሊ መደበኛ ሰዓት", "HNEG": "የምስራቅ ግሪንላንድ መደበኛ ሰዓት", "AEDT": "የአውስትራሊያ ምዕራባዊ የቀን ሰዓት አቆጣጠር", "SRT": "የሱሪናም ሰዓት", "WEZ": "የምዕራባዊ አውሮፓ መደበኛ ሰዓት", "HEOG": "የምዕራብ ግሪንላንድ ክረምት ሰዓት", "EDT": "የምዕራባዊ የቀን ሰዓት አቆጣጠር", "COT": "የኮሎምቢያ መደበኛ ሰዓት", "HNPMX": "የሜክሲኮ ፓሲፊክ መደበኛ ሰዓት አቆጣጠር", "CHAST": "የቻታም መደበኛ ሰዓት", "GMT": "ግሪንዊች ማዕከላዊ ሰዓት", "HKT": "የሆንግ ኮንግ መደበኛ ሰዓት", "ACST": "የአውስትራሊያ መካከለኛ መደበኛ የሰዓት አቆጣጠር"}, + } +} + +// Locale returns the current translators string locale +func (am *am_ET) Locale() string { + return am.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'am_ET' +func (am *am_ET) PluralsCardinal() []locales.PluralRule { + return am.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'am_ET' +func (am *am_ET) PluralsOrdinal() []locales.PluralRule { + return am.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'am_ET' +func (am *am_ET) PluralsRange() []locales.PluralRule { + return am.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'am_ET' +func (am *am_ET) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'am_ET' +func (am *am_ET) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'am_ET' +func (am *am_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := am.CardinalPluralRule(num1, v1) + end := am.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (am *am_ET) MonthAbbreviated(month time.Month) string { + return am.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (am *am_ET) MonthsAbbreviated() []string { + return am.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (am *am_ET) MonthNarrow(month time.Month) string { + return am.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (am *am_ET) MonthsNarrow() []string { + return am.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (am *am_ET) MonthWide(month time.Month) string { + return am.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (am *am_ET) MonthsWide() []string { + return am.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (am *am_ET) WeekdayAbbreviated(weekday time.Weekday) string { + return am.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (am *am_ET) WeekdaysAbbreviated() []string { + return am.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (am *am_ET) WeekdayNarrow(weekday time.Weekday) string { + return am.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (am *am_ET) WeekdaysNarrow() []string { + return am.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (am *am_ET) WeekdayShort(weekday time.Weekday) string { + return am.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (am *am_ET) WeekdaysShort() []string { + return am.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (am *am_ET) WeekdayWide(weekday time.Weekday) string { + return am.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (am *am_ET) WeekdaysWide() []string { + return am.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'am_ET' and handles both Whole and Real numbers based on 'v' +func (am *am_ET) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, am.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, am.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, am.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'am_ET' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (am *am_ET) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, am.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, am.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, am.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'am_ET' +func (am *am_ET) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := am.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, am.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, am.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, am.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, am.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'am_ET' +// in accounting notation. +func (am *am_ET) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := am.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, am.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, am.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, am.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, am.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, am.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'am_ET' +func (am *am_ET) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'am_ET' +func (am *am_ET) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, am.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'am_ET' +func (am *am_ET) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, am.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'am_ET' +func (am *am_ET) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, am.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0xe1, 0x8d, 0xa3}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, am.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'am_ET' +func (am *am_ET) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, am.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, am.periodsAbbreviated[0]...) + } else { + b = append(b, am.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'am_ET' +func (am *am_ET) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, am.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, am.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, am.periodsAbbreviated[0]...) + } else { + b = append(b, am.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'am_ET' +func (am *am_ET) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, am.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, am.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, am.periodsAbbreviated[0]...) + } else { + b = append(b, am.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'am_ET' +func (am *am_ET) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, am.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, am.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, am.periodsAbbreviated[0]...) + } else { + b = append(b, am.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := am.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/am_ET/am_ET_test.go b/vendor/github.com/go-playground/locales/am_ET/am_ET_test.go new file mode 100644 index 0000000000..1f5f41180f --- /dev/null +++ b/vendor/github.com/go-playground/locales/am_ET/am_ET_test.go @@ -0,0 +1,1120 @@ +package am_ET + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "am_ET" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar/ar.go b/vendor/github.com/go-playground/locales/ar/ar.go new file mode 100644 index 0000000000..c0e33abe34 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar/ar.go @@ -0,0 +1,712 @@ +package ar + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar' locale +func New() locales.Translator { + return &ar{ + locale: "ar", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "د.إ.\u200f", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "د.ب.\u200f", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "د.ج.\u200f", "ECS", "ECV", "EEK", "ج.م.\u200f", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "د.ع.\u200f", "ر.إ.", "ISJ", "ISK", "ITL", "JMD", "د.أ.\u200f", "JP¥", "KES", "KGS", "KHR", "ف.ج.ق.\u200f", "KPW", "KRH", "KRO", "₩", "د.ك.\u200f", "KYD", "KZT", "LAK", "ل.ل.\u200f", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "د.ل.\u200f", "د.م.\u200f", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "أ.م.\u200f", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "ر.ع.\u200f", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "ر.ق.\u200f", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "ر.س.\u200f", "SBD", "SCR", "د.س.\u200f", "ج.س.", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "ل.س.\u200f", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "د.ت.\u200f", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "***", "YDD", "ر.ي.\u200f", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNPM": "توقيت سانت بيير وميكولون الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CAT": "توقيت وسط أفريقيا", "VET": "توقيت فنزويلا", "TMT": "توقيت تركمانستان الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "CLST": "توقيت شيلي الصيفي", "MST": "MST", "BT": "توقيت بوتان", "GFT": "توقيت غايانا الفرنسية", "WITA": "توقيت وسط إندونيسيا", "AKST": "التوقيت الرسمي لألاسكا", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "HAST": "توقيت هاواي ألوتيان الرسمي", "JDT": "توقيت اليابان الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "EAT": "توقيت شرق أفريقيا", "SRT": "توقيت سورينام", "PDT": "توقيت المحيط الهادي الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HEEG": "توقيت شرق غرينلاند الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "CLT": "توقيت شيلي الرسمي", "OESZ": "توقيت شرق أوروبا الصيفي", "HNEG": "توقيت شرق غرينلاند الرسمي", "BOT": "توقيت بوليفيا", "ECT": "توقيت الإكوادور", "MESZ": "توقيت وسط أوروبا الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "IST": "توقيت الهند", "MDT": "MDT", "LHST": "توقيت لورد هاو الرسمي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "WIT": "توقيت شرق إندونيسيا", "GMT": "توقيت غرينتش", "AEST": "توقيت شرق أستراليا الرسمي", "UYT": "توقيت أورغواي الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "GYT": "توقيت غيانا", "AWDT": "توقيت غرب أستراليا الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "∅∅∅": "توقيت الأمازون الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "UYST": "توقيت أورغواي الصيفي", "HECU": "توقيت كوبا الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "WAT": "توقيت غرب أفريقيا الرسمي", "SAST": "توقيت جنوب أفريقيا", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "CHADT": "توقيت تشاتام الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "ART": "توقيت الأرجنتين الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "COST": "توقيت كولومبيا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "ACST": "توقيت وسط أستراليا الرسمي", "COT": "توقيت كولومبيا الرسمي", "HNCU": "توقيت كوبا الرسمي", "AWST": "توقيت غرب أستراليا الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "JST": "توقيت اليابان الرسمي", "MYT": "توقيت ماليزيا", "AKDT": "توقيت ألاسكا الصيفي", "WIB": "توقيت غرب إندونيسيا", "TMST": "توقيت تركمانستان الصيفي", "ACDT": "توقيت وسط أستراليا الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "ChST": "توقيت تشامورو", "CHAST": "توقيت تشاتام الرسمي", "SGT": "توقيت سنغافورة", "MEZ": "توقيت وسط أوروبا الرسمي", "WARST": "توقيت غرب الأرجنتين الصيفي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar' +func (ar *ar) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar' +func (ar *ar) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar' +func (ar *ar) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar' +func (ar *ar) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar' +func (ar *ar) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar' +func (ar *ar) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar' and handles both Whole and Real numbers based on 'v' +func (ar *ar) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar' +func (ar *ar) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar' +// in accounting notation. +func (ar *ar) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar' +func (ar *ar) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar' +func (ar *ar) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar' +func (ar *ar) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar' +func (ar *ar) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar' +func (ar *ar) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar' +func (ar *ar) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar' +func (ar *ar) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar' +func (ar *ar) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar/ar_test.go b/vendor/github.com/go-playground/locales/ar/ar_test.go new file mode 100644 index 0000000000..b9d28aca8f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar/ar_test.go @@ -0,0 +1,1120 @@ +package ar + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_001/ar_001.go b/vendor/github.com/go-playground/locales/ar_001/ar_001.go new file mode 100644 index 0000000000..6dbb369350 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_001/ar_001.go @@ -0,0 +1,712 @@ +package ar_001 + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_001 struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_001' locale +func New() locales.Translator { + return &ar_001{ + locale: "ar_001", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNCU": "توقيت كوبا الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي", "IST": "توقيت الهند", "SAST": "توقيت جنوب أفريقيا", "EAT": "توقيت شرق أفريقيا", "WIT": "توقيت شرق إندونيسيا", "WART": "توقيت غرب الأرجنتين الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "WITA": "توقيت وسط إندونيسيا", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "GYT": "توقيت غيانا", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CAT": "توقيت وسط أفريقيا", "JST": "توقيت اليابان الرسمي", "TMST": "توقيت تركمانستان الصيفي", "ART": "توقيت الأرجنتين الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "VET": "توقيت فنزويلا", "HNEG": "توقيت شرق غرينلاند الرسمي", "SRT": "توقيت سورينام", "TMT": "توقيت تركمانستان الرسمي", "AEST": "توقيت شرق أستراليا الرسمي", "HECU": "توقيت كوبا الصيفي", "PDT": "توقيت المحيط الهادي الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "CHAST": "توقيت تشاتام الرسمي", "CHADT": "توقيت تشاتام الصيفي", "SGT": "توقيت سنغافورة", "HADT": "توقيت هاواي ألوتيان الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNT": "توقيت نيوفاوندلاند الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "JDT": "توقيت اليابان الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "COT": "توقيت كولومبيا الرسمي", "COST": "توقيت كولومبيا الصيفي", "ADT": "التوقيت الصيفي الأطلسي", "GFT": "توقيت غايانا الفرنسية", "AKST": "التوقيت الرسمي لألاسكا", "ECT": "توقيت الإكوادور", "WARST": "توقيت غرب الأرجنتين الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "WEZ": "توقيت غرب أوروبا الرسمي", "GMT": "توقيت غرينتش", "BT": "توقيت بوتان", "AKDT": "توقيت ألاسكا الصيفي", "UYST": "توقيت أورغواي الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "HEEG": "توقيت شرق غرينلاند الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "BOT": "توقيت بوليفيا", "NZST": "توقيت نيوزيلندا الرسمي", "CLT": "توقيت شيلي الرسمي", "CLST": "توقيت شيلي الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "ACDT": "توقيت وسط أستراليا الصيفي", "LHST": "توقيت لورد هاو الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "WIB": "توقيت غرب إندونيسيا", "AWST": "توقيت غرب أستراليا الرسمي", "AWDT": "توقيت غرب أستراليا الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "MDT": "MDT", "HAT": "توقيت نيوفاوندلاند الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "MYT": "توقيت ماليزيا", "AST": "التوقيت الرسمي الأطلسي", "MST": "MST", "ChST": "توقيت تشامورو", "UYT": "توقيت أورغواي الرسمي", "∅∅∅": "توقيت برازيليا الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "PST": "توقيت المحيط الهادي الرسمي", "OESZ": "توقيت شرق أوروبا الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_001) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_001' +func (ar *ar_001) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_001' +func (ar *ar_001) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_001' +func (ar *ar_001) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_001' +func (ar *ar_001) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_001' +func (ar *ar_001) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_001' +func (ar *ar_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_001) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_001) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_001) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_001) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_001) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_001) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_001) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_001) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_001) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_001) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_001) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_001) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_001) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_001) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_001' and handles both Whole and Real numbers based on 'v' +func (ar *ar_001) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_001' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_001) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_001' +func (ar *ar_001) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_001' +// in accounting notation. +func (ar *ar_001) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_001' +func (ar *ar_001) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_001' +func (ar *ar_001) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_001' +func (ar *ar_001) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_001' +func (ar *ar_001) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_001' +func (ar *ar_001) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_001' +func (ar *ar_001) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_001' +func (ar *ar_001) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_001' +func (ar *ar_001) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_001/ar_001_test.go b/vendor/github.com/go-playground/locales/ar_001/ar_001_test.go new file mode 100644 index 0000000000..cdd4cb343f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_001/ar_001_test.go @@ -0,0 +1,1120 @@ +package ar_001 + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_001" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_AE/ar_AE.go b/vendor/github.com/go-playground/locales/ar_AE/ar_AE.go new file mode 100644 index 0000000000..7f044f57fe --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_AE/ar_AE.go @@ -0,0 +1,712 @@ +package ar_AE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_AE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_AE' locale +func New() locales.Translator { + return &ar_AE{ + locale: "ar_AE", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "$", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNCU": "توقيت كوبا الرسمي", "HECU": "توقيت كوبا الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "HADT": "توقيت هاواي ألوتيان الصيفي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "MYT": "توقيت ماليزيا", "HAT": "توقيت نيوفاوندلاند الصيفي", "AKST": "التوقيت الرسمي لألاسكا", "SRT": "توقيت سورينام", "GYT": "توقيت غيانا", "AWDT": "توقيت غرب أستراليا الصيفي", "PDT": "توقيت المحيط الهادي الصيفي", "TMT": "توقيت تركمانستان الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "WITA": "توقيت وسط إندونيسيا", "LHDT": "التوقيت الصيفي للورد هاو", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "CAT": "توقيت وسط أفريقيا", "HEOG": "توقيت غرب غرينلاند الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "IST": "توقيت الهند", "CLT": "توقيت شيلي الرسمي", "ART": "توقيت الأرجنتين الرسمي", "UYT": "توقيت أورغواي الرسمي", "SAST": "توقيت جنوب أفريقيا", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "CHAST": "توقيت تشاتام الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "AST": "التوقيت الرسمي الأطلسي", "ADT": "التوقيت الصيفي الأطلسي", "EAT": "توقيت شرق أفريقيا", "ECT": "توقيت الإكوادور", "MESZ": "توقيت وسط أوروبا الصيفي", "VET": "توقيت فنزويلا", "GMT": "توقيت غرينتش", "WARST": "توقيت غرب الأرجنتين الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HKT": "توقيت هونغ كونغ الرسمي", "BT": "توقيت بوتان", "AEST": "توقيت شرق أستراليا الرسمي", "TMST": "توقيت تركمانستان الصيفي", "AWST": "توقيت غرب أستراليا الرسمي", "MDT": "MDT", "WAT": "توقيت غرب أفريقيا الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNEG": "توقيت شرق غرينلاند الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "ChST": "توقيت تشامورو", "LHST": "توقيت لورد هاو الرسمي", "BOT": "توقيت بوليفيا", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "MST": "MST", "ARST": "توقيت الأرجنتين الصيفي", "HEEG": "توقيت شرق غرينلاند الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "UYST": "توقيت أورغواي الصيفي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "WIB": "توقيت غرب إندونيسيا", "WIT": "توقيت شرق إندونيسيا", "JDT": "توقيت اليابان الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "SGT": "توقيت سنغافورة", "COT": "توقيت كولومبيا الرسمي", "COST": "توقيت كولومبيا الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "GFT": "توقيت غايانا الفرنسية", "∅∅∅": "توقيت برازيليا الصيفي", "CHADT": "توقيت تشاتام الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "JST": "توقيت اليابان الرسمي", "CLST": "توقيت شيلي الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_AE) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_AE' +func (ar *ar_AE) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_AE' +func (ar *ar_AE) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_AE' +func (ar *ar_AE) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_AE' +func (ar *ar_AE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_AE' +func (ar *ar_AE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_AE' +func (ar *ar_AE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_AE) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_AE) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_AE) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_AE) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_AE) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_AE) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_AE) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_AE) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_AE) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_AE) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_AE) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_AE) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_AE) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_AE) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_AE' and handles both Whole and Real numbers based on 'v' +func (ar *ar_AE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_AE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_AE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_AE' +func (ar *ar_AE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_AE' +// in accounting notation. +func (ar *ar_AE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_AE' +func (ar *ar_AE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_AE' +func (ar *ar_AE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_AE' +func (ar *ar_AE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_AE' +func (ar *ar_AE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_AE' +func (ar *ar_AE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_AE' +func (ar *ar_AE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_AE' +func (ar *ar_AE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_AE' +func (ar *ar_AE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_AE/ar_AE_test.go b/vendor/github.com/go-playground/locales/ar_AE/ar_AE_test.go new file mode 100644 index 0000000000..420d048a17 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_AE/ar_AE_test.go @@ -0,0 +1,1120 @@ +package ar_AE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_AE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_BH/ar_BH.go b/vendor/github.com/go-playground/locales/ar_BH/ar_BH.go new file mode 100644 index 0000000000..f45b0e23ee --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_BH/ar_BH.go @@ -0,0 +1,712 @@ +package ar_BH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_BH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_BH' locale +func New() locales.Translator { + return &ar_BH{ + locale: "ar_BH", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNCU": "توقيت كوبا الرسمي", "NZST": "توقيت نيوزيلندا الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "AWST": "توقيت غرب أستراليا الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "CLST": "توقيت شيلي الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "MST": "MST", "HEEG": "توقيت شرق غرينلاند الصيفي", "ECT": "توقيت الإكوادور", "HAST": "توقيت هاواي ألوتيان الرسمي", "WARST": "توقيت غرب الأرجنتين الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "GFT": "توقيت غايانا الفرنسية", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "BOT": "توقيت بوليفيا", "JST": "توقيت اليابان الرسمي", "GMT": "توقيت غرينتش", "OESZ": "توقيت شرق أوروبا الصيفي", "COST": "توقيت كولومبيا الصيفي", "MYT": "توقيت ماليزيا", "WAST": "توقيت غرب أفريقيا الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "HNT": "توقيت نيوفاوندلاند الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "ChST": "توقيت تشامورو", "GYT": "توقيت غيانا", "HECU": "توقيت كوبا الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "TMST": "توقيت تركمانستان الصيفي", "ACDT": "توقيت وسط أستراليا الصيفي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "WIB": "توقيت غرب إندونيسيا", "UYST": "توقيت أورغواي الصيفي", "SRT": "توقيت سورينام", "HADT": "توقيت هاواي ألوتيان الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "CLT": "توقيت شيلي الرسمي", "AST": "التوقيت الرسمي الأطلسي", "HNEG": "توقيت شرق غرينلاند الرسمي", "UYT": "توقيت أورغواي الرسمي", "HNOG": "توقيت غرب غرينلاند الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "ART": "توقيت الأرجنتين الرسمي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "COT": "توقيت كولومبيا الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "IST": "توقيت الهند", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "BT": "توقيت بوتان", "MDT": "MDT", "AKST": "التوقيت الرسمي لألاسكا", "∅∅∅": "توقيت برازيليا الصيفي", "AWDT": "توقيت غرب أستراليا الصيفي", "CHAST": "توقيت تشاتام الرسمي", "SGT": "توقيت سنغافورة", "PDT": "توقيت المحيط الهادي الصيفي", "TMT": "توقيت تركمانستان الرسمي", "LHST": "توقيت لورد هاو الرسمي", "EAT": "توقيت شرق أفريقيا", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CAT": "توقيت وسط أفريقيا", "WEZ": "توقيت غرب أوروبا الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "CHADT": "توقيت تشاتام الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "SAST": "توقيت جنوب أفريقيا", "WIT": "توقيت شرق إندونيسيا", "VET": "توقيت فنزويلا", "JDT": "توقيت اليابان الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "WITA": "توقيت وسط إندونيسيا", "LHDT": "التوقيت الصيفي للورد هاو"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_BH) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_BH' +func (ar *ar_BH) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_BH' +func (ar *ar_BH) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_BH' +func (ar *ar_BH) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_BH' +func (ar *ar_BH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_BH' +func (ar *ar_BH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_BH' +func (ar *ar_BH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_BH) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_BH) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_BH) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_BH) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_BH) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_BH) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_BH) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_BH) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_BH) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_BH) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_BH) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_BH) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_BH) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_BH) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_BH' and handles both Whole and Real numbers based on 'v' +func (ar *ar_BH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_BH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_BH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_BH' +func (ar *ar_BH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_BH' +// in accounting notation. +func (ar *ar_BH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_BH' +func (ar *ar_BH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_BH' +func (ar *ar_BH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_BH' +func (ar *ar_BH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_BH' +func (ar *ar_BH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_BH' +func (ar *ar_BH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_BH' +func (ar *ar_BH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_BH' +func (ar *ar_BH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_BH' +func (ar *ar_BH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_BH/ar_BH_test.go b/vendor/github.com/go-playground/locales/ar_BH/ar_BH_test.go new file mode 100644 index 0000000000..0a90755104 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_BH/ar_BH_test.go @@ -0,0 +1,1120 @@ +package ar_BH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_BH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_DJ/ar_DJ.go b/vendor/github.com/go-playground/locales/ar_DJ/ar_DJ.go new file mode 100644 index 0000000000..c0901822a3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_DJ/ar_DJ.go @@ -0,0 +1,712 @@ +package ar_DJ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_DJ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_DJ' locale +func New() locales.Translator { + return &ar_DJ{ + locale: "ar_DJ", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "Fdj", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"AWST": "توقيت غرب أستراليا الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "COST": "توقيت كولومبيا الصيفي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "EAT": "توقيت شرق أفريقيا", "WIB": "توقيت غرب إندونيسيا", "WIT": "توقيت شرق إندونيسيا", "WART": "توقيت غرب الأرجنتين الرسمي", "OESZ": "توقيت شرق أوروبا الصيفي", "HEEG": "توقيت شرق غرينلاند الصيفي", "ChST": "توقيت تشامورو", "ARST": "توقيت الأرجنتين الصيفي", "UYT": "توقيت أورغواي الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "HAST": "توقيت هاواي ألوتيان الرسمي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "GMT": "توقيت غرينتش", "BT": "توقيت بوتان", "CHADT": "توقيت تشاتام الصيفي", "ART": "توقيت الأرجنتين الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HNEG": "توقيت شرق غرينلاند الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "JST": "توقيت اليابان الرسمي", "CLT": "توقيت شيلي الرسمي", "WEZ": "توقيت غرب أوروبا الرسمي", "TMST": "توقيت تركمانستان الصيفي", "TMT": "توقيت تركمانستان الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "∅∅∅": "توقيت الأمازون الصيفي", "CAT": "توقيت وسط أفريقيا", "NZST": "توقيت نيوزيلندا الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "ECT": "توقيت الإكوادور", "PDT": "توقيت المحيط الهادي الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "AST": "التوقيت الرسمي الأطلسي", "PST": "توقيت المحيط الهادي الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "SAST": "توقيت جنوب أفريقيا", "SRT": "توقيت سورينام", "AWDT": "توقيت غرب أستراليا الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "VET": "توقيت فنزويلا", "JDT": "توقيت اليابان الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "MDT": "MDT", "WITA": "توقيت وسط إندونيسيا", "AKDT": "توقيت ألاسكا الصيفي", "LHST": "توقيت لورد هاو الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "IST": "توقيت الهند", "MEZ": "توقيت وسط أوروبا الرسمي", "CLST": "توقيت شيلي الصيفي", "HAT": "توقيت نيوفاوندلاند الصيفي", "GYT": "توقيت غيانا", "MST": "MST", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "GFT": "توقيت غايانا الفرنسية", "AKST": "التوقيت الرسمي لألاسكا", "HADT": "توقيت هاواي ألوتيان الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "MYT": "توقيت ماليزيا", "ACDT": "توقيت وسط أستراليا الصيفي", "CHAST": "توقيت تشاتام الرسمي", "HECU": "توقيت كوبا الصيفي", "SGT": "توقيت سنغافورة", "HNOG": "توقيت غرب غرينلاند الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "AEST": "توقيت شرق أستراليا الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "UYST": "توقيت أورغواي الصيفي", "HNCU": "توقيت كوبا الرسمي", "BOT": "توقيت بوليفيا", "WAST": "توقيت غرب أفريقيا الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "ACST": "توقيت وسط أستراليا الرسمي", "COT": "توقيت كولومبيا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_DJ) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_DJ' +func (ar *ar_DJ) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_DJ' +func (ar *ar_DJ) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_DJ' +func (ar *ar_DJ) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_DJ' +func (ar *ar_DJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_DJ' +func (ar *ar_DJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_DJ' +func (ar *ar_DJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_DJ) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_DJ) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_DJ) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_DJ) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_DJ) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_DJ) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_DJ) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_DJ) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_DJ) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_DJ) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_DJ) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_DJ) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_DJ) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_DJ) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_DJ' and handles both Whole and Real numbers based on 'v' +func (ar *ar_DJ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_DJ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_DJ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_DJ' +func (ar *ar_DJ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_DJ' +// in accounting notation. +func (ar *ar_DJ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_DJ' +func (ar *ar_DJ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_DJ' +func (ar *ar_DJ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_DJ' +func (ar *ar_DJ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_DJ' +func (ar *ar_DJ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_DJ' +func (ar *ar_DJ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_DJ' +func (ar *ar_DJ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_DJ' +func (ar *ar_DJ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_DJ' +func (ar *ar_DJ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_DJ/ar_DJ_test.go b/vendor/github.com/go-playground/locales/ar_DJ/ar_DJ_test.go new file mode 100644 index 0000000000..7a0652960b --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_DJ/ar_DJ_test.go @@ -0,0 +1,1120 @@ +package ar_DJ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_DJ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_DZ/ar_DZ.go b/vendor/github.com/go-playground/locales/ar_DZ/ar_DZ.go new file mode 100644 index 0000000000..7a84fe3861 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_DZ/ar_DZ.go @@ -0,0 +1,698 @@ +package ar_DZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_DZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_DZ' locale +func New() locales.Translator { + return &ar_DZ{ + locale: "ar_DZ", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: ",", + group: ".", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "جانفي", "فيفري", "مارس", "أفريل", "ماي", "جوان", "جويلية", "أوت", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ج", "ف", "م", "أ", "م", "ج", "ج", "أ", "س", "أ", "ن", "د"}, + monthsWide: []string{"", "جانفي", "فيفري", "مارس", "أفريل", "ماي", "جوان", "جويلية", "أوت", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"NZST": "توقيت نيوزيلندا الرسمي", "TMST": "توقيت تركمانستان الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "WITA": "توقيت وسط إندونيسيا", "UYT": "توقيت أورغواي الرسمي", "HNCU": "توقيت كوبا الرسمي", "AWDT": "توقيت غرب أستراليا الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "ACST": "توقيت وسط أستراليا الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "AWST": "توقيت غرب أستراليا الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "HAT": "توقيت نيوفاوندلاند الصيفي", "ChST": "توقيت تشامورو", "NZDT": "توقيت نيوزيلندا الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "GYT": "توقيت غيانا", "WIT": "توقيت شرق إندونيسيا", "CLT": "توقيت شيلي الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "HECU": "توقيت كوبا الصيفي", "BOT": "توقيت بوليفيا", "JST": "توقيت اليابان الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "BT": "توقيت بوتان", "GFT": "توقيت غايانا الفرنسية", "WESZ": "توقيت غرب أوروبا الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "MST": "MST", "MDT": "MDT", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "COT": "توقيت كولومبيا الرسمي", "CAT": "توقيت وسط أفريقيا", "MEZ": "توقيت وسط أوروبا الرسمي", "SAST": "توقيت جنوب أفريقيا", "LHST": "توقيت لورد هاو الرسمي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "CLST": "توقيت شيلي الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "GMT": "توقيت غرينتش", "MYT": "توقيت ماليزيا", "TMT": "توقيت تركمانستان الرسمي", "COST": "توقيت كولومبيا الصيفي", "PST": "توقيت المحيط الهادي الرسمي", "ECT": "توقيت الإكوادور", "AEDT": "توقيت شرق أستراليا الصيفي", "UYST": "توقيت أورغواي الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "ART": "توقيت الأرجنتين الرسمي", "AKST": "التوقيت الرسمي لألاسكا", "WIB": "توقيت غرب إندونيسيا", "HAST": "توقيت هاواي ألوتيان الرسمي", "JDT": "توقيت اليابان الصيفي", "VET": "توقيت فنزويلا", "WEZ": "توقيت غرب أوروبا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "IST": "توقيت الهند", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "SGT": "توقيت سنغافورة", "HEOG": "توقيت غرب غرينلاند الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "HKST": "توقيت هونغ كونغ الصيفي", "CHADT": "توقيت تشاتام الصيفي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "EAT": "توقيت شرق أفريقيا", "HNT": "توقيت نيوفاوندلاند الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "∅∅∅": "توقيت الأمازون الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "HNEG": "توقيت شرق غرينلاند الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "SRT": "توقيت سورينام", "CHAST": "توقيت تشاتام الرسمي", "PDT": "توقيت المحيط الهادي الصيفي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_DZ) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_DZ' +func (ar *ar_DZ) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_DZ' +func (ar *ar_DZ) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_DZ' +func (ar *ar_DZ) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_DZ' +func (ar *ar_DZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_DZ' +func (ar *ar_DZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_DZ' +func (ar *ar_DZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_DZ) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_DZ) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_DZ) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_DZ) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_DZ) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_DZ) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_DZ) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_DZ) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_DZ) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_DZ) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_DZ) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_DZ) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_DZ) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_DZ) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_DZ' and handles both Whole and Real numbers based on 'v' +func (ar *ar_DZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_DZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_DZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 10 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_DZ' +func (ar *ar_DZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_DZ' +// in accounting notation. +func (ar *ar_DZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_DZ' +func (ar *ar_DZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_DZ' +func (ar *ar_DZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_DZ' +func (ar *ar_DZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_DZ' +func (ar *ar_DZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_DZ' +func (ar *ar_DZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_DZ' +func (ar *ar_DZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_DZ' +func (ar *ar_DZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_DZ' +func (ar *ar_DZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_DZ/ar_DZ_test.go b/vendor/github.com/go-playground/locales/ar_DZ/ar_DZ_test.go new file mode 100644 index 0000000000..a14b6ce049 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_DZ/ar_DZ_test.go @@ -0,0 +1,1120 @@ +package ar_DZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_DZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_EG/ar_EG.go b/vendor/github.com/go-playground/locales/ar_EG/ar_EG.go new file mode 100644 index 0000000000..ef1329e739 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_EG/ar_EG.go @@ -0,0 +1,712 @@ +package ar_EG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_EG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_EG' locale +func New() locales.Translator { + return &ar_EG{ + locale: "ar_EG", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"EAT": "توقيت شرق أفريقيا", "ChST": "توقيت تشامورو", "LHST": "توقيت لورد هاو الرسمي", "GYT": "توقيت غيانا", "PDT": "توقيت المحيط الهادي الصيفي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HECU": "توقيت كوبا الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "AWDT": "توقيت غرب أستراليا الصيفي", "WIB": "توقيت غرب إندونيسيا", "AST": "التوقيت الرسمي الأطلسي", "BT": "توقيت بوتان", "WITA": "توقيت وسط إندونيسيا", "AEST": "توقيت شرق أستراليا الرسمي", "MST": "التوقيت الجبلي الرسمي لأمريكا الشمالية", "ECT": "توقيت الإكوادور", "IST": "توقيت الهند", "MEZ": "توقيت وسط أوروبا الرسمي", "MESZ": "توقيت وسط أوروبا الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "AEDT": "توقيت شرق أستراليا الصيفي", "UYT": "توقيت أورغواي الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "TMST": "توقيت تركمانستان الصيفي", "ART": "توقيت الأرجنتين الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "SRT": "توقيت سورينام", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "ACST": "توقيت وسط أستراليا الرسمي", "CLST": "توقيت شيلي الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "TMT": "توقيت تركمانستان الرسمي", "SGT": "توقيت سنغافورة", "PST": "توقيت المحيط الهادي الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "UYST": "توقيت أورغواي الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "AWST": "توقيت غرب أستراليا الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "WARST": "توقيت غرب الأرجنتين الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "∅∅∅": "توقيت أزورس الصيفي", "HNCU": "توقيت كوبا الرسمي", "CHADT": "توقيت تشاتام الصيفي", "BOT": "توقيت بوليفيا", "CAT": "توقيت وسط أفريقيا", "GFT": "توقيت غايانا الفرنسية", "AKST": "التوقيت الرسمي لألاسكا", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "WAST": "توقيت غرب أفريقيا الصيفي", "VET": "توقيت فنزويلا", "HNOG": "توقيت غرب غرينلاند الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "MYT": "توقيت ماليزيا", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HAT": "توقيت نيوفاوندلاند الصيفي", "HEEG": "توقيت شرق غرينلاند الصيفي", "AKDT": "توقيت ألاسكا الصيفي", "MDT": "التوقيت الجبلي الصيفي لأمريكا الشمالية", "OESZ": "توقيت شرق أوروبا الصيفي", "ACDT": "توقيت وسط أستراليا الصيفي", "COST": "توقيت كولومبيا الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNT": "توقيت نيوفاوندلاند الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "COT": "توقيت كولومبيا الرسمي", "JDT": "توقيت اليابان الصيفي", "JST": "توقيت اليابان الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "GMT": "توقيت غرينتش", "SAST": "توقيت جنوب أفريقيا", "WIT": "توقيت شرق إندونيسيا", "CHAST": "توقيت تشاتام الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "CLT": "توقيت شيلي الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_EG) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_EG' +func (ar *ar_EG) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_EG' +func (ar *ar_EG) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_EG' +func (ar *ar_EG) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_EG' +func (ar *ar_EG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_EG' +func (ar *ar_EG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_EG' +func (ar *ar_EG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_EG) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_EG) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_EG) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_EG) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_EG) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_EG) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_EG) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_EG) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_EG) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_EG) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_EG) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_EG) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_EG) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_EG) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_EG' and handles both Whole and Real numbers based on 'v' +func (ar *ar_EG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_EG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_EG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_EG' +func (ar *ar_EG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_EG' +// in accounting notation. +func (ar *ar_EG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_EG' +func (ar *ar_EG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_EG' +func (ar *ar_EG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_EG' +func (ar *ar_EG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_EG' +func (ar *ar_EG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_EG' +func (ar *ar_EG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_EG' +func (ar *ar_EG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_EG' +func (ar *ar_EG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_EG' +func (ar *ar_EG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_EG/ar_EG_test.go b/vendor/github.com/go-playground/locales/ar_EG/ar_EG_test.go new file mode 100644 index 0000000000..9bc3a93d07 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_EG/ar_EG_test.go @@ -0,0 +1,1120 @@ +package ar_EG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_EG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_EH/ar_EH.go b/vendor/github.com/go-playground/locales/ar_EH/ar_EH.go new file mode 100644 index 0000000000..29cff871bf --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_EH/ar_EH.go @@ -0,0 +1,712 @@ +package ar_EH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_EH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_EH' locale +func New() locales.Translator { + return &ar_EH{ + locale: "ar_EH", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"SAST": "توقيت جنوب أفريقيا", "LHST": "توقيت لورد هاو الرسمي", "GYT": "توقيت غيانا", "MDT": "MDT", "ART": "توقيت الأرجنتين الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "ARST": "توقيت الأرجنتين الصيفي", "COT": "توقيت كولومبيا الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "HECU": "توقيت كوبا الصيفي", "MYT": "توقيت ماليزيا", "AST": "التوقيت الرسمي الأطلسي", "CHADT": "توقيت تشاتام الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "ACDT": "توقيت وسط أستراليا الصيفي", "BT": "توقيت بوتان", "AKST": "التوقيت الرسمي لألاسكا", "AWST": "توقيت غرب أستراليا الرسمي", "MESZ": "توقيت وسط أوروبا الصيفي", "TMST": "توقيت تركمانستان الصيفي", "JDT": "توقيت اليابان الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "WITA": "توقيت وسط إندونيسيا", "UYT": "توقيت أورغواي الرسمي", "WIT": "توقيت شرق إندونيسيا", "ECT": "توقيت الإكوادور", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "NZST": "توقيت نيوزيلندا الرسمي", "IST": "توقيت الهند", "HAST": "توقيت هاواي ألوتيان الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HNT": "توقيت نيوفاوندلاند الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "SRT": "توقيت سورينام", "HNOG": "توقيت غرب غرينلاند الرسمي", "OESZ": "توقيت شرق أوروبا الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "COST": "توقيت كولومبيا الصيفي", "WIB": "توقيت غرب إندونيسيا", "AWDT": "توقيت غرب أستراليا الصيفي", "PST": "توقيت المحيط الهادي الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "AKDT": "توقيت ألاسكا الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNEG": "توقيت شرق غرينلاند الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "HADT": "توقيت هاواي ألوتيان الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "TMT": "توقيت تركمانستان الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "∅∅∅": "توقيت الأمازون الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "CLST": "توقيت شيلي الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "UYST": "توقيت أورغواي الصيفي", "EAT": "توقيت شرق أفريقيا", "BOT": "توقيت بوليفيا", "NZDT": "توقيت نيوزيلندا الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "VET": "توقيت فنزويلا", "CLT": "توقيت شيلي الرسمي", "GFT": "توقيت غايانا الفرنسية", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CHAST": "توقيت تشاتام الرسمي", "CAT": "توقيت وسط أفريقيا", "MEZ": "توقيت وسط أوروبا الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "HNCU": "توقيت كوبا الرسمي", "MST": "MST", "HAT": "توقيت نيوفاوندلاند الصيفي", "ChST": "توقيت تشامورو", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "SGT": "توقيت سنغافورة", "JST": "توقيت اليابان الرسمي", "GMT": "توقيت غرينتش"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_EH) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_EH' +func (ar *ar_EH) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_EH' +func (ar *ar_EH) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_EH' +func (ar *ar_EH) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_EH' +func (ar *ar_EH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_EH' +func (ar *ar_EH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_EH' +func (ar *ar_EH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_EH) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_EH) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_EH) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_EH) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_EH) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_EH) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_EH) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_EH) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_EH) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_EH) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_EH) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_EH) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_EH) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_EH) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_EH' and handles both Whole and Real numbers based on 'v' +func (ar *ar_EH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_EH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_EH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_EH' +func (ar *ar_EH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_EH' +// in accounting notation. +func (ar *ar_EH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_EH' +func (ar *ar_EH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_EH' +func (ar *ar_EH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_EH' +func (ar *ar_EH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_EH' +func (ar *ar_EH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_EH' +func (ar *ar_EH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_EH' +func (ar *ar_EH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_EH' +func (ar *ar_EH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_EH' +func (ar *ar_EH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_EH/ar_EH_test.go b/vendor/github.com/go-playground/locales/ar_EH/ar_EH_test.go new file mode 100644 index 0000000000..db7c521f0a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_EH/ar_EH_test.go @@ -0,0 +1,1120 @@ +package ar_EH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_EH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_ER/ar_ER.go b/vendor/github.com/go-playground/locales/ar_ER/ar_ER.go new file mode 100644 index 0000000000..eb39ee84d8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_ER/ar_ER.go @@ -0,0 +1,712 @@ +package ar_ER + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_ER struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_ER' locale +func New() locales.Translator { + return &ar_ER{ + locale: "ar_ER", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "Nfk", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"OESZ": "توقيت شرق أوروبا الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "OEZ": "توقيت شرق أوروبا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "COST": "توقيت كولومبيا الصيفي", "ACDT": "توقيت وسط أستراليا الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "LHST": "توقيت لورد هاو الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "JST": "توقيت اليابان الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "AWDT": "توقيت غرب أستراليا الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "MYT": "توقيت ماليزيا", "ADT": "التوقيت الصيفي الأطلسي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "HAST": "توقيت هاواي ألوتيان الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "CHADT": "توقيت تشاتام الصيفي", "VET": "توقيت فنزويلا", "COT": "توقيت كولومبيا الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "GFT": "توقيت غايانا الفرنسية", "AWST": "توقيت غرب أستراليا الرسمي", "SGT": "توقيت سنغافورة", "NZST": "توقيت نيوزيلندا الرسمي", "AEST": "توقيت شرق أستراليا الرسمي", "AKST": "التوقيت الرسمي لألاسكا", "SRT": "توقيت سورينام", "WIB": "توقيت غرب إندونيسيا", "ECT": "توقيت الإكوادور", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "WAST": "توقيت غرب أفريقيا الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "ACST": "توقيت وسط أستراليا الرسمي", "WITA": "توقيت وسط إندونيسيا", "UYST": "توقيت أورغواي الصيفي", "BOT": "توقيت بوليفيا", "WARST": "توقيت غرب الأرجنتين الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "TMT": "توقيت تركمانستان الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "ChST": "توقيت تشامورو", "HNCU": "توقيت كوبا الرسمي", "CAT": "توقيت وسط أفريقيا", "CLST": "توقيت شيلي الصيفي", "HECU": "توقيت كوبا الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "JDT": "توقيت اليابان الصيفي", "TMST": "توقيت تركمانستان الصيفي", "MDT": "MDT", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "CHAST": "توقيت تشاتام الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "HADT": "توقيت هاواي ألوتيان الصيفي", "BT": "توقيت بوتان", "EAT": "توقيت شرق أفريقيا", "∅∅∅": "توقيت برازيليا الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "IST": "توقيت الهند", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "ART": "توقيت الأرجنتين الرسمي", "UYT": "توقيت أورغواي الرسمي", "WIT": "توقيت شرق إندونيسيا", "CLT": "توقيت شيلي الرسمي", "GMT": "توقيت غرينتش", "HNOG": "توقيت غرب غرينلاند الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "MST": "MST", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "AKDT": "توقيت ألاسكا الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "SAST": "توقيت جنوب أفريقيا", "GYT": "توقيت غيانا"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_ER) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_ER' +func (ar *ar_ER) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_ER' +func (ar *ar_ER) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_ER' +func (ar *ar_ER) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_ER' +func (ar *ar_ER) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_ER' +func (ar *ar_ER) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_ER' +func (ar *ar_ER) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_ER) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_ER) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_ER) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_ER) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_ER) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_ER) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_ER) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_ER) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_ER) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_ER) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_ER) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_ER) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_ER) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_ER) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_ER' and handles both Whole and Real numbers based on 'v' +func (ar *ar_ER) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_ER' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_ER) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_ER' +func (ar *ar_ER) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_ER' +// in accounting notation. +func (ar *ar_ER) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_ER' +func (ar *ar_ER) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_ER' +func (ar *ar_ER) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_ER' +func (ar *ar_ER) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_ER' +func (ar *ar_ER) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_ER' +func (ar *ar_ER) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_ER' +func (ar *ar_ER) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_ER' +func (ar *ar_ER) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_ER' +func (ar *ar_ER) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_ER/ar_ER_test.go b/vendor/github.com/go-playground/locales/ar_ER/ar_ER_test.go new file mode 100644 index 0000000000..6f323811b0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_ER/ar_ER_test.go @@ -0,0 +1,1120 @@ +package ar_ER + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_ER" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_IL/ar_IL.go b/vendor/github.com/go-playground/locales/ar_IL/ar_IL.go new file mode 100644 index 0000000000..ca9921bccf --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_IL/ar_IL.go @@ -0,0 +1,658 @@ +package ar_IL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_IL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_IL' locale +func New() locales.Translator { + return &ar_IL{ + locale: "ar_IL", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"GYT": "توقيت غيانا", "HNCU": "توقيت كوبا الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "∅∅∅": "توقيت الأمازون الصيفي", "CLT": "توقيت شيلي الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "JDT": "توقيت اليابان الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "GFT": "توقيت غايانا الفرنسية", "AEST": "توقيت شرق أستراليا الرسمي", "HECU": "توقيت كوبا الصيفي", "AWDT": "توقيت غرب أستراليا الصيفي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "COT": "توقيت كولومبيا الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "AWST": "توقيت غرب أستراليا الرسمي", "CHAST": "توقيت تشاتام الرسمي", "VET": "توقيت فنزويلا", "AST": "التوقيت الرسمي الأطلسي", "AKDT": "توقيت ألاسكا الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "MST": "MST", "SRT": "توقيت سورينام", "BOT": "توقيت بوليفيا", "IST": "توقيت الهند", "HEOG": "توقيت غرب غرينلاند الصيفي", "ADT": "التوقيت الصيفي الأطلسي", "OEZ": "توقيت شرق أوروبا الرسمي", "MDT": "MDT", "WAST": "توقيت غرب أفريقيا الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "CHADT": "توقيت تشاتام الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "ECT": "توقيت الإكوادور", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "BT": "توقيت بوتان", "UYST": "توقيت أورغواي الصيفي", "SAST": "توقيت جنوب أفريقيا", "WIB": "توقيت غرب إندونيسيا", "OESZ": "توقيت شرق أوروبا الصيفي", "UYT": "توقيت أورغواي الرسمي", "WIT": "توقيت شرق إندونيسيا", "CAT": "توقيت وسط أفريقيا", "TMT": "توقيت تركمانستان الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "AKST": "التوقيت الرسمي لألاسكا", "EAT": "توقيت شرق أفريقيا", "WESZ": "توقيت غرب أوروبا الصيفي", "GMT": "توقيت غرينتش", "ACDT": "توقيت وسط أستراليا الصيفي", "WITA": "توقيت وسط إندونيسيا", "WARST": "توقيت غرب الأرجنتين الصيفي", "ART": "توقيت الأرجنتين الرسمي", "HNT": "توقيت نيوفاوندلاند الرسمي", "SGT": "توقيت سنغافورة", "TMST": "توقيت تركمانستان الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "HEEG": "توقيت شرق غرينلاند الصيفي", "ChST": "توقيت تشامورو", "HAST": "توقيت هاواي ألوتيان الرسمي", "JST": "توقيت اليابان الرسمي", "MYT": "توقيت ماليزيا", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "PDT": "توقيت المحيط الهادي الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "COST": "توقيت كولومبيا الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "MESZ": "توقيت وسط أوروبا الصيفي", "LHST": "توقيت لورد هاو الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "CLST": "توقيت شيلي الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "AEDT": "توقيت شرق أستراليا الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "NZDT": "توقيت نيوزيلندا الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNEG": "توقيت شرق غرينلاند الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_IL) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_IL' +func (ar *ar_IL) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_IL' +func (ar *ar_IL) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_IL' +func (ar *ar_IL) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_IL' +func (ar *ar_IL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_IL' +func (ar *ar_IL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_IL' +func (ar *ar_IL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_IL) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_IL) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_IL) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_IL) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_IL) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_IL) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_IL) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_IL) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_IL) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_IL) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_IL) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_IL) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_IL) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_IL) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_IL' and handles both Whole and Real numbers based on 'v' +func (ar *ar_IL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_IL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_IL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_IL' +func (ar *ar_IL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_IL' +// in accounting notation. +func (ar *ar_IL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_IL' +func (ar *ar_IL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_IL' +func (ar *ar_IL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_IL' +func (ar *ar_IL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_IL' +func (ar *ar_IL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_IL' +func (ar *ar_IL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_IL' +func (ar *ar_IL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_IL' +func (ar *ar_IL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_IL' +func (ar *ar_IL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_IL/ar_IL_test.go b/vendor/github.com/go-playground/locales/ar_IL/ar_IL_test.go new file mode 100644 index 0000000000..78d37a1a6d --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_IL/ar_IL_test.go @@ -0,0 +1,1120 @@ +package ar_IL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_IL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_IQ/ar_IQ.go b/vendor/github.com/go-playground/locales/ar_IQ/ar_IQ.go new file mode 100644 index 0000000000..b4b7ffa8ae --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_IQ/ar_IQ.go @@ -0,0 +1,712 @@ +package ar_IQ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_IQ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_IQ' locale +func New() locales.Translator { + return &ar_IQ{ + locale: "ar_IQ", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرین الأول", "تشرين الثاني", "كانون الأول"}, + monthsNarrow: []string{"", "ك", "ش", "آ", "ن", "أ", "ح", "ت", "آ", "أ", "ت", "ت", "ك"}, + monthsWide: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"SRT": "توقيت سورينام", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "NZDT": "توقيت نيوزيلندا الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "COST": "توقيت كولومبيا الصيفي", "ChST": "توقيت تشامورو", "PST": "توقيت المحيط الهادي الرسمي", "IST": "توقيت الهند", "JDT": "توقيت اليابان الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "CLT": "توقيت شيلي الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "∅∅∅": "توقيت أزورس الصيفي", "CAT": "توقيت وسط أفريقيا", "JST": "توقيت اليابان الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "HNCU": "توقيت كوبا الرسمي", "AWST": "توقيت غرب أستراليا الرسمي", "CHAST": "توقيت تشاتام الرسمي", "BOT": "توقيت بوليفيا", "HADT": "توقيت هاواي ألوتيان الصيفي", "VET": "توقيت فنزويلا", "MYT": "توقيت ماليزيا", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "ADT": "التوقيت الصيفي الأطلسي", "WEZ": "توقيت غرب أوروبا الرسمي", "COT": "توقيت كولومبيا الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "EAT": "توقيت شرق أفريقيا", "WARST": "توقيت غرب الأرجنتين الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HAT": "توقيت نيوفاوندلاند الصيفي", "HNEG": "توقيت شرق غرينلاند الرسمي", "GFT": "توقيت غايانا الفرنسية", "HECU": "توقيت كوبا الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "TMT": "توقيت تركمانستان الرسمي", "WITA": "توقيت وسط إندونيسيا", "UYST": "توقيت أورغواي الصيفي", "SAST": "توقيت جنوب أفريقيا", "LHST": "توقيت لورد هاو الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "SGT": "توقيت سنغافورة", "CLST": "توقيت شيلي الصيفي", "BT": "توقيت بوتان", "GYT": "توقيت غيانا", "OEZ": "توقيت شرق أوروبا الرسمي", "ART": "توقيت الأرجنتين الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "MDT": "التوقيت الجبلي الصيفي لأمريكا الشمالية", "AKST": "التوقيت الرسمي لألاسكا", "AWDT": "توقيت غرب أستراليا الصيفي", "CHADT": "توقيت تشاتام الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "HNT": "توقيت نيوفاوندلاند الرسمي", "UYT": "توقيت أورغواي الرسمي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "MESZ": "توقيت وسط أوروبا الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "TMST": "توقيت تركمانستان الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "NZST": "توقيت نيوزيلندا الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "HAST": "توقيت هاواي ألوتيان الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "HEEG": "توقيت شرق غرينلاند الصيفي", "WIB": "توقيت غرب إندونيسيا", "ECT": "توقيت الإكوادور", "GMT": "توقيت غرينتش", "AEDT": "توقيت شرق أستراليا الصيفي", "MST": "التوقيت الجبلي الرسمي لأمريكا الشمالية", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "WIT": "توقيت شرق إندونيسيا", "PDT": "توقيت المحيط الهادي الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "ACST": "توقيت وسط أستراليا الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_IQ) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_IQ' +func (ar *ar_IQ) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_IQ' +func (ar *ar_IQ) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_IQ' +func (ar *ar_IQ) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_IQ' +func (ar *ar_IQ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_IQ' +func (ar *ar_IQ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_IQ' +func (ar *ar_IQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_IQ) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_IQ) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_IQ) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_IQ) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_IQ) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_IQ) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_IQ) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_IQ) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_IQ) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_IQ) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_IQ) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_IQ) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_IQ) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_IQ) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_IQ' and handles both Whole and Real numbers based on 'v' +func (ar *ar_IQ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_IQ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_IQ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_IQ' +func (ar *ar_IQ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_IQ' +// in accounting notation. +func (ar *ar_IQ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_IQ' +func (ar *ar_IQ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_IQ' +func (ar *ar_IQ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_IQ' +func (ar *ar_IQ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_IQ' +func (ar *ar_IQ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_IQ' +func (ar *ar_IQ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_IQ' +func (ar *ar_IQ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_IQ' +func (ar *ar_IQ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_IQ' +func (ar *ar_IQ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_IQ/ar_IQ_test.go b/vendor/github.com/go-playground/locales/ar_IQ/ar_IQ_test.go new file mode 100644 index 0000000000..223372a8ce --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_IQ/ar_IQ_test.go @@ -0,0 +1,1120 @@ +package ar_IQ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_IQ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_JO/ar_JO.go b/vendor/github.com/go-playground/locales/ar_JO/ar_JO.go new file mode 100644 index 0000000000..45538cb96b --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_JO/ar_JO.go @@ -0,0 +1,712 @@ +package ar_JO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_JO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_JO' locale +func New() locales.Translator { + return &ar_JO{ + locale: "ar_JO", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + monthsNarrow: []string{"", "ك", "ش", "آ", "ن", "أ", "ح", "ت", "آ", "أ", "ت", "ت", "ك"}, + monthsWide: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "HNCU": "توقيت كوبا الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "WIB": "توقيت غرب إندونيسيا", "ECT": "توقيت الإكوادور", "JST": "توقيت اليابان الرسمي", "AST": "التوقيت الرسمي الأطلسي", "OESZ": "توقيت شرق أوروبا الصيفي", "TMT": "توقيت تركمانستان الرسمي", "ART": "توقيت الأرجنتين الرسمي", "GFT": "توقيت غايانا الفرنسية", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "WIT": "توقيت شرق إندونيسيا", "MESZ": "توقيت وسط أوروبا الصيفي", "GMT": "توقيت غرينتش", "MYT": "توقيت ماليزيا", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "AWDT": "توقيت غرب أستراليا الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "CLST": "توقيت شيلي الصيفي", "SAST": "توقيت جنوب أفريقيا", "EAT": "توقيت شرق أفريقيا", "AEDT": "توقيت شرق أستراليا الصيفي", "SRT": "توقيت سورينام", "BOT": "توقيت بوليفيا", "COST": "توقيت كولومبيا الصيفي", "UYT": "توقيت أورغواي الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HKST": "توقيت هونغ كونغ الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "CHADT": "توقيت تشاتام الصيفي", "IST": "توقيت الهند", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "GYT": "توقيت غيانا", "CHAST": "توقيت تشاتام الرسمي", "JDT": "توقيت اليابان الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "AEST": "توقيت شرق أستراليا الرسمي", "AKST": "التوقيت الرسمي لألاسكا", "SGT": "توقيت سنغافورة", "HADT": "توقيت هاواي ألوتيان الصيفي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "MDT": "MDT", "ACST": "توقيت وسط أستراليا الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HKT": "توقيت هونغ كونغ الرسمي", "UYST": "توقيت أورغواي الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "TMST": "توقيت تركمانستان الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HAT": "توقيت نيوفاوندلاند الصيفي", "HAST": "توقيت هاواي ألوتيان الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "AWST": "توقيت غرب أستراليا الرسمي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "VET": "توقيت فنزويلا", "CLT": "توقيت شيلي الرسمي", "WARST": "توقيت غرب الأرجنتين الصيفي", "MST": "MST", "∅∅∅": "∅∅∅", "LHST": "توقيت لورد هاو الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "HECU": "توقيت كوبا الصيفي", "ADT": "التوقيت الصيفي الأطلسي", "ARST": "توقيت الأرجنتين الصيفي", "COT": "توقيت كولومبيا الرسمي", "BT": "توقيت بوتان", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "PDT": "توقيت المحيط الهادي الصيفي", "CAT": "توقيت وسط أفريقيا", "WAT": "توقيت غرب أفريقيا الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "WITA": "توقيت وسط إندونيسيا", "ChST": "توقيت تشامورو"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_JO) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_JO' +func (ar *ar_JO) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_JO' +func (ar *ar_JO) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_JO' +func (ar *ar_JO) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_JO' +func (ar *ar_JO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_JO' +func (ar *ar_JO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_JO' +func (ar *ar_JO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_JO) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_JO) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_JO) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_JO) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_JO) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_JO) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_JO) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_JO) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_JO) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_JO) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_JO) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_JO) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_JO) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_JO) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_JO' and handles both Whole and Real numbers based on 'v' +func (ar *ar_JO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_JO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_JO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_JO' +func (ar *ar_JO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_JO' +// in accounting notation. +func (ar *ar_JO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_JO' +func (ar *ar_JO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_JO' +func (ar *ar_JO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_JO' +func (ar *ar_JO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_JO' +func (ar *ar_JO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_JO' +func (ar *ar_JO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_JO' +func (ar *ar_JO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_JO' +func (ar *ar_JO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_JO' +func (ar *ar_JO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_JO/ar_JO_test.go b/vendor/github.com/go-playground/locales/ar_JO/ar_JO_test.go new file mode 100644 index 0000000000..372954937a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_JO/ar_JO_test.go @@ -0,0 +1,1120 @@ +package ar_JO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_JO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_KM/ar_KM.go b/vendor/github.com/go-playground/locales/ar_KM/ar_KM.go new file mode 100644 index 0000000000..67c9936c19 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_KM/ar_KM.go @@ -0,0 +1,674 @@ +package ar_KM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_KM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_KM' locale +func New() locales.Translator { + return &ar_KM{ + locale: "ar_KM", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"WART": "توقيت غرب الأرجنتين الرسمي", "ART": "توقيت الأرجنتين الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "ChST": "توقيت تشامورو", "SAST": "توقيت جنوب أفريقيا", "MESZ": "توقيت وسط أوروبا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "HNCU": "توقيت كوبا الرسمي", "WARST": "توقيت غرب الأرجنتين الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "ACST": "توقيت وسط أستراليا الرسمي", "BT": "توقيت بوتان", "HEEG": "توقيت شرق غرينلاند الصيفي", "WIT": "توقيت شرق إندونيسيا", "CAT": "توقيت وسط أفريقيا", "WESZ": "توقيت غرب أوروبا الصيفي", "CHADT": "توقيت تشاتام الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "ACDT": "توقيت وسط أستراليا الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "∅∅∅": "توقيت الأمازون الصيفي", "TMT": "توقيت تركمانستان الرسمي", "COT": "توقيت كولومبيا الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "GFT": "توقيت غايانا الفرنسية", "AKST": "التوقيت الرسمي لألاسكا", "CLST": "توقيت شيلي الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "GYT": "توقيت غيانا", "CLT": "توقيت شيلي الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "COST": "توقيت كولومبيا الصيفي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "AWST": "توقيت غرب أستراليا الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "SRT": "توقيت سورينام", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "UYST": "توقيت أورغواي الصيفي", "AWDT": "توقيت غرب أستراليا الصيفي", "PST": "توقيت المحيط الهادي الرسمي", "HADT": "توقيت هاواي ألوتيان الصيفي", "GMT": "توقيت غرينتش", "HKST": "توقيت هونغ كونغ الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "LHDT": "التوقيت الصيفي للورد هاو", "SGT": "توقيت سنغافورة", "ECT": "توقيت الإكوادور", "OESZ": "توقيت شرق أوروبا الصيفي", "MYT": "توقيت ماليزيا", "HNOG": "توقيت غرب غرينلاند الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "MST": "MST", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "CHAST": "توقيت تشاتام الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "VET": "توقيت فنزويلا", "JDT": "توقيت اليابان الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "MDT": "MDT", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HECU": "توقيت كوبا الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "JST": "توقيت اليابان الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "EAT": "توقيت شرق أفريقيا", "BOT": "توقيت بوليفيا", "PDT": "توقيت المحيط الهادي الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "TMST": "توقيت تركمانستان الصيفي", "WITA": "توقيت وسط إندونيسيا", "AEST": "توقيت شرق أستراليا الرسمي", "WIB": "توقيت غرب إندونيسيا", "IST": "توقيت الهند", "MEZ": "توقيت وسط أوروبا الرسمي", "LHST": "توقيت لورد هاو الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "UYT": "توقيت أورغواي الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_KM) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_KM' +func (ar *ar_KM) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_KM' +func (ar *ar_KM) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_KM' +func (ar *ar_KM) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_KM' +func (ar *ar_KM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_KM' +func (ar *ar_KM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_KM' +func (ar *ar_KM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_KM) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_KM) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_KM) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_KM) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_KM) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_KM) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_KM) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_KM) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_KM) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_KM) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_KM) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_KM) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_KM) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_KM) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_KM' and handles both Whole and Real numbers based on 'v' +func (ar *ar_KM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_KM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_KM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_KM' +func (ar *ar_KM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_KM' +// in accounting notation. +func (ar *ar_KM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_KM' +func (ar *ar_KM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_KM' +func (ar *ar_KM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_KM' +func (ar *ar_KM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_KM' +func (ar *ar_KM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_KM' +func (ar *ar_KM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_KM' +func (ar *ar_KM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_KM' +func (ar *ar_KM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_KM' +func (ar *ar_KM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_KM/ar_KM_test.go b/vendor/github.com/go-playground/locales/ar_KM/ar_KM_test.go new file mode 100644 index 0000000000..4fe9ad40aa --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_KM/ar_KM_test.go @@ -0,0 +1,1120 @@ +package ar_KM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_KM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_KW/ar_KW.go b/vendor/github.com/go-playground/locales/ar_KW/ar_KW.go new file mode 100644 index 0000000000..ecd9bc366d --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_KW/ar_KW.go @@ -0,0 +1,712 @@ +package ar_KW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_KW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_KW' locale +func New() locales.Translator { + return &ar_KW{ + locale: "ar_KW", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"MDT": "MDT", "ACDT": "توقيت وسط أستراليا الصيفي", "UYT": "توقيت أورغواي الرسمي", "WARST": "توقيت غرب الأرجنتين الصيفي", "CLST": "توقيت شيلي الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "∅∅∅": "توقيت بيرو الصيفي", "EAT": "توقيت شرق أفريقيا", "HECU": "توقيت كوبا الصيفي", "VET": "توقيت فنزويلا", "TMT": "توقيت تركمانستان الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "BT": "توقيت بوتان", "HNCU": "توقيت كوبا الرسمي", "CHADT": "توقيت تشاتام الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "WIB": "توقيت غرب إندونيسيا", "CAT": "توقيت وسط أفريقيا", "HNOG": "توقيت غرب غرينلاند الرسمي", "AST": "التوقيت الرسمي الأطلسي", "ART": "توقيت الأرجنتين الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "CLT": "توقيت شيلي الرسمي", "SRT": "توقيت سورينام", "WIT": "توقيت شرق إندونيسيا", "HNEG": "توقيت شرق غرينلاند الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "AKST": "التوقيت الرسمي لألاسكا", "GMT": "توقيت غرينتش", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HNT": "توقيت نيوفاوندلاند الرسمي", "ECT": "توقيت الإكوادور", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "AWDT": "توقيت غرب أستراليا الصيفي", "BOT": "توقيت بوليفيا", "COST": "توقيت كولومبيا الصيفي", "UYST": "توقيت أورغواي الصيفي", "ADT": "التوقيت الصيفي الأطلسي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HKT": "توقيت هونغ كونغ الرسمي", "WEZ": "توقيت غرب أوروبا الرسمي", "GYT": "توقيت غيانا", "PST": "توقيت المحيط الهادي الرسمي", "AWST": "توقيت غرب أستراليا الرسمي", "MEZ": "توقيت وسط أوروبا الرسمي", "MYT": "توقيت ماليزيا", "ChST": "توقيت تشامورو", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "AEDT": "توقيت شرق أستراليا الصيفي", "LHST": "توقيت لورد هاو الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "HADT": "توقيت هاواي ألوتيان الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "COT": "توقيت كولومبيا الرسمي", "AEST": "توقيت شرق أستراليا الرسمي", "JDT": "توقيت اليابان الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "GFT": "توقيت غايانا الفرنسية", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "NZST": "توقيت نيوزيلندا الرسمي", "ACST": "توقيت وسط أستراليا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "SAST": "توقيت جنوب أفريقيا", "SGT": "توقيت سنغافورة", "PDT": "توقيت المحيط الهادي الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "JST": "توقيت اليابان الرسمي", "WITA": "توقيت وسط إندونيسيا", "MESZ": "توقيت وسط أوروبا الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "AKDT": "توقيت ألاسكا الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CHAST": "توقيت تشاتام الرسمي", "IST": "توقيت الهند", "WART": "توقيت غرب الأرجنتين الرسمي", "TMST": "توقيت تركمانستان الصيفي", "MST": "MST"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_KW) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_KW' +func (ar *ar_KW) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_KW' +func (ar *ar_KW) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_KW' +func (ar *ar_KW) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_KW' +func (ar *ar_KW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_KW' +func (ar *ar_KW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_KW' +func (ar *ar_KW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_KW) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_KW) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_KW) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_KW) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_KW) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_KW) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_KW) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_KW) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_KW) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_KW) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_KW) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_KW) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_KW) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_KW) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_KW' and handles both Whole and Real numbers based on 'v' +func (ar *ar_KW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_KW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_KW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_KW' +func (ar *ar_KW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_KW' +// in accounting notation. +func (ar *ar_KW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_KW' +func (ar *ar_KW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_KW' +func (ar *ar_KW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_KW' +func (ar *ar_KW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_KW' +func (ar *ar_KW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_KW' +func (ar *ar_KW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_KW' +func (ar *ar_KW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_KW' +func (ar *ar_KW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_KW' +func (ar *ar_KW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_KW/ar_KW_test.go b/vendor/github.com/go-playground/locales/ar_KW/ar_KW_test.go new file mode 100644 index 0000000000..5b07a3a708 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_KW/ar_KW_test.go @@ -0,0 +1,1120 @@ +package ar_KW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_KW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_LB/ar_LB.go b/vendor/github.com/go-playground/locales/ar_LB/ar_LB.go new file mode 100644 index 0000000000..530a5ab85d --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_LB/ar_LB.go @@ -0,0 +1,698 @@ +package ar_LB + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_LB struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_LB' locale +func New() locales.Translator { + return &ar_LB{ + locale: "ar_LB", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: ",", + group: ".", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + monthsNarrow: []string{"", "ك", "ش", "آ", "ن", "أ", "ح", "ت", "آ", "أ", "ت", "ت", "ك"}, + monthsWide: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"UYT": "توقيت أورغواي الرسمي", "JST": "توقيت اليابان الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "TMT": "توقيت تركمانستان الرسمي", "AKST": "التوقيت الرسمي لألاسكا", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "WARST": "توقيت غرب الأرجنتين الصيفي", "MDT": "MDT", "HKT": "توقيت هونغ كونغ الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "GYT": "توقيت غيانا", "AWST": "توقيت غرب أستراليا الرسمي", "VET": "توقيت فنزويلا", "MESZ": "توقيت وسط أوروبا الصيفي", "ART": "توقيت الأرجنتين الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "WIT": "توقيت شرق إندونيسيا", "CHAST": "توقيت تشاتام الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "SGT": "توقيت سنغافورة", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "LHST": "توقيت لورد هاو الرسمي", "COT": "توقيت كولومبيا الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "SRT": "توقيت سورينام", "SAST": "توقيت جنوب أفريقيا", "PST": "توقيت المحيط الهادي الرسمي", "MYT": "توقيت ماليزيا", "CLT": "توقيت شيلي الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "CHADT": "توقيت تشاتام الصيفي", "ECT": "توقيت الإكوادور", "NZST": "توقيت نيوزيلندا الرسمي", "HNOG": "توقيت غرب غرينلاند الرسمي", "BOT": "توقيت بوليفيا", "NZDT": "توقيت نيوزيلندا الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "EAT": "توقيت شرق أفريقيا", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "WEZ": "توقيت غرب أوروبا الرسمي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "GFT": "توقيت غايانا الفرنسية", "HNCU": "توقيت كوبا الرسمي", "MST": "MST", "UYST": "توقيت أورغواي الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "HECU": "توقيت كوبا الصيفي", "IST": "توقيت الهند", "CAT": "توقيت وسط أفريقيا", "JDT": "توقيت اليابان الصيفي", "AST": "التوقيت الرسمي الأطلسي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "BT": "توقيت بوتان", "AEST": "توقيت شرق أستراليا الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "COST": "توقيت كولومبيا الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "TMST": "توقيت تركمانستان الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "HADT": "توقيت هاواي ألوتيان الصيفي", "∅∅∅": "توقيت الأمازون الصيفي", "GMT": "توقيت غرينتش", "CLST": "توقيت شيلي الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "WITA": "توقيت وسط إندونيسيا", "WIB": "توقيت غرب إندونيسيا", "AWDT": "توقيت غرب أستراليا الصيفي", "PDT": "توقيت المحيط الهادي الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "HEEG": "توقيت شرق غرينلاند الصيفي", "ChST": "توقيت تشامورو"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_LB) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_LB' +func (ar *ar_LB) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_LB' +func (ar *ar_LB) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_LB' +func (ar *ar_LB) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_LB' +func (ar *ar_LB) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_LB' +func (ar *ar_LB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_LB' +func (ar *ar_LB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_LB) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_LB) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_LB) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_LB) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_LB) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_LB) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_LB) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_LB) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_LB) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_LB) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_LB) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_LB) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_LB) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_LB) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_LB' and handles both Whole and Real numbers based on 'v' +func (ar *ar_LB) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_LB' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_LB) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 10 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_LB' +func (ar *ar_LB) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_LB' +// in accounting notation. +func (ar *ar_LB) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_LB' +func (ar *ar_LB) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_LB' +func (ar *ar_LB) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_LB' +func (ar *ar_LB) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_LB' +func (ar *ar_LB) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_LB' +func (ar *ar_LB) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_LB' +func (ar *ar_LB) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_LB' +func (ar *ar_LB) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_LB' +func (ar *ar_LB) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_LB/ar_LB_test.go b/vendor/github.com/go-playground/locales/ar_LB/ar_LB_test.go new file mode 100644 index 0000000000..694225c825 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_LB/ar_LB_test.go @@ -0,0 +1,1120 @@ +package ar_LB + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_LB" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_LY/ar_LY.go b/vendor/github.com/go-playground/locales/ar_LY/ar_LY.go new file mode 100644 index 0000000000..bf983200b7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_LY/ar_LY.go @@ -0,0 +1,698 @@ +package ar_LY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_LY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_LY' locale +func New() locales.Translator { + return &ar_LY{ + locale: "ar_LY", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: ",", + group: ".", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"", ""}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"CAT": "توقيت وسط أفريقيا", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "UYST": "توقيت أورغواي الصيفي", "∅∅∅": "توقيت أزورس الصيفي", "CLST": "توقيت شيلي الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "AEST": "توقيت شرق أستراليا الرسمي", "GYT": "توقيت غيانا", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "AKST": "التوقيت الرسمي لألاسكا", "AWST": "توقيت غرب أستراليا الرسمي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "SGT": "توقيت سنغافورة", "OESZ": "توقيت شرق أوروبا الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "AKDT": "توقيت ألاسكا الصيفي", "WIB": "توقيت غرب إندونيسيا", "HEOG": "توقيت غرب غرينلاند الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "MYT": "توقيت ماليزيا", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "BT": "توقيت بوتان", "MDT": "MDT", "CHADT": "توقيت تشاتام الصيفي", "PDT": "توقيت المحيط الهادي الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "JST": "توقيت اليابان الرسمي", "ART": "توقيت الأرجنتين الرسمي", "ACST": "توقيت وسط أستراليا الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "HNCU": "توقيت كوبا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "ChST": "توقيت تشامورو", "UYT": "توقيت أورغواي الرسمي", "HADT": "توقيت هاواي ألوتيان الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "HECU": "توقيت كوبا الصيفي", "AWDT": "توقيت غرب أستراليا الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "VET": "توقيت فنزويلا", "GMT": "توقيت غرينتش", "TMT": "توقيت تركمانستان الرسمي", "TMST": "توقيت تركمانستان الصيفي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "ARST": "توقيت الأرجنتين الصيفي", "WIT": "توقيت شرق إندونيسيا", "ECT": "توقيت الإكوادور", "WEZ": "توقيت غرب أوروبا الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "WITA": "توقيت وسط إندونيسيا", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "ADT": "التوقيت الصيفي الأطلسي", "CLT": "توقيت شيلي الرسمي", "MST": "MST", "WAST": "توقيت غرب أفريقيا الصيفي", "HEEG": "توقيت شرق غرينلاند الصيفي", "SAST": "توقيت جنوب أفريقيا", "CHAST": "توقيت تشاتام الرسمي", "NZST": "توقيت نيوزيلندا الرسمي", "MESZ": "توقيت وسط أوروبا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "WART": "توقيت غرب الأرجنتين الرسمي", "HNT": "توقيت نيوفاوندلاند الرسمي", "LHST": "توقيت لورد هاو الرسمي", "EAT": "توقيت شرق أفريقيا", "HAST": "توقيت هاواي ألوتيان الرسمي", "COST": "توقيت كولومبيا الصيفي", "GFT": "توقيت غايانا الفرنسية", "LHDT": "التوقيت الصيفي للورد هاو", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "HNEG": "توقيت شرق غرينلاند الرسمي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "BOT": "توقيت بوليفيا", "PST": "توقيت المحيط الهادي الرسمي", "IST": "توقيت الهند", "JDT": "توقيت اليابان الصيفي", "COT": "توقيت كولومبيا الرسمي", "SRT": "توقيت سورينام"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_LY) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_LY' +func (ar *ar_LY) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_LY' +func (ar *ar_LY) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_LY' +func (ar *ar_LY) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_LY' +func (ar *ar_LY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_LY' +func (ar *ar_LY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_LY' +func (ar *ar_LY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_LY) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_LY) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_LY) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_LY) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_LY) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_LY) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_LY) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_LY) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_LY) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_LY) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_LY) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_LY) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_LY) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_LY) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_LY' and handles both Whole and Real numbers based on 'v' +func (ar *ar_LY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_LY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_LY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 10 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_LY' +func (ar *ar_LY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_LY' +// in accounting notation. +func (ar *ar_LY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_LY' +func (ar *ar_LY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_LY' +func (ar *ar_LY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_LY' +func (ar *ar_LY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_LY' +func (ar *ar_LY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_LY' +func (ar *ar_LY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_LY' +func (ar *ar_LY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_LY' +func (ar *ar_LY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_LY' +func (ar *ar_LY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_LY/ar_LY_test.go b/vendor/github.com/go-playground/locales/ar_LY/ar_LY_test.go new file mode 100644 index 0000000000..b5a125d613 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_LY/ar_LY_test.go @@ -0,0 +1,1120 @@ +package ar_LY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_LY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_MA/ar_MA.go b/vendor/github.com/go-playground/locales/ar_MA/ar_MA.go new file mode 100644 index 0000000000..0e40b582e8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_MA/ar_MA.go @@ -0,0 +1,660 @@ +package ar_MA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_MA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_MA' locale +func New() locales.Translator { + return &ar_MA{ + locale: "ar_MA", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: ",", + group: ".", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "ماي", "يونيو", "يوليوز", "غشت", "شتنبر", "أكتوبر", "نونبر", "دجنبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "م", "ن", "ل", "غ", "ش", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "ماي", "يونيو", "يوليوز", "غشت", "شتنبر", "أكتوبر", "نونبر", "دجنبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"IST": "توقيت الهند", "MESZ": "توقيت وسط أوروبا الصيفي", "AKST": "التوقيت الرسمي لألاسكا", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "AWDT": "توقيت غرب أستراليا الصيفي", "JST": "توقيت اليابان الرسمي", "ART": "توقيت الأرجنتين الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "MDT": "التوقيت الجبلي الصيفي لأمريكا الشمالية", "SGT": "توقيت سنغافورة", "MEZ": "توقيت وسط أوروبا الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "OEZ": "توقيت شرق أوروبا الرسمي", "MYT": "توقيت ماليزيا", "COT": "توقيت كولومبيا الرسمي", "UYST": "توقيت أورغواي الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "EAT": "توقيت شرق أفريقيا", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "HECU": "توقيت كوبا الصيفي", "PDT": "توقيت المحيط الهادي الصيفي", "ECT": "توقيت الإكوادور", "WARST": "توقيت غرب الأرجنتين الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "MST": "التوقيت الجبلي الرسمي لأمريكا الشمالية", "ACST": "توقيت وسط أستراليا الرسمي", "BT": "توقيت بوتان", "TMST": "توقيت تركمانستان الصيفي", "WIT": "توقيت شرق إندونيسيا", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "CAT": "توقيت وسط أفريقيا", "OESZ": "توقيت شرق أوروبا الصيفي", "GMT": "توقيت غرينتش", "∅∅∅": "∅∅∅", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "GYT": "توقيت غيانا", "WESZ": "توقيت غرب أوروبا الصيفي", "GFT": "توقيت غايانا الفرنسية", "ChST": "توقيت تشامورو", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "AKDT": "توقيت ألاسكا الصيفي", "SAST": "توقيت جنوب أفريقيا", "HADT": "توقيت هاواي ألوتيان الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "UYT": "توقيت أورغواي الرسمي", "SRT": "توقيت سورينام", "WIB": "توقيت غرب إندونيسيا", "HAST": "توقيت هاواي ألوتيان الرسمي", "AST": "التوقيت الرسمي الأطلسي", "HNT": "توقيت نيوفاوندلاند الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "AWST": "توقيت غرب أستراليا الرسمي", "CHAST": "توقيت تشاتام الرسمي", "VET": "توقيت فنزويلا", "JDT": "توقيت اليابان الصيفي", "CLT": "توقيت شيلي الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "WITA": "توقيت وسط إندونيسيا", "LHDT": "التوقيت الصيفي للورد هاو", "ADT": "التوقيت الصيفي الأطلسي", "TMT": "توقيت تركمانستان الرسمي", "WEZ": "توقيت غرب أوروبا الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "COST": "توقيت كولومبيا الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "CLST": "توقيت شيلي الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "ACDT": "توقيت وسط أستراليا الصيفي", "BOT": "توقيت بوليفيا", "CHADT": "توقيت تشاتام الصيفي", "PST": "توقيت المحيط الهادي الرسمي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "LHST": "توقيت لورد هاو الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "HNCU": "توقيت كوبا الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_MA) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_MA' +func (ar *ar_MA) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_MA' +func (ar *ar_MA) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_MA' +func (ar *ar_MA) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_MA' +func (ar *ar_MA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_MA' +func (ar *ar_MA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_MA' +func (ar *ar_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_MA) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_MA) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_MA) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_MA) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_MA) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_MA) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_MA) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_MA) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_MA) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_MA) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_MA) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_MA) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_MA) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_MA) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_MA' and handles both Whole and Real numbers based on 'v' +func (ar *ar_MA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_MA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_MA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 10 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_MA' +func (ar *ar_MA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_MA' +// in accounting notation. +func (ar *ar_MA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_MA' +func (ar *ar_MA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_MA' +func (ar *ar_MA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_MA' +func (ar *ar_MA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_MA' +func (ar *ar_MA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_MA' +func (ar *ar_MA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_MA' +func (ar *ar_MA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_MA' +func (ar *ar_MA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_MA' +func (ar *ar_MA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_MA/ar_MA_test.go b/vendor/github.com/go-playground/locales/ar_MA/ar_MA_test.go new file mode 100644 index 0000000000..11c68780e1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_MA/ar_MA_test.go @@ -0,0 +1,1120 @@ +package ar_MA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_MA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_MR/ar_MR.go b/vendor/github.com/go-playground/locales/ar_MR/ar_MR.go new file mode 100644 index 0000000000..19adf6bb18 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_MR/ar_MR.go @@ -0,0 +1,698 @@ +package ar_MR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_MR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_MR' locale +func New() locales.Translator { + return &ar_MR{ + locale: "ar_MR", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: ",", + group: ".", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "إبريل", "مايو", "يونيو", "يوليو", "أغشت", "شتمبر", "أكتوبر", "نوفمبر", "دجمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "إ", "و", "ن", "ل", "غ", "ش", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "إبريل", "مايو", "يونيو", "يوليو", "أغشت", "شتمبر", "أكتوبر", "نوفمبر", "دجمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"WEZ": "توقيت غرب أوروبا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "EAT": "توقيت شرق أفريقيا", "OEZ": "توقيت شرق أوروبا الرسمي", "ART": "توقيت الأرجنتين الرسمي", "ACST": "توقيت وسط أستراليا الرسمي", "HNT": "توقيت نيوفاوندلاند الرسمي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "WIT": "توقيت شرق إندونيسيا", "IST": "توقيت الهند", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HEEG": "توقيت شرق غرينلاند الصيفي", "AKST": "التوقيت الرسمي لألاسكا", "PST": "توقيت المحيط الهادي الرسمي", "CAT": "توقيت وسط أفريقيا", "ADT": "التوقيت الصيفي الأطلسي", "OESZ": "توقيت شرق أوروبا الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "LHST": "توقيت لورد هاو الرسمي", "CHADT": "توقيت تشاتام الصيفي", "ECT": "توقيت الإكوادور", "WARST": "توقيت غرب الأرجنتين الصيفي", "MDT": "MDT", "WAT": "توقيت غرب أفريقيا الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "WITA": "توقيت وسط إندونيسيا", "ChST": "توقيت تشامورو", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "JDT": "توقيت اليابان الصيفي", "AST": "التوقيت الرسمي الأطلسي", "COT": "توقيت كولومبيا الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "GYT": "توقيت غيانا", "BOT": "توقيت بوليفيا", "VET": "توقيت فنزويلا", "ARST": "توقيت الأرجنتين الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "BT": "توقيت بوتان", "HECU": "توقيت كوبا الصيفي", "AWDT": "توقيت غرب أستراليا الصيفي", "SGT": "توقيت سنغافورة", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "CLT": "توقيت شيلي الرسمي", "TMT": "توقيت تركمانستان الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "UYT": "توقيت أورغواي الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "MST": "MST", "HNEG": "توقيت شرق غرينلاند الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "AWST": "توقيت غرب أستراليا الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "JST": "توقيت اليابان الرسمي", "CLST": "توقيت شيلي الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "AEST": "توقيت شرق أستراليا الرسمي", "HNCU": "توقيت كوبا الرسمي", "MESZ": "توقيت وسط أوروبا الصيفي", "GMT": "توقيت غرينتش", "HKST": "توقيت هونغ كونغ الصيفي", "∅∅∅": "∅∅∅", "GFT": "توقيت غايانا الفرنسية", "WIB": "توقيت غرب إندونيسيا", "NZST": "توقيت نيوزيلندا الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "SAST": "توقيت جنوب أفريقيا", "HAST": "توقيت هاواي ألوتيان الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "COST": "توقيت كولومبيا الصيفي", "UYST": "توقيت أورغواي الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CHAST": "توقيت تشاتام الرسمي", "HADT": "توقيت هاواي ألوتيان الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "MYT": "توقيت ماليزيا", "TMST": "توقيت تركمانستان الصيفي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "SRT": "توقيت سورينام"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_MR) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_MR' +func (ar *ar_MR) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_MR' +func (ar *ar_MR) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_MR' +func (ar *ar_MR) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_MR' +func (ar *ar_MR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_MR' +func (ar *ar_MR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_MR' +func (ar *ar_MR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_MR) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_MR) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_MR) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_MR) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_MR) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_MR) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_MR) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_MR) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_MR) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_MR) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_MR) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_MR) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_MR) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_MR) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_MR' and handles both Whole and Real numbers based on 'v' +func (ar *ar_MR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_MR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_MR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 10 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_MR' +func (ar *ar_MR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_MR' +// in accounting notation. +func (ar *ar_MR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_MR' +func (ar *ar_MR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_MR' +func (ar *ar_MR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_MR' +func (ar *ar_MR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_MR' +func (ar *ar_MR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_MR' +func (ar *ar_MR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_MR' +func (ar *ar_MR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_MR' +func (ar *ar_MR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_MR' +func (ar *ar_MR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_MR/ar_MR_test.go b/vendor/github.com/go-playground/locales/ar_MR/ar_MR_test.go new file mode 100644 index 0000000000..0c9143499e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_MR/ar_MR_test.go @@ -0,0 +1,1120 @@ +package ar_MR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_MR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_OM/ar_OM.go b/vendor/github.com/go-playground/locales/ar_OM/ar_OM.go new file mode 100644 index 0000000000..745e58a38a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_OM/ar_OM.go @@ -0,0 +1,712 @@ +package ar_OM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_OM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_OM' locale +func New() locales.Translator { + return &ar_OM{ + locale: "ar_OM", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "WITA": "توقيت وسط إندونيسيا", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "HNOG": "توقيت غرب غرينلاند الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "GFT": "توقيت غايانا الفرنسية", "AEDT": "توقيت شرق أستراليا الصيفي", "ECT": "توقيت الإكوادور", "CAT": "توقيت وسط أفريقيا", "OESZ": "توقيت شرق أوروبا الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "WARST": "توقيت غرب الأرجنتين الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "LHST": "توقيت لورد هاو الرسمي", "TMT": "توقيت تركمانستان الرسمي", "SGT": "توقيت سنغافورة", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "MESZ": "توقيت وسط أوروبا الصيفي", "CLT": "توقيت شيلي الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "CHAST": "توقيت تشاتام الرسمي", "GMT": "توقيت غرينتش", "MST": "التوقيت الجبلي الرسمي لأمريكا الشمالية", "AWDT": "توقيت غرب أستراليا الصيفي", "JST": "توقيت اليابان الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "JDT": "توقيت اليابان الصيفي", "ADT": "التوقيت الصيفي الأطلسي", "HAT": "توقيت نيوفاوندلاند الصيفي", "UYT": "توقيت أورغواي الرسمي", "HNCU": "توقيت كوبا الرسمي", "UYST": "توقيت أورغواي الصيفي", "SRT": "توقيت سورينام", "CHADT": "توقيت تشاتام الصيفي", "AWST": "توقيت غرب أستراليا الرسمي", "TMST": "توقيت تركمانستان الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "HADT": "توقيت هاواي ألوتيان الصيفي", "VET": "توقيت فنزويلا", "OEZ": "توقيت شرق أوروبا الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "ACST": "توقيت وسط أستراليا الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "ChST": "توقيت تشامورو", "HEOG": "توقيت غرب غرينلاند الصيفي", "AST": "التوقيت الرسمي الأطلسي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "AKST": "التوقيت الرسمي لألاسكا", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "BOT": "توقيت بوليفيا", "HAST": "توقيت هاواي ألوتيان الرسمي", "CLST": "توقيت شيلي الصيفي", "COT": "توقيت كولومبيا الرسمي", "SAST": "توقيت جنوب أفريقيا", "HECU": "توقيت كوبا الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "∅∅∅": "∅∅∅", "LHDT": "التوقيت الصيفي للورد هاو", "GYT": "توقيت غيانا", "WIT": "توقيت شرق إندونيسيا", "IST": "توقيت الهند", "ACDT": "توقيت وسط أستراليا الصيفي", "COST": "توقيت كولومبيا الصيفي", "BT": "توقيت بوتان", "MYT": "توقيت ماليزيا", "EAT": "توقيت شرق أفريقيا", "WIB": "توقيت غرب إندونيسيا", "ART": "توقيت الأرجنتين الرسمي", "MDT": "التوقيت الجبلي الصيفي لأمريكا الشمالية", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_OM) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_OM' +func (ar *ar_OM) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_OM' +func (ar *ar_OM) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_OM' +func (ar *ar_OM) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_OM' +func (ar *ar_OM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_OM' +func (ar *ar_OM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_OM' +func (ar *ar_OM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_OM) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_OM) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_OM) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_OM) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_OM) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_OM) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_OM) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_OM) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_OM) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_OM) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_OM) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_OM) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_OM) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_OM) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_OM' and handles both Whole and Real numbers based on 'v' +func (ar *ar_OM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_OM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_OM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_OM' +func (ar *ar_OM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_OM' +// in accounting notation. +func (ar *ar_OM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_OM' +func (ar *ar_OM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_OM' +func (ar *ar_OM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_OM' +func (ar *ar_OM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_OM' +func (ar *ar_OM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_OM' +func (ar *ar_OM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_OM' +func (ar *ar_OM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_OM' +func (ar *ar_OM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_OM' +func (ar *ar_OM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_OM/ar_OM_test.go b/vendor/github.com/go-playground/locales/ar_OM/ar_OM_test.go new file mode 100644 index 0000000000..33a5c8c9e0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_OM/ar_OM_test.go @@ -0,0 +1,1120 @@ +package ar_OM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_OM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_PS/ar_PS.go b/vendor/github.com/go-playground/locales/ar_PS/ar_PS.go new file mode 100644 index 0000000000..2a756847da --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_PS/ar_PS.go @@ -0,0 +1,712 @@ +package ar_PS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_PS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_PS' locale +func New() locales.Translator { + return &ar_PS{ + locale: "ar_PS", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + monthsNarrow: []string{"", "ك", "ش", "آ", "ن", "أ", "ح", "ت", "آ", "أ", "ت", "ت", "ك"}, + monthsWide: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"∅∅∅": "∅∅∅", "GYT": "توقيت غيانا", "EAT": "توقيت شرق أفريقيا", "MDT": "MDT", "ART": "توقيت الأرجنتين الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "UYST": "توقيت أورغواي الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "HECU": "توقيت كوبا الصيفي", "HAT": "توقيت نيوفاوندلاند الصيفي", "GFT": "توقيت غايانا الفرنسية", "AEDT": "توقيت شرق أستراليا الصيفي", "IST": "توقيت الهند", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "CHAST": "توقيت تشاتام الرسمي", "SRT": "توقيت سورينام", "WARST": "توقيت غرب الأرجنتين الصيفي", "WIT": "توقيت شرق إندونيسيا", "NZST": "توقيت نيوزيلندا الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "ChST": "توقيت تشامورو", "SAST": "توقيت جنوب أفريقيا", "CLT": "توقيت شيلي الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "WITA": "توقيت وسط إندونيسيا", "AKST": "التوقيت الرسمي لألاسكا", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "HAST": "توقيت هاواي ألوتيان الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "WIB": "توقيت غرب إندونيسيا", "CAT": "توقيت وسط أفريقيا", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "LHST": "توقيت لورد هاو الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "AWDT": "توقيت غرب أستراليا الصيفي", "CHADT": "توقيت تشاتام الصيفي", "VET": "توقيت فنزويلا", "TMT": "توقيت تركمانستان الرسمي", "MST": "MST", "COT": "توقيت كولومبيا الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "TMST": "توقيت تركمانستان الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "HNEG": "توقيت شرق غرينلاند الرسمي", "UYT": "توقيت أورغواي الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "AWST": "توقيت غرب أستراليا الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "ECT": "توقيت الإكوادور", "MEZ": "توقيت وسط أوروبا الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "JST": "توقيت اليابان الرسمي", "JDT": "توقيت اليابان الصيفي", "GMT": "توقيت غرينتش", "HADT": "توقيت هاواي ألوتيان الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "HNT": "توقيت نيوفاوندلاند الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "BOT": "توقيت بوليفيا", "ACST": "توقيت وسط أستراليا الرسمي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "NZDT": "توقيت نيوزيلندا الصيفي", "CLST": "توقيت شيلي الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "BT": "توقيت بوتان", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "SGT": "توقيت سنغافورة", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "PST": "توقيت المحيط الهادي الرسمي", "WEZ": "توقيت غرب أوروبا الرسمي", "MYT": "توقيت ماليزيا", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "COST": "توقيت كولومبيا الصيفي", "HNCU": "توقيت كوبا الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_PS) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_PS' +func (ar *ar_PS) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_PS' +func (ar *ar_PS) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_PS' +func (ar *ar_PS) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_PS' +func (ar *ar_PS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_PS' +func (ar *ar_PS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_PS' +func (ar *ar_PS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_PS) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_PS) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_PS) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_PS) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_PS) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_PS) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_PS) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_PS) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_PS) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_PS) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_PS) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_PS) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_PS) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_PS) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_PS' and handles both Whole and Real numbers based on 'v' +func (ar *ar_PS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_PS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_PS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_PS' +func (ar *ar_PS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_PS' +// in accounting notation. +func (ar *ar_PS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_PS' +func (ar *ar_PS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_PS' +func (ar *ar_PS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_PS' +func (ar *ar_PS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_PS' +func (ar *ar_PS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_PS' +func (ar *ar_PS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_PS' +func (ar *ar_PS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_PS' +func (ar *ar_PS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_PS' +func (ar *ar_PS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_PS/ar_PS_test.go b/vendor/github.com/go-playground/locales/ar_PS/ar_PS_test.go new file mode 100644 index 0000000000..8feba658ce --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_PS/ar_PS_test.go @@ -0,0 +1,1120 @@ +package ar_PS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_PS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_QA/ar_QA.go b/vendor/github.com/go-playground/locales/ar_QA/ar_QA.go new file mode 100644 index 0000000000..5317314a63 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_QA/ar_QA.go @@ -0,0 +1,712 @@ +package ar_QA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_QA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_QA' locale +func New() locales.Translator { + return &ar_QA{ + locale: "ar_QA", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "SGT": "توقيت سنغافورة", "WARST": "توقيت غرب الأرجنتين الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "COST": "توقيت كولومبيا الصيفي", "ChST": "توقيت تشامورو", "GMT": "توقيت غرينتش", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "BT": "توقيت بوتان", "HADT": "توقيت هاواي ألوتيان الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "WITA": "توقيت وسط إندونيسيا", "HNOG": "توقيت غرب غرينلاند الرسمي", "ACST": "توقيت وسط أستراليا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "COT": "توقيت كولومبيا الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "WIB": "توقيت غرب إندونيسيا", "CHADT": "توقيت تشاتام الصيفي", "IST": "توقيت الهند", "WART": "توقيت غرب الأرجنتين الرسمي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "AEST": "توقيت شرق أستراليا الرسمي", "SRT": "توقيت سورينام", "HAST": "توقيت هاواي ألوتيان الرسمي", "CAT": "توقيت وسط أفريقيا", "OESZ": "توقيت شرق أوروبا الصيفي", "MST": "MST", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "PDT": "توقيت المحيط الهادي الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "AKST": "التوقيت الرسمي لألاسكا", "UYT": "توقيت أورغواي الرسمي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "WIT": "توقيت شرق إندونيسيا", "CHAST": "توقيت تشاتام الرسمي", "ART": "توقيت الأرجنتين الرسمي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HNT": "توقيت نيوفاوندلاند الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "JST": "توقيت اليابان الرسمي", "MDT": "MDT", "GFT": "توقيت غايانا الفرنسية", "GYT": "توقيت غيانا", "EAT": "توقيت شرق أفريقيا", "NZST": "توقيت نيوزيلندا الرسمي", "VET": "توقيت فنزويلا", "MYT": "توقيت ماليزيا", "WEZ": "توقيت غرب أوروبا الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "UYST": "توقيت أورغواي الصيفي", "SAST": "توقيت جنوب أفريقيا", "AWDT": "توقيت غرب أستراليا الصيفي", "BOT": "توقيت بوليفيا", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "MEZ": "توقيت وسط أوروبا الرسمي", "CLT": "توقيت شيلي الرسمي", "CLST": "توقيت شيلي الصيفي", "ADT": "التوقيت الصيفي الأطلسي", "AEDT": "توقيت شرق أستراليا الصيفي", "HECU": "توقيت كوبا الصيفي", "AWST": "توقيت غرب أستراليا الرسمي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "JDT": "توقيت اليابان الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "TMT": "توقيت تركمانستان الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "HNCU": "توقيت كوبا الرسمي", "∅∅∅": "توقيت الأمازون الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "TMST": "توقيت تركمانستان الصيفي", "ACDT": "توقيت وسط أستراليا الصيفي", "HNEG": "توقيت شرق غرينلاند الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "LHST": "توقيت لورد هاو الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "ECT": "توقيت الإكوادور"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_QA) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_QA' +func (ar *ar_QA) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_QA' +func (ar *ar_QA) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_QA' +func (ar *ar_QA) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_QA' +func (ar *ar_QA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_QA' +func (ar *ar_QA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_QA' +func (ar *ar_QA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_QA) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_QA) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_QA) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_QA) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_QA) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_QA) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_QA) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_QA) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_QA) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_QA) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_QA) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_QA) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_QA) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_QA) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_QA' and handles both Whole and Real numbers based on 'v' +func (ar *ar_QA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_QA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_QA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_QA' +func (ar *ar_QA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_QA' +// in accounting notation. +func (ar *ar_QA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_QA' +func (ar *ar_QA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_QA' +func (ar *ar_QA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_QA' +func (ar *ar_QA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_QA' +func (ar *ar_QA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_QA' +func (ar *ar_QA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_QA' +func (ar *ar_QA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_QA' +func (ar *ar_QA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_QA' +func (ar *ar_QA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_QA/ar_QA_test.go b/vendor/github.com/go-playground/locales/ar_QA/ar_QA_test.go new file mode 100644 index 0000000000..78aea2aafc --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_QA/ar_QA_test.go @@ -0,0 +1,1120 @@ +package ar_QA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_QA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_SA/ar_SA.go b/vendor/github.com/go-playground/locales/ar_SA/ar_SA.go new file mode 100644 index 0000000000..699182f15a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SA/ar_SA.go @@ -0,0 +1,712 @@ +package ar_SA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_SA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_SA' locale +func New() locales.Translator { + return &ar_SA{ + locale: "ar_SA", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"", ""}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ARST": "توقيت الأرجنتين الصيفي", "SGT": "توقيت سنغافورة", "NZST": "توقيت نيوزيلندا الرسمي", "CHADT": "توقيت تشاتام الصيفي", "MYT": "توقيت ماليزيا", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "CHAST": "توقيت تشاتام الرسمي", "AST": "التوقيت الرسمي الأطلسي", "HKST": "توقيت هونغ كونغ الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "ECT": "توقيت الإكوادور", "MEZ": "توقيت وسط أوروبا الرسمي", "∅∅∅": "∅∅∅", "AKST": "التوقيت الرسمي لألاسكا", "UYT": "توقيت أورغواي الرسمي", "JDT": "توقيت اليابان الصيفي", "WART": "توقيت غرب الأرجنتين الرسمي", "CLST": "توقيت شيلي الصيفي", "ART": "توقيت الأرجنتين الرسمي", "UYST": "توقيت أورغواي الصيفي", "JST": "توقيت اليابان الرسمي", "AWDT": "توقيت غرب أستراليا الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "GMT": "توقيت غرينتش", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNCU": "توقيت كوبا الرسمي", "HECU": "توقيت كوبا الصيفي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "MESZ": "توقيت وسط أوروبا الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HAT": "توقيت نيوفاوندلاند الصيفي", "ChST": "توقيت تشامورو", "SAST": "توقيت جنوب أفريقيا", "BOT": "توقيت بوليفيا", "HNOG": "توقيت غرب غرينلاند الرسمي", "ACST": "توقيت وسط أستراليا الرسمي", "GFT": "توقيت غايانا الفرنسية", "AKDT": "توقيت ألاسكا الصيفي", "WITA": "توقيت وسط إندونيسيا", "WIT": "توقيت شرق إندونيسيا", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "MST": "MST", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "COT": "توقيت كولومبيا الرسمي", "SRT": "توقيت سورينام", "LHST": "توقيت لورد هاو الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "MDT": "MDT", "WAT": "توقيت غرب أفريقيا الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "PDT": "توقيت المحيط الهادي الصيفي", "IST": "توقيت الهند", "CLT": "توقيت شيلي الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "AEST": "توقيت شرق أستراليا الرسمي", "EAT": "توقيت شرق أفريقيا", "TMT": "توقيت تركمانستان الرسمي", "OESZ": "توقيت شرق أوروبا الصيفي", "HKT": "توقيت هونغ كونغ الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "WIB": "توقيت غرب إندونيسيا", "HNT": "توقيت نيوفاوندلاند الرسمي", "WEZ": "توقيت غرب أوروبا الرسمي", "TMST": "توقيت تركمانستان الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HEEG": "توقيت شرق غرينلاند الصيفي", "HAST": "توقيت هاواي ألوتيان الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "VET": "توقيت فنزويلا", "ADT": "التوقيت الصيفي الأطلسي", "COST": "توقيت كولومبيا الصيفي", "BT": "توقيت بوتان", "AWST": "توقيت غرب أستراليا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "GYT": "توقيت غيانا", "CAT": "توقيت وسط أفريقيا"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_SA) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_SA' +func (ar *ar_SA) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_SA' +func (ar *ar_SA) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_SA' +func (ar *ar_SA) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SA' +func (ar *ar_SA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SA' +func (ar *ar_SA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_SA' +func (ar *ar_SA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_SA) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_SA) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_SA) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_SA) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_SA) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_SA) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_SA) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_SA) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_SA) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_SA) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_SA) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_SA) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_SA) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_SA) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_SA' and handles both Whole and Real numbers based on 'v' +func (ar *ar_SA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_SA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_SA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 9 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SA' +func (ar *ar_SA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SA' +// in accounting notation. +func (ar *ar_SA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_SA' +func (ar *ar_SA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_SA' +func (ar *ar_SA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_SA' +func (ar *ar_SA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_SA' +func (ar *ar_SA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_SA' +func (ar *ar_SA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_SA' +func (ar *ar_SA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_SA' +func (ar *ar_SA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_SA' +func (ar *ar_SA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_SA/ar_SA_test.go b/vendor/github.com/go-playground/locales/ar_SA/ar_SA_test.go new file mode 100644 index 0000000000..798310e96b --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SA/ar_SA_test.go @@ -0,0 +1,1120 @@ +package ar_SA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_SA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_SD/ar_SD.go b/vendor/github.com/go-playground/locales/ar_SD/ar_SD.go new file mode 100644 index 0000000000..5bda6f4de8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SD/ar_SD.go @@ -0,0 +1,712 @@ +package ar_SD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_SD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_SD' locale +func New() locales.Translator { + return &ar_SD{ + locale: "ar_SD", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"NZST": "توقيت نيوزيلندا الرسمي", "GMT": "توقيت غرينتش", "CLT": "توقيت شيلي الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HAT": "توقيت نيوفاوندلاند الصيفي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "WIT": "توقيت شرق إندونيسيا", "AWDT": "توقيت غرب أستراليا الصيفي", "PST": "توقيت المحيط الهادي الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "UYT": "توقيت أورغواي الرسمي", "HNCU": "توقيت كوبا الرسمي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "CHAST": "توقيت تشاتام الرسمي", "∅∅∅": "توقيت الأمازون الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "MYT": "توقيت ماليزيا", "OEZ": "توقيت شرق أوروبا الرسمي", "EAT": "توقيت شرق أفريقيا", "IST": "توقيت الهند", "HNOG": "توقيت غرب غرينلاند الرسمي", "MDT": "MDT", "AKST": "التوقيت الرسمي لألاسكا", "UYST": "توقيت أورغواي الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "AKDT": "توقيت ألاسكا الصيفي", "GYT": "توقيت غيانا", "HECU": "توقيت كوبا الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "ACDT": "توقيت وسط أستراليا الصيفي", "SAST": "توقيت جنوب أفريقيا", "WART": "توقيت غرب الأرجنتين الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "JDT": "توقيت اليابان الصيفي", "TMST": "توقيت تركمانستان الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "ACST": "توقيت وسط أستراليا الرسمي", "COT": "توقيت كولومبيا الرسمي", "AEST": "توقيت شرق أستراليا الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "CLST": "توقيت شيلي الصيفي", "AST": "التوقيت الرسمي الأطلسي", "HKT": "توقيت هونغ كونغ الرسمي", "COST": "توقيت كولومبيا الصيفي", "BT": "توقيت بوتان", "WIB": "توقيت غرب إندونيسيا", "CAT": "توقيت وسط أفريقيا", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "WAT": "توقيت غرب أفريقيا الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "HEEG": "توقيت شرق غرينلاند الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "JST": "توقيت اليابان الرسمي", "MST": "MST", "HNT": "توقيت نيوفاوندلاند الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "SRT": "توقيت سورينام", "LHDT": "التوقيت الصيفي للورد هاو", "BOT": "توقيت بوليفيا", "VET": "توقيت فنزويلا", "TMT": "توقيت تركمانستان الرسمي", "ECT": "توقيت الإكوادور", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "AWST": "توقيت غرب أستراليا الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "CHADT": "توقيت تشاتام الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "ART": "توقيت الأرجنتين الرسمي", "SGT": "توقيت سنغافورة", "OESZ": "توقيت شرق أوروبا الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "GFT": "توقيت غايانا الفرنسية", "WITA": "توقيت وسط إندونيسيا", "ChST": "توقيت تشامورو", "LHST": "توقيت لورد هاو الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_SD) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_SD' +func (ar *ar_SD) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_SD' +func (ar *ar_SD) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_SD' +func (ar *ar_SD) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SD' +func (ar *ar_SD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SD' +func (ar *ar_SD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_SD' +func (ar *ar_SD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_SD) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_SD) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_SD) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_SD) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_SD) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_SD) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_SD) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_SD) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_SD) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_SD) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_SD) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_SD) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_SD) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_SD) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_SD' and handles both Whole and Real numbers based on 'v' +func (ar *ar_SD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_SD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_SD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SD' +func (ar *ar_SD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SD' +// in accounting notation. +func (ar *ar_SD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_SD' +func (ar *ar_SD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_SD' +func (ar *ar_SD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_SD' +func (ar *ar_SD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_SD' +func (ar *ar_SD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_SD' +func (ar *ar_SD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_SD' +func (ar *ar_SD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_SD' +func (ar *ar_SD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_SD' +func (ar *ar_SD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_SD/ar_SD_test.go b/vendor/github.com/go-playground/locales/ar_SD/ar_SD_test.go new file mode 100644 index 0000000000..1288f27ee0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SD/ar_SD_test.go @@ -0,0 +1,1120 @@ +package ar_SD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_SD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_SO/ar_SO.go b/vendor/github.com/go-playground/locales/ar_SO/ar_SO.go new file mode 100644 index 0000000000..56ba6735e3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SO/ar_SO.go @@ -0,0 +1,712 @@ +package ar_SO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_SO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_SO' locale +func New() locales.Translator { + return &ar_SO{ + locale: "ar_SO", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "S", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ChST": "توقيت تشامورو", "MESZ": "توقيت وسط أوروبا الصيفي", "MDT": "MDT", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "AEDT": "توقيت شرق أستراليا الصيفي", "VET": "توقيت فنزويلا", "MYT": "توقيت ماليزيا", "WITA": "توقيت وسط إندونيسيا", "SGT": "توقيت سنغافورة", "CAT": "توقيت وسط أفريقيا", "WARST": "توقيت غرب الأرجنتين الصيفي", "TMT": "توقيت تركمانستان الرسمي", "EAT": "توقيت شرق أفريقيا", "GMT": "توقيت غرينتش", "WART": "توقيت غرب الأرجنتين الرسمي", "ACST": "توقيت وسط أستراليا الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "∅∅∅": "توقيت أزورس الصيفي", "ECT": "توقيت الإكوادور", "JST": "توقيت اليابان الرسمي", "WESZ": "توقيت غرب أوروبا الصيفي", "GFT": "توقيت غايانا الفرنسية", "HNCU": "توقيت كوبا الرسمي", "AWST": "توقيت غرب أستراليا الرسمي", "AWDT": "توقيت غرب أستراليا الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "AKDT": "توقيت ألاسكا الصيفي", "WIT": "توقيت شرق إندونيسيا", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "WEZ": "توقيت غرب أوروبا الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "BOT": "توقيت بوليفيا", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HNEG": "توقيت شرق غرينلاند الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "COST": "توقيت كولومبيا الصيفي", "AKST": "التوقيت الرسمي لألاسكا", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "CHADT": "توقيت تشاتام الصيفي", "ADT": "التوقيت الصيفي الأطلسي", "TMST": "توقيت تركمانستان الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "IST": "توقيت الهند", "OEZ": "توقيت شرق أوروبا الرسمي", "HNOG": "توقيت غرب غرينلاند الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "UYST": "توقيت أورغواي الصيفي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "MEZ": "توقيت وسط أوروبا الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "HNT": "توقيت نيوفاوندلاند الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "GYT": "توقيت غيانا", "HECU": "توقيت كوبا الصيفي", "CHAST": "توقيت تشاتام الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "COT": "توقيت كولومبيا الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "MST": "MST", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HKT": "توقيت هونغ كونغ الرسمي", "LHST": "توقيت لورد هاو الرسمي", "WIB": "توقيت غرب إندونيسيا", "ART": "توقيت الأرجنتين الرسمي", "AST": "التوقيت الرسمي الأطلسي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "AEST": "توقيت شرق أستراليا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "SRT": "توقيت سورينام", "CLT": "توقيت شيلي الرسمي", "CLST": "توقيت شيلي الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "JDT": "توقيت اليابان الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "BT": "توقيت بوتان", "UYT": "توقيت أورغواي الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "SAST": "توقيت جنوب أفريقيا", "PST": "توقيت المحيط الهادي الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_SO) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_SO' +func (ar *ar_SO) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_SO' +func (ar *ar_SO) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_SO' +func (ar *ar_SO) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SO' +func (ar *ar_SO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SO' +func (ar *ar_SO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_SO' +func (ar *ar_SO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_SO) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_SO) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_SO) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_SO) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_SO) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_SO) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_SO) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_SO) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_SO) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_SO) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_SO) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_SO) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_SO) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_SO) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_SO' and handles both Whole and Real numbers based on 'v' +func (ar *ar_SO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_SO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_SO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 9 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SO' +func (ar *ar_SO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SO' +// in accounting notation. +func (ar *ar_SO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_SO' +func (ar *ar_SO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_SO' +func (ar *ar_SO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_SO' +func (ar *ar_SO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_SO' +func (ar *ar_SO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_SO' +func (ar *ar_SO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_SO' +func (ar *ar_SO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_SO' +func (ar *ar_SO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_SO' +func (ar *ar_SO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_SO/ar_SO_test.go b/vendor/github.com/go-playground/locales/ar_SO/ar_SO_test.go new file mode 100644 index 0000000000..6692fc05c8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SO/ar_SO_test.go @@ -0,0 +1,1120 @@ +package ar_SO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_SO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_SS/ar_SS.go b/vendor/github.com/go-playground/locales/ar_SS/ar_SS.go new file mode 100644 index 0000000000..b651f8b043 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SS/ar_SS.go @@ -0,0 +1,712 @@ +package ar_SS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_SS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_SS' locale +func New() locales.Translator { + return &ar_SS{ + locale: "ar_SS", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GB£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "£", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"PST": "توقيت المحيط الهادي الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "PDT": "توقيت المحيط الهادي الصيفي", "JDT": "توقيت اليابان الصيفي", "WEZ": "توقيت غرب أوروبا الرسمي", "MDT": "MDT", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HAT": "توقيت نيوفاوندلاند الصيفي", "∅∅∅": "توقيت برازيليا الصيفي", "TMST": "توقيت تركمانستان الصيفي", "GFT": "توقيت غايانا الفرنسية", "GYT": "توقيت غيانا", "HADT": "توقيت هاواي ألوتيان الصيفي", "BT": "توقيت بوتان", "HEEG": "توقيت شرق غرينلاند الصيفي", "WITA": "توقيت وسط إندونيسيا", "AKST": "التوقيت الرسمي لألاسكا", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HNT": "توقيت نيوفاوندلاند الرسمي", "ECT": "توقيت الإكوادور", "MESZ": "توقيت وسط أوروبا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "OESZ": "توقيت شرق أوروبا الصيفي", "CLST": "توقيت شيلي الصيفي", "ART": "توقيت الأرجنتين الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "SRT": "توقيت سورينام", "HNCU": "توقيت كوبا الرسمي", "HECU": "توقيت كوبا الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "CHADT": "توقيت تشاتام الصيفي", "VET": "توقيت فنزويلا", "MST": "MST", "ARST": "توقيت الأرجنتين الصيفي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "CLT": "توقيت شيلي الرسمي", "TMT": "توقيت تركمانستان الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "ChST": "توقيت تشامورو", "UYST": "توقيت أورغواي الصيفي", "NZST": "توقيت نيوزيلندا الرسمي", "HNOG": "توقيت غرب غرينلاند الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "BOT": "توقيت بوليفيا", "JST": "توقيت اليابان الرسمي", "OEZ": "توقيت شرق أوروبا الرسمي", "SAST": "توقيت جنوب أفريقيا", "MYT": "توقيت ماليزيا", "ACDT": "توقيت وسط أستراليا الصيفي", "WIB": "توقيت غرب إندونيسيا", "SGT": "توقيت سنغافورة", "IST": "توقيت الهند", "ADT": "التوقيت الصيفي الأطلسي", "WART": "توقيت غرب الأرجنتين الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "GMT": "توقيت غرينتش", "COST": "توقيت كولومبيا الصيفي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "EAT": "توقيت شرق أفريقيا", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "CHAST": "توقيت تشاتام الرسمي", "CAT": "توقيت وسط أفريقيا", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "HKT": "توقيت هونغ كونغ الرسمي", "AEST": "توقيت شرق أستراليا الرسمي", "UYT": "توقيت أورغواي الرسمي", "WIT": "توقيت شرق إندونيسيا", "HAST": "توقيت هاواي ألوتيان الرسمي", "COT": "توقيت كولومبيا الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "LHST": "توقيت لورد هاو الرسمي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "AWST": "توقيت غرب أستراليا الرسمي", "AWDT": "توقيت غرب أستراليا الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "ACST": "توقيت وسط أستراليا الرسمي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_SS) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_SS' +func (ar *ar_SS) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_SS' +func (ar *ar_SS) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_SS' +func (ar *ar_SS) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SS' +func (ar *ar_SS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SS' +func (ar *ar_SS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_SS' +func (ar *ar_SS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_SS) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_SS) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_SS) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_SS) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_SS) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_SS) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_SS) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_SS) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_SS) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_SS) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_SS) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_SS) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_SS) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_SS) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_SS' and handles both Whole and Real numbers based on 'v' +func (ar *ar_SS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_SS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_SS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SS' +func (ar *ar_SS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SS' +// in accounting notation. +func (ar *ar_SS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_SS' +func (ar *ar_SS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_SS' +func (ar *ar_SS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_SS' +func (ar *ar_SS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_SS' +func (ar *ar_SS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_SS' +func (ar *ar_SS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_SS' +func (ar *ar_SS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_SS' +func (ar *ar_SS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_SS' +func (ar *ar_SS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_SS/ar_SS_test.go b/vendor/github.com/go-playground/locales/ar_SS/ar_SS_test.go new file mode 100644 index 0000000000..3bfd45b218 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SS/ar_SS_test.go @@ -0,0 +1,1120 @@ +package ar_SS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_SS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_SY/ar_SY.go b/vendor/github.com/go-playground/locales/ar_SY/ar_SY.go new file mode 100644 index 0000000000..08d0dff98e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SY/ar_SY.go @@ -0,0 +1,712 @@ +package ar_SY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_SY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_SY' locale +func New() locales.Translator { + return &ar_SY{ + locale: "ar_SY", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + monthsNarrow: []string{"", "ك", "ش", "آ", "ن", "أ", "ح", "ت", "آ", "أ", "ت", "ت", "ك"}, + monthsWide: []string{"", "كانون الثاني", "شباط", "آذار", "نيسان", "أيار", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"BOT": "توقيت بوليفيا", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "WARST": "توقيت غرب الأرجنتين الصيفي", "GFT": "توقيت غايانا الفرنسية", "UYT": "توقيت أورغواي الرسمي", "MEZ": "توقيت وسط أوروبا الرسمي", "LHST": "توقيت لورد هاو الرسمي", "NZST": "توقيت نيوزيلندا الرسمي", "JDT": "توقيت اليابان الصيفي", "MYT": "توقيت ماليزيا", "HNT": "توقيت نيوفاوندلاند الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "EAT": "توقيت شرق أفريقيا", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "WART": "توقيت غرب الأرجنتين الرسمي", "HKST": "توقيت هونغ كونغ الصيفي", "BT": "توقيت بوتان", "CHADT": "توقيت تشاتام الصيفي", "PST": "توقيت المحيط الهادي الرسمي", "CAT": "توقيت وسط أفريقيا", "HKT": "توقيت هونغ كونغ الرسمي", "COT": "توقيت كولومبيا الرسمي", "HAT": "توقيت نيوفاوندلاند الصيفي", "SRT": "توقيت سورينام", "AWDT": "توقيت غرب أستراليا الصيفي", "TMT": "توقيت تركمانستان الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "UYST": "توقيت أورغواي الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "IST": "توقيت الهند", "OEZ": "توقيت شرق أوروبا الرسمي", "ART": "توقيت الأرجنتين الرسمي", "SGT": "توقيت سنغافورة", "WEZ": "توقيت غرب أوروبا الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "AST": "التوقيت الرسمي الأطلسي", "MDT": "MDT", "AEDT": "توقيت شرق أستراليا الصيفي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "HNCU": "توقيت كوبا الرسمي", "WIT": "توقيت شرق إندونيسيا", "AWST": "توقيت غرب أستراليا الرسمي", "JST": "توقيت اليابان الرسمي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "AEST": "توقيت شرق أستراليا الرسمي", "LHDT": "التوقيت الصيفي للورد هاو", "MESZ": "توقيت وسط أوروبا الصيفي", "WESZ": "توقيت غرب أوروبا الصيفي", "GMT": "توقيت غرينتش", "HEOG": "توقيت غرب غرينلاند الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "WITA": "توقيت وسط إندونيسيا", "MST": "MST", "AKST": "التوقيت الرسمي لألاسكا", "HECU": "توقيت كوبا الصيفي", "CHAST": "توقيت تشاتام الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "HAST": "توقيت هاواي ألوتيان الرسمي", "VET": "توقيت فنزويلا", "HNOG": "توقيت غرب غرينلاند الرسمي", "GYT": "توقيت غيانا", "ECT": "توقيت الإكوادور", "ADT": "التوقيت الصيفي الأطلسي", "WAT": "توقيت غرب أفريقيا الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "COST": "توقيت كولومبيا الصيفي", "∅∅∅": "توقيت برازيليا الصيفي", "CLST": "توقيت شيلي الصيفي", "AKDT": "توقيت ألاسكا الصيفي", "ChST": "توقيت تشامورو", "SAST": "توقيت جنوب أفريقيا", "WIB": "توقيت غرب إندونيسيا", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "CLT": "توقيت شيلي الرسمي", "TMST": "توقيت تركمانستان الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_SY) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_SY' +func (ar *ar_SY) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_SY' +func (ar *ar_SY) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_SY' +func (ar *ar_SY) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SY' +func (ar *ar_SY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_SY' +func (ar *ar_SY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_SY' +func (ar *ar_SY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_SY) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_SY) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_SY) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_SY) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_SY) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_SY) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_SY) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_SY) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_SY) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_SY) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_SY) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_SY) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_SY) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_SY) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_SY' and handles both Whole and Real numbers based on 'v' +func (ar *ar_SY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_SY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_SY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SY' +func (ar *ar_SY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_SY' +// in accounting notation. +func (ar *ar_SY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_SY' +func (ar *ar_SY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_SY' +func (ar *ar_SY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_SY' +func (ar *ar_SY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_SY' +func (ar *ar_SY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_SY' +func (ar *ar_SY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_SY' +func (ar *ar_SY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_SY' +func (ar *ar_SY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_SY' +func (ar *ar_SY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_SY/ar_SY_test.go b/vendor/github.com/go-playground/locales/ar_SY/ar_SY_test.go new file mode 100644 index 0000000000..210ce72b67 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_SY/ar_SY_test.go @@ -0,0 +1,1120 @@ +package ar_SY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_SY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_TD/ar_TD.go b/vendor/github.com/go-playground/locales/ar_TD/ar_TD.go new file mode 100644 index 0000000000..0b2de62843 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_TD/ar_TD.go @@ -0,0 +1,712 @@ +package ar_TD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_TD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_TD' locale +func New() locales.Translator { + return &ar_TD{ + locale: "ar_TD", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"AWST": "توقيت غرب أستراليا الرسمي", "CHAST": "توقيت تشاتام الرسمي", "CHADT": "توقيت تشاتام الصيفي", "WITA": "توقيت وسط إندونيسيا", "EAT": "توقيت شرق أفريقيا", "MST": "MST", "ACDT": "توقيت وسط أستراليا الصيفي", "GFT": "توقيت غايانا الفرنسية", "AKST": "التوقيت الرسمي لألاسكا", "AEST": "توقيت شرق أستراليا الرسمي", "UYT": "توقيت أورغواي الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "TMT": "توقيت تركمانستان الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "BOT": "توقيت بوليفيا", "UYST": "توقيت أورغواي الصيفي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "PDT": "توقيت المحيط الهادي الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "ART": "توقيت الأرجنتين الرسمي", "HNEG": "توقيت شرق غرينلاند الرسمي", "HAST": "توقيت هاواي ألوتيان الرسمي", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "WEZ": "توقيت غرب أوروبا الرسمي", "MDT": "MDT", "NZST": "توقيت نيوزيلندا الرسمي", "CLST": "توقيت شيلي الصيفي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "SGT": "توقيت سنغافورة", "CAT": "توقيت وسط أفريقيا", "WESZ": "توقيت غرب أوروبا الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "SRT": "توقيت سورينام", "OESZ": "توقيت شرق أوروبا الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "MYT": "توقيت ماليزيا", "ECT": "توقيت الإكوادور", "JDT": "توقيت اليابان الصيفي", "ADT": "التوقيت الصيفي الأطلسي", "COST": "توقيت كولومبيا الصيفي", "BT": "توقيت بوتان", "HNT": "توقيت نيوفاوندلاند الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "MESZ": "توقيت وسط أوروبا الصيفي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "HAT": "توقيت نيوفاوندلاند الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "HNCU": "توقيت كوبا الرسمي", "HECU": "توقيت كوبا الصيفي", "∅∅∅": "توقيت الأمازون الصيفي", "MEZ": "توقيت وسط أوروبا الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "GYT": "توقيت غيانا", "AWDT": "توقيت غرب أستراليا الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "COT": "توقيت كولومبيا الرسمي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "HKT": "توقيت هونغ كونغ الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "SAST": "توقيت جنوب أفريقيا", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "IST": "توقيت الهند", "HNOG": "توقيت غرب غرينلاند الرسمي", "ChST": "توقيت تشامورو", "LHST": "توقيت لورد هاو الرسمي", "GMT": "توقيت غرينتش", "WAT": "توقيت غرب أفريقيا الرسمي", "CLT": "توقيت شيلي الرسمي", "WIB": "توقيت غرب إندونيسيا", "JST": "توقيت اليابان الرسمي", "TMST": "توقيت تركمانستان الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "WAST": "توقيت غرب أفريقيا الصيفي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "VET": "توقيت فنزويلا", "WIT": "توقيت شرق إندونيسيا", "AKDT": "توقيت ألاسكا الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_TD) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_TD' +func (ar *ar_TD) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_TD' +func (ar *ar_TD) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_TD' +func (ar *ar_TD) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_TD' +func (ar *ar_TD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_TD' +func (ar *ar_TD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_TD' +func (ar *ar_TD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_TD) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_TD) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_TD) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_TD) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_TD) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_TD) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_TD) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_TD) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_TD) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_TD) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_TD) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_TD) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_TD) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_TD) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_TD' and handles both Whole and Real numbers based on 'v' +func (ar *ar_TD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_TD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_TD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_TD' +func (ar *ar_TD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_TD' +// in accounting notation. +func (ar *ar_TD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_TD' +func (ar *ar_TD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_TD' +func (ar *ar_TD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_TD' +func (ar *ar_TD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_TD' +func (ar *ar_TD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_TD' +func (ar *ar_TD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_TD' +func (ar *ar_TD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_TD' +func (ar *ar_TD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_TD' +func (ar *ar_TD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_TD/ar_TD_test.go b/vendor/github.com/go-playground/locales/ar_TD/ar_TD_test.go new file mode 100644 index 0000000000..8067eb0378 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_TD/ar_TD_test.go @@ -0,0 +1,1120 @@ +package ar_TD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_TD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_TN/ar_TN.go b/vendor/github.com/go-playground/locales/ar_TN/ar_TN.go new file mode 100644 index 0000000000..3290e6c9e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_TN/ar_TN.go @@ -0,0 +1,698 @@ +package ar_TN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_TN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_TN' locale +func New() locales.Translator { + return &ar_TN{ + locale: "ar_TN", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: ",", + group: ".", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "جانفي", "فيفري", "مارس", "أفريل", "ماي", "جوان", "جويلية", "أوت", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ج", "ف", "م", "أ", "م", "ج", "ج", "أ", "س", "أ", "ن", "د"}, + monthsWide: []string{"", "جانفي", "فيفري", "مارس", "أفريل", "ماي", "جوان", "جويلية", "أوت", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ACST": "توقيت وسط أستراليا الرسمي", "COT": "توقيت كولومبيا الرسمي", "SGT": "توقيت سنغافورة", "BOT": "توقيت بوليفيا", "HAST": "توقيت هاواي ألوتيان الرسمي", "CAT": "توقيت وسط أفريقيا", "WART": "توقيت غرب الأرجنتين الرسمي", "MDT": "MDT", "AKST": "التوقيت الرسمي لألاسكا", "LHST": "توقيت لورد هاو الرسمي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "EAT": "توقيت شرق أفريقيا", "HKT": "توقيت هونغ كونغ الرسمي", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "GYT": "توقيت غيانا", "ECT": "توقيت الإكوادور", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "MST": "MST", "WAST": "توقيت غرب أفريقيا الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "HEOG": "توقيت غرب غرينلاند الصيفي", "WARST": "توقيت غرب الأرجنتين الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "HNEG": "توقيت شرق غرينلاند الرسمي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "GFT": "توقيت غايانا الفرنسية", "CHAST": "توقيت تشاتام الرسمي", "PST": "توقيت المحيط الهادي الرسمي", "MEZ": "توقيت وسط أوروبا الرسمي", "GMT": "توقيت غرينتش", "CLST": "توقيت شيلي الصيفي", "ARST": "توقيت الأرجنتين الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "NZST": "توقيت نيوزيلندا الرسمي", "∅∅∅": "توقيت الأمازون الصيفي", "OESZ": "توقيت شرق أوروبا الصيفي", "TMT": "توقيت تركمانستان الرسمي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "JDT": "توقيت اليابان الصيفي", "CLT": "توقيت شيلي الرسمي", "VET": "توقيت فنزويلا", "WEZ": "توقيت غرب أوروبا الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "UYT": "توقيت أورغواي الرسمي", "WIB": "توقيت غرب إندونيسيا", "AWDT": "توقيت غرب أستراليا الصيفي", "PDT": "توقيت المحيط الهادي الصيفي", "AST": "التوقيت الرسمي الأطلسي", "OEZ": "توقيت شرق أوروبا الرسمي", "WAT": "توقيت غرب أفريقيا الرسمي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "WESZ": "توقيت غرب أوروبا الصيفي", "HAT": "توقيت نيوفاوندلاند الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "HNCU": "توقيت كوبا الرسمي", "JST": "توقيت اليابان الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "BT": "توقيت بوتان", "WITA": "توقيت وسط إندونيسيا", "SRT": "توقيت سورينام", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "AEDT": "توقيت شرق أستراليا الصيفي", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "LHDT": "التوقيت الصيفي للورد هاو", "AWST": "توقيت غرب أستراليا الرسمي", "ADT": "التوقيت الصيفي الأطلسي", "COST": "توقيت كولومبيا الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "WIT": "توقيت شرق إندونيسيا", "IST": "توقيت الهند", "HNT": "توقيت نيوفاوندلاند الرسمي", "AKDT": "توقيت ألاسكا الصيفي", "UYST": "توقيت أورغواي الصيفي", "SAST": "توقيت جنوب أفريقيا", "MYT": "توقيت ماليزيا", "ART": "توقيت الأرجنتين الرسمي", "CHADT": "توقيت تشاتام الصيفي", "NZDT": "توقيت نيوزيلندا الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "TMST": "توقيت تركمانستان الصيفي", "ChST": "توقيت تشامورو", "HECU": "توقيت كوبا الصيفي"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_TN) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_TN' +func (ar *ar_TN) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_TN' +func (ar *ar_TN) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_TN' +func (ar *ar_TN) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_TN' +func (ar *ar_TN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_TN' +func (ar *ar_TN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_TN' +func (ar *ar_TN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_TN) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_TN) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_TN) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_TN) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_TN) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_TN) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_TN) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_TN) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_TN) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_TN) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_TN) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_TN) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_TN) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_TN) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_TN' and handles both Whole and Real numbers based on 'v' +func (ar *ar_TN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_TN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_TN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 10 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_TN' +func (ar *ar_TN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_TN' +// in accounting notation. +func (ar *ar_TN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ar.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ar.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_TN' +func (ar *ar_TN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_TN' +func (ar *ar_TN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_TN' +func (ar *ar_TN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_TN' +func (ar *ar_TN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_TN' +func (ar *ar_TN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_TN' +func (ar *ar_TN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_TN' +func (ar *ar_TN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_TN' +func (ar *ar_TN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_TN/ar_TN_test.go b/vendor/github.com/go-playground/locales/ar_TN/ar_TN_test.go new file mode 100644 index 0000000000..46c221a2ca --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_TN/ar_TN_test.go @@ -0,0 +1,1120 @@ +package ar_TN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_TN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ar_YE/ar_YE.go b/vendor/github.com/go-playground/locales/ar_YE/ar_YE.go new file mode 100644 index 0000000000..4312ce4200 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_YE/ar_YE.go @@ -0,0 +1,712 @@ +package ar_YE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ar_YE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ar_YE' locale +func New() locales.Translator { + return &ar_YE{ + locale: "ar_YE", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{1, 4, 5, 6}, + decimal: "٫", + group: "٬", + minus: "؜-", + percent: "٪؜", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + monthsNarrow: []string{"", "ي", "ف", "م", "أ", "و", "ن", "ل", "غ", "س", "ك", "ب", "د"}, + monthsWide: []string{"", "يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"}, + daysAbbreviated: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysNarrow: []string{"ح", "ن", "ث", "ر", "خ", "ج", "س"}, + daysShort: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + daysWide: []string{"الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"}, + periodsAbbreviated: []string{"ص", "م"}, + periodsNarrow: []string{"ص", "م"}, + periodsWide: []string{"ص", "م"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"LHDT": "التوقيت الصيفي للورد هاو", "PST": "توقيت المحيط الهادي الرسمي", "WAST": "توقيت غرب أفريقيا الصيفي", "HNNOMX": "التوقيت الرسمي لشمال غرب المكسيك", "BT": "توقيت بوتان", "CHADT": "توقيت تشاتام الصيفي", "MESZ": "توقيت وسط أوروبا الصيفي", "AST": "التوقيت الرسمي الأطلسي", "MEZ": "توقيت وسط أوروبا الرسمي", "WART": "توقيت غرب الأرجنتين الرسمي", "ACDT": "توقيت وسط أستراليا الصيفي", "COT": "توقيت كولومبيا الرسمي", "HENOMX": "التوقيت الصيفي لشمال غرب المكسيك", "AKDT": "توقيت ألاسكا الصيفي", "HADT": "توقيت هاواي ألوتيان الصيفي", "OEZ": "توقيت شرق أوروبا الرسمي", "HECU": "توقيت كوبا الصيفي", "ECT": "توقيت الإكوادور", "WEZ": "توقيت غرب أوروبا الرسمي", "ARST": "توقيت الأرجنتين الصيفي", "AKST": "التوقيت الرسمي لألاسكا", "HNPM": "توقيت سانت بيير وميكولون الرسمي", "GYT": "توقيت غيانا", "HAST": "توقيت هاواي ألوتيان الرسمي", "IST": "توقيت الهند", "VET": "توقيت فنزويلا", "CLST": "توقيت شيلي الصيفي", "HKST": "توقيت هونغ كونغ الصيفي", "CDT": "التوقيت الصيفي المركزي لأمريكا الشمالية", "CHAST": "توقيت تشاتام الرسمي", "OESZ": "توقيت شرق أوروبا الصيفي", "HNPMX": "توقيت المحيط الهادي الرسمي للمكسيك", "PDT": "توقيت المحيط الهادي الصيفي", "MYT": "توقيت ماليزيا", "ADT": "التوقيت الصيفي الأطلسي", "MST": "MST", "ART": "توقيت الأرجنتين الرسمي", "ChST": "توقيت تشامورو", "SGT": "توقيت سنغافورة", "JDT": "توقيت اليابان الصيفي", "HNOG": "توقيت غرب غرينلاند الرسمي", "HEOG": "توقيت غرب غرينلاند الصيفي", "EDT": "التوقيت الصيفي الشرقي لأمريكا الشمالية", "SRT": "توقيت سورينام", "AWST": "توقيت غرب أستراليا الرسمي", "CAT": "توقيت وسط أفريقيا", "ACWST": "توقيت غرب وسط أستراليا الرسمي", "ACWDT": "توقيت غرب وسط أستراليا الصيفي", "AEST": "توقيت شرق أستراليا الرسمي", "UYST": "توقيت أورغواي الصيفي", "WIT": "توقيت شرق إندونيسيا", "JST": "توقيت اليابان الرسمي", "EST": "التوقيت الرسمي الشرقي لأمريكا الشمالية", "HNEG": "توقيت شرق غرينلاند الرسمي", "SAST": "توقيت جنوب أفريقيا", "BOT": "توقيت بوليفيا", "CLT": "توقيت شيلي الرسمي", "TMST": "توقيت تركمانستان الصيفي", "WAT": "توقيت غرب أفريقيا الرسمي", "HKT": "توقيت هونغ كونغ الرسمي", "WITA": "توقيت وسط إندونيسيا", "HEPM": "توقيت سانت بيير وميكولون الصيفي", "EAT": "توقيت شرق أفريقيا", "WARST": "توقيت غرب الأرجنتين الصيفي", "AEDT": "توقيت شرق أستراليا الصيفي", "MDT": "MDT", "UYT": "توقيت أورغواي الرسمي", "∅∅∅": "توقيت أزورس الصيفي", "LHST": "توقيت لورد هاو الرسمي", "NZST": "توقيت نيوزيلندا الرسمي", "NZDT": "توقيت نيوزيلندا الصيفي", "GMT": "توقيت غرينتش", "TMT": "توقيت تركمانستان الرسمي", "HEEG": "توقيت شرق غرينلاند الصيفي", "CST": "التوقيت الرسمي المركزي لأمريكا الشمالية", "AWDT": "توقيت غرب أستراليا الصيفي", "ACST": "توقيت وسط أستراليا الرسمي", "COST": "توقيت كولومبيا الصيفي", "HAT": "توقيت نيوفاوندلاند الصيفي", "HEPMX": "توقيت المحيط الهادي الصيفي للمكسيك", "HNCU": "توقيت كوبا الرسمي", "WIB": "توقيت غرب إندونيسيا", "WESZ": "توقيت غرب أوروبا الصيفي", "HNT": "توقيت نيوفاوندلاند الرسمي", "GFT": "توقيت غايانا الفرنسية"}, + } +} + +// Locale returns the current translators string locale +func (ar *ar_YE) Locale() string { + return ar.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ar_YE' +func (ar *ar_YE) PluralsCardinal() []locales.PluralRule { + return ar.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ar_YE' +func (ar *ar_YE) PluralsOrdinal() []locales.PluralRule { + return ar.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ar_YE' +func (ar *ar_YE) PluralsRange() []locales.PluralRule { + return ar.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ar_YE' +func (ar *ar_YE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if nMod100 >= 3 && nMod100 <= 10 { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 99 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ar_YE' +func (ar *ar_YE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ar_YE' +func (ar *ar_YE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ar.CardinalPluralRule(num1, v1) + end := ar.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleZero + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ar *ar_YE) MonthAbbreviated(month time.Month) string { + return ar.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ar *ar_YE) MonthsAbbreviated() []string { + return ar.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ar *ar_YE) MonthNarrow(month time.Month) string { + return ar.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ar *ar_YE) MonthsNarrow() []string { + return ar.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ar *ar_YE) MonthWide(month time.Month) string { + return ar.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ar *ar_YE) MonthsWide() []string { + return ar.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ar *ar_YE) WeekdayAbbreviated(weekday time.Weekday) string { + return ar.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ar *ar_YE) WeekdaysAbbreviated() []string { + return ar.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ar *ar_YE) WeekdayNarrow(weekday time.Weekday) string { + return ar.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ar *ar_YE) WeekdaysNarrow() []string { + return ar.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ar *ar_YE) WeekdayShort(weekday time.Weekday) string { + return ar.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ar *ar_YE) WeekdaysShort() []string { + return ar.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ar *ar_YE) WeekdayWide(weekday time.Weekday) string { + return ar.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ar *ar_YE) WeekdaysWide() []string { + return ar.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ar_YE' and handles both Whole and Real numbers based on 'v' +func (ar *ar_YE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ar_YE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ar *ar_YE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ar.percentSuffix...) + + b = append(b, ar.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ar_YE' +func (ar *ar_YE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ar.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ar_YE' +// in accounting notation. +func (ar *ar_YE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ar.currencies[currency] + l := len(s) + len(symbol) + 7 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ar.decimal) - 1; j >= 0; j-- { + b = append(b, ar.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ar.group) - 1; j >= 0; j-- { + b = append(b, ar.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ar.minus) - 1; j >= 0; j-- { + b = append(b, ar.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ar.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ar.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ar.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ar_YE' +func (ar *ar_YE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ar_YE' +func (ar *ar_YE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0xe2, 0x80, 0x8f, 0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ar_YE' +func (ar *ar_YE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ar_YE' +func (ar *ar_YE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ar.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ar.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ar_YE' +func (ar *ar_YE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ar_YE' +func (ar *ar_YE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ar_YE' +func (ar *ar_YE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ar_YE' +func (ar *ar_YE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ar.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ar.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ar.periodsAbbreviated[0]...) + } else { + b = append(b, ar.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ar.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ar_YE/ar_YE_test.go b/vendor/github.com/go-playground/locales/ar_YE/ar_YE_test.go new file mode 100644 index 0000000000..58451540d0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ar_YE/ar_YE_test.go @@ -0,0 +1,1120 @@ +package ar_YE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ar_YE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/as/as.go b/vendor/github.com/go-playground/locales/as/as.go new file mode 100644 index 0000000000..0549679219 --- /dev/null +++ b/vendor/github.com/go-playground/locales/as/as.go @@ -0,0 +1,667 @@ +package as + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type as struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'as' locale +func New() locales.Translator { + return &as{ + locale: "as", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: nil, + timeSeparator: ".", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "জানু", "ফেব্ৰু", "মাৰ্চ", "এপ্ৰিল", "মে", "জুন", "জুলাই", "আগ", "সেপ্ট", "অক্টো", "নভে", "ডিসে"}, + monthsWide: []string{"", "জানুৱাৰী", "ফেব্ৰুৱাৰী", "মাৰ্চ", "এপ্ৰিল", "মে", "জুন", "জুলাই", "আগষ্ট", "ছেপ্তেম্বৰ", "অক্টোবৰ", "নৱেম্বৰ", "ডিচেম্বৰ"}, + daysAbbreviated: []string{"ৰবি", "সোম", "মঙ্গল", "বুধ", "বৃহষ্পতি", "শুক্ৰ", "শনি"}, + daysWide: []string{"দেওবাৰ", "সোমবাৰ", "মঙ্গলবাৰ", "বুধবাৰ", "বৃহষ্পতিবাৰ", "শুক্ৰবাৰ", "শনিবাৰ"}, + periodsAbbreviated: []string{"পূৰ্বাহ্ণ", "অপৰাহ্ণ"}, + periodsWide: []string{"পূৰ্বাহ্ণ", "অপৰাহ্ণ"}, + timezones: map[string]string{"ART": "ART", "WAST": "WAST", "CAT": "CAT", "NZDT": "NZDT", "JST": "JST", "AST": "AST", "MYT": "MYT", "MDT": "MDT", "WITA": "WITA", "HECU": "HECU", "ECT": "ECT", "COT": "COT", "HEEG": "HEEG", "AKST": "AKST", "WIT": "WIT", "PST": "PST", "WARST": "WARST", "HEOG": "HEOG", "EDT": "EDT", "BT": "BT", "MST": "MST", "AEDT": "AEDT", "JDT": "JDT", "WESZ": "WESZ", "WART": "WART", "HEPMX": "HEPMX", "LHDT": "LHDT", "HNPMX": "HNPMX", "CHADT": "CHADT", "HAST": "HAST", "CLT": "CLT", "HNOG": "HNOG", "EST": "EST", "HNEG": "HNEG", "SRT": "SRT", "CHAST": "CHAST", "MEZ": "MEZ", "ACST": "ACST", "UYST": "UYST", "CST": "CST", "BOT": "BOT", "ACWDT": "ACWDT", "OESZ": "OESZ", "ChST": "ChST", "ACWST": "ACWST", "WEZ": "WEZ", "HEPM": "HEPM", "HNCU": "HNCU", "AWST": "AWST", "TMST": "TMST", "ARST": "ARST", "HNT": "HNT", "LHST": "LHST", "GYT": "GYT", "WIB": "WIB", "PDT": "PDT", "IST": "ভাৰতীয় সময়", "HNNOMX": "HNNOMX", "AKDT": "AKDT", "AEST": "AEST", "GFT": "GFT", "SAST": "SAST", "NZST": "NZST", "∅∅∅": "∅∅∅", "TMT": "TMT", "WAT": "WAT", "HAT": "HAT", "HNPM": "HNPM", "VET": "VET", "UYT": "UYT", "CDT": "CDT", "SGT": "SGT", "MESZ": "MESZ", "CLST": "CLST", "HKST": "HKST", "COST": "COST", "HENOMX": "HENOMX", "EAT": "EAT", "AWDT": "AWDT", "HADT": "HADT", "ADT": "ADT", "OEZ": "OEZ", "GMT": "GMT", "HKT": "HKT", "ACDT": "ACDT"}, + } +} + +// Locale returns the current translators string locale +func (as *as) Locale() string { + return as.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'as' +func (as *as) PluralsCardinal() []locales.PluralRule { + return as.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'as' +func (as *as) PluralsOrdinal() []locales.PluralRule { + return as.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'as' +func (as *as) PluralsRange() []locales.PluralRule { + return as.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'as' +func (as *as) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'as' +func (as *as) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'as' +func (as *as) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (as *as) MonthAbbreviated(month time.Month) string { + return as.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (as *as) MonthsAbbreviated() []string { + return as.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (as *as) MonthNarrow(month time.Month) string { + return as.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (as *as) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (as *as) MonthWide(month time.Month) string { + return as.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (as *as) MonthsWide() []string { + return as.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (as *as) WeekdayAbbreviated(weekday time.Weekday) string { + return as.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (as *as) WeekdaysAbbreviated() []string { + return as.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (as *as) WeekdayNarrow(weekday time.Weekday) string { + return as.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (as *as) WeekdaysNarrow() []string { + return as.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (as *as) WeekdayShort(weekday time.Weekday) string { + return as.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (as *as) WeekdaysShort() []string { + return as.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (as *as) WeekdayWide(weekday time.Weekday) string { + return as.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (as *as) WeekdaysWide() []string { + return as.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'as' and handles both Whole and Real numbers based on 'v' +func (as *as) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, as.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, as.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, as.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'as' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (as *as) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, as.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, as.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, as.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'as' +func (as *as) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := as.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, as.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, as.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(as.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, as.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, as.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, as.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'as' +// in accounting notation. +func (as *as) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := as.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, as.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, as.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(as.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, as.currencyNegativePrefix[j]) + } + + b = append(b, as.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(as.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, as.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, as.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'as' +func (as *as) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'as' +func (as *as) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'as' +func (as *as) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, as.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'as' +func (as *as) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, as.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, as.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'as' +func (as *as) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Hour() < 12 { + b = append(b, as.periodsAbbreviated[0]...) + } else { + b = append(b, as.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'as' +func (as *as) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, as.periodsAbbreviated[0]...) + } else { + b = append(b, as.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'as' +func (as *as) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, as.periodsAbbreviated[0]...) + } else { + b = append(b, as.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'as' +func (as *as) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, as.periodsAbbreviated[0]...) + } else { + b = append(b, as.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := as.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/as/as_test.go b/vendor/github.com/go-playground/locales/as/as_test.go new file mode 100644 index 0000000000..26c1d0b065 --- /dev/null +++ b/vendor/github.com/go-playground/locales/as/as_test.go @@ -0,0 +1,1120 @@ +package as + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "as" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/as_IN/as_IN.go b/vendor/github.com/go-playground/locales/as_IN/as_IN.go new file mode 100644 index 0000000000..2a1acc66aa --- /dev/null +++ b/vendor/github.com/go-playground/locales/as_IN/as_IN.go @@ -0,0 +1,667 @@ +package as_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type as_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'as_IN' locale +func New() locales.Translator { + return &as_IN{ + locale: "as_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: nil, + timeSeparator: ".", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "জানু", "ফেব্ৰু", "মাৰ্চ", "এপ্ৰিল", "মে", "জুন", "জুলাই", "আগ", "সেপ্ট", "অক্টো", "নভে", "ডিসে"}, + monthsWide: []string{"", "জানুৱাৰী", "ফেব্ৰুৱাৰী", "মাৰ্চ", "এপ্ৰিল", "মে", "জুন", "জুলাই", "আগষ্ট", "ছেপ্তেম্বৰ", "অক্টোবৰ", "নৱেম্বৰ", "ডিচেম্বৰ"}, + daysAbbreviated: []string{"ৰবি", "সোম", "মঙ্গল", "বুধ", "বৃহষ্পতি", "শুক্ৰ", "শনি"}, + daysWide: []string{"দেওবাৰ", "সোমবাৰ", "মঙ্গলবাৰ", "বুধবাৰ", "বৃহষ্পতিবাৰ", "শুক্ৰবাৰ", "শনিবাৰ"}, + periodsAbbreviated: []string{"পূৰ্বাহ্ণ", "অপৰাহ্ণ"}, + periodsWide: []string{"পূৰ্বাহ্ণ", "অপৰাহ্ণ"}, + timezones: map[string]string{"HNEG": "HNEG", "AWDT": "AWDT", "CAT": "CAT", "NZDT": "NZDT", "VET": "VET", "COT": "COT", "HNNOMX": "HNNOMX", "LHST": "LHST", "LHDT": "LHDT", "WARST": "WARST", "TMT": "TMT", "HECU": "HECU", "CLST": "CLST", "EST": "EST", "HKST": "HKST", "EAT": "EAT", "HNCU": "HNCU", "AEST": "AEST", "AEDT": "AEDT", "HNPM": "HNPM", "SRT": "SRT", "JST": "JST", "OEZ": "OEZ", "TMST": "TMST", "GFT": "GFT", "MESZ": "MESZ", "ART": "ART", "HKT": "HKT", "HENOMX": "HENOMX", "AKDT": "AKDT", "CST": "CST", "SGT": "SGT", "PST": "PST", "PDT": "PDT", "OESZ": "OESZ", "HNOG": "HNOG", "WAT": "WAT", "ChST": "ChST", "HNPMX": "HNPMX", "WESZ": "WESZ", "GMT": "GMT", "WART": "WART", "EDT": "EDT", "HEEG": "HEEG", "AKST": "AKST", "ECT": "ECT", "ADT": "ADT", "BT": "BT", "WIB": "WIB", "WIT": "WIT", "MEZ": "MEZ", "MYT": "MYT", "ACDT": "ACDT", "UYT": "UYT", "UYST": "UYST", "CDT": "CDT", "CHAST": "CHAST", "CHADT": "CHADT", "NZST": "NZST", "WITA": "WITA", "HEPM": "HEPM", "CLT": "CLT", "ARST": "ARST", "WAST": "WAST", "GYT": "GYT", "ACWST": "ACWST", "ACWDT": "ACWDT", "MDT": "MDT", "ACST": "ACST", "HAT": "HAT", "HEPMX": "HEPMX", "HAST": "HAST", "IST": "ভাৰতীয় সময়", "AST": "AST", "WEZ": "WEZ", "HEOG": "HEOG", "MST": "MST", "COST": "COST", "SAST": "SAST", "∅∅∅": "∅∅∅", "JDT": "JDT", "HNT": "HNT", "AWST": "AWST", "BOT": "BOT", "HADT": "HADT"}, + } +} + +// Locale returns the current translators string locale +func (as *as_IN) Locale() string { + return as.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'as_IN' +func (as *as_IN) PluralsCardinal() []locales.PluralRule { + return as.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'as_IN' +func (as *as_IN) PluralsOrdinal() []locales.PluralRule { + return as.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'as_IN' +func (as *as_IN) PluralsRange() []locales.PluralRule { + return as.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'as_IN' +func (as *as_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'as_IN' +func (as *as_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'as_IN' +func (as *as_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (as *as_IN) MonthAbbreviated(month time.Month) string { + return as.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (as *as_IN) MonthsAbbreviated() []string { + return as.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (as *as_IN) MonthNarrow(month time.Month) string { + return as.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (as *as_IN) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (as *as_IN) MonthWide(month time.Month) string { + return as.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (as *as_IN) MonthsWide() []string { + return as.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (as *as_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return as.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (as *as_IN) WeekdaysAbbreviated() []string { + return as.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (as *as_IN) WeekdayNarrow(weekday time.Weekday) string { + return as.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (as *as_IN) WeekdaysNarrow() []string { + return as.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (as *as_IN) WeekdayShort(weekday time.Weekday) string { + return as.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (as *as_IN) WeekdaysShort() []string { + return as.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (as *as_IN) WeekdayWide(weekday time.Weekday) string { + return as.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (as *as_IN) WeekdaysWide() []string { + return as.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'as_IN' and handles both Whole and Real numbers based on 'v' +func (as *as_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, as.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, as.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, as.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'as_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (as *as_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, as.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, as.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, as.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'as_IN' +func (as *as_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := as.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, as.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, as.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(as.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, as.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, as.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, as.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'as_IN' +// in accounting notation. +func (as *as_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := as.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, as.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, as.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(as.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, as.currencyNegativePrefix[j]) + } + + b = append(b, as.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(as.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, as.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, as.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'as_IN' +func (as *as_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'as_IN' +func (as *as_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'as_IN' +func (as *as_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, as.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'as_IN' +func (as *as_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, as.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, as.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'as_IN' +func (as *as_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Hour() < 12 { + b = append(b, as.periodsAbbreviated[0]...) + } else { + b = append(b, as.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'as_IN' +func (as *as_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, as.periodsAbbreviated[0]...) + } else { + b = append(b, as.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'as_IN' +func (as *as_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, as.periodsAbbreviated[0]...) + } else { + b = append(b, as.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'as_IN' +func (as *as_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, as.periodsAbbreviated[0]...) + } else { + b = append(b, as.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := as.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/as_IN/as_IN_test.go b/vendor/github.com/go-playground/locales/as_IN/as_IN_test.go new file mode 100644 index 0000000000..bf0b3978c1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/as_IN/as_IN_test.go @@ -0,0 +1,1120 @@ +package as_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "as_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/asa/asa.go b/vendor/github.com/go-playground/locales/asa/asa.go new file mode 100644 index 0000000000..0bb1c8ddd5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/asa/asa.go @@ -0,0 +1,520 @@ +package asa + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type asa struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'asa' locale +func New() locales.Translator { + return &asa{ + locale: "asa", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Ijm", "Jmo"}, + daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"icheheavo", "ichamthi"}, + periodsWide: []string{"icheheavo", "ichamthi"}, + erasAbbreviated: []string{"KM", "BM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla yakwe Yethu", "Baada yakwe Yethu"}, + timezones: map[string]string{"HEPM": "HEPM", "HEPMX": "HEPMX", "WIB": "WIB", "MST": "MST", "ACDT": "ACDT", "HEEG": "HEEG", "BT": "BT", "SAST": "SAST", "VET": "VET", "GMT": "GMT", "HNPMX": "HNPMX", "LHDT": "LHDT", "WIT": "WIT", "BOT": "BOT", "PST": "PST", "WARST": "WARST", "HENOMX": "HENOMX", "AEST": "AEST", "HECU": "HECU", "CDT": "CDT", "IST": "IST", "MEZ": "MEZ", "EDT": "EDT", "HNT": "HNT", "UYST": "UYST", "EAT": "EAT", "HAST": "HAST", "ART": "ART", "WART": "WART", "CLST": "CLST", "ADT": "ADT", "HKT": "HKT", "WAST": "WAST", "NZST": "NZST", "∅∅∅": "∅∅∅", "CHAST": "CHAST", "SGT": "SGT", "ACST": "ACST", "AEDT": "AEDT", "HKST": "HKST", "COT": "COT", "HAT": "HAT", "SRT": "SRT", "AWDT": "AWDT", "WESZ": "WESZ", "AST": "AST", "MESZ": "MESZ", "CLT": "CLT", "OESZ": "OESZ", "AKST": "AKST", "HNPM": "HNPM", "ECT": "ECT", "CAT": "CAT", "HEOG": "HEOG", "OEZ": "OEZ", "HNNOMX": "HNNOMX", "LHST": "LHST", "GYT": "GYT", "CHADT": "CHADT", "NZDT": "NZDT", "JST": "JST", "TMST": "TMST", "WEZ": "WEZ", "HNOG": "HNOG", "MDT": "MDT", "ARST": "ARST", "EST": "EST", "AKDT": "AKDT", "ChST": "ChST", "UYT": "UYT", "PDT": "PDT", "TMT": "TMT", "MYT": "MYT", "HNEG": "HNEG", "WAT": "WAT", "HADT": "HADT", "ACWST": "ACWST", "CST": "CST", "AWST": "AWST", "WITA": "WITA", "HNCU": "HNCU", "COST": "COST", "GFT": "GFT", "ACWDT": "ACWDT", "JDT": "JDT"}, + } +} + +// Locale returns the current translators string locale +func (asa *asa) Locale() string { + return asa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'asa' +func (asa *asa) PluralsCardinal() []locales.PluralRule { + return asa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'asa' +func (asa *asa) PluralsOrdinal() []locales.PluralRule { + return asa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'asa' +func (asa *asa) PluralsRange() []locales.PluralRule { + return asa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'asa' +func (asa *asa) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'asa' +func (asa *asa) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'asa' +func (asa *asa) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (asa *asa) MonthAbbreviated(month time.Month) string { + return asa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (asa *asa) MonthsAbbreviated() []string { + return asa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (asa *asa) MonthNarrow(month time.Month) string { + return asa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (asa *asa) MonthsNarrow() []string { + return asa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (asa *asa) MonthWide(month time.Month) string { + return asa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (asa *asa) MonthsWide() []string { + return asa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (asa *asa) WeekdayAbbreviated(weekday time.Weekday) string { + return asa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (asa *asa) WeekdaysAbbreviated() []string { + return asa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (asa *asa) WeekdayNarrow(weekday time.Weekday) string { + return asa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (asa *asa) WeekdaysNarrow() []string { + return asa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (asa *asa) WeekdayShort(weekday time.Weekday) string { + return asa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (asa *asa) WeekdaysShort() []string { + return asa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (asa *asa) WeekdayWide(weekday time.Weekday) string { + return asa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (asa *asa) WeekdaysWide() []string { + return asa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'asa' and handles both Whole and Real numbers based on 'v' +func (asa *asa) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'asa' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (asa *asa) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'asa' +func (asa *asa) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := asa.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, asa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, asa.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, asa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, asa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, asa.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'asa' +// in accounting notation. +func (asa *asa) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := asa.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, asa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, asa.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, asa.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, asa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, asa.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, asa.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'asa' +func (asa *asa) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'asa' +func (asa *asa) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, asa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'asa' +func (asa *asa) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, asa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'asa' +func (asa *asa) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, asa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, asa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'asa' +func (asa *asa) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, asa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'asa' +func (asa *asa) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, asa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, asa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'asa' +func (asa *asa) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, asa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, asa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'asa' +func (asa *asa) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, asa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, asa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := asa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/asa/asa_test.go b/vendor/github.com/go-playground/locales/asa/asa_test.go new file mode 100644 index 0000000000..80143c0b70 --- /dev/null +++ b/vendor/github.com/go-playground/locales/asa/asa_test.go @@ -0,0 +1,1120 @@ +package asa + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "asa" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/asa_TZ/asa_TZ.go b/vendor/github.com/go-playground/locales/asa_TZ/asa_TZ.go new file mode 100644 index 0000000000..835c06c08c --- /dev/null +++ b/vendor/github.com/go-playground/locales/asa_TZ/asa_TZ.go @@ -0,0 +1,520 @@ +package asa_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type asa_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'asa_TZ' locale +func New() locales.Translator { + return &asa_TZ{ + locale: "asa_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Ijm", "Jmo"}, + daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"icheheavo", "ichamthi"}, + periodsWide: []string{"icheheavo", "ichamthi"}, + erasAbbreviated: []string{"KM", "BM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla yakwe Yethu", "Baada yakwe Yethu"}, + timezones: map[string]string{"AEST": "AEST", "CST": "CST", "AWST": "AWST", "IST": "IST", "WESZ": "WESZ", "MDT": "MDT", "HKT": "HKT", "HAT": "HAT", "HEEG": "HEEG", "HEPMX": "HEPMX", "WART": "WART", "TMT": "TMT", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "HEPM": "HEPM", "HECU": "HECU", "CLST": "CLST", "HEOG": "HEOG", "AEDT": "AEDT", "UYST": "UYST", "HADT": "HADT", "MST": "MST", "HNNOMX": "HNNOMX", "AKST": "AKST", "ACWDT": "ACWDT", "EST": "EST", "GFT": "GFT", "SGT": "SGT", "HNOG": "HNOG", "BOT": "BOT", "ECT": "ECT", "NZST": "NZST", "ACWST": "ACWST", "VET": "VET", "OEZ": "OEZ", "GYT": "GYT", "ART": "ART", "WAT": "WAT", "EDT": "EDT", "HKST": "HKST", "ACDT": "ACDT", "LHST": "LHST", "HNPMX": "HNPMX", "AWDT": "AWDT", "HNT": "HNT", "WIB": "WIB", "PDT": "PDT", "WAST": "WAST", "BT": "BT", "CDT": "CDT", "WIT": "WIT", "MEZ": "MEZ", "JDT": "JDT", "COT": "COT", "HNEG": "HNEG", "ChST": "ChST", "SAST": "SAST", "SRT": "SRT", "EAT": "EAT", "PST": "PST", "UYT": "UYT", "CHAST": "CHAST", "CHADT": "CHADT", "HAST": "HAST", "NZDT": "NZDT", "ADT": "ADT", "ACST": "ACST", "HNPM": "HNPM", "CAT": "CAT", "JST": "JST", "WARST": "WARST", "CLT": "CLT", "GMT": "GMT", "WEZ": "WEZ", "ARST": "ARST", "WITA": "WITA", "AKDT": "AKDT", "LHDT": "LHDT", "MESZ": "MESZ", "MYT": "MYT", "OESZ": "OESZ", "TMST": "TMST", "COST": "COST", "HNCU": "HNCU", "AST": "AST"}, + } +} + +// Locale returns the current translators string locale +func (asa *asa_TZ) Locale() string { + return asa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'asa_TZ' +func (asa *asa_TZ) PluralsCardinal() []locales.PluralRule { + return asa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'asa_TZ' +func (asa *asa_TZ) PluralsOrdinal() []locales.PluralRule { + return asa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'asa_TZ' +func (asa *asa_TZ) PluralsRange() []locales.PluralRule { + return asa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'asa_TZ' +func (asa *asa_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'asa_TZ' +func (asa *asa_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'asa_TZ' +func (asa *asa_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (asa *asa_TZ) MonthAbbreviated(month time.Month) string { + return asa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (asa *asa_TZ) MonthsAbbreviated() []string { + return asa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (asa *asa_TZ) MonthNarrow(month time.Month) string { + return asa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (asa *asa_TZ) MonthsNarrow() []string { + return asa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (asa *asa_TZ) MonthWide(month time.Month) string { + return asa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (asa *asa_TZ) MonthsWide() []string { + return asa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (asa *asa_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return asa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (asa *asa_TZ) WeekdaysAbbreviated() []string { + return asa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (asa *asa_TZ) WeekdayNarrow(weekday time.Weekday) string { + return asa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (asa *asa_TZ) WeekdaysNarrow() []string { + return asa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (asa *asa_TZ) WeekdayShort(weekday time.Weekday) string { + return asa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (asa *asa_TZ) WeekdaysShort() []string { + return asa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (asa *asa_TZ) WeekdayWide(weekday time.Weekday) string { + return asa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (asa *asa_TZ) WeekdaysWide() []string { + return asa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'asa_TZ' and handles both Whole and Real numbers based on 'v' +func (asa *asa_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'asa_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (asa *asa_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'asa_TZ' +func (asa *asa_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := asa.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, asa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, asa.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, asa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, asa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, asa.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'asa_TZ' +// in accounting notation. +func (asa *asa_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := asa.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, asa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, asa.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, asa.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, asa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, asa.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, asa.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'asa_TZ' +func (asa *asa_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'asa_TZ' +func (asa *asa_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, asa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'asa_TZ' +func (asa *asa_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, asa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'asa_TZ' +func (asa *asa_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, asa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, asa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'asa_TZ' +func (asa *asa_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, asa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'asa_TZ' +func (asa *asa_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, asa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, asa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'asa_TZ' +func (asa *asa_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, asa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, asa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'asa_TZ' +func (asa *asa_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, asa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, asa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := asa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/asa_TZ/asa_TZ_test.go b/vendor/github.com/go-playground/locales/asa_TZ/asa_TZ_test.go new file mode 100644 index 0000000000..51ec9e4d9a --- /dev/null +++ b/vendor/github.com/go-playground/locales/asa_TZ/asa_TZ_test.go @@ -0,0 +1,1120 @@ +package asa_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "asa_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ast/ast.go b/vendor/github.com/go-playground/locales/ast/ast.go new file mode 100644 index 0000000000..722f28b366 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ast/ast.go @@ -0,0 +1,581 @@ +package ast + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ast struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ast' locale +func New() locales.Translator { + return &ast{ + locale: "ast", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "xin", "feb", "mar", "abr", "may", "xun", "xnt", "ago", "set", "och", "pay", "avi"}, + monthsNarrow: []string{"", "X", "F", "M", "A", "M", "X", "X", "A", "S", "O", "P", "A"}, + monthsWide: []string{"", "de xineru", "de febreru", "de marzu", "d’abril", "de mayu", "de xunu", "de xunetu", "d’agostu", "de setiembre", "d’ochobre", "de payares", "d’avientu"}, + daysAbbreviated: []string{"dom", "llu", "mar", "mié", "xue", "vie", "sáb"}, + daysNarrow: []string{"D", "L", "M", "M", "X", "V", "S"}, + daysShort: []string{"do", "ll", "ma", "mi", "xu", "vi", "sá"}, + daysWide: []string{"domingu", "llunes", "martes", "miércoles", "xueves", "vienres", "sábadu"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"de la mañana", "de la tarde"}, + erasAbbreviated: []string{"e.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"enantes de Cristu", "después de Cristu"}, + timezones: map[string]string{"HAT": "Hora braniega de Newfoundland", "ART": "Hora estándar d’Arxentina", "COST": "Hora braniega de Colombia", "HNT": "Hora estándar de Newfoundland", "CHADT": "Hora braniega de Chatham", "PDT": "Hora braniega del Pacíficu norteamericanu", "HEOG": "Hora braniega de Groenlandia occidental", "HEPMX": "Hora braniega del Pacíficu de Méxicu", "ACWDT": "Hora braniega d’Australia central del oeste", "HNOG": "Hora estándar de Groenlandia occidental", "HNNOMX": "Hora estándar del noroeste de Méxicu", "BOT": "Hora de Bolivia", "AST": "Hora estándar del Atlánticu", "MDT": "Hora braniega de Macáu", "CAT": "Hora d’África central", "WARST": "Hora braniega occidental d’Arxentina", "EST": "Hora estándar del este norteamericanu", "UYST": "Hora braniega del Uruguái", "HNCU": "Hora estándar de Cuba", "SGT": "Hora estándar de Singapur", "NZDT": "Hora braniega de Nueva Zelanda", "MESZ": "Hora braniega d’Europa Central", "OESZ": "Hora braniega d’Europa del Este", "GMT": "Hora media de Greenwich", "HEPM": "Hora braniega de Saint Pierre y Miquelon", "GYT": "Hora de La Guyana", "JDT": "Hora braniega de Xapón", "MEZ": "Hora estándar d’Europa Central", "WEZ": "Hora estándar d’Europa Occidental", "TMST": "Hora braniega del Turkmenistán", "MST": "Hora estándar de Macáu", "HNEG": "Hora estándar de Groenlandia oriental", "AEST": "Hora estándar d’Australia del este", "HNPMX": "Hora estándar del Pacíficu de Méxicu", "WIT": "Hora d’Indonesia del este", "AWDT": "Hora braniega d’Australia del oeste", "UYT": "Hora estándar del Uruguái", "HNPM": "Hora estándar de Saint Pierre y Miquelon", "IST": "Hora estándar de la India", "JST": "Hora estándar de Xapón", "WART": "Hora estándar occidental d’Arxentina", "CLST": "Hora braniega de Chile", "HKT": "Hora estándar de Ḥong Kong", "EAT": "Hora d’África del este", "PST": "Hora estándar del Pacíficu norteamericanu", "HADT": "Hora braniega de Hawaii-Aleutianes", "ChST": "Hora estándar de Chamorro", "LHDT": "Hora braniega de Lord Howe", "CDT": "Hora braniega central norteamericana", "VET": "Hora de Venezuela", "HENOMX": "Hora braniega del noroeste de Méxicu", "GFT": "Hora de La Guyana Francesa", "WITA": "Hora d’Indonesia central", "CST": "Hora estándar central norteamericana", "NZST": "Hora estándar de Nueva Zelanda", "ARST": "Hora braniega d’Arxentina", "COT": "Hora estándar de Colombia", "CHAST": "Hora estándar de Chatham", "ECT": "Hora d’Ecuador", "EDT": "Hora braniega del este norteamericanu", "MYT": "Hora de Malasia", "ADT": "Hora braniega del Atlánticu", "HKST": "Hora braniega de Ḥong Kong", "AEDT": "Hora braniega d’Australia del este", "SRT": "Hora del Surinam", "HAST": "Hora estándar de Hawaii-Aleutianes", "WESZ": "Hora braniega d’Europa Occidental", "BT": "Hora de Bután", "ACST": "Hora estándar d’Australia central", "ACDT": "Hora braniega d’Australia central", "HEEG": "Hora braniega de Groenlandia oriental", "OEZ": "Hora estándar d’Europa del Este", "WAT": "Hora estándar d’África del oeste", "∅∅∅": "Hora braniega de Les Azores", "WIB": "Hora d’Indonesia del oeste", "AWST": "Hora estándar d’Australia del oeste", "CLT": "Hora estándar de Chile", "WAST": "Hora braniega d’África del oeste", "AKDT": "Hora braniega d’Alaska", "SAST": "Hora de Sudáfrica", "HECU": "Hora braniega de Cuba", "ACWST": "Hora estándar d’Australia central del oeste", "LHST": "Hora estándar de Lord Howe", "TMT": "Hora estándar del Turkmenistán", "AKST": "Hora estándar d’Alaska"}, + } +} + +// Locale returns the current translators string locale +func (ast *ast) Locale() string { + return ast.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ast' +func (ast *ast) PluralsCardinal() []locales.PluralRule { + return ast.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ast' +func (ast *ast) PluralsOrdinal() []locales.PluralRule { + return ast.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ast' +func (ast *ast) PluralsRange() []locales.PluralRule { + return ast.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ast' +func (ast *ast) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ast' +func (ast *ast) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ast' +func (ast *ast) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ast *ast) MonthAbbreviated(month time.Month) string { + return ast.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ast *ast) MonthsAbbreviated() []string { + return ast.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ast *ast) MonthNarrow(month time.Month) string { + return ast.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ast *ast) MonthsNarrow() []string { + return ast.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ast *ast) MonthWide(month time.Month) string { + return ast.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ast *ast) MonthsWide() []string { + return ast.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ast *ast) WeekdayAbbreviated(weekday time.Weekday) string { + return ast.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ast *ast) WeekdaysAbbreviated() []string { + return ast.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ast *ast) WeekdayNarrow(weekday time.Weekday) string { + return ast.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ast *ast) WeekdaysNarrow() []string { + return ast.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ast *ast) WeekdayShort(weekday time.Weekday) string { + return ast.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ast *ast) WeekdaysShort() []string { + return ast.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ast *ast) WeekdayWide(weekday time.Weekday) string { + return ast.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ast *ast) WeekdaysWide() []string { + return ast.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ast' and handles both Whole and Real numbers based on 'v' +func (ast *ast) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ast.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ast.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ast.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ast' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ast *ast) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ast.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ast.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ast.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ast' +func (ast *ast) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ast.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ast.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ast.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ast.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ast.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ast.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ast' +// in accounting notation. +func (ast *ast) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ast.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ast.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ast.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ast.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ast.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ast.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ast.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ast' +func (ast *ast) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ast' +func (ast *ast) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ast.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ast' +func (ast *ast) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ast.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ast' +func (ast *ast) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ast.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ast.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ast' +func (ast *ast) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ast.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ast' +func (ast *ast) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ast.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ast.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ast' +func (ast *ast) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ast.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ast.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ast' +func (ast *ast) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ast.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ast.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ast.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ast/ast_test.go b/vendor/github.com/go-playground/locales/ast/ast_test.go new file mode 100644 index 0000000000..68adb2c706 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ast/ast_test.go @@ -0,0 +1,1120 @@ +package ast + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ast" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ast_ES/ast_ES.go b/vendor/github.com/go-playground/locales/ast_ES/ast_ES.go new file mode 100644 index 0000000000..386126fab6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ast_ES/ast_ES.go @@ -0,0 +1,581 @@ +package ast_ES + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ast_ES struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ast_ES' locale +func New() locales.Translator { + return &ast_ES{ + locale: "ast_ES", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "xin", "feb", "mar", "abr", "may", "xun", "xnt", "ago", "set", "och", "pay", "avi"}, + monthsNarrow: []string{"", "X", "F", "M", "A", "M", "X", "X", "A", "S", "O", "P", "A"}, + monthsWide: []string{"", "de xineru", "de febreru", "de marzu", "d’abril", "de mayu", "de xunu", "de xunetu", "d’agostu", "de setiembre", "d’ochobre", "de payares", "d’avientu"}, + daysAbbreviated: []string{"dom", "llu", "mar", "mié", "xue", "vie", "sáb"}, + daysNarrow: []string{"D", "L", "M", "M", "X", "V", "S"}, + daysShort: []string{"do", "ll", "ma", "mi", "xu", "vi", "sá"}, + daysWide: []string{"domingu", "llunes", "martes", "miércoles", "xueves", "vienres", "sábadu"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"de la mañana", "de la tarde"}, + erasAbbreviated: []string{"e.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"enantes de Cristu", "después de Cristu"}, + timezones: map[string]string{"AKDT": "Hora braniega d’Alaska", "HEPM": "Hora braniega de Saint Pierre y Miquelon", "SRT": "Hora del Surinam", "WIT": "Hora d’Indonesia del este", "CHADT": "Hora braniega de Chatham", "PST": "Hora estándar del Pacíficu norteamericanu", "WITA": "Hora d’Indonesia central", "AKST": "Hora estándar d’Alaska", "AEST": "Hora estándar d’Australia del este", "HNPM": "Hora estándar de Saint Pierre y Miquelon", "SGT": "Hora estándar de Singapur", "NZST": "Hora estándar de Nueva Zelanda", "ART": "Hora estándar d’Arxentina", "MDT": "Hora braniega de les montañes norteamericanes", "LHST": "Hora estándar de Lord Howe", "∅∅∅": "Hora braniega de Les Azores", "CHAST": "Hora estándar de Chatham", "CAT": "Hora d’África central", "JDT": "Hora braniega de Xapón", "WEZ": "Hora estándar d’Europa Occidental", "GYT": "Hora de La Guyana", "CDT": "Hora braniega central norteamericana", "AWDT": "Hora braniega d’Australia del oeste", "ECT": "Hora d’Ecuador", "MYT": "Hora de Malasia", "EST": "Hora estándar del este norteamericanu", "HNT": "Hora estándar de Newfoundland", "NZDT": "Hora braniega de Nueva Zelanda", "HNOG": "Hora estándar de Groenlandia occidental", "CLT": "Hora estándar de Chile", "HKST": "Hora braniega de Ḥong Kong", "HADT": "Hora braniega de Hawaii-Aleutianes", "GMT": "Hora media de Greenwich", "WARST": "Hora braniega occidental d’Arxentina", "BT": "Hora de Bután", "AEDT": "Hora braniega d’Australia del este", "HAST": "Hora estándar de Hawaii-Aleutianes", "JST": "Hora estándar de Xapón", "TMT": "Hora estándar del Turkmenistán", "HNEG": "Hora estándar de Groenlandia oriental", "UYT": "Hora estándar del Uruguái", "LHDT": "Hora braniega de Lord Howe", "MESZ": "Hora braniega d’Europa Central", "AST": "Hora estándar del Atlánticu", "ADT": "Hora braniega del Atlánticu", "CLST": "Hora braniega de Chile", "HAT": "Hora braniega de Newfoundland", "GFT": "Hora de La Guyana Francesa", "HECU": "Hora braniega de Cuba", "WESZ": "Hora braniega d’Europa Occidental", "AWST": "Hora estándar d’Australia del oeste", "WAT": "Hora estándar d’África del oeste", "WAST": "Hora braniega d’África del oeste", "COST": "Hora braniega de Colombia", "EDT": "Hora braniega del este norteamericanu", "HNPMX": "Hora estándar del Pacíficu de Méxicu", "HEPMX": "Hora braniega del Pacíficu de Méxicu", "BOT": "Hora de Bolivia", "MEZ": "Hora estándar d’Europa Central", "WART": "Hora estándar occidental d’Arxentina", "TMST": "Hora braniega del Turkmenistán", "ARST": "Hora braniega d’Arxentina", "HKT": "Hora estándar de Ḥong Kong", "MST": "Hora estándar de les montañes norteamericanes", "UYST": "Hora braniega del Uruguái", "WIB": "Hora d’Indonesia del oeste", "PDT": "Hora braniega del Pacíficu norteamericanu", "ACST": "Hora estándar d’Australia central", "ACDT": "Hora braniega d’Australia central", "HNNOMX": "Hora estándar del noroeste de Méxicu", "HNCU": "Hora estándar de Cuba", "ACWST": "Hora estándar d’Australia central del oeste", "OESZ": "Hora braniega d’Europa del Este", "COT": "Hora estándar de Colombia", "HEEG": "Hora braniega de Groenlandia oriental", "ChST": "Hora estándar de Chamorro", "IST": "Hora estándar de la India", "ACWDT": "Hora braniega d’Australia central del oeste", "OEZ": "Hora estándar d’Europa del Este", "HENOMX": "Hora braniega del noroeste de Méxicu", "SAST": "Hora de Sudáfrica", "EAT": "Hora d’África del este", "CST": "Hora estándar central norteamericana", "VET": "Hora de Venezuela", "HEOG": "Hora braniega de Groenlandia occidental"}, + } +} + +// Locale returns the current translators string locale +func (ast *ast_ES) Locale() string { + return ast.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ast_ES' +func (ast *ast_ES) PluralsCardinal() []locales.PluralRule { + return ast.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ast_ES' +func (ast *ast_ES) PluralsOrdinal() []locales.PluralRule { + return ast.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ast_ES' +func (ast *ast_ES) PluralsRange() []locales.PluralRule { + return ast.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ast_ES' +func (ast *ast_ES) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ast_ES' +func (ast *ast_ES) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ast_ES' +func (ast *ast_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ast *ast_ES) MonthAbbreviated(month time.Month) string { + return ast.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ast *ast_ES) MonthsAbbreviated() []string { + return ast.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ast *ast_ES) MonthNarrow(month time.Month) string { + return ast.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ast *ast_ES) MonthsNarrow() []string { + return ast.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ast *ast_ES) MonthWide(month time.Month) string { + return ast.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ast *ast_ES) MonthsWide() []string { + return ast.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ast *ast_ES) WeekdayAbbreviated(weekday time.Weekday) string { + return ast.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ast *ast_ES) WeekdaysAbbreviated() []string { + return ast.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ast *ast_ES) WeekdayNarrow(weekday time.Weekday) string { + return ast.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ast *ast_ES) WeekdaysNarrow() []string { + return ast.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ast *ast_ES) WeekdayShort(weekday time.Weekday) string { + return ast.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ast *ast_ES) WeekdaysShort() []string { + return ast.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ast *ast_ES) WeekdayWide(weekday time.Weekday) string { + return ast.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ast *ast_ES) WeekdaysWide() []string { + return ast.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ast_ES' and handles both Whole and Real numbers based on 'v' +func (ast *ast_ES) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ast.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ast.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ast.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ast_ES' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ast *ast_ES) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ast.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ast.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ast.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ast_ES' +func (ast *ast_ES) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ast.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ast.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ast.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ast.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ast.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ast.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ast_ES' +// in accounting notation. +func (ast *ast_ES) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ast.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ast.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ast.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ast.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ast.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ast.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ast.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ast_ES' +func (ast *ast_ES) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ast_ES' +func (ast *ast_ES) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ast.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ast_ES' +func (ast *ast_ES) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ast.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ast_ES' +func (ast *ast_ES) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ast.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ast.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ast_ES' +func (ast *ast_ES) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ast.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ast_ES' +func (ast *ast_ES) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ast.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ast.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ast_ES' +func (ast *ast_ES) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ast.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ast.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ast_ES' +func (ast *ast_ES) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ast.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ast.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ast.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ast_ES/ast_ES_test.go b/vendor/github.com/go-playground/locales/ast_ES/ast_ES_test.go new file mode 100644 index 0000000000..284c8e17a0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ast_ES/ast_ES_test.go @@ -0,0 +1,1120 @@ +package ast_ES + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ast_ES" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/az/az.go b/vendor/github.com/go-playground/locales/az/az.go new file mode 100644 index 0000000000..6d89c62710 --- /dev/null +++ b/vendor/github.com/go-playground/locales/az/az.go @@ -0,0 +1,628 @@ +package az + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type az struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'az' locale +func New() locales.Translator { + return &az{ + locale: "az", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "₼", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avq", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avqust", "sentyabr", "oktyabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"B.", "B.E.", "Ç.A.", "Ç.", "C.A.", "C.", "Ş."}, + daysNarrow: []string{"7", "1", "2", "3", "4", "5", "6"}, + daysShort: []string{"B.", "B.E.", "Ç.A.", "Ç.", "C.A.", "C.", "Ş."}, + daysWide: []string{"bazar", "bazar ertəsi", "çərşənbə axşamı", "çərşənbə", "cümə axşamı", "cümə", "şənbə"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"e.ə.", "y.e."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"eramızdan əvvəl", "yeni era"}, + timezones: map[string]string{"MYT": "Malayziya Vaxtı", "TMST": "Türkmənistan Yay Vaxtı", "EST": "Şimali Şərqi Amerika Standart Vaxtı", "ACST": "Mərkəzi Avstraliya Standart Vaxtı", "HEPMX": "Meksika Sakit Okean Yay Vaxtı", "SRT": "Surinam Vaxtı", "∅∅∅": "Azor Yay Vaxtı", "ARST": "Argentina Yay Vaxtı", "HNNOMX": "Şimal-Qərbi Meksika Standart Vaxtı", "HENOMX": "Şimal-Qərbi Meksika Yay Vaxtı", "AKDT": "Alyaska Yay Vaxtı", "WIT": "Şərqi İndoneziya Vaxtı", "NZDT": "Yeni Zelandiya Yay Vaxtı", "WARST": "Qərbi Argentina Yay Vaxtı", "CDT": "Şimali Mərkəzi Amerika Yay Vaxtı", "PST": "Şimali Amerika Sakit Okean Standart Vaxtı", "TMT": "Türkmənistan Standart Vaxtı", "HKST": "Honq Konq Yay Vaxtı", "WITA": "Mərkəzi İndoneziya Vaxtı", "HEPM": "San Pier və Mikelon Yay Vaxtı", "SAST": "Cənubi Afrika Vaxtı", "JST": "Yaponiya Standart Vaxtı", "WEZ": "Qərbi Avropa Standart Vaxtı", "ART": "Argentina Standart Vaxtı", "EDT": "Şimali Şərqi Amerika Yay Vaxtı", "HNEG": "Şərqi Qrenlandiya Standart Vaxtı", "GFT": "Fransız Qvianası Vaxtı", "BOT": "Boliviya Vaxtı", "CAT": "Mərkəzi Afrika Vaxtı", "VET": "Venesuela Vaxtı", "SGT": "Sinqapur Vaxtı", "OEZ": "Şərqi Avropa Standart Vaxtı", "MDT": "MDT", "CST": "Şimali Mərkəzi Amerika Standart Vaxtı", "AWST": "Qərbi Avstraliya Standart Vaxtı", "CHADT": "Çatham Yay Vaxtı", "CHAST": "Çatham Standart Vaxtı", "ECT": "Ekvador Vaxtı", "WART": "Qərbi Argentina Standart Vaxtı", "CLT": "Çili Standart Vaxtı", "WESZ": "Qərbi Avropa Yay Vaxtı", "HNPMX": "Meksika Sakit Okean Standart Vaxtı", "EAT": "Şərqi Afrika Vaxtı", "AWDT": "Qərbi Avstraliya Yay Vaxtı", "MST": "MST", "WAT": "Qərbi Afrika Standart Vaxtı", "HEEG": "Şərqi Qrenlandiya Yay Vaxtı", "COT": "Kolumbiya Standart Vaxtı", "WIB": "Qərbi İndoneziya Vaxtı", "MEZ": "Mərkəzi Avropa Standart Vaxtı", "HNOG": "Qərbi Qrenlandiya Standart Vaxtı", "LHDT": "Lord Hau Yay vaxtı", "MESZ": "Mərkəzi Avropa Yay Vaxtı", "HEOG": "Qərbi Qrenlandiya Yay Vaxtı", "AST": "Atlantik Standart Vaxt", "GMT": "Qrinviç Orta Vaxtı", "WAST": "Qərbi Afrika Yay Vaxtı", "AEST": "Şərqi Avstraliya Standart Vaxtı", "HNCU": "Kuba Standart Vaxtı", "HAST": "Havay-Aleut Standart Vaxtı", "NZST": "Yeni Zelandiya Standart Vaxtı", "ADT": "Atlantik Yay Vaxtı", "HNT": "Nyufaundlend Standart Vaxtı", "HAT": "Nyufaundlend Yay Vaxtı", "HADT": "Havay-Aleut Yay Vaxtı", "OESZ": "Şərqi Avropa Yay Vaxtı", "AEDT": "Şərqi Avstraliya Yay Vaxtı", "COST": "Kolumbiya Yay Vaxtı", "HNPM": "San Pier və Mikelon Standart Vaxtı", "HECU": "Kuba Yay Vaxtı", "PDT": "Şimali Amerika Sakit Okean Yay Vaxtı", "HKT": "Honq Konq Standart Vaxtı", "IST": "Hindistan Vaxtı", "ACWST": "Mərkəzi Qərbi Avstraliya Standart Vaxtı", "ACWDT": "Mərkəzi Qərbi Avstraliya Yay Vaxtı", "JDT": "Yaponiya Yay Vaxtı", "ACDT": "Mərkəzi Avstraliya Yay Vaxtı", "UYT": "Uruqvay Standart Vaxtı", "UYST": "Uruqvay Yay Vaxtı", "LHST": "Lord Hau Standart Vaxtı", "BT": "Butan Vaxtı", "AKST": "Alyaska Standart Vaxtı", "ChST": "Çamorro Vaxtı", "GYT": "Qayana Vaxtı", "CLST": "Çili Yay Vaxtı"}, + } +} + +// Locale returns the current translators string locale +func (az *az) Locale() string { + return az.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'az' +func (az *az) PluralsCardinal() []locales.PluralRule { + return az.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'az' +func (az *az) PluralsOrdinal() []locales.PluralRule { + return az.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'az' +func (az *az) PluralsRange() []locales.PluralRule { + return az.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'az' +func (az *az) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'az' +func (az *az) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + iMod1000 := i % 1000 + + if (iMod10 == 1 || iMod10 == 2 || iMod10 == 5 || iMod10 == 7 || iMod10 == 8) || (iMod100 == 20 || iMod100 == 50 || iMod100 == 70 || iMod100 == 80) { + return locales.PluralRuleOne + } else if (iMod10 == 3 || iMod10 == 4) || (iMod1000 == 100 || iMod1000 == 200 || iMod1000 == 300 || iMod1000 == 400 || iMod1000 == 500 || iMod1000 == 600 || iMod1000 == 700 || iMod1000 == 800 || iMod1000 == 900) { + return locales.PluralRuleFew + } else if (i == 0) || (iMod10 == 6) || (iMod100 == 40 || iMod100 == 60 || iMod100 == 90) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'az' +func (az *az) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := az.CardinalPluralRule(num1, v1) + end := az.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (az *az) MonthAbbreviated(month time.Month) string { + return az.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (az *az) MonthsAbbreviated() []string { + return az.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (az *az) MonthNarrow(month time.Month) string { + return az.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (az *az) MonthsNarrow() []string { + return az.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (az *az) MonthWide(month time.Month) string { + return az.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (az *az) MonthsWide() []string { + return az.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (az *az) WeekdayAbbreviated(weekday time.Weekday) string { + return az.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (az *az) WeekdaysAbbreviated() []string { + return az.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (az *az) WeekdayNarrow(weekday time.Weekday) string { + return az.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (az *az) WeekdaysNarrow() []string { + return az.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (az *az) WeekdayShort(weekday time.Weekday) string { + return az.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (az *az) WeekdaysShort() []string { + return az.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (az *az) WeekdayWide(weekday time.Weekday) string { + return az.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (az *az) WeekdaysWide() []string { + return az.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'az' and handles both Whole and Real numbers based on 'v' +func (az *az) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'az' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (az *az) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, az.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'az' +func (az *az) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'az' +// in accounting notation. +func (az *az) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyNegativePrefix[j]) + } + + b = append(b, az.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'az' +func (az *az) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'az' +func (az *az) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'az' +func (az *az) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'az' +func (az *az) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, az.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'az' +func (az *az) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'az' +func (az *az) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'az' +func (az *az) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'az' +func (az *az) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := az.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/az/az_test.go b/vendor/github.com/go-playground/locales/az/az_test.go new file mode 100644 index 0000000000..3919018bb6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/az/az_test.go @@ -0,0 +1,1120 @@ +package az + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "az" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/az_Cyrl/az_Cyrl.go b/vendor/github.com/go-playground/locales/az_Cyrl/az_Cyrl.go new file mode 100644 index 0000000000..0ecfe07b77 --- /dev/null +++ b/vendor/github.com/go-playground/locales/az_Cyrl/az_Cyrl.go @@ -0,0 +1,628 @@ +package az_Cyrl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type az_Cyrl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'az_Cyrl' locale +func New() locales.Translator { + return &az_Cyrl{ + locale: "az_Cyrl", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "₼", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "јан", "фев", "мар", "апр", "май", "ијн", "ијл", "авг", "сен", "окт", "ној", "дек"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "јанвар", "феврал", "март", "апрел", "май", "ијун", "ијул", "август", "сентјабр", "октјабр", "нојабр", "декабр"}, + daysAbbreviated: []string{"Б.", "Б.Е.", "Ч.А.", "Ч.", "Ҹ.А.", "Ҹ.", "Ш."}, + daysNarrow: []string{"7", "1", "2", "3", "4", "5", "6"}, + daysShort: []string{"Б.", "Б.Е.", "Ч.А.", "Ч.", "Ҹ.А.", "Ҹ.", "Ш."}, + daysWide: []string{"базар", "базар ертәси", "чәршәнбә ахшамы", "чәршәнбә", "ҹүмә ахшамы", "ҹүмә", "шәнбә"}, + periodsAbbreviated: []string{"АМ", "ПМ"}, + periodsNarrow: []string{"а", "п"}, + periodsWide: []string{"АМ", "ПМ"}, + erasAbbreviated: []string{"е.ә.", "ј.е."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ерамыздан әввәл", "јени ера"}, + timezones: map[string]string{"BT": "Butan Vaxtı", "GYT": "Qayana Vaxtı", "EAT": "Şərqi Afrika Vaxtı", "CHADT": "Çatham Yay Vaxtı", "IST": "Hindistan Vaxtı", "ACWDT": "Mərkəzi Qərbi Avstraliya Yay Vaxtı", "VET": "Venesuela Vaxtı", "ARST": "Argentina Yay Vaxtı", "TMT": "Türkmənistan Standart Vaxtı", "EST": "Şimali Şərqi Amerika Standart Vaxtı", "EDT": "Şimali Şərqi Amerika Yay Vaxtı", "AEST": "Şərqi Avstraliya Standart Vaxtı", "WIB": "Qərbi İndoneziya Vaxtı", "AWST": "Qərbi Avstraliya Standart Vaxtı", "MEZ": "Mərkəzi Avropa Standart Vaxtı", "WARST": "Qərbi Argentina Yay Vaxtı", "∅∅∅": "∅∅∅", "HNPM": "San Pier və Mikelon Standart Vaxtı", "ChST": "Çamorro Vaxtı", "SAST": "Cənubi Afrika Vaxtı", "PST": "Şimali Amerika Sakit Okean Standart Vaxtı", "CAT": "Mərkəzi Afrika Vaxtı", "MYT": "Malayziya Vaxtı", "ACDT": "Mərkəzi Avstraliya Yay Vaxtı", "HKT": "Honq Konq Standart Vaxtı", "HAT": "Nyufaundlend Yay Vaxtı", "HNCU": "Kuba Standart Vaxtı", "JDT": "Yaponiya Yay Vaxtı", "CLST": "Çili Yay Vaxtı", "LHDT": "Lord Hau Yay vaxtı", "CDT": "Şimali Mərkəzi Amerika Yay Vaxtı", "AWDT": "Qərbi Avstraliya Yay Vaxtı", "HAST": "Havay-Aleut Standart Vaxtı", "MESZ": "Mərkəzi Avropa Yay Vaxtı", "LHST": "Lord Hau Standart Vaxtı", "NZST": "Yeni Zelandiya Standart Vaxtı", "MST": "MST", "CST": "Şimali Mərkəzi Amerika Standart Vaxtı", "HNEG": "Şərqi Qrenlandiya Standart Vaxtı", "AEDT": "Şərqi Avstraliya Yay Vaxtı", "WIT": "Şərqi İndoneziya Vaxtı", "ACWST": "Mərkəzi Qərbi Avstraliya Standart Vaxtı", "NZDT": "Yeni Zelandiya Yay Vaxtı", "CLT": "Çili Standart Vaxtı", "TMST": "Türkmənistan Yay Vaxtı", "ACST": "Mərkəzi Avstraliya Standart Vaxtı", "HEEG": "Şərqi Qrenlandiya Yay Vaxtı", "UYST": "Uruqvay Yay Vaxtı", "HEPMX": "Meksika Sakit Okean Yay Vaxtı", "OEZ": "Şərqi Avropa Standart Vaxtı", "WESZ": "Qərbi Avropa Yay Vaxtı", "HNPMX": "Meksika Sakit Okean Standart Vaxtı", "HNOG": "Qərbi Qrenlandiya Standart Vaxtı", "COT": "Kolumbiya Standart Vaxtı", "HNNOMX": "Şimal-Qərbi Meksika Standart Vaxtı", "AKDT": "Alyaska Yay Vaxtı", "HADT": "Havay-Aleut Yay Vaxtı", "ECT": "Ekvador Vaxtı", "OESZ": "Şərqi Avropa Yay Vaxtı", "ART": "Argentina Standart Vaxtı", "AKST": "Alyaska Standart Vaxtı", "ADT": "Atlantik Yay Vaxtı", "HNT": "Nyufaundlend Standart Vaxtı", "UYT": "Uruqvay Standart Vaxtı", "CHAST": "Çatham Standart Vaxtı", "PDT": "Şimali Amerika Sakit Okean Yay Vaxtı", "AST": "Atlantik Standart Vaxt", "WAST": "Qərbi Afrika Yay Vaxtı", "HKST": "Honq Konq Yay Vaxtı", "WAT": "Qərbi Afrika Standart Vaxtı", "COST": "Kolumbiya Yay Vaxtı", "WITA": "Mərkəzi İndoneziya Vaxtı", "WEZ": "Qərbi Avropa Standart Vaxtı", "WART": "Qərbi Argentina Standart Vaxtı", "HEPM": "San Pier və Mikelon Yay Vaxtı", "HECU": "Kuba Yay Vaxtı", "BOT": "Boliviya Vaxtı", "HEOG": "Qərbi Qrenlandiya Yay Vaxtı", "GFT": "Fransız Qvianası Vaxtı", "MDT": "MDT", "HENOMX": "Şimal-Qərbi Meksika Yay Vaxtı", "SRT": "Surinam Vaxtı", "SGT": "Sinqapur Vaxtı", "JST": "Yaponiya Standart Vaxtı", "GMT": "Qrinviç Orta Vaxtı"}, + } +} + +// Locale returns the current translators string locale +func (az *az_Cyrl) Locale() string { + return az.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'az_Cyrl' +func (az *az_Cyrl) PluralsCardinal() []locales.PluralRule { + return az.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'az_Cyrl' +func (az *az_Cyrl) PluralsOrdinal() []locales.PluralRule { + return az.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'az_Cyrl' +func (az *az_Cyrl) PluralsRange() []locales.PluralRule { + return az.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'az_Cyrl' +func (az *az_Cyrl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'az_Cyrl' +func (az *az_Cyrl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + iMod1000 := i % 1000 + iMod10 := i % 10 + + if (iMod10 == 1 || iMod10 == 2 || iMod10 == 5 || iMod10 == 7 || iMod10 == 8) || (iMod100 == 20 || iMod100 == 50 || iMod100 == 70 || iMod100 == 80) { + return locales.PluralRuleOne + } else if (iMod10 == 3 || iMod10 == 4) || (iMod1000 == 100 || iMod1000 == 200 || iMod1000 == 300 || iMod1000 == 400 || iMod1000 == 500 || iMod1000 == 600 || iMod1000 == 700 || iMod1000 == 800 || iMod1000 == 900) { + return locales.PluralRuleFew + } else if (i == 0) || (iMod10 == 6) || (iMod100 == 40 || iMod100 == 60 || iMod100 == 90) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'az_Cyrl' +func (az *az_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := az.CardinalPluralRule(num1, v1) + end := az.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (az *az_Cyrl) MonthAbbreviated(month time.Month) string { + return az.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (az *az_Cyrl) MonthsAbbreviated() []string { + return az.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (az *az_Cyrl) MonthNarrow(month time.Month) string { + return az.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (az *az_Cyrl) MonthsNarrow() []string { + return az.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (az *az_Cyrl) MonthWide(month time.Month) string { + return az.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (az *az_Cyrl) MonthsWide() []string { + return az.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (az *az_Cyrl) WeekdayAbbreviated(weekday time.Weekday) string { + return az.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (az *az_Cyrl) WeekdaysAbbreviated() []string { + return az.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (az *az_Cyrl) WeekdayNarrow(weekday time.Weekday) string { + return az.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (az *az_Cyrl) WeekdaysNarrow() []string { + return az.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (az *az_Cyrl) WeekdayShort(weekday time.Weekday) string { + return az.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (az *az_Cyrl) WeekdaysShort() []string { + return az.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (az *az_Cyrl) WeekdayWide(weekday time.Weekday) string { + return az.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (az *az_Cyrl) WeekdaysWide() []string { + return az.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'az_Cyrl' and handles both Whole and Real numbers based on 'v' +func (az *az_Cyrl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'az_Cyrl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (az *az_Cyrl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, az.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'az_Cyrl' +func (az *az_Cyrl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'az_Cyrl' +// in accounting notation. +func (az *az_Cyrl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyNegativePrefix[j]) + } + + b = append(b, az.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'az_Cyrl' +func (az *az_Cyrl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'az_Cyrl' +func (az *az_Cyrl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'az_Cyrl' +func (az *az_Cyrl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'az_Cyrl' +func (az *az_Cyrl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, az.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'az_Cyrl' +func (az *az_Cyrl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'az_Cyrl' +func (az *az_Cyrl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'az_Cyrl' +func (az *az_Cyrl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'az_Cyrl' +func (az *az_Cyrl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := az.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/az_Cyrl/az_Cyrl_test.go b/vendor/github.com/go-playground/locales/az_Cyrl/az_Cyrl_test.go new file mode 100644 index 0000000000..b2523c57c6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/az_Cyrl/az_Cyrl_test.go @@ -0,0 +1,1120 @@ +package az_Cyrl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "az_Cyrl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/az_Cyrl_AZ/az_Cyrl_AZ.go b/vendor/github.com/go-playground/locales/az_Cyrl_AZ/az_Cyrl_AZ.go new file mode 100644 index 0000000000..322987b12d --- /dev/null +++ b/vendor/github.com/go-playground/locales/az_Cyrl_AZ/az_Cyrl_AZ.go @@ -0,0 +1,628 @@ +package az_Cyrl_AZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type az_Cyrl_AZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'az_Cyrl_AZ' locale +func New() locales.Translator { + return &az_Cyrl_AZ{ + locale: "az_Cyrl_AZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avq", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avqust", "sentyabr", "oktyabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"B.", "B.E.", "Ç.A.", "Ç.", "C.A.", "C.", "Ş."}, + daysNarrow: []string{"7", "1", "2", "3", "4", "5", "6"}, + daysShort: []string{"B.", "B.E.", "Ç.A.", "Ç.", "C.A.", "C.", "Ş."}, + daysWide: []string{"bazar", "bazar ertəsi", "çərşənbə axşamı", "çərşənbə", "cümə axşamı", "cümə", "şənbə"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"e.ə.", "y.e."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"eramızdan əvvəl", "yeni era"}, + timezones: map[string]string{"COT": "Kolumbiya Standart Vaxtı", "BT": "Butan Vaxtı", "HECU": "Kuba Yay Vaxtı", "CDT": "Şimali Mərkəzi Amerika Yay Vaxtı", "CLT": "Çili Standart Vaxtı", "ACWST": "Mərkəzi Qərbi Avstraliya Standart Vaxtı", "OEZ": "Şərqi Avropa Standart Vaxtı", "EDT": "Şimali Şərqi Amerika Yay Vaxtı", "HKST": "Honq Konq Yay Vaxtı", "ACDT": "Mərkəzi Avstraliya Yay Vaxtı", "HAT": "Nyufaundlend Yay Vaxtı", "WIT": "Şərqi İndoneziya Vaxtı", "HADT": "Havay-Aleut Yay Vaxtı", "MESZ": "Mərkəzi Avropa Yay Vaxtı", "WAT": "Qərbi Afrika Standart Vaxtı", "HEEG": "Şərqi Qrenlandiya Yay Vaxtı", "PST": "Şimali Amerika Sakit Okean Standart Vaxtı", "HAST": "Havay-Aleut Standart Vaxtı", "OESZ": "Şərqi Avropa Yay Vaxtı", "WEZ": "Qərbi Avropa Standart Vaxtı", "GMT": "Qrinviç Orta Vaxtı", "UYT": "Uruqvay Standart Vaxtı", "SRT": "Surinam Vaxtı", "∅∅∅": "Braziliya Yay Vaxtı", "CHADT": "Çatham Yay Vaxtı", "HNOG": "Qərbi Qrenlandiya Standart Vaxtı", "HNEG": "Şərqi Qrenlandiya Standart Vaxtı", "LHST": "Lord Hau Standart Vaxtı", "MEZ": "Mərkəzi Avropa Standart Vaxtı", "WARST": "Qərbi Argentina Yay Vaxtı", "CAT": "Mərkəzi Afrika Vaxtı", "VET": "Venesuela Vaxtı", "JST": "Yaponiya Standart Vaxtı", "COST": "Kolumbiya Yay Vaxtı", "CST": "Şimali Mərkəzi Amerika Standart Vaxtı", "CHAST": "Çatham Standart Vaxtı", "NZST": "Yeni Zelandiya Standart Vaxtı", "TMST": "Türkmənistan Yay Vaxtı", "HKT": "Honq Konq Standart Vaxtı", "HEPM": "San Pier və Mikelon Yay Vaxtı", "HEPMX": "Meksika Sakit Okean Yay Vaxtı", "WIB": "Qərbi İndoneziya Vaxtı", "BOT": "Boliviya Vaxtı", "PDT": "Şimali Amerika Sakit Okean Yay Vaxtı", "EAT": "Şərqi Afrika Vaxtı", "MDT": "MDT", "ChST": "Çamorro Vaxtı", "ECT": "Ekvador Vaxtı", "ART": "Argentina Standart Vaxtı", "TMT": "Türkmənistan Standart Vaxtı", "MST": "MST", "HENOMX": "Şimal-Qərbi Meksika Yay Vaxtı", "HNT": "Nyufaundlend Standart Vaxtı", "GFT": "Fransız Qvianası Vaxtı", "SGT": "Sinqapur Vaxtı", "AST": "Atlantik Standart Vaxt", "EST": "Şimali Şərqi Amerika Standart Vaxtı", "SAST": "Cənubi Afrika Vaxtı", "ACWDT": "Mərkəzi Qərbi Avstraliya Yay Vaxtı", "ADT": "Atlantik Yay Vaxtı", "AKST": "Alyaska Standart Vaxtı", "GYT": "Qayana Vaxtı", "HNCU": "Kuba Standart Vaxtı", "AWDT": "Qərbi Avstraliya Yay Vaxtı", "IST": "Hindistan Vaxtı", "LHDT": "Lord Hau Yay vaxtı", "HEOG": "Qərbi Qrenlandiya Yay Vaxtı", "AEST": "Şərqi Avstraliya Standart Vaxtı", "AEDT": "Şərqi Avstraliya Yay Vaxtı", "WAST": "Qərbi Afrika Yay Vaxtı", "ACST": "Mərkəzi Avstraliya Standart Vaxtı", "HNPMX": "Meksika Sakit Okean Standart Vaxtı", "WART": "Qərbi Argentina Standart Vaxtı", "AKDT": "Alyaska Yay Vaxtı", "MYT": "Malayziya Vaxtı", "UYST": "Uruqvay Yay Vaxtı", "HNPM": "San Pier və Mikelon Standart Vaxtı", "AWST": "Qərbi Avstraliya Standart Vaxtı", "NZDT": "Yeni Zelandiya Yay Vaxtı", "CLST": "Çili Yay Vaxtı", "ARST": "Argentina Yay Vaxtı", "HNNOMX": "Şimal-Qərbi Meksika Standart Vaxtı", "WITA": "Mərkəzi İndoneziya Vaxtı", "JDT": "Yaponiya Yay Vaxtı", "WESZ": "Qərbi Avropa Yay Vaxtı"}, + } +} + +// Locale returns the current translators string locale +func (az *az_Cyrl_AZ) Locale() string { + return az.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) PluralsCardinal() []locales.PluralRule { + return az.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) PluralsOrdinal() []locales.PluralRule { + return az.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) PluralsRange() []locales.PluralRule { + return az.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + iMod1000 := i % 1000 + + if (iMod10 == 1 || iMod10 == 2 || iMod10 == 5 || iMod10 == 7 || iMod10 == 8) || (iMod100 == 20 || iMod100 == 50 || iMod100 == 70 || iMod100 == 80) { + return locales.PluralRuleOne + } else if (iMod10 == 3 || iMod10 == 4) || (iMod1000 == 100 || iMod1000 == 200 || iMod1000 == 300 || iMod1000 == 400 || iMod1000 == 500 || iMod1000 == 600 || iMod1000 == 700 || iMod1000 == 800 || iMod1000 == 900) { + return locales.PluralRuleFew + } else if (i == 0) || (iMod10 == 6) || (iMod100 == 40 || iMod100 == 60 || iMod100 == 90) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := az.CardinalPluralRule(num1, v1) + end := az.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (az *az_Cyrl_AZ) MonthAbbreviated(month time.Month) string { + return az.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (az *az_Cyrl_AZ) MonthsAbbreviated() []string { + return az.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (az *az_Cyrl_AZ) MonthNarrow(month time.Month) string { + return az.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (az *az_Cyrl_AZ) MonthsNarrow() []string { + return az.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (az *az_Cyrl_AZ) MonthWide(month time.Month) string { + return az.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (az *az_Cyrl_AZ) MonthsWide() []string { + return az.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (az *az_Cyrl_AZ) WeekdayAbbreviated(weekday time.Weekday) string { + return az.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (az *az_Cyrl_AZ) WeekdaysAbbreviated() []string { + return az.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (az *az_Cyrl_AZ) WeekdayNarrow(weekday time.Weekday) string { + return az.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (az *az_Cyrl_AZ) WeekdaysNarrow() []string { + return az.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (az *az_Cyrl_AZ) WeekdayShort(weekday time.Weekday) string { + return az.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (az *az_Cyrl_AZ) WeekdaysShort() []string { + return az.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (az *az_Cyrl_AZ) WeekdayWide(weekday time.Weekday) string { + return az.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (az *az_Cyrl_AZ) WeekdaysWide() []string { + return az.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'az_Cyrl_AZ' and handles both Whole and Real numbers based on 'v' +func (az *az_Cyrl_AZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'az_Cyrl_AZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (az *az_Cyrl_AZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, az.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'az_Cyrl_AZ' +// in accounting notation. +func (az *az_Cyrl_AZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyNegativePrefix[j]) + } + + b = append(b, az.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, az.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'az_Cyrl_AZ' +func (az *az_Cyrl_AZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := az.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/az_Cyrl_AZ/az_Cyrl_AZ_test.go b/vendor/github.com/go-playground/locales/az_Cyrl_AZ/az_Cyrl_AZ_test.go new file mode 100644 index 0000000000..0554ed62be --- /dev/null +++ b/vendor/github.com/go-playground/locales/az_Cyrl_AZ/az_Cyrl_AZ_test.go @@ -0,0 +1,1120 @@ +package az_Cyrl_AZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "az_Cyrl_AZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/az_Latn/az_Latn.go b/vendor/github.com/go-playground/locales/az_Latn/az_Latn.go new file mode 100644 index 0000000000..754c353d10 --- /dev/null +++ b/vendor/github.com/go-playground/locales/az_Latn/az_Latn.go @@ -0,0 +1,628 @@ +package az_Latn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type az_Latn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'az_Latn' locale +func New() locales.Translator { + return &az_Latn{ + locale: "az_Latn", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avq", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avqust", "sentyabr", "oktyabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"B.", "B.E.", "Ç.A.", "Ç.", "C.A.", "C.", "Ş."}, + daysNarrow: []string{"7", "1", "2", "3", "4", "5", "6"}, + daysShort: []string{"B.", "B.E.", "Ç.A.", "Ç.", "C.A.", "C.", "Ş."}, + daysWide: []string{"bazar", "bazar ertəsi", "çərşənbə axşamı", "çərşənbə", "cümə axşamı", "cümə", "şənbə"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"e.ə.", "y.e."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"eramızdan əvvəl", "yeni era"}, + timezones: map[string]string{"MDT": "Şimali Dağlıq Amerika Yay Vaxtı", "HKT": "Honq Konq Standart Vaxtı", "HAT": "Nyufaundlend Yay Vaxtı", "LHDT": "Lord Hau Yay vaxtı", "IST": "Hindistan Vaxtı", "ACWDT": "Mərkəzi Qərbi Avstraliya Yay Vaxtı", "WARST": "Qərbi Argentina Yay Vaxtı", "ART": "Argentina Standart Vaxtı", "WITA": "Mərkəzi İndoneziya Vaxtı", "AKDT": "Alyaska Yay Vaxtı", "HECU": "Kuba Yay Vaxtı", "EDT": "Şimali Şərqi Amerika Yay Vaxtı", "HNPM": "San Pier və Mikelon Standart Vaxtı", "WIT": "Şərqi İndoneziya Vaxtı", "SGT": "Sinqapur Vaxtı", "HAST": "Havay-Aleut Standart Vaxtı", "MEZ": "Mərkəzi Avropa Standart Vaxtı", "HEOG": "Qərbi Qrenlandiya Yay Vaxtı", "HNNOMX": "Şimal-Qərbi Meksika Standart Vaxtı", "HNT": "Nyufaundlend Standart Vaxtı", "SRT": "Surinam Vaxtı", "GYT": "Qayana Vaxtı", "BOT": "Boliviya Vaxtı", "NZDT": "Yeni Zelandiya Yay Vaxtı", "JST": "Yaponiya Standart Vaxtı", "WEZ": "Qərbi Avropa Standart Vaxtı", "HENOMX": "Şimal-Qərbi Meksika Yay Vaxtı", "ChST": "Çamorro Vaxtı", "ACWST": "Mərkəzi Qərbi Avstraliya Standart Vaxtı", "NZST": "Yeni Zelandiya Standart Vaxtı", "WAT": "Qərbi Afrika Standart Vaxtı", "WAST": "Qərbi Afrika Yay Vaxtı", "HKST": "Honq Konq Yay Vaxtı", "ACST": "Mərkəzi Avstraliya Standart Vaxtı", "AKST": "Alyaska Standart Vaxtı", "CHAST": "Çatham Standart Vaxtı", "PST": "Şimali Amerika Sakit Okean Standart Vaxtı", "AST": "Atlantik Standart Vaxt", "ADT": "Atlantik Yay Vaxtı", "UYT": "Uruqvay Standart Vaxtı", "EST": "Şimali Şərqi Amerika Standart Vaxtı", "LHST": "Lord Hau Standart Vaxtı", "CST": "Şimali Mərkəzi Amerika Standart Vaxtı", "GMT": "Qrinviç Orta Vaxtı", "MYT": "Malayziya Vaxtı", "TMT": "Türkmənistan Standart Vaxtı", "UYST": "Uruqvay Yay Vaxtı", "MST": "Şimali Dağlıq Amerika Standart Vaxtı", "WIB": "Qərbi İndoneziya Vaxtı", "MESZ": "Mərkəzi Avropa Yay Vaxtı", "HNEG": "Şərqi Qrenlandiya Standart Vaxtı", "EAT": "Şərqi Afrika Vaxtı", "VET": "Venesuela Vaxtı", "CLT": "Çili Standart Vaxtı", "HNOG": "Qərbi Qrenlandiya Standart Vaxtı", "∅∅∅": "∅∅∅", "AEDT": "Şərqi Avstraliya Yay Vaxtı", "HEPM": "San Pier və Mikelon Yay Vaxtı", "AWDT": "Qərbi Avstraliya Yay Vaxtı", "PDT": "Şimali Amerika Sakit Okean Yay Vaxtı", "JDT": "Yaponiya Yay Vaxtı", "CLST": "Çili Yay Vaxtı", "COST": "Kolumbiya Yay Vaxtı", "AEST": "Şərqi Avstraliya Standart Vaxtı", "HEPMX": "Meksika Sakit Okean Yay Vaxtı", "CDT": "Şimali Mərkəzi Amerika Yay Vaxtı", "CAT": "Mərkəzi Afrika Vaxtı", "OESZ": "Şərqi Avropa Yay Vaxtı", "GFT": "Fransız Qvianası Vaxtı", "SAST": "Cənubi Afrika Vaxtı", "HNPMX": "Meksika Sakit Okean Standart Vaxtı", "HADT": "Havay-Aleut Yay Vaxtı", "ECT": "Ekvador Vaxtı", "OEZ": "Şərqi Avropa Standart Vaxtı", "WESZ": "Qərbi Avropa Yay Vaxtı", "WART": "Qərbi Argentina Standart Vaxtı", "BT": "Butan Vaxtı", "ARST": "Argentina Yay Vaxtı", "ACDT": "Mərkəzi Avstraliya Yay Vaxtı", "TMST": "Türkmənistan Yay Vaxtı", "HNCU": "Kuba Standart Vaxtı", "AWST": "Qərbi Avstraliya Standart Vaxtı", "CHADT": "Çatham Yay Vaxtı", "COT": "Kolumbiya Standart Vaxtı", "HEEG": "Şərqi Qrenlandiya Yay Vaxtı"}, + } +} + +// Locale returns the current translators string locale +func (az *az_Latn) Locale() string { + return az.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'az_Latn' +func (az *az_Latn) PluralsCardinal() []locales.PluralRule { + return az.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'az_Latn' +func (az *az_Latn) PluralsOrdinal() []locales.PluralRule { + return az.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'az_Latn' +func (az *az_Latn) PluralsRange() []locales.PluralRule { + return az.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'az_Latn' +func (az *az_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'az_Latn' +func (az *az_Latn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + iMod1000 := i % 1000 + + if (iMod10 == 1 || iMod10 == 2 || iMod10 == 5 || iMod10 == 7 || iMod10 == 8) || (iMod100 == 20 || iMod100 == 50 || iMod100 == 70 || iMod100 == 80) { + return locales.PluralRuleOne + } else if (iMod10 == 3 || iMod10 == 4) || (iMod1000 == 100 || iMod1000 == 200 || iMod1000 == 300 || iMod1000 == 400 || iMod1000 == 500 || iMod1000 == 600 || iMod1000 == 700 || iMod1000 == 800 || iMod1000 == 900) { + return locales.PluralRuleFew + } else if (i == 0) || (iMod10 == 6) || (iMod100 == 40 || iMod100 == 60 || iMod100 == 90) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'az_Latn' +func (az *az_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := az.CardinalPluralRule(num1, v1) + end := az.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (az *az_Latn) MonthAbbreviated(month time.Month) string { + return az.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (az *az_Latn) MonthsAbbreviated() []string { + return az.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (az *az_Latn) MonthNarrow(month time.Month) string { + return az.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (az *az_Latn) MonthsNarrow() []string { + return az.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (az *az_Latn) MonthWide(month time.Month) string { + return az.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (az *az_Latn) MonthsWide() []string { + return az.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (az *az_Latn) WeekdayAbbreviated(weekday time.Weekday) string { + return az.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (az *az_Latn) WeekdaysAbbreviated() []string { + return az.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (az *az_Latn) WeekdayNarrow(weekday time.Weekday) string { + return az.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (az *az_Latn) WeekdaysNarrow() []string { + return az.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (az *az_Latn) WeekdayShort(weekday time.Weekday) string { + return az.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (az *az_Latn) WeekdaysShort() []string { + return az.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (az *az_Latn) WeekdayWide(weekday time.Weekday) string { + return az.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (az *az_Latn) WeekdaysWide() []string { + return az.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'az_Latn' and handles both Whole and Real numbers based on 'v' +func (az *az_Latn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'az_Latn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (az *az_Latn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, az.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'az_Latn' +func (az *az_Latn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'az_Latn' +// in accounting notation. +func (az *az_Latn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyNegativePrefix[j]) + } + + b = append(b, az.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'az_Latn' +func (az *az_Latn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'az_Latn' +func (az *az_Latn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'az_Latn' +func (az *az_Latn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'az_Latn' +func (az *az_Latn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, az.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'az_Latn' +func (az *az_Latn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'az_Latn' +func (az *az_Latn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'az_Latn' +func (az *az_Latn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'az_Latn' +func (az *az_Latn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := az.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/az_Latn/az_Latn_test.go b/vendor/github.com/go-playground/locales/az_Latn/az_Latn_test.go new file mode 100644 index 0000000000..e30fbdebd5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/az_Latn/az_Latn_test.go @@ -0,0 +1,1120 @@ +package az_Latn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "az_Latn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/az_Latn_AZ/az_Latn_AZ.go b/vendor/github.com/go-playground/locales/az_Latn_AZ/az_Latn_AZ.go new file mode 100644 index 0000000000..73582413b5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/az_Latn_AZ/az_Latn_AZ.go @@ -0,0 +1,628 @@ +package az_Latn_AZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type az_Latn_AZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'az_Latn_AZ' locale +func New() locales.Translator { + return &az_Latn_AZ{ + locale: "az_Latn_AZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avq", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avqust", "sentyabr", "oktyabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"B.", "B.E.", "Ç.A.", "Ç.", "C.A.", "C.", "Ş."}, + daysNarrow: []string{"7", "1", "2", "3", "4", "5", "6"}, + daysShort: []string{"B.", "B.E.", "Ç.A.", "Ç.", "C.A.", "C.", "Ş."}, + daysWide: []string{"bazar", "bazar ertəsi", "çərşənbə axşamı", "çərşənbə", "cümə axşamı", "cümə", "şənbə"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"e.ə.", "y.e."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"eramızdan əvvəl", "yeni era"}, + timezones: map[string]string{"GFT": "Fransız Qvianası Vaxtı", "PST": "Şimali Amerika Sakit Okean Standart Vaxtı", "CAT": "Mərkəzi Afrika Vaxtı", "EST": "Şimali Şərqi Amerika Standart Vaxtı", "ChST": "Çamorro Vaxtı", "CDT": "Şimali Mərkəzi Amerika Yay Vaxtı", "OESZ": "Şərqi Avropa Yay Vaxtı", "COST": "Kolumbiya Yay Vaxtı", "MDT": "Şimali Dağlıq Amerika Yay Vaxtı", "HAST": "Havay-Aleut Standart Vaxtı", "CLST": "Çili Yay Vaxtı", "TMT": "Türkmənistan Standart Vaxtı", "WAT": "Qərbi Afrika Standart Vaxtı", "HKT": "Honq Konq Standart Vaxtı", "ACDT": "Mərkəzi Avstraliya Yay Vaxtı", "SRT": "Surinam Vaxtı", "ECT": "Ekvador Vaxtı", "WESZ": "Qərbi Avropa Yay Vaxtı", "AEST": "Şərqi Avstraliya Standart Vaxtı", "JST": "Yaponiya Standart Vaxtı", "WAST": "Qərbi Afrika Yay Vaxtı", "HAT": "Nyufaundlend Yay Vaxtı", "HNPM": "San Pier və Mikelon Standart Vaxtı", "IST": "Hindistan Vaxtı", "VET": "Venesuela Vaxtı", "AST": "Atlantik Standart Vaxt", "BT": "Butan Vaxtı", "∅∅∅": "∅∅∅", "WIT": "Şərqi İndoneziya Vaxtı", "AWDT": "Qərbi Avstraliya Yay Vaxtı", "MYT": "Malayziya Vaxtı", "COT": "Kolumbiya Standart Vaxtı", "SAST": "Cənubi Afrika Vaxtı", "LHDT": "Lord Hau Yay vaxtı", "HNPMX": "Meksika Sakit Okean Standart Vaxtı", "JDT": "Yaponiya Yay Vaxtı", "HENOMX": "Şimal-Qərbi Meksika Yay Vaxtı", "UYT": "Uruqvay Standart Vaxtı", "UYST": "Uruqvay Yay Vaxtı", "LHST": "Lord Hau Standart Vaxtı", "SGT": "Sinqapur Vaxtı", "NZST": "Yeni Zelandiya Standart Vaxtı", "HEOG": "Qərbi Qrenlandiya Yay Vaxtı", "GMT": "Qrinviç Orta Vaxtı", "HNNOMX": "Şimal-Qərbi Meksika Standart Vaxtı", "AWST": "Qərbi Avstraliya Standart Vaxtı", "NZDT": "Yeni Zelandiya Yay Vaxtı", "MESZ": "Mərkəzi Avropa Yay Vaxtı", "ADT": "Atlantik Yay Vaxtı", "OEZ": "Şərqi Avropa Standart Vaxtı", "CLT": "Çili Standart Vaxtı", "ACST": "Mərkəzi Avstraliya Standart Vaxtı", "ART": "Argentina Standart Vaxtı", "AKST": "Alyaska Standart Vaxtı", "HEPM": "San Pier və Mikelon Yay Vaxtı", "HECU": "Kuba Yay Vaxtı", "CHAST": "Çatham Standart Vaxtı", "PDT": "Şimali Amerika Sakit Okean Yay Vaxtı", "ACWDT": "Mərkəzi Qərbi Avstraliya Yay Vaxtı", "WEZ": "Qərbi Avropa Standart Vaxtı", "HNT": "Nyufaundlend Standart Vaxtı", "AKDT": "Alyaska Yay Vaxtı", "GYT": "Qayana Vaxtı", "WIB": "Qərbi İndoneziya Vaxtı", "WARST": "Qərbi Argentina Yay Vaxtı", "EDT": "Şimali Şərqi Amerika Yay Vaxtı", "HNEG": "Şərqi Qrenlandiya Standart Vaxtı", "AEDT": "Şərqi Avstraliya Yay Vaxtı", "HEPMX": "Meksika Sakit Okean Yay Vaxtı", "EAT": "Şərqi Afrika Vaxtı", "HNCU": "Kuba Standart Vaxtı", "MEZ": "Mərkəzi Avropa Standart Vaxtı", "TMST": "Türkmənistan Yay Vaxtı", "HEEG": "Şərqi Qrenlandiya Yay Vaxtı", "WITA": "Mərkəzi İndoneziya Vaxtı", "ACWST": "Mərkəzi Qərbi Avstraliya Standart Vaxtı", "HNOG": "Qərbi Qrenlandiya Standart Vaxtı", "WART": "Qərbi Argentina Standart Vaxtı", "HKST": "Honq Konq Yay Vaxtı", "MST": "Şimali Dağlıq Amerika Standart Vaxtı", "CST": "Şimali Mərkəzi Amerika Standart Vaxtı", "CHADT": "Çatham Yay Vaxtı", "BOT": "Boliviya Vaxtı", "HADT": "Havay-Aleut Yay Vaxtı", "ARST": "Argentina Yay Vaxtı"}, + } +} + +// Locale returns the current translators string locale +func (az *az_Latn_AZ) Locale() string { + return az.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'az_Latn_AZ' +func (az *az_Latn_AZ) PluralsCardinal() []locales.PluralRule { + return az.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'az_Latn_AZ' +func (az *az_Latn_AZ) PluralsOrdinal() []locales.PluralRule { + return az.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'az_Latn_AZ' +func (az *az_Latn_AZ) PluralsRange() []locales.PluralRule { + return az.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'az_Latn_AZ' +func (az *az_Latn_AZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'az_Latn_AZ' +func (az *az_Latn_AZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + iMod1000 := i % 1000 + + if (iMod10 == 1 || iMod10 == 2 || iMod10 == 5 || iMod10 == 7 || iMod10 == 8) || (iMod100 == 20 || iMod100 == 50 || iMod100 == 70 || iMod100 == 80) { + return locales.PluralRuleOne + } else if (iMod10 == 3 || iMod10 == 4) || (iMod1000 == 100 || iMod1000 == 200 || iMod1000 == 300 || iMod1000 == 400 || iMod1000 == 500 || iMod1000 == 600 || iMod1000 == 700 || iMod1000 == 800 || iMod1000 == 900) { + return locales.PluralRuleFew + } else if (i == 0) || (iMod10 == 6) || (iMod100 == 40 || iMod100 == 60 || iMod100 == 90) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'az_Latn_AZ' +func (az *az_Latn_AZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := az.CardinalPluralRule(num1, v1) + end := az.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (az *az_Latn_AZ) MonthAbbreviated(month time.Month) string { + return az.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (az *az_Latn_AZ) MonthsAbbreviated() []string { + return az.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (az *az_Latn_AZ) MonthNarrow(month time.Month) string { + return az.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (az *az_Latn_AZ) MonthsNarrow() []string { + return az.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (az *az_Latn_AZ) MonthWide(month time.Month) string { + return az.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (az *az_Latn_AZ) MonthsWide() []string { + return az.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (az *az_Latn_AZ) WeekdayAbbreviated(weekday time.Weekday) string { + return az.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (az *az_Latn_AZ) WeekdaysAbbreviated() []string { + return az.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (az *az_Latn_AZ) WeekdayNarrow(weekday time.Weekday) string { + return az.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (az *az_Latn_AZ) WeekdaysNarrow() []string { + return az.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (az *az_Latn_AZ) WeekdayShort(weekday time.Weekday) string { + return az.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (az *az_Latn_AZ) WeekdaysShort() []string { + return az.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (az *az_Latn_AZ) WeekdayWide(weekday time.Weekday) string { + return az.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (az *az_Latn_AZ) WeekdaysWide() []string { + return az.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'az_Latn_AZ' and handles both Whole and Real numbers based on 'v' +func (az *az_Latn_AZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'az_Latn_AZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (az *az_Latn_AZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, az.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, az.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'az_Latn_AZ' +// in accounting notation. +func (az *az_Latn_AZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := az.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, az.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, az.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyNegativePrefix[j]) + } + + b = append(b, az.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(az.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, az.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, az.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, az.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, az.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'az_Latn_AZ' +func (az *az_Latn_AZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, az.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, az.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := az.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/az_Latn_AZ/az_Latn_AZ_test.go b/vendor/github.com/go-playground/locales/az_Latn_AZ/az_Latn_AZ_test.go new file mode 100644 index 0000000000..84bbb79878 --- /dev/null +++ b/vendor/github.com/go-playground/locales/az_Latn_AZ/az_Latn_AZ_test.go @@ -0,0 +1,1120 @@ +package az_Latn_AZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "az_Latn_AZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bas/bas.go b/vendor/github.com/go-playground/locales/bas/bas.go new file mode 100644 index 0000000000..c92fd9c222 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bas/bas.go @@ -0,0 +1,575 @@ +package bas + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bas struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bas' locale +func New() locales.Translator { + return &bas{ + locale: "bas", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "kɔn", "mac", "mat", "mto", "mpu", "hil", "nje", "hik", "dip", "bio", "may", "liɓ"}, + monthsNarrow: []string{"", "k", "m", "m", "m", "m", "h", "n", "h", "d", "b", "m", "l"}, + monthsWide: []string{"", "Kɔndɔŋ", "Màcɛ̂l", "Màtùmb", "Màtop", "M̀puyɛ", "Hìlòndɛ̀", "Njèbà", "Hìkaŋ", "Dìpɔ̀s", "Bìòôm", "Màyɛsèp", "Lìbuy li ńyèe"}, + daysAbbreviated: []string{"nɔy", "nja", "uum", "ŋge", "mbɔ", "kɔɔ", "jon"}, + daysNarrow: []string{"n", "n", "u", "ŋ", "m", "k", "j"}, + daysWide: []string{"ŋgwà nɔ̂y", "ŋgwà njaŋgumba", "ŋgwà ûm", "ŋgwà ŋgê", "ŋgwà mbɔk", "ŋgwà kɔɔ", "ŋgwà jôn"}, + periodsAbbreviated: []string{"I bikɛ̂glà", "I ɓugajɔp"}, + periodsWide: []string{"I bikɛ̂glà", "I ɓugajɔp"}, + erasAbbreviated: []string{"b.Y.K", "m.Y.K"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"bisū bi Yesù Krǐstò", "i mbūs Yesù Krǐstò"}, + timezones: map[string]string{"EDT": "EDT", "HEPMX": "HEPMX", "HNCU": "HNCU", "CHADT": "CHADT", "SGT": "SGT", "HADT": "HADT", "ADT": "ADT", "ACST": "ACST", "SAST": "SAST", "WEZ": "WEZ", "WAT": "WAT", "HKST": "HKST", "HNT": "HNT", "HNEG": "HNEG", "ChST": "ChST", "SRT": "SRT", "WIB": "WIB", "AWST": "AWST", "MST": "MST", "COST": "COST", "WITA": "WITA", "AKDT": "AKDT", "CST": "CST", "PDT": "PDT", "CAT": "CAT", "MYT": "MYT", "CLT": "CLT", "OEZ": "OEZ", "CHAST": "CHAST", "IST": "IST", "JST": "JST", "TMST": "TMST", "ART": "ART", "HENOMX": "HENOMX", "UYST": "UYST", "WARST": "WARST", "LHST": "LHST", "LHDT": "LHDT", "HNPMX": "HNPMX", "GYT": "GYT", "PST": "PST", "NZDT": "NZDT", "MESZ": "MESZ", "MDT": "MDT", "ARST": "ARST", "COT": "COT", "AEST": "AEST", "CDT": "CDT", "WIT": "WIT", "AWDT": "AWDT", "HKT": "HKT", "WESZ": "WESZ", "UYT": "UYT", "BOT": "BOT", "ECT": "ECT", "JDT": "JDT", "BT": "BT", "HEEG": "HEEG", "VET": "VET", "WART": "WART", "HAT": "HAT", "GFT": "GFT", "AKST": "AKST", "ACWST": "ACWST", "NZST": "NZST", "MEZ": "MEZ", "HNOG": "HNOG", "HEOG": "HEOG", "GMT": "GMT", "HNNOMX": "HNNOMX", "HEPM": "HEPM", "∅∅∅": "∅∅∅", "EAT": "EAT", "AST": "AST", "WAST": "WAST", "ACDT": "ACDT", "AEDT": "AEDT", "HNPM": "HNPM", "HECU": "HECU", "HAST": "HAST", "ACWDT": "ACWDT", "CLST": "CLST", "OESZ": "OESZ", "TMT": "TMT", "EST": "EST"}, + } +} + +// Locale returns the current translators string locale +func (bas *bas) Locale() string { + return bas.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bas' +func (bas *bas) PluralsCardinal() []locales.PluralRule { + return bas.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bas' +func (bas *bas) PluralsOrdinal() []locales.PluralRule { + return bas.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bas' +func (bas *bas) PluralsRange() []locales.PluralRule { + return bas.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bas' +func (bas *bas) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bas' +func (bas *bas) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bas' +func (bas *bas) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bas *bas) MonthAbbreviated(month time.Month) string { + return bas.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bas *bas) MonthsAbbreviated() []string { + return bas.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bas *bas) MonthNarrow(month time.Month) string { + return bas.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bas *bas) MonthsNarrow() []string { + return bas.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bas *bas) MonthWide(month time.Month) string { + return bas.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bas *bas) MonthsWide() []string { + return bas.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bas *bas) WeekdayAbbreviated(weekday time.Weekday) string { + return bas.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bas *bas) WeekdaysAbbreviated() []string { + return bas.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bas *bas) WeekdayNarrow(weekday time.Weekday) string { + return bas.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bas *bas) WeekdaysNarrow() []string { + return bas.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bas *bas) WeekdayShort(weekday time.Weekday) string { + return bas.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bas *bas) WeekdaysShort() []string { + return bas.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bas *bas) WeekdayWide(weekday time.Weekday) string { + return bas.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bas *bas) WeekdaysWide() []string { + return bas.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bas' and handles both Whole and Real numbers based on 'v' +func (bas *bas) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(bas.group) - 1; j >= 0; j-- { + b = append(b, bas.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bas' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bas *bas) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bas.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bas.percentSuffix...) + + b = append(b, bas.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bas' +func (bas *bas) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bas.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(bas.group) - 1; j >= 0; j-- { + b = append(b, bas.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bas.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bas' +// in accounting notation. +func (bas *bas) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bas.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(bas.group) - 1; j >= 0; j-- { + b = append(b, bas.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bas.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bas.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bas.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bas' +func (bas *bas) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bas' +func (bas *bas) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bas.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bas' +func (bas *bas) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bas' +func (bas *bas) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bas.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bas' +func (bas *bas) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bas' +func (bas *bas) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bas' +func (bas *bas) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bas' +func (bas *bas) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bas.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bas/bas_test.go b/vendor/github.com/go-playground/locales/bas/bas_test.go new file mode 100644 index 0000000000..1b9b2b87a5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bas/bas_test.go @@ -0,0 +1,1120 @@ +package bas + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bas" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bas_CM/bas_CM.go b/vendor/github.com/go-playground/locales/bas_CM/bas_CM.go new file mode 100644 index 0000000000..f405345c86 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bas_CM/bas_CM.go @@ -0,0 +1,575 @@ +package bas_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bas_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bas_CM' locale +func New() locales.Translator { + return &bas_CM{ + locale: "bas_CM", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "kɔn", "mac", "mat", "mto", "mpu", "hil", "nje", "hik", "dip", "bio", "may", "liɓ"}, + monthsNarrow: []string{"", "k", "m", "m", "m", "m", "h", "n", "h", "d", "b", "m", "l"}, + monthsWide: []string{"", "Kɔndɔŋ", "Màcɛ̂l", "Màtùmb", "Màtop", "M̀puyɛ", "Hìlòndɛ̀", "Njèbà", "Hìkaŋ", "Dìpɔ̀s", "Bìòôm", "Màyɛsèp", "Lìbuy li ńyèe"}, + daysAbbreviated: []string{"nɔy", "nja", "uum", "ŋge", "mbɔ", "kɔɔ", "jon"}, + daysNarrow: []string{"n", "n", "u", "ŋ", "m", "k", "j"}, + daysWide: []string{"ŋgwà nɔ̂y", "ŋgwà njaŋgumba", "ŋgwà ûm", "ŋgwà ŋgê", "ŋgwà mbɔk", "ŋgwà kɔɔ", "ŋgwà jôn"}, + periodsAbbreviated: []string{"I bikɛ̂glà", "I ɓugajɔp"}, + periodsWide: []string{"I bikɛ̂glà", "I ɓugajɔp"}, + erasAbbreviated: []string{"b.Y.K", "m.Y.K"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"bisū bi Yesù Krǐstò", "i mbūs Yesù Krǐstò"}, + timezones: map[string]string{"HNT": "HNT", "UYT": "UYT", "HEPMX": "HEPMX", "SRT": "SRT", "AWDT": "AWDT", "HAST": "HAST", "NZDT": "NZDT", "WITA": "WITA", "WIT": "WIT", "ACWST": "ACWST", "OEZ": "OEZ", "HNOG": "HNOG", "COT": "COT", "AKST": "AKST", "AEST": "AEST", "MDT": "MDT", "CAT": "CAT", "ACWDT": "ACWDT", "MESZ": "MESZ", "ACST": "ACST", "HAT": "HAT", "CHAST": "CHAST", "PDT": "PDT", "IST": "IST", "CLST": "CLST", "HEEG": "HEEG", "AEDT": "AEDT", "PST": "PST", "WAT": "WAT", "MEZ": "MEZ", "GMT": "GMT", "TMT": "TMT", "WAST": "WAST", "HKT": "HKT", "HENOMX": "HENOMX", "EAT": "EAT", "ADT": "ADT", "CLT": "CLT", "COST": "COST", "BT": "BT", "AKDT": "AKDT", "JST": "JST", "GFT": "GFT", "CDT": "CDT", "HADT": "HADT", "VET": "VET", "OESZ": "OESZ", "WART": "WART", "HKST": "HKST", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "∅∅∅": "∅∅∅", "UYST": "UYST", "LHST": "LHST", "AWST": "AWST", "SGT": "SGT", "AST": "AST", "WESZ": "WESZ", "MST": "MST", "ChST": "ChST", "WIB": "WIB", "ECT": "ECT", "WARST": "WARST", "ARST": "ARST", "EST": "EST", "HNPMX": "HNPMX", "BOT": "BOT", "NZST": "NZST", "JDT": "JDT", "WEZ": "WEZ", "MYT": "MYT", "HNPM": "HNPM", "HEPM": "HEPM", "GYT": "GYT", "HECU": "HECU", "ART": "ART", "HNEG": "HNEG", "SAST": "SAST", "LHDT": "LHDT", "CHADT": "CHADT", "TMST": "TMST", "EDT": "EDT", "HNCU": "HNCU", "CST": "CST", "HEOG": "HEOG"}, + } +} + +// Locale returns the current translators string locale +func (bas *bas_CM) Locale() string { + return bas.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bas_CM' +func (bas *bas_CM) PluralsCardinal() []locales.PluralRule { + return bas.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bas_CM' +func (bas *bas_CM) PluralsOrdinal() []locales.PluralRule { + return bas.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bas_CM' +func (bas *bas_CM) PluralsRange() []locales.PluralRule { + return bas.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bas_CM' +func (bas *bas_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bas_CM' +func (bas *bas_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bas_CM' +func (bas *bas_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bas *bas_CM) MonthAbbreviated(month time.Month) string { + return bas.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bas *bas_CM) MonthsAbbreviated() []string { + return bas.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bas *bas_CM) MonthNarrow(month time.Month) string { + return bas.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bas *bas_CM) MonthsNarrow() []string { + return bas.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bas *bas_CM) MonthWide(month time.Month) string { + return bas.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bas *bas_CM) MonthsWide() []string { + return bas.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bas *bas_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return bas.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bas *bas_CM) WeekdaysAbbreviated() []string { + return bas.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bas *bas_CM) WeekdayNarrow(weekday time.Weekday) string { + return bas.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bas *bas_CM) WeekdaysNarrow() []string { + return bas.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bas *bas_CM) WeekdayShort(weekday time.Weekday) string { + return bas.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bas *bas_CM) WeekdaysShort() []string { + return bas.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bas *bas_CM) WeekdayWide(weekday time.Weekday) string { + return bas.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bas *bas_CM) WeekdaysWide() []string { + return bas.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bas_CM' and handles both Whole and Real numbers based on 'v' +func (bas *bas_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(bas.group) - 1; j >= 0; j-- { + b = append(b, bas.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bas_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bas *bas_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bas.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bas.percentSuffix...) + + b = append(b, bas.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bas_CM' +func (bas *bas_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bas.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(bas.group) - 1; j >= 0; j-- { + b = append(b, bas.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bas.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bas_CM' +// in accounting notation. +func (bas *bas_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bas.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(bas.group) - 1; j >= 0; j-- { + b = append(b, bas.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bas.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bas.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bas.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bas_CM' +func (bas *bas_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bas_CM' +func (bas *bas_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bas.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bas_CM' +func (bas *bas_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bas_CM' +func (bas *bas_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bas.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bas_CM' +func (bas *bas_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bas_CM' +func (bas *bas_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bas_CM' +func (bas *bas_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bas_CM' +func (bas *bas_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bas.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bas_CM/bas_CM_test.go b/vendor/github.com/go-playground/locales/bas_CM/bas_CM_test.go new file mode 100644 index 0000000000..cda7c58a9c --- /dev/null +++ b/vendor/github.com/go-playground/locales/bas_CM/bas_CM_test.go @@ -0,0 +1,1120 @@ +package bas_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bas_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/be/be.go b/vendor/github.com/go-playground/locales/be/be.go new file mode 100644 index 0000000000..284c8bcd15 --- /dev/null +++ b/vendor/github.com/go-playground/locales/be/be.go @@ -0,0 +1,658 @@ +package be + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type be struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'be' locale +func New() locales.Translator { + return &be{ + locale: "be", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{4, 6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "Br", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "₽", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "сту", "лют", "сак", "кра", "мая", "чэр", "ліп", "жні", "вер", "кас", "ліс", "сне"}, + monthsNarrow: []string{"", "с", "л", "с", "к", "м", "ч", "л", "ж", "в", "к", "л", "с"}, + monthsWide: []string{"", "студзеня", "лютага", "сакавіка", "красавіка", "мая", "чэрвеня", "ліпеня", "жніўня", "верасня", "кастрычніка", "лістапада", "снежня"}, + daysAbbreviated: []string{"нд", "пн", "аў", "ср", "чц", "пт", "сб"}, + daysNarrow: []string{"н", "п", "а", "с", "ч", "п", "с"}, + daysShort: []string{"нд", "пн", "аў", "ср", "чц", "пт", "сб"}, + daysWide: []string{"нядзеля", "панядзелак", "аўторак", "серада", "чацвер", "пятніца", "субота"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"да н.э.", "н.э."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"да нараджэння Хрыстова", "ад нараджэння Хрыстова"}, + timezones: map[string]string{"WAST": "Заходнеафрыканскі летні час", "WIT": "Усходнеінданезійскі час", "HAST": "Гавайска-Алеуцкі стандартны час", "MEZ": "Цэнтральнаеўрапейскі стандартны час", "MESZ": "Цэнтральнаеўрапейскі летні час", "VET": "Венесуэльскі час", "WESZ": "Заходнееўрапейскі летні час", "ARST": "Аргенцінскі летні час", "AKDT": "Летні час Аляскі", "HNCU": "Стандартны час Кубы", "HADT": "Гавайска-Алеуцкі летні час", "HNEG": "Стандартны час Усходняй Грэнландыі", "HEPMX": "Мексіканскі ціхаакіянскі летні час", "IST": "Час Індыі", "OESZ": "Усходнееўрапейскі летні час", "GMT": "Час па Грынвічы", "MYT": "Час Малайзіі", "ACDT": "Летні час цэнтральнай Аўстраліі", "HAT": "Ньюфаўндлендскі летні час", "AWST": "Стандартны час заходняй Аўстраліі", "CHADT": "Летні час Чатэма", "CAT": "Цэнтральнаафрыканскі час", "WART": "Стандартны час Заходняй Аргенціны", "COT": "Калумбійскі стандартны час", "HEEG": "Летні час Усходняй Грэнландыі", "HECU": "Летні час Кубы", "CDT": "Паўночнаамерыканскі цэнтральны летні час", "ACWST": "Заходні стандартны час Цэнтральнай Аўстраліі", "CLST": "Чылійскі летні час", "HNOG": "Стандартны час Заходняй Грэнландыі", "ACST": "Стандартны час цэнтральнай Аўстраліі", "PDT": "Ціхаакіянскі летні час", "ACWDT": "Заходні летні час Цэнтральнай Аўстраліі", "EDT": "Паўночнаамерыканскі ўсходні летні час", "HKT": "Стандартны час Ганконга", "HNT": "Ньюфаўндлендскі стандартны час", "LHDT": "Летні час Лорд-Хау", "AST": "Атлантычны стандартны час", "BT": "Час Бутана", "SRT": "Час Сурынама", "CST": "Паўночнаамерыканскі цэнтральны стандартны час", "CHAST": "Стандартны час Чатэма", "WARST": "Летні час Заходняй Аргенціны", "ADT": "Атлантычны летні час", "WEZ": "Заходнееўрапейскі стандартны час", "TMT": "Стандартны час Туркменістана", "MDT": "MDT", "HKST": "Летні час Ганконга", "HNNOMX": "Паўночна-заходні мексіканскі стандартны час", "AEDT": "Летні час усходняй Аўстраліі", "EAT": "Усходнеафрыканскі час", "PST": "Ціхаакіянскі стандартны час", "TMST": "Летні час Туркменістана", "MST": "MST", "WAT": "Заходнеафрыканскі стандартны час", "COST": "Калумбійскі летні час", "∅∅∅": "Перуанскі летні час", "HEPM": "Стандартны летні час Сен-П’ер і Мікелон", "LHST": "Стандартны час Лорд-Хау", "BOT": "Балівійскі час", "EST": "Паўночнаамерыканскі ўсходні стандартны час", "GFT": "Час Французскай Гвіяны", "WITA": "Цэнтральнаінданезійскі час", "AKST": "Стандартны час Аляскі", "HNPM": "Стандартны час Сен-П’ер і Мікелон", "HEOG": "Летні час Заходняй Грэнландыі", "OEZ": "Усходнееўрапейскі стандартны час", "HENOMX": "Паўночна-заходні мексіканскі летні час", "ECT": "Эквадорскі час", "AEST": "Стандартны час усходняй Аўстраліі", "HNPMX": "Мексіканскі ціхаакіянскі стандатны час", "WIB": "Заходнеінданезійскі час", "JDT": "Летні час Японіі", "ART": "Аргенцінскі стандартны час", "ChST": "Час Чамора", "UYT": "Уругвайскі стандартны час", "SAST": "Паўднёваафрыканскі час", "SGT": "Сінгапурскі час", "CLT": "Чылійскі стандартны час", "AWDT": "Летні час заходняй Аўстраліі", "NZST": "Стандартны час Новай Зеландыі", "UYST": "Уругвайскі летні час", "GYT": "Час Гаяны", "NZDT": "Летні час Новай Зеландыі", "JST": "Стандартны час Японіі"}, + } +} + +// Locale returns the current translators string locale +func (be *be) Locale() string { + return be.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'be' +func (be *be) PluralsCardinal() []locales.PluralRule { + return be.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'be' +func (be *be) PluralsOrdinal() []locales.PluralRule { + return be.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'be' +func (be *be) PluralsRange() []locales.PluralRule { + return be.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'be' +func (be *be) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 >= 2 && nMod10 <= 4 && (nMod100 < 12 || nMod100 > 14) { + return locales.PluralRuleFew + } else if (nMod10 == 0) || (nMod10 >= 5 && nMod10 <= 9) || (nMod100 >= 11 && nMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'be' +func (be *be) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if (nMod10 == 2 || nMod10 == 3) && (nMod100 != 12 && nMod100 != 13) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'be' +func (be *be) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := be.CardinalPluralRule(num1, v1) + end := be.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (be *be) MonthAbbreviated(month time.Month) string { + return be.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (be *be) MonthsAbbreviated() []string { + return be.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (be *be) MonthNarrow(month time.Month) string { + return be.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (be *be) MonthsNarrow() []string { + return be.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (be *be) MonthWide(month time.Month) string { + return be.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (be *be) MonthsWide() []string { + return be.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (be *be) WeekdayAbbreviated(weekday time.Weekday) string { + return be.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (be *be) WeekdaysAbbreviated() []string { + return be.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (be *be) WeekdayNarrow(weekday time.Weekday) string { + return be.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (be *be) WeekdaysNarrow() []string { + return be.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (be *be) WeekdayShort(weekday time.Weekday) string { + return be.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (be *be) WeekdaysShort() []string { + return be.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (be *be) WeekdayWide(weekday time.Weekday) string { + return be.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (be *be) WeekdaysWide() []string { + return be.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'be' and handles both Whole and Real numbers based on 'v' +func (be *be) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, be.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(be.group) - 1; j >= 0; j-- { + b = append(b, be.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, be.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'be' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (be *be) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, be.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, be.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, be.percentSuffix...) + + b = append(b, be.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'be' +func (be *be) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := be.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, be.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(be.group) - 1; j >= 0; j-- { + b = append(b, be.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, be.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, be.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, be.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'be' +// in accounting notation. +func (be *be) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := be.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, be.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(be.group) - 1; j >= 0; j-- { + b = append(b, be.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, be.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, be.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, be.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, be.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'be' +func (be *be) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'be' +func (be *be) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'be' +func (be *be) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, be.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'be' +func (be *be) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, be.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, be.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'be' +func (be *be) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, be.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'be' +func (be *be) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, be.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, be.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'be' +func (be *be) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, be.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, be.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'be' +func (be *be) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, be.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, be.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := be.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/be/be_test.go b/vendor/github.com/go-playground/locales/be/be_test.go new file mode 100644 index 0000000000..d34710dfff --- /dev/null +++ b/vendor/github.com/go-playground/locales/be/be_test.go @@ -0,0 +1,1120 @@ +package be + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "be" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/be_BY/be_BY.go b/vendor/github.com/go-playground/locales/be_BY/be_BY.go new file mode 100644 index 0000000000..382d670ff0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/be_BY/be_BY.go @@ -0,0 +1,658 @@ +package be_BY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type be_BY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'be_BY' locale +func New() locales.Translator { + return &be_BY{ + locale: "be_BY", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{4, 6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "сту", "лют", "сак", "кра", "мая", "чэр", "ліп", "жні", "вер", "кас", "ліс", "сне"}, + monthsNarrow: []string{"", "с", "л", "с", "к", "м", "ч", "л", "ж", "в", "к", "л", "с"}, + monthsWide: []string{"", "студзеня", "лютага", "сакавіка", "красавіка", "мая", "чэрвеня", "ліпеня", "жніўня", "верасня", "кастрычніка", "лістапада", "снежня"}, + daysAbbreviated: []string{"нд", "пн", "аў", "ср", "чц", "пт", "сб"}, + daysNarrow: []string{"н", "п", "а", "с", "ч", "п", "с"}, + daysShort: []string{"нд", "пн", "аў", "ср", "чц", "пт", "сб"}, + daysWide: []string{"нядзеля", "панядзелак", "аўторак", "серада", "чацвер", "пятніца", "субота"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"да н.э.", "н.э."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"да нараджэння Хрыстова", "ад нараджэння Хрыстова"}, + timezones: map[string]string{"ADT": "Атлантычны летні час", "UYST": "Уругвайскі летні час", "EAT": "Усходнеафрыканскі час", "NZST": "Стандартны час Новай Зеландыі", "CHADT": "Летні час Чатэма", "AST": "Атлантычны стандартны час", "ACST": "Стандартны час цэнтральнай Аўстраліі", "AKDT": "Летні час Аляскі", "WIT": "Усходнеінданезійскі час", "GYT": "Час Гаяны", "HNNOMX": "Паўночна-заходні мексіканскі стандартны час", "HNEG": "Стандартны час Усходняй Грэнландыі", "AKST": "Стандартны час Аляскі", "CLT": "Чылійскі стандартны час", "OESZ": "Усходнееўрапейскі летні час", "HAT": "Ньюфаўндлендскі летні час", "HEPMX": "Мексіканскі ціхаакіянскі летні час", "ECT": "Эквадорскі час", "OEZ": "Усходнееўрапейскі стандартны час", "ARST": "Аргенцінскі летні час", "HECU": "Летні час Кубы", "CAT": "Цэнтральнаафрыканскі час", "ACWDT": "Заходні летні час Цэнтральнай Аўстраліі", "PST": "Ціхаакіянскі стандартны час", "MESZ": "Цэнтральнаеўрапейскі летні час", "VET": "Венесуэльскі час", "HNT": "Ньюфаўндлендскі стандартны час", "LHST": "Стандартны час Лорд-Хау", "CHAST": "Стандартны час Чатэма", "CLST": "Чылійскі летні час", "SAST": "Паўднёваафрыканскі час", "LHDT": "Летні час Лорд-Хау", "JST": "Стандартны час Японіі", "HKST": "Летні час Ганконга", "GFT": "Час Французскай Гвіяны", "HNCU": "Стандартны час Кубы", "WESZ": "Заходнееўрапейскі летні час", "COT": "Калумбійскі стандартны час", "BT": "Час Бутана", "NZDT": "Летні час Новай Зеландыі", "IST": "Час Індыі", "MEZ": "Цэнтральнаеўрапейскі стандартны час", "WARST": "Летні час Заходняй Аргенціны", "EDT": "Паўночнаамерыканскі ўсходні летні час", "HNPMX": "Мексіканскі ціхаакіянскі стандатны час", "WIB": "Заходнеінданезійскі час", "BOT": "Балівійскі час", "UYT": "Уругвайскі стандартны час", "CDT": "Паўночнаамерыканскі цэнтральны летні час", "AWDT": "Летні час заходняй Аўстраліі", "PDT": "Ціхаакіянскі летні час", "JDT": "Летні час Японіі", "COST": "Калумбійскі летні час", "AEST": "Стандартны час усходняй Аўстраліі", "ChST": "Час Чамора", "HNOG": "Стандартны час Заходняй Грэнландыі", "EST": "Паўночнаамерыканскі ўсходні стандартны час", "TMST": "Летні час Туркменістана", "WAT": "Заходнеафрыканскі стандартны час", "AWST": "Стандартны час заходняй Аўстраліі", "SGT": "Сінгапурскі час", "GMT": "Час па Грынвічы", "HEPM": "Стандартны летні час Сен-П’ер і Мікелон", "WART": "Стандартны час Заходняй Аргенціны", "TMT": "Стандартны час Туркменістана", "SRT": "Час Сурынама", "CST": "Паўночнаамерыканскі цэнтральны стандартны час", "HAST": "Гавайска-Алеуцкі стандартны час", "ACWST": "Заходні стандартны час Цэнтральнай Аўстраліі", "HEOG": "Летні час Заходняй Грэнландыі", "HEEG": "Летні час Усходняй Грэнландыі", "MST": "Паўночнаамерыканскі горны стандартны час", "HNPM": "Стандартны час Сен-П’ер і Мікелон", "ART": "Аргенцінскі стандартны час", "HADT": "Гавайска-Алеуцкі летні час", "WAST": "Заходнеафрыканскі летні час", "ACDT": "Летні час цэнтральнай Аўстраліі", "WITA": "Цэнтральнаінданезійскі час", "AEDT": "Летні час усходняй Аўстраліі", "WEZ": "Заходнееўрапейскі стандартны час", "MYT": "Час Малайзіі", "HKT": "Стандартны час Ганконга", "HENOMX": "Паўночна-заходні мексіканскі летні час", "∅∅∅": "Перуанскі летні час", "MDT": "Паўночнаамерыканскі горны летні час"}, + } +} + +// Locale returns the current translators string locale +func (be *be_BY) Locale() string { + return be.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'be_BY' +func (be *be_BY) PluralsCardinal() []locales.PluralRule { + return be.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'be_BY' +func (be *be_BY) PluralsOrdinal() []locales.PluralRule { + return be.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'be_BY' +func (be *be_BY) PluralsRange() []locales.PluralRule { + return be.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'be_BY' +func (be *be_BY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 >= 2 && nMod10 <= 4 && (nMod100 < 12 || nMod100 > 14) { + return locales.PluralRuleFew + } else if (nMod10 == 0) || (nMod10 >= 5 && nMod10 <= 9) || (nMod100 >= 11 && nMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'be_BY' +func (be *be_BY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if (nMod10 == 2 || nMod10 == 3) && (nMod100 != 12 && nMod100 != 13) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'be_BY' +func (be *be_BY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := be.CardinalPluralRule(num1, v1) + end := be.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (be *be_BY) MonthAbbreviated(month time.Month) string { + return be.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (be *be_BY) MonthsAbbreviated() []string { + return be.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (be *be_BY) MonthNarrow(month time.Month) string { + return be.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (be *be_BY) MonthsNarrow() []string { + return be.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (be *be_BY) MonthWide(month time.Month) string { + return be.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (be *be_BY) MonthsWide() []string { + return be.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (be *be_BY) WeekdayAbbreviated(weekday time.Weekday) string { + return be.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (be *be_BY) WeekdaysAbbreviated() []string { + return be.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (be *be_BY) WeekdayNarrow(weekday time.Weekday) string { + return be.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (be *be_BY) WeekdaysNarrow() []string { + return be.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (be *be_BY) WeekdayShort(weekday time.Weekday) string { + return be.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (be *be_BY) WeekdaysShort() []string { + return be.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (be *be_BY) WeekdayWide(weekday time.Weekday) string { + return be.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (be *be_BY) WeekdaysWide() []string { + return be.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'be_BY' and handles both Whole and Real numbers based on 'v' +func (be *be_BY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, be.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(be.group) - 1; j >= 0; j-- { + b = append(b, be.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, be.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'be_BY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (be *be_BY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, be.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, be.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, be.percentSuffix...) + + b = append(b, be.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'be_BY' +func (be *be_BY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := be.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, be.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(be.group) - 1; j >= 0; j-- { + b = append(b, be.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, be.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, be.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, be.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'be_BY' +// in accounting notation. +func (be *be_BY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := be.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, be.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(be.group) - 1; j >= 0; j-- { + b = append(b, be.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, be.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, be.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, be.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, be.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'be_BY' +func (be *be_BY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'be_BY' +func (be *be_BY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'be_BY' +func (be *be_BY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, be.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'be_BY' +func (be *be_BY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, be.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, be.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'be_BY' +func (be *be_BY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, be.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'be_BY' +func (be *be_BY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, be.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, be.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'be_BY' +func (be *be_BY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, be.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, be.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'be_BY' +func (be *be_BY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, be.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, be.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := be.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/be_BY/be_BY_test.go b/vendor/github.com/go-playground/locales/be_BY/be_BY_test.go new file mode 100644 index 0000000000..e93f11a2d0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/be_BY/be_BY_test.go @@ -0,0 +1,1120 @@ +package be_BY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "be_BY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bem/bem.go b/vendor/github.com/go-playground/locales/bem/bem.go new file mode 100644 index 0000000000..eb604a77f6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bem/bem.go @@ -0,0 +1,561 @@ +package bem + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bem struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bem' locale +func New() locales.Translator { + return &bem{ + locale: "bem", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "K", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Epr", "Mei", "Jun", "Jul", "Oga", "Sep", "Okt", "Nov", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "E", "M", "J", "J", "O", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Epreo", "Mei", "Juni", "Julai", "Ogasti", "Septemba", "Oktoba", "Novemba", "Disemba"}, + daysWide: []string{"Pa Mulungu", "Palichimo", "Palichibuli", "Palichitatu", "Palichine", "Palichisano", "Pachibelushi"}, + periodsAbbreviated: []string{"uluchelo", "akasuba"}, + periodsWide: []string{"uluchelo", "akasuba"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Before Yesu", "After Yesu"}, + timezones: map[string]string{"ADT": "ADT", "TMT": "TMT", "ARST": "ARST", "HENOMX": "HENOMX", "HNCU": "HNCU", "AWST": "AWST", "JST": "JST", "WARST": "WARST", "UYST": "UYST", "LHST": "LHST", "GYT": "GYT", "MYT": "MYT", "CLST": "CLST", "COST": "COST", "HEPM": "HEPM", "HNNOMX": "HNNOMX", "JDT": "JDT", "WESZ": "WESZ", "HNOG": "HNOG", "EDT": "EDT", "AKDT": "AKDT", "SRT": "SRT", "NZDT": "NZDT", "MDT": "MDT", "EST": "EST", "BT": "BT", "AST": "AST", "BOT": "BOT", "CHAST": "CHAST", "VET": "VET", "GMT": "GMT", "ACDT": "ACDT", "EAT": "EAT", "WEZ": "WEZ", "MST": "MST", "HKT": "HKT", "SAST": "SAST", "WIB": "WIB", "ACWDT": "ACWDT", "CAT": "CAT", "ACST": "ACST", "HNT": "HNT", "GFT": "GFT", "LHDT": "LHDT", "HAST": "HAST", "HADT": "HADT", "NZST": "NZST", "OESZ": "OESZ", "AEST": "AEST", "AEDT": "AEDT", "WITA": "WITA", "CDT": "CDT", "PST": "PST", "MEZ": "MEZ", "WART": "WART", "AKST": "AKST", "CHADT": "CHADT", "ACWST": "ACWST", "MESZ": "MESZ", "ART": "ART", "ChST": "ChST", "HECU": "HECU", "SGT": "SGT", "CLT": "CLT", "HEOG": "HEOG", "HKST": "HKST", "∅∅∅": "∅∅∅", "CST": "CST", "WAT": "WAT", "WAST": "WAST", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "WIT": "WIT", "ECT": "ECT", "HNEG": "HNEG", "UYT": "UYT", "HAT": "HAT", "HNPM": "HNPM", "PDT": "PDT", "IST": "IST", "OEZ": "OEZ", "COT": "COT", "AWDT": "AWDT", "TMST": "TMST", "HEEG": "HEEG"}, + } +} + +// Locale returns the current translators string locale +func (bem *bem) Locale() string { + return bem.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bem' +func (bem *bem) PluralsCardinal() []locales.PluralRule { + return bem.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bem' +func (bem *bem) PluralsOrdinal() []locales.PluralRule { + return bem.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bem' +func (bem *bem) PluralsRange() []locales.PluralRule { + return bem.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bem' +func (bem *bem) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bem' +func (bem *bem) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bem' +func (bem *bem) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bem *bem) MonthAbbreviated(month time.Month) string { + return bem.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bem *bem) MonthsAbbreviated() []string { + return bem.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bem *bem) MonthNarrow(month time.Month) string { + return bem.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bem *bem) MonthsNarrow() []string { + return bem.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bem *bem) MonthWide(month time.Month) string { + return bem.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bem *bem) MonthsWide() []string { + return bem.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bem *bem) WeekdayAbbreviated(weekday time.Weekday) string { + return bem.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bem *bem) WeekdaysAbbreviated() []string { + return bem.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bem *bem) WeekdayNarrow(weekday time.Weekday) string { + return bem.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bem *bem) WeekdaysNarrow() []string { + return bem.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bem *bem) WeekdayShort(weekday time.Weekday) string { + return bem.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bem *bem) WeekdaysShort() []string { + return bem.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bem *bem) WeekdayWide(weekday time.Weekday) string { + return bem.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bem *bem) WeekdaysWide() []string { + return bem.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bem' and handles both Whole and Real numbers based on 'v' +func (bem *bem) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bem' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bem *bem) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bem' +func (bem *bem) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bem.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bem.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bem.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, bem.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bem.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bem' +// in accounting notation. +func (bem *bem) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bem.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bem.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bem.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, bem.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bem.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bem.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bem' +func (bem *bem) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bem' +func (bem *bem) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bem.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bem' +func (bem *bem) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bem.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bem' +func (bem *bem) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bem.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bem.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bem' +func (bem *bem) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bem.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bem.periodsAbbreviated[0]...) + } else { + b = append(b, bem.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bem' +func (bem *bem) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bem.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bem.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bem.periodsAbbreviated[0]...) + } else { + b = append(b, bem.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bem' +func (bem *bem) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bem.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bem.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bem.periodsAbbreviated[0]...) + } else { + b = append(b, bem.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bem' +func (bem *bem) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bem.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bem.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bem.periodsAbbreviated[0]...) + } else { + b = append(b, bem.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bem.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bem/bem_test.go b/vendor/github.com/go-playground/locales/bem/bem_test.go new file mode 100644 index 0000000000..1297500244 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bem/bem_test.go @@ -0,0 +1,1120 @@ +package bem + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bem" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bem_ZM/bem_ZM.go b/vendor/github.com/go-playground/locales/bem_ZM/bem_ZM.go new file mode 100644 index 0000000000..e21560c32b --- /dev/null +++ b/vendor/github.com/go-playground/locales/bem_ZM/bem_ZM.go @@ -0,0 +1,561 @@ +package bem_ZM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bem_ZM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bem_ZM' locale +func New() locales.Translator { + return &bem_ZM{ + locale: "bem_ZM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Epr", "Mei", "Jun", "Jul", "Oga", "Sep", "Okt", "Nov", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "E", "M", "J", "J", "O", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Epreo", "Mei", "Juni", "Julai", "Ogasti", "Septemba", "Oktoba", "Novemba", "Disemba"}, + daysWide: []string{"Pa Mulungu", "Palichimo", "Palichibuli", "Palichitatu", "Palichine", "Palichisano", "Pachibelushi"}, + periodsAbbreviated: []string{"uluchelo", "akasuba"}, + periodsWide: []string{"uluchelo", "akasuba"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Before Yesu", "After Yesu"}, + timezones: map[string]string{"ACWDT": "ACWDT", "TMT": "TMT", "MDT": "MDT", "ART": "ART", "WAST": "WAST", "ACST": "ACST", "HNT": "HNT", "CST": "CST", "HNPM": "HNPM", "WITA": "WITA", "HADT": "HADT", "WESZ": "WESZ", "HEEG": "HEEG", "UYT": "UYT", "HNPMX": "HNPMX", "WAT": "WAT", "EDT": "EDT", "COST": "COST", "HENOMX": "HENOMX", "AEST": "AEST", "ChST": "ChST", "HEPM": "HEPM", "GMT": "GMT", "HEPMX": "HEPMX", "CHAST": "CHAST", "ADT": "ADT", "CLST": "CLST", "COT": "COT", "SAST": "SAST", "GYT": "GYT", "CHADT": "CHADT", "OESZ": "OESZ", "MYT": "MYT", "HEOG": "HEOG", "MST": "MST", "AKST": "AKST", "SRT": "SRT", "NZST": "NZST", "CAT": "CAT", "AEDT": "AEDT", "HAST": "HAST", "WIT": "WIT", "SGT": "SGT", "MESZ": "MESZ", "JDT": "JDT", "CLT": "CLT", "TMST": "TMST", "HECU": "HECU", "VET": "VET", "JST": "JST", "WART": "WART", "AKDT": "AKDT", "UYST": "UYST", "ECT": "ECT", "EAT": "EAT", "HNCU": "HNCU", "IST": "IST", "MEZ": "MEZ", "WARST": "WARST", "HNOG": "HNOG", "BT": "BT", "LHDT": "LHDT", "LHST": "LHST", "ARST": "ARST", "WIB": "WIB", "AWST": "AWST", "BOT": "BOT", "ACWST": "ACWST", "AST": "AST", "OEZ": "OEZ", "EST": "EST", "∅∅∅": "∅∅∅", "HKT": "HKT", "PDT": "PDT", "WEZ": "WEZ", "HNNOMX": "HNNOMX", "HNEG": "HNEG", "CDT": "CDT", "PST": "PST", "NZDT": "NZDT", "HKST": "HKST", "ACDT": "ACDT", "HAT": "HAT", "GFT": "GFT", "AWDT": "AWDT"}, + } +} + +// Locale returns the current translators string locale +func (bem *bem_ZM) Locale() string { + return bem.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bem_ZM' +func (bem *bem_ZM) PluralsCardinal() []locales.PluralRule { + return bem.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bem_ZM' +func (bem *bem_ZM) PluralsOrdinal() []locales.PluralRule { + return bem.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bem_ZM' +func (bem *bem_ZM) PluralsRange() []locales.PluralRule { + return bem.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bem_ZM' +func (bem *bem_ZM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bem_ZM' +func (bem *bem_ZM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bem_ZM' +func (bem *bem_ZM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bem *bem_ZM) MonthAbbreviated(month time.Month) string { + return bem.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bem *bem_ZM) MonthsAbbreviated() []string { + return bem.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bem *bem_ZM) MonthNarrow(month time.Month) string { + return bem.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bem *bem_ZM) MonthsNarrow() []string { + return bem.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bem *bem_ZM) MonthWide(month time.Month) string { + return bem.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bem *bem_ZM) MonthsWide() []string { + return bem.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bem *bem_ZM) WeekdayAbbreviated(weekday time.Weekday) string { + return bem.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bem *bem_ZM) WeekdaysAbbreviated() []string { + return bem.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bem *bem_ZM) WeekdayNarrow(weekday time.Weekday) string { + return bem.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bem *bem_ZM) WeekdaysNarrow() []string { + return bem.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bem *bem_ZM) WeekdayShort(weekday time.Weekday) string { + return bem.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bem *bem_ZM) WeekdaysShort() []string { + return bem.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bem *bem_ZM) WeekdayWide(weekday time.Weekday) string { + return bem.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bem *bem_ZM) WeekdaysWide() []string { + return bem.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bem_ZM' and handles both Whole and Real numbers based on 'v' +func (bem *bem_ZM) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bem_ZM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bem *bem_ZM) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bem_ZM' +func (bem *bem_ZM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bem.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bem.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bem.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, bem.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bem.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bem_ZM' +// in accounting notation. +func (bem *bem_ZM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bem.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bem.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bem.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, bem.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bem.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bem.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bem_ZM' +func (bem *bem_ZM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bem_ZM' +func (bem *bem_ZM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bem.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bem_ZM' +func (bem *bem_ZM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bem.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bem_ZM' +func (bem *bem_ZM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bem.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bem.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bem_ZM' +func (bem *bem_ZM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bem.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bem.periodsAbbreviated[0]...) + } else { + b = append(b, bem.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bem_ZM' +func (bem *bem_ZM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bem.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bem.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bem.periodsAbbreviated[0]...) + } else { + b = append(b, bem.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bem_ZM' +func (bem *bem_ZM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bem.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bem.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bem.periodsAbbreviated[0]...) + } else { + b = append(b, bem.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bem_ZM' +func (bem *bem_ZM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bem.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bem.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bem.periodsAbbreviated[0]...) + } else { + b = append(b, bem.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bem.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bem_ZM/bem_ZM_test.go b/vendor/github.com/go-playground/locales/bem_ZM/bem_ZM_test.go new file mode 100644 index 0000000000..b8acf92108 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bem_ZM/bem_ZM_test.go @@ -0,0 +1,1120 @@ +package bem_ZM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bem_ZM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bez/bez.go b/vendor/github.com/go-playground/locales/bez/bez.go new file mode 100644 index 0000000000..ae9e6f1d8f --- /dev/null +++ b/vendor/github.com/go-playground/locales/bez/bez.go @@ -0,0 +1,512 @@ +package bez + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bez struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bez' locale +func New() locales.Translator { + return &bez{ + locale: "bez", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Hut", "Vil", "Dat", "Tai", "Han", "Sit", "Sab", "Nan", "Tis", "Kum", "Kmj", "Kmb"}, + monthsNarrow: []string{"", "H", "V", "D", "T", "H", "S", "S", "N", "T", "K", "K", "K"}, + monthsWide: []string{"", "pa mwedzi gwa hutala", "pa mwedzi gwa wuvili", "pa mwedzi gwa wudatu", "pa mwedzi gwa wutai", "pa mwedzi gwa wuhanu", "pa mwedzi gwa sita", "pa mwedzi gwa saba", "pa mwedzi gwa nane", "pa mwedzi gwa tisa", "pa mwedzi gwa kumi", "pa mwedzi gwa kumi na moja", "pa mwedzi gwa kumi na mbili"}, + daysAbbreviated: []string{"Mul", "Vil", "Hiv", "Hid", "Hit", "Hih", "Lem"}, + daysNarrow: []string{"M", "J", "H", "H", "H", "W", "J"}, + daysWide: []string{"pa mulungu", "pa shahuviluha", "pa hivili", "pa hidatu", "pa hitayi", "pa hihanu", "pa shahulembela"}, + periodsAbbreviated: []string{"pamilau", "pamunyi"}, + periodsWide: []string{"pamilau", "pamunyi"}, + erasAbbreviated: []string{"KM", "BM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Mtwaa", "Baada ya Mtwaa"}, + timezones: map[string]string{"VET": "VET", "HEOG": "HEOG", "GMT": "GMT", "TMST": "TMST", "GFT": "GFT", "HNCU": "HNCU", "HAST": "HAST", "HADT": "HADT", "IST": "IST", "EDT": "EDT", "HEPM": "HEPM", "ACWST": "ACWST", "WAST": "WAST", "AKDT": "AKDT", "LHST": "LHST", "HNEG": "HNEG", "ChST": "ChST", "HAT": "HAT", "WITA": "WITA", "PDT": "PDT", "WARST": "WARST", "CLST": "CLST", "TMT": "TMT", "ACST": "ACST", "BT": "BT", "CHADT": "CHADT", "AKST": "AKST", "HNPM": "HNPM", "SAST": "SAST", "LHDT": "LHDT", "HEPMX": "HEPMX", "AWST": "AWST", "NZST": "NZST", "ACDT": "ACDT", "EAT": "EAT", "CHAST": "CHAST", "JDT": "JDT", "CLT": "CLT", "MDT": "MDT", "HKT": "HKT", "CST": "CST", "AWDT": "AWDT", "OEZ": "OEZ", "ART": "ART", "HKST": "HKST", "AEST": "AEST", "WIB": "WIB", "OESZ": "OESZ", "AEDT": "AEDT", "UYT": "UYT", "GYT": "GYT", "ECT": "ECT", "WEZ": "WEZ", "WART": "WART", "WESZ": "WESZ", "EST": "EST", "UYST": "UYST", "CDT": "CDT", "∅∅∅": "∅∅∅", "NZDT": "NZDT", "WAT": "WAT", "HNT": "HNT", "HEEG": "HEEG", "SRT": "SRT", "PST": "PST", "JST": "JST", "HNOG": "HNOG", "AST": "AST", "BOT": "BOT", "MEZ": "MEZ", "ADT": "ADT", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "HECU": "HECU", "WIT": "WIT", "MESZ": "MESZ", "MST": "MST", "ARST": "ARST", "SGT": "SGT", "CAT": "CAT", "ACWDT": "ACWDT", "MYT": "MYT", "COT": "COT", "COST": "COST", "HENOMX": "HENOMX"}, + } +} + +// Locale returns the current translators string locale +func (bez *bez) Locale() string { + return bez.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bez' +func (bez *bez) PluralsCardinal() []locales.PluralRule { + return bez.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bez' +func (bez *bez) PluralsOrdinal() []locales.PluralRule { + return bez.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bez' +func (bez *bez) PluralsRange() []locales.PluralRule { + return bez.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bez' +func (bez *bez) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bez' +func (bez *bez) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bez' +func (bez *bez) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bez *bez) MonthAbbreviated(month time.Month) string { + return bez.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bez *bez) MonthsAbbreviated() []string { + return bez.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bez *bez) MonthNarrow(month time.Month) string { + return bez.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bez *bez) MonthsNarrow() []string { + return bez.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bez *bez) MonthWide(month time.Month) string { + return bez.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bez *bez) MonthsWide() []string { + return bez.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bez *bez) WeekdayAbbreviated(weekday time.Weekday) string { + return bez.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bez *bez) WeekdaysAbbreviated() []string { + return bez.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bez *bez) WeekdayNarrow(weekday time.Weekday) string { + return bez.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bez *bez) WeekdaysNarrow() []string { + return bez.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bez *bez) WeekdayShort(weekday time.Weekday) string { + return bez.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bez *bez) WeekdaysShort() []string { + return bez.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bez *bez) WeekdayWide(weekday time.Weekday) string { + return bez.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bez *bez) WeekdaysWide() []string { + return bez.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bez' and handles both Whole and Real numbers based on 'v' +func (bez *bez) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bez' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bez *bez) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bez' +func (bez *bez) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bez.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bez.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bez.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bez.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bez.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bez' +// in accounting notation. +func (bez *bez) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bez.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bez.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bez.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bez.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bez.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bez' +func (bez *bez) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bez' +func (bez *bez) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bez.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bez' +func (bez *bez) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bez.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bez' +func (bez *bez) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bez.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bez.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bez' +func (bez *bez) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bez.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bez' +func (bez *bez) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bez.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bez.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bez' +func (bez *bez) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bez.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bez.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bez' +func (bez *bez) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bez.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bez.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bez.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bez/bez_test.go b/vendor/github.com/go-playground/locales/bez/bez_test.go new file mode 100644 index 0000000000..c6a45ba8c4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bez/bez_test.go @@ -0,0 +1,1120 @@ +package bez + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bez" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bez_TZ/bez_TZ.go b/vendor/github.com/go-playground/locales/bez_TZ/bez_TZ.go new file mode 100644 index 0000000000..487aa53bfa --- /dev/null +++ b/vendor/github.com/go-playground/locales/bez_TZ/bez_TZ.go @@ -0,0 +1,512 @@ +package bez_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bez_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bez_TZ' locale +func New() locales.Translator { + return &bez_TZ{ + locale: "bez_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Hut", "Vil", "Dat", "Tai", "Han", "Sit", "Sab", "Nan", "Tis", "Kum", "Kmj", "Kmb"}, + monthsNarrow: []string{"", "H", "V", "D", "T", "H", "S", "S", "N", "T", "K", "K", "K"}, + monthsWide: []string{"", "pa mwedzi gwa hutala", "pa mwedzi gwa wuvili", "pa mwedzi gwa wudatu", "pa mwedzi gwa wutai", "pa mwedzi gwa wuhanu", "pa mwedzi gwa sita", "pa mwedzi gwa saba", "pa mwedzi gwa nane", "pa mwedzi gwa tisa", "pa mwedzi gwa kumi", "pa mwedzi gwa kumi na moja", "pa mwedzi gwa kumi na mbili"}, + daysAbbreviated: []string{"Mul", "Vil", "Hiv", "Hid", "Hit", "Hih", "Lem"}, + daysNarrow: []string{"M", "J", "H", "H", "H", "W", "J"}, + daysWide: []string{"pa mulungu", "pa shahuviluha", "pa hivili", "pa hidatu", "pa hitayi", "pa hihanu", "pa shahulembela"}, + periodsAbbreviated: []string{"pamilau", "pamunyi"}, + periodsWide: []string{"pamilau", "pamunyi"}, + erasAbbreviated: []string{"KM", "BM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Mtwaa", "Baada ya Mtwaa"}, + timezones: map[string]string{"UYST": "UYST", "∅∅∅": "∅∅∅", "HECU": "HECU", "ACWDT": "ACWDT", "JDT": "JDT", "WARST": "WARST", "BOT": "BOT", "CLST": "CLST", "EDT": "EDT", "NZST": "NZST", "AST": "AST", "OEZ": "OEZ", "HKT": "HKT", "ACST": "ACST", "WART": "WART", "OESZ": "OESZ", "HEPMX": "HEPMX", "CDT": "CDT", "SGT": "SGT", "PST": "PST", "HAST": "HAST", "HAT": "HAT", "SRT": "SRT", "WIB": "WIB", "TMT": "TMT", "TMST": "TMST", "HENOMX": "HENOMX", "CST": "CST", "NZDT": "NZDT", "MDT": "MDT", "ACWST": "ACWST", "CLT": "CLT", "COT": "COT", "ART": "ART", "ACDT": "ACDT", "HNPM": "HNPM", "VET": "VET", "JST": "JST", "ADT": "ADT", "WESZ": "WESZ", "MST": "MST", "MYT": "MYT", "HNT": "HNT", "AEST": "AEST", "AEDT": "AEDT", "HNEG": "HNEG", "ChST": "ChST", "PDT": "PDT", "HNOG": "HNOG", "WAT": "WAT", "COST": "COST", "HNNOMX": "HNNOMX", "GMT": "GMT", "EST": "EST", "AKST": "AKST", "SAST": "SAST", "HNPMX": "HNPMX", "WIT": "WIT", "AWDT": "AWDT", "HADT": "HADT", "HKST": "HKST", "BT": "BT", "AKDT": "AKDT", "IST": "IST", "WEZ": "WEZ", "LHST": "LHST", "LHDT": "LHDT", "EAT": "EAT", "HNCU": "HNCU", "AWST": "AWST", "GYT": "GYT", "CHAST": "CHAST", "ECT": "ECT", "GFT": "GFT", "WITA": "WITA", "HEPM": "HEPM", "CHADT": "CHADT", "MESZ": "MESZ", "HEOG": "HEOG", "ARST": "ARST", "HEEG": "HEEG", "CAT": "CAT", "MEZ": "MEZ", "WAST": "WAST", "UYT": "UYT"}, + } +} + +// Locale returns the current translators string locale +func (bez *bez_TZ) Locale() string { + return bez.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bez_TZ' +func (bez *bez_TZ) PluralsCardinal() []locales.PluralRule { + return bez.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bez_TZ' +func (bez *bez_TZ) PluralsOrdinal() []locales.PluralRule { + return bez.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bez_TZ' +func (bez *bez_TZ) PluralsRange() []locales.PluralRule { + return bez.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bez_TZ' +func (bez *bez_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bez_TZ' +func (bez *bez_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bez_TZ' +func (bez *bez_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bez *bez_TZ) MonthAbbreviated(month time.Month) string { + return bez.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bez *bez_TZ) MonthsAbbreviated() []string { + return bez.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bez *bez_TZ) MonthNarrow(month time.Month) string { + return bez.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bez *bez_TZ) MonthsNarrow() []string { + return bez.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bez *bez_TZ) MonthWide(month time.Month) string { + return bez.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bez *bez_TZ) MonthsWide() []string { + return bez.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bez *bez_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return bez.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bez *bez_TZ) WeekdaysAbbreviated() []string { + return bez.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bez *bez_TZ) WeekdayNarrow(weekday time.Weekday) string { + return bez.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bez *bez_TZ) WeekdaysNarrow() []string { + return bez.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bez *bez_TZ) WeekdayShort(weekday time.Weekday) string { + return bez.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bez *bez_TZ) WeekdaysShort() []string { + return bez.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bez *bez_TZ) WeekdayWide(weekday time.Weekday) string { + return bez.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bez *bez_TZ) WeekdaysWide() []string { + return bez.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bez_TZ' and handles both Whole and Real numbers based on 'v' +func (bez *bez_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bez_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bez *bez_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bez_TZ' +func (bez *bez_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bez.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bez.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bez.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bez.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bez.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bez_TZ' +// in accounting notation. +func (bez *bez_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bez.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bez.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bez.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bez.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bez.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bez_TZ' +func (bez *bez_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bez_TZ' +func (bez *bez_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bez.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bez_TZ' +func (bez *bez_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bez.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bez_TZ' +func (bez *bez_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bez.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bez.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bez_TZ' +func (bez *bez_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bez.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bez_TZ' +func (bez *bez_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bez.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bez.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bez_TZ' +func (bez *bez_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bez.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bez.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bez_TZ' +func (bez *bez_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bez.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bez.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bez.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bez_TZ/bez_TZ_test.go b/vendor/github.com/go-playground/locales/bez_TZ/bez_TZ_test.go new file mode 100644 index 0000000000..d52c782b31 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bez_TZ/bez_TZ_test.go @@ -0,0 +1,1120 @@ +package bez_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bez_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bg/bg.go b/vendor/github.com/go-playground/locales/bg/bg.go new file mode 100644 index 0000000000..0271b98d62 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bg/bg.go @@ -0,0 +1,568 @@ +package bg + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bg struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bg' locale +func New() locales.Translator { + return &bg{ + locale: "bg", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "лв.", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "щ.д.", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "яну", "фев", "март", "апр", "май", "юни", "юли", "авг", "сеп", "окт", "ное", "дек"}, + monthsNarrow: []string{"", "я", "ф", "м", "а", "м", "ю", "ю", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "януари", "февруари", "март", "април", "май", "юни", "юли", "август", "септември", "октомври", "ноември", "декември"}, + daysAbbreviated: []string{"нд", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"н", "п", "в", "с", "ч", "п", "с"}, + daysShort: []string{"нд", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"неделя", "понеделник", "вторник", "сряда", "четвъртък", "петък", "събота"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"пр.об.", "сл.об."}, + erasAbbreviated: []string{"пр.Хр.", "сл.Хр."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"преди Христа", "след Христа"}, + timezones: map[string]string{"HKT": "Хонконгско стандартно време", "BT": "Бутанско време", "GYT": "Гаяна", "EAT": "Източноафриканско време", "CHAST": "Чатъм – стандартно време", "ARST": "Аржентинско лятно часово време", "AKST": "Аляска – стандартно време", "WEZ": "Западноевропейско стандартно време", "AST": "Северноамериканско атлантическо стандартно време", "OEZ": "Източноевропейско стандартно време", "HEEG": "Източногренландско лятно часово време", "HNCU": "Кубинско стандартно време", "WIT": "Източноиндонезийско време", "VET": "Венецуелско време", "MYT": "Малайзийско време", "NZDT": "Новозеландско лятно часово време", "EDT": "Северноамериканско източно лятно часово време", "COT": "Колумбийско стандартно време", "GFT": "Френска Гвиана", "UYT": "Уругвайско стандартно време", "PST": "Северноамериканско тихоокеанско стандартно време", "MST": "MST", "∅∅∅": "∅∅∅", "HNPM": "Сен Пиер и Микелон – стандартно време", "ChST": "Чаморо – стандартно време", "PDT": "Северноамериканско тихоокеанско лятно часово време", "HECU": "Кубинско лятно часово време", "AWST": "Австралия – западно стандартно време", "MEZ": "Централноевропейско стандартно време", "MDT": "MDT", "WAST": "Западноафриканско лятно часово време", "EST": "Северноамериканско източно стандартно време", "AEST": "Австралия – източно стандартно време", "HEPM": "Сен Пиер и Микелон – лятно часово време", "HEPMX": "Мексиканско тихоокеанско лятно часово време", "SAST": "Южноафриканско време", "JDT": "Японско лятно часово време", "GMT": "Средно гринуичко време", "OESZ": "Източноевропейско лятно часово време", "HNNOMX": "Мексико – северозападно стандартно време", "HNT": "Нюфаундлендско стандартно време", "CHADT": "Чатъм – лятно часово време", "ECT": "Еквадорско време", "TMST": "Туркменистанско лятно часово време", "WART": "Западноаржентинско стандартно време", "ART": "Аржентинско стандартно време", "HKST": "Хонконгско лятно часово време", "ACDT": "Австралия – централно лятно часово време", "CDT": "Северноамериканско централно лятно часово време", "IST": "Индийско стандартно време", "CLST": "Чилийско лятно часово време", "HEOG": "Западногренландско лятно часово време", "TMT": "Туркменистанско стандартно време", "HNEG": "Източногренландско стандартно време", "HAT": "Нюфаундлендско лятно часово време", "LHST": "Лорд Хау – стандартно време", "LHDT": "Лорд Хау – лятно часово време", "ACWDT": "Австралия – западно централно лятно часово време", "WIB": "Западноиндонезийско време", "ACWST": "Австралия – западно централно стандартно време", "WARST": "Западноаржентинско лятно часово време", "SRT": "Суринамско време", "CST": "Северноамериканско централно стандартно време", "CAT": "Централноафриканско време", "HNOG": "Западногренландско стандартно време", "BOT": "Боливийско време", "SGT": "Сингапурско време", "NZST": "Новозеландско стандартно време", "MESZ": "Централноевропейско лятно часово време", "ACST": "Австралия – централно стандартно време", "AKDT": "Аляска – лятно часово време", "HNPMX": "Мексиканско тихоокеанско стандартно време", "WESZ": "Западноевропейско лятно време", "CLT": "Чилийско стандартно време", "WAT": "Западноафриканско стандартно време", "UYST": "Уругвайско лятно часово време", "AWDT": "Австралия – западно лятно часово време", "HAST": "Хавайско-алеутско стандартно време", "JST": "Японско стандартно време", "ADT": "Северноамериканско атлантическо лятно часово време", "HENOMX": "Мексико – северозападно лятно часово време", "COST": "Колумбийско лятно часово време", "AEDT": "Австралия – източно лятно часово време", "WITA": "Централноиндонезийско време", "HADT": "Хавайско-алеутско лятно часово време"}, + } +} + +// Locale returns the current translators string locale +func (bg *bg) Locale() string { + return bg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bg' +func (bg *bg) PluralsCardinal() []locales.PluralRule { + return bg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bg' +func (bg *bg) PluralsOrdinal() []locales.PluralRule { + return bg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bg' +func (bg *bg) PluralsRange() []locales.PluralRule { + return bg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bg' +func (bg *bg) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bg' +func (bg *bg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bg' +func (bg *bg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bg *bg) MonthAbbreviated(month time.Month) string { + return bg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bg *bg) MonthsAbbreviated() []string { + return bg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bg *bg) MonthNarrow(month time.Month) string { + return bg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bg *bg) MonthsNarrow() []string { + return bg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bg *bg) MonthWide(month time.Month) string { + return bg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bg *bg) MonthsWide() []string { + return bg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bg *bg) WeekdayAbbreviated(weekday time.Weekday) string { + return bg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bg *bg) WeekdaysAbbreviated() []string { + return bg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bg *bg) WeekdayNarrow(weekday time.Weekday) string { + return bg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bg *bg) WeekdaysNarrow() []string { + return bg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bg *bg) WeekdayShort(weekday time.Weekday) string { + return bg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bg *bg) WeekdaysShort() []string { + return bg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bg *bg) WeekdayWide(weekday time.Weekday) string { + return bg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bg *bg) WeekdaysWide() []string { + return bg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bg' and handles both Whole and Real numbers based on 'v' +func (bg *bg) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(bg.group) - 1; j >= 0; j-- { + b = append(b, bg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bg' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bg *bg) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bg.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bg' +func (bg *bg) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bg.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bg.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bg' +// in accounting notation. +func (bg *bg) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bg.currencies[currency] + l := len(s) + len(symbol) + 6 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bg.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bg.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bg.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bg' +func (bg *bg) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bg' +func (bg *bg) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bg' +func (bg *bg) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bg' +func (bg *bg) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bg' +func (bg *bg) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bg' +func (bg *bg) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bg' +func (bg *bg) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bg' +func (bg *bg) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bg/bg_test.go b/vendor/github.com/go-playground/locales/bg/bg_test.go new file mode 100644 index 0000000000..4228b64bba --- /dev/null +++ b/vendor/github.com/go-playground/locales/bg/bg_test.go @@ -0,0 +1,1120 @@ +package bg + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bg" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bg_BG/bg_BG.go b/vendor/github.com/go-playground/locales/bg_BG/bg_BG.go new file mode 100644 index 0000000000..aa8d7d0151 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bg_BG/bg_BG.go @@ -0,0 +1,568 @@ +package bg_BG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bg_BG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bg_BG' locale +func New() locales.Translator { + return &bg_BG{ + locale: "bg_BG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "яну", "фев", "март", "апр", "май", "юни", "юли", "авг", "сеп", "окт", "ное", "дек"}, + monthsNarrow: []string{"", "я", "ф", "м", "а", "м", "ю", "ю", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "януари", "февруари", "март", "април", "май", "юни", "юли", "август", "септември", "октомври", "ноември", "декември"}, + daysAbbreviated: []string{"нд", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"н", "п", "в", "с", "ч", "п", "с"}, + daysShort: []string{"нд", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"неделя", "понеделник", "вторник", "сряда", "четвъртък", "петък", "събота"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"пр.об.", "сл.об."}, + erasAbbreviated: []string{"пр.Хр.", "сл.Хр."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"преди Христа", "след Христа"}, + timezones: map[string]string{"CHAST": "Чатъм – стандартно време", "NZDT": "Новозеландско лятно часово време", "CLST": "Чилийско лятно часово време", "ACST": "Австралия – централно стандартно време", "CHADT": "Чатъм – лятно часово време", "ECT": "Еквадорско време", "CAT": "Централноафриканско време", "AST": "Северноамериканско атлантическо стандартно време", "COST": "Колумбийско лятно часово време", "HNT": "Нюфаундлендско стандартно време", "AEDT": "Австралия – източно лятно часово време", "HADT": "Хавайско-алеутско лятно часово време", "VET": "Венецуелско време", "CLT": "Чилийско стандартно време", "IST": "Индийско стандартно време", "WARST": "Западноаржентинско лятно часово време", "HEEG": "Източногренландско лятно часово време", "EAT": "Източноафриканско време", "EDT": "Северноамериканско източно лятно часово време", "HNNOMX": "Мексико – северозападно стандартно време", "HENOMX": "Мексико – северозападно лятно часово време", "AKDT": "Аляска – лятно часово време", "SRT": "Суринамско време", "HNCU": "Кубинско стандартно време", "BOT": "Боливийско време", "OEZ": "Източноевропейско стандартно време", "TMT": "Туркменистанско стандартно време", "WAT": "Западноафриканско стандартно време", "ChST": "Чаморо – стандартно време", "JST": "Японско стандартно време", "MST": "MST", "MDT": "MDT", "HAT": "Нюфаундлендско лятно часово време", "GFT": "Френска Гвиана", "WITA": "Централноиндонезийско време", "HNPMX": "Мексиканско тихоокеанско стандартно време", "WIB": "Западноиндонезийско време", "∅∅∅": "Бразилско лятно часово време", "PST": "Северноамериканско тихоокеанско стандартно време", "PDT": "Северноамериканско тихоокеанско лятно часово време", "HEOG": "Западногренландско лятно часово време", "HKT": "Хонконгско стандартно време", "AWDT": "Австралия – западно лятно часово време", "MEZ": "Централноевропейско стандартно време", "OESZ": "Източноевропейско лятно часово време", "MYT": "Малайзийско време", "UYST": "Уругвайско лятно часово време", "HNPM": "Сен Пиер и Микелон – стандартно време", "HEPM": "Сен Пиер и Микелон – лятно часово време", "CDT": "Северноамериканско централно лятно часово време", "ACWST": "Австралия – западно централно стандартно време", "ACWDT": "Австралия – западно централно лятно часово време", "MESZ": "Централноевропейско лятно часово време", "HNOG": "Западногренландско стандартно време", "ARST": "Аржентинско лятно часово време", "EST": "Северноамериканско източно стандартно време", "ACDT": "Австралия – централно лятно часово време", "HAST": "Хавайско-алеутско стандартно време", "ADT": "Северноамериканско атлантическо лятно часово време", "WEZ": "Западноевропейско стандартно време", "BT": "Бутанско време", "HNEG": "Източногренландско стандартно време", "AKST": "Аляска – стандартно време", "SAST": "Южноафриканско време", "WIT": "Източноиндонезийско време", "AWST": "Австралия – западно стандартно време", "WART": "Западноаржентинско стандартно време", "ART": "Аржентинско стандартно време", "LHDT": "Лорд Хау – лятно часово време", "GMT": "Средно гринуичко време", "TMST": "Туркменистанско лятно часово време", "CST": "Северноамериканско централно стандартно време", "NZST": "Новозеландско стандартно време", "WESZ": "Западноевропейско лятно време", "WAST": "Западноафриканско лятно часово време", "HECU": "Кубинско лятно часово време", "SGT": "Сингапурско време", "JDT": "Японско лятно часово време", "HKST": "Хонконгско лятно часово време", "COT": "Колумбийско стандартно време", "AEST": "Австралия – източно стандартно време", "HEPMX": "Мексиканско тихоокеанско лятно часово време", "GYT": "Гаяна", "UYT": "Уругвайско стандартно време", "LHST": "Лорд Хау – стандартно време"}, + } +} + +// Locale returns the current translators string locale +func (bg *bg_BG) Locale() string { + return bg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bg_BG' +func (bg *bg_BG) PluralsCardinal() []locales.PluralRule { + return bg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bg_BG' +func (bg *bg_BG) PluralsOrdinal() []locales.PluralRule { + return bg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bg_BG' +func (bg *bg_BG) PluralsRange() []locales.PluralRule { + return bg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bg_BG' +func (bg *bg_BG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bg_BG' +func (bg *bg_BG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bg_BG' +func (bg *bg_BG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bg *bg_BG) MonthAbbreviated(month time.Month) string { + return bg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bg *bg_BG) MonthsAbbreviated() []string { + return bg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bg *bg_BG) MonthNarrow(month time.Month) string { + return bg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bg *bg_BG) MonthsNarrow() []string { + return bg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bg *bg_BG) MonthWide(month time.Month) string { + return bg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bg *bg_BG) MonthsWide() []string { + return bg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bg *bg_BG) WeekdayAbbreviated(weekday time.Weekday) string { + return bg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bg *bg_BG) WeekdaysAbbreviated() []string { + return bg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bg *bg_BG) WeekdayNarrow(weekday time.Weekday) string { + return bg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bg *bg_BG) WeekdaysNarrow() []string { + return bg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bg *bg_BG) WeekdayShort(weekday time.Weekday) string { + return bg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bg *bg_BG) WeekdaysShort() []string { + return bg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bg *bg_BG) WeekdayWide(weekday time.Weekday) string { + return bg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bg *bg_BG) WeekdaysWide() []string { + return bg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bg_BG' and handles both Whole and Real numbers based on 'v' +func (bg *bg_BG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(bg.group) - 1; j >= 0; j-- { + b = append(b, bg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bg_BG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bg *bg_BG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bg.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bg_BG' +func (bg *bg_BG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bg.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bg.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bg_BG' +// in accounting notation. +func (bg *bg_BG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bg.currencies[currency] + l := len(s) + len(symbol) + 6 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bg.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bg.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bg.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bg_BG' +func (bg *bg_BG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bg_BG' +func (bg *bg_BG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bg_BG' +func (bg *bg_BG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bg_BG' +func (bg *bg_BG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bg_BG' +func (bg *bg_BG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bg_BG' +func (bg *bg_BG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bg_BG' +func (bg *bg_BG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bg_BG' +func (bg *bg_BG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bg_BG/bg_BG_test.go b/vendor/github.com/go-playground/locales/bg_BG/bg_BG_test.go new file mode 100644 index 0000000000..d180eede01 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bg_BG/bg_BG_test.go @@ -0,0 +1,1120 @@ +package bg_BG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bg_BG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bm/bm.go b/vendor/github.com/go-playground/locales/bm/bm.go new file mode 100644 index 0000000000..bee9de2ce2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bm/bm.go @@ -0,0 +1,506 @@ +package bm + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bm struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bm' locale +func New() locales.Translator { + return &bm{ + locale: "bm", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "zan", "feb", "mar", "awi", "mɛ", "zuw", "zul", "uti", "sɛt", "ɔku", "now", "des"}, + monthsNarrow: []string{"", "Z", "F", "M", "A", "M", "Z", "Z", "U", "S", "Ɔ", "N", "D"}, + monthsWide: []string{"", "zanwuye", "feburuye", "marisi", "awirili", "mɛ", "zuwɛn", "zuluye", "uti", "sɛtanburu", "ɔkutɔburu", "nowanburu", "desanburu"}, + daysAbbreviated: []string{"kar", "ntɛ", "tar", "ara", "ala", "jum", "sib"}, + daysNarrow: []string{"K", "N", "T", "A", "A", "J", "S"}, + daysWide: []string{"kari", "ntɛnɛ", "tarata", "araba", "alamisa", "juma", "sibiri"}, + erasAbbreviated: []string{"J.-C. ɲɛ", "ni J.-C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"jezu krisiti ɲɛ", "jezu krisiti minkɛ"}, + timezones: map[string]string{"HKT": "HKT", "LHST": "LHST", "HNCU": "HNCU", "CDT": "CDT", "MEZ": "MEZ", "EST": "EST", "BT": "BT", "UYT": "UYT", "HEPMX": "HEPMX", "CST": "CST", "WARST": "WARST", "TMST": "TMST", "ACDT": "ACDT", "PST": "PST", "CLST": "CLST", "MESZ": "MESZ", "OESZ": "OESZ", "ADT": "ADT", "MDT": "MDT", "NZST": "NZST", "∅∅∅": "∅∅∅", "HADT": "HADT", "ACWDT": "ACWDT", "HKST": "HKST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "AEDT": "AEDT", "SGT": "SGT", "CHAST": "CHAST", "BOT": "BOT", "HNEG": "HNEG", "COT": "COT", "HNPM": "HNPM", "EAT": "EAT", "AWDT": "AWDT", "CHADT": "CHADT", "WART": "WART", "ART": "ART", "ACWST": "ACWST", "NZDT": "NZDT", "WESZ": "WESZ", "TMT": "TMT", "WAT": "WAT", "COST": "COST", "LHDT": "LHDT", "PDT": "PDT", "VET": "VET", "HNPMX": "HNPMX", "AWST": "AWST", "JDT": "JDT", "ACST": "ACST", "HEEG": "HEEG", "UYST": "UYST", "MYT": "MYT", "HAT": "HAT", "AST": "AST", "EDT": "EDT", "WAST": "WAST", "AEST": "AEST", "SAST": "SAST", "WIB": "WIB", "HAST": "HAST", "IST": "IST", "HNT": "HNT", "AKDT": "AKDT", "ECT": "ECT", "WEZ": "WEZ", "MST": "MST", "HEPM": "HEPM", "ChST": "ChST", "OEZ": "OEZ", "HNOG": "HNOG", "CLT": "CLT", "ARST": "ARST", "GFT": "GFT", "AKST": "AKST", "SRT": "SRT", "JST": "JST", "GMT": "GMT", "WITA": "WITA", "GYT": "GYT", "HECU": "HECU", "WIT": "WIT", "CAT": "CAT", "HEOG": "HEOG"}, + } +} + +// Locale returns the current translators string locale +func (bm *bm) Locale() string { + return bm.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bm' +func (bm *bm) PluralsCardinal() []locales.PluralRule { + return bm.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bm' +func (bm *bm) PluralsOrdinal() []locales.PluralRule { + return bm.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bm' +func (bm *bm) PluralsRange() []locales.PluralRule { + return bm.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bm' +func (bm *bm) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bm' +func (bm *bm) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bm' +func (bm *bm) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bm *bm) MonthAbbreviated(month time.Month) string { + return bm.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bm *bm) MonthsAbbreviated() []string { + return bm.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bm *bm) MonthNarrow(month time.Month) string { + return bm.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bm *bm) MonthsNarrow() []string { + return bm.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bm *bm) MonthWide(month time.Month) string { + return bm.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bm *bm) MonthsWide() []string { + return bm.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bm *bm) WeekdayAbbreviated(weekday time.Weekday) string { + return bm.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bm *bm) WeekdaysAbbreviated() []string { + return bm.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bm *bm) WeekdayNarrow(weekday time.Weekday) string { + return bm.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bm *bm) WeekdaysNarrow() []string { + return bm.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bm *bm) WeekdayShort(weekday time.Weekday) string { + return bm.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bm *bm) WeekdaysShort() []string { + return bm.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bm *bm) WeekdayWide(weekday time.Weekday) string { + return bm.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bm *bm) WeekdaysWide() []string { + return bm.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bm' and handles both Whole and Real numbers based on 'v' +func (bm *bm) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bm' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bm *bm) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bm' +func (bm *bm) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bm.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bm.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, bm.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bm' +// in accounting notation. +func (bm *bm) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bm.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bm.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, bm.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bm.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bm' +func (bm *bm) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bm' +func (bm *bm) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bm.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bm' +func (bm *bm) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bm' +func (bm *bm) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bm.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bm' +func (bm *bm) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bm' +func (bm *bm) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bm' +func (bm *bm) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bm' +func (bm *bm) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bm.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bm/bm_test.go b/vendor/github.com/go-playground/locales/bm/bm_test.go new file mode 100644 index 0000000000..fdd3f61dc5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bm/bm_test.go @@ -0,0 +1,1120 @@ +package bm + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bm" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bm_ML/bm_ML.go b/vendor/github.com/go-playground/locales/bm_ML/bm_ML.go new file mode 100644 index 0000000000..78fc4950c1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bm_ML/bm_ML.go @@ -0,0 +1,506 @@ +package bm_ML + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bm_ML struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bm_ML' locale +func New() locales.Translator { + return &bm_ML{ + locale: "bm_ML", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "zan", "feb", "mar", "awi", "mɛ", "zuw", "zul", "uti", "sɛt", "ɔku", "now", "des"}, + monthsNarrow: []string{"", "Z", "F", "M", "A", "M", "Z", "Z", "U", "S", "Ɔ", "N", "D"}, + monthsWide: []string{"", "zanwuye", "feburuye", "marisi", "awirili", "mɛ", "zuwɛn", "zuluye", "uti", "sɛtanburu", "ɔkutɔburu", "nowanburu", "desanburu"}, + daysAbbreviated: []string{"kar", "ntɛ", "tar", "ara", "ala", "jum", "sib"}, + daysNarrow: []string{"K", "N", "T", "A", "A", "J", "S"}, + daysWide: []string{"kari", "ntɛnɛ", "tarata", "araba", "alamisa", "juma", "sibiri"}, + erasAbbreviated: []string{"J.-C. ɲɛ", "ni J.-C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"jezu krisiti ɲɛ", "jezu krisiti minkɛ"}, + timezones: map[string]string{"WARST": "WARST", "CHADT": "CHADT", "ECT": "ECT", "PST": "PST", "NZST": "NZST", "OESZ": "OESZ", "UYT": "UYT", "UYST": "UYST", "WART": "WART", "ACDT": "ACDT", "HAT": "HAT", "ChST": "ChST", "SAST": "SAST", "CLST": "CLST", "WEZ": "WEZ", "TMST": "TMST", "JST": "JST", "WESZ": "WESZ", "ARST": "ARST", "AEDT": "AEDT", "HEPMX": "HEPMX", "EAT": "EAT", "CDT": "CDT", "CAT": "CAT", "EST": "EST", "HNNOMX": "HNNOMX", "WITA": "WITA", "HNPM": "HNPM", "HEPM": "HEPM", "CST": "CST", "GYT": "GYT", "WAST": "WAST", "COST": "COST", "HENOMX": "HENOMX", "LHST": "LHST", "LHDT": "LHDT", "IST": "IST", "HNOG": "HNOG", "WAT": "WAT", "HNT": "HNT", "AWST": "AWST", "ACWDT": "ACWDT", "TMT": "TMT", "ART": "ART", "ACST": "ACST", "HNEG": "HNEG", "HAST": "HAST", "MESZ": "MESZ", "AWDT": "AWDT", "GMT": "GMT", "ADT": "ADT", "EDT": "EDT", "∅∅∅": "∅∅∅", "AKDT": "AKDT", "SRT": "SRT", "HECU": "HECU", "MEZ": "MEZ", "HADT": "HADT", "MDT": "MDT", "HKT": "HKT", "HKST": "HKST", "AEST": "AEST", "GFT": "GFT", "WIT": "WIT", "CHAST": "CHAST", "AST": "AST", "AKST": "AKST", "VET": "VET", "MYT": "MYT", "CLT": "CLT", "COT": "COT", "HEEG": "HEEG", "HNPMX": "HNPMX", "SGT": "SGT", "NZDT": "NZDT", "PDT": "PDT", "HEOG": "HEOG", "OEZ": "OEZ", "MST": "MST", "BT": "BT", "HNCU": "HNCU", "WIB": "WIB", "BOT": "BOT", "ACWST": "ACWST", "JDT": "JDT"}, + } +} + +// Locale returns the current translators string locale +func (bm *bm_ML) Locale() string { + return bm.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bm_ML' +func (bm *bm_ML) PluralsCardinal() []locales.PluralRule { + return bm.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bm_ML' +func (bm *bm_ML) PluralsOrdinal() []locales.PluralRule { + return bm.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bm_ML' +func (bm *bm_ML) PluralsRange() []locales.PluralRule { + return bm.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bm_ML' +func (bm *bm_ML) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bm_ML' +func (bm *bm_ML) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bm_ML' +func (bm *bm_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bm *bm_ML) MonthAbbreviated(month time.Month) string { + return bm.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bm *bm_ML) MonthsAbbreviated() []string { + return bm.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bm *bm_ML) MonthNarrow(month time.Month) string { + return bm.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bm *bm_ML) MonthsNarrow() []string { + return bm.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bm *bm_ML) MonthWide(month time.Month) string { + return bm.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bm *bm_ML) MonthsWide() []string { + return bm.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bm *bm_ML) WeekdayAbbreviated(weekday time.Weekday) string { + return bm.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bm *bm_ML) WeekdaysAbbreviated() []string { + return bm.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bm *bm_ML) WeekdayNarrow(weekday time.Weekday) string { + return bm.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bm *bm_ML) WeekdaysNarrow() []string { + return bm.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bm *bm_ML) WeekdayShort(weekday time.Weekday) string { + return bm.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bm *bm_ML) WeekdaysShort() []string { + return bm.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bm *bm_ML) WeekdayWide(weekday time.Weekday) string { + return bm.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bm *bm_ML) WeekdaysWide() []string { + return bm.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bm_ML' and handles both Whole and Real numbers based on 'v' +func (bm *bm_ML) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bm_ML' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bm *bm_ML) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bm_ML' +func (bm *bm_ML) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bm.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bm.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, bm.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bm_ML' +// in accounting notation. +func (bm *bm_ML) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bm.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bm.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, bm.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bm.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bm_ML' +func (bm *bm_ML) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bm_ML' +func (bm *bm_ML) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bm.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bm_ML' +func (bm *bm_ML) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bm_ML' +func (bm *bm_ML) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bm.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bm_ML' +func (bm *bm_ML) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bm_ML' +func (bm *bm_ML) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bm_ML' +func (bm *bm_ML) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bm_ML' +func (bm *bm_ML) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bm.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bm_ML/bm_ML_test.go b/vendor/github.com/go-playground/locales/bm_ML/bm_ML_test.go new file mode 100644 index 0000000000..d43f678dfb --- /dev/null +++ b/vendor/github.com/go-playground/locales/bm_ML/bm_ML_test.go @@ -0,0 +1,1120 @@ +package bm_ML + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bm_ML" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bn/bn.go b/vendor/github.com/go-playground/locales/bn/bn.go new file mode 100644 index 0000000000..72bf97c8ef --- /dev/null +++ b/vendor/github.com/go-playground/locales/bn/bn.go @@ -0,0 +1,658 @@ +package bn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bn' locale +func New() locales.Translator { + return &bn{ + locale: "bn", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "৳", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "জানু", "ফেব", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগস্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"}, + monthsNarrow: []string{"", "জা", "ফে", "মা", "এ", "মে", "জুন", "জু", "আ", "সে", "অ", "ন", "ডি"}, + monthsWide: []string{"", "জানুয়ারী", "ফেব্রুয়ারী", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগস্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"}, + daysAbbreviated: []string{"রবি", "সোম", "মঙ্গল", "বুধ", "বৃহস্পতি", "শুক্র", "শনি"}, + daysNarrow: []string{"র", "সো", "ম", "বু", "বৃ", "শু", "শ"}, + daysShort: []string{"রঃ", "সোঃ", "মঃ", "বুঃ", "বৃঃ", "শুঃ", "শোঃ"}, + daysWide: []string{"রবিবার", "সোমবার", "মঙ্গলবার", "বুধবার", "বৃহস্পতিবার", "শুক্রবার", "শনিবার"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"খ্রিস্টপূর্ব", "খৃষ্টাব্দ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"খ্রিস্টপূর্ব", "খৃষ্টাব্দ"}, + timezones: map[string]string{"GMT": "গ্রীনিচ মিন টাইম", "CLT": "চিলি মানক সময়", "TMT": "তুর্কমেনিস্তান মানক সময়", "COT": "কোলোম্বিয়া মানক সময়", "AWST": "অস্ট্রেলীয় পশ্চিমি মানক সময়", "CHADT": "চ্যাথাম দিবালোক সময়", "NZDT": "নিউজিল্যান্ড দিবালোক সময়", "WEZ": "পশ্চিম ইউরোপের মানক সময়", "HNT": "নিউফাউন্ডল্যান্ড মানক সময়", "HNEG": "পূর্ব গ্রীনল্যান্ড মানক সময়", "AEST": "অস্ট্রেলীয় পূর্ব মানক সময়", "LHDT": "লর্ড হাওয়ে দিবালোক মসয়", "HECU": "কিউবা দিবালোক সময়", "HAT": "নিউফাউন্ডল্যান্ড দিবালোক সময়", "CST": "কেন্দ্রীয় মানক সময়", "HEOG": "পশ্চিম গ্রীনল্যান্ড গ্রীষ্মকালীন সময়", "SAST": "দক্ষিণ আফ্রিকা মানক সময়", "HNPMX": "মেক্সিকান প্রশান্ত মহসাগরীয় মানক সময়", "GYT": "গুয়ানা সময়", "EAT": "পূর্ব আফ্রিকা সময়", "BOT": "বোলিভিয়া সময়", "PST": "প্রশান্ত মহাসাগরীয় অঞ্চলের মানক সময়", "CAT": "মধ্য আফ্রিকা সময়", "ARST": "আর্জেনটিনা গ্রীষ্মকালীন সময়", "EST": "পূর্বাঞ্চলের প্রমাণ সময়", "AKST": "আলাস্কা মানক সময়", "UYT": "উরুগুয়ে মানক সময়", "HEPM": "সেন্ট পিয়ের ও মিকেলন দিবালোক সময়", "ECT": "ইকুয়েডর সময়", "HAST": "হাওয়াই-আলেউত মানক সময়", "HKST": "হং কং গ্রীষ্মকালীন সময়", "COST": "কোলোম্বিয়া গ্রীষ্মকালীন সময়", "BT": "ভুটান সময়", "AEDT": "অস্ট্রেলীয় পূর্ব দিবালোক সময়", "SRT": "সুরিনাম সময়", "WIB": "পশ্চিমী ইন্দোনেশিয়া সময়", "HADT": "হাওয়াই-আলেউত দিবালোক সময়", "NZST": "নিউজিল্যান্ড মানক সময়", "OESZ": "পূর্ব ইউরোপের গ্রীষ্মকালীন সময়", "ACDT": "অস্ট্রেলীয় কেন্দ্রীয় দিবালোক সময়", "CDT": "কেন্দ্রীয় দিবালোক সময়", "MESZ": "মধ্য ইউরোপের গ্রীষ্মকালীন সময়", "ART": "আর্জেনটিনা মানক সময়", "ACWDT": "অস্ট্রেলীয় কেন্দ্রীয় পশ্চিমি দিবালোক সময়", "CLST": "চিলি গ্রীষ্মকাল সময়", "HNOG": "পশ্চিম গ্রীনল্যান্ড মানক সময়", "TMST": "তুর্কমেনিস্তান গ্রীষ্মকালীন সময়", "HENOMX": "উত্তরপশ্চিম মেক্সিকোর দিনের সময়", "ChST": "চামেরো মানক সময়", "UYST": "উরুগুয়ে গ্রীষ্মকালীন সময়", "ACWST": "অস্ট্রেলীয় কেন্দ্রীয় পশ্চিমি মানক সময়", "MYT": "মালয়েশিয়া সময়", "OEZ": "পূর্ব ইউরোপের মানক সময়", "HEEG": "পূর্ব গ্রীনল্যান্ড গ্রীষ্মকালীন সময়", "HEPMX": "মেক্সিকান প্রশান্ত মহাসাগরীয় দিবালোক সময়", "PDT": "প্রশান্ত মহাসাগরীয় অঞ্চলের দিনের সময়", "∅∅∅": "অ্যামাজন গ্রীষ্মকালীন সময়", "JST": "জাপান মানক সময়", "MST": "মাকাও মান সময়", "AKDT": "আলাস্কা দিবালোক সময়", "LHST": "লর্ড হাওয়ে মানক মসয়", "IST": "ভারতীয় মানক সময়", "VET": "ভেনেজুয়েলা সময়", "MDT": "মাকাও গ্রীষ্মকাল সময়", "HNNOMX": "উত্তরপশ্চিম মেক্সিকোর মানক সময়", "MEZ": "মধ্য ইউরোপের মানক সময়", "WAT": "পশ্চিম আফ্রিকা মানক সময়", "HNPM": "সেন্ট পিয়ের ও মিকেলন মানক সময়", "WIT": "পূর্ব ইন্দোনেশিয়া সময়", "AWDT": "অস্ট্রেলীয় পশ্চিমি দিবালোক সময়", "CHAST": "চ্যাথাম মানক সময়", "SGT": "সিঙ্গাপুর মানক সময়", "WESZ": "পশ্চিম ইউরোপের গ্রীষ্মকালীন সময়", "WAST": "পশ্চিম আফ্রিকা গ্রীষ্মকালীন সময়", "EDT": "পূর্বাঞ্চলের দিবালোক সময়", "HKT": "হং কং মানক সময়", "WITA": "কেন্দ্রীয় ইন্দোনেশিয়া সময়", "JDT": "জাপান দিবালোক সময়", "ADT": "অতলান্তিক দিবালোক সময়", "GFT": "ফরাসি গায়ানা সময়", "HNCU": "কিউবা মানক সময়", "WART": "পশ্চিমি আর্জেনটিনার প্রমাণ সময়", "WARST": "পশ্চিমি আর্জেনটিনা গৃষ্মকালীন সময়", "AST": "অতলান্তিক মানক সময়", "ACST": "অস্ট্রেলীয় কেন্দ্রীয় মানক সময়"}, + } +} + +// Locale returns the current translators string locale +func (bn *bn) Locale() string { + return bn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bn' +func (bn *bn) PluralsCardinal() []locales.PluralRule { + return bn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bn' +func (bn *bn) PluralsOrdinal() []locales.PluralRule { + return bn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bn' +func (bn *bn) PluralsRange() []locales.PluralRule { + return bn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bn' +func (bn *bn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bn' +func (bn *bn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bn' +func (bn *bn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := bn.CardinalPluralRule(num1, v1) + end := bn.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bn *bn) MonthAbbreviated(month time.Month) string { + return bn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bn *bn) MonthsAbbreviated() []string { + return bn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bn *bn) MonthNarrow(month time.Month) string { + return bn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bn *bn) MonthsNarrow() []string { + return bn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bn *bn) MonthWide(month time.Month) string { + return bn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bn *bn) MonthsWide() []string { + return bn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bn *bn) WeekdayAbbreviated(weekday time.Weekday) string { + return bn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bn *bn) WeekdaysAbbreviated() []string { + return bn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bn *bn) WeekdayNarrow(weekday time.Weekday) string { + return bn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bn *bn) WeekdaysNarrow() []string { + return bn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bn *bn) WeekdayShort(weekday time.Weekday) string { + return bn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bn *bn) WeekdaysShort() []string { + return bn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bn *bn) WeekdayWide(weekday time.Weekday) string { + return bn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bn *bn) WeekdaysWide() []string { + return bn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bn' and handles both Whole and Real numbers based on 'v' +func (bn *bn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bn *bn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bn' +func (bn *bn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bn.currencies[currency] + l := len(s) + len(symbol) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bn' +// in accounting notation. +func (bn *bn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bn.currencies[currency] + l := len(s) + len(symbol) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bn.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bn' +func (bn *bn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bn' +func (bn *bn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bn' +func (bn *bn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bn' +func (bn *bn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bn' +func (bn *bn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bn' +func (bn *bn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bn' +func (bn *bn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bn' +func (bn *bn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bn/bn_test.go b/vendor/github.com/go-playground/locales/bn/bn_test.go new file mode 100644 index 0000000000..d651cb3c4e --- /dev/null +++ b/vendor/github.com/go-playground/locales/bn/bn_test.go @@ -0,0 +1,1120 @@ +package bn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bn_BD/bn_BD.go b/vendor/github.com/go-playground/locales/bn_BD/bn_BD.go new file mode 100644 index 0000000000..06eaed0af5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bn_BD/bn_BD.go @@ -0,0 +1,658 @@ +package bn_BD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bn_BD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bn_BD' locale +func New() locales.Translator { + return &bn_BD{ + locale: "bn_BD", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "জানু", "ফেব", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগস্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"}, + monthsNarrow: []string{"", "জা", "ফে", "মা", "এ", "মে", "জুন", "জু", "আ", "সে", "অ", "ন", "ডি"}, + monthsWide: []string{"", "জানুয়ারী", "ফেব্রুয়ারী", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগস্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"}, + daysAbbreviated: []string{"রবি", "সোম", "মঙ্গল", "বুধ", "বৃহস্পতি", "শুক্র", "শনি"}, + daysNarrow: []string{"র", "সো", "ম", "বু", "বৃ", "শু", "শ"}, + daysShort: []string{"রঃ", "সোঃ", "মঃ", "বুঃ", "বৃঃ", "শুঃ", "শোঃ"}, + daysWide: []string{"রবিবার", "সোমবার", "মঙ্গলবার", "বুধবার", "বৃহস্পতিবার", "শুক্রবার", "শনিবার"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"খ্রিস্টপূর্ব", "খৃষ্টাব্দ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"খ্রিস্টপূর্ব", "খৃষ্টাব্দ"}, + timezones: map[string]string{"MESZ": "মধ্য ইউরোপের গ্রীষ্মকালীন সময়", "ACST": "অস্ট্রেলীয় কেন্দ্রীয় মানক সময়", "HNPMX": "মেক্সিকান প্রশান্ত মহসাগরীয় মানক সময়", "AWST": "অস্ট্রেলীয় পশ্চিমি মানক সময়", "JST": "জাপান মানক সময়", "HNT": "নিউফাউন্ডল্যান্ড মানক সময়", "LHDT": "লর্ড হাওয়ে দিবালোক মসয়", "BOT": "বোলিভিয়া সময়", "PDT": "প্রশান্ত মহাসাগরীয় অঞ্চলের দিনের সময়", "CAT": "মধ্য আফ্রিকা সময়", "WEZ": "পশ্চিম ইউরোপের মানক সময়", "MST": "মাকাও মান সময়", "WITA": "কেন্দ্রীয় ইন্দোনেশিয়া সময়", "CST": "কেন্দ্রীয় মানক সময়", "AWDT": "অস্ট্রেলীয় পশ্চিমি দিবালোক সময়", "OESZ": "পূর্ব ইউরোপের গ্রীষ্মকালীন সময়", "AST": "অতলান্তিক মানক সময়", "COST": "কোলোম্বিয়া গ্রীষ্মকালীন সময়", "HNEG": "পূর্ব গ্রীনল্যান্ড মানক সময়", "CHAST": "চ্যাথাম মানক সময়", "NZST": "নিউজিল্যান্ড মানক সময়", "OEZ": "পূর্ব ইউরোপের মানক সময়", "HEOG": "পশ্চিম গ্রীনল্যান্ড গ্রীষ্মকালীন সময়", "ART": "আর্জেনটিনা মানক সময়", "UYT": "উরুগুয়ে মানক সময়", "PST": "প্রশান্ত মহাসাগরীয় অঞ্চলের মানক সময়", "IST": "ভারতীয় মানক সময়", "MYT": "মালয়েশিয়া সময়", "HNNOMX": "উত্তরপশ্চিম মেক্সিকোর মানক সময়", "HKT": "হং কং মানক সময়", "HKST": "হং কং গ্রীষ্মকালীন সময়", "WIB": "পশ্চিমী ইন্দোনেশিয়া সময়", "CDT": "কেন্দ্রীয় দিবালোক সময়", "HADT": "হাওয়াই-আলেউত দিবালোক সময়", "ACWDT": "অস্ট্রেলীয় কেন্দ্রীয় পশ্চিমি দিবালোক সময়", "CLST": "চিলি গ্রীষ্মকাল সময়", "HNOG": "পশ্চিম গ্রীনল্যান্ড মানক সময়", "SGT": "সিঙ্গাপুর মানক সময়", "EAT": "পূর্ব আফ্রিকা সময়", "WIT": "পূর্ব ইন্দোনেশিয়া সময়", "WESZ": "পশ্চিম ইউরোপের গ্রীষ্মকালীন সময়", "MDT": "মাকাও গ্রীষ্মকাল সময়", "UYST": "উরুগুয়ে গ্রীষ্মকালীন সময়", "HEPM": "সেন্ট পিয়ের ও মিকেলন দিবালোক সময়", "ECT": "ইকুয়েডর সময়", "ARST": "আর্জেনটিনা গ্রীষ্মকালীন সময়", "BT": "ভুটান সময়", "AKDT": "আলাস্কা দিবালোক সময়", "JDT": "জাপান দিবালোক সময়", "ACDT": "অস্ট্রেলীয় কেন্দ্রীয় দিবালোক সময়", "LHST": "লর্ড হাওয়ে মানক মসয়", "GYT": "গুয়ানা সময়", "MEZ": "মধ্য ইউরোপের মানক সময়", "GMT": "গ্রীনিচ মিন টাইম", "CLT": "চিলি মানক সময়", "HEPMX": "মেক্সিকান প্রশান্ত মহাসাগরীয় দিবালোক সময়", "SAST": "দক্ষিণ আফ্রিকা মানক সময়", "HAST": "হাওয়াই-আলেউত মানক সময়", "TMT": "তুর্কমেনিস্তান মানক সময়", "WAT": "পশ্চিম আফ্রিকা মানক সময়", "AKST": "আলাস্কা মানক সময়", "WARST": "পশ্চিমি আর্জেনটিনা গৃষ্মকালীন সময়", "HAT": "নিউফাউন্ডল্যান্ড দিবালোক সময়", "AEDT": "অস্ট্রেলীয় পূর্ব দিবালোক সময়", "ChST": "চামেরো মানক সময়", "EDT": "পূর্বাঞ্চলের দিবালোক সময়", "WAST": "পশ্চিম আফ্রিকা গ্রীষ্মকালীন সময়", "COT": "কোলোম্বিয়া মানক সময়", "HEEG": "পূর্ব গ্রীনল্যান্ড গ্রীষ্মকালীন সময়", "ACWST": "অস্ট্রেলীয় কেন্দ্রীয় পশ্চিমি মানক সময়", "WART": "পশ্চিমি আর্জেনটিনার প্রমাণ সময়", "ADT": "অতলান্তিক দিবালোক সময়", "EST": "পূর্বাঞ্চলের প্রমাণ সময়", "GFT": "ফরাসি গায়ানা সময়", "TMST": "তুর্কমেনিস্তান গ্রীষ্মকালীন সময়", "HECU": "কিউবা দিবালোক সময়", "CHADT": "চ্যাথাম দিবালোক সময়", "AEST": "অস্ট্রেলীয় পূর্ব মানক সময়", "HNPM": "সেন্ট পিয়ের ও মিকেলন মানক সময়", "SRT": "সুরিনাম সময়", "HNCU": "কিউবা মানক সময়", "NZDT": "নিউজিল্যান্ড দিবালোক সময়", "∅∅∅": "অ্যামাজন গ্রীষ্মকালীন সময়", "VET": "ভেনেজুয়েলা সময়", "HENOMX": "উত্তরপশ্চিম মেক্সিকোর দিনের সময়"}, + } +} + +// Locale returns the current translators string locale +func (bn *bn_BD) Locale() string { + return bn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bn_BD' +func (bn *bn_BD) PluralsCardinal() []locales.PluralRule { + return bn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bn_BD' +func (bn *bn_BD) PluralsOrdinal() []locales.PluralRule { + return bn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bn_BD' +func (bn *bn_BD) PluralsRange() []locales.PluralRule { + return bn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bn_BD' +func (bn *bn_BD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bn_BD' +func (bn *bn_BD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bn_BD' +func (bn *bn_BD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := bn.CardinalPluralRule(num1, v1) + end := bn.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bn *bn_BD) MonthAbbreviated(month time.Month) string { + return bn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bn *bn_BD) MonthsAbbreviated() []string { + return bn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bn *bn_BD) MonthNarrow(month time.Month) string { + return bn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bn *bn_BD) MonthsNarrow() []string { + return bn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bn *bn_BD) MonthWide(month time.Month) string { + return bn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bn *bn_BD) MonthsWide() []string { + return bn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bn *bn_BD) WeekdayAbbreviated(weekday time.Weekday) string { + return bn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bn *bn_BD) WeekdaysAbbreviated() []string { + return bn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bn *bn_BD) WeekdayNarrow(weekday time.Weekday) string { + return bn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bn *bn_BD) WeekdaysNarrow() []string { + return bn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bn *bn_BD) WeekdayShort(weekday time.Weekday) string { + return bn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bn *bn_BD) WeekdaysShort() []string { + return bn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bn *bn_BD) WeekdayWide(weekday time.Weekday) string { + return bn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bn *bn_BD) WeekdaysWide() []string { + return bn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bn_BD' and handles both Whole and Real numbers based on 'v' +func (bn *bn_BD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bn_BD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bn *bn_BD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bn_BD' +func (bn *bn_BD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bn.currencies[currency] + l := len(s) + len(symbol) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bn_BD' +// in accounting notation. +func (bn *bn_BD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bn.currencies[currency] + l := len(s) + len(symbol) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bn.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bn_BD' +func (bn *bn_BD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bn_BD' +func (bn *bn_BD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bn_BD' +func (bn *bn_BD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bn_BD' +func (bn *bn_BD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bn_BD' +func (bn *bn_BD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bn_BD' +func (bn *bn_BD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bn_BD' +func (bn *bn_BD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bn_BD' +func (bn *bn_BD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bn_BD/bn_BD_test.go b/vendor/github.com/go-playground/locales/bn_BD/bn_BD_test.go new file mode 100644 index 0000000000..55bde34d3c --- /dev/null +++ b/vendor/github.com/go-playground/locales/bn_BD/bn_BD_test.go @@ -0,0 +1,1120 @@ +package bn_BD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bn_BD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bn_IN/bn_IN.go b/vendor/github.com/go-playground/locales/bn_IN/bn_IN.go new file mode 100644 index 0000000000..b7cab55a22 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bn_IN/bn_IN.go @@ -0,0 +1,658 @@ +package bn_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bn_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bn_IN' locale +func New() locales.Translator { + return &bn_IN{ + locale: "bn_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "জানু", "ফেব", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগস্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"}, + monthsNarrow: []string{"", "জা", "ফে", "মা", "এ", "মে", "জুন", "জু", "আ", "সে", "অ", "ন", "ডি"}, + monthsWide: []string{"", "জানুয়ারী", "ফেব্রুয়ারী", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগস্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"}, + daysAbbreviated: []string{"রবি", "সোম", "মঙ্গল", "বুধ", "বৃহস্পতি", "শুক্র", "শনি"}, + daysNarrow: []string{"র", "সো", "ম", "বু", "বৃ", "শু", "শ"}, + daysShort: []string{"রঃ", "সোঃ", "মঃ", "বুঃ", "বৃঃ", "শুঃ", "শোঃ"}, + daysWide: []string{"রবিবার", "সোমবার", "মঙ্গলবার", "বুধবার", "বৃহস্পতিবার", "শুক্রবার", "শনিবার"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"খ্রিস্টপূর্ব", "খৃষ্টাব্দ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"খ্রিস্টপূর্ব", "খৃষ্টাব্দ"}, + timezones: map[string]string{"GYT": "গুয়ানা সময়", "AWDT": "অস্ট্রেলীয় পশ্চিমি দিবালোক সময়", "CLST": "চিলি গ্রীষ্মকাল সময়", "HENOMX": "উত্তরপশ্চিম মেক্সিকোর দিনের সময়", "AEDT": "অস্ট্রেলীয় পূর্ব দিবালোক সময়", "UYST": "উরুগুয়ে গ্রীষ্মকালীন সময়", "HEPM": "সেন্ট পিয়ের ও মিকেলন দিবালোক সময়", "HNPMX": "মেক্সিকান প্রশান্ত মহসাগরীয় মানক সময়", "HNCU": "কিউবা মানক সময়", "HAST": "হাওয়াই-আলেউত মানক সময়", "HAT": "নিউফাউন্ডল্যান্ড দিবালোক সময়", "JDT": "জাপান দিবালোক সময়", "MDT": "মাকাও গ্রীষ্মকাল সময়", "EDT": "পূর্বাঞ্চলের দিবালোক সময়", "SAST": "দক্ষিণ আফ্রিকা মানক সময়", "PST": "প্রশান্ত মহাসাগরীয় অঞ্চলের মানক সময়", "ACWDT": "অস্ট্রেলীয় কেন্দ্রীয় পশ্চিমি দিবালোক সময়", "CAT": "মধ্য আফ্রিকা সময়", "MYT": "মালয়েশিয়া সময়", "∅∅∅": "এজোরেস গ্রীষ্মকালীন সময়", "CST": "কেন্দ্রীয় মানক সময়", "CDT": "কেন্দ্রীয় দিবালোক সময়", "BT": "ভুটান সময়", "HEEG": "পূর্ব গ্রীনল্যান্ড গ্রীষ্মকালীন সময়", "AEST": "অস্ট্রেলীয় পূর্ব মানক সময়", "HADT": "হাওয়াই-আলেউত দিবালোক সময়", "MEZ": "মধ্য ইউরোপের মানক সময়", "HNOG": "পশ্চিম গ্রীনল্যান্ড মানক সময়", "HNPM": "সেন্ট পিয়ের ও মিকেলন মানক সময়", "GMT": "গ্রীনিচ মিন টাইম", "ART": "আর্জেনটিনা মানক সময়", "VET": "ভেনেজুয়েলা সময়", "ACST": "অস্ট্রেলীয় কেন্দ্রীয় মানক সময়", "COST": "কোলোম্বিয়া গ্রীষ্মকালীন সময়", "GFT": "ফরাসি গায়ানা সময়", "AKST": "আলাস্কা মানক সময়", "WIB": "পশ্চিমী ইন্দোনেশিয়া সময়", "CHAST": "চ্যাথাম মানক সময়", "MESZ": "মধ্য ইউরোপের গ্রীষ্মকালীন সময়", "HNEG": "পূর্ব গ্রীনল্যান্ড মানক সময়", "IST": "ভারতীয় মানক সময়", "NZDT": "নিউজিল্যান্ড দিবালোক সময়", "WESZ": "পশ্চিম ইউরোপের গ্রীষ্মকালীন সময়", "ADT": "অতলান্তিক দিবালোক সময়", "TMST": "তুর্কমেনিস্তান গ্রীষ্মকালীন সময়", "ARST": "আর্জেনটিনা গ্রীষ্মকালীন সময়", "BOT": "বোলিভিয়া সময়", "PDT": "প্রশান্ত মহাসাগরীয় অঞ্চলের দিনের সময়", "CLT": "চিলি মানক সময়", "HKT": "হং কং মানক সময়", "HKST": "হং কং গ্রীষ্মকালীন সময়", "LHDT": "লর্ড হাওয়ে দিবালোক মসয়", "SGT": "সিঙ্গাপুর মানক সময়", "NZST": "নিউজিল্যান্ড মানক সময়", "WAT": "পশ্চিম আফ্রিকা মানক সময়", "EST": "পূর্বাঞ্চলের প্রমাণ সময়", "COT": "কোলোম্বিয়া মানক সময়", "AKDT": "আলাস্কা দিবালোক সময়", "WART": "পশ্চিমি আর্জেনটিনার প্রমাণ সময়", "WARST": "পশ্চিমি আর্জেনটিনা গৃষ্মকালীন সময়", "HEOG": "পশ্চিম গ্রীনল্যান্ড গ্রীষ্মকালীন সময়", "JST": "জাপান মানক সময়", "AST": "অতলান্তিক মানক সময়", "WEZ": "পশ্চিম ইউরোপের মানক সময়", "HNT": "নিউফাউন্ডল্যান্ড মানক সময়", "ChST": "চামেরো মানক সময়", "SRT": "সুরিনাম সময়", "ACWST": "অস্ট্রেলীয় কেন্দ্রীয় পশ্চিমি মানক সময়", "HNNOMX": "উত্তরপশ্চিম মেক্সিকোর মানক সময়", "CHADT": "চ্যাথাম দিবালোক সময়", "ECT": "ইকুয়েডর সময়", "ACDT": "অস্ট্রেলীয় কেন্দ্রীয় দিবালোক সময়", "HECU": "কিউবা দিবালোক সময়", "WIT": "পূর্ব ইন্দোনেশিয়া সময়", "TMT": "তুর্কমেনিস্তান মানক সময়", "WAST": "পশ্চিম আফ্রিকা গ্রীষ্মকালীন সময়", "UYT": "উরুগুয়ে মানক সময়", "HEPMX": "মেক্সিকান প্রশান্ত মহাসাগরীয় দিবালোক সময়", "EAT": "পূর্ব আফ্রিকা সময়", "OESZ": "পূর্ব ইউরোপের গ্রীষ্মকালীন সময়", "MST": "মাকাও মান সময়", "WITA": "কেন্দ্রীয় ইন্দোনেশিয়া সময়", "LHST": "লর্ড হাওয়ে মানক মসয়", "AWST": "অস্ট্রেলীয় পশ্চিমি মানক সময়", "OEZ": "পূর্ব ইউরোপের মানক সময়"}, + } +} + +// Locale returns the current translators string locale +func (bn *bn_IN) Locale() string { + return bn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bn_IN' +func (bn *bn_IN) PluralsCardinal() []locales.PluralRule { + return bn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bn_IN' +func (bn *bn_IN) PluralsOrdinal() []locales.PluralRule { + return bn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bn_IN' +func (bn *bn_IN) PluralsRange() []locales.PluralRule { + return bn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bn_IN' +func (bn *bn_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bn_IN' +func (bn *bn_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bn_IN' +func (bn *bn_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := bn.CardinalPluralRule(num1, v1) + end := bn.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bn *bn_IN) MonthAbbreviated(month time.Month) string { + return bn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bn *bn_IN) MonthsAbbreviated() []string { + return bn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bn *bn_IN) MonthNarrow(month time.Month) string { + return bn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bn *bn_IN) MonthsNarrow() []string { + return bn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bn *bn_IN) MonthWide(month time.Month) string { + return bn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bn *bn_IN) MonthsWide() []string { + return bn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bn *bn_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return bn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bn *bn_IN) WeekdaysAbbreviated() []string { + return bn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bn *bn_IN) WeekdayNarrow(weekday time.Weekday) string { + return bn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bn *bn_IN) WeekdaysNarrow() []string { + return bn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bn *bn_IN) WeekdayShort(weekday time.Weekday) string { + return bn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bn *bn_IN) WeekdaysShort() []string { + return bn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bn *bn_IN) WeekdayWide(weekday time.Weekday) string { + return bn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bn *bn_IN) WeekdaysWide() []string { + return bn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bn_IN' and handles both Whole and Real numbers based on 'v' +func (bn *bn_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bn_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bn *bn_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bn_IN' +func (bn *bn_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bn.currencies[currency] + l := len(s) + len(symbol) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bn_IN' +// in accounting notation. +func (bn *bn_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bn.currencies[currency] + l := len(s) + len(symbol) + 1 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, bn.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bn.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bn_IN' +func (bn *bn_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bn_IN' +func (bn *bn_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bn_IN' +func (bn *bn_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bn_IN' +func (bn *bn_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, bn.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bn_IN' +func (bn *bn_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bn_IN' +func (bn *bn_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bn_IN' +func (bn *bn_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bn_IN' +func (bn *bn_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bn.periodsAbbreviated[0]...) + } else { + b = append(b, bn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bn_IN/bn_IN_test.go b/vendor/github.com/go-playground/locales/bn_IN/bn_IN_test.go new file mode 100644 index 0000000000..bdee61d9dc --- /dev/null +++ b/vendor/github.com/go-playground/locales/bn_IN/bn_IN_test.go @@ -0,0 +1,1120 @@ +package bn_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bn_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bo/bo.go b/vendor/github.com/go-playground/locales/bo/bo.go new file mode 100644 index 0000000000..f1e092d2e8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bo/bo.go @@ -0,0 +1,628 @@ +package bo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bo' locale +func New() locales.Translator { + return &bo{ + locale: "bo", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ཟླ་༡", "ཟླ་༢", "ཟླ་༣", "ཟླ་༤", "ཟླ་༥", "ཟླ་༦", "ཟླ་༧", "ཟླ་༨", "ཟླ་༩", "ཟླ་༡༠", "ཟླ་༡༡", "ཟླ་༡༢"}, + monthsWide: []string{"", "ཟླ་བ་དང་པོ", "ཟླ་བ་གཉིས་པ", "ཟླ་བ་གསུམ་པ", "ཟླ་བ་བཞི་པ", "ཟླ་བ་ལྔ་པ", "ཟླ་བ་དྲུག་པ", "ཟླ་བ་བདུན་པ", "ཟླ་བ་བརྒྱད་པ", "ཟླ་བ་དགུ་པ", "ཟླ་བ་བཅུ་པ", "ཟླ་བ་བཅུ་གཅིག་པ", "ཟླ་བ་བཅུ་གཉིས་པ"}, + daysAbbreviated: []string{"ཉི་མ་", "ཟླ་བ་", "མིག་དམར་", "ལྷག་པ་", "ཕུར་བུ་", "པ་སངས་", "སྤེན་པ་"}, + daysNarrow: []string{"ཉི", "ཟླ", "མིག", "ལྷག", "ཕུར", "སངས", "སྤེན"}, + daysWide: []string{"གཟའ་ཉི་མ་", "གཟའ་ཟླ་བ་", "གཟའ་མིག་དམར་", "གཟའ་ལྷག་པ་", "གཟའ་ཕུར་བུ་", "གཟའ་པ་སངས་", "གཟའ་སྤེན་པ་"}, + periodsAbbreviated: []string{"སྔ་དྲོ་", "ཕྱི་དྲོ་"}, + periodsWide: []string{"སྔ་དྲོ་", "ཕྱི་དྲོ་"}, + erasAbbreviated: []string{"སྤྱི་ལོ་སྔོན་", "སྤྱི་ལོ་"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"IST": "IST", "MESZ": "MESZ", "EST": "EST", "EAT": "EAT", "CDT": "CDT", "AWST": "AWST", "PDT": "PDT", "HAST": "HAST", "ART": "ART", "ACDT": "ACDT", "CLST": "CLST", "WARST": "WARST", "GMT": "GMT", "WITA": "WITA", "HECU": "HECU", "WIB": "WIB", "CST": "CST", "MEZ": "MEZ", "OEZ": "OEZ", "HAT": "HAT", "ACWDT": "ACWDT", "WAST": "WAST", "HKST": "HKST", "CHADT": "CHADT", "ACWST": "ACWST", "ARST": "ARST", "BT": "BT", "HNEG": "HNEG", "AEST": "AEST", "ChST": "ChST", "CHAST": "CHAST", "HNOG": "HNOG", "MDT": "MDT", "ADT": "ADT", "COT": "COT", "HNNOMX": "HNNOMX", "LHST": "LHST", "JDT": "JDT", "HEOG": "HEOG", "ACST": "ACST", "HEEG": "HEEG", "UYT": "UYT", "SRT": "SRT", "HNCU": "HNCU", "WESZ": "WESZ", "WART": "WART", "HNT": "HNT", "AEDT": "AEDT", "UYST": "UYST", "HNPM": "HNPM", "AST": "AST", "TMST": "TMST", "AWDT": "AWDT", "WAT": "WAT", "HNPMX": "HNPMX", "AKST": "AKST", "HEPMX": "HEPMX", "WIT": "WIT", "CLT": "CLT", "WEZ": "WEZ", "OESZ": "OESZ", "MYT": "MYT", "GFT": "GFT", "HEPM": "HEPM", "HADT": "HADT", "NZST": "NZST", "HENOMX": "HENOMX", "SAST": "SAST", "LHDT": "LHDT", "CAT": "CAT", "NZDT": "NZDT", "MST": "MST", "AKDT": "AKDT", "GYT": "GYT", "BOT": "BOT", "∅∅∅": "∅∅∅", "TMT": "TMT", "COST": "COST", "JST": "JST", "EDT": "EDT", "VET": "VET", "HKT": "HKT", "SGT": "SGT", "PST": "PST", "ECT": "ECT"}, + } +} + +// Locale returns the current translators string locale +func (bo *bo) Locale() string { + return bo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bo' +func (bo *bo) PluralsCardinal() []locales.PluralRule { + return bo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bo' +func (bo *bo) PluralsOrdinal() []locales.PluralRule { + return bo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bo' +func (bo *bo) PluralsRange() []locales.PluralRule { + return bo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bo' +func (bo *bo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bo' +func (bo *bo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bo' +func (bo *bo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bo *bo) MonthAbbreviated(month time.Month) string { + return bo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bo *bo) MonthsAbbreviated() []string { + return bo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bo *bo) MonthNarrow(month time.Month) string { + return bo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bo *bo) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bo *bo) MonthWide(month time.Month) string { + return bo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bo *bo) MonthsWide() []string { + return bo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bo *bo) WeekdayAbbreviated(weekday time.Weekday) string { + return bo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bo *bo) WeekdaysAbbreviated() []string { + return bo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bo *bo) WeekdayNarrow(weekday time.Weekday) string { + return bo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bo *bo) WeekdaysNarrow() []string { + return bo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bo *bo) WeekdayShort(weekday time.Weekday) string { + return bo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bo *bo) WeekdaysShort() []string { + return bo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bo *bo) WeekdayWide(weekday time.Weekday) string { + return bo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bo *bo) WeekdaysWide() []string { + return bo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bo' and handles both Whole and Real numbers based on 'v' +func (bo *bo) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bo *bo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bo' +func (bo *bo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bo.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bo' +// in accounting notation. +func (bo *bo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bo.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyNegativePrefix[j]) + } + + b = append(b, bo.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bo' +func (bo *bo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bo' +func (bo *bo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b}...) + b = append(b, bo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bo' +func (bo *bo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, bo.monthsWide[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bo' +func (bo *bo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, bo.monthsWide[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, bo.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bo' +func (bo *bo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bo' +func (bo *bo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bo' +func (bo *bo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bo' +func (bo *bo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bo/bo_test.go b/vendor/github.com/go-playground/locales/bo/bo_test.go new file mode 100644 index 0000000000..33fcc1bb3a --- /dev/null +++ b/vendor/github.com/go-playground/locales/bo/bo_test.go @@ -0,0 +1,1120 @@ +package bo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bo_CN/bo_CN.go b/vendor/github.com/go-playground/locales/bo_CN/bo_CN.go new file mode 100644 index 0000000000..de7e99b10b --- /dev/null +++ b/vendor/github.com/go-playground/locales/bo_CN/bo_CN.go @@ -0,0 +1,628 @@ +package bo_CN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bo_CN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bo_CN' locale +func New() locales.Translator { + return &bo_CN{ + locale: "bo_CN", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ཟླ་༡", "ཟླ་༢", "ཟླ་༣", "ཟླ་༤", "ཟླ་༥", "ཟླ་༦", "ཟླ་༧", "ཟླ་༨", "ཟླ་༩", "ཟླ་༡༠", "ཟླ་༡༡", "ཟླ་༡༢"}, + monthsWide: []string{"", "ཟླ་བ་དང་པོ", "ཟླ་བ་གཉིས་པ", "ཟླ་བ་གསུམ་པ", "ཟླ་བ་བཞི་པ", "ཟླ་བ་ལྔ་པ", "ཟླ་བ་དྲུག་པ", "ཟླ་བ་བདུན་པ", "ཟླ་བ་བརྒྱད་པ", "ཟླ་བ་དགུ་པ", "ཟླ་བ་བཅུ་པ", "ཟླ་བ་བཅུ་གཅིག་པ", "ཟླ་བ་བཅུ་གཉིས་པ"}, + daysAbbreviated: []string{"ཉི་མ་", "ཟླ་བ་", "མིག་དམར་", "ལྷག་པ་", "ཕུར་བུ་", "པ་སངས་", "སྤེན་པ་"}, + daysNarrow: []string{"ཉི", "ཟླ", "མིག", "ལྷག", "ཕུར", "སངས", "སྤེན"}, + daysWide: []string{"གཟའ་ཉི་མ་", "གཟའ་ཟླ་བ་", "གཟའ་མིག་དམར་", "གཟའ་ལྷག་པ་", "གཟའ་ཕུར་བུ་", "གཟའ་པ་སངས་", "གཟའ་སྤེན་པ་"}, + periodsAbbreviated: []string{"སྔ་དྲོ་", "ཕྱི་དྲོ་"}, + periodsWide: []string{"སྔ་དྲོ་", "ཕྱི་དྲོ་"}, + erasAbbreviated: []string{"སྤྱི་ལོ་སྔོན་", "སྤྱི་ལོ་"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNEG": "HNEG", "SRT": "SRT", "MEZ": "MEZ", "CLT": "CLT", "TMT": "TMT", "TMST": "TMST", "EDT": "EDT", "COST": "COST", "AWDT": "AWDT", "GMT": "GMT", "ACST": "ACST", "MYT": "MYT", "MST": "MST", "AEST": "AEST", "BOT": "BOT", "ADT": "ADT", "WEZ": "WEZ", "WAST": "WAST", "ChST": "ChST", "LHDT": "LHDT", "CHAST": "CHAST", "WESZ": "WESZ", "HEOG": "HEOG", "ARST": "ARST", "UYST": "UYST", "HNPMX": "HNPMX", "ACWDT": "ACWDT", "JDT": "JDT", "WART": "WART", "EST": "EST", "WITA": "WITA", "WIB": "WIB", "NZST": "NZST", "ACWST": "ACWST", "ACDT": "ACDT", "BT": "BT", "∅∅∅": "∅∅∅", "AKDT": "AKDT", "CDT": "CDT", "HADT": "HADT", "HAT": "HAT", "HEPMX": "HEPMX", "NZDT": "NZDT", "MESZ": "MESZ", "VET": "VET", "HKT": "HKT", "HNPM": "HNPM", "LHST": "LHST", "PST": "PST", "HKST": "HKST", "SAST": "SAST", "OEZ": "OEZ", "WARST": "WARST", "ART": "ART", "HNT": "HNT", "PDT": "PDT", "GYT": "GYT", "CST": "CST", "AST": "AST", "COT": "COT", "HEEG": "HEEG", "AKST": "AKST", "GFT": "GFT", "HEPM": "HEPM", "ECT": "ECT", "CLST": "CLST", "HNCU": "HNCU", "HECU": "HECU", "AWST": "AWST", "CHADT": "CHADT", "HAST": "HAST", "CAT": "CAT", "IST": "IST", "OESZ": "OESZ", "MDT": "MDT", "UYT": "UYT", "EAT": "EAT", "WIT": "WIT", "SGT": "SGT", "JST": "JST", "HNOG": "HNOG", "WAT": "WAT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "AEDT": "AEDT"}, + } +} + +// Locale returns the current translators string locale +func (bo *bo_CN) Locale() string { + return bo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bo_CN' +func (bo *bo_CN) PluralsCardinal() []locales.PluralRule { + return bo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bo_CN' +func (bo *bo_CN) PluralsOrdinal() []locales.PluralRule { + return bo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bo_CN' +func (bo *bo_CN) PluralsRange() []locales.PluralRule { + return bo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bo_CN' +func (bo *bo_CN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bo_CN' +func (bo *bo_CN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bo_CN' +func (bo *bo_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bo *bo_CN) MonthAbbreviated(month time.Month) string { + return bo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bo *bo_CN) MonthsAbbreviated() []string { + return bo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bo *bo_CN) MonthNarrow(month time.Month) string { + return bo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bo *bo_CN) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bo *bo_CN) MonthWide(month time.Month) string { + return bo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bo *bo_CN) MonthsWide() []string { + return bo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bo *bo_CN) WeekdayAbbreviated(weekday time.Weekday) string { + return bo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bo *bo_CN) WeekdaysAbbreviated() []string { + return bo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bo *bo_CN) WeekdayNarrow(weekday time.Weekday) string { + return bo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bo *bo_CN) WeekdaysNarrow() []string { + return bo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bo *bo_CN) WeekdayShort(weekday time.Weekday) string { + return bo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bo *bo_CN) WeekdaysShort() []string { + return bo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bo *bo_CN) WeekdayWide(weekday time.Weekday) string { + return bo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bo *bo_CN) WeekdaysWide() []string { + return bo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bo_CN' and handles both Whole and Real numbers based on 'v' +func (bo *bo_CN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bo_CN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bo *bo_CN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bo_CN' +func (bo *bo_CN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bo.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bo_CN' +// in accounting notation. +func (bo *bo_CN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bo.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyNegativePrefix[j]) + } + + b = append(b, bo.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bo_CN' +func (bo *bo_CN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bo_CN' +func (bo *bo_CN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b}...) + b = append(b, bo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bo_CN' +func (bo *bo_CN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, bo.monthsWide[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bo_CN' +func (bo *bo_CN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, bo.monthsWide[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, bo.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bo_CN' +func (bo *bo_CN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bo_CN' +func (bo *bo_CN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bo_CN' +func (bo *bo_CN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bo_CN' +func (bo *bo_CN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bo_CN/bo_CN_test.go b/vendor/github.com/go-playground/locales/bo_CN/bo_CN_test.go new file mode 100644 index 0000000000..f4e143a877 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bo_CN/bo_CN_test.go @@ -0,0 +1,1120 @@ +package bo_CN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bo_CN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bo_IN/bo_IN.go b/vendor/github.com/go-playground/locales/bo_IN/bo_IN.go new file mode 100644 index 0000000000..a11ccbfa88 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bo_IN/bo_IN.go @@ -0,0 +1,628 @@ +package bo_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bo_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bo_IN' locale +func New() locales.Translator { + return &bo_IN{ + locale: "bo_IN", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ཟླ་༡", "ཟླ་༢", "ཟླ་༣", "ཟླ་༤", "ཟླ་༥", "ཟླ་༦", "ཟླ་༧", "ཟླ་༨", "ཟླ་༩", "ཟླ་༡༠", "ཟླ་༡༡", "ཟླ་༡༢"}, + monthsWide: []string{"", "ཟླ་བ་དང་པོ", "ཟླ་བ་གཉིས་པ", "ཟླ་བ་གསུམ་པ", "ཟླ་བ་བཞི་པ", "ཟླ་བ་ལྔ་པ", "ཟླ་བ་དྲུག་པ", "ཟླ་བ་བདུན་པ", "ཟླ་བ་བརྒྱད་པ", "ཟླ་བ་དགུ་པ", "ཟླ་བ་བཅུ་པ", "ཟླ་བ་བཅུ་གཅིག་པ", "ཟླ་བ་བཅུ་གཉིས་པ"}, + daysAbbreviated: []string{"ཉི་མ་", "ཟླ་བ་", "མིག་དམར་", "ལྷག་པ་", "ཕུར་བུ་", "པ་སངས་", "སྤེན་པ་"}, + daysNarrow: []string{"ཉི", "ཟླ", "མིག", "ལྷག", "ཕུར", "སངས", "སྤེན"}, + daysWide: []string{"གཟའ་ཉི་མ་", "གཟའ་ཟླ་བ་", "གཟའ་མིག་དམར་", "གཟའ་ལྷག་པ་", "གཟའ་ཕུར་བུ་", "གཟའ་པ་སངས་", "གཟའ་སྤེན་པ་"}, + periodsAbbreviated: []string{"སྔ་དྲོ་", "ཕྱི་དྲོ་"}, + periodsWide: []string{"སྔ་དྲོ་", "ཕྱི་དྲོ་"}, + erasAbbreviated: []string{"སྤྱི་ལོ་སྔོན་", "སྤྱི་ལོ་"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"TMT": "TMT", "AKDT": "AKDT", "UYST": "UYST", "HECU": "HECU", "CST": "CST", "CLT": "CLT", "HEOG": "HEOG", "HEEG": "HEEG", "AEDT": "AEDT", "CHAST": "CHAST", "HADT": "HADT", "OEZ": "OEZ", "MDT": "MDT", "PST": "PST", "CLST": "CLST", "HNT": "HNT", "GFT": "GFT", "WAT": "WAT", "ACST": "ACST", "COST": "COST", "SGT": "SGT", "BOT": "BOT", "MESZ": "MESZ", "VET": "VET", "NZST": "NZST", "EDT": "EDT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "GYT": "GYT", "HNCU": "HNCU", "PDT": "PDT", "ACWDT": "ACWDT", "ChST": "ChST", "WITA": "WITA", "AEST": "AEST", "ACWST": "ACWST", "NZDT": "NZDT", "BT": "BT", "HAT": "HAT", "JST": "JST", "ACDT": "ACDT", "HNPM": "HNPM", "HEPMX": "HEPMX", "CDT": "CDT", "∅∅∅": "∅∅∅", "ADT": "ADT", "WARST": "WARST", "AWDT": "AWDT", "WEZ": "WEZ", "MST": "MST", "AKST": "AKST", "WESZ": "WESZ", "GMT": "GMT", "WAST": "WAST", "ECT": "ECT", "IST": "IST", "MEZ": "MEZ", "HNOG": "HNOG", "WIB": "WIB", "HEPM": "HEPM", "EAT": "EAT", "ARST": "ARST", "EST": "EST", "ART": "ART", "HAST": "HAST", "CAT": "CAT", "OESZ": "OESZ", "WART": "WART", "CHADT": "CHADT", "COT": "COT", "HKT": "HKT", "HNEG": "HNEG", "LHST": "LHST", "HNPMX": "HNPMX", "AWST": "AWST", "JDT": "JDT", "AST": "AST", "MYT": "MYT", "SRT": "SRT", "SAST": "SAST", "LHDT": "LHDT", "WIT": "WIT", "TMST": "TMST", "HKST": "HKST", "UYT": "UYT"}, + } +} + +// Locale returns the current translators string locale +func (bo *bo_IN) Locale() string { + return bo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bo_IN' +func (bo *bo_IN) PluralsCardinal() []locales.PluralRule { + return bo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bo_IN' +func (bo *bo_IN) PluralsOrdinal() []locales.PluralRule { + return bo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bo_IN' +func (bo *bo_IN) PluralsRange() []locales.PluralRule { + return bo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bo_IN' +func (bo *bo_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bo_IN' +func (bo *bo_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bo_IN' +func (bo *bo_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bo *bo_IN) MonthAbbreviated(month time.Month) string { + return bo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bo *bo_IN) MonthsAbbreviated() []string { + return bo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bo *bo_IN) MonthNarrow(month time.Month) string { + return bo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bo *bo_IN) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bo *bo_IN) MonthWide(month time.Month) string { + return bo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bo *bo_IN) MonthsWide() []string { + return bo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bo *bo_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return bo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bo *bo_IN) WeekdaysAbbreviated() []string { + return bo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bo *bo_IN) WeekdayNarrow(weekday time.Weekday) string { + return bo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bo *bo_IN) WeekdaysNarrow() []string { + return bo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bo *bo_IN) WeekdayShort(weekday time.Weekday) string { + return bo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bo *bo_IN) WeekdaysShort() []string { + return bo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bo *bo_IN) WeekdayWide(weekday time.Weekday) string { + return bo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bo *bo_IN) WeekdaysWide() []string { + return bo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bo_IN' and handles both Whole and Real numbers based on 'v' +func (bo *bo_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bo_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bo *bo_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bo_IN' +func (bo *bo_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bo.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, bo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bo_IN' +// in accounting notation. +func (bo *bo_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bo.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyNegativePrefix[j]) + } + + b = append(b, bo.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(bo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, bo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bo_IN' +func (bo *bo_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bo_IN' +func (bo *bo_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b}...) + b = append(b, bo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bo_IN' +func (bo *bo_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, bo.monthsWide[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bo_IN' +func (bo *bo_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, bo.monthsWide[t.Month()]...) + b = append(b, []byte{0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, bo.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bo_IN' +func (bo *bo_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bo_IN' +func (bo *bo_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bo_IN' +func (bo *bo_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bo_IN' +func (bo *bo_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, bo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, bo.periodsAbbreviated[0]...) + } else { + b = append(b, bo.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bo_IN/bo_IN_test.go b/vendor/github.com/go-playground/locales/bo_IN/bo_IN_test.go new file mode 100644 index 0000000000..b157540692 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bo_IN/bo_IN_test.go @@ -0,0 +1,1120 @@ +package bo_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bo_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/br/br.go b/vendor/github.com/go-playground/locales/br/br.go new file mode 100644 index 0000000000..75cd806a9c --- /dev/null +++ b/vendor/github.com/go-playground/locales/br/br.go @@ -0,0 +1,608 @@ +package br + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type br struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'br' locale +func New() locales.Translator { + return &br{ + locale: "br", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$A", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "$CA", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£ RU", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "$ HK", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$ ZN", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$ SU", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Gen.", "Cʼhwe.", "Meur.", "Ebr.", "Mae", "Mezh.", "Goue.", "Eost", "Gwen.", "Here", "Du", "Kzu."}, + monthsNarrow: []string{"", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}, + monthsWide: []string{"", "Genver", "Cʼhwevrer", "Meurzh", "Ebrel", "Mae", "Mezheven", "Gouere", "Eost", "Gwengolo", "Here", "Du", "Kerzu"}, + daysAbbreviated: []string{"Sul", "Lun", "Meu.", "Mer.", "Yaou", "Gwe.", "Sad."}, + daysNarrow: []string{"Su", "L", "Mz", "Mc", "Y", "G", "Sa"}, + daysShort: []string{"Sul", "Lun", "Meu.", "Mer.", "Yaou", "Gwe.", "Sad."}, + daysWide: []string{"Sul", "Lun", "Meurzh", "Mercʼher", "Yaou", "Gwener", "Sadorn"}, + periodsAbbreviated: []string{"A.M.", "G.M."}, + periodsNarrow: []string{"am", "gm"}, + periodsWide: []string{"A.M.", "G.M."}, + erasAbbreviated: []string{"a-raok J.K.", "goude J.K."}, + erasNarrow: []string{"a-raok J.K.", "goude J.K."}, + erasWide: []string{"a-raok Jezuz-Krist", "goude Jezuz-Krist"}, + timezones: map[string]string{"WITA": "WITA", "∅∅∅": "eur hañv an Azorez", "HEOG": "eur hañv Greunland ar Cʼhornôg", "ARST": "eur hañv Arcʼhantina", "WAST": "eur hañv Afrika ar Cʼhornôg", "HKT": "eur cʼhoañv Hong Kong", "WART": "eur cʼhoañv Arcʼhantina ar Cʼhornôg", "WARST": "eur hañv Arcʼhantina ar Cʼhornôg", "CLST": "eur hañv Chile", "AST": "AST", "WEZ": "eur cʼhoañv Europa ar Cʼhornôg", "UYT": "eur cʼhoañv Uruguay", "HECU": "eur hañv Kuba", "CHAST": "eur cʼhoañv Chatham", "NZDT": "eur hañv Zeland-Nevez", "ART": "eur cʼhoañv Arcʼhantina", "CLT": "eur cʼhoañv Chile", "EDT": "eur hañv ar Reter", "HKST": "eur hañv Hong Kong", "HENOMX": "eur hañv Gwalarn Mecʼhiko", "HAT": "eur hañv Newfoundland", "HNCU": "eur cʼhoañv Kuba", "AWDT": "eur hañv Aostralia ar Cʼhornôg", "SGT": "eur cʼhoañv Singapour", "PDT": "PDT", "VET": "eur Venezuela", "OEZ": "eur cʼhoañv Europa ar Reter", "LHDT": "LHDT", "AWST": "eur cʼhoañv Aostralia ar Cʼhornôg", "HAST": "HAST", "MESZ": "eur hañv Kreizeuropa", "ADT": "ADT", "HNEG": "eur cʼhoañv Greunland ar Reter", "AKST": "eur cʼhoañv Alaska", "HEPMX": "HEPMX", "SRT": "eur Surinam", "BOT": "eur Bolivia", "TMST": "eur hañv Turkmenistan", "CST": "CST", "HNOG": "eur cʼhoañv Greunland ar Cʼhornôg", "COST": "eur hañv Kolombia", "MST": "eur cʼhoañv ar Menezioù", "GYT": "eur Guyana", "EAT": "eur Afrika ar Reter", "COT": "eur cʼhoañv Kolombia", "NZST": "eur cʼhoañv Zeland-Nevez", "GMT": "Amzer keitat Greenwich (AKG)", "ACDT": "eur hañv Kreizaostralia", "MDT": "eur hañv ar Menezioù", "WIT": "eur Indonezia ar Reter", "HADT": "HADT", "IST": "eur cʼhoañv India", "ACWST": "eur cʼhoañv Kreizaostralia ar Cʼhornôg", "HNNOMX": "eur cʼhoañv Gwalarn Mecʼhiko", "HNT": "eur cʼhoañv Newfoundland", "HEPM": "eur hañv Sant-Pêr-ha-Mikelon", "WIB": "eur Indonezia ar Cʼhornôg", "WESZ": "eur hañv Europa ar Cʼhornôg", "ACST": "eur cʼhoañv Kreizaostralia", "HEEG": "eur hañv Greunland ar Reter", "AKDT": "eur hañv Alaska", "AEST": "eur cʼhoañv Aostralia ar Reter", "SAST": "eur cʼhoañv Suafrika", "HNPMX": "HNPMX", "MYT": "eur Malaysia", "UYST": "eur hañv Uruguay", "CHADT": "eur hañv Chatham", "ACWDT": "eur hañv Kreizaostralia ar Cʼhornôg", "MEZ": "eur cʼhoañv Kreizeuropa", "OESZ": "eur hañv Europa ar Reter", "WAT": "eur cʼhoañv Afrika ar Cʼhornôg", "ChST": "ChST", "LHST": "LHST", "ECT": "eur Ecuador", "CAT": "eur Kreizafrika", "JDT": "eur hañv Japan", "GFT": "eur Gwiana cʼhall", "HNPM": "eur cʼhoañv Sant-Pêr-ha-Mikelon", "PST": "PST", "TMT": "eur cʼhoañv Turkmenistan", "AEDT": "eur hañv Aostralia ar Reter", "CDT": "CDT", "JST": "eur cʼhoañv Japan", "EST": "eur cʼhoañv ar Reter", "BT": "eur Bhoutan"}, + } +} + +// Locale returns the current translators string locale +func (br *br) Locale() string { + return br.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'br' +func (br *br) PluralsCardinal() []locales.PluralRule { + return br.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'br' +func (br *br) PluralsOrdinal() []locales.PluralRule { + return br.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'br' +func (br *br) PluralsRange() []locales.PluralRule { + return br.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'br' +func (br *br) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + nMod1000000 := math.Mod(n, 1000000) + + if nMod10 == 1 && (nMod100 != 11 && nMod100 != 71 && nMod100 != 91) { + return locales.PluralRuleOne + } else if nMod10 == 2 && (nMod100 != 12 && nMod100 != 72 && nMod100 != 92) { + return locales.PluralRuleTwo + } else if nMod10 >= 3 && nMod10 <= 4 && (nMod10 == 9) && (nMod100 < 10 || nMod100 > 19) || (nMod100 < 70 || nMod100 > 79) || (nMod100 < 90 || nMod100 > 99) { + return locales.PluralRuleFew + } else if n != 0 && nMod1000000 == 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'br' +func (br *br) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'br' +func (br *br) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (br *br) MonthAbbreviated(month time.Month) string { + return br.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (br *br) MonthsAbbreviated() []string { + return br.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (br *br) MonthNarrow(month time.Month) string { + return br.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (br *br) MonthsNarrow() []string { + return br.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (br *br) MonthWide(month time.Month) string { + return br.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (br *br) MonthsWide() []string { + return br.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (br *br) WeekdayAbbreviated(weekday time.Weekday) string { + return br.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (br *br) WeekdaysAbbreviated() []string { + return br.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (br *br) WeekdayNarrow(weekday time.Weekday) string { + return br.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (br *br) WeekdaysNarrow() []string { + return br.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (br *br) WeekdayShort(weekday time.Weekday) string { + return br.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (br *br) WeekdaysShort() []string { + return br.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (br *br) WeekdayWide(weekday time.Weekday) string { + return br.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (br *br) WeekdaysWide() []string { + return br.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'br' and handles both Whole and Real numbers based on 'v' +func (br *br) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, br.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(br.group) - 1; j >= 0; j-- { + b = append(b, br.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, br.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'br' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (br *br) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, br.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, br.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, br.percentSuffix...) + + b = append(b, br.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'br' +func (br *br) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := br.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, br.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(br.group) - 1; j >= 0; j-- { + b = append(b, br.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, br.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, br.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, br.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'br' +// in accounting notation. +func (br *br) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := br.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, br.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(br.group) - 1; j >= 0; j-- { + b = append(b, br.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, br.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, br.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, br.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, br.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'br' +func (br *br) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'br' +func (br *br) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, br.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'br' +func (br *br) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, br.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'br' +func (br *br) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, br.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, br.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'br' +func (br *br) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, br.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'br' +func (br *br) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, br.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, br.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'br' +func (br *br) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, br.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, br.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'br' +func (br *br) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, br.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, br.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := br.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/br/br_test.go b/vendor/github.com/go-playground/locales/br/br_test.go new file mode 100644 index 0000000000..f19012b0c0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/br/br_test.go @@ -0,0 +1,1120 @@ +package br + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "br" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/br_FR/br_FR.go b/vendor/github.com/go-playground/locales/br_FR/br_FR.go new file mode 100644 index 0000000000..e2fe4ee671 --- /dev/null +++ b/vendor/github.com/go-playground/locales/br_FR/br_FR.go @@ -0,0 +1,608 @@ +package br_FR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type br_FR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'br_FR' locale +func New() locales.Translator { + return &br_FR{ + locale: "br_FR", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Gen.", "Cʼhwe.", "Meur.", "Ebr.", "Mae", "Mezh.", "Goue.", "Eost", "Gwen.", "Here", "Du", "Kzu."}, + monthsNarrow: []string{"", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}, + monthsWide: []string{"", "Genver", "Cʼhwevrer", "Meurzh", "Ebrel", "Mae", "Mezheven", "Gouere", "Eost", "Gwengolo", "Here", "Du", "Kerzu"}, + daysAbbreviated: []string{"Sul", "Lun", "Meu.", "Mer.", "Yaou", "Gwe.", "Sad."}, + daysNarrow: []string{"Su", "L", "Mz", "Mc", "Y", "G", "Sa"}, + daysShort: []string{"Sul", "Lun", "Meu.", "Mer.", "Yaou", "Gwe.", "Sad."}, + daysWide: []string{"Sul", "Lun", "Meurzh", "Mercʼher", "Yaou", "Gwener", "Sadorn"}, + periodsAbbreviated: []string{"A.M.", "G.M."}, + periodsNarrow: []string{"am", "gm"}, + periodsWide: []string{"A.M.", "G.M."}, + erasAbbreviated: []string{"a-raok J.K.", "goude J.K."}, + erasNarrow: []string{"a-raok J.K.", "goude J.K."}, + erasWide: []string{"a-raok Jezuz-Krist", "goude Jezuz-Krist"}, + timezones: map[string]string{"GFT": "eur Gwiana cʼhall", "AKDT": "eur hañv Alaska", "HEPM": "eur hañv Sant-Pêr-ha-Mikelon", "EDT": "eur hañv ar Reter", "HNT": "eur cʼhoañv Newfoundland", "HEEG": "eur hañv Greunland ar Reter", "CHAST": "eur cʼhoañv Chatham", "CHADT": "eur hañv Chatham", "ECT": "eur Ecuador", "MESZ": "eur hañv Kreizeuropa", "AKST": "eur cʼhoañv Alaska", "UYT": "eur cʼhoañv Uruguay", "WIB": "eur Indonezia ar Cʼhornôg", "HAST": "HAST", "COST": "eur hañv Kolombia", "WARST": "eur hañv Arcʼhantina ar Cʼhornôg", "AEST": "eur cʼhoañv Aostralia ar Reter", "HAT": "eur hañv Newfoundland", "SRT": "eur Surinam", "GYT": "eur Guyana", "∅∅∅": "eur hañv Brasília", "JST": "eur cʼhoañv Japan", "JDT": "eur hañv Japan", "MST": "eur cʼhoañv Macau", "WAT": "eur cʼhoañv Afrika ar Cʼhornôg", "HEPMX": "HEPMX", "WIT": "eur Indonezia ar Reter", "ACWDT": "eur hañv Kreizaostralia ar Cʼhornôg", "GMT": "Amzer keitat Greenwich (AKG)", "TMT": "eur cʼhoañv Turkmenistan", "AWST": "eur cʼhoañv Aostralia ar Cʼhornôg", "PDT": "PDT", "OEZ": "eur cʼhoañv Europa ar Reter", "ARST": "eur hañv Arcʼhantina", "IST": "eur cʼhoañv India", "HNEG": "eur cʼhoañv Greunland ar Reter", "ChST": "ChST", "HEOG": "eur hañv Greunland ar Cʼhornôg", "HNNOMX": "eur cʼhoañv Gwalarn Mecʼhiko", "HNCU": "eur cʼhoañv Kuba", "CST": "CST", "CDT": "CDT", "HADT": "HADT", "EST": "eur cʼhoañv ar Reter", "HKT": "eur cʼhoañv Hong Kong", "SAST": "eur cʼhoañv Suafrika", "CLT": "eur cʼhoañv Chile", "HNOG": "eur cʼhoañv Greunland ar Cʼhornôg", "AST": "AST", "TMST": "eur hañv Turkmenistan", "BOT": "eur Bolivia", "BT": "eur Bhoutan", "CLST": "eur hañv Chile", "COT": "eur cʼhoañv Kolombia", "UYST": "eur hañv Uruguay", "HNPM": "eur cʼhoañv Sant-Pêr-ha-Mikelon", "HECU": "eur hañv Kuba", "ACWST": "eur cʼhoañv Kreizaostralia ar Cʼhornôg", "MEZ": "eur cʼhoañv Kreizeuropa", "WEZ": "eur cʼhoañv Europa ar Cʼhornôg", "HNPMX": "HNPMX", "OESZ": "eur hañv Europa ar Reter", "HKST": "eur hañv Hong Kong", "WAST": "eur hañv Afrika ar Cʼhornôg", "HENOMX": "eur hañv Gwalarn Mecʼhiko", "EAT": "eur Afrika ar Reter", "AWDT": "eur hañv Aostralia ar Cʼhornôg", "PST": "PST", "CAT": "eur Kreizafrika", "AEDT": "eur hañv Aostralia ar Reter", "LHDT": "LHDT", "ADT": "ADT", "ART": "eur cʼhoañv Arcʼhantina", "MDT": "eur hañv Macau", "WITA": "WITA", "NZST": "eur cʼhoañv Zeland-Nevez", "VET": "eur Venezuela", "WESZ": "eur hañv Europa ar Cʼhornôg", "WART": "eur cʼhoañv Arcʼhantina ar Cʼhornôg", "LHST": "LHST", "ACDT": "eur hañv Kreizaostralia", "SGT": "eur cʼhoañv Singapour", "NZDT": "eur hañv Zeland-Nevez", "MYT": "eur Malaysia", "ACST": "eur cʼhoañv Kreizaostralia"}, + } +} + +// Locale returns the current translators string locale +func (br *br_FR) Locale() string { + return br.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'br_FR' +func (br *br_FR) PluralsCardinal() []locales.PluralRule { + return br.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'br_FR' +func (br *br_FR) PluralsOrdinal() []locales.PluralRule { + return br.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'br_FR' +func (br *br_FR) PluralsRange() []locales.PluralRule { + return br.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'br_FR' +func (br *br_FR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + nMod1000000 := math.Mod(n, 1000000) + + if nMod10 == 1 && (nMod100 != 11 && nMod100 != 71 && nMod100 != 91) { + return locales.PluralRuleOne + } else if nMod10 == 2 && (nMod100 != 12 && nMod100 != 72 && nMod100 != 92) { + return locales.PluralRuleTwo + } else if nMod10 >= 3 && nMod10 <= 4 && (nMod10 == 9) && (nMod100 < 10 || nMod100 > 19) || (nMod100 < 70 || nMod100 > 79) || (nMod100 < 90 || nMod100 > 99) { + return locales.PluralRuleFew + } else if n != 0 && nMod1000000 == 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'br_FR' +func (br *br_FR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'br_FR' +func (br *br_FR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (br *br_FR) MonthAbbreviated(month time.Month) string { + return br.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (br *br_FR) MonthsAbbreviated() []string { + return br.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (br *br_FR) MonthNarrow(month time.Month) string { + return br.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (br *br_FR) MonthsNarrow() []string { + return br.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (br *br_FR) MonthWide(month time.Month) string { + return br.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (br *br_FR) MonthsWide() []string { + return br.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (br *br_FR) WeekdayAbbreviated(weekday time.Weekday) string { + return br.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (br *br_FR) WeekdaysAbbreviated() []string { + return br.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (br *br_FR) WeekdayNarrow(weekday time.Weekday) string { + return br.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (br *br_FR) WeekdaysNarrow() []string { + return br.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (br *br_FR) WeekdayShort(weekday time.Weekday) string { + return br.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (br *br_FR) WeekdaysShort() []string { + return br.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (br *br_FR) WeekdayWide(weekday time.Weekday) string { + return br.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (br *br_FR) WeekdaysWide() []string { + return br.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'br_FR' and handles both Whole and Real numbers based on 'v' +func (br *br_FR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, br.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(br.group) - 1; j >= 0; j-- { + b = append(b, br.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, br.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'br_FR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (br *br_FR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, br.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, br.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, br.percentSuffix...) + + b = append(b, br.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'br_FR' +func (br *br_FR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := br.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, br.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(br.group) - 1; j >= 0; j-- { + b = append(b, br.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, br.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, br.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, br.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'br_FR' +// in accounting notation. +func (br *br_FR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := br.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, br.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(br.group) - 1; j >= 0; j-- { + b = append(b, br.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, br.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, br.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, br.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, br.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'br_FR' +func (br *br_FR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'br_FR' +func (br *br_FR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, br.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'br_FR' +func (br *br_FR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, br.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'br_FR' +func (br *br_FR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, br.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, br.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'br_FR' +func (br *br_FR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, br.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'br_FR' +func (br *br_FR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, br.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, br.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'br_FR' +func (br *br_FR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, br.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, br.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'br_FR' +func (br *br_FR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, br.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, br.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := br.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/br_FR/br_FR_test.go b/vendor/github.com/go-playground/locales/br_FR/br_FR_test.go new file mode 100644 index 0000000000..ff80570591 --- /dev/null +++ b/vendor/github.com/go-playground/locales/br_FR/br_FR_test.go @@ -0,0 +1,1120 @@ +package br_FR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "br_FR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/brx/brx.go b/vendor/github.com/go-playground/locales/brx/brx.go new file mode 100644 index 0000000000..f959da76e0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/brx/brx.go @@ -0,0 +1,653 @@ +package brx + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type brx struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'brx' locale +func New() locales.Translator { + return &brx{ + locale: "brx", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsNarrow: []string{"", "ज", "फे", "मा", "ए", "मे", "जु", "जु", "आ", "से", "अ", "न", "दि"}, + monthsWide: []string{"", "जानुवारी", "फेब्रुवारी", "मार्स", "एफ्रिल", "मे", "जुन", "जुलाइ", "आगस्थ", "सेबथेज्ब़र", "अखथबर", "नबेज्ब़र", "दिसेज्ब़र"}, + daysAbbreviated: []string{"रबि", "सम", "मंगल", "बुद", "बिसथि", "सुखुर", "सुनि"}, + daysNarrow: []string{"र", "स", "मं", "बु", "बि", "सु", "सु"}, + daysWide: []string{"रबिबार", "समबार", "मंगलबार", "बुदबार", "बिसथिबार", "सुखुरबार", "सुनिबार"}, + periodsAbbreviated: []string{"फुं", "बेलासे"}, + periodsWide: []string{"फुं", "बेलासे"}, + erasAbbreviated: []string{"ईसा.पूर्व", "सन"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HKT": "हाँगकॉंग स्टैंडर्ड टाईम", "HNT": "न्युफाऊंडलैण्ड स्टैंडर्ड टाईम", "HEPMX": "HEPMX", "SRT": "सुरीनाम स्टैंडर्ड टाईम", "ACWST": "मध्य-पश्चीम ओस्ट्रेलिया स्टैंडर्ड टाईम", "JDT": "जपान डेलाईट टाईम", "HNOG": "ग्रीनलैण्ड वेस्टर्न स्टैंडर्ड टाईम", "WARST": "पश्चीम अर्जण्टिना समर टाईम", "ARST": "अर्जण्टिना समर टाईम", "COT": "कोलंबिया स्टैंडर्ड टाईम", "HNNOMX": "HNNOMX", "CHAST": "चैथम स्टैंडर्ड टाईम", "HAST": "हवाई आलटन स्टैंडर्ड टाईम", "NZST": "न्युज़ीलैण्ड स्टैंडर्ड टाईम", "ADT": "अटलांटीक डेलाईट टाईम", "CLT": "चीली स्टैंडर्ड टाईम", "ACST": "मध्य ओस्ट्रेलिया स्टैंडर्ड टाईम", "PDT": "पैसीफीक डेलाईट टाईम", "WART": "पश्चीम अर्जण्टिना स्टैंडर्ड टाईम", "UYT": "ऊरुगुए स्टैंडर्ड टाईम", "HNPMX": "HNPMX", "GYT": "गुयाना स्टैंडर्ड टाईम", "AWDT": "दक्षिण ओस्ट्रेलिया डेलाईट टाईम", "MEZ": "मध्य यूरोप स्टैंडर्ड टाईम", "GFT": "फ्रान्सीसी गुयाना स्टैंडर्ड टाईम", "HEEG": "ग्रीनलैण्ड ईस्टर्न समर टाईम", "SAST": "दक्षिण अफ्रीका स्टैंडर्ड टाईम", "CDT": "सैंट्रल अमरिका डेलाईट टाईम", "MESZ": "मध्य यूरोप समर टाईम", "OEZ": "ईस्टर्न यूरोप स्टैंडर्ड टाईम", "HEOG": "ग्रीनलैण्ड वेस्टर्न समर टाईम", "MST": "माकाऊ स्टैंडर्ड टाईम", "EST": "ईस्टर्न अमरिका स्टैंडर्ड टाईम", "ChST": "चामरो स्टैंडर्ड टाईम", "EAT": "पूर्वी अफ्रीका स्टैंडर्ड टाईम", "VET": "वेनेज़ुएला स्टैंडर्ड टाईम", "WEZ": "वेस्टर्न यूरोप स्टैंडर्ड टाईम", "AKST": "अलास्का स्टैंडर्ड टाईम", "AEST": "पूर्वी ओस्ट्रेलिया स्टैंडर्ड टाईम", "UYST": "ऊरुगुए समर टाईम", "ACWDT": "मध्य-पश्चीम ओस्ट्रेलिया डेलाईट टाईम", "∅∅∅": "आकर समर टाईम", "AKDT": "अलास्का डेलाईट टाईम", "AWST": "दक्षिण ओस्ट्रेलिया स्टैंडर्ड टाईम", "CHADT": "चैथम डेलाईट टाईम", "IST": "भारतीय स्टैंडर्ड टाईम", "COST": "कोलंबिया समर टाईम", "NZDT": "न्युज़ीलैण्ड डेलाईट टाईम", "SGT": "सींगापुर स्टैंडर्ड टाईम", "CLST": "चीली समर टाईम", "ACDT": "मध्य ओस्ट्रेलिया डेलाईट टाईम", "HECU": "क्युबा डेलाईट टाईम", "ECT": "एक्वाडौर स्टैंडर्ड टाईम", "MYT": "मलेशिया स्टैंडर्ड टाईम", "EDT": "ईस्टर्न अमरिका डेलाईट टाईम", "HENOMX": "HENOMX", "HEPM": "सेँ पीयॅर एवं मीकलों डेलाईट टाईम", "OESZ": "ईस्टर्न यूरोप समर टाईम", "HNEG": "ग्रीनलैण्ड ईस्टर्न स्टैंडर्ड टाईम", "AEDT": "पूर्वी ओस्ट्रेलिया डेलाईट टाईम", "LHDT": "लार्ड़ होव डेलाईट टाईम", "TMT": "तुर्कमेनीस्तान स्टैंडर्ड टाईम", "ART": "अर्जनटिना स्टैंडर्ड टाईम", "HKST": "हाँगकॉंग समर टाईम", "HNCU": "क्युबा स्टैंडर्ड टाईम", "WIB": "वेस्टर्न ईंडोनीशिया स्टैंडर्ड टाईम", "BOT": "बोलिविया स्टैंडर्ड टाईम", "GMT": "ग्रीनीच स्टैंडर्ड टाईम", "HAT": "न्युफाऊंडलैण्ड डेलाईट टाईम", "HNPM": "सेँ पीयॅर एवं मीकलों स्टैंडर्ड टाईम", "WIT": "ईस्टर्न ईंडोनीशिया स्टैंडर्ड टाईम", "PST": "पैसीफीक स्टैंडर्ड टाईम", "HADT": "हवाई आलटन डेलाईट टाईम", "CAT": "मध्य अफ्रीका स्टैंडर्ड टाईम", "JST": "जपान स्टैंडर्ड टाईम", "MDT": "माकाऊ समर टाईम", "WESZ": "वेस्टर्न यूरोप समर टाईम", "TMST": "तुर्कमेनीस्तान समर टाईम", "WAST": "पश्चीम अफ्रीका समर टाईम", "BT": "भुटान स्टैंडर्ड टाईम", "WITA": "ईंडोनीशिया स्टैंडर्ड टाईम", "LHST": "लार्ड़ होव स्टैंडर्ड टाईम", "CST": "सैंट्रल अमरिका स्टैंडर्ड टाईम", "AST": "अटलांटीक स्टैंडर्ड टाईम", "WAT": "पश्चीम अफ्रीका स्टैंडर्ड टाईम"}, + } +} + +// Locale returns the current translators string locale +func (brx *brx) Locale() string { + return brx.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'brx' +func (brx *brx) PluralsCardinal() []locales.PluralRule { + return brx.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'brx' +func (brx *brx) PluralsOrdinal() []locales.PluralRule { + return brx.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'brx' +func (brx *brx) PluralsRange() []locales.PluralRule { + return brx.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'brx' +func (brx *brx) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'brx' +func (brx *brx) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'brx' +func (brx *brx) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (brx *brx) MonthAbbreviated(month time.Month) string { + return brx.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (brx *brx) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (brx *brx) MonthNarrow(month time.Month) string { + return brx.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (brx *brx) MonthsNarrow() []string { + return brx.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (brx *brx) MonthWide(month time.Month) string { + return brx.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (brx *brx) MonthsWide() []string { + return brx.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (brx *brx) WeekdayAbbreviated(weekday time.Weekday) string { + return brx.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (brx *brx) WeekdaysAbbreviated() []string { + return brx.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (brx *brx) WeekdayNarrow(weekday time.Weekday) string { + return brx.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (brx *brx) WeekdaysNarrow() []string { + return brx.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (brx *brx) WeekdayShort(weekday time.Weekday) string { + return brx.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (brx *brx) WeekdaysShort() []string { + return brx.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (brx *brx) WeekdayWide(weekday time.Weekday) string { + return brx.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (brx *brx) WeekdaysWide() []string { + return brx.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'brx' and handles both Whole and Real numbers based on 'v' +func (brx *brx) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, brx.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, brx.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, brx.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'brx' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (brx *brx) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, brx.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, brx.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, brx.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'brx' +func (brx *brx) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := brx.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, brx.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, brx.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(brx.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, brx.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, brx.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, brx.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'brx' +// in accounting notation. +func (brx *brx) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := brx.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, brx.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, brx.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(brx.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, brx.currencyNegativePrefix[j]) + } + + b = append(b, brx.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(brx.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, brx.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, brx.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'brx' +func (brx *brx) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'brx' +func (brx *brx) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, brx.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'brx' +func (brx *brx) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, brx.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'brx' +func (brx *brx) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, brx.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, brx.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'brx' +func (brx *brx) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, brx.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, brx.periodsAbbreviated[0]...) + } else { + b = append(b, brx.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'brx' +func (brx *brx) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, brx.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, brx.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, brx.periodsAbbreviated[0]...) + } else { + b = append(b, brx.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'brx' +func (brx *brx) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, brx.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, brx.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, brx.periodsAbbreviated[0]...) + } else { + b = append(b, brx.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'brx' +func (brx *brx) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, brx.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, brx.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, brx.periodsAbbreviated[0]...) + } else { + b = append(b, brx.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := brx.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/brx/brx_test.go b/vendor/github.com/go-playground/locales/brx/brx_test.go new file mode 100644 index 0000000000..f6208f2692 --- /dev/null +++ b/vendor/github.com/go-playground/locales/brx/brx_test.go @@ -0,0 +1,1120 @@ +package brx + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "brx" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/brx_IN/brx_IN.go b/vendor/github.com/go-playground/locales/brx_IN/brx_IN.go new file mode 100644 index 0000000000..9f83b77aa7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/brx_IN/brx_IN.go @@ -0,0 +1,653 @@ +package brx_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type brx_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'brx_IN' locale +func New() locales.Translator { + return &brx_IN{ + locale: "brx_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsNarrow: []string{"", "ज", "फे", "मा", "ए", "मे", "जु", "जु", "आ", "से", "अ", "न", "दि"}, + monthsWide: []string{"", "जानुवारी", "फेब्रुवारी", "मार्स", "एफ्रिल", "मे", "जुन", "जुलाइ", "आगस्थ", "सेबथेज्ब़र", "अखथबर", "नबेज्ब़र", "दिसेज्ब़र"}, + daysAbbreviated: []string{"रबि", "सम", "मंगल", "बुद", "बिसथि", "सुखुर", "सुनि"}, + daysNarrow: []string{"र", "स", "मं", "बु", "बि", "सु", "सु"}, + daysWide: []string{"रबिबार", "समबार", "मंगलबार", "बुदबार", "बिसथिबार", "सुखुरबार", "सुनिबार"}, + periodsAbbreviated: []string{"फुं", "बेलासे"}, + periodsWide: []string{"फुं", "बेलासे"}, + erasAbbreviated: []string{"ईसा.पूर्व", "सन"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HKT": "हाँगकॉंग स्टैंडर्ड टाईम", "COST": "कोलंबिया समर टाईम", "MDT": "अमरिका माऊन्टन डेलाईट टाईम", "CAT": "मध्य अफ्रीका स्टैंडर्ड टाईम", "MYT": "मलेशिया स्टैंडर्ड टाईम", "TMT": "तुर्कमेनीस्तान स्टैंडर्ड टाईम", "HENOMX": "HENOMX", "BT": "भुटान स्टैंडर्ड टाईम", "HEPMX": "HEPMX", "WIT": "ईस्टर्न ईंडोनीशिया स्टैंडर्ड टाईम", "CLST": "चीली समर टाईम", "AST": "अटलांटीक स्टैंडर्ड टाईम", "HNEG": "ग्रीनलैण्ड ईस्टर्न स्टैंडर्ड टाईम", "MST": "अमरिका माऊन्टन स्टैंडर्ड टाईम", "HNPMX": "HNPMX", "LHDT": "लार्ड़ होव डेलाईट टाईम", "CST": "सैंट्रल अमरिका स्टैंडर्ड टाईम", "ACDT": "मध्य ओस्ट्रेलिया डेलाईट टाईम", "HNCU": "क्युबा स्टैंडर्ड टाईम", "BOT": "बोलिविया स्टैंडर्ड टाईम", "CHADT": "चैथम डेलाईट टाईम", "ECT": "एक्वाडौर स्टैंडर्ड टाईम", "WARST": "पश्चीम अर्जण्टिना समर टाईम", "OEZ": "ईस्टर्न यूरोप स्टैंडर्ड टाईम", "GFT": "फ्रान्सीसी गुयाना स्टैंडर्ड टाईम", "AKST": "अलास्का स्टैंडर्ड टाईम", "NZDT": "न्युज़ीलैण्ड डेलाईट टाईम", "MESZ": "मध्य यूरोप समर टाईम", "GMT": "ग्रीनीच स्टैंडर्ड टाईम", "AWDT": "दक्षिण ओस्ट्रेलिया डेलाईट टाईम", "PDT": "पैसीफीक डेलाईट टाईम", "MEZ": "मध्य यूरोप स्टैंडर्ड टाईम", "HNT": "न्युफाऊंडलैण्ड स्टैंडर्ड टाईम", "WITA": "ईंडोनीशिया स्टैंडर्ड टाईम", "SRT": "सुरीनाम स्टैंडर्ड टाईम", "WIB": "वेस्टर्न ईंडोनीशिया स्टैंडर्ड टाईम", "EAT": "पूर्वी अफ्रीका स्टैंडर्ड टाईम", "WART": "पश्चीम अर्जण्टिना स्टैंडर्ड टाईम", "LHST": "लार्ड़ होव स्टैंडर्ड टाईम", "IST": "भारतीय स्टैंडर्ड टाईम", "OESZ": "ईस्टर्न यूरोप समर टाईम", "WAST": "पश्चीम अफ्रीका समर टाईम", "HEEG": "ग्रीनलैण्ड ईस्टर्न समर टाईम", "AEDT": "पूर्वी ओस्ट्रेलिया डेलाईट टाईम", "HNPM": "सेँ पीयॅर एवं मीकलों स्टैंडर्ड टाईम", "ChST": "चामरो स्टैंडर्ड टाईम", "ARST": "अर्जण्टिना समर टाईम", "COT": "कोलंबिया स्टैंडर्ड टाईम", "AKDT": "अलास्का डेलाईट टाईम", "HEPM": "सेँ पीयॅर एवं मीकलों डेलाईट टाईम", "AWST": "दक्षिण ओस्ट्रेलिया स्टैंडर्ड टाईम", "WESZ": "वेस्टर्न यूरोप समर टाईम", "CLT": "चीली स्टैंडर्ड टाईम", "HNOG": "ग्रीनलैण्ड वेस्टर्न स्टैंडर्ड टाईम", "UYT": "ऊरुगुए स्टैंडर्ड टाईम", "NZST": "न्युज़ीलैण्ड स्टैंडर्ड टाईम", "CHAST": "चैथम स्टैंडर्ड टाईम", "HADT": "हवाई आलटन डेलाईट टाईम", "ADT": "अटलांटीक डेलाईट टाईम", "HKST": "हाँगकॉंग समर टाईम", "∅∅∅": "आकर समर टाईम", "HAT": "न्युफाऊंडलैण्ड डेलाईट टाईम", "UYST": "ऊरुगुए समर टाईम", "HECU": "क्युबा डेलाईट टाईम", "AEST": "पूर्वी ओस्ट्रेलिया स्टैंडर्ड टाईम", "SAST": "दक्षिण अफ्रीका स्टैंडर्ड टाईम", "TMST": "तुर्कमेनीस्तान समर टाईम", "GYT": "गुयाना स्टैंडर्ड टाईम", "HAST": "हवाई आलटन स्टैंडर्ड टाईम", "ACWST": "मध्य-पश्चीम ओस्ट्रेलिया स्टैंडर्ड टाईम", "JST": "जपान स्टैंडर्ड टाईम", "JDT": "जपान डेलाईट टाईम", "WEZ": "वेस्टर्न यूरोप स्टैंडर्ड टाईम", "ART": "अर्जनटिना स्टैंडर्ड टाईम", "WAT": "पश्चीम अफ्रीका स्टैंडर्ड टाईम", "EDT": "ईस्टर्न अमरिका डेलाईट टाईम", "ACST": "मध्य ओस्ट्रेलिया स्टैंडर्ड टाईम", "ACWDT": "मध्य-पश्चीम ओस्ट्रेलिया डेलाईट टाईम", "VET": "वेनेज़ुएला स्टैंडर्ड टाईम", "HEOG": "ग्रीनलैण्ड वेस्टर्न समर टाईम", "EST": "ईस्टर्न अमरिका स्टैंडर्ड टाईम", "HNNOMX": "HNNOMX", "CDT": "सैंट्रल अमरिका डेलाईट टाईम", "SGT": "सींगापुर स्टैंडर्ड टाईम", "PST": "पैसीफीक स्टैंडर्ड टाईम"}, + } +} + +// Locale returns the current translators string locale +func (brx *brx_IN) Locale() string { + return brx.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'brx_IN' +func (brx *brx_IN) PluralsCardinal() []locales.PluralRule { + return brx.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'brx_IN' +func (brx *brx_IN) PluralsOrdinal() []locales.PluralRule { + return brx.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'brx_IN' +func (brx *brx_IN) PluralsRange() []locales.PluralRule { + return brx.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'brx_IN' +func (brx *brx_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'brx_IN' +func (brx *brx_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'brx_IN' +func (brx *brx_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (brx *brx_IN) MonthAbbreviated(month time.Month) string { + return brx.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (brx *brx_IN) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (brx *brx_IN) MonthNarrow(month time.Month) string { + return brx.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (brx *brx_IN) MonthsNarrow() []string { + return brx.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (brx *brx_IN) MonthWide(month time.Month) string { + return brx.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (brx *brx_IN) MonthsWide() []string { + return brx.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (brx *brx_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return brx.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (brx *brx_IN) WeekdaysAbbreviated() []string { + return brx.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (brx *brx_IN) WeekdayNarrow(weekday time.Weekday) string { + return brx.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (brx *brx_IN) WeekdaysNarrow() []string { + return brx.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (brx *brx_IN) WeekdayShort(weekday time.Weekday) string { + return brx.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (brx *brx_IN) WeekdaysShort() []string { + return brx.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (brx *brx_IN) WeekdayWide(weekday time.Weekday) string { + return brx.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (brx *brx_IN) WeekdaysWide() []string { + return brx.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'brx_IN' and handles both Whole and Real numbers based on 'v' +func (brx *brx_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, brx.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, brx.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, brx.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'brx_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (brx *brx_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, brx.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, brx.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, brx.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'brx_IN' +func (brx *brx_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := brx.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, brx.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, brx.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(brx.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, brx.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, brx.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, brx.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'brx_IN' +// in accounting notation. +func (brx *brx_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := brx.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, brx.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, brx.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(brx.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, brx.currencyNegativePrefix[j]) + } + + b = append(b, brx.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(brx.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, brx.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, brx.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'brx_IN' +func (brx *brx_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'brx_IN' +func (brx *brx_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, brx.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'brx_IN' +func (brx *brx_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, brx.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'brx_IN' +func (brx *brx_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, brx.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, brx.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'brx_IN' +func (brx *brx_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, brx.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, brx.periodsAbbreviated[0]...) + } else { + b = append(b, brx.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'brx_IN' +func (brx *brx_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, brx.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, brx.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, brx.periodsAbbreviated[0]...) + } else { + b = append(b, brx.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'brx_IN' +func (brx *brx_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, brx.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, brx.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, brx.periodsAbbreviated[0]...) + } else { + b = append(b, brx.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'brx_IN' +func (brx *brx_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, brx.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, brx.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, brx.periodsAbbreviated[0]...) + } else { + b = append(b, brx.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := brx.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/brx_IN/brx_IN_test.go b/vendor/github.com/go-playground/locales/brx_IN/brx_IN_test.go new file mode 100644 index 0000000000..a76b2e1efd --- /dev/null +++ b/vendor/github.com/go-playground/locales/brx_IN/brx_IN_test.go @@ -0,0 +1,1120 @@ +package brx_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "brx_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bs/bs.go b/vendor/github.com/go-playground/locales/bs/bs.go new file mode 100644 index 0000000000..975f527957 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs/bs.go @@ -0,0 +1,621 @@ +package bs + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bs struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bs' locale +func New() locales.Translator { + return &bs{ + locale: "bs", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "KM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "kn", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "din.", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "avg", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januar", "februar", "mart", "april", "maj", "juni", "juli", "avgust", "septembar", "oktobar", "novembar", "decembar"}, + daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"}, + daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"prijepodne", "popodne"}, + periodsNarrow: []string{"prijepodne", "popodne"}, + periodsWide: []string{"prijepodne", "popodne"}, + erasAbbreviated: []string{"p. n. e.", "n. e."}, + erasNarrow: []string{"pr.n.e.", "AD"}, + erasWide: []string{"prije nove ere", "nove ere"}, + timezones: map[string]string{"MDT": "Makao letnje računanje vremena", "PDT": "Sjevernoameričko pacifičko ljetno vrijeme", "OEZ": "Istočnoevropsko standardno vrijeme", "WEZ": "Zapadnoevropsko standardno vrijeme", "HKT": "Hongkonško standardno vrijeme", "COT": "Kolumbijsko standardno vrijeme", "CDT": "Sjevernoameričko centralno ljetno vrijeme", "JST": "Japansko standardno vrijeme", "AST": "Sjevernoameričko atlantsko standardno vrijeme", "MST": "Makao standardno vreme", "AEDT": "Istočnoaustralijsko ljetno vrijeme", "WIT": "Istočnoindonezijsko vrijeme", "ECT": "Ekvadorsko vrijeme", "HEEG": "Istočnogrenlandsko ljetno vrijeme", "CST": "Sjevernoameričko centralno standardno vrijeme", "TMT": "Turkmenistansko standardno vrijeme", "HKST": "Hongkonško ljetno vrijeme", "ACST": "Centralnoaustralijsko standardno vrijeme", "HEPMX": "Meksičko pacifičko ljetno vrijeme", "AWST": "Zapadnoaustralijsko standardno vrijeme", "CLST": "Čileansko ljetno vrijeme", "ARST": "Argentinsko ljetno vrijeme", "COST": "Kolumbijsko ljetno vrijeme", "HNPM": "Standardno vrijeme na Ostrvima Sen Pjer i Mikelon", "LHDT": "Ljetno vrijeme na Ostrvu Lord Hau", "SRT": "Surinamsko vrijeme", "BOT": "Bolivijsko vrijeme", "MESZ": "Centralnoevropsko ljetno vrijeme", "ART": "Argentinsko standardno vrijeme", "HNNOMX": "Sjeverozapadno meksičko standardno vrijeme", "∅∅∅": "Peruansko ljetno vrijeme", "WITA": "Centralnoindonezijsko vrijeme", "HNPMX": "Meksičko pacifičko standardno vrijeme", "VET": "Venecuelansko vrijeme", "ADT": "Sjevernoameričko atlantsko ljetno vrijeme", "EAT": "Istočnoafričko vrijeme", "CAT": "Centralnoafričko vrijeme", "CHAST": "Čatamsko standardno vrijeme", "CHADT": "Čatamsko ljetno vrijeme", "SGT": "Singapursko standardno vrijeme", "HENOMX": "Sjeverozapadno meksičko ljetno vrijeme", "HNEG": "Istočnogrenlandsko standardno vrijeme", "AKDT": "Aljaskansko ljetno vrijeme", "ChST": "Čamorsko standardno vrijeme", "HECU": "Kubansko ljetno vrijeme", "ACWDT": "Australijsko centralnozapadno ljetno vrijeme", "SAST": "Južnoafričko standardno vrijeme", "GMT": "Griničko vrijeme", "WAST": "Zapadnoafričko ljetno vrijeme", "EST": "Sjevernoameričko istočno standardno vrijeme", "AKST": "Aljaskansko standardno vrijeme", "HEPM": "Ljetno vrijeme na Ostrvima Sen Pjer i Mikelon", "JDT": "Japansko ljetno vrijeme", "HNOG": "Zapadnogrenlandsko standardno vrijeme", "MYT": "Malezijsko vrijeme", "BT": "Butansko vrijeme", "GYT": "Gvajansko vrijeme", "NZST": "Novozelandsko standardno vrijeme", "IST": "Indijsko standardno vrijeme", "WART": "Zapadnoargentinsko standardno vrijeme", "WESZ": "Zapadnoevropsko ljetno vrijeme", "LHST": "Standardno vrijeme na Ostrvu Lord Hau", "AWDT": "Zapadnoaustralijsko ljetno vrijeme", "HADT": "Havajsko-aleućansko ljetno vrijeme", "HNT": "Njufaundlendsko standardno vrijeme", "MEZ": "Centralnoevropsko standardno vrijeme", "CLT": "Čileansko standardno vrijeme", "ACDT": "Centralnoaustralijsko ljetno vrijeme", "HNCU": "Kubansko standardno vrijeme", "WIB": "Zapadnoindonezijsko vrijeme", "PST": "Sjevernoameričko pacifičko standardno vrijeme", "HAST": "Havajsko-aleućansko standardno vrijeme", "ACWST": "Australijsko centralnozapadno standardno vrijeme", "NZDT": "Novozelandsko ljetno vrijeme", "HEOG": "Zapadnogrenlandsko ljetno vrijeme", "OESZ": "Istočnoevropsko ljetno vrijeme", "WAT": "Zapadnoafričko standardno vrijeme", "HAT": "Njufaundlendsko ljetno vrijeme", "UYST": "Urugvajsko ljetno vrijeme", "UYT": "Urugvajsko standardno vrijeme", "WARST": "Zapadnoargentinsko ljetno vrijeme", "TMST": "Turkmenistansko ljetno vrijeme", "EDT": "Sjevernoameričko istočno ljetno vrijeme", "GFT": "Francuskogvajansko vrijeme", "AEST": "Istočnoaustralijsko standardno vrijeme"}, + } +} + +// Locale returns the current translators string locale +func (bs *bs) Locale() string { + return bs.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bs' +func (bs *bs) PluralsCardinal() []locales.PluralRule { + return bs.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bs' +func (bs *bs) PluralsOrdinal() []locales.PluralRule { + return bs.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bs' +func (bs *bs) PluralsRange() []locales.PluralRule { + return bs.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bs' +func (bs *bs) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bs' +func (bs *bs) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bs' +func (bs *bs) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := bs.CardinalPluralRule(num1, v1) + end := bs.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bs *bs) MonthAbbreviated(month time.Month) string { + return bs.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bs *bs) MonthsAbbreviated() []string { + return bs.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bs *bs) MonthNarrow(month time.Month) string { + return bs.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bs *bs) MonthsNarrow() []string { + return bs.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bs *bs) MonthWide(month time.Month) string { + return bs.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bs *bs) MonthsWide() []string { + return bs.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bs *bs) WeekdayAbbreviated(weekday time.Weekday) string { + return bs.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bs *bs) WeekdaysAbbreviated() []string { + return bs.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bs *bs) WeekdayNarrow(weekday time.Weekday) string { + return bs.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bs *bs) WeekdaysNarrow() []string { + return bs.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bs *bs) WeekdayShort(weekday time.Weekday) string { + return bs.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bs *bs) WeekdaysShort() []string { + return bs.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bs *bs) WeekdayWide(weekday time.Weekday) string { + return bs.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bs *bs) WeekdaysWide() []string { + return bs.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bs' and handles both Whole and Real numbers based on 'v' +func (bs *bs) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bs' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bs *bs) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bs.percentSuffix...) + + b = append(b, bs.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bs' +func (bs *bs) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bs.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bs' +// in accounting notation. +func (bs *bs) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bs.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bs.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bs.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bs' +func (bs *bs) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bs' +func (bs *bs) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bs' +func (bs *bs) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bs' +func (bs *bs) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bs.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bs' +func (bs *bs) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bs' +func (bs *bs) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bs' +func (bs *bs) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bs' +func (bs *bs) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bs.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bs/bs_test.go b/vendor/github.com/go-playground/locales/bs/bs_test.go new file mode 100644 index 0000000000..91c7d67cc3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs/bs_test.go @@ -0,0 +1,1120 @@ +package bs + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bs" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bs_Cyrl/bs_Cyrl.go b/vendor/github.com/go-playground/locales/bs_Cyrl/bs_Cyrl.go new file mode 100644 index 0000000000..813da59106 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs_Cyrl/bs_Cyrl.go @@ -0,0 +1,636 @@ +package bs_Cyrl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bs_Cyrl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bs_Cyrl' locale +func New() locales.Translator { + return &bs_Cyrl{ + locale: "bs_Cyrl", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "КМ", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "Кч", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "зл", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "дин.", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "Тл", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "јан", "феб", "мар", "апр", "мај", "јун", "јул", "авг", "сеп", "окт", "нов", "дец"}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јуни", "јули", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"нед", "пон", "уто", "сри", "чет", "пет", "суб"}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysWide: []string{"недеља", "понедељак", "уторак", "сриједа", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"пре подне", "поподне"}, + periodsNarrow: []string{"prijepodne", "popodne"}, + periodsWide: []string{"пре подне", "поподне"}, + erasAbbreviated: []string{"п. н. е.", "н. е."}, + erasNarrow: []string{"п.н.е.", "н.е."}, + erasWide: []string{"Пре нове ере", "Нове ере"}, + timezones: map[string]string{"SGT": "Сингапур стандардно време", "HKT": "Хонг Конг стандардно време", "COT": "Колумбија стандардно време", "HNNOMX": "Sjeverozapadno meksičko standardno vrijeme", "HENOMX": "Sjeverozapadno meksičko ljetno vrijeme", "LHDT": "Лорд Хов летње рачунање времена", "AWDT": "Аустралијско западно летње рачунање времена", "MEZ": "Средњеевропско стандардно време", "JDT": "Јапанско летње рачунање времена", "HNCU": "Куба стандардно време", "CDT": "Централно летње рачунање времена", "NZDT": "Нови Зеланд летње рачунање времена", "OESZ": "Источноевропско летње рачунање времена", "BT": "Бутан време", "UYST": "Уругвај летње рачунање времена", "HAST": "Хавајско-алеутско стандардно време", "ART": "Аргентина стандардно време", "AKST": "Аљашко стандардно време", "CHADT": "Чатам летње рачунање времена", "CHAST": "Чатам стандардно време", "MYT": "Малезија време", "CLST": "Чиле летње рачунање времена", "WAT": "Западно-афричко стандардно време", "HNEG": "Источни Гренланд стандардно време", "GFT": "Француска Гвајана време", "AWST": "Аустралијско западно стандардно време", "HNPM": "Сен Пјер и Микелон стандардно време", "SAST": "Јужно-афричко време", "JST": "Јапанско стандардно време", "WESZ": "Западноевропско летње рачунање времена", "EST": "Источно стандардно време", "ACST": "Аустралијско централно стандардно време", "WITA": "Централно-индонезијско време", "ChST": "Чаморо време", "HEPMX": "Meksičko pacifičko ljetno vrijeme", "EAT": "Источно-афричко време", "HNPMX": "Meksičko pacifičko standardno vrijeme", "GYT": "Гвајана време", "CAT": "Централно-афричко време", "ACWST": "Аустралијско централно западно стандардно време", "ACWDT": "Аустралијско централно западно летње рачунање времена", "TMT": "Туркменистан стандардно време", "AKDT": "Аљашко летње време", "COST": "Колумбија летње рачунање времена", "HEEG": "Источни Гренланд летње рачунање времена", "HEPM": "Сен Пјер и Микелон летње рачунање вемена", "SRT": "Суринам време", "HECU": "Куба летње рачунање времена", "WIB": "Западно-индонезијско време", "AST": "Атланско стандардно време", "ADT": "Атланско лтње рачунање времена", "TMST": "Туркменистан летње рачунање времена", "ARST": "Аргентина летње рачунање времена", "ACDT": "Аустралијско централно летње рачунање времена", "LHST": "Лорд Хов стандардно време", "VET": "Венецуела време", "MDT": "Макао летње рачунање вемена", "AEDT": "Аустралијско источно летње рачунање времена", "WIT": "Источно-индонезијско време", "WART": "Западна Аргентина стандардно време", "GMT": "Гринвич средње време", "HAT": "Њуфаундленд летње рачунање времена", "PDT": "Пацифичко летње рачунање времена", "BOT": "Боливија време", "∅∅∅": "Амазон летње рачунање времена", "WARST": "Западна Аргентина летње рачунање времена", "HNOG": "Западни Гренланд стандардно време", "MST": "Макао стандардно време", "EDT": "Источно летње рачунање времена", "UYT": "Уругвај стандардно време", "NZST": "Нови Зеланд стандардно време", "MESZ": "Средњеевропско летње рачунање времена", "CLT": "Чиле стандардно време", "AEST": "Аустралијско источно стандардно време", "CST": "Централно стандардно време", "WEZ": "Западноевропско стандардно време", "WAST": "Западно-афричко летње рачунање времена", "PST": "Пацифичко стандардно време", "HADT": "Хавајско-алеутско летње рачунање времена", "IST": "Индијско стандардно време", "HEOG": "Западни Гренланд летње рачунање времена", "OEZ": "Источноевропско стандардно време", "HKST": "Хонгконшко летње рачунање времена", "HNT": "Њуфаундленд стандардно време", "ECT": "Еквадор време"}, + } +} + +// Locale returns the current translators string locale +func (bs *bs_Cyrl) Locale() string { + return bs.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bs_Cyrl' +func (bs *bs_Cyrl) PluralsCardinal() []locales.PluralRule { + return bs.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bs_Cyrl' +func (bs *bs_Cyrl) PluralsOrdinal() []locales.PluralRule { + return bs.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bs_Cyrl' +func (bs *bs_Cyrl) PluralsRange() []locales.PluralRule { + return bs.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Cyrl' +func (bs *bs_Cyrl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod100 := f % 100 + fMod10 := f % 10 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Cyrl' +func (bs *bs_Cyrl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bs_Cyrl' +func (bs *bs_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := bs.CardinalPluralRule(num1, v1) + end := bs.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bs *bs_Cyrl) MonthAbbreviated(month time.Month) string { + return bs.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bs *bs_Cyrl) MonthsAbbreviated() []string { + return bs.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bs *bs_Cyrl) MonthNarrow(month time.Month) string { + return bs.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bs *bs_Cyrl) MonthsNarrow() []string { + return bs.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bs *bs_Cyrl) MonthWide(month time.Month) string { + return bs.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bs *bs_Cyrl) MonthsWide() []string { + return bs.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bs *bs_Cyrl) WeekdayAbbreviated(weekday time.Weekday) string { + return bs.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bs *bs_Cyrl) WeekdaysAbbreviated() []string { + return bs.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bs *bs_Cyrl) WeekdayNarrow(weekday time.Weekday) string { + return bs.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bs *bs_Cyrl) WeekdaysNarrow() []string { + return bs.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bs *bs_Cyrl) WeekdayShort(weekday time.Weekday) string { + return bs.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bs *bs_Cyrl) WeekdaysShort() []string { + return bs.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bs *bs_Cyrl) WeekdayWide(weekday time.Weekday) string { + return bs.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bs *bs_Cyrl) WeekdaysWide() []string { + return bs.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bs_Cyrl' and handles both Whole and Real numbers based on 'v' +func (bs *bs_Cyrl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bs_Cyrl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bs *bs_Cyrl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bs.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bs.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Cyrl' +// in accounting notation. +func (bs *bs_Cyrl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bs.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bs.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bs.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bs.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bs_Cyrl' +func (bs *bs_Cyrl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bs.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bs_Cyrl/bs_Cyrl_test.go b/vendor/github.com/go-playground/locales/bs_Cyrl/bs_Cyrl_test.go new file mode 100644 index 0000000000..b4132d5335 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs_Cyrl/bs_Cyrl_test.go @@ -0,0 +1,1120 @@ +package bs_Cyrl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bs_Cyrl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bs_Cyrl_BA/bs_Cyrl_BA.go b/vendor/github.com/go-playground/locales/bs_Cyrl_BA/bs_Cyrl_BA.go new file mode 100644 index 0000000000..8aa854f22c --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs_Cyrl_BA/bs_Cyrl_BA.go @@ -0,0 +1,621 @@ +package bs_Cyrl_BA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bs_Cyrl_BA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bs_Cyrl_BA' locale +func New() locales.Translator { + return &bs_Cyrl_BA{ + locale: "bs_Cyrl_BA", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "avg", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januar", "februar", "mart", "april", "maj", "juni", "juli", "avgust", "septembar", "oktobar", "novembar", "decembar"}, + daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"}, + daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"prijepodne", "popodne"}, + periodsNarrow: []string{"prijepodne", "popodne"}, + periodsWide: []string{"prijepodne", "popodne"}, + erasAbbreviated: []string{"p. n. e.", "n. e."}, + erasNarrow: []string{"pr.n.e.", "AD"}, + erasWide: []string{"prije nove ere", "nove ere"}, + timezones: map[string]string{"AST": "Sjevernoameričko atlantsko standardno vrijeme", "MST": "Makao standardno vreme", "LHST": "Standardno vrijeme na Ostrvu Lord Hau", "SGT": "Singapursko standardno vrijeme", "CHADT": "Čatamsko ljetno vrijeme", "IST": "Indijsko standardno vrijeme", "ACWDT": "Australijsko centralnozapadno ljetno vrijeme", "WIT": "Istočnoindonezijsko vrijeme", "NZST": "Novozelandsko standardno vrijeme", "WART": "Zapadnoargentinsko standardno vrijeme", "UYST": "Urugvajsko ljetno vrijeme", "ChST": "Čamorsko standardno vrijeme", "GYT": "Gvajansko vrijeme", "HNCU": "Kubansko standardno vrijeme", "EAT": "Istočnoafričko vrijeme", "EST": "Sjevernoameričko istočno standardno vrijeme", "AWST": "Zapadnoaustralijsko standardno vrijeme", "NZDT": "Novozelandsko ljetno vrijeme", "OEZ": "Istočnoevropsko standardno vrijeme", "MDT": "Makao letnje računanje vremena", "ACDT": "Centralnoaustralijsko ljetno vrijeme", "AKST": "Aljaskansko standardno vrijeme", "CST": "Sjevernoameričko centralno standardno vrijeme", "OESZ": "Istočnoevropsko ljetno vrijeme", "ARST": "Argentinsko ljetno vrijeme", "HNNOMX": "Sjeverozapadno meksičko standardno vrijeme", "GFT": "Francuskogvajansko vrijeme", "WITA": "Centralnoindonezijsko vrijeme", "AKDT": "Aljaskansko ljetno vrijeme", "LHDT": "Ljetno vrijeme na Ostrvu Lord Hau", "MEZ": "Centralnoevropsko standardno vrijeme", "WESZ": "Zapadnoevropsko ljetno vrijeme", "CLST": "Čileansko ljetno vrijeme", "COT": "Kolumbijsko standardno vrijeme", "HEPM": "Ljetno vrijeme na Ostrvima Sen Pjer i Mikelon", "HNPMX": "Meksičko pacifičko standardno vrijeme", "HEPMX": "Meksičko pacifičko ljetno vrijeme", "CAT": "Centralnoafričko vrijeme", "TMT": "Turkmenistansko standardno vrijeme", "ADT": "Sjevernoameričko atlantsko ljetno vrijeme", "AEDT": "Istočnoaustralijsko ljetno vrijeme", "BOT": "Bolivijsko vrijeme", "ACWST": "Australijsko centralnozapadno standardno vrijeme", "GMT": "Griničko vrijeme", "MYT": "Malezijsko vrijeme", "HEOG": "Zapadnogrenlandsko ljetno vrijeme", "HECU": "Kubansko ljetno vrijeme", "AWDT": "Zapadnoaustralijsko ljetno vrijeme", "JDT": "Japansko ljetno vrijeme", "BT": "Butansko vrijeme", "UYT": "Urugvajsko standardno vrijeme", "PST": "Sjevernoameričko pacifičko standardno vrijeme", "JST": "Japansko standardno vrijeme", "AEST": "Istočnoaustralijsko standardno vrijeme", "HKST": "Hongkonško ljetno vrijeme", "WAT": "Zapadnoafričko standardno vrijeme", "WAST": "Zapadnoafričko ljetno vrijeme", "ACST": "Centralnoaustralijsko standardno vrijeme", "HNT": "Njufaundlendsko standardno vrijeme", "SAST": "Južnoafričko standardno vrijeme", "PDT": "Sjevernoameričko pacifičko ljetno vrijeme", "ECT": "Ekvadorsko vrijeme", "TMST": "Turkmenistansko ljetno vrijeme", "COST": "Kolumbijsko ljetno vrijeme", "HAST": "Havajsko-aleućansko standardno vrijeme", "MESZ": "Centralnoevropsko ljetno vrijeme", "WARST": "Zapadnoargentinsko ljetno vrijeme", "ART": "Argentinsko standardno vrijeme", "HEEG": "Istočnogrenlandsko ljetno vrijeme", "CDT": "Sjevernoameričko centralno ljetno vrijeme", "CHAST": "Čatamsko standardno vrijeme", "EDT": "Sjevernoameričko istočno ljetno vrijeme", "HENOMX": "Sjeverozapadno meksičko ljetno vrijeme", "HAT": "Njufaundlendsko ljetno vrijeme", "SRT": "Surinamsko vrijeme", "WEZ": "Zapadnoevropsko standardno vrijeme", "CLT": "Čileansko standardno vrijeme", "HNOG": "Zapadnogrenlandsko standardno vrijeme", "HKT": "Hongkonško standardno vrijeme", "HNEG": "Istočnogrenlandsko standardno vrijeme", "HNPM": "Standardno vrijeme na Ostrvima Sen Pjer i Mikelon", "∅∅∅": "Azorsko ljetno vrijeme", "WIB": "Zapadnoindonezijsko vrijeme", "HADT": "Havajsko-aleućansko ljetno vrijeme", "VET": "Venecuelansko vrijeme"}, + } +} + +// Locale returns the current translators string locale +func (bs *bs_Cyrl_BA) Locale() string { + return bs.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) PluralsCardinal() []locales.PluralRule { + return bs.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) PluralsOrdinal() []locales.PluralRule { + return bs.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) PluralsRange() []locales.PluralRule { + return bs.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := bs.CardinalPluralRule(num1, v1) + end := bs.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bs *bs_Cyrl_BA) MonthAbbreviated(month time.Month) string { + return bs.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bs *bs_Cyrl_BA) MonthsAbbreviated() []string { + return bs.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bs *bs_Cyrl_BA) MonthNarrow(month time.Month) string { + return bs.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bs *bs_Cyrl_BA) MonthsNarrow() []string { + return bs.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bs *bs_Cyrl_BA) MonthWide(month time.Month) string { + return bs.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bs *bs_Cyrl_BA) MonthsWide() []string { + return bs.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bs *bs_Cyrl_BA) WeekdayAbbreviated(weekday time.Weekday) string { + return bs.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bs *bs_Cyrl_BA) WeekdaysAbbreviated() []string { + return bs.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bs *bs_Cyrl_BA) WeekdayNarrow(weekday time.Weekday) string { + return bs.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bs *bs_Cyrl_BA) WeekdaysNarrow() []string { + return bs.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bs *bs_Cyrl_BA) WeekdayShort(weekday time.Weekday) string { + return bs.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bs *bs_Cyrl_BA) WeekdaysShort() []string { + return bs.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bs *bs_Cyrl_BA) WeekdayWide(weekday time.Weekday) string { + return bs.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bs *bs_Cyrl_BA) WeekdaysWide() []string { + return bs.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bs_Cyrl_BA' and handles both Whole and Real numbers based on 'v' +func (bs *bs_Cyrl_BA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bs_Cyrl_BA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bs *bs_Cyrl_BA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bs.percentSuffix...) + + b = append(b, bs.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bs.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Cyrl_BA' +// in accounting notation. +func (bs *bs_Cyrl_BA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bs.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bs.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bs.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bs.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bs_Cyrl_BA' +func (bs *bs_Cyrl_BA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bs.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bs_Cyrl_BA/bs_Cyrl_BA_test.go b/vendor/github.com/go-playground/locales/bs_Cyrl_BA/bs_Cyrl_BA_test.go new file mode 100644 index 0000000000..42efd373ea --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs_Cyrl_BA/bs_Cyrl_BA_test.go @@ -0,0 +1,1120 @@ +package bs_Cyrl_BA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bs_Cyrl_BA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bs_Latn/bs_Latn.go b/vendor/github.com/go-playground/locales/bs_Latn/bs_Latn.go new file mode 100644 index 0000000000..e4b0c82cd0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs_Latn/bs_Latn.go @@ -0,0 +1,621 @@ +package bs_Latn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bs_Latn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bs_Latn' locale +func New() locales.Translator { + return &bs_Latn{ + locale: "bs_Latn", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "avg", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januar", "februar", "mart", "april", "maj", "juni", "juli", "avgust", "septembar", "oktobar", "novembar", "decembar"}, + daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"}, + daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"prijepodne", "popodne"}, + periodsNarrow: []string{"prijepodne", "popodne"}, + periodsWide: []string{"prijepodne", "popodne"}, + erasAbbreviated: []string{"p. n. e.", "n. e."}, + erasNarrow: []string{"pr.n.e.", "AD"}, + erasWide: []string{"prije nove ere", "nove ere"}, + timezones: map[string]string{"JDT": "Japansko ljetno vrijeme", "TMT": "Turkmenistansko standardno vrijeme", "HNPM": "Standardno vrijeme na Ostrvima Sen Pjer i Mikelon", "HEPM": "Ljetno vrijeme na Ostrvima Sen Pjer i Mikelon", "CDT": "Sjevernoameričko centralno ljetno vrijeme", "HEPMX": "Meksičko pacifičko ljetno vrijeme", "CHAST": "Čatamsko standardno vrijeme", "MST": "Makao standardno vreme", "WARST": "Zapadnoargentinsko ljetno vrijeme", "CLT": "Čileansko standardno vrijeme", "ACWST": "Australijsko centralnozapadno standardno vrijeme", "OESZ": "Istočnoevropsko ljetno vrijeme", "GMT": "Griničko vrijeme", "ARST": "Argentinsko ljetno vrijeme", "HKT": "Hongkonško standardno vrijeme", "HKST": "Hongkonško ljetno vrijeme", "HNT": "Njufaundlendsko standardno vrijeme", "AKST": "Aljaskansko standardno vrijeme", "HNPMX": "Meksičko pacifičko standardno vrijeme", "ACWDT": "Australijsko centralnozapadno ljetno vrijeme", "MESZ": "Centralnoevropsko ljetno vrijeme", "SRT": "Surinamsko vrijeme", "BOT": "Bolivijsko vrijeme", "AEDT": "Istočnoaustralijsko ljetno vrijeme", "ADT": "Sjevernoameričko atlantsko ljetno vrijeme", "ART": "Argentinsko standardno vrijeme", "MDT": "Makao letnje računanje vremena", "WAT": "Zapadnoafričko standardno vrijeme", "AKDT": "Aljaskansko ljetno vrijeme", "AWDT": "Zapadnoaustralijsko ljetno vrijeme", "VET": "Venecuelansko vrijeme", "CLST": "Čileansko ljetno vrijeme", "WESZ": "Zapadnoevropsko ljetno vrijeme", "PDT": "Sjevernoameričko pacifičko ljetno vrijeme", "WAST": "Zapadnoafričko ljetno vrijeme", "COT": "Kolumbijsko standardno vrijeme", "COST": "Kolumbijsko ljetno vrijeme", "ACST": "Centralnoaustralijsko standardno vrijeme", "LHDT": "Ljetno vrijeme na Ostrvu Lord Hau", "WIB": "Zapadnoindonezijsko vrijeme", "CHADT": "Čatamsko ljetno vrijeme", "HEEG": "Istočnogrenlandsko ljetno vrijeme", "HEOG": "Zapadnogrenlandsko ljetno vrijeme", "HENOMX": "Sjeverozapadno meksičko ljetno vrijeme", "EAT": "Istočnoafričko vrijeme", "BT": "Butansko vrijeme", "MEZ": "Centralnoevropsko standardno vrijeme", "AST": "Sjevernoameričko atlantsko standardno vrijeme", "HNNOMX": "Sjeverozapadno meksičko standardno vrijeme", "HNEG": "Istočnogrenlandsko standardno vrijeme", "GFT": "Francuskogvajansko vrijeme", "SAST": "Južnoafričko standardno vrijeme", "CST": "Sjevernoameričko centralno standardno vrijeme", "NZST": "Novozelandsko standardno vrijeme", "WITA": "Centralnoindonezijsko vrijeme", "OEZ": "Istočnoevropsko standardno vrijeme", "ACDT": "Centralnoaustralijsko ljetno vrijeme", "HECU": "Kubansko ljetno vrijeme", "ECT": "Ekvadorsko vrijeme", "NZDT": "Novozelandsko ljetno vrijeme", "AWST": "Zapadnoaustralijsko standardno vrijeme", "HNOG": "Zapadnogrenlandsko standardno vrijeme", "AEST": "Istočnoaustralijsko standardno vrijeme", "UYT": "Urugvajsko standardno vrijeme", "LHST": "Standardno vrijeme na Ostrvu Lord Hau", "WIT": "Istočnoindonezijsko vrijeme", "WEZ": "Zapadnoevropsko standardno vrijeme", "EST": "Sjevernoameričko istočno standardno vrijeme", "HNCU": "Kubansko standardno vrijeme", "IST": "Indijsko standardno vrijeme", "JST": "Japansko standardno vrijeme", "MYT": "Malezijsko vrijeme", "WART": "Zapadnoargentinsko standardno vrijeme", "TMST": "Turkmenistansko ljetno vrijeme", "ChST": "Čamorsko standardno vrijeme", "SGT": "Singapursko standardno vrijeme", "PST": "Sjevernoameričko pacifičko standardno vrijeme", "HAST": "Havajsko-aleućansko standardno vrijeme", "HADT": "Havajsko-aleućansko ljetno vrijeme", "CAT": "Centralnoafričko vrijeme", "EDT": "Sjevernoameričko istočno ljetno vrijeme", "HAT": "Njufaundlendsko ljetno vrijeme", "UYST": "Urugvajsko ljetno vrijeme", "∅∅∅": "Azorsko ljetno vrijeme", "GYT": "Gvajansko vrijeme"}, + } +} + +// Locale returns the current translators string locale +func (bs *bs_Latn) Locale() string { + return bs.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bs_Latn' +func (bs *bs_Latn) PluralsCardinal() []locales.PluralRule { + return bs.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bs_Latn' +func (bs *bs_Latn) PluralsOrdinal() []locales.PluralRule { + return bs.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bs_Latn' +func (bs *bs_Latn) PluralsRange() []locales.PluralRule { + return bs.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Latn' +func (bs *bs_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Latn' +func (bs *bs_Latn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bs_Latn' +func (bs *bs_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := bs.CardinalPluralRule(num1, v1) + end := bs.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bs *bs_Latn) MonthAbbreviated(month time.Month) string { + return bs.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bs *bs_Latn) MonthsAbbreviated() []string { + return bs.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bs *bs_Latn) MonthNarrow(month time.Month) string { + return bs.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bs *bs_Latn) MonthsNarrow() []string { + return bs.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bs *bs_Latn) MonthWide(month time.Month) string { + return bs.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bs *bs_Latn) MonthsWide() []string { + return bs.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bs *bs_Latn) WeekdayAbbreviated(weekday time.Weekday) string { + return bs.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bs *bs_Latn) WeekdaysAbbreviated() []string { + return bs.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bs *bs_Latn) WeekdayNarrow(weekday time.Weekday) string { + return bs.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bs *bs_Latn) WeekdaysNarrow() []string { + return bs.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bs *bs_Latn) WeekdayShort(weekday time.Weekday) string { + return bs.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bs *bs_Latn) WeekdaysShort() []string { + return bs.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bs *bs_Latn) WeekdayWide(weekday time.Weekday) string { + return bs.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bs *bs_Latn) WeekdaysWide() []string { + return bs.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bs_Latn' and handles both Whole and Real numbers based on 'v' +func (bs *bs_Latn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bs_Latn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bs *bs_Latn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bs.percentSuffix...) + + b = append(b, bs.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Latn' +func (bs *bs_Latn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bs.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Latn' +// in accounting notation. +func (bs *bs_Latn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bs.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bs.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bs.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bs_Latn' +func (bs *bs_Latn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bs_Latn' +func (bs *bs_Latn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bs_Latn' +func (bs *bs_Latn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bs_Latn' +func (bs *bs_Latn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bs.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bs_Latn' +func (bs *bs_Latn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bs_Latn' +func (bs *bs_Latn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bs_Latn' +func (bs *bs_Latn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bs_Latn' +func (bs *bs_Latn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bs.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bs_Latn/bs_Latn_test.go b/vendor/github.com/go-playground/locales/bs_Latn/bs_Latn_test.go new file mode 100644 index 0000000000..fde1ce88d6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs_Latn/bs_Latn_test.go @@ -0,0 +1,1120 @@ +package bs_Latn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bs_Latn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/bs_Latn_BA/bs_Latn_BA.go b/vendor/github.com/go-playground/locales/bs_Latn_BA/bs_Latn_BA.go new file mode 100644 index 0000000000..813e1bbde0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs_Latn_BA/bs_Latn_BA.go @@ -0,0 +1,621 @@ +package bs_Latn_BA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type bs_Latn_BA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'bs_Latn_BA' locale +func New() locales.Translator { + return &bs_Latn_BA{ + locale: "bs_Latn_BA", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "avg", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januar", "februar", "mart", "april", "maj", "juni", "juli", "avgust", "septembar", "oktobar", "novembar", "decembar"}, + daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"}, + daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"prijepodne", "popodne"}, + periodsNarrow: []string{"prijepodne", "popodne"}, + periodsWide: []string{"prijepodne", "popodne"}, + erasAbbreviated: []string{"p. n. e.", "n. e."}, + erasNarrow: []string{"pr.n.e.", "AD"}, + erasWide: []string{"prije nove ere", "nove ere"}, + timezones: map[string]string{"HNEG": "Istočnogrenlandsko standardno vrijeme", "JDT": "Japansko ljetno vrijeme", "TMT": "Turkmenistansko standardno vrijeme", "CAT": "Centralnoafričko vrijeme", "AST": "Sjevernoameričko atlantsko standardno vrijeme", "HNNOMX": "Sjeverozapadno meksičko standardno vrijeme", "ChST": "Čamorsko standardno vrijeme", "MEZ": "Centralnoevropsko standardno vrijeme", "OEZ": "Istočnoevropsko standardno vrijeme", "SGT": "Singapursko standardno vrijeme", "NZST": "Novozelandsko standardno vrijeme", "OESZ": "Istočnoevropsko ljetno vrijeme", "WARST": "Zapadnoargentinsko ljetno vrijeme", "WAT": "Zapadnoafričko standardno vrijeme", "EAT": "Istočnoafričko vrijeme", "AWDT": "Zapadnoaustralijsko ljetno vrijeme", "CHAST": "Čatamsko standardno vrijeme", "NZDT": "Novozelandsko ljetno vrijeme", "HNOG": "Zapadnogrenlandsko standardno vrijeme", "MYT": "Malezijsko vrijeme", "HKT": "Hongkonško standardno vrijeme", "HENOMX": "Sjeverozapadno meksičko ljetno vrijeme", "HECU": "Kubansko ljetno vrijeme", "∅∅∅": "Brazilijsko ljetno vrijeme", "HEPMX": "Meksičko pacifičko ljetno vrijeme", "SRT": "Surinamsko vrijeme", "HKST": "Hongkonško ljetno vrijeme", "COST": "Kolumbijsko ljetno vrijeme", "HEEG": "Istočnogrenlandsko ljetno vrijeme", "HADT": "Havajsko-aleućansko ljetno vrijeme", "WAST": "Zapadnoafričko ljetno vrijeme", "HEPM": "Ljetno vrijeme na Ostrvima Sen Pjer i Mikelon", "HNPMX": "Meksičko pacifičko standardno vrijeme", "AWST": "Zapadnoaustralijsko standardno vrijeme", "WITA": "Centralnoindonezijsko vrijeme", "ADT": "Sjevernoameričko atlantsko ljetno vrijeme", "WESZ": "Zapadnoevropsko ljetno vrijeme", "MST": "Makao standardno vreme", "EST": "Sjevernoameričko istočno standardno vrijeme", "GFT": "Francuskogvajansko vrijeme", "UYST": "Urugvajsko ljetno vrijeme", "HNCU": "Kubansko standardno vrijeme", "WIB": "Zapadnoindonezijsko vrijeme", "ACWDT": "Australijsko centralnozapadno ljetno vrijeme", "AEDT": "Istočnoaustralijsko ljetno vrijeme", "HNPM": "Standardno vrijeme na Ostrvima Sen Pjer i Mikelon", "LHDT": "Ljetno vrijeme na Ostrvu Lord Hau", "WIT": "Istočnoindonezijsko vrijeme", "ECT": "Ekvadorsko vrijeme", "CLT": "Čileansko standardno vrijeme", "WEZ": "Zapadnoevropsko standardno vrijeme", "WART": "Zapadnoargentinsko standardno vrijeme", "AKST": "Aljaskansko standardno vrijeme", "HAST": "Havajsko-aleućansko standardno vrijeme", "IST": "Indijsko standardno vrijeme", "COT": "Kolumbijsko standardno vrijeme", "BOT": "Bolivijsko vrijeme", "ACWST": "Australijsko centralnozapadno standardno vrijeme", "ARST": "Argentinsko ljetno vrijeme", "EDT": "Sjevernoameričko istočno ljetno vrijeme", "ACDT": "Centralnoaustralijsko ljetno vrijeme", "BT": "Butansko vrijeme", "HNT": "Njufaundlendsko standardno vrijeme", "UYT": "Urugvajsko standardno vrijeme", "PDT": "Sjevernoameričko pacifičko ljetno vrijeme", "JST": "Japansko standardno vrijeme", "CDT": "Sjevernoameričko centralno ljetno vrijeme", "VET": "Venecuelansko vrijeme", "CLST": "Čileansko ljetno vrijeme", "HEOG": "Zapadnogrenlandsko ljetno vrijeme", "GMT": "Griničko vrijeme", "ART": "Argentinsko standardno vrijeme", "GYT": "Gvajansko vrijeme", "CST": "Sjevernoameričko centralno standardno vrijeme", "SAST": "Južnoafričko standardno vrijeme", "ACST": "Centralnoaustralijsko standardno vrijeme", "HAT": "Njufaundlendsko ljetno vrijeme", "MESZ": "Centralnoevropsko ljetno vrijeme", "LHST": "Standardno vrijeme na Ostrvu Lord Hau", "CHADT": "Čatamsko ljetno vrijeme", "PST": "Sjevernoameričko pacifičko standardno vrijeme", "AKDT": "Aljaskansko ljetno vrijeme", "AEST": "Istočnoaustralijsko standardno vrijeme", "TMST": "Turkmenistansko ljetno vrijeme", "MDT": "Makao letnje računanje vremena"}, + } +} + +// Locale returns the current translators string locale +func (bs *bs_Latn_BA) Locale() string { + return bs.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'bs_Latn_BA' +func (bs *bs_Latn_BA) PluralsCardinal() []locales.PluralRule { + return bs.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'bs_Latn_BA' +func (bs *bs_Latn_BA) PluralsOrdinal() []locales.PluralRule { + return bs.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'bs_Latn_BA' +func (bs *bs_Latn_BA) PluralsRange() []locales.PluralRule { + return bs.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := bs.CardinalPluralRule(num1, v1) + end := bs.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (bs *bs_Latn_BA) MonthAbbreviated(month time.Month) string { + return bs.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (bs *bs_Latn_BA) MonthsAbbreviated() []string { + return bs.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (bs *bs_Latn_BA) MonthNarrow(month time.Month) string { + return bs.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (bs *bs_Latn_BA) MonthsNarrow() []string { + return bs.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (bs *bs_Latn_BA) MonthWide(month time.Month) string { + return bs.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (bs *bs_Latn_BA) MonthsWide() []string { + return bs.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (bs *bs_Latn_BA) WeekdayAbbreviated(weekday time.Weekday) string { + return bs.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (bs *bs_Latn_BA) WeekdaysAbbreviated() []string { + return bs.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (bs *bs_Latn_BA) WeekdayNarrow(weekday time.Weekday) string { + return bs.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (bs *bs_Latn_BA) WeekdaysNarrow() []string { + return bs.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (bs *bs_Latn_BA) WeekdayShort(weekday time.Weekday) string { + return bs.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (bs *bs_Latn_BA) WeekdaysShort() []string { + return bs.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (bs *bs_Latn_BA) WeekdayWide(weekday time.Weekday) string { + return bs.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (bs *bs_Latn_BA) WeekdaysWide() []string { + return bs.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'bs_Latn_BA' and handles both Whole and Real numbers based on 'v' +func (bs *bs_Latn_BA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'bs_Latn_BA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (bs *bs_Latn_BA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, bs.percentSuffix...) + + b = append(b, bs.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, bs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, bs.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bs_Latn_BA' +// in accounting notation. +func (bs *bs_Latn_BA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := bs.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, bs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, bs.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, bs.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, bs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, bs.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, bs.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, bs.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, bs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'bs_Latn_BA' +func (bs *bs_Latn_BA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, bs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, bs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := bs.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/bs_Latn_BA/bs_Latn_BA_test.go b/vendor/github.com/go-playground/locales/bs_Latn_BA/bs_Latn_BA_test.go new file mode 100644 index 0000000000..ee4346d8bc --- /dev/null +++ b/vendor/github.com/go-playground/locales/bs_Latn_BA/bs_Latn_BA_test.go @@ -0,0 +1,1120 @@ +package bs_Latn_BA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "bs_Latn_BA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ca/ca.go b/vendor/github.com/go-playground/locales/ca/ca.go new file mode 100644 index 0000000000..10f341cbab --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca/ca.go @@ -0,0 +1,578 @@ +package ca + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ca struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ca' locale +func New() locales.Translator { + return &ca{ + locale: "ca", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "₧", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "de gen.", "de febr.", "de març", "d’abr.", "de maig", "de juny", "de jul.", "d’ag.", "de set.", "d’oct.", "de nov.", "de des."}, + monthsNarrow: []string{"", "GN", "FB", "MÇ", "AB", "MG", "JN", "JL", "AG", "ST", "OC", "NV", "DS"}, + monthsWide: []string{"", "de gener", "de febrer", "de març", "d’abril", "de maig", "de juny", "de juliol", "d’agost", "de setembre", "d’octubre", "de novembre", "de desembre"}, + daysAbbreviated: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysNarrow: []string{"dg", "dl", "dt", "dc", "dj", "dv", "ds"}, + daysShort: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysWide: []string{"diumenge", "dilluns", "dimarts", "dimecres", "dijous", "divendres", "dissabte"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"aC", "dC"}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"abans de Crist", "després de Crist"}, + timezones: map[string]string{"HNNOMX": "Hora estàndard del nord-oest de Mèxic", "CDT": "Hora d’estiu central d’Amèrica del Nord", "SGT": "Hora de Singapur", "TMT": "Hora estàndard del Turkmenistan", "WAT": "Hora estàndard de l’Àfrica Occidental", "HENOMX": "Hora d’estiu del nord-oest de Mèxic", "HAT": "Hora d’estiu de Terranova", "UYST": "Hora d’estiu de l’Uruguai", "ACWDT": "Hora d’estiu d’Austràlia centre-occidental", "MYT": "Hora de Malàisia", "GFT": "Hora de la Guaiana Francesa", "HNCU": "Hora estàndard de Cuba", "AWST": "Hora estàndard d’Austràlia Occidental", "AWDT": "Hora d’estiu d’Austràlia Occidental", "CHAST": "Hora estàndard de Chatham", "TMST": "Hora d’estiu del Turkmenistan", "HECU": "Hora d’estiu de Cuba", "BOT": "Hora de Bolívia", "ACWST": "Hora estàndard d’Austràlia centre-occidental", "NZST": "Hora estàndard de Nova Zelanda", "WARST": "Hora d’estiu de l’oest de l’Argentina", "AST": "Hora estàndard de l’Atlàntic", "EDT": "Hora d’estiu oriental d’Amèrica del Nord", "ACDT": "Hora d’estiu d’Austràlia Central", "HEEG": "Hora d’estiu de l’Est de Grenlàndia", "MDT": "Hora d’estiu de muntanya d’Amèrica del Nord", "AEST": "Hora estàndard d’Austràlia Oriental", "UYT": "Hora estàndard de l’Uruguai", "OEZ": "Hora estàndard de l’Est d’Europa", "HEOG": "Hora d’estiu de l’Oest de Grenlàndia", "MST": "Hora estàndard de muntanya d’Amèrica del Nord", "AKST": "Hora estàndard d’Alaska", "LHST": "Hora estàndard de Lord Howe", "LHDT": "Horari d’estiu de Lord Howe", "EAT": "Hora de l’Àfrica Oriental", "CST": "Hora estàndard central d’Amèrica del Nord", "CLST": "Hora d’estiu de Xile", "PST": "Hora estàndard del Pacífic", "PDT": "Hora d’estiu del Pacífic", "MESZ": "Hora d’estiu del Centre d’Europa", "HNT": "Hora estàndard de Terranova", "SRT": "Hora de Surinam", "IST": "Hora estàndard de l’Índia", "JST": "Hora estàndard del Japó", "WART": "Hora estàndard de l’oest de l’Argentina", "ADT": "Hora d’estiu de l’Atlàntic", "COST": "Hora d’estiu de Colòmbia", "AKDT": "Hora d’estiu d’Alaska", "JDT": "Hora d’estiu del Japó", "OESZ": "Hora d’estiu de l’Est d’Europa", "ARST": "Hora d’estiu de l’Argentina", "COT": "Hora estàndard de Colòmbia", "AEDT": "Hora d’estiu d’Austràlia Oriental", "WIB": "Hora de l’oest d’Indonèsia", "CAT": "Hora de l’Àfrica Central", "HNOG": "Hora estàndard de l’Oest de Grenlàndia", "∅∅∅": "∅∅∅", "VET": "Hora de Veneçuela", "CLT": "Hora estàndard de Xile", "EST": "Hora estàndard oriental d’Amèrica del Nord", "ACST": "Hora estàndard d’Austràlia Central", "HNPMX": "Hora estàndard del Pacífic de Mèxic", "ART": "Hora estàndard de l’Argentina", "WAST": "Hora d’estiu de l’Àfrica Occidental", "HADT": "Hora d’estiu de Hawaii-Aleutianes", "BT": "Hora de Bhutan", "WITA": "Hora central d’Indonèsia", "ChST": "Hora de Chamorro", "WIT": "Hora de l’est d’Indonèsia", "CHADT": "Hora d’estiu de Chatham", "ECT": "Hora de l’Equador", "HAST": "Hora estàndard de Hawaii-Aleutianes", "NZDT": "Hora d’estiu de Nova Zelanda", "HKT": "Hora estàndard de Hong Kong", "HKST": "Hora d’estiu de Hong Kong", "HNEG": "Hora estàndard de l’Est de Grenlàndia", "HNPM": "Hora estàndard de Saint-Pierre i Miquelon", "SAST": "Hora estàndard del sud de l’Àfrica", "HEPMX": "Hora d’estiu del Pacífic de Mèxic", "GYT": "Hora de Guyana", "MEZ": "Hora estàndard del Centre d’Europa", "WEZ": "Hora estàndard de l’Oest d’Europa", "GMT": "Hora del Meridià de Greenwich", "HEPM": "Hora d’estiu de Saint-Pierre i Miquelon", "WESZ": "Hora d’estiu de l’Oest d’Europa"}, + } +} + +// Locale returns the current translators string locale +func (ca *ca) Locale() string { + return ca.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ca' +func (ca *ca) PluralsCardinal() []locales.PluralRule { + return ca.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ca' +func (ca *ca) PluralsOrdinal() []locales.PluralRule { + return ca.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ca' +func (ca *ca) PluralsRange() []locales.PluralRule { + return ca.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ca' +func (ca *ca) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ca' +func (ca *ca) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 3 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ca' +func (ca *ca) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ca *ca) MonthAbbreviated(month time.Month) string { + return ca.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ca *ca) MonthsAbbreviated() []string { + return ca.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ca *ca) MonthNarrow(month time.Month) string { + return ca.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ca *ca) MonthsNarrow() []string { + return ca.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ca *ca) MonthWide(month time.Month) string { + return ca.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ca *ca) MonthsWide() []string { + return ca.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ca *ca) WeekdayAbbreviated(weekday time.Weekday) string { + return ca.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ca *ca) WeekdaysAbbreviated() []string { + return ca.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ca *ca) WeekdayNarrow(weekday time.Weekday) string { + return ca.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ca *ca) WeekdaysNarrow() []string { + return ca.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ca *ca) WeekdayShort(weekday time.Weekday) string { + return ca.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ca *ca) WeekdaysShort() []string { + return ca.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ca *ca) WeekdayWide(weekday time.Weekday) string { + return ca.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ca *ca) WeekdaysWide() []string { + return ca.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ca' and handles both Whole and Real numbers based on 'v' +func (ca *ca) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ca' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ca *ca) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ca.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ca' +func (ca *ca) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ca.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ca' +// in accounting notation. +func (ca *ca) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ca.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ca.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ca.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ca' +func (ca *ca) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ca' +func (ca *ca) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ca' +func (ca *ca) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ca' +func (ca *ca) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ca.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ca' +func (ca *ca) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ca' +func (ca *ca) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ca' +func (ca *ca) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ca' +func (ca *ca) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ca.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ca/ca_test.go b/vendor/github.com/go-playground/locales/ca/ca_test.go new file mode 100644 index 0000000000..b465e400fe --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca/ca_test.go @@ -0,0 +1,1120 @@ +package ca + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ca" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ca_AD/ca_AD.go b/vendor/github.com/go-playground/locales/ca_AD/ca_AD.go new file mode 100644 index 0000000000..141ab241c6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_AD/ca_AD.go @@ -0,0 +1,578 @@ +package ca_AD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ca_AD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ca_AD' locale +func New() locales.Translator { + return &ca_AD{ + locale: "ca_AD", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "de gen.", "de febr.", "de març", "d’abr.", "de maig", "de juny", "de jul.", "d’ag.", "de set.", "d’oct.", "de nov.", "de des."}, + monthsNarrow: []string{"", "GN", "FB", "MÇ", "AB", "MG", "JN", "JL", "AG", "ST", "OC", "NV", "DS"}, + monthsWide: []string{"", "de gener", "de febrer", "de març", "d’abril", "de maig", "de juny", "de juliol", "d’agost", "de setembre", "d’octubre", "de novembre", "de desembre"}, + daysAbbreviated: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysNarrow: []string{"dg", "dl", "dt", "dc", "dj", "dv", "ds"}, + daysShort: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysWide: []string{"diumenge", "dilluns", "dimarts", "dimecres", "dijous", "divendres", "dissabte"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"aC", "dC"}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"abans de Crist", "després de Crist"}, + timezones: map[string]string{"CHAST": "Hora estàndard de Chatham", "PDT": "Hora d’estiu del Pacífic", "HADT": "Hora d’estiu de Hawaii-Aleutianes", "TMT": "Hora estàndard del Turkmenistan", "HENOMX": "Hora d’estiu del nord-oest de Mèxic", "ACWDT": "Hora d’estiu d’Austràlia centre-occidental", "HEOG": "Hora d’estiu de l’Oest de Grenlàndia", "SAST": "Hora estàndard del sud de l’Àfrica", "CAT": "Hora de l’Àfrica Central", "JST": "Hora estàndard del Japó", "CLT": "Hora estàndard de Xile", "ADT": "Hora d’estiu de l’Atlàntic", "HNEG": "Hora estàndard de l’Est de Grenlàndia", "UYST": "Hora d’estiu de l’Uruguai", "WIB": "Hora de l’oest d’Indonèsia", "NZST": "Hora estàndard de Nova Zelanda", "EST": "Hora estàndard oriental d’Amèrica del Nord", "CHADT": "Hora d’estiu de Chatham", "IST": "Hora estàndard de l’Índia", "MEZ": "Hora estàndard del Centre d’Europa", "WEZ": "Hora estàndard de l’Oest d’Europa", "AKST": "Hora estàndard d’Alaska", "EAT": "Hora de l’Àfrica Oriental", "NZDT": "Hora d’estiu de Nova Zelanda", "∅∅∅": "Hora d’estiu de l’Amazones", "ACDT": "Hora d’estiu d’Austràlia Central", "AEDT": "Hora d’estiu d’Austràlia Oriental", "SRT": "Hora de Surinam", "LHST": "Hora estàndard de Lord Howe", "HNOG": "Hora estàndard de l’Oest de Grenlàndia", "HNPM": "Hora estàndard de Saint-Pierre i Miquelon", "PST": "Hora estàndard del Pacífic", "MESZ": "Hora d’estiu del Centre d’Europa", "AST": "Hora estàndard de l’Atlàntic", "HKT": "Hora estàndard de Hong Kong", "ACST": "Hora estàndard d’Austràlia Central", "HAST": "Hora estàndard de Hawaii-Aleutianes", "COST": "Hora d’estiu de Colòmbia", "WITA": "Hora central d’Indonèsia", "ACWST": "Hora estàndard d’Austràlia centre-occidental", "EDT": "Hora d’estiu oriental d’Amèrica del Nord", "BT": "Hora de Bhutan", "UYT": "Hora estàndard de l’Uruguai", "HEPM": "Hora d’estiu de Saint-Pierre i Miquelon", "OEZ": "Hora estàndard de l’Est d’Europa", "MST": "Hora estàndard de Macau", "HNNOMX": "Hora estàndard del nord-oest de Mèxic", "HAT": "Hora d’estiu de Terranova", "HNPMX": "Hora estàndard del Pacífic de Mèxic", "HNCU": "Hora estàndard de Cuba", "HECU": "Hora d’estiu de Cuba", "ECT": "Hora de l’Equador", "HKST": "Hora d’estiu de Hong Kong", "HNT": "Hora estàndard de Terranova", "AEST": "Hora estàndard d’Austràlia Oriental", "ChST": "Hora de Chamorro", "WART": "Hora estàndard de l’oest de l’Argentina", "COT": "Hora estàndard de Colòmbia", "SGT": "Hora de Singapur", "VET": "Hora de Veneçuela", "GMT": "Hora del Meridià de Greenwich", "ARST": "Hora d’estiu de l’Argentina", "LHDT": "Horari d’estiu de Lord Howe", "GYT": "Hora de Guyana", "CST": "Hora estàndard central d’Amèrica del Nord", "CDT": "Hora d’estiu central d’Amèrica del Nord", "BOT": "Hora de Bolívia", "MYT": "Hora de Malàisia", "CLST": "Hora d’estiu de Xile", "OESZ": "Hora d’estiu de l’Est d’Europa", "WESZ": "Hora d’estiu de l’Oest d’Europa", "MDT": "Hora d’estiu de Macau", "ART": "Hora estàndard de l’Argentina", "WAT": "Hora estàndard de l’Àfrica Occidental", "WAST": "Hora d’estiu de l’Àfrica Occidental", "HEEG": "Hora d’estiu de l’Est de Grenlàndia", "AKDT": "Hora d’estiu d’Alaska", "WIT": "Hora de l’est d’Indonèsia", "AWST": "Hora estàndard d’Austràlia Occidental", "AWDT": "Hora d’estiu d’Austràlia Occidental", "JDT": "Hora d’estiu del Japó", "WARST": "Hora d’estiu de l’oest de l’Argentina", "TMST": "Hora d’estiu del Turkmenistan", "GFT": "Hora de la Guaiana Francesa", "HEPMX": "Hora d’estiu del Pacífic de Mèxic"}, + } +} + +// Locale returns the current translators string locale +func (ca *ca_AD) Locale() string { + return ca.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ca_AD' +func (ca *ca_AD) PluralsCardinal() []locales.PluralRule { + return ca.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ca_AD' +func (ca *ca_AD) PluralsOrdinal() []locales.PluralRule { + return ca.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ca_AD' +func (ca *ca_AD) PluralsRange() []locales.PluralRule { + return ca.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ca_AD' +func (ca *ca_AD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ca_AD' +func (ca *ca_AD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 3 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ca_AD' +func (ca *ca_AD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ca *ca_AD) MonthAbbreviated(month time.Month) string { + return ca.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ca *ca_AD) MonthsAbbreviated() []string { + return ca.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ca *ca_AD) MonthNarrow(month time.Month) string { + return ca.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ca *ca_AD) MonthsNarrow() []string { + return ca.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ca *ca_AD) MonthWide(month time.Month) string { + return ca.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ca *ca_AD) MonthsWide() []string { + return ca.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ca *ca_AD) WeekdayAbbreviated(weekday time.Weekday) string { + return ca.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ca *ca_AD) WeekdaysAbbreviated() []string { + return ca.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ca *ca_AD) WeekdayNarrow(weekday time.Weekday) string { + return ca.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ca *ca_AD) WeekdaysNarrow() []string { + return ca.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ca *ca_AD) WeekdayShort(weekday time.Weekday) string { + return ca.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ca *ca_AD) WeekdaysShort() []string { + return ca.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ca *ca_AD) WeekdayWide(weekday time.Weekday) string { + return ca.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ca *ca_AD) WeekdaysWide() []string { + return ca.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ca_AD' and handles both Whole and Real numbers based on 'v' +func (ca *ca_AD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ca_AD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ca *ca_AD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ca.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ca_AD' +func (ca *ca_AD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ca.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ca_AD' +// in accounting notation. +func (ca *ca_AD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ca.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ca.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ca.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ca_AD' +func (ca *ca_AD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ca_AD' +func (ca *ca_AD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ca_AD' +func (ca *ca_AD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ca_AD' +func (ca *ca_AD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ca.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ca_AD' +func (ca *ca_AD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ca_AD' +func (ca *ca_AD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ca_AD' +func (ca *ca_AD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ca_AD' +func (ca *ca_AD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ca.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ca_AD/ca_AD_test.go b/vendor/github.com/go-playground/locales/ca_AD/ca_AD_test.go new file mode 100644 index 0000000000..4056866e7c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_AD/ca_AD_test.go @@ -0,0 +1,1120 @@ +package ca_AD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ca_AD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ca_ES/ca_ES.go b/vendor/github.com/go-playground/locales/ca_ES/ca_ES.go new file mode 100644 index 0000000000..ab6d42c4d6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_ES/ca_ES.go @@ -0,0 +1,578 @@ +package ca_ES + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ca_ES struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ca_ES' locale +func New() locales.Translator { + return &ca_ES{ + locale: "ca_ES", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "de gen.", "de febr.", "de març", "d’abr.", "de maig", "de juny", "de jul.", "d’ag.", "de set.", "d’oct.", "de nov.", "de des."}, + monthsNarrow: []string{"", "GN", "FB", "MÇ", "AB", "MG", "JN", "JL", "AG", "ST", "OC", "NV", "DS"}, + monthsWide: []string{"", "de gener", "de febrer", "de març", "d’abril", "de maig", "de juny", "de juliol", "d’agost", "de setembre", "d’octubre", "de novembre", "de desembre"}, + daysAbbreviated: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysNarrow: []string{"dg", "dl", "dt", "dc", "dj", "dv", "ds"}, + daysShort: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysWide: []string{"diumenge", "dilluns", "dimarts", "dimecres", "dijous", "divendres", "dissabte"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"aC", "dC"}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"abans de Crist", "després de Crist"}, + timezones: map[string]string{"AWST": "Hora estàndard d’Austràlia Occidental", "CHADT": "Hora d’estiu de Chatham", "CAT": "Hora de l’Àfrica Central", "ACWDT": "Hora d’estiu d’Austràlia centre-occidental", "ARST": "Hora d’estiu de l’Argentina", "WAT": "Hora estàndard de l’Àfrica Occidental", "SAST": "Hora estàndard del sud de l’Àfrica", "CHAST": "Hora estàndard de Chatham", "CLST": "Hora d’estiu de Xile", "MST": "Hora estàndard de Macau", "ACST": "Hora estàndard d’Austràlia Central", "WITA": "Hora central d’Indonèsia", "LHST": "Hora estàndard de Lord Howe", "PST": "Hora estàndard del Pacífic", "MYT": "Hora de Malàisia", "OEZ": "Hora estàndard de l’Est d’Europa", "BT": "Hora de Bhutan", "NZST": "Hora estàndard de Nova Zelanda", "ACWST": "Hora estàndard d’Austràlia centre-occidental", "MESZ": "Hora d’estiu del Centre d’Europa", "JST": "Hora estàndard del Japó", "EDT": "Hora d’estiu oriental d’Amèrica del Nord", "UYST": "Hora d’estiu de l’Uruguai", "LHDT": "Horari d’estiu de Lord Howe", "HNPMX": "Hora estàndard del Pacífic de Mèxic", "AWDT": "Hora d’estiu d’Austràlia Occidental", "IST": "Hora estàndard de l’Índia", "TMST": "Hora d’estiu del Turkmenistan", "HKT": "Hora estàndard de Hong Kong", "HAT": "Hora d’estiu de Terranova", "UYT": "Hora estàndard de l’Uruguai", "GYT": "Hora de Guyana", "HAST": "Hora estàndard de Hawaii-Aleutianes", "∅∅∅": "Hora d’estiu de l’Amazones", "VET": "Hora de Veneçuela", "JDT": "Hora d’estiu del Japó", "HNOG": "Hora estàndard de l’Oest de Grenlàndia", "HEOG": "Hora d’estiu de l’Oest de Grenlàndia", "WIT": "Hora de l’est d’Indonèsia", "BOT": "Hora de Bolívia", "HADT": "Hora d’estiu de Hawaii-Aleutianes", "NZDT": "Hora d’estiu de Nova Zelanda", "HNNOMX": "Hora estàndard del nord-oest de Mèxic", "ECT": "Hora de l’Equador", "OESZ": "Hora d’estiu de l’Est d’Europa", "GFT": "Hora de la Guaiana Francesa", "HEPMX": "Hora d’estiu del Pacífic de Mèxic", "CLT": "Hora estàndard de Xile", "WESZ": "Hora d’estiu de l’Oest d’Europa", "HEPM": "Hora d’estiu de Saint-Pierre i Miquelon", "SRT": "Hora de Surinam", "HKST": "Hora d’estiu de Hong Kong", "HNT": "Hora estàndard de Terranova", "AEDT": "Hora d’estiu d’Austràlia Oriental", "AKDT": "Hora d’estiu d’Alaska", "HNPM": "Hora estàndard de Saint-Pierre i Miquelon", "HNCU": "Hora estàndard de Cuba", "TMT": "Hora estàndard del Turkmenistan", "ART": "Hora estàndard de l’Argentina", "HEEG": "Hora d’estiu de l’Est de Grenlàndia", "AKST": "Hora estàndard d’Alaska", "CST": "Hora estàndard central d’Amèrica del Nord", "WEZ": "Hora estàndard de l’Oest d’Europa", "WIB": "Hora de l’oest d’Indonèsia", "PDT": "Hora d’estiu del Pacífic", "GMT": "Hora del Meridià de Greenwich", "AST": "Hora estàndard de l’Atlàntic", "HNEG": "Hora estàndard de l’Est de Grenlàndia", "AEST": "Hora estàndard d’Austràlia Oriental", "HECU": "Hora d’estiu de Cuba", "CDT": "Hora d’estiu central d’Amèrica del Nord", "WARST": "Hora d’estiu de l’oest de l’Argentina", "ADT": "Hora d’estiu de l’Atlàntic", "MDT": "Hora d’estiu de Macau", "WAST": "Hora d’estiu de l’Àfrica Occidental", "EST": "Hora estàndard oriental d’Amèrica del Nord", "ACDT": "Hora d’estiu d’Austràlia Central", "COT": "Hora estàndard de Colòmbia", "HENOMX": "Hora d’estiu del nord-oest de Mèxic", "SGT": "Hora de Singapur", "MEZ": "Hora estàndard del Centre d’Europa", "WART": "Hora estàndard de l’oest de l’Argentina", "COST": "Hora d’estiu de Colòmbia", "ChST": "Hora de Chamorro", "EAT": "Hora de l’Àfrica Oriental"}, + } +} + +// Locale returns the current translators string locale +func (ca *ca_ES) Locale() string { + return ca.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ca_ES' +func (ca *ca_ES) PluralsCardinal() []locales.PluralRule { + return ca.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ca_ES' +func (ca *ca_ES) PluralsOrdinal() []locales.PluralRule { + return ca.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ca_ES' +func (ca *ca_ES) PluralsRange() []locales.PluralRule { + return ca.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ca_ES' +func (ca *ca_ES) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ca_ES' +func (ca *ca_ES) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 3 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ca_ES' +func (ca *ca_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ca *ca_ES) MonthAbbreviated(month time.Month) string { + return ca.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ca *ca_ES) MonthsAbbreviated() []string { + return ca.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ca *ca_ES) MonthNarrow(month time.Month) string { + return ca.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ca *ca_ES) MonthsNarrow() []string { + return ca.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ca *ca_ES) MonthWide(month time.Month) string { + return ca.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ca *ca_ES) MonthsWide() []string { + return ca.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ca *ca_ES) WeekdayAbbreviated(weekday time.Weekday) string { + return ca.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ca *ca_ES) WeekdaysAbbreviated() []string { + return ca.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ca *ca_ES) WeekdayNarrow(weekday time.Weekday) string { + return ca.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ca *ca_ES) WeekdaysNarrow() []string { + return ca.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ca *ca_ES) WeekdayShort(weekday time.Weekday) string { + return ca.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ca *ca_ES) WeekdaysShort() []string { + return ca.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ca *ca_ES) WeekdayWide(weekday time.Weekday) string { + return ca.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ca *ca_ES) WeekdaysWide() []string { + return ca.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ca_ES' and handles both Whole and Real numbers based on 'v' +func (ca *ca_ES) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ca_ES' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ca *ca_ES) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ca.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ca_ES' +func (ca *ca_ES) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ca.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ca_ES' +// in accounting notation. +func (ca *ca_ES) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ca.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ca.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ca.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ca_ES' +func (ca *ca_ES) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ca_ES' +func (ca *ca_ES) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ca_ES' +func (ca *ca_ES) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ca_ES' +func (ca *ca_ES) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ca.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ca_ES' +func (ca *ca_ES) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ca_ES' +func (ca *ca_ES) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ca_ES' +func (ca *ca_ES) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ca_ES' +func (ca *ca_ES) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ca.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ca_ES/ca_ES_test.go b/vendor/github.com/go-playground/locales/ca_ES/ca_ES_test.go new file mode 100644 index 0000000000..6162c24785 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_ES/ca_ES_test.go @@ -0,0 +1,1120 @@ +package ca_ES + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ca_ES" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go b/vendor/github.com/go-playground/locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go new file mode 100644 index 0000000000..2e375e5360 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_ES_VALENCIA/ca_ES_VALENCIA.go @@ -0,0 +1,578 @@ +package ca_ES_VALENCIA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ca_ES_VALENCIA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ca_ES_VALENCIA' locale +func New() locales.Translator { + return &ca_ES_VALENCIA{ + locale: "ca_ES_VALENCIA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "de gen.", "de febr.", "de març", "d’abr.", "de maig", "de juny", "de jul.", "d’ag.", "de set.", "d’oct.", "de nov.", "de des."}, + monthsNarrow: []string{"", "GN", "FB", "MÇ", "AB", "MG", "JN", "JL", "AG", "ST", "OC", "NV", "DS"}, + monthsWide: []string{"", "de gener", "de febrer", "de març", "d’abril", "de maig", "de juny", "de juliol", "d’agost", "de setembre", "d’octubre", "de novembre", "de desembre"}, + daysAbbreviated: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysNarrow: []string{"dg", "dl", "dt", "dc", "dj", "dv", "ds"}, + daysShort: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysWide: []string{"diumenge", "dilluns", "dimarts", "dimecres", "dijous", "divendres", "dissabte"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"aC", "dC"}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"abans de Crist", "després de Crist"}, + timezones: map[string]string{"AKST": "Hora estàndard d’Alaska", "EAT": "Hora de l’Àfrica Oriental", "TMT": "Hora estàndard del Turkmenistan", "HKT": "Hora estàndard de Hong Kong", "ACDT": "Hora d’estiu d’Austràlia Central", "HEEG": "Hora d’estiu de l’Est de Grenlàndia", "UYST": "Hora d’estiu de l’Uruguai", "HEPMX": "Hora d’estiu del Pacífic de Mèxic", "MYT": "Hora de Malàisia", "HAT": "Hora d’estiu de Terranova", "UYT": "Hora estàndard de l’Uruguai", "GYT": "Hora de Guyana", "HNCU": "Hora estàndard de Cuba", "CHADT": "Hora d’estiu de Chatham", "NZDT": "Hora d’estiu de Nova Zelanda", "HNPMX": "Hora estàndard del Pacífic de Mèxic", "WIB": "Hora de l’oest d’Indonèsia", "SGT": "Hora de Singapur", "JDT": "Hora d’estiu del Japó", "WAST": "Hora d’estiu de l’Àfrica Occidental", "CDT": "Hora d’estiu central d’Amèrica del Nord", "HAST": "Hora estàndard de Hawaii-Aleutianes", "JST": "Hora estàndard del Japó", "OESZ": "Hora d’estiu de l’Est d’Europa", "HKST": "Hora d’estiu de Hong Kong", "HNPM": "Hora estàndard de Saint-Pierre i Miquelon", "LHST": "Hora estàndard de Lord Howe", "BOT": "Hora de Bolívia", "WEZ": "Hora estàndard de l’Oest d’Europa", "EDT": "Hora d’estiu oriental d’Amèrica del Nord", "AKDT": "Hora d’estiu d’Alaska", "AEST": "Hora estàndard d’Austràlia Oriental", "HEPM": "Hora d’estiu de Saint-Pierre i Miquelon", "IST": "Hora estàndard de l’Índia", "ACWST": "Hora estàndard d’Austràlia centre-occidental", "NZST": "Hora estàndard de Nova Zelanda", "HENOMX": "Hora d’estiu del nord-oest de Mèxic", "TMST": "Hora d’estiu del Turkmenistan", "COT": "Hora estàndard de Colòmbia", "HNNOMX": "Hora estàndard del nord-oest de Mèxic", "SRT": "Hora de Surinam", "AWDT": "Hora d’estiu d’Austràlia Occidental", "PDT": "Hora d’estiu del Pacífic", "HNOG": "Hora estàndard de l’Oest de Grenlàndia", "GMT": "Hora del Meridià de Greenwich", "WITA": "Hora central d’Indonèsia", "WARST": "Hora d’estiu de l’oest de l’Argentina", "ARST": "Hora d’estiu de l’Argentina", "HNEG": "Hora estàndard de l’Est de Grenlàndia", "GFT": "Hora de la Guaiana Francesa", "AEDT": "Hora d’estiu d’Austràlia Oriental", "LHDT": "Horari d’estiu de Lord Howe", "CLT": "Hora estàndard de Xile", "ADT": "Hora d’estiu de l’Atlàntic", "WAT": "Hora estàndard de l’Àfrica Occidental", "VET": "Hora de Veneçuela", "ART": "Hora estàndard de l’Argentina", "ACST": "Hora estàndard d’Austràlia Central", "AWST": "Hora estàndard d’Austràlia Occidental", "CHAST": "Hora estàndard de Chatham", "MESZ": "Hora d’estiu del Centre d’Europa", "HNT": "Hora estàndard de Terranova", "WART": "Hora estàndard de l’oest de l’Argentina", "MST": "Hora estàndard de Macau", "EST": "Hora estàndard oriental d’Amèrica del Nord", "ChST": "Hora de Chamorro", "SAST": "Hora estàndard del sud de l’Àfrica", "HADT": "Hora d’estiu de Hawaii-Aleutianes", "CAT": "Hora de l’Àfrica Central", "MEZ": "Hora estàndard del Centre d’Europa", "CST": "Hora estàndard central d’Amèrica del Nord", "WIT": "Hora de l’est d’Indonèsia", "ECT": "Hora de l’Equador", "MDT": "Hora d’estiu de Macau", "COST": "Hora d’estiu de Colòmbia", "PST": "Hora estàndard del Pacífic", "CLST": "Hora d’estiu de Xile", "AST": "Hora estàndard de l’Atlàntic", "BT": "Hora de Bhutan", "WESZ": "Hora d’estiu de l’Oest d’Europa", "∅∅∅": "Hora d’estiu de les Açores", "HECU": "Hora d’estiu de Cuba", "ACWDT": "Hora d’estiu d’Austràlia centre-occidental", "HEOG": "Hora d’estiu de l’Oest de Grenlàndia", "OEZ": "Hora estàndard de l’Est d’Europa"}, + } +} + +// Locale returns the current translators string locale +func (ca *ca_ES_VALENCIA) Locale() string { + return ca.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) PluralsCardinal() []locales.PluralRule { + return ca.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) PluralsOrdinal() []locales.PluralRule { + return ca.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) PluralsRange() []locales.PluralRule { + return ca.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 3 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ca *ca_ES_VALENCIA) MonthAbbreviated(month time.Month) string { + return ca.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ca *ca_ES_VALENCIA) MonthsAbbreviated() []string { + return ca.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ca *ca_ES_VALENCIA) MonthNarrow(month time.Month) string { + return ca.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ca *ca_ES_VALENCIA) MonthsNarrow() []string { + return ca.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ca *ca_ES_VALENCIA) MonthWide(month time.Month) string { + return ca.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ca *ca_ES_VALENCIA) MonthsWide() []string { + return ca.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ca *ca_ES_VALENCIA) WeekdayAbbreviated(weekday time.Weekday) string { + return ca.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ca *ca_ES_VALENCIA) WeekdaysAbbreviated() []string { + return ca.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ca *ca_ES_VALENCIA) WeekdayNarrow(weekday time.Weekday) string { + return ca.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ca *ca_ES_VALENCIA) WeekdaysNarrow() []string { + return ca.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ca *ca_ES_VALENCIA) WeekdayShort(weekday time.Weekday) string { + return ca.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ca *ca_ES_VALENCIA) WeekdaysShort() []string { + return ca.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ca *ca_ES_VALENCIA) WeekdayWide(weekday time.Weekday) string { + return ca.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ca *ca_ES_VALENCIA) WeekdaysWide() []string { + return ca.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ca_ES_VALENCIA' and handles both Whole and Real numbers based on 'v' +func (ca *ca_ES_VALENCIA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ca_ES_VALENCIA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ca *ca_ES_VALENCIA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ca.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ca.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ca_ES_VALENCIA' +// in accounting notation. +func (ca *ca_ES_VALENCIA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ca.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ca.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ca.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ca.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ca_ES_VALENCIA' +func (ca *ca_ES_VALENCIA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ca.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ca_ES_VALENCIA/ca_ES_VALENCIA_test.go b/vendor/github.com/go-playground/locales/ca_ES_VALENCIA/ca_ES_VALENCIA_test.go new file mode 100644 index 0000000000..390cffb44b --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_ES_VALENCIA/ca_ES_VALENCIA_test.go @@ -0,0 +1,1120 @@ +package ca_ES_VALENCIA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ca_ES_VALENCIA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ca_FR/ca_FR.go b/vendor/github.com/go-playground/locales/ca_FR/ca_FR.go new file mode 100644 index 0000000000..7ecc84ffff --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_FR/ca_FR.go @@ -0,0 +1,578 @@ +package ca_FR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ca_FR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ca_FR' locale +func New() locales.Translator { + return &ca_FR{ + locale: "ca_FR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "F", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "de gen.", "de febr.", "de març", "d’abr.", "de maig", "de juny", "de jul.", "d’ag.", "de set.", "d’oct.", "de nov.", "de des."}, + monthsNarrow: []string{"", "GN", "FB", "MÇ", "AB", "MG", "JN", "JL", "AG", "ST", "OC", "NV", "DS"}, + monthsWide: []string{"", "de gener", "de febrer", "de març", "d’abril", "de maig", "de juny", "de juliol", "d’agost", "de setembre", "d’octubre", "de novembre", "de desembre"}, + daysAbbreviated: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysNarrow: []string{"dg", "dl", "dt", "dc", "dj", "dv", "ds"}, + daysShort: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysWide: []string{"diumenge", "dilluns", "dimarts", "dimecres", "dijous", "divendres", "dissabte"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"aC", "dC"}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"abans de Crist", "després de Crist"}, + timezones: map[string]string{"IST": "Hora estàndard de l’Índia", "HEOG": "Hora d’estiu de l’Oest de Grenlàndia", "HKT": "Hora estàndard de Hong Kong", "AEST": "Hora estàndard d’Austràlia Oriental", "WIB": "Hora de l’oest d’Indonèsia", "CST": "Hora estàndard central d’Amèrica del Nord", "CHADT": "Hora d’estiu de Chatham", "ACST": "Hora estàndard d’Austràlia Central", "HENOMX": "Hora d’estiu del nord-oest de Mèxic", "AKDT": "Hora d’estiu d’Alaska", "COT": "Hora estàndard de Colòmbia", "HEEG": "Hora d’estiu de l’Est de Grenlàndia", "WAST": "Hora d’estiu de l’Àfrica Occidental", "CAT": "Hora de l’Àfrica Central", "MESZ": "Hora d’estiu del Centre d’Europa", "HAT": "Hora d’estiu de Terranova", "AKST": "Hora estàndard d’Alaska", "SGT": "Hora de Singapur", "WIT": "Hora de l’est d’Indonèsia", "CHAST": "Hora estàndard de Chatham", "BOT": "Hora de Bolívia", "NZST": "Hora estàndard de Nova Zelanda", "NZDT": "Hora d’estiu de Nova Zelanda", "HNT": "Hora estàndard de Terranova", "UYST": "Hora d’estiu de l’Uruguai", "HNPMX": "Hora estàndard del Pacífic de Mèxic", "WAT": "Hora estàndard de l’Àfrica Occidental", "OEZ": "Hora estàndard de l’Est d’Europa", "WART": "Hora estàndard de l’oest de l’Argentina", "AWST": "Hora estàndard d’Austràlia Occidental", "ECT": "Hora de l’Equador", "CLT": "Hora estàndard de Xile", "ACWDT": "Hora d’estiu d’Austràlia centre-occidental", "BT": "Hora de Bhutan", "WITA": "Hora central d’Indonèsia", "HNCU": "Hora estàndard de Cuba", "AWDT": "Hora d’estiu d’Austràlia Occidental", "AST": "Hora estàndard de l’Atlàntic", "WEZ": "Hora estàndard de l’Oest d’Europa", "WARST": "Hora d’estiu de l’oest de l’Argentina", "HNEG": "Hora estàndard de l’Est de Grenlàndia", "∅∅∅": "∅∅∅", "HEPMX": "Hora d’estiu del Pacífic de Mèxic", "EAT": "Hora de l’Àfrica Oriental", "HAST": "Hora estàndard de Hawaii-Aleutianes", "OESZ": "Hora d’estiu de l’Est d’Europa", "TMT": "Hora estàndard del Turkmenistan", "AEDT": "Hora d’estiu d’Austràlia Oriental", "MDT": "Hora d’estiu de muntanya d’Amèrica del Nord", "SRT": "Hora de Surinam", "HECU": "Hora d’estiu de Cuba", "MEZ": "Hora estàndard del Centre d’Europa", "MYT": "Hora de Malàisia", "ChST": "Hora de Chamorro", "LHDT": "Horari d’estiu de Lord Howe", "GYT": "Hora de Guyana", "JST": "Hora estàndard del Japó", "TMST": "Hora d’estiu del Turkmenistan", "EDT": "Hora d’estiu oriental d’Amèrica del Nord", "GFT": "Hora de la Guaiana Francesa", "UYT": "Hora estàndard de l’Uruguai", "HADT": "Hora d’estiu de Hawaii-Aleutianes", "PDT": "Hora d’estiu del Pacífic", "HNOG": "Hora estàndard de l’Oest de Grenlàndia", "HNPM": "Hora estàndard de Saint-Pierre i Miquelon", "SAST": "Hora estàndard del sud de l’Àfrica", "PST": "Hora estàndard del Pacífic", "ACWST": "Hora estàndard d’Austràlia centre-occidental", "ARST": "Hora d’estiu de l’Argentina", "ACDT": "Hora d’estiu d’Austràlia Central", "HNNOMX": "Hora estàndard del nord-oest de Mèxic", "MST": "Hora estàndard de muntanya d’Amèrica del Nord", "WESZ": "Hora d’estiu de l’Oest d’Europa", "GMT": "Hora del Meridià de Greenwich", "ART": "Hora estàndard de l’Argentina", "COST": "Hora d’estiu de Colòmbia", "HEPM": "Hora d’estiu de Saint-Pierre i Miquelon", "LHST": "Hora estàndard de Lord Howe", "CLST": "Hora d’estiu de Xile", "ADT": "Hora d’estiu de l’Atlàntic", "EST": "Hora estàndard oriental d’Amèrica del Nord", "HKST": "Hora d’estiu de Hong Kong", "CDT": "Hora d’estiu central d’Amèrica del Nord", "VET": "Hora de Veneçuela", "JDT": "Hora d’estiu del Japó"}, + } +} + +// Locale returns the current translators string locale +func (ca *ca_FR) Locale() string { + return ca.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ca_FR' +func (ca *ca_FR) PluralsCardinal() []locales.PluralRule { + return ca.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ca_FR' +func (ca *ca_FR) PluralsOrdinal() []locales.PluralRule { + return ca.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ca_FR' +func (ca *ca_FR) PluralsRange() []locales.PluralRule { + return ca.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ca_FR' +func (ca *ca_FR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ca_FR' +func (ca *ca_FR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 3 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ca_FR' +func (ca *ca_FR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ca *ca_FR) MonthAbbreviated(month time.Month) string { + return ca.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ca *ca_FR) MonthsAbbreviated() []string { + return ca.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ca *ca_FR) MonthNarrow(month time.Month) string { + return ca.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ca *ca_FR) MonthsNarrow() []string { + return ca.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ca *ca_FR) MonthWide(month time.Month) string { + return ca.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ca *ca_FR) MonthsWide() []string { + return ca.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ca *ca_FR) WeekdayAbbreviated(weekday time.Weekday) string { + return ca.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ca *ca_FR) WeekdaysAbbreviated() []string { + return ca.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ca *ca_FR) WeekdayNarrow(weekday time.Weekday) string { + return ca.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ca *ca_FR) WeekdaysNarrow() []string { + return ca.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ca *ca_FR) WeekdayShort(weekday time.Weekday) string { + return ca.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ca *ca_FR) WeekdaysShort() []string { + return ca.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ca *ca_FR) WeekdayWide(weekday time.Weekday) string { + return ca.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ca *ca_FR) WeekdaysWide() []string { + return ca.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ca_FR' and handles both Whole and Real numbers based on 'v' +func (ca *ca_FR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ca_FR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ca *ca_FR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ca.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ca_FR' +func (ca *ca_FR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ca.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ca_FR' +// in accounting notation. +func (ca *ca_FR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ca.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ca.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ca.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ca_FR' +func (ca *ca_FR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ca_FR' +func (ca *ca_FR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ca_FR' +func (ca *ca_FR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ca_FR' +func (ca *ca_FR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ca.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ca_FR' +func (ca *ca_FR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ca_FR' +func (ca *ca_FR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ca_FR' +func (ca *ca_FR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ca_FR' +func (ca *ca_FR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ca.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ca_FR/ca_FR_test.go b/vendor/github.com/go-playground/locales/ca_FR/ca_FR_test.go new file mode 100644 index 0000000000..5cdbcf1657 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_FR/ca_FR_test.go @@ -0,0 +1,1120 @@ +package ca_FR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ca_FR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ca_IT/ca_IT.go b/vendor/github.com/go-playground/locales/ca_IT/ca_IT.go new file mode 100644 index 0000000000..e90a3067b8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_IT/ca_IT.go @@ -0,0 +1,578 @@ +package ca_IT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ca_IT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ca_IT' locale +func New() locales.Translator { + return &ca_IT{ + locale: "ca_IT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "de gen.", "de febr.", "de març", "d’abr.", "de maig", "de juny", "de jul.", "d’ag.", "de set.", "d’oct.", "de nov.", "de des."}, + monthsNarrow: []string{"", "GN", "FB", "MÇ", "AB", "MG", "JN", "JL", "AG", "ST", "OC", "NV", "DS"}, + monthsWide: []string{"", "de gener", "de febrer", "de març", "d’abril", "de maig", "de juny", "de juliol", "d’agost", "de setembre", "d’octubre", "de novembre", "de desembre"}, + daysAbbreviated: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysNarrow: []string{"dg", "dl", "dt", "dc", "dj", "dv", "ds"}, + daysShort: []string{"dg.", "dl.", "dt.", "dc.", "dj.", "dv.", "ds."}, + daysWide: []string{"diumenge", "dilluns", "dimarts", "dimecres", "dijous", "divendres", "dissabte"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"aC", "dC"}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"abans de Crist", "després de Crist"}, + timezones: map[string]string{"MST": "Hora estàndard de muntanya d’Amèrica del Nord", "HEPMX": "Hora d’estiu del Pacífic de Mèxic", "CST": "Hora estàndard central d’Amèrica del Nord", "CDT": "Hora d’estiu central d’Amèrica del Nord", "MYT": "Hora de Malàisia", "ART": "Hora estàndard de l’Argentina", "HKT": "Hora estàndard de Hong Kong", "AKDT": "Hora d’estiu d’Alaska", "HNEG": "Hora estàndard de l’Est de Grenlàndia", "WESZ": "Hora d’estiu de l’Oest d’Europa", "CLST": "Hora d’estiu de Xile", "HKST": "Hora d’estiu de Hong Kong", "BT": "Hora de Bhutan", "HAST": "Hora estàndard de Hawaii-Aleutianes", "VET": "Hora de Veneçuela", "ARST": "Hora d’estiu de l’Argentina", "SAST": "Hora estàndard del sud de l’Àfrica", "MESZ": "Hora d’estiu del Centre d’Europa", "HNPMX": "Hora estàndard del Pacífic de Mèxic", "HEOG": "Hora d’estiu de l’Oest de Grenlàndia", "WART": "Hora estàndard de l’oest de l’Argentina", "TMT": "Hora estàndard del Turkmenistan", "EST": "Hora estàndard oriental d’Amèrica del Nord", "ECT": "Hora de l’Equador", "UYT": "Hora estàndard de l’Uruguai", "SRT": "Hora de Surinam", "WIB": "Hora de l’oest d’Indonèsia", "JST": "Hora estàndard del Japó", "ACDT": "Hora d’estiu d’Austràlia Central", "COT": "Hora estàndard de Colòmbia", "AEST": "Hora estàndard d’Austràlia Oriental", "EAT": "Hora de l’Àfrica Oriental", "COST": "Hora d’estiu de Colòmbia", "HNT": "Hora estàndard de Terranova", "BOT": "Hora de Bolívia", "HADT": "Hora d’estiu de Hawaii-Aleutianes", "IST": "Hora estàndard de l’Índia", "HENOMX": "Hora d’estiu del nord-oest de Mèxic", "SGT": "Hora de Singapur", "PST": "Hora estàndard del Pacífic", "WARST": "Hora d’estiu de l’oest de l’Argentina", "WAST": "Hora d’estiu de l’Àfrica Occidental", "HEPM": "Hora d’estiu de Saint-Pierre i Miquelon", "WIT": "Hora de l’est d’Indonèsia", "AWDT": "Hora d’estiu d’Austràlia Occidental", "PDT": "Hora d’estiu del Pacífic", "WEZ": "Hora estàndard de l’Oest d’Europa", "TMST": "Hora d’estiu del Turkmenistan", "MDT": "Hora d’estiu de muntanya d’Amèrica del Nord", "AEDT": "Hora d’estiu d’Austràlia Oriental", "AST": "Hora estàndard de l’Atlàntic", "CLT": "Hora estàndard de Xile", "AKST": "Hora estàndard d’Alaska", "LHST": "Hora estàndard de Lord Howe", "HECU": "Hora d’estiu de Cuba", "ACWST": "Hora estàndard d’Austràlia centre-occidental", "MEZ": "Hora estàndard del Centre d’Europa", "OESZ": "Hora d’estiu de l’Est d’Europa", "WAT": "Hora estàndard de l’Àfrica Occidental", "ACST": "Hora estàndard d’Austràlia Central", "UYST": "Hora d’estiu de l’Uruguai", "HEEG": "Hora d’estiu de l’Est de Grenlàndia", "∅∅∅": "∅∅∅", "HNCU": "Hora estàndard de Cuba", "ACWDT": "Hora d’estiu d’Austràlia centre-occidental", "NZST": "Hora estàndard de Nova Zelanda", "HNOG": "Hora estàndard de l’Oest de Grenlàndia", "OEZ": "Hora estàndard de l’Est d’Europa", "HAT": "Hora d’estiu de Terranova", "EDT": "Hora d’estiu oriental d’Amèrica del Nord", "HNNOMX": "Hora estàndard del nord-oest de Mèxic", "GMT": "Hora del Meridià de Greenwich", "GYT": "Hora de Guyana", "CAT": "Hora de l’Àfrica Central", "NZDT": "Hora d’estiu de Nova Zelanda", "JDT": "Hora d’estiu del Japó", "WITA": "Hora central d’Indonèsia", "AWST": "Hora estàndard d’Austràlia Occidental", "ChST": "Hora de Chamorro", "HNPM": "Hora estàndard de Saint-Pierre i Miquelon", "LHDT": "Horari d’estiu de Lord Howe", "CHAST": "Hora estàndard de Chatham", "CHADT": "Hora d’estiu de Chatham", "ADT": "Hora d’estiu de l’Atlàntic", "GFT": "Hora de la Guaiana Francesa"}, + } +} + +// Locale returns the current translators string locale +func (ca *ca_IT) Locale() string { + return ca.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ca_IT' +func (ca *ca_IT) PluralsCardinal() []locales.PluralRule { + return ca.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ca_IT' +func (ca *ca_IT) PluralsOrdinal() []locales.PluralRule { + return ca.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ca_IT' +func (ca *ca_IT) PluralsRange() []locales.PluralRule { + return ca.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ca_IT' +func (ca *ca_IT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ca_IT' +func (ca *ca_IT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 3 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ca_IT' +func (ca *ca_IT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ca *ca_IT) MonthAbbreviated(month time.Month) string { + return ca.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ca *ca_IT) MonthsAbbreviated() []string { + return ca.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ca *ca_IT) MonthNarrow(month time.Month) string { + return ca.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ca *ca_IT) MonthsNarrow() []string { + return ca.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ca *ca_IT) MonthWide(month time.Month) string { + return ca.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ca *ca_IT) MonthsWide() []string { + return ca.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ca *ca_IT) WeekdayAbbreviated(weekday time.Weekday) string { + return ca.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ca *ca_IT) WeekdaysAbbreviated() []string { + return ca.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ca *ca_IT) WeekdayNarrow(weekday time.Weekday) string { + return ca.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ca *ca_IT) WeekdaysNarrow() []string { + return ca.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ca *ca_IT) WeekdayShort(weekday time.Weekday) string { + return ca.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ca *ca_IT) WeekdaysShort() []string { + return ca.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ca *ca_IT) WeekdayWide(weekday time.Weekday) string { + return ca.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ca *ca_IT) WeekdaysWide() []string { + return ca.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ca_IT' and handles both Whole and Real numbers based on 'v' +func (ca *ca_IT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ca_IT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ca *ca_IT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ca.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ca_IT' +func (ca *ca_IT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ca.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ca.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ca_IT' +// in accounting notation. +func (ca *ca_IT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ca.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ca.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ca.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ca.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ca.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ca.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ca.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ca_IT' +func (ca *ca_IT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ca_IT' +func (ca *ca_IT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ca_IT' +func (ca *ca_IT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ca_IT' +func (ca *ca_IT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ca.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ca.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ca_IT' +func (ca *ca_IT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ca_IT' +func (ca *ca_IT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ca_IT' +func (ca *ca_IT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ca_IT' +func (ca *ca_IT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ca.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ca.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ca.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ca_IT/ca_IT_test.go b/vendor/github.com/go-playground/locales/ca_IT/ca_IT_test.go new file mode 100644 index 0000000000..2a1a3b33c2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ca_IT/ca_IT_test.go @@ -0,0 +1,1120 @@ +package ca_IT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ca_IT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ce/ce.go b/vendor/github.com/go-playground/locales/ce/ce.go new file mode 100644 index 0000000000..6e7c0d2a84 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ce/ce.go @@ -0,0 +1,439 @@ +package ce + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ce struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ce' locale +func New() locales.Translator { + return &ce{ + locale: "ce", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "₽", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв", "фев", "мар", "апр", "май", "июн", "июл", "авг", "сен", "окт", "ноя", "дек"}, + monthsWide: []string{"", "январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь"}, + daysWide: []string{"кӀиранан де", "оршотан де", "шинарин де", "кхаарин де", "еарин де", "пӀераскан де", "шот де"}, + timezones: map[string]string{"EST": "Малхбален Америка, стандартан хан", "GFT": "Французийн Гвиана", "CLST": "Чили, аьхкенан хан", "WESZ": "Малхбузен Европа, аьхкенан хан", "HEOG": "Малхбузен Гренланди, аьхкенан хан", "BT": "Бутан", "CHADT": "Чатем, аьхкенан хан", "ACWDT": "Юккъера Австрали, малхбузен аьхкенан хан", "HKT": "Гонконг, стандартан хан", "HKST": "Гонконг, аьхкенан хан", "HNT": "Ньюфаундленд, стандартан хан", "ECT": "Эквадор", "MESZ": "Юккъера Европа, аьхкенан хан", "TMST": "Туркменин аьхкенан хан", "ACDT": "Юккъера Австрали, аьхкенан хан", "AKDT": "Аляска, аьхкенан хан", "WITA": "Юккъера Индонези", "CAT": "Юккъера Африка", "PDT": "Тийна океанан аьхкенан хан", "HADT": "Гавайн-алеутийн аьхкенан хан", "JDT": "Япони, аьхкенан хан", "ARST": "Аргентина, аьхкенан хан", "WAST": "Малхбузен Африка, аьхкенан хан", "CDT": "Юккъера Америка, аьхкенан хан", "SGT": "Сингапур", "WART": "Малхбузен Аргентина, стандартан хан", "AKST": "Аляска, стандартан хан", "HEPM": "Сен-Пьер а, Микелон а, аьхкенан хан", "HAST": "Гавайн-алеутийн стандартан хан", "NZST": "Керла Зеланди, стандартан хан", "NZDT": "Керла Зеланди, аьхкенан хан", "OEZ": "Малхбален Европа, стандартан хан", "CLT": "Чили, стандартан хан", "MST": "MST", "HNNOMX": "Къилбаседа Американ Мексикан стандартан хан", "PST": "Тийна океанан стандартан хан", "IST": "Инди", "TMT": "Туркменин стандартан хан", "AEST": "Малхбален Австрали, стандартан хан", "GYT": "Гайана", "BOT": "Боливи", "ACWST": "Юккъера Австрали, малхбузен стандартан хан", "MEZ": "Юккъера Европа, стандартан хан", "HEEG": "Малхбален Гренланди, аьхкенан хан", "HNPMX": "Тийна океанан Мексикан стандартан хан", "AWDT": "Малхбузен Австрали, аьхкенан хан", "CHAST": "Чатем, стандартан хан", "ACST": "Юккъера Австрали, стандартан хан", "SAST": "Къилба Африка", "OESZ": "Малхбален Европа, аьхкенан хан", "AST": "Атлантикан стандартан хан", "LHST": "Лорд-Хау, стандартан хан", "LHDT": "Лорд-Хау, аьхкенан хан", "WIT": "Малхбален Индонези", "JST": "Япони, стандартан хан", "ART": "Аргентина, стандартан хан", "HENOMX": "Къилбаседа Американ Мексикан аьхкенан хан", "ChST": "Чаморро", "SRT": "Суринам", "HNCU": "Куба, стандартан хан", "WIB": "Малхбузен Индонези", "CST": "Юккъера Америка, стандартан хан", "GMT": "Гринвичица юкъара хан", "MDT": "MDT", "WAT": "Малхбузен Африка, стандартан хан", "HEPMX": "Тийна океанан Мексикан аьхкенан хан", "HNEG": "Малхбален Гренланди, стандартан хан", "EAT": "Малхбален Африка", "HECU": "Куба, аьхкенан хан", "AWST": "Малхбузен Австрали, стандартан хан", "ADT": "Атлантикан аьхкенан хан", "EDT": "Малхбален Америка, аьхкенан хан", "COT": "Колумби, стандартан хан", "HNPM": "Сен-Пьер а, Микелон а, стандартан хан", "∅∅∅": "Азоран гӀайренаш, аьхкенан хан", "WEZ": "Малхбузен Европа, стандартан хан", "MYT": "Малайзи", "WARST": "Малхбузен Аргентина, аьхкенан хан", "COST": "Колумби, аьхкенан хан", "HAT": "Ньюфаундленд, аьхкенан хан", "UYST": "Уругвай, аьхкенан хан", "VET": "Венесуэла", "HNOG": "Малхбузен Гренланди, стандартан хан", "AEDT": "Малхбален Австрали, аьхкенан хан", "UYT": "Уругвай, стандартан хан"}, + } +} + +// Locale returns the current translators string locale +func (ce *ce) Locale() string { + return ce.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ce' +func (ce *ce) PluralsCardinal() []locales.PluralRule { + return ce.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ce' +func (ce *ce) PluralsOrdinal() []locales.PluralRule { + return ce.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ce' +func (ce *ce) PluralsRange() []locales.PluralRule { + return ce.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ce' +func (ce *ce) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ce' +func (ce *ce) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ce' +func (ce *ce) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ce *ce) MonthAbbreviated(month time.Month) string { + return ce.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ce *ce) MonthsAbbreviated() []string { + return ce.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ce *ce) MonthNarrow(month time.Month) string { + return ce.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ce *ce) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ce *ce) MonthWide(month time.Month) string { + return ce.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ce *ce) MonthsWide() []string { + return ce.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ce *ce) WeekdayAbbreviated(weekday time.Weekday) string { + return ce.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ce *ce) WeekdaysAbbreviated() []string { + return ce.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ce *ce) WeekdayNarrow(weekday time.Weekday) string { + return ce.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ce *ce) WeekdaysNarrow() []string { + return ce.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ce *ce) WeekdayShort(weekday time.Weekday) string { + return ce.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ce *ce) WeekdaysShort() []string { + return ce.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ce *ce) WeekdayWide(weekday time.Weekday) string { + return ce.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ce *ce) WeekdaysWide() []string { + return ce.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ce' and handles both Whole and Real numbers based on 'v' +func (ce *ce) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ce.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ce.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ce.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ce' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ce *ce) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ce.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ce.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ce.percentSuffix...) + + b = append(b, ce.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ce' +func (ce *ce) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ce.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ce.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ce.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ce.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ce.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ce.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ce' +// in accounting notation. +func (ce *ce) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ce.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ce.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ce.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ce.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ce.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ce.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ce.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ce' +func (ce *ce) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ce' +func (ce *ce) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ce' +func (ce *ce) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ce' +func (ce *ce) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ce' +func (ce *ce) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ce' +func (ce *ce) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ce' +func (ce *ce) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ce' +func (ce *ce) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ce/ce_test.go b/vendor/github.com/go-playground/locales/ce/ce_test.go new file mode 100644 index 0000000000..32181dcfbc --- /dev/null +++ b/vendor/github.com/go-playground/locales/ce/ce_test.go @@ -0,0 +1,1120 @@ +package ce + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ce" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ce_RU/ce_RU.go b/vendor/github.com/go-playground/locales/ce_RU/ce_RU.go new file mode 100644 index 0000000000..c6fd217251 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ce_RU/ce_RU.go @@ -0,0 +1,439 @@ +package ce_RU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ce_RU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ce_RU' locale +func New() locales.Translator { + return &ce_RU{ + locale: "ce_RU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв", "фев", "мар", "апр", "май", "июн", "июл", "авг", "сен", "окт", "ноя", "дек"}, + monthsWide: []string{"", "январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь"}, + daysWide: []string{"кӀиранан де", "оршотан де", "шинарин де", "кхаарин де", "еарин де", "пӀераскан де", "шот де"}, + timezones: map[string]string{"SAST": "Къилба Африка", "HNCU": "Куба, стандартан хан", "HAT": "Ньюфаундленд, аьхкенан хан", "WART": "Малхбузен Аргентина, стандартан хан", "MDT": "MDT", "EST": "Малхбален Америка, стандартан хан", "LHST": "Лорд-Хау, стандартан хан", "EAT": "Малхбален Африка", "WEZ": "Малхбузен Европа, стандартан хан", "WAT": "Малхбузен Африка, стандартан хан", "ACST": "Юккъера Австрали, стандартан хан", "ACDT": "Юккъера Австрали, аьхкенан хан", "HEPM": "Сен-Пьер а, Микелон а, аьхкенан хан", "LHDT": "Лорд-Хау, аьхкенан хан", "CLT": "Чили, стандартан хан", "ADT": "Атлантикан аьхкенан хан", "AKST": "Аляска, стандартан хан", "UYT": "Уругвай, стандартан хан", "ACWST": "Юккъера Австрали, малхбузен стандартан хан", "MEZ": "Юккъера Европа, стандартан хан", "GMT": "Гринвичица юкъара хан", "HENOMX": "Къилбаседа Американ Мексикан аьхкенан хан", "HNT": "Ньюфаундленд, стандартан хан", "WITA": "Юккъера Индонези", "∅∅∅": "Азоран гӀайренаш, аьхкенан хан", "ECT": "Эквадор", "IST": "Инди", "AEDT": "Малхбален Австрали, аьхкенан хан", "WIB": "Малхбузен Индонези", "AWDT": "Малхбузен Австрали, аьхкенан хан", "WESZ": "Малхбузен Европа, аьхкенан хан", "HEPMX": "Тийна океанан Мексикан аьхкенан хан", "CDT": "Юккъера Америка, аьхкенан хан", "HNNOMX": "Къилбаседа Американ Мексикан стандартан хан", "GFT": "Французийн Гвиана", "HNPM": "Сен-Пьер а, Микелон а, стандартан хан", "SRT": "Суринам", "NZDT": "Керла Зеланди, аьхкенан хан", "HKST": "Гонконг, аьхкенан хан", "OESZ": "Малхбален Европа, аьхкенан хан", "AKDT": "Аляска, аьхкенан хан", "WIT": "Малхбален Индонези", "PDT": "Тийна океанан аьхкенан хан", "HAST": "Гавайн-алеутийн стандартан хан", "CLST": "Чили, аьхкенан хан", "HNOG": "Малхбузен Гренланди, стандартан хан", "HEOG": "Малхбузен Гренланди, аьхкенан хан", "ART": "Аргентина, стандартан хан", "GYT": "Гайана", "HECU": "Куба, аьхкенан хан", "MYT": "Малайзи", "MESZ": "Юккъера Европа, аьхкенан хан", "HEEG": "Малхбален Гренланди, аьхкенан хан", "CHADT": "Чатем, аьхкенан хан", "HADT": "Гавайн-алеутийн аьхкенан хан", "CAT": "Юккъера Африка", "BT": "Бутан", "UYST": "Уругвай, аьхкенан хан", "JST": "Япони, стандартан хан", "OEZ": "Малхбален Европа, стандартан хан", "MST": "MST", "TMT": "Туркменин стандартан хан", "ChST": "Чаморро", "CHAST": "Чатем, стандартан хан", "VET": "Венесуэла", "JDT": "Япони, аьхкенан хан", "COST": "Колумби, аьхкенан хан", "HNEG": "Малхбален Гренланди, стандартан хан", "BOT": "Боливи", "TMST": "Туркменин аьхкенан хан", "EDT": "Малхбален Америка, аьхкенан хан", "WARST": "Малхбузен Аргентина, аьхкенан хан", "ARST": "Аргентина, аьхкенан хан", "HKT": "Гонконг, стандартан хан", "COT": "Колумби, стандартан хан", "AEST": "Малхбален Австрали, стандартан хан", "HNPMX": "Тийна океанан Мексикан стандартан хан", "PST": "Тийна океанан стандартан хан", "NZST": "Керла Зеланди, стандартан хан", "ACWDT": "Юккъера Австрали, малхбузен аьхкенан хан", "AST": "Атлантикан стандартан хан", "WAST": "Малхбузен Африка, аьхкенан хан", "CST": "Юккъера Америка, стандартан хан", "AWST": "Малхбузен Австрали, стандартан хан", "SGT": "Сингапур"}, + } +} + +// Locale returns the current translators string locale +func (ce *ce_RU) Locale() string { + return ce.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ce_RU' +func (ce *ce_RU) PluralsCardinal() []locales.PluralRule { + return ce.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ce_RU' +func (ce *ce_RU) PluralsOrdinal() []locales.PluralRule { + return ce.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ce_RU' +func (ce *ce_RU) PluralsRange() []locales.PluralRule { + return ce.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ce_RU' +func (ce *ce_RU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ce_RU' +func (ce *ce_RU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ce_RU' +func (ce *ce_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ce *ce_RU) MonthAbbreviated(month time.Month) string { + return ce.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ce *ce_RU) MonthsAbbreviated() []string { + return ce.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ce *ce_RU) MonthNarrow(month time.Month) string { + return ce.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ce *ce_RU) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ce *ce_RU) MonthWide(month time.Month) string { + return ce.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ce *ce_RU) MonthsWide() []string { + return ce.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ce *ce_RU) WeekdayAbbreviated(weekday time.Weekday) string { + return ce.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ce *ce_RU) WeekdaysAbbreviated() []string { + return ce.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ce *ce_RU) WeekdayNarrow(weekday time.Weekday) string { + return ce.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ce *ce_RU) WeekdaysNarrow() []string { + return ce.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ce *ce_RU) WeekdayShort(weekday time.Weekday) string { + return ce.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ce *ce_RU) WeekdaysShort() []string { + return ce.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ce *ce_RU) WeekdayWide(weekday time.Weekday) string { + return ce.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ce *ce_RU) WeekdaysWide() []string { + return ce.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ce_RU' and handles both Whole and Real numbers based on 'v' +func (ce *ce_RU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ce.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ce.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ce.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ce_RU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ce *ce_RU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ce.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ce.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ce.percentSuffix...) + + b = append(b, ce.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ce_RU' +func (ce *ce_RU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ce.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ce.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ce.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ce.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ce.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ce.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ce_RU' +// in accounting notation. +func (ce *ce_RU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ce.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ce.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ce.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ce.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ce.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ce.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ce.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ce_RU' +func (ce *ce_RU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ce_RU' +func (ce *ce_RU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ce_RU' +func (ce *ce_RU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ce_RU' +func (ce *ce_RU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ce_RU' +func (ce *ce_RU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ce_RU' +func (ce *ce_RU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ce_RU' +func (ce *ce_RU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ce_RU' +func (ce *ce_RU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ce_RU/ce_RU_test.go b/vendor/github.com/go-playground/locales/ce_RU/ce_RU_test.go new file mode 100644 index 0000000000..281f8d24a7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ce_RU/ce_RU_test.go @@ -0,0 +1,1120 @@ +package ce_RU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ce_RU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/cgg/cgg.go b/vendor/github.com/go-playground/locales/cgg/cgg.go new file mode 100644 index 0000000000..0e0aaadbfd --- /dev/null +++ b/vendor/github.com/go-playground/locales/cgg/cgg.go @@ -0,0 +1,515 @@ +package cgg + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type cgg struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'cgg' locale +func New() locales.Translator { + return &cgg{ + locale: "cgg", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "USh", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "KBZ", "KBR", "KST", "KKN", "KTN", "KMK", "KMS", "KMN", "KMW", "KKM", "KNK", "KNB"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Okwokubanza", "Okwakabiri", "Okwakashatu", "Okwakana", "Okwakataana", "Okwamukaaga", "Okwamushanju", "Okwamunaana", "Okwamwenda", "Okwaikumi", "Okwaikumi na kumwe", "Okwaikumi na ibiri"}, + daysAbbreviated: []string{"SAN", "ORK", "OKB", "OKS", "OKN", "OKT", "OMK"}, + daysNarrow: []string{"S", "K", "R", "S", "N", "T", "M"}, + daysWide: []string{"Sande", "Orwokubanza", "Orwakabiri", "Orwakashatu", "Orwakana", "Orwakataano", "Orwamukaaga"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kurisito Atakaijire", "Kurisito Yaijire"}, + timezones: map[string]string{"VET": "VET", "OEZ": "OEZ", "ART": "ART", "EDT": "EDT", "COST": "COST", "HNNOMX": "HNNOMX", "HNPM": "HNPM", "HNCU": "HNCU", "SGT": "SGT", "MDT": "MDT", "BT": "BT", "AEDT": "AEDT", "CHADT": "CHADT", "HADT": "HADT", "WESZ": "WESZ", "WARST": "WARST", "ChST": "ChST", "LHST": "LHST", "HKST": "HKST", "ACST": "ACST", "CAT": "CAT", "HAST": "HAST", "ECT": "ECT", "NZDT": "NZDT", "MEZ": "MEZ", "ADT": "ADT", "CLT": "CLT", "HNT": "HNT", "CST": "CST", "UYT": "UYT", "SRT": "SRT", "WIT": "WIT", "PST": "PST", "HEOG": "HEOG", "TMST": "TMST", "AKST": "AKST", "∅∅∅": "∅∅∅", "EAT": "EAT", "AWST": "AWST", "ACWDT": "ACWDT", "JST": "JST", "AST": "AST", "HAT": "HAT", "LHDT": "LHDT", "WIB": "WIB", "AWDT": "AWDT", "MST": "MST", "ACDT": "ACDT", "COT": "COT", "AKDT": "AKDT", "HEPM": "HEPM", "SAST": "SAST", "WART": "WART", "CLST": "CLST", "TMT": "TMT", "HKT": "HKT", "MESZ": "MESZ", "BOT": "BOT", "WAST": "WAST", "HEPMX": "HEPMX", "EST": "EST", "AEST": "AEST", "JDT": "JDT", "GYT": "GYT", "CHAST": "CHAST", "NZST": "NZST", "HNOG": "HNOG", "HNPMX": "HNPMX", "OESZ": "OESZ", "WEZ": "WEZ", "HEEG": "HEEG", "GFT": "GFT", "HECU": "HECU", "ACWST": "ACWST", "HENOMX": "HENOMX", "HNEG": "HNEG", "IST": "IST", "PDT": "PDT", "GMT": "GMT", "MYT": "MYT", "ARST": "ARST", "WAT": "WAT", "WITA": "WITA", "UYST": "UYST", "CDT": "CDT"}, + } +} + +// Locale returns the current translators string locale +func (cgg *cgg) Locale() string { + return cgg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'cgg' +func (cgg *cgg) PluralsCardinal() []locales.PluralRule { + return cgg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'cgg' +func (cgg *cgg) PluralsOrdinal() []locales.PluralRule { + return cgg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'cgg' +func (cgg *cgg) PluralsRange() []locales.PluralRule { + return cgg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'cgg' +func (cgg *cgg) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'cgg' +func (cgg *cgg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'cgg' +func (cgg *cgg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (cgg *cgg) MonthAbbreviated(month time.Month) string { + return cgg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (cgg *cgg) MonthsAbbreviated() []string { + return cgg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (cgg *cgg) MonthNarrow(month time.Month) string { + return cgg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (cgg *cgg) MonthsNarrow() []string { + return cgg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (cgg *cgg) MonthWide(month time.Month) string { + return cgg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (cgg *cgg) MonthsWide() []string { + return cgg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (cgg *cgg) WeekdayAbbreviated(weekday time.Weekday) string { + return cgg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (cgg *cgg) WeekdaysAbbreviated() []string { + return cgg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (cgg *cgg) WeekdayNarrow(weekday time.Weekday) string { + return cgg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (cgg *cgg) WeekdaysNarrow() []string { + return cgg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (cgg *cgg) WeekdayShort(weekday time.Weekday) string { + return cgg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (cgg *cgg) WeekdaysShort() []string { + return cgg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (cgg *cgg) WeekdayWide(weekday time.Weekday) string { + return cgg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (cgg *cgg) WeekdaysWide() []string { + return cgg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'cgg' and handles both Whole and Real numbers based on 'v' +func (cgg *cgg) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'cgg' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (cgg *cgg) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'cgg' +func (cgg *cgg) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cgg.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cgg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cgg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, cgg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cgg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'cgg' +// in accounting notation. +func (cgg *cgg) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cgg.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cgg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cgg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, cgg.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cgg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'cgg' +func (cgg *cgg) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'cgg' +func (cgg *cgg) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cgg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'cgg' +func (cgg *cgg) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cgg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'cgg' +func (cgg *cgg) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, cgg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cgg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'cgg' +func (cgg *cgg) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'cgg' +func (cgg *cgg) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'cgg' +func (cgg *cgg) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'cgg' +func (cgg *cgg) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := cgg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/cgg/cgg_test.go b/vendor/github.com/go-playground/locales/cgg/cgg_test.go new file mode 100644 index 0000000000..3fae92e9f6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cgg/cgg_test.go @@ -0,0 +1,1120 @@ +package cgg + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "cgg" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/cgg_UG/cgg_UG.go b/vendor/github.com/go-playground/locales/cgg_UG/cgg_UG.go new file mode 100644 index 0000000000..016091c2f4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cgg_UG/cgg_UG.go @@ -0,0 +1,515 @@ +package cgg_UG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type cgg_UG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'cgg_UG' locale +func New() locales.Translator { + return &cgg_UG{ + locale: "cgg_UG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "KBZ", "KBR", "KST", "KKN", "KTN", "KMK", "KMS", "KMN", "KMW", "KKM", "KNK", "KNB"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Okwokubanza", "Okwakabiri", "Okwakashatu", "Okwakana", "Okwakataana", "Okwamukaaga", "Okwamushanju", "Okwamunaana", "Okwamwenda", "Okwaikumi", "Okwaikumi na kumwe", "Okwaikumi na ibiri"}, + daysAbbreviated: []string{"SAN", "ORK", "OKB", "OKS", "OKN", "OKT", "OMK"}, + daysNarrow: []string{"S", "K", "R", "S", "N", "T", "M"}, + daysWide: []string{"Sande", "Orwokubanza", "Orwakabiri", "Orwakashatu", "Orwakana", "Orwakataano", "Orwamukaaga"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kurisito Atakaijire", "Kurisito Yaijire"}, + timezones: map[string]string{"AKDT": "AKDT", "∅∅∅": "∅∅∅", "LHDT": "LHDT", "WIB": "WIB", "CST": "CST", "WIT": "WIT", "EST": "EST", "UYT": "UYT", "CHAST": "CHAST", "MEZ": "MEZ", "CLST": "CLST", "HNT": "HNT", "CDT": "CDT", "ECT": "ECT", "MESZ": "MESZ", "HNOG": "HNOG", "WAT": "WAT", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "MDT": "MDT", "ChST": "ChST", "GYT": "GYT", "HAST": "HAST", "VET": "VET", "SRT": "SRT", "PST": "PST", "AST": "AST", "WEZ": "WEZ", "ARST": "ARST", "EDT": "EDT", "AEST": "AEST", "HEPMX": "HEPMX", "PDT": "PDT", "HADT": "HADT", "WART": "WART", "NZDT": "NZDT", "MYT": "MYT", "ART": "ART", "SAST": "SAST", "HECU": "HECU", "CAT": "CAT", "ACWST": "ACWST", "TMST": "TMST", "WAST": "WAST", "LHST": "LHST", "EAT": "EAT", "HNCU": "HNCU", "AWDT": "AWDT", "JST": "JST", "ACST": "ACST", "COST": "COST", "UYST": "UYST", "OEZ": "OEZ", "AEDT": "AEDT", "MST": "MST", "HNPM": "HNPM", "SGT": "SGT", "OESZ": "OESZ", "COT": "COT", "HENOMX": "HENOMX", "GFT": "GFT", "AWST": "AWST", "IST": "IST", "HNEG": "HNEG", "WITA": "WITA", "HEPM": "HEPM", "CHADT": "CHADT", "ADT": "ADT", "HAT": "HAT", "BOT": "BOT", "WESZ": "WESZ", "HKST": "HKST", "HNPMX": "HNPMX", "JDT": "JDT", "TMT": "TMT", "ACDT": "ACDT", "HKT": "HKT", "AKST": "AKST", "NZST": "NZST", "ACWDT": "ACWDT", "GMT": "GMT", "WARST": "WARST", "CLT": "CLT", "HEOG": "HEOG", "BT": "BT"}, + } +} + +// Locale returns the current translators string locale +func (cgg *cgg_UG) Locale() string { + return cgg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'cgg_UG' +func (cgg *cgg_UG) PluralsCardinal() []locales.PluralRule { + return cgg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'cgg_UG' +func (cgg *cgg_UG) PluralsOrdinal() []locales.PluralRule { + return cgg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'cgg_UG' +func (cgg *cgg_UG) PluralsRange() []locales.PluralRule { + return cgg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'cgg_UG' +func (cgg *cgg_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'cgg_UG' +func (cgg *cgg_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'cgg_UG' +func (cgg *cgg_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (cgg *cgg_UG) MonthAbbreviated(month time.Month) string { + return cgg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (cgg *cgg_UG) MonthsAbbreviated() []string { + return cgg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (cgg *cgg_UG) MonthNarrow(month time.Month) string { + return cgg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (cgg *cgg_UG) MonthsNarrow() []string { + return cgg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (cgg *cgg_UG) MonthWide(month time.Month) string { + return cgg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (cgg *cgg_UG) MonthsWide() []string { + return cgg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (cgg *cgg_UG) WeekdayAbbreviated(weekday time.Weekday) string { + return cgg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (cgg *cgg_UG) WeekdaysAbbreviated() []string { + return cgg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (cgg *cgg_UG) WeekdayNarrow(weekday time.Weekday) string { + return cgg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (cgg *cgg_UG) WeekdaysNarrow() []string { + return cgg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (cgg *cgg_UG) WeekdayShort(weekday time.Weekday) string { + return cgg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (cgg *cgg_UG) WeekdaysShort() []string { + return cgg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (cgg *cgg_UG) WeekdayWide(weekday time.Weekday) string { + return cgg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (cgg *cgg_UG) WeekdaysWide() []string { + return cgg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'cgg_UG' and handles both Whole and Real numbers based on 'v' +func (cgg *cgg_UG) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'cgg_UG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (cgg *cgg_UG) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'cgg_UG' +func (cgg *cgg_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cgg.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cgg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cgg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, cgg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cgg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'cgg_UG' +// in accounting notation. +func (cgg *cgg_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cgg.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cgg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cgg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, cgg.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cgg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'cgg_UG' +func (cgg *cgg_UG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'cgg_UG' +func (cgg *cgg_UG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cgg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'cgg_UG' +func (cgg *cgg_UG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cgg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'cgg_UG' +func (cgg *cgg_UG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, cgg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cgg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'cgg_UG' +func (cgg *cgg_UG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'cgg_UG' +func (cgg *cgg_UG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'cgg_UG' +func (cgg *cgg_UG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'cgg_UG' +func (cgg *cgg_UG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cgg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := cgg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/cgg_UG/cgg_UG_test.go b/vendor/github.com/go-playground/locales/cgg_UG/cgg_UG_test.go new file mode 100644 index 0000000000..6620db686a --- /dev/null +++ b/vendor/github.com/go-playground/locales/cgg_UG/cgg_UG_test.go @@ -0,0 +1,1120 @@ +package cgg_UG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "cgg_UG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/chr/chr.go b/vendor/github.com/go-playground/locales/chr/chr.go new file mode 100644 index 0000000000..823015b06b --- /dev/null +++ b/vendor/github.com/go-playground/locales/chr/chr.go @@ -0,0 +1,621 @@ +package chr + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type chr struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'chr' locale +func New() locales.Translator { + return &chr{ + locale: "chr", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ᎤᏃ", "ᎧᎦ", "ᎠᏅ", "ᎧᏬ", "ᎠᏂ", "ᏕᎭ", "ᎫᏰ", "ᎦᎶ", "ᏚᎵ", "ᏚᏂ", "ᏅᏓ", "ᎥᏍ"}, + monthsNarrow: []string{"", "Ꭴ", "Ꭷ", "Ꭰ", "Ꭷ", "Ꭰ", "Ꮥ", "Ꭻ", "Ꭶ", "Ꮪ", "Ꮪ", "Ꮕ", "Ꭵ"}, + monthsWide: []string{"", "ᎤᏃᎸᏔᏅ", "ᎧᎦᎵ", "ᎠᏅᏱ", "ᎧᏬᏂ", "ᎠᏂᏍᎬᏘ", "ᏕᎭᎷᏱ", "ᎫᏰᏉᏂ", "ᎦᎶᏂ", "ᏚᎵᏍᏗ", "ᏚᏂᏅᏗ", "ᏅᏓᏕᏆ", "ᎥᏍᎩᏱ"}, + daysAbbreviated: []string{"ᏆᏍᎬ", "ᏉᏅᎯ", "ᏔᎵᏁ", "ᏦᎢᏁ", "ᏅᎩᏁ", "ᏧᎾᎩ", "ᏈᏕᎾ"}, + daysNarrow: []string{"Ꮖ", "Ꮙ", "Ꮤ", "Ꮶ", "Ꮕ", "Ꮷ", "Ꭴ"}, + daysShort: []string{"ᏍᎬ", "ᏅᎯ", "ᏔᎵ", "ᏦᎢ", "ᏅᎩ", "ᏧᎾ", "ᏕᎾ"}, + daysWide: []string{"ᎤᎾᏙᏓᏆᏍᎬ", "ᎤᎾᏙᏓᏉᏅᎯ", "ᏔᎵᏁᎢᎦ", "ᏦᎢᏁᎢᎦ", "ᏅᎩᏁᎢᎦ", "ᏧᎾᎩᎶᏍᏗ", "ᎤᎾᏙᏓᏈᏕᎾ"}, + periodsAbbreviated: []string{"ᏌᎾᎴ", "ᏒᎯᏱᎢᏗᏢ"}, + periodsNarrow: []string{"Ꮜ", "Ꮢ"}, + periodsWide: []string{"ᏌᎾᎴ", "ᏒᎯᏱᎢᏗᏢ"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ᏧᏓᎷᎸ ᎤᎷᎯᏍᏗ ᎦᎶᏁᏛ", "ᎠᏃ ᏙᎻᏂ"}, + timezones: map[string]string{"AWDT": "ᎡᎳᏗᏜ ᏭᏕᎵᎬ ᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "CHADT": "ᏣᏝᎻ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "WEZ": "ᏭᏕᎵᎬ ᏗᏜ ᏳᎳᏈ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HNT": "ᎢᏤᎤᏂᏩᏛᏓᎦᏙᎯ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HADT": "ᎭᏩᏱ-ᎠᎵᏳᏏᎠᏂ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "MESZ": "ᎠᏰᏟ ᏳᎳᏈ ᎪᎩ ᎠᏟᎢᎵᏒ", "OEZ": "ᏗᎧᎸᎬ ᏗᏜ ᏳᎳᏈ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "TMT": "ᏛᎵᎩᎺᏂᏍᏔᏂ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "EDT": "ᏗᎧᎸᎬ ᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "HNCU": "ᎫᏆ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "NZDT": "ᎢᏤ ᏏᎢᎴᏂᏗ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "HEOG": "ᏭᏕᎵᎬ ᎢᏤᏍᏛᏱ ᎪᎩ ᎠᏟᎢᎵᏒ", "ACST": "ᎠᏰᏟ ᎡᎳᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "WITA": "ᎠᏰᏟ ᎢᏂᏙᏂᏍᏯ ᎠᏟᎢᎵᏒ", "PDT": "ᏭᏕᎵᎬ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "HNEG": "ᏗᎧᎸᎬ ᎢᏤᏍᏛᏱ ᎠᏟᎶᏍᏗ ᎠᎵᎢᎵᏒ", "UYST": "ᏳᎷᏇ ᎪᎩ ᎠᏟᎢᎵᏒ", "LHST": "ᎤᎬᏫᏳᎯ ᎭᏫ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "LHDT": "ᎤᎬᏫᏳᎯ ᎭᏫ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "SAST": "ᏧᎦᎾᏮ ᎬᎿᎨᏍᏛ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "GYT": "ᎦᏯᎾ ᎠᏟᎢᎵᏒ", "CST": "ᎠᏰᏟ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "JDT": "ᏣᏩᏂᏏ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "WARST": "ᏭᏕᎵᎬ ᏗᏜ ᎠᏥᏂᏘᏂᎠ ᎪᎩ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HECU": "ᎫᏆ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "EAT": "ᏗᎧᎸᎬ ᎬᎿᎨᏍᏛ ᎠᏟᎢᎵᏒ", "HEEG": "ᏗᎧᎸᎬ ᎢᏤᏍᏛᏱ ᎪᎩ ᎠᏟᎢᎵᏒ", "BT": "ᏊᏔᏂ ᎠᏟᎢᎵᏒ", "ACDT": "ᎠᏰᏟ ᎡᎳᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "HEPMX": "ᎠᏂᏍᏆᏂ ᏭᏕᎵᎬ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "CDT": "ᎠᏰᏟ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "BOT": "ᏉᎵᏫᎠ ᎠᏟᎢᎵᏒ", "NZST": "ᎢᏤ ᏏᎢᎴᏂᏗ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "JST": "ᏣᏩᏂᏏ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AWST": "ᎡᎳᏗᏜ ᏭᏕᎵᎬ ᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "PST": "ᏭᏕᎵᎬ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HNOG": "ᏭᏕᎵᎬ ᎢᏤᏍᏛᏱ ᎠᏟᎶᏍᏗ ᎠᎵᎢᎵᏒ", "WAST": "ᏭᏕᎵᎬ ᎬᎿᎨᏍᏛ ᎪᎩ ᎠᏟᎢᎵᏒ", "ChST": "ᏣᎼᎶ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "CHAST": "ᏣᏝᎻ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "WESZ": "ᏭᏕᎵᎬ ᏗᏜ ᏳᎳᏈ ᎪᎩ ᎠᏟᎢᎵᏒ", "MYT": "ᎹᎴᏏᎢᎠ ᎠᏟᎢᎵᏒ", "HNNOMX": "ᏧᏴᏢ ᏭᏕᎵᎬ ᎠᏂᏍᏆᏂ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "COT": "ᎪᎸᎻᏈᎢᎠ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AEDT": "ᎡᎳᏗᏜ ᏗᎧᎸᎬ ᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "HNPMX": "ᎠᏂᏍᏆᏂ ᏭᏕᎵᎬ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "OESZ": "ᏗᎧᎸᎬ ᏗᏜ ᏳᎳᏈ ᎪᎩ ᎠᏟᎢᎵᏒ", "CLST": "ᏥᎵ ᎪᎩ ᎠᏟᎢᎵᏒ", "ADT": "ᏗᎧᎸᎬ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "HKST": "ᎰᏂᎩ ᎪᏂᎩ ᎪᎩ ᎠᏟᎢᎵᏒ", "SRT": "ᏒᎵᎾᎻ ᎠᏟᎢᎵᏒ", "SGT": "ᏏᏂᎦᏉᎵ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "EST": "ᏗᎧᎸᎬ ᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HAT": "ᎢᏤᎤᏂᏩᏛᏓᎦᏙᎯ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "AEST": "ᎡᎳᏗᏜ ᏗᎧᎸᎬ ᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "WIT": "ᏗᎧᎸᎬ ᏗᏜ ᎢᏂᏙᏂᏍᏯ ᎠᏟᎢᎵᏒ", "IST": "ᎢᏂᏗᎢᎠ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "GMT": "ᎢᏤ ᎢᏳᏍᏗ ᎠᏟᎢᎵᏒ", "WART": "ᏭᏕᎵᎬ ᏗᏜ ᎠᏥᏂᏘᏂᎠ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "TMST": "ᏛᎵᎩᎺᏂᏍᏔᏂ ᎪᎩ ᎠᏟᎢᎵᏒ", "HEPM": "ᎤᏓᏅᏘ ᏈᏰ ᎠᎴ ᎻᏇᎶᏂ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "CLT": "ᏥᎵ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AST": "ᏗᎧᎸᎬ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "MST": "MST", "WAT": "ᏭᏕᎵᎬ ᎬᎿᎨᏍᏛ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AKDT": "ᎠᎳᏍᎦ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "ARST": "ᎠᏥᏂᏘᏂᎠ ᎪᎩ ᎠᏟᎢᎵᏒ", "COST": "ᎪᎸᎻᏈᎢᎠ ᎪᎩ ᎠᏟᎢᎵᏒ", "GFT": "ᎠᏂᎦᎸ ᏈᏯᎾ ᎠᏟᎢᎵᏒ", "HAST": "ᎭᏩᏱ-ᎠᎵᏳᏏᎠᏂ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "ACWST": "ᎠᏰᏟ ᎡᎳᏗᏜ ᏭᏕᎵᎬ ᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "VET": "ᏪᏁᏑᏪᎳ ᎠᏟᎢᎵᏒ", "MEZ": "ᎠᏰᏟ ᏳᎳᏈ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "ART": "ᎠᏥᏂᏘᏂᎠ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HNPM": "ᎤᏓᏅᏘ ᏈᏰ ᎠᎴ ᎻᏇᎶᏂ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HKT": "ᎰᏂᎩ ᎪᏂᎩ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AKST": "ᎠᎳᏍᎦ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "∅∅∅": "ᎠᏐᎴᏏ ᎪᎩ ᎠᏟᎢᎵᏒ", "WIB": "ᏭᏕᎵᎬ ᏗᏜ ᎢᏂᏙᏂᏍᏯ ᎠᏟᎢᎵᏒ", "ECT": "ᎡᏆᏙᎵ ᎠᏟᎢᎵᏒ", "ACWDT": "ᎠᏰᏟ ᎡᎳᏗᏜ ᏭᏕᎵᎬ ᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "CAT": "ᎠᏰᏟ ᎬᎿᎨᏍᏛ ᎠᏟᎢᎵᏒ", "MDT": "MDT", "HENOMX": "ᏧᏴᏢ ᏭᏕᎵᎬ ᎠᏂᏍᏆᏂ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "UYT": "ᏳᎷᏇ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ"}, + } +} + +// Locale returns the current translators string locale +func (chr *chr) Locale() string { + return chr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'chr' +func (chr *chr) PluralsCardinal() []locales.PluralRule { + return chr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'chr' +func (chr *chr) PluralsOrdinal() []locales.PluralRule { + return chr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'chr' +func (chr *chr) PluralsRange() []locales.PluralRule { + return chr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'chr' +func (chr *chr) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'chr' +func (chr *chr) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'chr' +func (chr *chr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (chr *chr) MonthAbbreviated(month time.Month) string { + return chr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (chr *chr) MonthsAbbreviated() []string { + return chr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (chr *chr) MonthNarrow(month time.Month) string { + return chr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (chr *chr) MonthsNarrow() []string { + return chr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (chr *chr) MonthWide(month time.Month) string { + return chr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (chr *chr) MonthsWide() []string { + return chr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (chr *chr) WeekdayAbbreviated(weekday time.Weekday) string { + return chr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (chr *chr) WeekdaysAbbreviated() []string { + return chr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (chr *chr) WeekdayNarrow(weekday time.Weekday) string { + return chr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (chr *chr) WeekdaysNarrow() []string { + return chr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (chr *chr) WeekdayShort(weekday time.Weekday) string { + return chr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (chr *chr) WeekdaysShort() []string { + return chr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (chr *chr) WeekdayWide(weekday time.Weekday) string { + return chr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (chr *chr) WeekdaysWide() []string { + return chr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'chr' and handles both Whole and Real numbers based on 'v' +func (chr *chr) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, chr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, chr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, chr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'chr' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (chr *chr) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, chr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, chr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, chr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'chr' +func (chr *chr) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := chr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, chr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, chr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, chr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, chr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'chr' +// in accounting notation. +func (chr *chr) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := chr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, chr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, chr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, chr.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, chr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, chr.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'chr' +func (chr *chr) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'chr' +func (chr *chr) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, chr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'chr' +func (chr *chr) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, chr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'chr' +func (chr *chr) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, chr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, chr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'chr' +func (chr *chr) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, chr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, chr.periodsAbbreviated[0]...) + } else { + b = append(b, chr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'chr' +func (chr *chr) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, chr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, chr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, chr.periodsAbbreviated[0]...) + } else { + b = append(b, chr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'chr' +func (chr *chr) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, chr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, chr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, chr.periodsAbbreviated[0]...) + } else { + b = append(b, chr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'chr' +func (chr *chr) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, chr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, chr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, chr.periodsAbbreviated[0]...) + } else { + b = append(b, chr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := chr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/chr/chr_test.go b/vendor/github.com/go-playground/locales/chr/chr_test.go new file mode 100644 index 0000000000..4c960a42a5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/chr/chr_test.go @@ -0,0 +1,1120 @@ +package chr + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "chr" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/chr_US/chr_US.go b/vendor/github.com/go-playground/locales/chr_US/chr_US.go new file mode 100644 index 0000000000..3dfcdfad62 --- /dev/null +++ b/vendor/github.com/go-playground/locales/chr_US/chr_US.go @@ -0,0 +1,621 @@ +package chr_US + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type chr_US struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'chr_US' locale +func New() locales.Translator { + return &chr_US{ + locale: "chr_US", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ᎤᏃ", "ᎧᎦ", "ᎠᏅ", "ᎧᏬ", "ᎠᏂ", "ᏕᎭ", "ᎫᏰ", "ᎦᎶ", "ᏚᎵ", "ᏚᏂ", "ᏅᏓ", "ᎥᏍ"}, + monthsNarrow: []string{"", "Ꭴ", "Ꭷ", "Ꭰ", "Ꭷ", "Ꭰ", "Ꮥ", "Ꭻ", "Ꭶ", "Ꮪ", "Ꮪ", "Ꮕ", "Ꭵ"}, + monthsWide: []string{"", "ᎤᏃᎸᏔᏅ", "ᎧᎦᎵ", "ᎠᏅᏱ", "ᎧᏬᏂ", "ᎠᏂᏍᎬᏘ", "ᏕᎭᎷᏱ", "ᎫᏰᏉᏂ", "ᎦᎶᏂ", "ᏚᎵᏍᏗ", "ᏚᏂᏅᏗ", "ᏅᏓᏕᏆ", "ᎥᏍᎩᏱ"}, + daysAbbreviated: []string{"ᏆᏍᎬ", "ᏉᏅᎯ", "ᏔᎵᏁ", "ᏦᎢᏁ", "ᏅᎩᏁ", "ᏧᎾᎩ", "ᏈᏕᎾ"}, + daysNarrow: []string{"Ꮖ", "Ꮙ", "Ꮤ", "Ꮶ", "Ꮕ", "Ꮷ", "Ꭴ"}, + daysShort: []string{"ᏍᎬ", "ᏅᎯ", "ᏔᎵ", "ᏦᎢ", "ᏅᎩ", "ᏧᎾ", "ᏕᎾ"}, + daysWide: []string{"ᎤᎾᏙᏓᏆᏍᎬ", "ᎤᎾᏙᏓᏉᏅᎯ", "ᏔᎵᏁᎢᎦ", "ᏦᎢᏁᎢᎦ", "ᏅᎩᏁᎢᎦ", "ᏧᎾᎩᎶᏍᏗ", "ᎤᎾᏙᏓᏈᏕᎾ"}, + periodsAbbreviated: []string{"ᏌᎾᎴ", "ᏒᎯᏱᎢᏗᏢ"}, + periodsNarrow: []string{"Ꮜ", "Ꮢ"}, + periodsWide: []string{"ᏌᎾᎴ", "ᏒᎯᏱᎢᏗᏢ"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ᏧᏓᎷᎸ ᎤᎷᎯᏍᏗ ᎦᎶᏁᏛ", "ᎠᏃ ᏙᎻᏂ"}, + timezones: map[string]string{"MDT": "ᎣᏓᎸ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "HNCU": "ᎫᏆ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "OESZ": "ᏗᎧᎸᎬ ᏗᏜ ᏳᎳᏈ ᎪᎩ ᎠᏟᎢᎵᏒ", "AKST": "ᎠᎳᏍᎦ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "ChST": "ᏣᎼᎶ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "SAST": "ᏧᎦᎾᏮ ᎬᎿᎨᏍᏛ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "ACWDT": "ᎠᏰᏟ ᎡᎳᏗᏜ ᏭᏕᎵᎬ ᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "JST": "ᏣᏩᏂᏏ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HAT": "ᎢᏤᎤᏂᏩᏛᏓᎦᏙᎯ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "SGT": "ᏏᏂᎦᏉᎵ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HAST": "ᎭᏩᏱ-ᎠᎵᏳᏏᎠᏂ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "GMT": "ᎢᏤ ᎢᏳᏍᏗ ᎠᏟᎢᎵᏒ", "CLT": "ᏥᎵ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "CLST": "ᏥᎵ ᎪᎩ ᎠᏟᎢᎵᏒ", "ART": "ᎠᏥᏂᏘᏂᎠ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "ARST": "ᎠᏥᏂᏘᏂᎠ ᎪᎩ ᎠᏟᎢᎵᏒ", "BT": "ᏊᏔᏂ ᎠᏟᎢᎵᏒ", "VET": "ᏪᏁᏑᏪᎳ ᎠᏟᎢᎵᏒ", "HEPMX": "ᎠᏂᏍᏆᏂ ᏭᏕᎵᎬ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "CST": "ᎠᏰᏟ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "ACST": "ᎠᏰᏟ ᎡᎳᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "COST": "ᎪᎸᎻᏈᎢᎠ ᎪᎩ ᎠᏟᎢᎵᏒ", "LHST": "ᎤᎬᏫᏳᎯ ᎭᏫ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HADT": "ᎭᏩᏱ-ᎠᎵᏳᏏᎠᏂ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "IST": "ᎢᏂᏗᎢᎠ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "NZDT": "ᎢᏤ ᏏᎢᎴᏂᏗ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "WAST": "ᏭᏕᎵᎬ ᎬᎿᎨᏍᏛ ᎪᎩ ᎠᏟᎢᎵᏒ", "HKST": "ᎰᏂᎩ ᎪᏂᎩ ᎪᎩ ᎠᏟᎢᎵᏒ", "PST": "ᏭᏕᎵᎬ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "MST": "ᎣᏓᎸ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "CHAST": "ᏣᏝᎻ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "WESZ": "ᏭᏕᎵᎬ ᏗᏜ ᏳᎳᏈ ᎪᎩ ᎠᏟᎢᎵᏒ", "HEEG": "ᏗᎧᎸᎬ ᎢᏤᏍᏛᏱ ᎪᎩ ᎠᏟᎢᎵᏒ", "ADT": "ᏗᎧᎸᎬ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "EST": "ᏗᎧᎸᎬ ᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "MEZ": "ᎠᏰᏟ ᏳᎳᏈ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "GYT": "ᎦᏯᎾ ᎠᏟᎢᎵᏒ", "CDT": "ᎠᏰᏟ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "ACWST": "ᎠᏰᏟ ᎡᎳᏗᏜ ᏭᏕᎵᎬ ᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HNOG": "ᏭᏕᎵᎬ ᎢᏤᏍᏛᏱ ᎠᏟᎶᏍᏗ ᎠᎵᎢᎵᏒ", "HENOMX": "ᏧᏴᏢ ᏭᏕᎵᎬ ᎠᏂᏍᏆᏂ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "UYT": "ᏳᎷᏇ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AEDT": "ᎡᎳᏗᏜ ᏗᎧᎸᎬ ᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "MESZ": "ᎠᏰᏟ ᏳᎳᏈ ᎪᎩ ᎠᏟᎢᎵᏒ", "JDT": "ᏣᏩᏂᏏ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "MYT": "ᎹᎴᏏᎢᎠ ᎠᏟᎢᎵᏒ", "HKT": "ᎰᏂᎩ ᎪᏂᎩ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AEST": "ᎡᎳᏗᏜ ᏗᎧᎸᎬ ᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "NZST": "ᎢᏤ ᏏᎢᎴᏂᏗ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AST": "ᏗᎧᎸᎬ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "TMST": "ᏛᎵᎩᎺᏂᏍᏔᏂ ᎪᎩ ᎠᏟᎢᎵᏒ", "PDT": "ᏭᏕᎵᎬ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "WIB": "ᏭᏕᎵᎬ ᏗᏜ ᎢᏂᏙᏂᏍᏯ ᎠᏟᎢᎵᏒ", "AWDT": "ᎡᎳᏗᏜ ᏭᏕᎵᎬ ᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "ECT": "ᎡᏆᏙᎵ ᎠᏟᎢᎵᏒ", "WART": "ᏭᏕᎵᎬ ᏗᏜ ᎠᏥᏂᏘᏂᎠ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "WARST": "ᏭᏕᎵᎬ ᏗᏜ ᎠᏥᏂᏘᏂᎠ ᎪᎩ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "COT": "ᎪᎸᎻᏈᎢᎠ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "UYST": "ᏳᎷᏇ ᎪᎩ ᎠᏟᎢᎵᏒ", "HNEG": "ᏗᎧᎸᎬ ᎢᏤᏍᏛᏱ ᎠᏟᎶᏍᏗ ᎠᎵᎢᎵᏒ", "∅∅∅": "∅∅∅", "HNPMX": "ᎠᏂᏍᏆᏂ ᏭᏕᎵᎬ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AWST": "ᎡᎳᏗᏜ ᏭᏕᎵᎬ ᏗᏜ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "CHADT": "ᏣᏝᎻ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "OEZ": "ᏗᎧᎸᎬ ᏗᏜ ᏳᎳᏈ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HEOG": "ᏭᏕᎵᎬ ᎢᏤᏍᏛᏱ ᎪᎩ ᎠᏟᎢᎵᏒ", "HNT": "ᎢᏤᎤᏂᏩᏛᏓᎦᏙᎯ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "HNPM": "ᎤᏓᏅᏘ ᏈᏰ ᎠᎴ ᎻᏇᎶᏂ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "LHDT": "ᎤᎬᏫᏳᎯ ᎭᏫ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "EAT": "ᏗᎧᎸᎬ ᎬᎿᎨᏍᏛ ᎠᏟᎢᎵᏒ", "BOT": "ᏉᎵᏫᎠ ᎠᏟᎢᎵᏒ", "CAT": "ᎠᏰᏟ ᎬᎿᎨᏍᏛ ᎠᏟᎢᎵᏒ", "WEZ": "ᏭᏕᎵᎬ ᏗᏜ ᏳᎳᏈ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "TMT": "ᏛᎵᎩᎺᏂᏍᏔᏂ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "AKDT": "ᎠᎳᏍᎦ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "EDT": "ᏗᎧᎸᎬ ᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "ACDT": "ᎠᏰᏟ ᎡᎳᏗᏜ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "WAT": "ᏭᏕᎵᎬ ᎬᎿᎨᏍᏛ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "SRT": "ᏒᎵᎾᎻ ᎠᏟᎢᎵᏒ", "HNNOMX": "ᏧᏴᏢ ᏭᏕᎵᎬ ᎠᏂᏍᏆᏂ ᎠᏟᎶᏍᏗ ᎠᏟᎢᎵᏒ", "WITA": "ᎠᏰᏟ ᎢᏂᏙᏂᏍᏯ ᎠᏟᎢᎵᏒ", "HEPM": "ᎤᏓᏅᏘ ᏈᏰ ᎠᎴ ᎻᏇᎶᏂ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏒᎩ", "HECU": "ᎫᏆ ᎪᎯ ᎢᎦ ᎠᏟᎢᎵᏍᏒᎩ", "WIT": "ᏗᎧᎸᎬ ᏗᏜ ᎢᏂᏙᏂᏍᏯ ᎠᏟᎢᎵᏒ", "GFT": "ᎠᏂᎦᎸ ᏈᏯᎾ ᎠᏟᎢᎵᏒ"}, + } +} + +// Locale returns the current translators string locale +func (chr *chr_US) Locale() string { + return chr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'chr_US' +func (chr *chr_US) PluralsCardinal() []locales.PluralRule { + return chr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'chr_US' +func (chr *chr_US) PluralsOrdinal() []locales.PluralRule { + return chr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'chr_US' +func (chr *chr_US) PluralsRange() []locales.PluralRule { + return chr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'chr_US' +func (chr *chr_US) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'chr_US' +func (chr *chr_US) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'chr_US' +func (chr *chr_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (chr *chr_US) MonthAbbreviated(month time.Month) string { + return chr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (chr *chr_US) MonthsAbbreviated() []string { + return chr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (chr *chr_US) MonthNarrow(month time.Month) string { + return chr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (chr *chr_US) MonthsNarrow() []string { + return chr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (chr *chr_US) MonthWide(month time.Month) string { + return chr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (chr *chr_US) MonthsWide() []string { + return chr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (chr *chr_US) WeekdayAbbreviated(weekday time.Weekday) string { + return chr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (chr *chr_US) WeekdaysAbbreviated() []string { + return chr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (chr *chr_US) WeekdayNarrow(weekday time.Weekday) string { + return chr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (chr *chr_US) WeekdaysNarrow() []string { + return chr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (chr *chr_US) WeekdayShort(weekday time.Weekday) string { + return chr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (chr *chr_US) WeekdaysShort() []string { + return chr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (chr *chr_US) WeekdayWide(weekday time.Weekday) string { + return chr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (chr *chr_US) WeekdaysWide() []string { + return chr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'chr_US' and handles both Whole and Real numbers based on 'v' +func (chr *chr_US) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, chr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, chr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, chr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'chr_US' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (chr *chr_US) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, chr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, chr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, chr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'chr_US' +func (chr *chr_US) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := chr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, chr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, chr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, chr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, chr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'chr_US' +// in accounting notation. +func (chr *chr_US) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := chr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, chr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, chr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, chr.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, chr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, chr.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'chr_US' +func (chr *chr_US) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'chr_US' +func (chr *chr_US) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, chr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'chr_US' +func (chr *chr_US) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, chr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'chr_US' +func (chr *chr_US) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, chr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, chr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'chr_US' +func (chr *chr_US) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, chr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, chr.periodsAbbreviated[0]...) + } else { + b = append(b, chr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'chr_US' +func (chr *chr_US) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, chr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, chr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, chr.periodsAbbreviated[0]...) + } else { + b = append(b, chr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'chr_US' +func (chr *chr_US) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, chr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, chr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, chr.periodsAbbreviated[0]...) + } else { + b = append(b, chr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'chr_US' +func (chr *chr_US) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, chr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, chr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, chr.periodsAbbreviated[0]...) + } else { + b = append(b, chr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := chr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/chr_US/chr_US_test.go b/vendor/github.com/go-playground/locales/chr_US/chr_US_test.go new file mode 100644 index 0000000000..348f842c86 --- /dev/null +++ b/vendor/github.com/go-playground/locales/chr_US/chr_US_test.go @@ -0,0 +1,1120 @@ +package chr_US + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "chr_US" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ckb/ckb.go b/vendor/github.com/go-playground/locales/ckb/ckb.go new file mode 100644 index 0000000000..87925cc369 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ckb/ckb.go @@ -0,0 +1,644 @@ +package ckb + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ckb struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ckb' locale +func New() locales.Translator { + return &ckb{ + locale: "ckb", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: "٫", + group: "٬", + percent: "٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "کانوونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمووز", "ئاب", "ئەیلوول", "تشرینی یەکەم", "تشرینی دووەم", "کانونی یەکەم"}, + monthsNarrow: []string{"", "ک", "ش", "ئ", "ن", "ئ", "ح", "ت", "ئ", "ئ", "ت", "ت", "ک"}, + monthsWide: []string{"", "کانوونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمووز", "ئاب", "ئەیلوول", "تشرینی یەکەم", "تشرینی دووەم", "کانونی یەکەم"}, + daysAbbreviated: []string{"یەکشەممە", "دووشەممە", "سێشەممە", "چوارشەممە", "پێنجشەممە", "ھەینی", "شەممە"}, + daysNarrow: []string{"ی", "د", "س", "چ", "پ", "ھ", "ش"}, + daysShort: []string{"١ش", "٢ش", "٣ش", "٤ش", "٥ش", "ھ", "ش"}, + daysWide: []string{"یەکشەممە", "دووشەممە", "سێشەممە", "چوارشەممە", "پێنجشەممە", "ھەینی", "شەممە"}, + periodsAbbreviated: []string{"ب.ن", "د.ن"}, + periodsNarrow: []string{"ب.ن", "د.ن"}, + periodsWide: []string{"ب.ن", "د.ن"}, + erasAbbreviated: []string{"پێش زایین", "زایینی"}, + erasNarrow: []string{"پ.ن", "ز"}, + erasWide: []string{"پێش زایین", "زایینی"}, + timezones: map[string]string{"HKST": "HKST", "COT": "COT", "HAST": "HAST", "JST": "JST", "WESZ": "WESZ", "MDT": "MDT", "JDT": "JDT", "OESZ": "OESZ", "HAT": "HAT", "HEPM": "HEPM", "PST": "PST", "PDT": "PDT", "NZDT": "NZDT", "VET": "VET", "LHDT": "LHDT", "AST": "AST", "GMT": "GMT", "AEDT": "AEDT", "CLST": "CLST", "ART": "ART", "ARST": "ARST", "AKST": "AKST", "ECT": "ECT", "NZST": "NZST", "MESZ": "MESZ", "CLT": "CLT", "LHST": "LHST", "HNCU": "HNCU", "AEST": "AEST", "HNPMX": "HNPMX", "CDT": "CDT", "WEZ": "WEZ", "EST": "EST", "HENOMX": "HENOMX", "AKDT": "AKDT", "∅∅∅": "∅∅∅", "HEOG": "HEOG", "HKT": "HKT", "COST": "COST", "ACWDT": "ACWDT", "TMT": "TMT", "HNNOMX": "HNNOMX", "SRT": "SRT", "ACDT": "ACDT", "HNT": "HNT", "HNEG": "HNEG", "HEEG": "HEEG", "AWDT": "AWDT", "CHAST": "CHAST", "CAT": "CAT", "OEZ": "OEZ", "SGT": "SGT", "BOT": "BOT", "BT": "BT", "EAT": "EAT", "MYT": "MYT", "MST": "MST", "CST": "CST", "ACWST": "ACWST", "ACST": "ACST", "WITA": "WITA", "ChST": "ChST", "HECU": "HECU", "HNOG": "HNOG", "ADT": "ADT", "UYT": "UYT", "SAST": "SAST", "AWST": "AWST", "IST": "IST", "WARST": "WARST", "HADT": "HADT", "MEZ": "MEZ", "WART": "WART", "UYST": "UYST", "WIT": "WIT", "TMST": "TMST", "WAST": "WAST", "GYT": "GYT", "WIB": "WIB", "HNPM": "HNPM", "HEPMX": "HEPMX", "CHADT": "CHADT", "WAT": "WAT", "EDT": "EDT", "GFT": "GFT"}, + } +} + +// Locale returns the current translators string locale +func (ckb *ckb) Locale() string { + return ckb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ckb' +func (ckb *ckb) PluralsCardinal() []locales.PluralRule { + return ckb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ckb' +func (ckb *ckb) PluralsOrdinal() []locales.PluralRule { + return ckb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ckb' +func (ckb *ckb) PluralsRange() []locales.PluralRule { + return ckb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ckb' +func (ckb *ckb) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ckb' +func (ckb *ckb) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ckb' +func (ckb *ckb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ckb *ckb) MonthAbbreviated(month time.Month) string { + return ckb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ckb *ckb) MonthsAbbreviated() []string { + return ckb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ckb *ckb) MonthNarrow(month time.Month) string { + return ckb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ckb *ckb) MonthsNarrow() []string { + return ckb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ckb *ckb) MonthWide(month time.Month) string { + return ckb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ckb *ckb) MonthsWide() []string { + return ckb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ckb *ckb) WeekdayAbbreviated(weekday time.Weekday) string { + return ckb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ckb *ckb) WeekdaysAbbreviated() []string { + return ckb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ckb *ckb) WeekdayNarrow(weekday time.Weekday) string { + return ckb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ckb *ckb) WeekdaysNarrow() []string { + return ckb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ckb *ckb) WeekdayShort(weekday time.Weekday) string { + return ckb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ckb *ckb) WeekdaysShort() []string { + return ckb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ckb *ckb) WeekdayWide(weekday time.Weekday) string { + return ckb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ckb *ckb) WeekdaysWide() []string { + return ckb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ckb' and handles both Whole and Real numbers based on 'v' +func (ckb *ckb) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ckb' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ckb *ckb) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ckb.percentSuffix...) + + b = append(b, ckb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ckb' +func (ckb *ckb) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ckb.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ckb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ckb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ckb' +// in accounting notation. +func (ckb *ckb) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ckb.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ckb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ckb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ckb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ckb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ckb' +func (ckb *ckb) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ckb' +func (ckb *ckb) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ckb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ckb' +func (ckb *ckb) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xdb, 0x8c, 0x20}...) + b = append(b, ckb.monthsWide[t.Month()]...) + b = append(b, []byte{0xdb, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ckb' +func (ckb *ckb) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ckb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ckb.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ckb' +func (ckb *ckb) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ckb.periodsAbbreviated[0]...) + } else { + b = append(b, ckb.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ckb' +func (ckb *ckb) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ckb.periodsAbbreviated[0]...) + } else { + b = append(b, ckb.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ckb' +func (ckb *ckb) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ckb.periodsAbbreviated[0]...) + } else { + b = append(b, ckb.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ckb' +func (ckb *ckb) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ckb.periodsAbbreviated[0]...) + } else { + b = append(b, ckb.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ckb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ckb/ckb_test.go b/vendor/github.com/go-playground/locales/ckb/ckb_test.go new file mode 100644 index 0000000000..f554f2ea2d --- /dev/null +++ b/vendor/github.com/go-playground/locales/ckb/ckb_test.go @@ -0,0 +1,1120 @@ +package ckb + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ckb" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ckb_IQ/ckb_IQ.go b/vendor/github.com/go-playground/locales/ckb_IQ/ckb_IQ.go new file mode 100644 index 0000000000..bc65da56e3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ckb_IQ/ckb_IQ.go @@ -0,0 +1,644 @@ +package ckb_IQ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ckb_IQ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ckb_IQ' locale +func New() locales.Translator { + return &ckb_IQ{ + locale: "ckb_IQ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: "٫", + group: "٬", + percent: "٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "کانوونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمووز", "ئاب", "ئەیلوول", "تشرینی یەکەم", "تشرینی دووەم", "کانونی یەکەم"}, + monthsNarrow: []string{"", "ک", "ش", "ئ", "ن", "ئ", "ح", "ت", "ئ", "ئ", "ت", "ت", "ک"}, + monthsWide: []string{"", "کانوونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمووز", "ئاب", "ئەیلوول", "تشرینی یەکەم", "تشرینی دووەم", "کانونی یەکەم"}, + daysAbbreviated: []string{"یەکشەممە", "دووشەممە", "سێشەممە", "چوارشەممە", "پێنجشەممە", "ھەینی", "شەممە"}, + daysNarrow: []string{"ی", "د", "س", "چ", "پ", "ھ", "ش"}, + daysShort: []string{"١ش", "٢ش", "٣ش", "٤ش", "٥ش", "ھ", "ش"}, + daysWide: []string{"یەکشەممە", "دووشەممە", "سێشەممە", "چوارشەممە", "پێنجشەممە", "ھەینی", "شەممە"}, + periodsAbbreviated: []string{"ب.ن", "د.ن"}, + periodsNarrow: []string{"ب.ن", "د.ن"}, + periodsWide: []string{"ب.ن", "د.ن"}, + erasAbbreviated: []string{"پێش زایین", "زایینی"}, + erasNarrow: []string{"پ.ن", "ز"}, + erasWide: []string{"پێش زایین", "زایینی"}, + timezones: map[string]string{"WART": "WART", "WARST": "WARST", "AEST": "AEST", "AKST": "AKST", "WEZ": "WEZ", "GMT": "GMT", "MYT": "MYT", "AEDT": "AEDT", "∅∅∅": "∅∅∅", "MEZ": "MEZ", "COT": "COT", "ChST": "ChST", "HKST": "HKST", "HAT": "HAT", "UYT": "UYT", "AWST": "AWST", "ACWST": "ACWST", "NZST": "NZST", "MDT": "MDT", "CLST": "CLST", "HNOG": "HNOG", "HNNOMX": "HNNOMX", "BT": "BT", "AWDT": "AWDT", "HAST": "HAST", "CAT": "CAT", "JDT": "JDT", "WITA": "WITA", "ACWDT": "ACWDT", "IST": "IST", "HEPMX": "HEPMX", "SRT": "SRT", "CDT": "CDT", "PDT": "PDT", "WESZ": "WESZ", "EST": "EST", "HNPM": "HNPM", "UYST": "UYST", "HNPMX": "HNPMX", "SAST": "SAST", "GYT": "GYT", "ART": "ART", "ARST": "ARST", "HECU": "HECU", "CHADT": "CHADT", "HADT": "HADT", "ECT": "ECT", "NZDT": "NZDT", "PST": "PST", "WAT": "WAT", "GFT": "GFT", "WIB": "WIB", "ACDT": "ACDT", "HEEG": "HEEG", "HNT": "HNT", "LHST": "LHST", "VET": "VET", "OESZ": "OESZ", "TMT": "TMT", "TMST": "TMST", "WIT": "WIT", "LHDT": "LHDT", "CHAST": "CHAST", "HEOG": "HEOG", "EDT": "EDT", "AKDT": "AKDT", "ADT": "ADT", "MST": "MST", "WAST": "WAST", "COST": "COST", "SGT": "SGT", "JST": "JST", "MESZ": "MESZ", "CLT": "CLT", "HNCU": "HNCU", "AST": "AST", "OEZ": "OEZ", "HKT": "HKT", "EAT": "EAT", "BOT": "BOT", "HENOMX": "HENOMX", "ACST": "ACST", "HNEG": "HNEG", "HEPM": "HEPM", "CST": "CST"}, + } +} + +// Locale returns the current translators string locale +func (ckb *ckb_IQ) Locale() string { + return ckb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ckb_IQ' +func (ckb *ckb_IQ) PluralsCardinal() []locales.PluralRule { + return ckb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ckb_IQ' +func (ckb *ckb_IQ) PluralsOrdinal() []locales.PluralRule { + return ckb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ckb_IQ' +func (ckb *ckb_IQ) PluralsRange() []locales.PluralRule { + return ckb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ckb_IQ' +func (ckb *ckb_IQ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ckb_IQ' +func (ckb *ckb_IQ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ckb_IQ' +func (ckb *ckb_IQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ckb *ckb_IQ) MonthAbbreviated(month time.Month) string { + return ckb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ckb *ckb_IQ) MonthsAbbreviated() []string { + return ckb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ckb *ckb_IQ) MonthNarrow(month time.Month) string { + return ckb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ckb *ckb_IQ) MonthsNarrow() []string { + return ckb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ckb *ckb_IQ) MonthWide(month time.Month) string { + return ckb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ckb *ckb_IQ) MonthsWide() []string { + return ckb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ckb *ckb_IQ) WeekdayAbbreviated(weekday time.Weekday) string { + return ckb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ckb *ckb_IQ) WeekdaysAbbreviated() []string { + return ckb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ckb *ckb_IQ) WeekdayNarrow(weekday time.Weekday) string { + return ckb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ckb *ckb_IQ) WeekdaysNarrow() []string { + return ckb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ckb *ckb_IQ) WeekdayShort(weekday time.Weekday) string { + return ckb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ckb *ckb_IQ) WeekdaysShort() []string { + return ckb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ckb *ckb_IQ) WeekdayWide(weekday time.Weekday) string { + return ckb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ckb *ckb_IQ) WeekdaysWide() []string { + return ckb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ckb_IQ' and handles both Whole and Real numbers based on 'v' +func (ckb *ckb_IQ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ckb_IQ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ckb *ckb_IQ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ckb.percentSuffix...) + + b = append(b, ckb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ckb.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ckb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ckb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ckb_IQ' +// in accounting notation. +func (ckb *ckb_IQ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ckb.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ckb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ckb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ckb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ckb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ckb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xdb, 0x8c, 0x20}...) + b = append(b, ckb.monthsWide[t.Month()]...) + b = append(b, []byte{0xdb, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ckb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ckb.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ckb.periodsAbbreviated[0]...) + } else { + b = append(b, ckb.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ckb.periodsAbbreviated[0]...) + } else { + b = append(b, ckb.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ckb.periodsAbbreviated[0]...) + } else { + b = append(b, ckb.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ckb_IQ' +func (ckb *ckb_IQ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ckb.periodsAbbreviated[0]...) + } else { + b = append(b, ckb.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ckb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ckb_IQ/ckb_IQ_test.go b/vendor/github.com/go-playground/locales/ckb_IQ/ckb_IQ_test.go new file mode 100644 index 0000000000..51c244e5e0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ckb_IQ/ckb_IQ_test.go @@ -0,0 +1,1120 @@ +package ckb_IQ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ckb_IQ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ckb_IR/ckb_IR.go b/vendor/github.com/go-playground/locales/ckb_IR/ckb_IR.go new file mode 100644 index 0000000000..c526b6fb64 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ckb_IR/ckb_IR.go @@ -0,0 +1,606 @@ +package ckb_IR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ckb_IR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ckb_IR' locale +func New() locales.Translator { + return &ckb_IR{ + locale: "ckb_IR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: "٫", + group: "٬", + percent: "٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "کانوونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمووز", "ئاب", "ئەیلوول", "تشرینی یەکەم", "تشرینی دووەم", "کانونی یەکەم"}, + monthsNarrow: []string{"", "ک", "ش", "ئ", "ن", "ئ", "ح", "ت", "ئ", "ئ", "ت", "ت", "ک"}, + monthsWide: []string{"", "کانوونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمووز", "ئاب", "ئەیلوول", "تشرینی یەکەم", "تشرینی دووەم", "کانونی یەکەم"}, + daysAbbreviated: []string{"یەکشەممە", "دووشەممە", "سێشەممە", "چوارشەممە", "پێنجشەممە", "ھەینی", "شەممە"}, + daysNarrow: []string{"ی", "د", "س", "چ", "پ", "ھ", "ش"}, + daysShort: []string{"١ش", "٢ش", "٣ش", "٤ش", "٥ش", "ھ", "ش"}, + daysWide: []string{"یەکشەممە", "دووشەممە", "سێشەممە", "چوارشەممە", "پێنجشەممە", "ھەینی", "شەممە"}, + periodsAbbreviated: []string{"ب.ن", "د.ن"}, + periodsNarrow: []string{"ب.ن", "د.ن"}, + periodsWide: []string{"ب.ن", "د.ن"}, + erasAbbreviated: []string{"پێش زایین", "زایینی"}, + erasNarrow: []string{"پ.ن", "ز"}, + erasWide: []string{"پێش زایین", "زایینی"}, + timezones: map[string]string{"HKT": "HKT", "MST": "MST", "ART": "ART", "HNT": "HNT", "CST": "CST", "OESZ": "OESZ", "TMT": "TMT", "JDT": "JDT", "CLST": "CLST", "AST": "AST", "SAST": "SAST", "ACWDT": "ACWDT", "MEZ": "MEZ", "HEOG": "HEOG", "HEPM": "HEPM", "AWST": "AWST", "CAT": "CAT", "ACWST": "ACWST", "GMT": "GMT", "MDT": "MDT", "UYST": "UYST", "HEPMX": "HEPMX", "CDT": "CDT", "BOT": "BOT", "∅∅∅": "∅∅∅", "ADT": "ADT", "ECT": "ECT", "MYT": "MYT", "WAT": "WAT", "ARST": "ARST", "SRT": "SRT", "WIT": "WIT", "NZDT": "NZDT", "OEZ": "OEZ", "WITA": "WITA", "HNPMX": "HNPMX", "GYT": "GYT", "CHAST": "CHAST", "PDT": "PDT", "TMST": "TMST", "WAST": "WAST", "HEEG": "HEEG", "AEDT": "AEDT", "UYT": "UYT", "JST": "JST", "BT": "BT", "WART": "WART", "HNOG": "HNOG", "EST": "EST", "ACST": "ACST", "HNCU": "HNCU", "HAST": "HAST", "IST": "IST", "VET": "VET", "AEST": "AEST", "HNPM": "HNPM", "LHDT": "LHDT", "WIB": "WIB", "CLT": "CLT", "GFT": "GFT", "EAT": "EAT", "CHADT": "CHADT", "MESZ": "MESZ", "HNNOMX": "HNNOMX", "NZST": "NZST", "WEZ": "WEZ", "AKST": "AKST", "LHST": "LHST", "HECU": "HECU", "SGT": "SGT", "PST": "PST", "EDT": "EDT", "HENOMX": "HENOMX", "COT": "COT", "HAT": "HAT", "ChST": "ChST", "AWDT": "AWDT", "HADT": "HADT", "WARST": "WARST", "WESZ": "WESZ", "COST": "COST", "HNEG": "HNEG", "AKDT": "AKDT", "HKST": "HKST", "ACDT": "ACDT"}, + } +} + +// Locale returns the current translators string locale +func (ckb *ckb_IR) Locale() string { + return ckb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ckb_IR' +func (ckb *ckb_IR) PluralsCardinal() []locales.PluralRule { + return ckb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ckb_IR' +func (ckb *ckb_IR) PluralsOrdinal() []locales.PluralRule { + return ckb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ckb_IR' +func (ckb *ckb_IR) PluralsRange() []locales.PluralRule { + return ckb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ckb_IR' +func (ckb *ckb_IR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ckb_IR' +func (ckb *ckb_IR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ckb_IR' +func (ckb *ckb_IR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ckb *ckb_IR) MonthAbbreviated(month time.Month) string { + return ckb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ckb *ckb_IR) MonthsAbbreviated() []string { + return ckb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ckb *ckb_IR) MonthNarrow(month time.Month) string { + return ckb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ckb *ckb_IR) MonthsNarrow() []string { + return ckb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ckb *ckb_IR) MonthWide(month time.Month) string { + return ckb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ckb *ckb_IR) MonthsWide() []string { + return ckb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ckb *ckb_IR) WeekdayAbbreviated(weekday time.Weekday) string { + return ckb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ckb *ckb_IR) WeekdaysAbbreviated() []string { + return ckb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ckb *ckb_IR) WeekdayNarrow(weekday time.Weekday) string { + return ckb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ckb *ckb_IR) WeekdaysNarrow() []string { + return ckb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ckb *ckb_IR) WeekdayShort(weekday time.Weekday) string { + return ckb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ckb *ckb_IR) WeekdaysShort() []string { + return ckb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ckb *ckb_IR) WeekdayWide(weekday time.Weekday) string { + return ckb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ckb *ckb_IR) WeekdaysWide() []string { + return ckb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ckb_IR' and handles both Whole and Real numbers based on 'v' +func (ckb *ckb_IR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ckb_IR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ckb *ckb_IR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ckb.percentSuffix...) + + b = append(b, ckb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ckb_IR' +func (ckb *ckb_IR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ckb.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ckb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ckb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ckb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ckb_IR' +// in accounting notation. +func (ckb *ckb_IR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ckb.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ckb.decimal) - 1; j >= 0; j-- { + b = append(b, ckb.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ckb.group) - 1; j >= 0; j-- { + b = append(b, ckb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ckb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ckb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ckb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ckb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ckb_IR' +func (ckb *ckb_IR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ckb_IR' +func (ckb *ckb_IR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ckb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ckb_IR' +func (ckb *ckb_IR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xdb, 0x8c, 0x20}...) + b = append(b, ckb.monthsWide[t.Month()]...) + b = append(b, []byte{0xdb, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ckb_IR' +func (ckb *ckb_IR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ckb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ckb.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ckb_IR' +func (ckb *ckb_IR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ckb_IR' +func (ckb *ckb_IR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ckb_IR' +func (ckb *ckb_IR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ckb_IR' +func (ckb *ckb_IR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ckb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ckb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ckb_IR/ckb_IR_test.go b/vendor/github.com/go-playground/locales/ckb_IR/ckb_IR_test.go new file mode 100644 index 0000000000..0e40102796 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ckb_IR/ckb_IR_test.go @@ -0,0 +1,1120 @@ +package ckb_IR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ckb_IR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/cmd/README.md b/vendor/github.com/go-playground/locales/cmd/README.md new file mode 100644 index 0000000000..b33ff22c8e --- /dev/null +++ b/vendor/github.com/go-playground/locales/cmd/README.md @@ -0,0 +1,6 @@ +Resources can be downloaded from [http://cldr.unicode.org/index/downloads](http://cldr.unicode.org/index/downloads) + +extract them under the data folder in this directory. + +If any errors, or problems with the CLDR rules are encountered I strongly encourage contributing to the CLDR project and/or +adding the exceptions to `generate_resources.go`; any changes/fixes made directly to the generated locales will be rejected. \ No newline at end of file diff --git a/vendor/github.com/go-playground/locales/cmd/currency.tmpl b/vendor/github.com/go-playground/locales/cmd/currency.tmpl new file mode 100644 index 0000000000..80c83eeeb1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cmd/currency.tmpl @@ -0,0 +1,11 @@ +{{ define "currencies" }} +package currency + +// Type is the currency type associated with the locales currency enum +type Type int + +// locale currencies +const ( + {{ . }} +) +{{ end }} \ No newline at end of file diff --git a/vendor/github.com/go-playground/locales/cmd/data/.gitignore b/vendor/github.com/go-playground/locales/cmd/data/.gitignore new file mode 100644 index 0000000000..86d0cb2726 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cmd/data/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/vendor/github.com/go-playground/locales/cmd/generate_resources.go b/vendor/github.com/go-playground/locales/cmd/generate_resources.go new file mode 100644 index 0000000000..8d21508a3b --- /dev/null +++ b/vendor/github.com/go-playground/locales/cmd/generate_resources.go @@ -0,0 +1,2886 @@ +package main + +import ( + "fmt" + "log" + "os" + "os/exec" + "regexp" + "sort" + "strconv" + "strings" + + "github.com/go-playground/locales" + + "golang.org/x/text/unicode/cldr" + + "text/template" +) + +const ( + locDir = "../%s" + locFilename = locDir + "/%s.go" +) + +var ( + tfuncs = template.FuncMap{ + "is_multibyte": func(s string) bool { + return len([]byte(s)) > 1 + }, + "reverse_bytes": func(s string) string { + b := make([]byte, 0, 8) + + for j := len(s) - 1; j >= 0; j-- { + b = append(b, s[j]) + } + + return fmt.Sprintf("%#v", b) + }, + "byte_count": func(s ...string) string { + var count int + + for i := 0; i < len(s); i++ { + count += len([]byte(s[i])) + } + + return strconv.Itoa(count) + }, + } + prVarFuncs = map[string]string{ + "n": "n := math.Abs(num)\n", + "i": "i := int64(n)\n", + // "v": "v := ...", // inherently available as argument + "w": "w := locales.W(n, v)\n", + "f": "f := locales.F(n, v)\n", + "t": "t := locales.T(n, v)\n", + } + + translators = make(map[string]*translator) + baseTranslators = make(map[string]*translator) + globalCurrenciesMap = make(map[string]struct{}) // ["USD"] = "$" currency code, just all currencies for mapping to enum + globCurrencyIdxMap = make(map[string]int) // ["USD"] = 0 + globalCurrencies = make([]string, 0, 100) // array of currency codes index maps to enum + tmpl *template.Template + nModRegex = regexp.MustCompile("(n%[0-9]+)") + iModRegex = regexp.MustCompile("(i%[0-9]+)") + wModRegex = regexp.MustCompile("(w%[0-9]+)") + fModRegex = regexp.MustCompile("(f%[0-9]+)") + tModRegex = regexp.MustCompile("(t%[0-9]+)") + groupLenRegex = regexp.MustCompile(",([0-9#]+)\\.") + groupLenPercentRegex = regexp.MustCompile(",([0-9#]+)$") + secondaryGroupLenRegex = regexp.MustCompile(",([0-9#]+),") + requiredNumRegex = regexp.MustCompile("([0-9]+)\\.") + requiredDecimalRegex = regexp.MustCompile("\\.([0-9]+)") + + enInheritance = map[string]string{ + "en_AG": "en_001", "en_AI": "en_001", "en_AS": "en", "en_AU": "en_GB", "en_BB": "en_001", "en_BE": "en_GB", "en_BM": "en_001", "en_BS": "en_001", "en_BW": "en_001", "en_BZ": "en_001", "en_CA": "en_001", "en_CC": "en_001", "en_CK": "en_001", "en_CM": "en_001", "en_CX": "en_001", "en_DG": "en_GB", "en_DM": "en_001", "en_ER": "en_001", "en_FJ": "en_001", "en_FK": "en_GB", "en_FM": "en_001", "en_GB": "en_001", "en_GD": "en_001", "en_GG": "en_GB", "en_GH": "en_001", "en_GI": "en_GB", "en_GM": "en_001", "en_GU": "en", "en_GY": "en_001", "en_HK": "en_GB", "en_IE": "en_GB", "en_IM": "en_GB", "en_IN": "en_GB", "en_IO": "en_GB", "en_JE": "en_GB", "en_JM": "en_001", "en_KE": "en_001", "en_KI": "en_001", "en_KN": "en_001", "en_KY": "en_001", "en_LC": "en_001", "en_LR": "en_001", "en_LS": "en_001", "en_MG": "en_001", "en_MH": "en", "en_MO": "en_GB", "en_MP": "en", "en_MS": "en_001", "en_MT": "en_GB", "en_MU": "en_001", "en_MW": "en_001", "en_MY": "en_001", "en_NA": "en_001", "en_NF": "en_001", "en_NG": "en_001", "en_NR": "en_001", "en_NU": "en_001", "en_NZ": "en_GB", "en_PG": "en_001", "en_PH": "en_001", "en_PK": "en_GB", "en_PN": "en_001", "en_PR": "en", "en_PW": "en_001", "en_RW": "en_001", "en_SB": "en_001", "en_SC": "en_001", "en_SD": "en_001", "en_SG": "en_GB", "en_SH": "en_GB", "en_SL": "en_001", "en_SS": "en_001", "en_SX": "en_001", "en_SZ": "en_001", "en_TC": "en_001", "en_TK": "en_001", "en_TO": "en_001", "en_TT": "en_001", "en_TV": "en_001", "en_TZ": "en_001", "en_UG": "en_001", "en_UM": "en", "en_US": "en", "en_VC": "en_001", "en_VG": "en_GB", "en_VI": "en", "en_VU": "en_001", "en_WS": "en_001", "en_ZA": "en_001", "en_ZM": "en_001", "en_ZW": "en_001", + } +) + +type translator struct { + Locale string + BaseLocale string + // InheritedLocale string + Plurals string + CardinalFunc string + PluralsOrdinal string + OrdinalFunc string + PluralsRange string + RangeFunc string + Decimal string + Group string + Minus string + Percent string + PerMille string + TimeSeparator string + Infinity string + Currencies string + + // FmtNumber vars + FmtNumberExists bool + FmtNumberGroupLen int + FmtNumberSecondaryGroupLen int + FmtNumberMinDecimalLen int + + // FmtPercent vars + FmtPercentExists bool + FmtPercentGroupLen int + FmtPercentSecondaryGroupLen int + FmtPercentMinDecimalLen int + FmtPercentPrefix string + FmtPercentSuffix string + FmtPercentInPrefix bool + FmtPercentLeft bool + + // FmtCurrency vars + FmtCurrencyExists bool + FmtCurrencyGroupLen int + FmtCurrencySecondaryGroupLen int + FmtCurrencyMinDecimalLen int + FmtCurrencyPrefix string + FmtCurrencySuffix string + FmtCurrencyInPrefix bool + FmtCurrencyLeft bool + FmtCurrencyNegativeExists bool + FmtCurrencyNegativePrefix string + FmtCurrencyNegativeSuffix string + FmtCurrencyNegativeInPrefix bool + FmtCurrencyNegativeLeft bool + + // Date & Time + FmtCalendarExists bool + + FmtMonthsAbbreviated string + FmtMonthsNarrow string + FmtMonthsWide string + + FmtDaysAbbreviated string + FmtDaysNarrow string + FmtDaysShort string + FmtDaysWide string + + FmtPeriodsAbbreviated string + FmtPeriodsNarrow string + FmtPeriodsShort string + FmtPeriodsWide string + + FmtErasAbbreviated string + FmtErasNarrow string + FmtErasWide string + + FmtTimezones string + + // calculation only fields below this point... + DecimalNumberFormat string + PercentNumberFormat string + CurrencyNumberFormat string + NegativeCurrencyNumberFormat string + + // Dates + FmtDateFull string + FmtDateLong string + FmtDateMedium string + FmtDateShort string + + // Times + FmtTimeFull string + FmtTimeLong string + FmtTimeMedium string + FmtTimeShort string + + // timezones per locale by type + timezones map[string]*zoneAbbrev // key = type eg. America_Eastern zone Abbrev will be long form eg. Eastern Standard Time, Pacific Standard Time..... +} + +type zoneAbbrev struct { + standard string + daylight string +} + +var timezones = map[string]*zoneAbbrev{} // key = type eg. America_Eastern zone Abbrev eg. EST & EDT + +func main() { + + var err error + + // load template + tmpl, err = template.New("all").Funcs(tfuncs).ParseGlob("*.tmpl") + if err != nil { + log.Fatal(err) + } + + // load CLDR recourses + var decoder cldr.Decoder + + cldr, err := decoder.DecodePath("data/core") + if err != nil { + panic(err) + } + + preProcess(cldr) + postProcess(cldr) + + var currencies string + + for i, curr := range globalCurrencies { + + if i == 0 { + currencies = curr + " Type = iota\n" + continue + } + + currencies += curr + "\n" + } + + if err = os.MkdirAll(fmt.Sprintf(locDir, "currency"), 0777); err != nil { + log.Fatal(err) + } + + filename := fmt.Sprintf(locFilename, "currency", "currency") + + output, err := os.Create(filename) + if err != nil { + log.Fatal(err) + } + defer output.Close() + + if err := tmpl.ExecuteTemplate(output, "currencies", currencies); err != nil { + log.Fatal(err) + } + + output.Close() + + // after file written run gofmt on file to ensure best formatting + cmd := exec.Command("goimports", "-w", filename) + if err = cmd.Run(); err != nil { + log.Panic(err) + } + + cmd = exec.Command("gofmt", "-s", "-w", filename) + if err = cmd.Run(); err != nil { + log.Panic(err) + } + + var locMap string + + for _, trans := range translators { + + locMap += `"` + trans.Locale + `" : ` + trans.Locale + `.New, +` + + fmt.Println("Writing Data:", trans.Locale) + + if err = os.MkdirAll(fmt.Sprintf(locDir, trans.Locale), 0777); err != nil { + log.Fatal(err) + } + + filename = fmt.Sprintf(locFilename, trans.Locale, trans.Locale) + + output, err := os.Create(filename) + if err != nil { + log.Fatal(err) + } + defer output.Close() + + if err := tmpl.ExecuteTemplate(output, "translator", trans); err != nil { + log.Fatal(err) + } + + output.Close() + + // after file written run gofmt on file to ensure best formatting + cmd := exec.Command("goimports", "-w", filename) + if err = cmd.Run(); err != nil { + log.Panic(err) + } + + // this simplifies some syntax that I can;t find an option for in goimports, namely '-s' + cmd = exec.Command("gofmt", "-s", "-w", filename) + if err = cmd.Run(); err != nil { + log.Panic(err) + } + + filename = fmt.Sprintf(locFilename, trans.Locale, trans.Locale+"_test") + + if _, err := os.Stat(filename); err == nil { + fmt.Println("*************** test file exists, skipping:", filename) + continue + } + + output, err = os.Create(filename) + if err != nil { + log.Fatal(err) + } + defer output.Close() + + if err := tmpl.ExecuteTemplate(output, "tests", trans); err != nil { + log.Fatal(err) + } + + output.Close() + + // after file written run gofmt on file to ensure best formatting + cmd = exec.Command("goimports", "-w", filename) + if err = cmd.Run(); err != nil { + log.Panic(err) + } + + // this simplifies some syntax that I can;t find an option for in goimports, namely '-s' + cmd = exec.Command("gofmt", "-s", "-w", filename) + if err = cmd.Run(); err != nil { + log.Panic(err) + } + } +} + +func applyOverrides(trans *translator) { + + if trans.BaseLocale == "ru" { + trans.PercentNumberFormat = "#,##0%" + } +} + +func postProcess(cldr *cldr.CLDR) { + + for _, v := range timezones { + + // no DST + if len(v.daylight) == 0 { + v.daylight = v.standard + } + } + + var inherited *translator + var base *translator + var inheritedFound, baseFound bool + + for _, trans := range translators { + + fmt.Println("Post Processing:", trans.Locale) + + // cardinal plural rules + trans.CardinalFunc, trans.Plurals = parseCardinalPluralRuleFunc(cldr, trans.Locale, trans.BaseLocale) + + //ordinal plural rules + trans.OrdinalFunc, trans.PluralsOrdinal = parseOrdinalPluralRuleFunc(cldr, trans.BaseLocale) + + // range plural rules + trans.RangeFunc, trans.PluralsRange = parseRangePluralRuleFunc(cldr, trans.BaseLocale) + + // ignore base locales + if trans.BaseLocale == trans.Locale { + inheritedFound = false + baseFound = false + } else { + + inheritedFound = false + + if trans.BaseLocale == "en" { + if inherit, found := enInheritance[trans.Locale]; found { + inherited, inheritedFound = translators[inherit] + } + } + + base, baseFound = baseTranslators[trans.BaseLocale] + } + + // Numbers + + if len(trans.Decimal) == 0 { + + if inheritedFound { + trans.Decimal = inherited.Decimal + } + + if len(trans.Decimal) == 0 && baseFound { + trans.Decimal = base.Decimal + } + + if len(trans.Decimal) == 0 { + trans.Decimal = "" + } + } + + if len(trans.Group) == 0 { + + if inheritedFound { + trans.Group = inherited.Group + } + + if len(trans.Group) == 0 && baseFound { + trans.Group = base.Group + } + + if len(trans.Group) == 0 { + trans.Group = "" + } + } + + if len(trans.Minus) == 0 { + + if inheritedFound { + trans.Minus = inherited.Minus + } + + if len(trans.Minus) == 0 && baseFound { + trans.Minus = base.Minus + } + + if len(trans.Minus) == 0 { + trans.Minus = "" + } + } + + if len(trans.Percent) == 0 { + + if inheritedFound { + trans.Percent = inherited.Percent + } + + if len(trans.Percent) == 0 && baseFound { + trans.Percent = base.Percent + } + + if len(trans.Percent) == 0 { + trans.Percent = "" + } + } + + if len(trans.PerMille) == 0 { + + if inheritedFound { + trans.PerMille = inherited.PerMille + } + + if len(trans.PerMille) == 0 && baseFound { + trans.PerMille = base.PerMille + } + + if len(trans.PerMille) == 0 { + trans.PerMille = "" + } + } + + if len(trans.TimeSeparator) == 0 && inheritedFound { + trans.TimeSeparator = inherited.TimeSeparator + } + + if len(trans.TimeSeparator) == 0 && baseFound { + trans.TimeSeparator = base.TimeSeparator + } + + if len(trans.Infinity) == 0 && inheritedFound { + trans.Infinity = inherited.Infinity + } + + if len(trans.Infinity) == 0 && baseFound { + trans.Infinity = base.Infinity + } + + // Currency + + // number values + + if len(trans.DecimalNumberFormat) == 0 && inheritedFound { + trans.DecimalNumberFormat = inherited.DecimalNumberFormat + } + + if len(trans.DecimalNumberFormat) == 0 && baseFound { + trans.DecimalNumberFormat = base.DecimalNumberFormat + } + + if len(trans.PercentNumberFormat) == 0 && inheritedFound { + trans.PercentNumberFormat = inherited.PercentNumberFormat + } + + if len(trans.PercentNumberFormat) == 0 && baseFound { + trans.PercentNumberFormat = base.PercentNumberFormat + } + + if len(trans.CurrencyNumberFormat) == 0 && inheritedFound { + trans.CurrencyNumberFormat = inherited.CurrencyNumberFormat + } + + if len(trans.CurrencyNumberFormat) == 0 && baseFound { + trans.CurrencyNumberFormat = base.CurrencyNumberFormat + } + + if len(trans.NegativeCurrencyNumberFormat) == 0 && inheritedFound { + trans.NegativeCurrencyNumberFormat = inherited.NegativeCurrencyNumberFormat + } + + if len(trans.NegativeCurrencyNumberFormat) == 0 && baseFound { + trans.NegativeCurrencyNumberFormat = base.NegativeCurrencyNumberFormat + } + + // date values + + if len(trans.FmtDateFull) == 0 && inheritedFound { + trans.FmtDateFull = inherited.FmtDateFull + } + + if len(trans.FmtDateFull) == 0 && baseFound { + trans.FmtDateFull = base.FmtDateFull + } + + if len(trans.FmtDateLong) == 0 && inheritedFound { + trans.FmtDateLong = inherited.FmtDateLong + } + + if len(trans.FmtDateLong) == 0 && baseFound { + trans.FmtDateLong = base.FmtDateLong + } + + if len(trans.FmtDateMedium) == 0 && inheritedFound { + trans.FmtDateMedium = inherited.FmtDateMedium + } + + if len(trans.FmtDateMedium) == 0 && baseFound { + trans.FmtDateMedium = base.FmtDateMedium + } + + if len(trans.FmtDateShort) == 0 && inheritedFound { + trans.FmtDateShort = inherited.FmtDateShort + } + + if len(trans.FmtDateShort) == 0 && baseFound { + trans.FmtDateShort = base.FmtDateShort + } + + // time values + + if len(trans.FmtTimeFull) == 0 && inheritedFound { + trans.FmtTimeFull = inherited.FmtTimeFull + } + + if len(trans.FmtTimeFull) == 0 && baseFound { + trans.FmtTimeFull = base.FmtTimeFull + } + + if len(trans.FmtTimeLong) == 0 && inheritedFound { + trans.FmtTimeLong = inherited.FmtTimeLong + } + + if len(trans.FmtTimeLong) == 0 && baseFound { + trans.FmtTimeLong = base.FmtTimeLong + } + + if len(trans.FmtTimeMedium) == 0 && inheritedFound { + trans.FmtTimeMedium = inherited.FmtTimeMedium + } + + if len(trans.FmtTimeMedium) == 0 && baseFound { + trans.FmtTimeMedium = base.FmtTimeMedium + } + + if len(trans.FmtTimeShort) == 0 && inheritedFound { + trans.FmtTimeShort = inherited.FmtTimeShort + } + + if len(trans.FmtTimeShort) == 0 && baseFound { + trans.FmtTimeShort = base.FmtTimeShort + } + + // month values + + if len(trans.FmtMonthsAbbreviated) == 0 && inheritedFound { + trans.FmtMonthsAbbreviated = inherited.FmtMonthsAbbreviated + } + + if len(trans.FmtMonthsAbbreviated) == 0 && baseFound { + trans.FmtMonthsAbbreviated = base.FmtMonthsAbbreviated + } + + if len(trans.FmtMonthsNarrow) == 0 && inheritedFound { + trans.FmtMonthsNarrow = inherited.FmtMonthsNarrow + } + + if len(trans.FmtMonthsNarrow) == 0 && baseFound { + trans.FmtMonthsNarrow = base.FmtMonthsNarrow + } + + if len(trans.FmtMonthsWide) == 0 && inheritedFound { + trans.FmtMonthsWide = inherited.FmtMonthsWide + } + + if len(trans.FmtMonthsWide) == 0 && baseFound { + trans.FmtMonthsWide = base.FmtMonthsWide + } + + // day values + + if len(trans.FmtDaysAbbreviated) == 0 && inheritedFound { + trans.FmtDaysAbbreviated = inherited.FmtDaysAbbreviated + } + + if len(trans.FmtDaysAbbreviated) == 0 && baseFound { + trans.FmtDaysAbbreviated = base.FmtDaysAbbreviated + } + + if len(trans.FmtDaysNarrow) == 0 && inheritedFound { + trans.FmtDaysNarrow = inherited.FmtDaysNarrow + } + + if len(trans.FmtDaysNarrow) == 0 && baseFound { + trans.FmtDaysNarrow = base.FmtDaysNarrow + } + + if len(trans.FmtDaysShort) == 0 && inheritedFound { + trans.FmtDaysShort = inherited.FmtDaysShort + } + + if len(trans.FmtDaysShort) == 0 && baseFound { + trans.FmtDaysShort = base.FmtDaysShort + } + + if len(trans.FmtDaysWide) == 0 && inheritedFound { + trans.FmtDaysWide = inherited.FmtDaysWide + } + + if len(trans.FmtDaysWide) == 0 && baseFound { + trans.FmtDaysWide = base.FmtDaysWide + } + + // period values + + if len(trans.FmtPeriodsAbbreviated) == 0 && inheritedFound { + trans.FmtPeriodsAbbreviated = inherited.FmtPeriodsAbbreviated + } + + if len(trans.FmtPeriodsAbbreviated) == 0 && baseFound { + trans.FmtPeriodsAbbreviated = base.FmtPeriodsAbbreviated + } + + if len(trans.FmtPeriodsNarrow) == 0 && inheritedFound { + trans.FmtPeriodsNarrow = inherited.FmtPeriodsNarrow + } + + if len(trans.FmtPeriodsNarrow) == 0 && baseFound { + trans.FmtPeriodsNarrow = base.FmtPeriodsNarrow + } + + if len(trans.FmtPeriodsShort) == 0 && inheritedFound { + trans.FmtPeriodsShort = inherited.FmtPeriodsShort + } + + if len(trans.FmtPeriodsShort) == 0 && baseFound { + trans.FmtPeriodsShort = base.FmtPeriodsShort + } + + if len(trans.FmtPeriodsWide) == 0 && inheritedFound { + trans.FmtPeriodsWide = inherited.FmtPeriodsWide + } + + if len(trans.FmtPeriodsWide) == 0 && baseFound { + trans.FmtPeriodsWide = base.FmtPeriodsWide + } + + // era values + + if len(trans.FmtErasAbbreviated) == 0 && inheritedFound { + trans.FmtErasAbbreviated = inherited.FmtErasAbbreviated + } + + if len(trans.FmtErasAbbreviated) == 0 && baseFound { + trans.FmtErasAbbreviated = base.FmtErasAbbreviated + } + + if len(trans.FmtErasNarrow) == 0 && inheritedFound { + trans.FmtErasNarrow = inherited.FmtErasNarrow + } + + if len(trans.FmtErasNarrow) == 0 && baseFound { + trans.FmtErasNarrow = base.FmtErasNarrow + } + + if len(trans.FmtErasWide) == 0 && inheritedFound { + trans.FmtErasWide = inherited.FmtErasWide + } + + if len(trans.FmtErasWide) == 0 && baseFound { + trans.FmtErasWide = base.FmtErasWide + } + + ldml := cldr.RawLDML(trans.Locale) + + currencies := make([]string, len(globalCurrencies), len(globalCurrencies)) + + var kval string + + for k, v := range globCurrencyIdxMap { + + kval = k + // if kval[:len(kval)-1] != " " { + // kval += " " + // } + + currencies[v] = kval + } + + // some just have no data... + if ldml.Numbers != nil { + + if ldml.Numbers.Currencies != nil { + for _, currency := range ldml.Numbers.Currencies.Currency { + + if len(currency.Symbol) == 0 { + continue + } + + if len(currency.Symbol[0].Data()) == 0 { + continue + } + + if len(currency.Type) == 0 { + continue + } + + currencies[globCurrencyIdxMap[currency.Type]] = currency.Symbol[0].Data() + } + } + } + + trans.Currencies = fmt.Sprintf("%#v", currencies) + + // timezones + + if (trans.timezones == nil || len(trans.timezones) == 0) && inheritedFound { + trans.timezones = inherited.timezones + } + + if (trans.timezones == nil || len(trans.timezones) == 0) && baseFound { + trans.timezones = base.timezones + } + + // make sure all inherited timezones are part of sub locale timezones + if inheritedFound { + + var ok bool + + for k, v := range inherited.timezones { + + if _, ok = trans.timezones[k]; ok { + continue + } + + trans.timezones[k] = v + } + } + + // make sure all base timezones are part of sub locale timezones + if baseFound { + + var ok bool + + for k, v := range base.timezones { + + if _, ok = trans.timezones[k]; ok { + continue + } + + trans.timezones[k] = v + } + } + + applyOverrides(trans) + + parseDecimalNumberFormat(trans) + parsePercentNumberFormat(trans) + parseCurrencyNumberFormat(trans) + } + + for _, trans := range translators { + + fmt.Println("Final Processing:", trans.Locale) + + // if it's still nill..... + if trans.timezones == nil { + trans.timezones = make(map[string]*zoneAbbrev) + } + + tz := make(map[string]string) // key = abbrev locale eg. EST, EDT, MST, PST... value = long locale eg. Eastern Standard Time, Pacific Time..... + + for k, v := range timezones { + + ttz, ok := trans.timezones[k] + if !ok { + ttz = v + trans.timezones[k] = v + } + + tz[v.standard] = ttz.standard + tz[v.daylight] = ttz.daylight + } + + trans.FmtTimezones = fmt.Sprintf("%#v", tz) + + if len(trans.TimeSeparator) == 0 { + trans.TimeSeparator = ":" + } + + trans.FmtDateShort, trans.FmtDateMedium, trans.FmtDateLong, trans.FmtDateFull = parseDateFormats(trans, trans.FmtDateShort, trans.FmtDateMedium, trans.FmtDateLong, trans.FmtDateFull) + trans.FmtTimeShort, trans.FmtTimeMedium, trans.FmtTimeLong, trans.FmtTimeFull = parseDateFormats(trans, trans.FmtTimeShort, trans.FmtTimeMedium, trans.FmtTimeLong, trans.FmtTimeFull) + } +} + +// preprocesses maps, array etc... just requires multiple passes no choice.... +func preProcess(cldrVar *cldr.CLDR) { + + for _, l := range cldrVar.Locales() { + + fmt.Println("Pre Processing:", l) + + split := strings.SplitN(l, "_", 2) + baseLocale := split[0] + // inheritedLocale := baseLocale + + // // one of the inherited english locales + // // http://cldr.unicode.org/development/development-process/design-proposals/english-inheritance + // if l == "en_001" || l == "en_GB" { + // inheritedLocale = l + // } + + trans := &translator{ + Locale: l, + BaseLocale: baseLocale, + // InheritedLocale: inheritedLocale, + } + + // if is a base locale + if len(split) == 1 { + baseTranslators[baseLocale] = trans + } + + // baseTranslators[l] = trans + // baseTranslators[baseLocale] = trans // allowing for unofficial fallback if none exists + translators[l] = trans + + // get number, currency and datetime symbols + + // number values + ldml := cldrVar.RawLDML(l) + + // some just have no data... + if ldml.Numbers != nil { + + if len(ldml.Numbers.Symbols) > 0 { + + symbol := ldml.Numbers.Symbols[0] + + // Try to get the default numbering system instead of the first one + systems := ldml.Numbers.DefaultNumberingSystem + // There shouldn't really be more than one DefaultNumberingSystem + if len(systems) > 0 { + if dns := systems[0].Data(); dns != "" { + for k := range ldml.Numbers.Symbols { + if ldml.Numbers.Symbols[k].NumberSystem == dns { + symbol = ldml.Numbers.Symbols[k] + break + } + } + } + } + + if len(symbol.Decimal) > 0 { + trans.Decimal = symbol.Decimal[0].Data() + } + if len(symbol.Group) > 0 { + trans.Group = symbol.Group[0].Data() + } + if len(symbol.MinusSign) > 0 { + trans.Minus = symbol.MinusSign[0].Data() + } + if len(symbol.PercentSign) > 0 { + trans.Percent = symbol.PercentSign[0].Data() + } + if len(symbol.PerMille) > 0 { + trans.PerMille = symbol.PerMille[0].Data() + } + + if len(symbol.TimeSeparator) > 0 { + trans.TimeSeparator = symbol.TimeSeparator[0].Data() + } + + if len(symbol.Infinity) > 0 { + trans.Infinity = symbol.Infinity[0].Data() + } + } + + if ldml.Numbers.Currencies != nil { + + for _, currency := range ldml.Numbers.Currencies.Currency { + + if len(strings.TrimSpace(currency.Type)) == 0 { + continue + } + + globalCurrenciesMap[currency.Type] = struct{}{} + } + } + + if len(ldml.Numbers.DecimalFormats) > 0 && len(ldml.Numbers.DecimalFormats[0].DecimalFormatLength) > 0 { + + for _, dfl := range ldml.Numbers.DecimalFormats[0].DecimalFormatLength { + if len(dfl.Type) == 0 { + trans.DecimalNumberFormat = dfl.DecimalFormat[0].Pattern[0].Data() + break + } + } + } + + if len(ldml.Numbers.PercentFormats) > 0 && len(ldml.Numbers.PercentFormats[0].PercentFormatLength) > 0 { + + for _, dfl := range ldml.Numbers.PercentFormats[0].PercentFormatLength { + if len(dfl.Type) == 0 { + trans.PercentNumberFormat = dfl.PercentFormat[0].Pattern[0].Data() + break + } + } + } + + if len(ldml.Numbers.CurrencyFormats) > 0 && len(ldml.Numbers.CurrencyFormats[0].CurrencyFormatLength) > 0 { + + if len(ldml.Numbers.CurrencyFormats[0].CurrencyFormatLength[0].CurrencyFormat) > 1 { + + split := strings.SplitN(ldml.Numbers.CurrencyFormats[0].CurrencyFormatLength[0].CurrencyFormat[1].Pattern[0].Data(), ";", 2) + + trans.CurrencyNumberFormat = split[0] + + if len(split) > 1 && len(split[1]) > 0 { + trans.NegativeCurrencyNumberFormat = split[1] + } else { + trans.NegativeCurrencyNumberFormat = trans.CurrencyNumberFormat + } + } else { + trans.CurrencyNumberFormat = ldml.Numbers.CurrencyFormats[0].CurrencyFormatLength[0].CurrencyFormat[0].Pattern[0].Data() + trans.NegativeCurrencyNumberFormat = trans.CurrencyNumberFormat + } + } + } + + if ldml.Dates != nil { + + if ldml.Dates.TimeZoneNames != nil { + + for _, zone := range ldml.Dates.TimeZoneNames.Metazone { + + for _, short := range zone.Short { + + if len(short.Standard) > 0 { + za, ok := timezones[zone.Type] + if !ok { + za = new(zoneAbbrev) + timezones[zone.Type] = za + } + za.standard = short.Standard[0].Data() + } + + if len(short.Daylight) > 0 { + za, ok := timezones[zone.Type] + if !ok { + za = new(zoneAbbrev) + timezones[zone.Type] = za + } + za.daylight = short.Daylight[0].Data() + } + } + + for _, long := range zone.Long { + + if trans.timezones == nil { + trans.timezones = make(map[string]*zoneAbbrev) + } + + if len(long.Standard) > 0 { + za, ok := trans.timezones[zone.Type] + if !ok { + za = new(zoneAbbrev) + trans.timezones[zone.Type] = za + } + za.standard = long.Standard[0].Data() + } + + za, ok := trans.timezones[zone.Type] + if !ok { + za = new(zoneAbbrev) + trans.timezones[zone.Type] = za + } + + if len(long.Daylight) > 0 { + za.daylight = long.Daylight[0].Data() + } else { + za.daylight = za.standard + } + } + } + } + + if ldml.Dates.Calendars != nil { + + var calendar *cldr.Calendar + + for _, cal := range ldml.Dates.Calendars.Calendar { + if cal.Type == "gregorian" { + calendar = cal + } + } + + if calendar != nil { + + if calendar.DateFormats != nil { + + for _, datefmt := range calendar.DateFormats.DateFormatLength { + + switch datefmt.Type { + case "full": + trans.FmtDateFull = datefmt.DateFormat[0].Pattern[0].Data() + + case "long": + trans.FmtDateLong = datefmt.DateFormat[0].Pattern[0].Data() + + case "medium": + trans.FmtDateMedium = datefmt.DateFormat[0].Pattern[0].Data() + + case "short": + trans.FmtDateShort = datefmt.DateFormat[0].Pattern[0].Data() + } + } + } + + if calendar.TimeFormats != nil { + + for _, datefmt := range calendar.TimeFormats.TimeFormatLength { + + switch datefmt.Type { + case "full": + trans.FmtTimeFull = datefmt.TimeFormat[0].Pattern[0].Data() + case "long": + trans.FmtTimeLong = datefmt.TimeFormat[0].Pattern[0].Data() + case "medium": + trans.FmtTimeMedium = datefmt.TimeFormat[0].Pattern[0].Data() + case "short": + trans.FmtTimeShort = datefmt.TimeFormat[0].Pattern[0].Data() + } + } + } + + if calendar.Months != nil { + + // month context starts at 'format', but there is also has 'stand-alone' + // I'm making the decision to use the 'stand-alone' if, and only if, + // the value does not exist in the 'format' month context + var abbrSet, narrSet, wideSet bool + + for _, monthctx := range calendar.Months.MonthContext { + + for _, months := range monthctx.MonthWidth { + + var monthData []string + + for _, m := range months.Month { + + if len(m.Data()) == 0 { + continue + } + + switch m.Type { + case "1": + monthData = append(monthData, m.Data()) + case "2": + monthData = append(monthData, m.Data()) + case "3": + monthData = append(monthData, m.Data()) + case "4": + monthData = append(monthData, m.Data()) + case "5": + monthData = append(monthData, m.Data()) + case "6": + monthData = append(monthData, m.Data()) + case "7": + monthData = append(monthData, m.Data()) + case "8": + monthData = append(monthData, m.Data()) + case "9": + monthData = append(monthData, m.Data()) + case "10": + monthData = append(monthData, m.Data()) + case "11": + monthData = append(monthData, m.Data()) + case "12": + monthData = append(monthData, m.Data()) + } + } + + if len(monthData) > 0 { + + // making array indexes line up with month values + // so I'll have an extra empty value, it's way faster + // than a switch over all type values... + monthData = append(make([]string, 1, len(monthData)+1), monthData...) + + switch months.Type { + case "abbreviated": + if !abbrSet { + abbrSet = true + trans.FmtMonthsAbbreviated = fmt.Sprintf("%#v", monthData) + } + case "narrow": + if !narrSet { + narrSet = true + trans.FmtMonthsNarrow = fmt.Sprintf("%#v", monthData) + } + case "wide": + if !wideSet { + wideSet = true + trans.FmtMonthsWide = fmt.Sprintf("%#v", monthData) + } + } + } + } + } + } + + if calendar.Days != nil { + + // day context starts at 'format', but there is also has 'stand-alone' + // I'm making the decision to use the 'stand-alone' if, and only if, + // the value does not exist in the 'format' day context + var abbrSet, narrSet, shortSet, wideSet bool + + for _, dayctx := range calendar.Days.DayContext { + + for _, days := range dayctx.DayWidth { + + var dayData []string + + for _, d := range days.Day { + + switch d.Type { + case "sun": + dayData = append(dayData, d.Data()) + case "mon": + dayData = append(dayData, d.Data()) + case "tue": + dayData = append(dayData, d.Data()) + case "wed": + dayData = append(dayData, d.Data()) + case "thu": + dayData = append(dayData, d.Data()) + case "fri": + dayData = append(dayData, d.Data()) + case "sat": + dayData = append(dayData, d.Data()) + } + } + + if len(dayData) > 0 { + switch days.Type { + case "abbreviated": + if !abbrSet { + abbrSet = true + trans.FmtDaysAbbreviated = fmt.Sprintf("%#v", dayData) + } + case "narrow": + if !narrSet { + narrSet = true + trans.FmtDaysNarrow = fmt.Sprintf("%#v", dayData) + } + case "short": + if !shortSet { + shortSet = true + trans.FmtDaysShort = fmt.Sprintf("%#v", dayData) + } + case "wide": + if !wideSet { + wideSet = true + trans.FmtDaysWide = fmt.Sprintf("%#v", dayData) + } + } + } + } + } + } + + if calendar.DayPeriods != nil { + + // day periods context starts at 'format', but there is also has 'stand-alone' + // I'm making the decision to use the 'stand-alone' if, and only if, + // the value does not exist in the 'format' day period context + var abbrSet, narrSet, shortSet, wideSet bool + + for _, ctx := range calendar.DayPeriods.DayPeriodContext { + + for _, width := range ctx.DayPeriodWidth { + + // [0] = AM + // [0] = PM + ampm := make([]string, 2, 2) + + for _, d := range width.DayPeriod { + + if d.Type == "am" { + ampm[0] = d.Data() + continue + } + + if d.Type == "pm" { + ampm[1] = d.Data() + } + } + + switch width.Type { + case "abbreviated": + if !abbrSet { + abbrSet = true + trans.FmtPeriodsAbbreviated = fmt.Sprintf("%#v", ampm) + } + case "narrow": + if !narrSet { + narrSet = true + trans.FmtPeriodsNarrow = fmt.Sprintf("%#v", ampm) + } + case "short": + if !shortSet { + shortSet = true + trans.FmtPeriodsShort = fmt.Sprintf("%#v", ampm) + } + case "wide": + if !wideSet { + wideSet = true + trans.FmtPeriodsWide = fmt.Sprintf("%#v", ampm) + } + } + } + } + } + + if calendar.Eras != nil { + + // [0] = BC + // [0] = AD + abbrev := make([]string, 2, 2) + narr := make([]string, 2, 2) + wide := make([]string, 2, 2) + + if calendar.Eras.EraAbbr != nil { + + if len(calendar.Eras.EraAbbr.Era) == 4 { + abbrev[0] = calendar.Eras.EraAbbr.Era[0].Data() + abbrev[1] = calendar.Eras.EraAbbr.Era[2].Data() + } else if len(calendar.Eras.EraAbbr.Era) == 2 { + abbrev[0] = calendar.Eras.EraAbbr.Era[0].Data() + abbrev[1] = calendar.Eras.EraAbbr.Era[1].Data() + } + } + + if calendar.Eras.EraNarrow != nil { + + if len(calendar.Eras.EraNarrow.Era) == 4 { + narr[0] = calendar.Eras.EraNarrow.Era[0].Data() + narr[1] = calendar.Eras.EraNarrow.Era[2].Data() + } else if len(calendar.Eras.EraNarrow.Era) == 2 { + narr[0] = calendar.Eras.EraNarrow.Era[0].Data() + narr[1] = calendar.Eras.EraNarrow.Era[1].Data() + } + } + + if calendar.Eras.EraNames != nil { + + if len(calendar.Eras.EraNames.Era) == 4 { + wide[0] = calendar.Eras.EraNames.Era[0].Data() + wide[1] = calendar.Eras.EraNames.Era[2].Data() + } else if len(calendar.Eras.EraNames.Era) == 2 { + wide[0] = calendar.Eras.EraNames.Era[0].Data() + wide[1] = calendar.Eras.EraNames.Era[1].Data() + } + } + + trans.FmtErasAbbreviated = fmt.Sprintf("%#v", abbrev) + trans.FmtErasNarrow = fmt.Sprintf("%#v", narr) + trans.FmtErasWide = fmt.Sprintf("%#v", wide) + } + } + } + } + } + + for k := range globalCurrenciesMap { + globalCurrencies = append(globalCurrencies, k) + } + + sort.Strings(globalCurrencies) + + for i, loc := range globalCurrencies { + globCurrencyIdxMap[loc] = i + } +} + +func parseDateFormats(trans *translator, shortFormat, mediumFormat, longFormat, fullFormat string) (short, medium, long, full string) { + + // Short Date Parsing + + short = parseDateTimeFormat(trans.BaseLocale, shortFormat, 2) + medium = parseDateTimeFormat(trans.BaseLocale, mediumFormat, 2) + long = parseDateTimeFormat(trans.BaseLocale, longFormat, 1) + full = parseDateTimeFormat(trans.BaseLocale, fullFormat, 0) + + // End Short Data Parsing + + return +} + +func parseDateTimeFormat(baseLocale, format string, eraScore uint8) (results string) { + + // rules: + // y = four digit year + // yy = two digit year + + // var b []byte + + var inConstantText bool + var start int + + for i := 0; i < len(format); i++ { + + switch format[i] { + + // time separator + case ':': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + results += "b = append(b, " + baseLocale + ".timeSeparator...)" + case '\'': + + i++ + startI := i + + // peek to see if '' + if len(format) != i && format[i] == '\'' { + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i-1])) + "...)\n" + } else { + inConstantText = true + start = i + } + + continue + } + + // not '' so whatever comes between '' is constant + + if len(format) != i { + + // advance i to the next single quote + 1 + for ; i < len(format); i++ { + if format[i] == '\'' { + + if inConstantText { + inConstantText = false + b := []byte(format[start : startI-1]) + b = append(b, []byte(format[startI:i])...) + + results += "b = append(b, " + fmt.Sprintf("%#v", b) + "...)\n" + + } else { + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[startI:i])) + "...)\n" + } + + break + } + } + } + + // 24 hour + case 'H': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + // peek + // two digit hour required? + if len(format) != i+1 && format[i+1] == 'H' { + i++ + results += ` + if t.Hour() < 10 { + b = append(b, '0') + } + + ` + } + + results += "b = strconv.AppendInt(b, int64(t.Hour()), 10)\n" + + // hour + case 'h': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + results += ` + h := t.Hour() + + if h > 12 { + h -= 12 + } + + ` + + // peek + // two digit hour required? + if len(format) != i+1 && format[i+1] == 'h' { + i++ + results += ` + if h < 10 { + b = append(b, '0') + } + + ` + } + + results += "b = strconv.AppendInt(b, int64(h), 10)\n" + + // minute + case 'm': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + // peek + // two digit minute required? + if len(format) != i+1 && format[i+1] == 'm' { + i++ + results += ` + + if t.Minute() < 10 { + b = append(b, '0') + } + + ` + } + + results += "b = strconv.AppendInt(b, int64(t.Minute()), 10)\n" + + // second + case 's': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + // peek + // two digit minute required? + if len(format) != i+1 && format[i+1] == 's' { + i++ + results += ` + + if t.Second() < 10 { + b = append(b, '0') + } + + ` + } + + results += "b = strconv.AppendInt(b, int64(t.Second()), 10)\n" + + // day period + case 'a': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + // only used with 'h', patterns should not contains 'a' without 'h' so not checking + + // choosing to use abbreviated, didn't see any rules about which should be used with which + // date format.... + + results += ` + + if t.Hour() < 12 { + b = append(b, ` + baseLocale + `.periodsAbbreviated[0]...) + } else { + b = append(b, ` + baseLocale + `.periodsAbbreviated[1]...) + } + + ` + + // timezone + case 'z', 'v': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + // consume multiple, only handling Abbrev tz from time.Time for the moment... + + var count int + + if format[i] == 'z' { + for j := i; j < len(format); j++ { + if format[j] == 'z' { + count++ + } else { + break + } + } + } + + if format[i] == 'v' { + for j := i; j < len(format); j++ { + if format[j] == 'v' { + count++ + } else { + break + } + } + } + + i += count - 1 + + // using the timezone on the Go time object, eg. EST, EDT, MST..... + + if count < 4 { + + results += ` + + tz, _ := t.Zone() + b = append(b, tz...) + + ` + } else { + + results += ` + tz, _ := t.Zone() + + if btz, ok := ` + baseLocale + `.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + ` + } + + // day + case 'd': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + // peek + // two digit day required? + if len(format) != i+1 && format[i+1] == 'd' { + i++ + results += ` + + if t.Day() < 10 { + b = append(b, '0') + } + + ` + } + + results += "b = strconv.AppendInt(b, int64(t.Day()), 10)\n" + + // month + case 'M': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + var count int + + // count # of M's + for j := i; j < len(format); j++ { + if format[j] == 'M' { + count++ + } else { + break + } + } + + switch count { + + // Numeric form, at least 1 digit + case 1: + + results += "b = strconv.AppendInt(b, int64(t.Month()), 10)\n" + + // Number form, at least 2 digits (padding with 0) + case 2: + + results += ` + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + ` + + // Abbreviated form + case 3: + + results += "b = append(b, " + baseLocale + ".monthsAbbreviated[t.Month()]...)\n" + + // Full/Wide form + case 4: + + results += "b = append(b, " + baseLocale + ".monthsWide[t.Month()]...)\n" + + // Narrow form - only used in where context makes it clear, such as headers in a calendar. + // Should be one character wherever possible. + case 5: + + results += "b = append(b, " + baseLocale + ".monthsNarrow[t.Month()]...)\n" + } + + // skip over M's + i += count - 1 + + // year + case 'y': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + // peek + // two digit year + if len(format) != i+1 && format[i+1] == 'y' { + i++ + results += ` + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + ` + } else { + // four digit year + results += ` + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + ` + } + + // weekday + // I know I only see 'EEEE' in the xml, but just in case handled all posibilities + case 'E': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + var count int + + // count # of E's + for j := i; j < len(format); j++ { + if format[j] == 'E' { + count++ + } else { + break + } + } + + switch count { + + // Narrow + case 1: + + results += "b = append(b, " + baseLocale + ".daysNarrow[t.Weekday()]...)\n" + + // Short + case 2: + + results += "b = append(b, " + baseLocale + ".daysShort[t.Weekday()]...)\n" + + // Abbreviated + case 3: + + results += "b = append(b, " + baseLocale + ".daysAbbreviated[t.Weekday()]...)\n" + + // Full/Wide + case 4: + + results += "b = append(b, " + baseLocale + ".daysWide[t.Weekday()]...)\n" + } + + // skip over E's + i += count - 1 + + // era eg. AD, BC + case 'G': + + if inConstantText { + inConstantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:i])) + "...)\n" + } + + switch eraScore { + case 0: + results += ` + + if t.Year() < 0 { + b = append(b, ` + baseLocale + `.erasWide[0]...) + } else { + b = append(b, ` + baseLocale + `.erasWide[1]...) + } + + ` + case 1, 2: + results += ` + + if t.Year() < 0 { + b = append(b, ` + baseLocale + `.erasAbbreviated[0]...) + } else { + b = append(b, ` + baseLocale + `.erasAbbreviated[1]...) + } + + ` + } + + default: + // append all non matched text as they are constants + if !inConstantText { + inConstantText = true + start = i + } + } + } + + // if we were inConstantText when the string ended, add what's left. + if inConstantText { + // inContantText = false + results += "b = append(b, " + fmt.Sprintf("%#v", []byte(format[start:])) + "...)\n" + } + + return +} + +func parseCurrencyNumberFormat(trans *translator) { + + if len(trans.CurrencyNumberFormat) == 0 { + return + } + + trans.FmtCurrencyExists = true + negativeEqual := trans.CurrencyNumberFormat == trans.NegativeCurrencyNumberFormat + + match := groupLenRegex.FindString(trans.CurrencyNumberFormat) + if len(match) > 0 { + trans.FmtCurrencyGroupLen = len(match) - 2 + } + + match = requiredDecimalRegex.FindString(trans.CurrencyNumberFormat) + if len(match) > 0 { + trans.FmtCurrencyMinDecimalLen = len(match) - 1 + } + + match = secondaryGroupLenRegex.FindString(trans.CurrencyNumberFormat) + if len(match) > 0 { + trans.FmtCurrencySecondaryGroupLen = len(match) - 2 + } + + idx := 0 + + for idx = 0; idx < len(trans.CurrencyNumberFormat); idx++ { + if trans.CurrencyNumberFormat[idx] == '#' || trans.CurrencyNumberFormat[idx] == '0' { + trans.FmtCurrencyPrefix = trans.CurrencyNumberFormat[:idx] + break + } + } + + for idx = len(trans.CurrencyNumberFormat) - 1; idx >= 0; idx-- { + if trans.CurrencyNumberFormat[idx] == '#' || trans.CurrencyNumberFormat[idx] == '0' { + idx++ + trans.FmtCurrencySuffix = trans.CurrencyNumberFormat[idx:] + break + } + } + + for idx = 0; idx < len(trans.FmtCurrencyPrefix); idx++ { + if trans.FmtCurrencyPrefix[idx] == '¤' { + + trans.FmtCurrencyInPrefix = true + trans.FmtCurrencyPrefix = strings.Replace(trans.FmtCurrencyPrefix, string(trans.FmtCurrencyPrefix[idx]), "", 1) + + if idx == 0 { + trans.FmtCurrencyLeft = true + } else { + trans.FmtCurrencyLeft = false + } + + break + } + } + + for idx = 0; idx < len(trans.FmtCurrencySuffix); idx++ { + if trans.FmtCurrencySuffix[idx] == '¤' { + + trans.FmtCurrencyInPrefix = false + trans.FmtCurrencySuffix = strings.Replace(trans.FmtCurrencySuffix, string(trans.FmtCurrencySuffix[idx]), "", 1) + + if idx == 0 { + trans.FmtCurrencyLeft = true + } else { + trans.FmtCurrencyLeft = false + } + + break + } + } + + // if len(trans.FmtCurrencyPrefix) > 0 { + // trans.FmtCurrencyPrefix = fmt.Sprintf("%#v", []byte(trans.FmtCurrencyPrefix)) + // } + + // if len(trans.FmtCurrencySuffix) > 0 { + // trans.FmtCurrencySuffix = fmt.Sprintf("%#v", []byte(trans.FmtCurrencySuffix)) + // } + + // no need to parse again if true.... + if negativeEqual { + + trans.FmtCurrencyNegativePrefix = trans.FmtCurrencyPrefix + trans.FmtCurrencyNegativeSuffix = trans.FmtCurrencySuffix + trans.FmtCurrencyNegativeInPrefix = trans.FmtCurrencyInPrefix + trans.FmtCurrencyNegativeLeft = trans.FmtCurrencyLeft + + return + } + + trans.FmtCurrencyNegativeExists = true + + for idx = 0; idx < len(trans.NegativeCurrencyNumberFormat); idx++ { + if trans.NegativeCurrencyNumberFormat[idx] == '#' || trans.NegativeCurrencyNumberFormat[idx] == '0' { + + trans.FmtCurrencyNegativePrefix = trans.NegativeCurrencyNumberFormat[:idx] + break + } + } + + for idx = len(trans.NegativeCurrencyNumberFormat) - 1; idx >= 0; idx-- { + if trans.NegativeCurrencyNumberFormat[idx] == '#' || trans.NegativeCurrencyNumberFormat[idx] == '0' { + idx++ + trans.FmtCurrencyNegativeSuffix = trans.NegativeCurrencyNumberFormat[idx:] + break + } + } + + for idx = 0; idx < len(trans.FmtCurrencyNegativePrefix); idx++ { + if trans.FmtCurrencyNegativePrefix[idx] == '¤' { + + trans.FmtCurrencyNegativeInPrefix = true + trans.FmtCurrencyNegativePrefix = strings.Replace(trans.FmtCurrencyNegativePrefix, string(trans.FmtCurrencyNegativePrefix[idx]), "", 1) + + if idx == 0 { + trans.FmtCurrencyNegativeLeft = true + } else { + trans.FmtCurrencyNegativeLeft = false + } + + break + } + } + + for idx = 0; idx < len(trans.FmtCurrencyNegativeSuffix); idx++ { + if trans.FmtCurrencyNegativeSuffix[idx] == '¤' { + + trans.FmtCurrencyNegativeInPrefix = false + trans.FmtCurrencyNegativeSuffix = strings.Replace(trans.FmtCurrencyNegativeSuffix, string(trans.FmtCurrencyNegativeSuffix[idx]), "", 1) + + if idx == 0 { + trans.FmtCurrencyNegativeLeft = true + } else { + trans.FmtCurrencyNegativeLeft = false + } + + break + } + } + + // if len(trans.FmtCurrencyNegativePrefix) > 0 { + // trans.FmtCurrencyNegativePrefix = fmt.Sprintf("%#v", []byte(trans.FmtCurrencyNegativePrefix)) + // } + + // if len(trans.FmtCurrencyNegativeSuffix) > 0 { + // trans.FmtCurrencyNegativeSuffix = fmt.Sprintf("%#v", []byte(trans.FmtCurrencyNegativeSuffix)) + // } + + return +} + +func parsePercentNumberFormat(trans *translator) { + + if len(trans.PercentNumberFormat) == 0 { + return + } + + trans.FmtPercentExists = true + + match := groupLenPercentRegex.FindString(trans.PercentNumberFormat) + if len(match) > 0 { + trans.FmtPercentGroupLen = len(match) - 1 + } + + match = requiredDecimalRegex.FindString(trans.PercentNumberFormat) + if len(match) > 0 { + trans.FmtPercentMinDecimalLen = len(match) - 1 + } + + match = secondaryGroupLenRegex.FindString(trans.PercentNumberFormat) + if len(match) > 0 { + trans.FmtPercentSecondaryGroupLen = len(match) - 2 + } + + idx := 0 + + for idx = 0; idx < len(trans.PercentNumberFormat); idx++ { + if trans.PercentNumberFormat[idx] == '#' || trans.PercentNumberFormat[idx] == '0' { + trans.FmtPercentPrefix = trans.PercentNumberFormat[:idx] + break + } + } + + for idx = len(trans.PercentNumberFormat) - 1; idx >= 0; idx-- { + if trans.PercentNumberFormat[idx] == '#' || trans.PercentNumberFormat[idx] == '0' { + idx++ + trans.FmtPercentSuffix = trans.PercentNumberFormat[idx:] + break + } + } + + for idx = 0; idx < len(trans.FmtPercentPrefix); idx++ { + if trans.FmtPercentPrefix[idx] == '%' { + + trans.FmtPercentInPrefix = true + trans.FmtPercentPrefix = strings.Replace(trans.FmtPercentPrefix, string(trans.FmtPercentPrefix[idx]), "", 1) + + if idx == 0 { + trans.FmtPercentLeft = true + } else { + trans.FmtPercentLeft = false + } + + break + } + } + + for idx = 0; idx < len(trans.FmtPercentSuffix); idx++ { + if trans.FmtPercentSuffix[idx] == '%' { + + trans.FmtPercentInPrefix = false + trans.FmtPercentSuffix = strings.Replace(trans.FmtPercentSuffix, string(trans.FmtPercentSuffix[idx]), "", 1) + + if idx == 0 { + trans.FmtPercentLeft = true + } else { + trans.FmtPercentLeft = false + } + + break + } + } + + // if len(trans.FmtPercentPrefix) > 0 { + // trans.FmtPercentPrefix = fmt.Sprintf("%#v", []byte(trans.FmtPercentPrefix)) + // } + + // if len(trans.FmtPercentSuffix) > 0 { + // trans.FmtPercentSuffix = fmt.Sprintf("%#v", []byte(trans.FmtPercentSuffix)) + // } + + return +} + +func parseDecimalNumberFormat(trans *translator) { + + if len(trans.DecimalNumberFormat) == 0 { + return + } + + trans.FmtNumberExists = true + + formats := strings.SplitN(trans.DecimalNumberFormat, ";", 2) + + match := groupLenRegex.FindString(formats[0]) + if len(match) > 0 { + trans.FmtNumberGroupLen = len(match) - 2 + } + + match = requiredDecimalRegex.FindString(formats[0]) + if len(match) > 0 { + trans.FmtNumberMinDecimalLen = len(match) - 1 + } + + match = secondaryGroupLenRegex.FindString(formats[0]) + if len(match) > 0 { + trans.FmtNumberSecondaryGroupLen = len(match) - 2 + } + + return +} + +type sortRank struct { + Rank uint8 + Value string +} + +type ByRank []sortRank + +func (a ByRank) Len() int { return len(a) } +func (a ByRank) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByRank) Less(i, j int) bool { return a[i].Rank < a[j].Rank } + +type ByPluralRule []locales.PluralRule + +func (a ByPluralRule) Len() int { return len(a) } +func (a ByPluralRule) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByPluralRule) Less(i, j int) bool { return a[i] < a[j] } + +// TODO: refine generated code a bit, some combinations end up with same plural rule, +// could check all at once; but it works and that's step 1 complete +func parseRangePluralRuleFunc(current *cldr.CLDR, baseLocale string) (results string, plurals string) { + + var pluralRange *struct { + cldr.Common + Locales string `xml:"locales,attr"` + PluralRange []*struct { + cldr.Common + Start string `xml:"start,attr"` + End string `xml:"end,attr"` + Result string `xml:"result,attr"` + } `xml:"pluralRange"` + } + + var pluralArr []locales.PluralRule + + for _, pr := range current.Supplemental().Plurals[1].PluralRanges { + + locs := strings.Split(pr.Locales, " ") + + for _, loc := range locs { + + if loc == baseLocale { + pluralRange = pr + } + } + } + + // no range plural rules for locale + if pluralRange == nil { + plurals = "nil" + results = "return locales.PluralRuleUnknown" + return + } + + mp := make(map[string]struct{}) + + // pre-process if all the same + for _, rule := range pluralRange.PluralRange { + mp[rule.Result] = struct{}{} + } + + for k := range mp { + psI := pluralStringToInt(k) + pluralArr = append(pluralArr, psI) + } + + if len(mp) == 1 { + results += "return locales." + pluralStringToString(pluralRange.PluralRange[0].Result) + plurals = fmt.Sprintf("%#v", pluralArr) + return + } + + multiple := len(pluralRange.PluralRange) > 1 + + if multiple { + results += "start := " + baseLocale + ".CardinalPluralRule(num1, v1)\n" + results += "end := " + baseLocale + ".CardinalPluralRule(num2, v2)\n\n" + } + + first := true + + // pre parse for variables + for i, rule := range pluralRange.PluralRange { + + if i == len(pluralRange.PluralRange)-1 { + + if multiple { + results += "\n\n" + } + results += "return locales." + pluralStringToString(rule.Result) + continue + } + + if first { + results += "if" + first = false + } else { + results += "else if" + } + + results += " start == locales." + pluralStringToString(rule.Start) + " && end == locales." + pluralStringToString(rule.End) + " {\n return locales." + pluralStringToString(rule.Result) + "\n} " + + } + + if multiple { + results = "\n" + results + "\n" + } + + if len(pluralArr) == 0 { + plurals = "nil" + } else { + + ints := make([]int, len(pluralArr)) + for i := 0; i < len(pluralArr); i++ { + ints[i] = int(pluralArr[i]) + } + + sort.Ints(ints) + + for i := 0; i < len(ints); i++ { + pluralArr[i] = locales.PluralRule(ints[i]) + } + + plurals = fmt.Sprintf("%#v", pluralArr) + } + + return + +} + +// TODO: cleanup function logic perhaps write a lexer... but it's working right now, and +// I'm already farther down the rabbit hole than I'd like and so pulling the chute here. +func parseOrdinalPluralRuleFunc(current *cldr.CLDR, baseLocale string) (results string, plurals string) { + + var prOrdinal *struct { + cldr.Common + Locales string "xml:\"locales,attr\"" + PluralRule []*struct { + cldr.Common + Count string "xml:\"count,attr\"" + } "xml:\"pluralRule\"" + } + + var pluralArr []locales.PluralRule + + // idx 0 is ordinal rules + for _, pr := range current.Supplemental().Plurals[0].PluralRules { + + locs := strings.Split(pr.Locales, " ") + + for _, loc := range locs { + + if loc == baseLocale { + + prOrdinal = pr + // for _, pl := range pr.PluralRule { + // fmt.Println(pl.Count, pl.Common.Data()) + // } + } + } + } + + // no plural rules for locale + if prOrdinal == nil { + plurals = "nil" + results = "return locales.PluralRuleUnknown" + return + } + + vals := make(map[string]struct{}) + first := true + + // pre parse for variables + for _, rule := range prOrdinal.PluralRule { + + ps1 := pluralStringToString(rule.Count) + psI := pluralStringToInt(rule.Count) + pluralArr = append(pluralArr, psI) + + data := strings.Replace(strings.Replace(strings.Replace(strings.TrimSpace(strings.SplitN(rule.Common.Data(), "@", 2)[0]), " = ", " == ", -1), " or ", " || ", -1), " and ", " && ", -1) + + if len(data) == 0 { + if len(prOrdinal.PluralRule) == 1 { + + results = "return locales." + ps1 + + } else { + + results += "\n\nreturn locales." + ps1 + // results += "else {\nreturn locales." + locales.PluralStringToString(rule.Count) + ", nil\n}" + } + + continue + } + + // // All need n, so always add + // if strings.Contains(data, "n") { + // vals[prVarFuncs["n"]] = struct{}{} + // } + + if strings.Contains(data, "i") { + vals[prVarFuncs["i"]] = struct{}{} + } + + // v is inherently avaialable as an argument + // if strings.Contains(data, "v") { + // vals[prVarFuncs["v"]] = struct{}{} + // } + + if strings.Contains(data, "w") { + vals[prVarFuncs["w"]] = struct{}{} + } + + if strings.Contains(data, "f") { + vals[prVarFuncs["f"]] = struct{}{} + } + + if strings.Contains(data, "t") { + vals[prVarFuncs["t"]] = struct{}{} + } + + if first { + results += "if " + first = false + } else { + results += "else if " + } + + stmt := "" + + // real work here + // + // split by 'or' then by 'and' allowing to better + // determine bracketing for formula + + ors := strings.Split(data, "||") + + for _, or := range ors { + + stmt += "(" + + ands := strings.Split(strings.TrimSpace(or), "&&") + + for _, and := range ands { + + inArg := false + pre := "" + lft := "" + preOperator := "" + args := strings.Split(strings.TrimSpace(and), " ") + + for _, a := range args { + + if inArg { + // check to see if is a value range 2..9 + + multiRange := strings.Count(a, "..") > 1 + cargs := strings.Split(strings.TrimSpace(a), ",") + hasBracket := len(cargs) > 1 + bracketAdded := false + lastWasRange := false + + for _, carg := range cargs { + + if rng := strings.Split(carg, ".."); len(rng) > 1 { + + if multiRange { + pre += " (" + } else { + pre += " " + } + + switch preOperator { + case "==": + pre += lft + " >= " + rng[0] + " && " + lft + "<=" + rng[1] + case "!=": + pre += "(" + lft + " < " + rng[0] + " || " + lft + " > " + rng[1] + ")" + } + + if multiRange { + pre += ") || " + } else { + pre += " || " + } + + lastWasRange = true + continue + } + + if lastWasRange { + pre = strings.TrimRight(pre, " || ") + " && " + } + + lastWasRange = false + + if hasBracket && !bracketAdded { + pre += "(" + bracketAdded = true + } + + // single comma separated values + switch preOperator { + case "==": + pre += " " + lft + preOperator + carg + " || " + case "!=": + pre += " " + lft + preOperator + carg + " && " + } + + } + + pre = strings.TrimRight(pre, " || ") + pre = strings.TrimRight(pre, " && ") + pre = strings.TrimRight(pre, " || ") + + if hasBracket && bracketAdded { + pre += ")" + } + + continue + } + + if strings.Contains(a, "=") || a == ">" || a == "<" { + inArg = true + preOperator = a + continue + } + + lft += a + } + + stmt += pre + " && " + } + + stmt = strings.TrimRight(stmt, " && ") + ") || " + } + + stmt = strings.TrimRight(stmt, " || ") + + results += stmt + + results += " {\n" + + // return plural rule here + results += "return locales." + ps1 + "\n" + + results += "}" + } + + pre := "\n" + + // always needed + vals[prVarFuncs["n"]] = struct{}{} + + sorted := make([]sortRank, 0, len(vals)) + + for k := range vals { + switch k[:1] { + case "n": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["n"], + Rank: 1, + }) + case "i": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["i"], + Rank: 2, + }) + case "w": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["w"], + Rank: 3, + }) + case "f": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["f"], + Rank: 4, + }) + case "t": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["t"], + Rank: 5, + }) + } + } + + sort.Sort(ByRank(sorted)) + + for _, k := range sorted { + pre += k.Value + } + + if len(results) == 0 { + results = "return locales.PluralRuleUnknown" + } else { + + if !strings.HasPrefix(results, "return") { + + results = manyToSingleVars(results) + // pre += "\n" + results = pre + results + } + } + + if len(pluralArr) == 0 { + plurals = "nil" + } else { + plurals = fmt.Sprintf("%#v", pluralArr) + } + + return +} + +// TODO: cleanup function logic perhaps write a lexer... but it's working right now, and +// I'm already farther down the rabbit hole than I'd like and so pulling the chute here. +// +// updated to also accept actual locale as 'pt_PT' exists in cardinal rules different from 'pt' +func parseCardinalPluralRuleFunc(current *cldr.CLDR, locale, baseLocale string) (results string, plurals string) { + + var prCardinal *struct { + cldr.Common + Locales string "xml:\"locales,attr\"" + PluralRule []*struct { + cldr.Common + Count string "xml:\"count,attr\"" + } "xml:\"pluralRule\"" + } + + var pluralArr []locales.PluralRule + var inBaseLocale bool + l := locale + +FIND: + // idx 2 is cardinal rules + for _, pr := range current.Supplemental().Plurals[2].PluralRules { + + locs := strings.Split(pr.Locales, " ") + + for _, loc := range locs { + + if loc == l { + prCardinal = pr + } + } + } + + // no plural rules for locale + if prCardinal == nil { + + if !inBaseLocale { + inBaseLocale = true + l = baseLocale + goto FIND + } + + plurals = "nil" + results = "return locales.PluralRuleUnknown" + return + } + + vals := make(map[string]struct{}) + first := true + + // pre parse for variables + for _, rule := range prCardinal.PluralRule { + + ps1 := pluralStringToString(rule.Count) + psI := pluralStringToInt(rule.Count) + pluralArr = append(pluralArr, psI) + + data := strings.Replace(strings.Replace(strings.Replace(strings.TrimSpace(strings.SplitN(rule.Common.Data(), "@", 2)[0]), " = ", " == ", -1), " or ", " || ", -1), " and ", " && ", -1) + + if len(data) == 0 { + if len(prCardinal.PluralRule) == 1 { + + results = "return locales." + ps1 + + } else { + + results += "\n\nreturn locales." + ps1 + // results += "else {\nreturn locales." + locales.PluralStringToString(rule.Count) + ", nil\n}" + } + + continue + } + + // // All need n, so always add + // if strings.Contains(data, "n") { + // vals[prVarFuncs["n"]] = struct{}{} + // } + + if strings.Contains(data, "i") { + vals[prVarFuncs["i"]] = struct{}{} + } + + // v is inherently avaialable as an argument + // if strings.Contains(data, "v") { + // vals[prVarFuncs["v"]] = struct{}{} + // } + + if strings.Contains(data, "w") { + vals[prVarFuncs["w"]] = struct{}{} + } + + if strings.Contains(data, "f") { + vals[prVarFuncs["f"]] = struct{}{} + } + + if strings.Contains(data, "t") { + vals[prVarFuncs["t"]] = struct{}{} + } + + if first { + results += "if " + first = false + } else { + results += "else if " + } + + stmt := "" + + // real work here + // + // split by 'or' then by 'and' allowing to better + // determine bracketing for formula + + ors := strings.Split(data, "||") + + for _, or := range ors { + + stmt += "(" + + ands := strings.Split(strings.TrimSpace(or), "&&") + + for _, and := range ands { + + inArg := false + pre := "" + lft := "" + preOperator := "" + args := strings.Split(strings.TrimSpace(and), " ") + + for _, a := range args { + + if inArg { + // check to see if is a value range 2..9 + + multiRange := strings.Count(a, "..") > 1 + cargs := strings.Split(strings.TrimSpace(a), ",") + hasBracket := len(cargs) > 1 + bracketAdded := false + lastWasRange := false + + for _, carg := range cargs { + + if rng := strings.Split(carg, ".."); len(rng) > 1 { + + if multiRange { + pre += " (" + } else { + pre += " " + } + + switch preOperator { + case "==": + pre += lft + " >= " + rng[0] + " && " + lft + "<=" + rng[1] + case "!=": + pre += "(" + lft + " < " + rng[0] + " || " + lft + " > " + rng[1] + ")" + } + + if multiRange { + pre += ") || " + } else { + pre += " || " + } + + lastWasRange = true + continue + } + + if lastWasRange { + pre = strings.TrimRight(pre, " || ") + " && " + } + + lastWasRange = false + + if hasBracket && !bracketAdded { + pre += "(" + bracketAdded = true + } + + // single comma separated values + switch preOperator { + case "==": + pre += " " + lft + preOperator + carg + " || " + case "!=": + pre += " " + lft + preOperator + carg + " && " + } + + } + + pre = strings.TrimRight(pre, " || ") + pre = strings.TrimRight(pre, " && ") + pre = strings.TrimRight(pre, " || ") + + if hasBracket && bracketAdded { + pre += ")" + } + + continue + } + + if strings.Contains(a, "=") || a == ">" || a == "<" { + inArg = true + preOperator = a + continue + } + + lft += a + } + + stmt += pre + " && " + } + + stmt = strings.TrimRight(stmt, " && ") + ") || " + } + + stmt = strings.TrimRight(stmt, " || ") + + results += stmt + + results += " {\n" + + // return plural rule here + results += "return locales." + ps1 + "\n" + + results += "}" + } + + pre := "\n" + + // always needed + vals[prVarFuncs["n"]] = struct{}{} + + sorted := make([]sortRank, 0, len(vals)) + + for k := range vals { + switch k[:1] { + case "n": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["n"], + Rank: 1, + }) + case "i": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["i"], + Rank: 2, + }) + case "w": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["w"], + Rank: 3, + }) + case "f": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["f"], + Rank: 4, + }) + case "t": + sorted = append(sorted, sortRank{ + Value: prVarFuncs["t"], + Rank: 5, + }) + } + } + + sort.Sort(ByRank(sorted)) + + for _, k := range sorted { + pre += k.Value + } + + if len(results) == 0 { + results = "return locales.PluralRuleUnknown" + } else { + + if !strings.HasPrefix(results, "return") { + + results = manyToSingleVars(results) + // pre += "\n" + results = pre + results + } + } + + if len(pluralArr) == 0 { + plurals = "nil" + } else { + plurals = fmt.Sprintf("%#v", pluralArr) + } + + return +} + +func manyToSingleVars(input string) (results string) { + + matches := nModRegex.FindAllString(input, -1) + mp := make(map[string][]string) // map of formula to variable + var found bool + var split []string + var variable string + + for _, formula := range matches { + + if _, found = mp[formula]; found { + continue + } + + split = strings.SplitN(formula, "%", 2) + + mp[formula] = []string{split[1], "math.Mod(" + split[0] + ", " + split[1] + ")"} + } + + for k, v := range mp { + variable = "nMod" + v[0] + results += variable + " := " + v[1] + "\n" + input = strings.Replace(input, k, variable, -1) + } + + matches = iModRegex.FindAllString(input, -1) + mp = make(map[string][]string) // map of formula to variable + + for _, formula := range matches { + + if _, found = mp[formula]; found { + continue + } + + split = strings.SplitN(formula, "%", 2) + + mp[formula] = []string{split[1], formula} + } + + for k, v := range mp { + variable = "iMod" + v[0] + results += variable + " := " + v[1] + "\n" + input = strings.Replace(input, k, variable, -1) + } + + matches = wModRegex.FindAllString(input, -1) + mp = make(map[string][]string) // map of formula to variable + + for _, formula := range matches { + + if _, found = mp[formula]; found { + continue + } + + split = strings.SplitN(formula, "%", 2) + + mp[formula] = []string{split[1], formula} + } + + for k, v := range mp { + variable = "wMod" + v[0] + results += variable + " := " + v[1] + "\n" + input = strings.Replace(input, k, variable, -1) + } + + matches = fModRegex.FindAllString(input, -1) + mp = make(map[string][]string) // map of formula to variable + + for _, formula := range matches { + + if _, found = mp[formula]; found { + continue + } + + split = strings.SplitN(formula, "%", 2) + + mp[formula] = []string{split[1], formula} + } + + for k, v := range mp { + variable = "fMod" + v[0] + results += variable + " := " + v[1] + "\n" + input = strings.Replace(input, k, variable, -1) + } + + matches = tModRegex.FindAllString(input, -1) + mp = make(map[string][]string) // map of formula to variable + + for _, formula := range matches { + + if _, found = mp[formula]; found { + continue + } + + split = strings.SplitN(formula, "%", 2) + + mp[formula] = []string{split[1], formula} + } + + for k, v := range mp { + variable = "tMod" + v[0] + results += variable + " := " + v[1] + "\n" + input = strings.Replace(input, k, variable, -1) + } + + results = results + "\n" + input + + return +} + +// pluralStringToInt returns the enum value of 'plural' provided +func pluralStringToInt(plural string) locales.PluralRule { + + switch plural { + case "zero": + return locales.PluralRuleZero + case "one": + return locales.PluralRuleOne + case "two": + return locales.PluralRuleTwo + case "few": + return locales.PluralRuleFew + case "many": + return locales.PluralRuleMany + case "other": + return locales.PluralRuleOther + default: + return locales.PluralRuleUnknown + } +} + +func pluralStringToString(pr string) string { + + pr = strings.TrimSpace(pr) + + switch pr { + case "zero": + return "PluralRuleZero" + case "one": + return "PluralRuleOne" + case "two": + return "PluralRuleTwo" + case "few": + return "PluralRuleFew" + case "many": + return "PluralRuleMany" + case "other": + return "PluralRuleOther" + default: + return "PluralRuleUnknown" + } +} diff --git a/vendor/github.com/go-playground/locales/cmd/locale_map.tmpl b/vendor/github.com/go-playground/locales/cmd/locale_map.tmpl new file mode 100644 index 0000000000..d3e0db56d3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cmd/locale_map.tmpl @@ -0,0 +1,34 @@ +{{ define "localeslist" }} +package localeslist + +import ( + "sync" +) + +// LocaleFunc is the function to run in order to create +// a new instance of a given locale +type LocaleFunc func() locales.Translator + +// LocaleMap is map of locale string to instance function +type LocaleMap map[string]LocaleFunc + + +var ( + once sync.Once + localeMap LocaleMap +) + +func init() { + once.Do(func(){ + localeMap = map[string]LocaleFunc{ + {{ . }} + } + }) +} + +// Map returns the map of locales to instance New function +func Map() LocaleMap { + return localeMap +} + +{{ end }} \ No newline at end of file diff --git a/vendor/github.com/go-playground/locales/cmd/tests.tmpl b/vendor/github.com/go-playground/locales/cmd/tests.tmpl new file mode 100644 index 0000000000..2d2147a89b --- /dev/null +++ b/vendor/github.com/go-playground/locales/cmd/tests.tmpl @@ -0,0 +1,1123 @@ +{{ define "tests" }} +package {{ .Locale }} + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "{{ .Locale }}" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +{{ end }} \ No newline at end of file diff --git a/vendor/github.com/go-playground/locales/cmd/translator.tmpl b/vendor/github.com/go-playground/locales/cmd/translator.tmpl new file mode 100644 index 0000000000..d2903bf7b7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cmd/translator.tmpl @@ -0,0 +1,950 @@ +{{ define "translator" }} +package {{ .Locale }} + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type {{ .Locale }} struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + {{- if gt (len .FmtPercentPrefix) 0}} + percentPrefix string + {{- end }} + {{- if gt (len .FmtPercentSuffix) 0}} + percentSuffix string + {{- end }} + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + {{- if gt (len .FmtCurrencyPrefix) 0}} + currencyPositivePrefix string + {{- end }} + {{- if gt (len .FmtCurrencySuffix) 0}} + currencyPositiveSuffix string + {{- end }} + {{- if gt (len .FmtCurrencyNegativePrefix) 0}} + currencyNegativePrefix string + {{- end }} + {{- if gt (len .FmtCurrencyNegativeSuffix) 0}} + currencyNegativeSuffix string + {{- end }} + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the '{{ .Locale }}' locale +func New() locales.Translator { + return &{{ .Locale }}{ + locale: "{{ .Locale }}", + pluralsCardinal: {{ .Plurals }}, + pluralsOrdinal: {{ .PluralsOrdinal }}, + pluralsRange: {{ .PluralsRange }}, + {{- if gt (len .Decimal) 0}} + decimal: "{{ .Decimal }}", + {{- end}} + {{- if gt (len .Group) 0}} + group: "{{ .Group }}", + {{- end}} + {{- if gt (len .Minus) 0}} + minus: "{{ .Minus }}", + {{- end}} + {{- if gt (len .Percent) 0}} + percent: "{{ .Percent }}", + {{- end}} + {{- if gt (len .PerMille) 0}} + perMille: "{{ .PerMille }}", + {{- end}} + {{- if gt (len .TimeSeparator) 0}} + timeSeparator: "{{ .TimeSeparator }}", + {{- end}} + {{- if gt (len .Infinity) 0}} + inifinity: "{{ .Infinity }}", + {{- end}} + currencies: {{ .Currencies }}, + {{- if gt (len .FmtPercentPrefix) 0}} + percentPrefix: "{{ .FmtPercentPrefix }}", + {{- end -}} + {{- if gt (len .FmtPercentSuffix) 0}} + percentSuffix: "{{ .FmtPercentSuffix }}", + {{- end -}} + {{- if gt (len .FmtCurrencyPrefix) 0}} + currencyPositivePrefix: "{{ .FmtCurrencyPrefix }}", + {{- end -}} + {{- if gt (len .FmtCurrencySuffix) 0}} + currencyPositiveSuffix: "{{ .FmtCurrencySuffix }}", + {{- end -}} + {{- if gt (len .FmtCurrencyNegativePrefix) 0}} + currencyNegativePrefix: "{{ .FmtCurrencyNegativePrefix }}", + {{- end -}} + {{- if gt (len .FmtCurrencyNegativeSuffix) 0}} + currencyNegativeSuffix: "{{ .FmtCurrencyNegativeSuffix }}", + {{- end -}} + {{- if gt (len .FmtMonthsAbbreviated) 0 }} + monthsAbbreviated: {{ .FmtMonthsAbbreviated }}, + {{- end -}} + {{- if gt (len .FmtMonthsNarrow) 0 }} + monthsNarrow: {{ .FmtMonthsNarrow }}, + {{- end -}} + {{- if gt (len .FmtMonthsWide) 0 }} + monthsWide: {{ .FmtMonthsWide }}, + {{- end -}} + {{- if gt (len .FmtDaysAbbreviated) 0 }} + daysAbbreviated: {{ .FmtDaysAbbreviated }}, + {{- end -}} + {{- if gt (len .FmtDaysNarrow) 0 }} + daysNarrow: {{ .FmtDaysNarrow }}, + {{- end -}} + {{- if gt (len .FmtDaysShort) 0 }} + daysShort: {{ .FmtDaysShort }}, + {{- end -}} + {{- if gt (len .FmtDaysWide) 0 }} + daysWide: {{ .FmtDaysWide }}, + {{- end -}} + {{- if gt (len .FmtPeriodsAbbreviated) 0 }} + periodsAbbreviated: {{ .FmtPeriodsAbbreviated }}, + {{- end -}} + {{- if gt (len .FmtPeriodsNarrow) 0 }} + periodsNarrow: {{ .FmtPeriodsNarrow }}, + {{- end -}} + {{- if gt (len .FmtPeriodsShort) 0 }} + periodsShort: {{ .FmtPeriodsShort }}, + {{- end -}} + {{- if gt (len .FmtPeriodsWide) 0 }} + periodsWide: {{ .FmtPeriodsWide }}, + {{- end -}} + {{- if gt (len .FmtErasAbbreviated) 0 }} + erasAbbreviated: {{ .FmtErasAbbreviated }}, + {{- end -}} + {{- if gt (len .FmtErasNarrow) 0 }} + erasNarrow: {{ .FmtErasNarrow }}, + {{- end -}} + {{- if gt (len .FmtErasWide) 0 }} + erasWide: {{ .FmtErasWide }}, + {{- end }} + timezones: {{ .FmtTimezones }}, + } +} + +// Locale returns the current translators string locale +func({{ .BaseLocale }} *{{ .Locale }}) Locale() string { + return {{ .BaseLocale }}.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) PluralsCardinal() []locales.PluralRule { + return {{ .BaseLocale }}.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) PluralsOrdinal() []locales.PluralRule { + return {{ .BaseLocale }}.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) PluralsRange() []locales.PluralRule { + return {{ .BaseLocale }}.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + {{ .CardinalFunc }} +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + {{ .OrdinalFunc }} +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) RangePluralRule(num1 float64, v1 uint64,num2 float64, v2 uint64) locales.PluralRule { + {{ .RangeFunc }} +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func({{ .BaseLocale }} *{{ .Locale }}) MonthAbbreviated(month time.Month) string { + return {{ .BaseLocale }}.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func({{ .BaseLocale }} *{{ .Locale }}) MonthsAbbreviated() []string { + {{- if gt (len .FmtMonthsAbbreviated) 0 }} + return {{ .BaseLocale }}.monthsAbbreviated[1:] + {{ else }} + return nil + {{- end -}} +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func({{ .BaseLocale }} *{{ .Locale }}) MonthNarrow(month time.Month) string { + return {{ .BaseLocale }}.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func({{ .BaseLocale }} *{{ .Locale }}) MonthsNarrow() []string { + {{- if gt (len .FmtMonthsNarrow) 0 }} + return {{ .BaseLocale }}.monthsNarrow[1:] + {{ else }} + return nil + {{- end -}} +} + +// MonthWide returns the locales wide month given the 'month' provided +func({{ .BaseLocale }} *{{ .Locale }}) MonthWide(month time.Month) string { + return {{ .BaseLocale }}.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func({{ .BaseLocale }} *{{ .Locale }}) MonthsWide() []string { + {{- if gt (len .FmtMonthsWide) 0 }} + return {{ .BaseLocale }}.monthsWide[1:] + {{ else }} + return nil + {{- end -}} +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func({{ .BaseLocale }} *{{ .Locale }}) WeekdayAbbreviated(weekday time.Weekday) string { + return {{ .BaseLocale }}.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func({{ .BaseLocale }} *{{ .Locale }}) WeekdaysAbbreviated() []string { + return {{ .BaseLocale }}.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func({{ .BaseLocale }} *{{ .Locale }}) WeekdayNarrow(weekday time.Weekday) string { + return {{ .BaseLocale }}.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func({{ .BaseLocale }} *{{ .Locale }}) WeekdaysNarrow() []string { + return {{ .BaseLocale }}.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func({{ .BaseLocale }} *{{ .Locale }}) WeekdayShort(weekday time.Weekday) string { + return {{ .BaseLocale }}.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func({{ .BaseLocale }} *{{ .Locale }}) WeekdaysShort() []string { + return {{ .BaseLocale }}.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func({{ .BaseLocale }} *{{ .Locale }}) WeekdayWide(weekday time.Weekday) string { + return {{ .BaseLocale }}.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func({{ .BaseLocale }} *{{ .Locale }}) WeekdaysWide() []string { + return {{ .BaseLocale }}.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for '{{ .Locale }}' and handles both Whole and Real numbers based on 'v' +func({{ .BaseLocale }} *{{ .Locale }}) FmtNumber(num float64, v uint64) string { + + {{ if eq .FmtNumberExists true }} + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + {{- if gt .FmtNumberGroupLen 0 }} + l := len(s) + {{ byte_count .Decimal .Minus }} + {{ byte_count .Group }} * len(s[:len(s)-int(v)-1]) / {{ .FmtNumberGroupLen }} + count := 0 + inWhole := v == 0 + {{- if gt .FmtNumberSecondaryGroupLen 0}} + inSecondary := false + groupThreshold := {{ .FmtNumberGroupLen }} + {{ end -}} + {{ else }} + l := len(s) + {{ byte_count .Decimal .Minus }} + {{ end }} + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + + {{- if is_multibyte .Decimal }} + for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.decimal[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.decimal[0]) + {{- end -}} + {{- if gt .FmtNumberGroupLen 0 }} + inWhole = true + {{- end }} + continue + } + + {{ if gt .FmtNumberGroupLen 0 }} + if inWhole { + + {{- if gt .FmtNumberSecondaryGroupLen 0}} + + if count == groupThreshold { + {{- if is_multibyte .Group }} + for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.group[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.group[0]) + {{- end }} + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = {{ .FmtNumberSecondaryGroupLen }} + } + {{ else }} + if count == {{ .FmtNumberGroupLen }} { + {{- if is_multibyte .Group }} + for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.group[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.group[0]) + {{- end }} + count = 1 + {{ end -}} + } else { + count++ + } + } + + {{ end }} + + b = append(b, s[i]) + } + + if num < 0 { + {{- if is_multibyte .Minus }} + for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.minus[j]) + } + {{ else }} + b = append(b, {{ .BaseLocale }}.minus[0]) + {{ end -}} + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + {{ if gt .FmtNumberMinDecimalLen 0 }} + if int(v) < {{ .FmtNumberMinDecimalLen }} { + + if v == 0 { + b = append(b, {{ .BaseLocale }}.decimal...) + } + + for i := 0; i < {{ .FmtNumberMinDecimalLen }}-int(v); i++ { + b = append(b, '0') + } + } + {{ end }} + + return string(b) + {{ else }} + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + {{ end -}} +} + +// FmtPercent returns 'num' with digits/precision of 'v' for '{{ .Locale }}' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func({{ .BaseLocale }} *{{ .Locale }}) FmtPercent(num float64, v uint64) string { + + {{- if eq .FmtPercentExists true }} + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + {{- if gt .FmtPercentGroupLen 0 }} + l := len(s) + {{ byte_count .Decimal .Minus .Percent .FmtPercentPrefix .FmtPercentSuffix }} + {{ byte_count .Group }} * len(s[:len(s)-int(v)-1]) / {{ .FmtPercentGroupLen }} + count := 0 + inWhole := v == 0 + {{- if gt .FmtPercentSecondaryGroupLen 0}} + inSecondary := false + groupThreshold := {{ .FmtPercentGroupLen }} + {{ end -}} + {{ else }} + l := len(s) + {{ byte_count .Decimal .Minus .Percent .FmtPercentPrefix .FmtPercentSuffix }} + {{- end }} + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + + {{- if is_multibyte .Decimal }} + for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.decimal[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.decimal[0]) + {{- end -}} + {{- if gt .FmtPercentGroupLen 0 }} + inWhole = true + {{ end }} + continue + } + + {{ if gt .FmtPercentGroupLen 0 }} + if inWhole { + + {{- if gt .FmtPercentSecondaryGroupLen 0}} + + if count == groupThreshold { + {{- if is_multibyte .Group }} + for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.group[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.group[0]) + {{- end }} + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = {{ .FmtPercentSecondaryGroupLen }} + } + {{ else }} + if count == {{ .FmtPercentGroupLen }} { + {{- if is_multibyte .Group }} + for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.group[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.group[0]) + {{- end }} + count = 1 + {{ end -}} + } else { + count++ + } + } + + {{ end }} + + b = append(b, s[i]) + } + + if num < 0 { + {{- if is_multibyte .Minus }} + for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.minus[j]) + } + {{ else }} + b = append(b, {{ .BaseLocale }}.minus[0]) + {{ end -}} + } + + {{ if and .FmtPercentInPrefix (not .FmtPercentLeft) }} + {{- if is_multibyte .Percent }} + for j := len({{ .BaseLocale }}.percent) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.percent[j]) + } + {{ else }} + b = append(b, {{ .BaseLocale }}.percent[0]) + {{ end }} + {{ end }} + + {{ if gt (len .FmtPercentPrefix) 0}} + {{- if is_multibyte .FmtPercentPrefix }} + for j := len({{ .BaseLocale }}.percentPrefix) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.percentPrefix[j]) + } + {{ else }} + b = append(b, {{ .BaseLocale }}.percentPrefix[0]) + {{ end }} + {{ end }} + + {{ if and .FmtPercentInPrefix .FmtPercentLeft }} + {{- if is_multibyte .Percent }} + for j := len({{ .BaseLocale }}.percent) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.percent[j]) + } + {{ else }} + b = append(b, {{ .BaseLocale }}.percent[0]) + {{ end }} + {{ end }} + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + {{ if gt .FmtPercentMinDecimalLen 0 }} + if int(v) < {{ .FmtPercentMinDecimalLen }} { + + if v == 0 { + b = append(b, {{ .BaseLocale }}.decimal...) + } + + for i := 0; i < {{ .FmtPercentMinDecimalLen }}-int(v); i++ { + b = append(b, '0') + } + } + {{ end }} + + {{ if and (not .FmtPercentInPrefix) .FmtPercentLeft }} + b = append(b, {{ .BaseLocale }}.percent...) + {{ end }} + + {{ if gt (len .FmtPercentSuffix) 0}} + b = append(b, {{ .BaseLocale }}.percentSuffix...) + {{ end }} + + {{ if and (not .FmtPercentInPrefix) (not .FmtPercentLeft) }} + b = append(b, {{ .BaseLocale }}.percent...) + {{ end }} + + return string(b) + {{ else }} + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + {{ end -}} +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := {{ .BaseLocale }}.currencies[currency] + {{- if eq .FmtCurrencyExists true }} + {{- if gt .FmtCurrencyGroupLen 0 }} + l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyPrefix .FmtCurrencySuffix }} + {{ byte_count .Group }} * len(s[:len(s)-int(v)-1]) / {{ .FmtCurrencyGroupLen }} + count := 0 + inWhole := v == 0 + {{- if gt .FmtCurrencySecondaryGroupLen 0}} + inSecondary := false + groupThreshold := {{ .FmtCurrencyGroupLen }} + {{ end -}} + {{ else }} + l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyPrefix .FmtCurrencySuffix }} + {{ end }} + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + + {{- if is_multibyte .Decimal }} + for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.decimal[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.decimal[0]) + {{- end -}} + {{- if gt .FmtCurrencyGroupLen 0 }} + inWhole = true + {{- end }} + continue + } + + {{ if gt .FmtCurrencyGroupLen 0 }} + if inWhole { + + {{- if gt .FmtCurrencySecondaryGroupLen 0}} + + if count == groupThreshold { + {{- if is_multibyte .Group }} + for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.group[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.group[0]) + {{- end }} + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = {{ .FmtCurrencySecondaryGroupLen }} + } + {{ else }} + if count == {{ .FmtCurrencyGroupLen }} { + {{- if is_multibyte .Group }} + for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.group[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.group[0]) + {{- end }} + count = 1 + {{ end -}} + } else { + count++ + } + } + + {{ end }} + + b = append(b, s[i]) + } + + {{ if and .FmtCurrencyInPrefix (not .FmtCurrencyLeft) }} + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + {{ end }} + + {{ if gt (len .FmtCurrencyPrefix) 0}} + {{- if is_multibyte .FmtCurrencyPrefix }} + for j := len({{ .BaseLocale }}.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.currencyPositivePrefix[j]) + } + {{ else }} + b = append(b, {{ .BaseLocale }}.currencyPositivePrefix[0]) + {{ end }} + {{ end }} + + {{ if and .FmtCurrencyInPrefix .FmtCurrencyLeft }} + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + {{ end }} + + if num < 0 { + {{- if is_multibyte .Minus }} + for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.minus[j]) + } + {{ else -}} + b = append(b, {{ .BaseLocale }}.minus[0]) + {{ end -}} + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + {{ if gt .FmtCurrencyMinDecimalLen 0 }} + if int(v) < {{ .FmtCurrencyMinDecimalLen }} { + + if v == 0 { + b = append(b, {{ .BaseLocale }}.decimal...) + } + + for i := 0; i < {{ .FmtCurrencyMinDecimalLen }}-int(v); i++ { + b = append(b, '0') + } + } + {{ end }} + + {{ if and (not .FmtCurrencyInPrefix) .FmtCurrencyLeft }} + b = append(b, symbol...) + {{ end }} + + {{ if gt (len .FmtCurrencySuffix) 0}} + b = append(b, {{ .BaseLocale }}.currencyPositiveSuffix...) + {{ end }} + + {{ if and (not .FmtCurrencyInPrefix) (not .FmtCurrencyLeft) }} + b = append(b, symbol...) + {{ end }} + + return string(b) + {{ else }} + return string(append(append([]byte{}, symbol...), s...)) + {{ end -}} +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for '{{ .Locale }}' +// in accounting notation. +func({{ .BaseLocale }} *{{ .Locale }}) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := {{ .BaseLocale }}.currencies[currency] + {{- if eq .FmtCurrencyExists true }} + {{- if gt .FmtCurrencyGroupLen 0 }} + l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyNegativePrefix .FmtCurrencyNegativeSuffix }} + {{ byte_count .Group }} * len(s[:len(s)-int(v)-1]) / {{ .FmtCurrencyGroupLen }} + count := 0 + inWhole := v == 0 + {{- if gt .FmtCurrencySecondaryGroupLen 0}} + inSecondary := false + groupThreshold := {{ .FmtCurrencyGroupLen }} + {{ end -}} + {{ else }} + l := len(s) + len(symbol) + {{ byte_count .Decimal .Minus .FmtCurrencyNegativePrefix .FmtCurrencyNegativeSuffix }} + {{ end }} + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + + {{- if is_multibyte .Decimal }} + for j := len({{ .BaseLocale }}.decimal) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.decimal[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.decimal[0]) + {{- end -}} + {{- if gt .FmtCurrencyGroupLen 0 }} + inWhole = true + {{- end }} + continue + } + + {{ if gt .FmtCurrencyGroupLen 0 }} + if inWhole { + + {{- if gt .FmtCurrencySecondaryGroupLen 0}} + + if count == groupThreshold { + {{- if is_multibyte .Group }} + for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.group[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.group[0]) + {{- end }} + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = {{ .FmtCurrencySecondaryGroupLen }} + } + {{ else }} + if count == {{ .FmtCurrencyGroupLen }} { + {{- if is_multibyte .Group }} + for j := len({{ .BaseLocale }}.group) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.group[j]) + } + {{- else }} + b = append(b, {{ .BaseLocale }}.group[0]) + {{- end }} + count = 1 + {{ end -}} + } else { + count++ + } + } + + {{ end }} + + b = append(b, s[i]) + } + + if num < 0 { + + {{ if and .FmtCurrencyNegativeInPrefix (not .FmtCurrencyNegativeLeft) }} + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + {{ end }} + + {{ if gt (len .FmtCurrencyNegativePrefix) 0}} + {{- if is_multibyte .FmtCurrencyNegativePrefix }} + for j := len({{ .BaseLocale }}.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.currencyNegativePrefix[j]) + } + {{ else }} + b = append(b, {{ .BaseLocale }}.currencyNegativePrefix[0]) + {{ end }} + {{ end }} + + {{ if and .FmtCurrencyNegativeInPrefix .FmtCurrencyNegativeLeft }} + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + {{ end }} + + {{ if eq (not .FmtCurrencyNegativeExists) true}} + {{- if is_multibyte .Minus }} + for j := len({{ .BaseLocale }}.minus) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.minus[j]) + } + {{ else -}} + b = append(b, {{ .BaseLocale }}.minus[0]) + {{ end -}} + {{ end }} + + {{ if or .FmtCurrencyInPrefix (gt (len .FmtCurrencyPrefix) 0) }} + } else { + {{ end }} + + {{ if and .FmtCurrencyInPrefix (not .FmtCurrencyLeft) }} + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + {{ end }} + + {{ if gt (len .FmtCurrencyPrefix) 0}} + {{- if is_multibyte .FmtCurrencyPrefix }} + for j := len({{ .BaseLocale }}.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, {{ .BaseLocale }}.currencyPositivePrefix[j]) + } + {{ else }} + b = append(b, {{ .BaseLocale }}.currencyPositivePrefix[0]) + {{ end }} + {{ end }} + + {{ if and .FmtCurrencyInPrefix .FmtCurrencyLeft }} + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + {{- end }} + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + {{ if gt .FmtCurrencyMinDecimalLen 0 }} + if int(v) < {{ .FmtCurrencyMinDecimalLen }} { + + if v == 0 { + b = append(b, {{ .BaseLocale }}.decimal...) + } + + for i := 0; i < {{ .FmtCurrencyMinDecimalLen }}-int(v); i++ { + b = append(b, '0') + } + } + {{- end }} + + {{ if or (not .FmtCurrencyNegativeInPrefix) (gt (len .FmtCurrencyNegativeSuffix) 0)}} + if num < 0 { + {{- end }} + {{- if and (not .FmtCurrencyNegativeInPrefix) .FmtCurrencyNegativeLeft }} + b = append(b, symbol...) + {{- end -}} + + {{- if gt (len .FmtCurrencyNegativeSuffix) 0}} + b = append(b, {{ .BaseLocale }}.currencyNegativeSuffix...) + {{- end -}} + + {{- if and (not .FmtCurrencyNegativeInPrefix) (not .FmtCurrencyNegativeLeft) }} + b = append(b, symbol...) + {{- end -}} + {{ if or (not .FmtCurrencyInPrefix) (gt (len .FmtCurrencySuffix) 0)}} + } else { + {{ end }} + {{- if and (not .FmtCurrencyInPrefix) .FmtCurrencyLeft }} + b = append(b, symbol...) + {{- end -}} + + {{- if gt (len .FmtCurrencySuffix) 0}} + b = append(b, {{ .BaseLocale }}.currencyPositiveSuffix...) + {{- end -}} + + {{- if and (not .FmtCurrencyInPrefix) (not .FmtCurrencyLeft) }} + b = append(b, symbol...) + {{- end -}} + {{- if or (not .FmtCurrencyNegativeInPrefix) (gt (len .FmtCurrencyNegativeSuffix) 0)}} + } + {{- end }} + + return string(b) + {{ else }} + return string(append(append([]byte{}, symbol...), s...)) + {{ end -}} +} + +// FmtDateShort returns the short date representation of 't' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + {{ .FmtDateShort }} + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + {{ .FmtDateMedium }} + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + {{ .FmtDateLong }} + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + {{ .FmtDateFull }} + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + {{ .FmtTimeShort }} + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + {{ .FmtTimeMedium }} + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + {{ .FmtTimeLong }} + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for '{{ .Locale }}' +func({{ .BaseLocale }} *{{ .Locale }}) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + {{ .FmtTimeFull }} + + return string(b) +} + +{{ end }} diff --git a/vendor/github.com/go-playground/locales/cs/cs.go b/vendor/github.com/go-playground/locales/cs/cs.go new file mode 100644 index 0000000000..9aac385981 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cs/cs.go @@ -0,0 +1,620 @@ +package cs + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type cs struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'cs' locale +func New() locales.Translator { + return &cs{ + locale: "cs", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "Kčs", "CUC", "CUP", "CVE", "CYP", "Kč", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "ECU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "led", "úno", "bře", "dub", "kvě", "čvn", "čvc", "srp", "zář", "říj", "lis", "pro"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "ledna", "února", "března", "dubna", "května", "června", "července", "srpna", "září", "října", "listopadu", "prosince"}, + daysAbbreviated: []string{"ne", "po", "út", "st", "čt", "pá", "so"}, + daysNarrow: []string{"N", "P", "Ú", "S", "Č", "P", "S"}, + daysShort: []string{"ne", "po", "út", "st", "čt", "pá", "so"}, + daysWide: []string{"neděle", "pondělí", "úterý", "středa", "čtvrtek", "pátek", "sobota"}, + periodsAbbreviated: []string{"dop.", "odp."}, + periodsNarrow: []string{"dop.", "odp."}, + periodsWide: []string{"dop.", "odp."}, + erasAbbreviated: []string{"př. n. l.", "n. l."}, + erasNarrow: []string{"př.n.l.", "n.l."}, + erasWide: []string{"př. n. l.", "n. l."}, + timezones: map[string]string{"MEZ": "Středoevropský standardní čas", "JDT": "Japonský letní čas", "CLT": "Chilský standardní čas", "UYST": "Uruguayský letní čas", "CHAST": "Chathamský standardní čas", "HADT": "Havajsko-aleutský letní čas", "BT": "Bhútánský čas", "HEEG": "Východogrónský letní čas", "HNPMX": "Mexický pacifický standardní čas", "ARST": "Argentinský letní čas", "EDT": "Severoamerický východní letní čas", "MYT": "Malajský čas", "SAST": "Jihoafrický čas", "GYT": "Guyanský čas", "CHADT": "Chathamský letní čas", "WART": "Západoargentinský standardní čas", "GMT": "Greenwichský střední čas", "TMT": "Turkmenský standardní čas", "HNNOMX": "Severozápadní mexický standardní čas", "WITA": "Středoindonéský čas", "AEDT": "Východoaustralský letní čas", "PDT": "Severoamerický pacifický letní čas", "OESZ": "Východoevropský letní čas", "WAT": "Západoafrický standardní čas", "AEST": "Východoaustralský standardní čas", "LHST": "Standardní čas ostrova lorda Howa", "HEPMX": "Mexický pacifický letní čas", "IST": "Indický čas", "HEOG": "Západogrónský letní čas", "TMST": "Turkmenský letní čas", "EST": "Severoamerický východní standardní čas", "HKST": "Hongkongský letní čas", "∅∅∅": "Brasilijský letní čas", "HAST": "Havajsko-aleutský standardní čas", "NZST": "Novozélandský standardní čas", "CLST": "Chilský letní čas", "AST": "Atlantický standardní čas", "WESZ": "Západoevropský letní čas", "ACST": "Středoaustralský standardní čas", "WIB": "Západoindonéský čas", "AWST": "Západoaustralský standardní čas", "MDT": "Macajský letní čas", "PST": "Severoamerický pacifický standardní čas", "ACWST": "Středozápadní australský standardní čas", "WARST": "Západoargentinský letní čas", "HNOG": "Západogrónský standardní čas", "WEZ": "Západoevropský standardní čas", "HNT": "Newfoundlandský standardní čas", "AKDT": "Aljašský letní čas", "HNPM": "Pierre-miquelonský standardní čas", "HNCU": "Kubánský standardní čas", "VET": "Venezuelský čas", "JST": "Japonský standardní čas", "ADT": "Atlantický letní čas", "OEZ": "Východoevropský standardní čas", "WAST": "Západoafrický letní čas", "COT": "Kolumbijský standardní čas", "HNEG": "Východogrónský standardní čas", "SGT": "Singapurský čas", "ACWDT": "Středozápadní australský letní čas", "HEPM": "Pierre-miquelonský letní čas", "SRT": "Surinamský čas", "MST": "Macajský standardní čas", "COST": "Kolumbijský letní čas", "GFT": "Francouzskoguyanský čas", "HECU": "Kubánský letní čas", "WIT": "Východoindonéský čas", "HAT": "Newfoundlandský letní čas", "LHDT": "Letní čas ostrova lorda Howa", "CDT": "Severoamerický centrální letní čas", "MESZ": "Středoevropský letní čas", "ACDT": "Středoaustralský letní čas", "HENOMX": "Severozápadní mexický letní čas", "AKST": "Aljašský standardní čas", "ChST": "Chamorrský čas", "UYT": "Uruguayský standardní čas", "CST": "Severoamerický centrální standardní čas", "CAT": "Středoafrický čas", "NZDT": "Novozélandský letní čas", "ART": "Argentinský standardní čas", "HKT": "Hongkongský standardní čas", "EAT": "Východoafrický čas", "BOT": "Bolivijský čas", "AWDT": "Západoaustralský letní čas", "ECT": "Ekvádorský čas"}, + } +} + +// Locale returns the current translators string locale +func (cs *cs) Locale() string { + return cs.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'cs' +func (cs *cs) PluralsCardinal() []locales.PluralRule { + return cs.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'cs' +func (cs *cs) PluralsOrdinal() []locales.PluralRule { + return cs.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'cs' +func (cs *cs) PluralsRange() []locales.PluralRule { + return cs.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'cs' +func (cs *cs) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if i >= 2 && i <= 4 && v == 0 { + return locales.PluralRuleFew + } else if v != 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'cs' +func (cs *cs) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'cs' +func (cs *cs) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := cs.CardinalPluralRule(num1, v1) + end := cs.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (cs *cs) MonthAbbreviated(month time.Month) string { + return cs.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (cs *cs) MonthsAbbreviated() []string { + return cs.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (cs *cs) MonthNarrow(month time.Month) string { + return cs.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (cs *cs) MonthsNarrow() []string { + return cs.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (cs *cs) MonthWide(month time.Month) string { + return cs.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (cs *cs) MonthsWide() []string { + return cs.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (cs *cs) WeekdayAbbreviated(weekday time.Weekday) string { + return cs.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (cs *cs) WeekdaysAbbreviated() []string { + return cs.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (cs *cs) WeekdayNarrow(weekday time.Weekday) string { + return cs.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (cs *cs) WeekdaysNarrow() []string { + return cs.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (cs *cs) WeekdayShort(weekday time.Weekday) string { + return cs.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (cs *cs) WeekdaysShort() []string { + return cs.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (cs *cs) WeekdayWide(weekday time.Weekday) string { + return cs.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (cs *cs) WeekdaysWide() []string { + return cs.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'cs' and handles both Whole and Real numbers based on 'v' +func (cs *cs) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cs.group) - 1; j >= 0; j-- { + b = append(b, cs.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'cs' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (cs *cs) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cs.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, cs.percentSuffix...) + + b = append(b, cs.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'cs' +func (cs *cs) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cs.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cs.group) - 1; j >= 0; j-- { + b = append(b, cs.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, cs.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'cs' +// in accounting notation. +func (cs *cs) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cs.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cs.group) - 1; j >= 0; j-- { + b = append(b, cs.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, cs.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, cs.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, cs.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'cs' +func (cs *cs) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'cs' +func (cs *cs) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'cs' +func (cs *cs) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, cs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'cs' +func (cs *cs) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, cs.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, cs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'cs' +func (cs *cs) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'cs' +func (cs *cs) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'cs' +func (cs *cs) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'cs' +func (cs *cs) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := cs.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/cs/cs_test.go b/vendor/github.com/go-playground/locales/cs/cs_test.go new file mode 100644 index 0000000000..77c1bb916e --- /dev/null +++ b/vendor/github.com/go-playground/locales/cs/cs_test.go @@ -0,0 +1,1120 @@ +package cs + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "cs" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/cs_CZ/cs_CZ.go b/vendor/github.com/go-playground/locales/cs_CZ/cs_CZ.go new file mode 100644 index 0000000000..f4ba7431b1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cs_CZ/cs_CZ.go @@ -0,0 +1,620 @@ +package cs_CZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type cs_CZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'cs_CZ' locale +func New() locales.Translator { + return &cs_CZ{ + locale: "cs_CZ", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "led", "úno", "bře", "dub", "kvě", "čvn", "čvc", "srp", "zář", "říj", "lis", "pro"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "ledna", "února", "března", "dubna", "května", "června", "července", "srpna", "září", "října", "listopadu", "prosince"}, + daysAbbreviated: []string{"ne", "po", "út", "st", "čt", "pá", "so"}, + daysNarrow: []string{"N", "P", "Ú", "S", "Č", "P", "S"}, + daysShort: []string{"ne", "po", "út", "st", "čt", "pá", "so"}, + daysWide: []string{"neděle", "pondělí", "úterý", "středa", "čtvrtek", "pátek", "sobota"}, + periodsAbbreviated: []string{"dop.", "odp."}, + periodsNarrow: []string{"dop.", "odp."}, + periodsWide: []string{"dop.", "odp."}, + erasAbbreviated: []string{"př. n. l.", "n. l."}, + erasNarrow: []string{"př.n.l.", "n.l."}, + erasWide: []string{"př. n. l.", "n. l."}, + timezones: map[string]string{"HEPMX": "Mexický pacifický letní čas", "WIT": "Východoindonéský čas", "ACWDT": "Středozápadní australský letní čas", "NZDT": "Novozélandský letní čas", "HENOMX": "Severozápadní mexický letní čas", "AEST": "Východoaustralský standardní čas", "MST": "Severoamerický horský standardní čas", "BOT": "Bolivijský čas", "HNOG": "Západogrónský standardní čas", "HNNOMX": "Severozápadní mexický standardní čas", "∅∅∅": "Acrejský letní čas", "HNPMX": "Mexický pacifický standardní čas", "CHADT": "Chathamský letní čas", "TMT": "Turkmenský standardní čas", "EDT": "Severoamerický východní letní čas", "HKT": "Hongkongský standardní čas", "SRT": "Surinamský čas", "CHAST": "Chathamský standardní čas", "OESZ": "Východoevropský letní čas", "WARST": "Západoargentinský letní čas", "CLST": "Chilský letní čas", "HKST": "Hongkongský letní čas", "IST": "Indický čas", "HEEG": "Východogrónský letní čas", "WITA": "Středoindonéský čas", "HEPM": "Pierre-miquelonský letní čas", "LHDT": "Letní čas ostrova lorda Howa", "CST": "Severoamerický centrální standardní čas", "PST": "Severoamerický pacifický standardní čas", "CAT": "Středoafrický čas", "HEOG": "Západogrónský letní čas", "ADT": "Atlantický letní čas", "HNEG": "Východogrónský standardní čas", "LHST": "Standardní čas ostrova lorda Howa", "HECU": "Kubánský letní čas", "AWST": "Západoaustralský standardní čas", "HNPM": "Pierre-miquelonský standardní čas", "SGT": "Singapurský čas", "HADT": "Havajsko-aleutský letní čas", "WAST": "Západoafrický letní čas", "COT": "Kolumbijský standardní čas", "AWDT": "Západoaustralský letní čas", "ACST": "Středoaustralský standardní čas", "AKST": "Aljašský standardní čas", "AEDT": "Východoaustralský letní čas", "HAST": "Havajsko-aleutský standardní čas", "WEZ": "Západoevropský standardní čas", "TMST": "Turkmenský letní čas", "ART": "Argentinský standardní čas", "ACWST": "Středozápadní australský standardní čas", "MESZ": "Středoevropský letní čas", "MEZ": "Středoevropský standardní čas", "WART": "Západoargentinský standardní čas", "EST": "Severoamerický východní standardní čas", "GFT": "Francouzskoguyanský čas", "EAT": "Východoafrický čas", "HNCU": "Kubánský standardní čas", "ECT": "Ekvádorský čas", "NZST": "Novozélandský standardní čas", "COST": "Kolumbijský letní čas", "BT": "Bhútánský čas", "SAST": "Jihoafrický čas", "JDT": "Japonský letní čas", "OEZ": "Východoevropský standardní čas", "CLT": "Chilský standardní čas", "HAT": "Newfoundlandský letní čas", "UYT": "Uruguayský standardní čas", "UYST": "Uruguayský letní čas", "WIB": "Západoindonéský čas", "JST": "Japonský standardní čas", "WAT": "Západoafrický standardní čas", "MYT": "Malajský čas", "HNT": "Newfoundlandský standardní čas", "ChST": "Chamorrský čas", "CDT": "Severoamerický centrální letní čas", "PDT": "Severoamerický pacifický letní čas", "VET": "Venezuelský čas", "AST": "Atlantický standardní čas", "GMT": "Greenwichský střední čas", "ACDT": "Středoaustralský letní čas", "AKDT": "Aljašský letní čas", "MDT": "Severoamerický horský letní čas", "GYT": "Guyanský čas", "WESZ": "Západoevropský letní čas", "ARST": "Argentinský letní čas"}, + } +} + +// Locale returns the current translators string locale +func (cs *cs_CZ) Locale() string { + return cs.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'cs_CZ' +func (cs *cs_CZ) PluralsCardinal() []locales.PluralRule { + return cs.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'cs_CZ' +func (cs *cs_CZ) PluralsOrdinal() []locales.PluralRule { + return cs.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'cs_CZ' +func (cs *cs_CZ) PluralsRange() []locales.PluralRule { + return cs.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'cs_CZ' +func (cs *cs_CZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if i >= 2 && i <= 4 && v == 0 { + return locales.PluralRuleFew + } else if v != 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'cs_CZ' +func (cs *cs_CZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'cs_CZ' +func (cs *cs_CZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := cs.CardinalPluralRule(num1, v1) + end := cs.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (cs *cs_CZ) MonthAbbreviated(month time.Month) string { + return cs.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (cs *cs_CZ) MonthsAbbreviated() []string { + return cs.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (cs *cs_CZ) MonthNarrow(month time.Month) string { + return cs.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (cs *cs_CZ) MonthsNarrow() []string { + return cs.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (cs *cs_CZ) MonthWide(month time.Month) string { + return cs.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (cs *cs_CZ) MonthsWide() []string { + return cs.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (cs *cs_CZ) WeekdayAbbreviated(weekday time.Weekday) string { + return cs.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (cs *cs_CZ) WeekdaysAbbreviated() []string { + return cs.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (cs *cs_CZ) WeekdayNarrow(weekday time.Weekday) string { + return cs.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (cs *cs_CZ) WeekdaysNarrow() []string { + return cs.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (cs *cs_CZ) WeekdayShort(weekday time.Weekday) string { + return cs.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (cs *cs_CZ) WeekdaysShort() []string { + return cs.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (cs *cs_CZ) WeekdayWide(weekday time.Weekday) string { + return cs.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (cs *cs_CZ) WeekdaysWide() []string { + return cs.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'cs_CZ' and handles both Whole and Real numbers based on 'v' +func (cs *cs_CZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cs.group) - 1; j >= 0; j-- { + b = append(b, cs.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'cs_CZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (cs *cs_CZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cs.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, cs.percentSuffix...) + + b = append(b, cs.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'cs_CZ' +func (cs *cs_CZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cs.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cs.group) - 1; j >= 0; j-- { + b = append(b, cs.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cs.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, cs.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'cs_CZ' +// in accounting notation. +func (cs *cs_CZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cs.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cs.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cs.group) - 1; j >= 0; j-- { + b = append(b, cs.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, cs.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cs.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, cs.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, cs.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'cs_CZ' +func (cs *cs_CZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'cs_CZ' +func (cs *cs_CZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'cs_CZ' +func (cs *cs_CZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, cs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'cs_CZ' +func (cs *cs_CZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, cs.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, cs.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'cs_CZ' +func (cs *cs_CZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'cs_CZ' +func (cs *cs_CZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'cs_CZ' +func (cs *cs_CZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'cs_CZ' +func (cs *cs_CZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cs.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cs.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := cs.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/cs_CZ/cs_CZ_test.go b/vendor/github.com/go-playground/locales/cs_CZ/cs_CZ_test.go new file mode 100644 index 0000000000..9cec35fb7c --- /dev/null +++ b/vendor/github.com/go-playground/locales/cs_CZ/cs_CZ_test.go @@ -0,0 +1,1120 @@ +package cs_CZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "cs_CZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/cu/cu.go b/vendor/github.com/go-playground/locales/cu/cu.go new file mode 100644 index 0000000000..c9bca4218f --- /dev/null +++ b/vendor/github.com/go-playground/locales/cu/cu.go @@ -0,0 +1,594 @@ +package cu + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type cu struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'cu' locale +func New() locales.Translator { + return &cu{ + locale: "cu", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "₸", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "₽", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "₴", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "і҆аⷩ҇", "феⷡ҇", "маⷬ҇", "а҆пⷬ҇", "маꙵ", "і҆ꙋⷩ҇", "і҆ꙋⷧ҇", "а҆́ѵⷢ҇", "сеⷫ҇", "ѻ҆кⷮ", "ноеⷨ", "деⷦ҇"}, + monthsNarrow: []string{"", "І҆", "Ф", "М", "А҆", "М", "І҆", "І҆", "А҆", "С", "Ѻ҆", "Н", "Д"}, + monthsWide: []string{"", "і҆аннꙋа́рїа", "феврꙋа́рїа", "ма́рта", "а҆прі́ллїа", "ма́їа", "і҆ꙋ́нїа", "і҆ꙋ́лїа", "а҆́ѵгꙋста", "септе́мврїа", "ѻ҆ктѡ́врїа", "ное́мврїа", "деке́мврїа"}, + daysAbbreviated: []string{"ндⷧ҇ѧ", "пнⷣе", "втоⷬ҇", "срⷣе", "чеⷦ҇", "пѧⷦ҇", "сꙋⷠ҇"}, + daysNarrow: []string{"Н", "П", "В", "С", "Ч", "П", "С"}, + daysShort: []string{"ндⷧ҇ѧ", "пнⷣе", "втоⷬ҇", "срⷣе", "чеⷦ҇", "пѧⷦ҇", "сꙋⷠ҇"}, + daysWide: []string{"недѣ́лѧ", "понедѣ́льникъ", "вто́рникъ", "среда̀", "четверто́къ", "пѧто́къ", "сꙋббѡ́та"}, + periodsAbbreviated: []string{"ДП", "ПП"}, + periodsNarrow: []string{"ДП", "ПП"}, + periodsWide: []string{"ДП", "ПП"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"пре́дъ р.\u00a0х.", "по р.\u00a0х."}, + timezones: map[string]string{"HNPM": "HNPM", "PDT": "тихоѻкеа́нское лѣ́тнее вре́мѧ", "NZDT": "NZDT", "MST": "MST", "ART": "ART", "WAT": "WAT", "HEPMX": "HEPMX", "HECU": "HECU", "AWDT": "AWDT", "HAST": "HAST", "IST": "IST", "WARST": "WARST", "CLT": "CLT", "HKST": "HKST", "HEEG": "HEEG", "TMT": "TMT", "EST": "восточноамерїка́нское зи́мнее вре́мѧ", "PST": "тихоѻкеа́нское зи́мнее вре́мѧ", "NZST": "NZST", "TMST": "TMST", "HNEG": "HNEG", "AKDT": "AKDT", "AEDT": "AEDT", "GYT": "GYT", "ADT": "а҆тланті́ческое лѣ́тнее вре́мѧ", "AWST": "AWST", "OEZ": "восточноєѵрѡпе́йское зи́мнее вре́мѧ", "ChST": "ChST", "HEPM": "HEPM", "CLST": "CLST", "HENOMX": "HENOMX", "HNT": "HNT", "AKST": "AKST", "HNCU": "HNCU", "MESZ": "среднеєѵрѡпе́йское лѣ́тнее вре́мѧ", "OESZ": "восточноєѵрѡпе́йское лѣ́тнее вре́мѧ", "UYT": "UYT", "LHDT": "LHDT", "CHAST": "CHAST", "BOT": "BOT", "ACDT": "ACDT", "HNPMX": "HNPMX", "CST": "среднеамерїка́нское зи́мнее вре́мѧ", "CHADT": "CHADT", "SGT": "SGT", "JDT": "JDT", "MDT": "MDT", "ACST": "ACST", "WITA": "WITA", "UYST": "UYST", "WIT": "WIT", "MYT": "MYT", "ARST": "ARST", "HNNOMX": "HNNOMX", "BT": "BT", "EDT": "восточноамерїка́нское лѣ́тнее вре́мѧ", "SRT": "SRT", "HADT": "HADT", "ACWDT": "ACWDT", "JST": "JST", "HNOG": "HNOG", "AST": "а҆тланті́ческое зи́мнее вре́мѧ", "WAST": "WAST", "WIB": "WIB", "MEZ": "среднеєѵрѡпе́йское зи́мнее вре́мѧ", "GFT": "GFT", "ACWST": "ACWST", "WART": "WART", "HEOG": "HEOG", "WESZ": "западноєѵрѡпе́йское лѣ́тнее вре́мѧ", "GMT": "сре́днее вре́мѧ по грі́нꙋичꙋ", "WEZ": "западноєѵрѡпе́йское зи́мнее вре́мѧ", "COT": "COT", "AEST": "AEST", "VET": "VET", "∅∅∅": "∅∅∅", "SAST": "SAST", "LHST": "LHST", "EAT": "EAT", "CDT": "среднеамерїка́нское лѣ́тнее вре́мѧ", "ECT": "ECT", "CAT": "CAT", "HKT": "HKT", "COST": "COST", "HAT": "HAT"}, + } +} + +// Locale returns the current translators string locale +func (cu *cu) Locale() string { + return cu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'cu' +func (cu *cu) PluralsCardinal() []locales.PluralRule { + return cu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'cu' +func (cu *cu) PluralsOrdinal() []locales.PluralRule { + return cu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'cu' +func (cu *cu) PluralsRange() []locales.PluralRule { + return cu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'cu' +func (cu *cu) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'cu' +func (cu *cu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'cu' +func (cu *cu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (cu *cu) MonthAbbreviated(month time.Month) string { + return cu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (cu *cu) MonthsAbbreviated() []string { + return cu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (cu *cu) MonthNarrow(month time.Month) string { + return cu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (cu *cu) MonthsNarrow() []string { + return cu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (cu *cu) MonthWide(month time.Month) string { + return cu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (cu *cu) MonthsWide() []string { + return cu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (cu *cu) WeekdayAbbreviated(weekday time.Weekday) string { + return cu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (cu *cu) WeekdaysAbbreviated() []string { + return cu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (cu *cu) WeekdayNarrow(weekday time.Weekday) string { + return cu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (cu *cu) WeekdaysNarrow() []string { + return cu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (cu *cu) WeekdayShort(weekday time.Weekday) string { + return cu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (cu *cu) WeekdaysShort() []string { + return cu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (cu *cu) WeekdayWide(weekday time.Weekday) string { + return cu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (cu *cu) WeekdaysWide() []string { + return cu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'cu' and handles both Whole and Real numbers based on 'v' +func (cu *cu) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cu.group) - 1; j >= 0; j-- { + b = append(b, cu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'cu' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (cu *cu) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, cu.percentSuffix...) + + b = append(b, cu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'cu' +func (cu *cu) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cu.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cu.group) - 1; j >= 0; j-- { + b = append(b, cu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, cu.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'cu' +// in accounting notation. +func (cu *cu) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cu.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cu.group) - 1; j >= 0; j-- { + b = append(b, cu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, cu.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, cu.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, cu.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'cu' +func (cu *cu) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'cu' +func (cu *cu) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, cu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'cu' +func (cu *cu) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, cu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'cu' +func (cu *cu) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, cu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xd0, 0xbb}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'cu' +func (cu *cu) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'cu' +func (cu *cu) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'cu' +func (cu *cu) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'cu' +func (cu *cu) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := cu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/cu/cu_test.go b/vendor/github.com/go-playground/locales/cu/cu_test.go new file mode 100644 index 0000000000..91c734a406 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cu/cu_test.go @@ -0,0 +1,1120 @@ +package cu + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "cu" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/cu_RU/cu_RU.go b/vendor/github.com/go-playground/locales/cu_RU/cu_RU.go new file mode 100644 index 0000000000..c466addbfa --- /dev/null +++ b/vendor/github.com/go-playground/locales/cu_RU/cu_RU.go @@ -0,0 +1,594 @@ +package cu_RU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type cu_RU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'cu_RU' locale +func New() locales.Translator { + return &cu_RU{ + locale: "cu_RU", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "і҆аⷩ҇", "феⷡ҇", "маⷬ҇", "а҆пⷬ҇", "маꙵ", "і҆ꙋⷩ҇", "і҆ꙋⷧ҇", "а҆́ѵⷢ҇", "сеⷫ҇", "ѻ҆кⷮ", "ноеⷨ", "деⷦ҇"}, + monthsNarrow: []string{"", "І҆", "Ф", "М", "А҆", "М", "І҆", "І҆", "А҆", "С", "Ѻ҆", "Н", "Д"}, + monthsWide: []string{"", "і҆аннꙋа́рїа", "феврꙋа́рїа", "ма́рта", "а҆прі́ллїа", "ма́їа", "і҆ꙋ́нїа", "і҆ꙋ́лїа", "а҆́ѵгꙋста", "септе́мврїа", "ѻ҆ктѡ́врїа", "ное́мврїа", "деке́мврїа"}, + daysAbbreviated: []string{"ндⷧ҇ѧ", "пнⷣе", "втоⷬ҇", "срⷣе", "чеⷦ҇", "пѧⷦ҇", "сꙋⷠ҇"}, + daysNarrow: []string{"Н", "П", "В", "С", "Ч", "П", "С"}, + daysShort: []string{"ндⷧ҇ѧ", "пнⷣе", "втоⷬ҇", "срⷣе", "чеⷦ҇", "пѧⷦ҇", "сꙋⷠ҇"}, + daysWide: []string{"недѣ́лѧ", "понедѣ́льникъ", "вто́рникъ", "среда̀", "четверто́къ", "пѧто́къ", "сꙋббѡ́та"}, + periodsAbbreviated: []string{"ДП", "ПП"}, + periodsNarrow: []string{"ДП", "ПП"}, + periodsWide: []string{"ДП", "ПП"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"пре́дъ р.\u00a0х.", "по р.\u00a0х."}, + timezones: map[string]string{"EDT": "восточноамерїка́нское лѣ́тнее вре́мѧ", "HEEG": "HEEG", "ChST": "ChST", "UYT": "UYT", "WIB": "WIB", "HNT": "HNT", "AKDT": "AKDT", "SRT": "SRT", "LHDT": "LHDT", "ACST": "ACST", "COT": "COT", "AEDT": "AEDT", "HNPM": "HNPM", "HAST": "HAST", "MYT": "MYT", "WARST": "WARST", "OESZ": "восточноєѵрѡпе́йское лѣ́тнее вре́мѧ", "HEPMX": "HEPMX", "HNCU": "HNCU", "CST": "среднеамерїка́нское зи́мнее вре́мѧ", "AST": "а҆тланті́ческое зи́мнее вре́мѧ", "ACDT": "ACDT", "JDT": "JDT", "CLST": "CLST", "EST": "восточноамерїка́нское зи́мнее вре́мѧ", "HNEG": "HNEG", "AKST": "AKST", "CHAST": "CHAST", "HEOG": "HEOG", "HENOMX": "HENOMX", "WITA": "WITA", "OEZ": "восточноєѵрѡпе́йское зи́мнее вре́мѧ", "HAT": "HAT", "PDT": "тихоѻкеа́нское лѣ́тнее вре́мѧ", "ACWDT": "ACWDT", "WART": "WART", "ADT": "а҆тланті́ческое лѣ́тнее вре́мѧ", "CLT": "CLT", "COST": "COST", "GYT": "GYT", "EAT": "EAT", "AWST": "AWST", "BOT": "BOT", "VET": "VET", "TMT": "TMT", "BT": "BT", "MDT": "MDT", "HKT": "HKT", "WAST": "WAST", "HEPM": "HEPM", "NZDT": "NZDT", "WEZ": "западноєѵрѡпе́йское зи́мнее вре́мѧ", "WESZ": "западноєѵрѡпе́йское лѣ́тнее вре́мѧ", "TMST": "TMST", "UYST": "UYST", "HECU": "HECU", "CDT": "среднеамерїка́нское лѣ́тнее вре́мѧ", "CHADT": "CHADT", "HADT": "HADT", "NZST": "NZST", "CAT": "CAT", "ACWST": "ACWST", "WAT": "WAT", "AWDT": "AWDT", "WIT": "WIT", "SGT": "SGT", "ECT": "ECT", "MESZ": "среднеєѵрѡпе́йское лѣ́тнее вре́мѧ", "ARST": "ARST", "ART": "ART", "HKST": "HKST", "HNNOMX": "HNNOMX", "LHST": "LHST", "PST": "тихоѻкеа́нское зи́мнее вре́мѧ", "JST": "JST", "MEZ": "среднеєѵрѡпе́йское зи́мнее вре́мѧ", "GMT": "сре́днее вре́мѧ по грі́нꙋичꙋ", "AEST": "AEST", "GFT": "GFT", "HNPMX": "HNPMX", "SAST": "SAST", "∅∅∅": "∅∅∅", "IST": "IST", "HNOG": "HNOG", "MST": "MST"}, + } +} + +// Locale returns the current translators string locale +func (cu *cu_RU) Locale() string { + return cu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'cu_RU' +func (cu *cu_RU) PluralsCardinal() []locales.PluralRule { + return cu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'cu_RU' +func (cu *cu_RU) PluralsOrdinal() []locales.PluralRule { + return cu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'cu_RU' +func (cu *cu_RU) PluralsRange() []locales.PluralRule { + return cu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'cu_RU' +func (cu *cu_RU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'cu_RU' +func (cu *cu_RU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'cu_RU' +func (cu *cu_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (cu *cu_RU) MonthAbbreviated(month time.Month) string { + return cu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (cu *cu_RU) MonthsAbbreviated() []string { + return cu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (cu *cu_RU) MonthNarrow(month time.Month) string { + return cu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (cu *cu_RU) MonthsNarrow() []string { + return cu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (cu *cu_RU) MonthWide(month time.Month) string { + return cu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (cu *cu_RU) MonthsWide() []string { + return cu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (cu *cu_RU) WeekdayAbbreviated(weekday time.Weekday) string { + return cu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (cu *cu_RU) WeekdaysAbbreviated() []string { + return cu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (cu *cu_RU) WeekdayNarrow(weekday time.Weekday) string { + return cu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (cu *cu_RU) WeekdaysNarrow() []string { + return cu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (cu *cu_RU) WeekdayShort(weekday time.Weekday) string { + return cu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (cu *cu_RU) WeekdaysShort() []string { + return cu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (cu *cu_RU) WeekdayWide(weekday time.Weekday) string { + return cu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (cu *cu_RU) WeekdaysWide() []string { + return cu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'cu_RU' and handles both Whole and Real numbers based on 'v' +func (cu *cu_RU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cu.group) - 1; j >= 0; j-- { + b = append(b, cu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'cu_RU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (cu *cu_RU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, cu.percentSuffix...) + + b = append(b, cu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'cu_RU' +func (cu *cu_RU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cu.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cu.group) - 1; j >= 0; j-- { + b = append(b, cu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, cu.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'cu_RU' +// in accounting notation. +func (cu *cu_RU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cu.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(cu.group) - 1; j >= 0; j-- { + b = append(b, cu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, cu.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, cu.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, cu.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'cu_RU' +func (cu *cu_RU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'cu_RU' +func (cu *cu_RU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, cu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'cu_RU' +func (cu *cu_RU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, cu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'cu_RU' +func (cu *cu_RU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, cu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xd0, 0xbb}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'cu_RU' +func (cu *cu_RU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'cu_RU' +func (cu *cu_RU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'cu_RU' +func (cu *cu_RU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'cu_RU' +func (cu *cu_RU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := cu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/cu_RU/cu_RU_test.go b/vendor/github.com/go-playground/locales/cu_RU/cu_RU_test.go new file mode 100644 index 0000000000..3f32150cde --- /dev/null +++ b/vendor/github.com/go-playground/locales/cu_RU/cu_RU_test.go @@ -0,0 +1,1120 @@ +package cu_RU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "cu_RU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/currency/currency.go b/vendor/github.com/go-playground/locales/currency/currency.go new file mode 100644 index 0000000000..6e75ec58ce --- /dev/null +++ b/vendor/github.com/go-playground/locales/currency/currency.go @@ -0,0 +1,306 @@ +package currency + +// Type is the currency type associated with the locales currency enum +type Type int + +// locale currencies +const ( + ADP Type = iota + AED + AFA + AFN + ALK + ALL + AMD + ANG + AOA + AOK + AON + AOR + ARA + ARL + ARM + ARP + ARS + ATS + AUD + AWG + AZM + AZN + BAD + BAM + BAN + BBD + BDT + BEC + BEF + BEL + BGL + BGM + BGN + BGO + BHD + BIF + BMD + BND + BOB + BOL + BOP + BOV + BRB + BRC + BRE + BRL + BRN + BRR + BRZ + BSD + BTN + BUK + BWP + BYB + BYN + BYR + BZD + CAD + CDF + CHE + CHF + CHW + CLE + CLF + CLP + CNX + CNY + COP + COU + CRC + CSD + CSK + CUC + CUP + CVE + CYP + CZK + DDM + DEM + DJF + DKK + DOP + DZD + ECS + ECV + EEK + EGP + ERN + ESA + ESB + ESP + ETB + EUR + FIM + FJD + FKP + FRF + GBP + GEK + GEL + GHC + GHS + GIP + GMD + GNF + GNS + GQE + GRD + GTQ + GWE + GWP + GYD + HKD + HNL + HRD + HRK + HTG + HUF + IDR + IEP + ILP + ILR + ILS + INR + IQD + IRR + ISJ + ISK + ITL + JMD + JOD + JPY + KES + KGS + KHR + KMF + KPW + KRH + KRO + KRW + KWD + KYD + KZT + LAK + LBP + LKR + LRD + LSL + LTL + LTT + LUC + LUF + LUL + LVL + LVR + LYD + MAD + MAF + MCF + MDC + MDL + MGA + MGF + MKD + MKN + MLF + MMK + MNT + MOP + MRO + MTL + MTP + MUR + MVP + MVR + MWK + MXN + MXP + MXV + MYR + MZE + MZM + MZN + NAD + NGN + NIC + NIO + NLG + NOK + NPR + NZD + OMR + PAB + PEI + PEN + PES + PGK + PHP + PKR + PLN + PLZ + PTE + PYG + QAR + RHD + ROL + RON + RSD + RUB + RUR + RWF + SAR + SBD + SCR + SDD + SDG + SDP + SEK + SGD + SHP + SIT + SKK + SLL + SOS + SRD + SRG + SSP + STD + SUR + SVC + SYP + SZL + THB + TJR + TJS + TMM + TMT + TND + TOP + TPE + TRL + TRY + TTD + TWD + TZS + UAH + UAK + UGS + UGX + USD + USN + USS + UYI + UYP + UYU + UZS + VEB + VEF + VND + VNN + VUV + WST + XAF + XAG + XAU + XBA + XBB + XBC + XBD + XCD + XDR + XEU + XFO + XFU + XOF + XPD + XPF + XPT + XRE + XSU + XTS + XUA + XXX + YDD + YER + YUD + YUM + YUN + YUR + ZAL + ZAR + ZMK + ZMW + ZRN + ZRZ + ZWD + ZWL + ZWR +) diff --git a/vendor/github.com/go-playground/locales/cy/cy.go b/vendor/github.com/go-playground/locales/cy/cy.go new file mode 100644 index 0000000000..7b0a20c7f8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cy/cy.go @@ -0,0 +1,661 @@ +package cy + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type cy struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'cy' locale +func New() locales.Translator { + return &cy{ + locale: "cy", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ion", "Chwef", "Maw", "Ebrill", "Mai", "Meh", "Gorff", "Awst", "Medi", "Hyd", "Tach", "Rhag"}, + monthsNarrow: []string{"", "I", "Ch", "M", "E", "M", "M", "G", "A", "M", "H", "T", "Rh"}, + monthsWide: []string{"", "Ionawr", "Chwefror", "Mawrth", "Ebrill", "Mai", "Mehefin", "Gorffennaf", "Awst", "Medi", "Hydref", "Tachwedd", "Rhagfyr"}, + daysAbbreviated: []string{"Sul", "Llun", "Maw", "Mer", "Iau", "Gwen", "Sad"}, + daysNarrow: []string{"S", "Ll", "M", "M", "I", "G", "S"}, + daysShort: []string{"Su", "Ll", "Ma", "Me", "Ia", "Gw", "Sa"}, + daysWide: []string{"Dydd Sul", "Dydd Llun", "Dydd Mawrth", "Dydd Mercher", "Dydd Iau", "Dydd Gwener", "Dydd Sadwrn"}, + periodsAbbreviated: []string{"yb", "yh"}, + periodsNarrow: []string{"b", "h"}, + periodsWide: []string{"yb", "yh"}, + erasAbbreviated: []string{"CC", "OC"}, + erasNarrow: []string{"C", "O"}, + erasWide: []string{"Cyn Crist", "Oed Crist"}, + timezones: map[string]string{"GMT": "Amser Safonol Greenwich", "AWST": "Amser Safonol Gorllewin Awstralia", "MYT": "Amser Malaysia", "CLT": "Amser Safonol Chile", "AKDT": "Amser Haf Alaska", "LHDT": "Amser Haf yr Arglwydd Howe", "HNPMX": "Amser Safonol Pasiffig Mecsico", "∅∅∅": "Amser Haf Amazonas", "HNOG": "Amser Safonol Gorllewin yr Ynys Las", "TMT": "Amser Safonol Tyrcmenistan", "AKST": "Amser Safonol Alaska", "HNPM": "Amser Safonol Saint-Pierre-et-Miquelon", "LHST": "Amser Safonol yr Arglwydd Howe", "WIT": "Amser Dwyrain Indonesia", "JST": "Amser Safonol Siapan", "TMST": "Amser Haf Tyrcmenistan", "ARST": "Amser Haf Ariannin", "EST": "Amser Safonol Dwyrain Gogledd America", "ACST": "Amser Safonol Canolbarth Awstralia", "HEEG": "Amser Haf Dwyrain yr Ynys Las", "NZDT": "Amser Haf Seland Newydd", "MESZ": "Amser Haf Canolbarth Ewrop", "HNEG": "Amser Safonol Dwyrain yr Ynys Las", "BOT": "Amser Bolivia", "WARST": "Amser Haf Gorllewin Ariannin", "MDT": "MDT", "ACDT": "Amser Haf Canolbarth Awstralia", "HNT": "Amser Safonol Newfoundland", "GYT": "Amser Guyana", "WIB": "Amser Gorllewin Indonesia", "OEZ": "Amser Safonol Dwyrain Ewrop", "HKT": "Amser Safonol Hong Kong", "HNNOMX": "Amser Safonol Gogledd Orllewin Mecsico", "GFT": "Amser Guyane Ffrengig", "ECT": "Amser Ecuador", "ACWST": "Amser Safonol Canolbarth Gorllewin Awstralia", "ACWDT": "Amser Haf Canolbarth Gorllewin Awstralia", "MST": "MST", "HENOMX": "Amser Haf Gogledd Orllewin Mecsico", "UYT": "Amser Safonol Uruguay", "CST": "Amser Safonol Canolbarth Gogledd America", "CDT": "Amser Haf Canolbarth Gogledd America", "CHAST": "Amser Safonol Chatham", "JDT": "Amser Haf Siapan", "OESZ": "Amser Haf Dwyrain Ewrop", "WAT": "Amser Safonol Gorllewin Affrica", "SRT": "Amser Suriname", "CHADT": "Amser Haf Chatham", "PST": "Amser Safonol Cefnfor Tawel Gogledd America", "SAST": "Amser Safonol De Affrica", "SGT": "Amser Singapore", "EDT": "Amser Haf Dwyrain Gogledd America", "EAT": "Amser Dwyrain Affrica", "COT": "Amser Safonol Colombia", "AEST": "Amser Safonol Dwyrain Awstralia", "ChST": "Amser Chamorro", "HECU": "Amser Haf Cuba", "HADT": "Amser Haf Hawaii-Aleutian", "CAT": "Amser Canolbarth Affrica", "NZST": "Amser Safonol Seland Newydd", "VET": "Amser Venezuela", "ADT": "Amser Haf Cefnfor yr Iwerydd", "WESZ": "Amser Haf Gorllewin Ewrop", "HKST": "Amser Haf Hong Kong", "HEPMX": "Amser Haf Pasiffig Mecsico", "IST": "Amser India", "WART": "Amser Safonol Gorllewin Ariannin", "WITA": "Amser Canolbarth Indonesia", "AWDT": "Amser Haf Gorllewin Awstralia", "HAST": "Amser Safonol Hawaii-Aleutian", "MEZ": "Amser Safonol Canolbarth Ewrop", "HEOG": "Amser Haf Gorllewin yr Ynys Las", "AST": "Amser Safonol Cefnfor yr Iwerydd", "CLST": "Amser Haf Chile", "ART": "Amser Safonol Ariannin", "COST": "Amser Haf Colombia", "BT": "Amser Bhutan", "HAT": "Amser Haf Newfoundland", "AEDT": "Amser Haf Dwyrain Awstralia", "UYST": "Amser Haf Uruguay", "PDT": "Amser Haf Cefnfor Tawel Gogledd America", "WEZ": "Amser Safonol Gorllewin Ewrop", "WAST": "Amser Haf Gorllewin Affrica", "HEPM": "Amser Haf Saint-Pierre-et-Miquelon", "HNCU": "Amser Safonol Cuba"}, + } +} + +// Locale returns the current translators string locale +func (cy *cy) Locale() string { + return cy.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'cy' +func (cy *cy) PluralsCardinal() []locales.PluralRule { + return cy.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'cy' +func (cy *cy) PluralsOrdinal() []locales.PluralRule { + return cy.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'cy' +func (cy *cy) PluralsRange() []locales.PluralRule { + return cy.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'cy' +func (cy *cy) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 3 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'cy' +func (cy *cy) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 0 || n == 7 || n == 8 || n == 9 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 3 || n == 4 { + return locales.PluralRuleFew + } else if n == 5 || n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'cy' +func (cy *cy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := cy.CardinalPluralRule(num1, v1) + end := cy.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (cy *cy) MonthAbbreviated(month time.Month) string { + return cy.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (cy *cy) MonthsAbbreviated() []string { + return cy.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (cy *cy) MonthNarrow(month time.Month) string { + return cy.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (cy *cy) MonthsNarrow() []string { + return cy.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (cy *cy) MonthWide(month time.Month) string { + return cy.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (cy *cy) MonthsWide() []string { + return cy.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (cy *cy) WeekdayAbbreviated(weekday time.Weekday) string { + return cy.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (cy *cy) WeekdaysAbbreviated() []string { + return cy.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (cy *cy) WeekdayNarrow(weekday time.Weekday) string { + return cy.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (cy *cy) WeekdaysNarrow() []string { + return cy.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (cy *cy) WeekdayShort(weekday time.Weekday) string { + return cy.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (cy *cy) WeekdaysShort() []string { + return cy.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (cy *cy) WeekdayWide(weekday time.Weekday) string { + return cy.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (cy *cy) WeekdaysWide() []string { + return cy.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'cy' and handles both Whole and Real numbers based on 'v' +func (cy *cy) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'cy' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (cy *cy) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cy.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, cy.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'cy' +func (cy *cy) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cy.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, cy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'cy' +// in accounting notation. +func (cy *cy) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cy.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, cy.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, cy.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'cy' +func (cy *cy) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'cy' +func (cy *cy) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cy.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'cy' +func (cy *cy) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'cy' +func (cy *cy) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, cy.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'cy' +func (cy *cy) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'cy' +func (cy *cy) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'cy' +func (cy *cy) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'cy' +func (cy *cy) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := cy.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/cy/cy_test.go b/vendor/github.com/go-playground/locales/cy/cy_test.go new file mode 100644 index 0000000000..feda64d4dd --- /dev/null +++ b/vendor/github.com/go-playground/locales/cy/cy_test.go @@ -0,0 +1,1120 @@ +package cy + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "cy" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/cy_GB/cy_GB.go b/vendor/github.com/go-playground/locales/cy_GB/cy_GB.go new file mode 100644 index 0000000000..b1f4c56c72 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cy_GB/cy_GB.go @@ -0,0 +1,661 @@ +package cy_GB + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type cy_GB struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'cy_GB' locale +func New() locales.Translator { + return &cy_GB{ + locale: "cy_GB", + pluralsCardinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{1, 2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ion", "Chwef", "Maw", "Ebrill", "Mai", "Meh", "Gorff", "Awst", "Medi", "Hyd", "Tach", "Rhag"}, + monthsNarrow: []string{"", "I", "Ch", "M", "E", "M", "M", "G", "A", "M", "H", "T", "Rh"}, + monthsWide: []string{"", "Ionawr", "Chwefror", "Mawrth", "Ebrill", "Mai", "Mehefin", "Gorffennaf", "Awst", "Medi", "Hydref", "Tachwedd", "Rhagfyr"}, + daysAbbreviated: []string{"Sul", "Llun", "Maw", "Mer", "Iau", "Gwen", "Sad"}, + daysNarrow: []string{"S", "Ll", "M", "M", "I", "G", "S"}, + daysShort: []string{"Su", "Ll", "Ma", "Me", "Ia", "Gw", "Sa"}, + daysWide: []string{"Dydd Sul", "Dydd Llun", "Dydd Mawrth", "Dydd Mercher", "Dydd Iau", "Dydd Gwener", "Dydd Sadwrn"}, + periodsAbbreviated: []string{"yb", "yh"}, + periodsNarrow: []string{"b", "h"}, + periodsWide: []string{"yb", "yh"}, + erasAbbreviated: []string{"CC", "OC"}, + erasNarrow: []string{"C", "O"}, + erasWide: []string{"Cyn Crist", "Oed Crist"}, + timezones: map[string]string{"MEZ": "Amser Safonol Canolbarth Ewrop", "WARST": "Amser Haf Gorllewin Ariannin", "SRT": "Amser Suriname", "HENOMX": "Amser Haf Gogledd Orllewin Mecsico", "AEDT": "Amser Haf Dwyrain Awstralia", "GYT": "Amser Guyana", "CHAST": "Amser Safonol Chatham", "NZDT": "Amser Haf Seland Newydd", "ACWDT": "Amser Haf Canolbarth Gorllewin Awstralia", "MESZ": "Amser Haf Canolbarth Ewrop", "CLT": "Amser Safonol Chile", "ChST": "Amser Chamorro", "UYT": "Amser Safonol Uruguay", "AWST": "Amser Safonol Gorllewin Awstralia", "AWDT": "Amser Haf Gorllewin Awstralia", "HAST": "Amser Safonol Hawaii-Aleutian", "WAT": "Amser Safonol Gorllewin Affrica", "HNT": "Amser Safonol Newfoundland", "AKST": "Amser Safonol Alaska", "AST": "Amser Safonol Cefnfor yr Iwerydd", "ADT": "Amser Haf Cefnfor yr Iwerydd", "MST": "MST", "PST": "Amser Safonol Cefnfor Tawel Gogledd America", "OEZ": "Amser Safonol Dwyrain Ewrop", "WESZ": "Amser Haf Gorllewin Ewrop", "ACST": "Amser Safonol Canolbarth Awstralia", "AEST": "Amser Safonol Dwyrain Awstralia", "EAT": "Amser Dwyrain Affrica", "HNOG": "Amser Safonol Gorllewin yr Ynys Las", "EST": "Amser Safonol Dwyrain Gogledd America", "GFT": "Amser Guyane Ffrengig", "PDT": "Amser Haf Cefnfor Tawel Gogledd America", "ACDT": "Amser Haf Canolbarth Awstralia", "HNPM": "Amser Safonol Saint-Pierre-et-Miquelon", "CDT": "Amser Haf Canolbarth Gogledd America", "ECT": "Amser Ecuador", "HNPMX": "Amser Safonol Pasiffig Mecsico", "HNCU": "Amser Safonol Cuba", "CST": "Amser Safonol Canolbarth Gogledd America", "ACWST": "Amser Safonol Canolbarth Gorllewin Awstralia", "ARST": "Amser Haf Ariannin", "HEEG": "Amser Haf Dwyrain yr Ynys Las", "JDT": "Amser Haf Siapan", "CLST": "Amser Haf Chile", "ART": "Amser Safonol Ariannin", "COT": "Amser Safonol Colombia", "COST": "Amser Haf Colombia", "∅∅∅": "Amser Haf Brasília", "SGT": "Amser Singapore", "BOT": "Amser Bolivia", "WEZ": "Amser Safonol Gorllewin Ewrop", "LHST": "Amser Safonol yr Arglwydd Howe", "MDT": "MDT", "HAT": "Amser Haf Newfoundland", "WIT": "Amser Dwyrain Indonesia", "MYT": "Amser Malaysia", "WART": "Amser Safonol Gorllewin Ariannin", "HEOG": "Amser Haf Gorllewin yr Ynys Las", "TMT": "Amser Safonol Tyrcmenistan", "TMST": "Amser Haf Tyrcmenistan", "WITA": "Amser Canolbarth Indonesia", "HEPMX": "Amser Haf Pasiffig Mecsico", "LHDT": "Amser Haf yr Arglwydd Howe", "HECU": "Amser Haf Cuba", "CHADT": "Amser Haf Chatham", "IST": "Amser India", "WAST": "Amser Haf Gorllewin Affrica", "BT": "Amser Bhutan", "HEPM": "Amser Haf Saint-Pierre-et-Miquelon", "HADT": "Amser Haf Hawaii-Aleutian", "NZST": "Amser Safonol Seland Newydd", "OESZ": "Amser Haf Dwyrain Ewrop", "CAT": "Amser Canolbarth Affrica", "VET": "Amser Venezuela", "GMT": "Amser Safonol Greenwich", "HKT": "Amser Safonol Hong Kong", "AKDT": "Amser Haf Alaska", "UYST": "Amser Haf Uruguay", "WIB": "Amser Gorllewin Indonesia", "JST": "Amser Safonol Siapan", "EDT": "Amser Haf Dwyrain Gogledd America", "HKST": "Amser Haf Hong Kong", "HNNOMX": "Amser Safonol Gogledd Orllewin Mecsico", "HNEG": "Amser Safonol Dwyrain yr Ynys Las", "SAST": "Amser Safonol De Affrica"}, + } +} + +// Locale returns the current translators string locale +func (cy *cy_GB) Locale() string { + return cy.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'cy_GB' +func (cy *cy_GB) PluralsCardinal() []locales.PluralRule { + return cy.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'cy_GB' +func (cy *cy_GB) PluralsOrdinal() []locales.PluralRule { + return cy.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'cy_GB' +func (cy *cy_GB) PluralsRange() []locales.PluralRule { + return cy.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'cy_GB' +func (cy *cy_GB) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 3 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'cy_GB' +func (cy *cy_GB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 0 || n == 7 || n == 8 || n == 9 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n == 3 || n == 4 { + return locales.PluralRuleFew + } else if n == 5 || n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'cy_GB' +func (cy *cy_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := cy.CardinalPluralRule(num1, v1) + end := cy.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleZero && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleZero && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleZero && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (cy *cy_GB) MonthAbbreviated(month time.Month) string { + return cy.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (cy *cy_GB) MonthsAbbreviated() []string { + return cy.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (cy *cy_GB) MonthNarrow(month time.Month) string { + return cy.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (cy *cy_GB) MonthsNarrow() []string { + return cy.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (cy *cy_GB) MonthWide(month time.Month) string { + return cy.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (cy *cy_GB) MonthsWide() []string { + return cy.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (cy *cy_GB) WeekdayAbbreviated(weekday time.Weekday) string { + return cy.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (cy *cy_GB) WeekdaysAbbreviated() []string { + return cy.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (cy *cy_GB) WeekdayNarrow(weekday time.Weekday) string { + return cy.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (cy *cy_GB) WeekdaysNarrow() []string { + return cy.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (cy *cy_GB) WeekdayShort(weekday time.Weekday) string { + return cy.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (cy *cy_GB) WeekdaysShort() []string { + return cy.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (cy *cy_GB) WeekdayWide(weekday time.Weekday) string { + return cy.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (cy *cy_GB) WeekdaysWide() []string { + return cy.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'cy_GB' and handles both Whole and Real numbers based on 'v' +func (cy *cy_GB) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'cy_GB' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (cy *cy_GB) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cy.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, cy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, cy.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'cy_GB' +func (cy *cy_GB) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cy.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, cy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'cy_GB' +// in accounting notation. +func (cy *cy_GB) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := cy.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, cy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, cy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, cy.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, cy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, cy.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'cy_GB' +func (cy *cy_GB) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'cy_GB' +func (cy *cy_GB) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cy.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'cy_GB' +func (cy *cy_GB) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'cy_GB' +func (cy *cy_GB) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, cy.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, cy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'cy_GB' +func (cy *cy_GB) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'cy_GB' +func (cy *cy_GB) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'cy_GB' +func (cy *cy_GB) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'cy_GB' +func (cy *cy_GB) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, cy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, cy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := cy.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/cy_GB/cy_GB_test.go b/vendor/github.com/go-playground/locales/cy_GB/cy_GB_test.go new file mode 100644 index 0000000000..2689e07ea1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/cy_GB/cy_GB_test.go @@ -0,0 +1,1120 @@ +package cy_GB + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "cy_GB" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/da/da.go b/vendor/github.com/go-playground/locales/da/da.go new file mode 100644 index 0000000000..459f0194f1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/da/da.go @@ -0,0 +1,608 @@ +package da + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type da struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'da' locale +func New() locales.Translator { + return &da{ + locale: "da", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "kr.", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"søn.", "man.", "tir.", "ons.", "tor.", "fre.", "lør."}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sø", "ma", "ti", "on", "to", "fr", "lø"}, + daysWide: []string{"søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"fKr", "eKr"}, + erasWide: []string{"f.Kr.", "e.Kr."}, + timezones: map[string]string{"HAST": "Hawaii-Aleutian-normaltid", "CAT": "Centralafrikansk tid", "MYT": "Malaysisk tid", "COST": "Colombiansk sommertid", "SAST": "Sydafrikansk tid", "WIT": "Østindonesisk tid", "HNPMX": "Mexicansk Pacific-normaltid", "AWDT": "Vestaustralsk sommertid", "CLT": "Chilensk normaltid", "ACST": "Centralaustralsk normaltid", "COT": "Colombiansk normaltid", "WITA": "Centralindonesisk tid", "UYST": "Uruguayansk sommertid", "VET": "Venezuelansk tid", "TMST": "Turkmensk sommertid", "HNT": "Newfoundlandsk normaltid", "HNCU": "Cubansk normaltid", "CST": "Central-normaltid", "PST": "Pacific-normaltid", "HADT": "Hawaii-Aleutian-sommertid", "HKT": "Hongkong-normaltid", "BOT": "Boliviansk tid", "ACWST": "Vestlig centralaustralsk normaltid", "OESZ": "Østeuropæisk sommertid", "HKST": "Hongkong-sommertid", "LHDT": "Lord Howe-sommertid", "EAT": "Østafrikansk tid", "AEDT": "Østaustralsk sommertid", "UYT": "Uruguayansk normaltid", "ECT": "Ecuadoriansk tid", "∅∅∅": "Amazonas-sommertid", "WART": "Vestargentinsk normaltid", "MST": "Macao-normaltid", "ARST": "Argentinsk sommertid", "HEEG": "Østgrønlandsk sommertid", "WIB": "Vestindonesisk tid", "IST": "Indisk normaltid", "ACWDT": "Vestlig centralaustralsk sommertid", "AST": "Atlantic-normaltid", "WAT": "Vestafrikansk normaltid", "BT": "Bhutanesisk tid", "GFT": "Fransk Guyana-tid", "HEPMX": "Mexicansk Pacific-sommertid", "AWST": "Vestaustralsk normaltid", "NZST": "Newzealandsk normaltid", "ADT": "Atlantic-sommertid", "ACDT": "Centralaustralsk sommertid", "HNNOMX": "Nordvestmexicansk normaltid", "HENOMX": "Nordvestmexicansk sommertid", "HECU": "Cubansk sommertid", "CHADT": "Chatham-sommertid", "MEZ": "Centraleuropæisk normaltid", "WEZ": "Vesteuropæisk normaltid", "LHST": "Lord Howe-normaltid", "CDT": "Central-sommertid", "CHAST": "Chatham-normaltid", "SGT": "Singaporeansk normaltid", "PDT": "Pacific-sommertid", "OEZ": "Østeuropæisk normaltid", "WARST": "Vestargentinsk sommertid", "EDT": "Eastern-sommertid", "HNEG": "Østgrønlandsk normaltid", "AKST": "Alaska-normaltid", "SRT": "Surinam-tid", "HEOG": "Vestgrønlandsk sommertid", "WAST": "Vestafrikansk sommertid", "EST": "Eastern-normaltid", "HAT": "Newfoundlandsk sommertid", "AKDT": "Alaska-sommertid", "HEPM": "Saint Pierre- og Miquelon-sommertid", "ART": "Argentinsk normaltid", "GYT": "Guyana-tid", "MDT": "Macao-sommertid", "ChST": "Chamorro-tid", "JDT": "Japansk sommertid", "HNOG": "Vestgrønlandsk normaltid", "WESZ": "Vesteuropæisk sommertid", "GMT": "GMT", "CLST": "Chilensk sommertid", "TMT": "Turkmensk normaltid", "NZDT": "Newzealandsk sommertid", "MESZ": "Centraleuropæisk sommertid", "JST": "Japansk normaltid", "AEST": "Østaustralsk normaltid", "HNPM": "Saint Pierre- og Miquelon-normaltid"}, + } +} + +// Locale returns the current translators string locale +func (da *da) Locale() string { + return da.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'da' +func (da *da) PluralsCardinal() []locales.PluralRule { + return da.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'da' +func (da *da) PluralsOrdinal() []locales.PluralRule { + return da.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'da' +func (da *da) PluralsRange() []locales.PluralRule { + return da.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'da' +func (da *da) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) + + if (n == 1) || (t != 0 && (i == 0 || i == 1)) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'da' +func (da *da) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'da' +func (da *da) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := da.CardinalPluralRule(num1, v1) + end := da.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (da *da) MonthAbbreviated(month time.Month) string { + return da.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (da *da) MonthsAbbreviated() []string { + return da.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (da *da) MonthNarrow(month time.Month) string { + return da.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (da *da) MonthsNarrow() []string { + return da.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (da *da) MonthWide(month time.Month) string { + return da.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (da *da) MonthsWide() []string { + return da.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (da *da) WeekdayAbbreviated(weekday time.Weekday) string { + return da.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (da *da) WeekdaysAbbreviated() []string { + return da.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (da *da) WeekdayNarrow(weekday time.Weekday) string { + return da.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (da *da) WeekdaysNarrow() []string { + return da.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (da *da) WeekdayShort(weekday time.Weekday) string { + return da.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (da *da) WeekdaysShort() []string { + return da.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (da *da) WeekdayWide(weekday time.Weekday) string { + return da.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (da *da) WeekdaysWide() []string { + return da.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'da' and handles both Whole and Real numbers based on 'v' +func (da *da) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'da' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (da *da) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, da.percentSuffix...) + + b = append(b, da.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'da' +func (da *da) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := da.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, da.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, da.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'da' +// in accounting notation. +func (da *da) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := da.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, da.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, da.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, da.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, da.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'da' +func (da *da) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'da' +func (da *da) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'da' +func (da *da) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'da' +func (da *da) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, da.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0x64, 0x65, 0x6e}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'da' +func (da *da) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'da' +func (da *da) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'da' +func (da *da) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'da' +func (da *da) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := da.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/da/da_test.go b/vendor/github.com/go-playground/locales/da/da_test.go new file mode 100644 index 0000000000..26437b21a7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/da/da_test.go @@ -0,0 +1,1120 @@ +package da + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "da" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/da_DK/da_DK.go b/vendor/github.com/go-playground/locales/da_DK/da_DK.go new file mode 100644 index 0000000000..9c5639878c --- /dev/null +++ b/vendor/github.com/go-playground/locales/da_DK/da_DK.go @@ -0,0 +1,608 @@ +package da_DK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type da_DK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'da_DK' locale +func New() locales.Translator { + return &da_DK{ + locale: "da_DK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"søn.", "man.", "tir.", "ons.", "tor.", "fre.", "lør."}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sø", "ma", "ti", "on", "to", "fr", "lø"}, + daysWide: []string{"søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"fKr", "eKr"}, + erasWide: []string{"f.Kr.", "e.Kr."}, + timezones: map[string]string{"TMST": "Turkmensk sommertid", "WITA": "Centralindonesisk tid", "HEPM": "Saint Pierre- og Miquelon-sommertid", "CST": "Central-normaltid", "MESZ": "Centraleuropæisk sommertid", "CLT": "Chilensk normaltid", "CHADT": "Chatham-sommertid", "NZDT": "Newzealandsk sommertid", "MEZ": "Centraleuropæisk normaltid", "COST": "Colombiansk sommertid", "SRT": "Surinam-tid", "HECU": "Cubansk sommertid", "AWDT": "Vestaustralsk sommertid", "ACWDT": "Vestlig centralaustralsk sommertid", "HKST": "Hongkong-sommertid", "AKDT": "Alaska-sommertid", "PDT": "Pacific-sommertid", "IST": "Indisk normaltid", "EDT": "Eastern-sommertid", "WARST": "Vestargentinsk sommertid", "HNT": "Newfoundlandsk normaltid", "SAST": "Sydafrikansk tid", "PST": "Pacific-normaltid", "HADT": "Hawaii-Aleutian-sommertid", "HEOG": "Vestgrønlandsk sommertid", "WEZ": "Vesteuropæisk normaltid", "HNCU": "Cubansk normaltid", "AWST": "Vestaustralsk normaltid", "CHAST": "Chatham-normaltid", "ECT": "Ecuadoriansk tid", "HNPM": "Saint Pierre- og Miquelon-normaltid", "CDT": "Central-sommertid", "ADT": "Atlantic-sommertid", "HKT": "Hongkong-normaltid", "HNOG": "Vestgrønlandsk normaltid", "OEZ": "Østeuropæisk normaltid", "ACDT": "Centralaustralsk sommertid", "HENOMX": "Nordvestmexicansk sommertid", "AEST": "Østaustralsk normaltid", "ChST": "Chamorro-tid", "LHDT": "Lord Howe-sommertid", "∅∅∅": "Azorerne-sommertid", "WAT": "Vestafrikansk normaltid", "WAST": "Vestafrikansk sommertid", "UYT": "Uruguayansk normaltid", "UYST": "Uruguayansk sommertid", "EAT": "Østafrikansk tid", "WIB": "Vestindonesisk tid", "AST": "Atlantic-normaltid", "GYT": "Guyana-tid", "SGT": "Singaporeansk normaltid", "WESZ": "Vesteuropæisk sommertid", "TMT": "Turkmensk normaltid", "HEEG": "Østgrønlandsk sommertid", "COT": "Colombiansk normaltid", "GFT": "Fransk Guyana-tid", "MST": "Mountain-normaltid", "VET": "Venezuelansk tid", "EST": "Eastern-normaltid", "ACST": "Centralaustralsk normaltid", "HNEG": "Østgrønlandsk normaltid", "MDT": "Mountain-sommertid", "GMT": "GMT", "MYT": "Malaysisk tid", "HNNOMX": "Nordvestmexicansk normaltid", "HAT": "Newfoundlandsk sommertid", "CLST": "Chilensk sommertid", "OESZ": "Østeuropæisk sommertid", "ART": "Argentinsk normaltid", "LHST": "Lord Howe-normaltid", "HEPMX": "Mexicansk Pacific-sommertid", "BOT": "Boliviansk tid", "ACWST": "Vestlig centralaustralsk normaltid", "JST": "Japansk normaltid", "AKST": "Alaska-normaltid", "AEDT": "Østaustralsk sommertid", "NZST": "Newzealandsk normaltid", "ARST": "Argentinsk sommertid", "WART": "Vestargentinsk normaltid", "BT": "Bhutanesisk tid", "HNPMX": "Mexicansk Pacific-normaltid", "WIT": "Østindonesisk tid", "HAST": "Hawaii-Aleutian-normaltid", "CAT": "Centralafrikansk tid", "JDT": "Japansk sommertid"}, + } +} + +// Locale returns the current translators string locale +func (da *da_DK) Locale() string { + return da.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'da_DK' +func (da *da_DK) PluralsCardinal() []locales.PluralRule { + return da.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'da_DK' +func (da *da_DK) PluralsOrdinal() []locales.PluralRule { + return da.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'da_DK' +func (da *da_DK) PluralsRange() []locales.PluralRule { + return da.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'da_DK' +func (da *da_DK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) + + if (n == 1) || (t != 0 && (i == 0 || i == 1)) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'da_DK' +func (da *da_DK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'da_DK' +func (da *da_DK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := da.CardinalPluralRule(num1, v1) + end := da.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (da *da_DK) MonthAbbreviated(month time.Month) string { + return da.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (da *da_DK) MonthsAbbreviated() []string { + return da.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (da *da_DK) MonthNarrow(month time.Month) string { + return da.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (da *da_DK) MonthsNarrow() []string { + return da.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (da *da_DK) MonthWide(month time.Month) string { + return da.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (da *da_DK) MonthsWide() []string { + return da.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (da *da_DK) WeekdayAbbreviated(weekday time.Weekday) string { + return da.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (da *da_DK) WeekdaysAbbreviated() []string { + return da.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (da *da_DK) WeekdayNarrow(weekday time.Weekday) string { + return da.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (da *da_DK) WeekdaysNarrow() []string { + return da.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (da *da_DK) WeekdayShort(weekday time.Weekday) string { + return da.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (da *da_DK) WeekdaysShort() []string { + return da.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (da *da_DK) WeekdayWide(weekday time.Weekday) string { + return da.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (da *da_DK) WeekdaysWide() []string { + return da.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'da_DK' and handles both Whole and Real numbers based on 'v' +func (da *da_DK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'da_DK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (da *da_DK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, da.percentSuffix...) + + b = append(b, da.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'da_DK' +func (da *da_DK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := da.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, da.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, da.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'da_DK' +// in accounting notation. +func (da *da_DK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := da.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, da.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, da.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, da.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, da.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'da_DK' +func (da *da_DK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'da_DK' +func (da *da_DK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'da_DK' +func (da *da_DK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'da_DK' +func (da *da_DK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, da.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0x64, 0x65, 0x6e}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'da_DK' +func (da *da_DK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'da_DK' +func (da *da_DK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'da_DK' +func (da *da_DK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'da_DK' +func (da *da_DK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := da.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/da_DK/da_DK_test.go b/vendor/github.com/go-playground/locales/da_DK/da_DK_test.go new file mode 100644 index 0000000000..71ed28d7cc --- /dev/null +++ b/vendor/github.com/go-playground/locales/da_DK/da_DK_test.go @@ -0,0 +1,1120 @@ +package da_DK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "da_DK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/da_GL/da_GL.go b/vendor/github.com/go-playground/locales/da_GL/da_GL.go new file mode 100644 index 0000000000..d58391a002 --- /dev/null +++ b/vendor/github.com/go-playground/locales/da_GL/da_GL.go @@ -0,0 +1,646 @@ +package da_GL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type da_GL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'da_GL' locale +func New() locales.Translator { + return &da_GL{ + locale: "da_GL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"søn.", "man.", "tir.", "ons.", "tor.", "fre.", "lør."}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sø", "ma", "ti", "on", "to", "fr", "lø"}, + daysWide: []string{"søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"fKr", "eKr"}, + erasWide: []string{"f.Kr.", "e.Kr."}, + timezones: map[string]string{"HNEG": "Østgrønlandsk normaltid", "AEST": "Østaustralsk normaltid", "NZDT": "Newzealandsk sommertid", "WAST": "Vestafrikansk sommertid", "HEOG": "Vestgrønlandsk sommertid", "OESZ": "Østeuropæisk sommertid", "HKST": "Hongkong-sommertid", "HEPM": "Saint Pierre- og Miquelon-sommertid", "PDT": "Pacific-sommertid", "HADT": "Hawaii-Aleutian-sommertid", "ACDT": "Centralaustralsk sommertid", "LHST": "Lord Howe-normaltid", "IST": "Indisk normaltid", "WEZ": "Vesteuropæisk normaltid", "WART": "Vestargentinsk normaltid", "LHDT": "Lord Howe-sommertid", "GMT": "GMT", "MYT": "Malaysisk tid", "CLT": "Chilensk normaltid", "CLST": "Chilensk sommertid", "AST": "Atlantic-normaltid", "WARST": "Vestargentinsk sommertid", "EDT": "Eastern-sommertid", "UYT": "Uruguayansk normaltid", "WIB": "Vestindonesisk tid", "∅∅∅": "Brasiliansk sommertid", "HAST": "Hawaii-Aleutian-normaltid", "MST": "Macao-normaltid", "CST": "Central-normaltid", "BOT": "Boliviansk tid", "JST": "Japansk normaltid", "OEZ": "Østeuropæisk normaltid", "HEPMX": "Mexicansk Pacific-sommertid", "SRT": "Surinam-tid", "ACWST": "Vestlig centralaustralsk normaltid", "VET": "Venezuelansk tid", "CHADT": "Chatham-sommertid", "PST": "Pacific-normaltid", "MESZ": "Centraleuropæisk sommertid", "TMT": "Turkmensk normaltid", "HNNOMX": "Nordvestmexicansk normaltid", "HENOMX": "Nordvestmexicansk sommertid", "EAT": "Østafrikansk tid", "AWDT": "Vestaustralsk sommertid", "AEDT": "Østaustralsk sommertid", "BT": "Bhutanesisk tid", "AKST": "Alaska-normaltid", "SAST": "Sydafrikansk tid", "WITA": "Centralindonesisk tid", "UYST": "Uruguayansk sommertid", "MDT": "Macao-sommertid", "HKT": "Hongkong-normaltid", "GFT": "Fransk Guyana-tid", "GYT": "Guyana-tid", "CHAST": "Chatham-normaltid", "HNOG": "Vestgrønlandsk normaltid", "COT": "Colombiansk normaltid", "HNT": "Newfoundlandsk normaltid", "HNPM": "Saint Pierre- og Miquelon-normaltid", "MEZ": "Centraleuropæisk normaltid", "JDT": "Japansk sommertid", "SGT": "Singaporeansk normaltid", "HEEG": "Østgrønlandsk sommertid", "TMST": "Turkmensk sommertid", "HECU": "Cubansk sommertid", "WESZ": "Vesteuropæisk sommertid", "NZST": "Newzealandsk normaltid", "ADT": "Atlantic-sommertid", "ART": "Argentinsk normaltid", "ACST": "Centralaustralsk normaltid", "HNCU": "Cubansk normaltid", "CDT": "Central-sommertid", "ACWDT": "Vestlig centralaustralsk sommertid", "WAT": "Vestafrikansk normaltid", "EST": "Eastern-normaltid", "ChST": "Chamorro-tid", "HNPMX": "Mexicansk Pacific-normaltid", "WIT": "Østindonesisk tid", "ECT": "Ecuadoriansk tid", "ARST": "Argentinsk sommertid", "COST": "Colombiansk sommertid", "HAT": "Newfoundlandsk sommertid", "AKDT": "Alaska-sommertid", "AWST": "Vestaustralsk normaltid", "CAT": "Centralafrikansk tid"}, + } +} + +// Locale returns the current translators string locale +func (da *da_GL) Locale() string { + return da.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'da_GL' +func (da *da_GL) PluralsCardinal() []locales.PluralRule { + return da.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'da_GL' +func (da *da_GL) PluralsOrdinal() []locales.PluralRule { + return da.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'da_GL' +func (da *da_GL) PluralsRange() []locales.PluralRule { + return da.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'da_GL' +func (da *da_GL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) + + if (n == 1) || (t != 0 && (i == 0 || i == 1)) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'da_GL' +func (da *da_GL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'da_GL' +func (da *da_GL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := da.CardinalPluralRule(num1, v1) + end := da.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (da *da_GL) MonthAbbreviated(month time.Month) string { + return da.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (da *da_GL) MonthsAbbreviated() []string { + return da.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (da *da_GL) MonthNarrow(month time.Month) string { + return da.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (da *da_GL) MonthsNarrow() []string { + return da.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (da *da_GL) MonthWide(month time.Month) string { + return da.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (da *da_GL) MonthsWide() []string { + return da.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (da *da_GL) WeekdayAbbreviated(weekday time.Weekday) string { + return da.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (da *da_GL) WeekdaysAbbreviated() []string { + return da.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (da *da_GL) WeekdayNarrow(weekday time.Weekday) string { + return da.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (da *da_GL) WeekdaysNarrow() []string { + return da.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (da *da_GL) WeekdayShort(weekday time.Weekday) string { + return da.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (da *da_GL) WeekdaysShort() []string { + return da.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (da *da_GL) WeekdayWide(weekday time.Weekday) string { + return da.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (da *da_GL) WeekdaysWide() []string { + return da.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'da_GL' and handles both Whole and Real numbers based on 'v' +func (da *da_GL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'da_GL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (da *da_GL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, da.percentSuffix...) + + b = append(b, da.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'da_GL' +func (da *da_GL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := da.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, da.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, da.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, da.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'da_GL' +// in accounting notation. +func (da *da_GL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := da.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, da.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, da.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, da.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, da.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, da.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, da.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'da_GL' +func (da *da_GL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'da_GL' +func (da *da_GL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'da_GL' +func (da *da_GL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'da_GL' +func (da *da_GL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, da.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0x64, 0x65, 0x6e}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, da.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'da_GL' +func (da *da_GL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, da.periodsAbbreviated[0]...) + } else { + b = append(b, da.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'da_GL' +func (da *da_GL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, da.periodsAbbreviated[0]...) + } else { + b = append(b, da.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'da_GL' +func (da *da_GL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, da.periodsAbbreviated[0]...) + } else { + b = append(b, da.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'da_GL' +func (da *da_GL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, da.periodsAbbreviated[0]...) + } else { + b = append(b, da.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := da.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/da_GL/da_GL_test.go b/vendor/github.com/go-playground/locales/da_GL/da_GL_test.go new file mode 100644 index 0000000000..b5d1ee8add --- /dev/null +++ b/vendor/github.com/go-playground/locales/da_GL/da_GL_test.go @@ -0,0 +1,1120 @@ +package da_GL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "da_GL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dav/dav.go b/vendor/github.com/go-playground/locales/dav/dav.go new file mode 100644 index 0000000000..af4804e120 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dav/dav.go @@ -0,0 +1,518 @@ +package dav + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dav struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dav' locale +func New() locales.Translator { + return &dav{ + locale: "dav", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Imb", "Kaw", "Kad", "Kan", "Kas", "Kar", "Mfu", "Wun", "Ike", "Iku", "Imw", "Iwi"}, + monthsNarrow: []string{"", "I", "K", "K", "K", "K", "K", "M", "W", "I", "I", "I", "I"}, + monthsWide: []string{"", "Mori ghwa imbiri", "Mori ghwa kawi", "Mori ghwa kadadu", "Mori ghwa kana", "Mori ghwa kasanu", "Mori ghwa karandadu", "Mori ghwa mfungade", "Mori ghwa wunyanya", "Mori ghwa ikenda", "Mori ghwa ikumi", "Mori ghwa ikumi na imweri", "Mori ghwa ikumi na iwi"}, + daysAbbreviated: []string{"Jum", "Jim", "Kaw", "Kad", "Kan", "Kas", "Ngu"}, + daysNarrow: []string{"J", "J", "K", "K", "K", "K", "N"}, + daysWide: []string{"Ituku ja jumwa", "Kuramuka jimweri", "Kuramuka kawi", "Kuramuka kadadu", "Kuramuka kana", "Kuramuka kasanu", "Kifula nguwo"}, + periodsAbbreviated: []string{"Luma lwa K", "luma lwa p"}, + periodsWide: []string{"Luma lwa K", "luma lwa p"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristo", "Baada ya Kristo"}, + timezones: map[string]string{"SAST": "SAST", "WESZ": "WESZ", "MST": "MST", "EDT": "EDT", "BT": "BT", "HAT": "HAT", "GFT": "GFT", "HNCU": "HNCU", "HAST": "HAST", "HEPMX": "HEPMX", "SRT": "SRT", "AKDT": "AKDT", "LHDT": "LHDT", "GYT": "GYT", "CHAST": "CHAST", "ACWDT": "ACWDT", "PDT": "PDT", "ACWST": "ACWST", "GMT": "GMT", "TMT": "TMT", "WAT": "WAT", "ACDT": "ACDT", "HECU": "HECU", "SGT": "SGT", "AEDT": "AEDT", "AKST": "AKST", "OEZ": "OEZ", "ART": "ART", "HKST": "HKST", "WITA": "WITA", "HNPM": "HNPM", "CDT": "CDT", "NZST": "NZST", "ARST": "ARST", "TMST": "TMST", "MDT": "MDT", "ACST": "ACST", "HEPM": "HEPM", "UYT": "UYT", "UYST": "UYST", "VET": "VET", "MYT": "MYT", "PST": "PST", "WIT": "WIT", "HADT": "HADT", "ECT": "ECT", "JDT": "JDT", "WART": "WART", "WIB": "WIB", "∅∅∅": "∅∅∅", "MESZ": "MESZ", "EST": "EST", "HNNOMX": "HNNOMX", "NZDT": "NZDT", "CAT": "CAT", "ChST": "ChST", "LHST": "LHST", "OESZ": "OESZ", "WAST": "WAST", "CHADT": "CHADT", "HEOG": "HEOG", "JST": "JST", "WEZ": "WEZ", "AST": "AST", "HKT": "HKT", "HENOMX": "HENOMX", "CST": "CST", "AWST": "AWST", "HNOG": "HNOG", "COST": "COST", "MEZ": "MEZ", "WARST": "WARST", "IST": "IST", "CLT": "CLT", "ADT": "ADT", "COT": "COT", "AEST": "AEST", "AWDT": "AWDT", "BOT": "BOT", "HNEG": "HNEG", "HEEG": "HEEG", "HNT": "HNT", "HNPMX": "HNPMX", "EAT": "EAT", "CLST": "CLST"}, + } +} + +// Locale returns the current translators string locale +func (dav *dav) Locale() string { + return dav.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dav' +func (dav *dav) PluralsCardinal() []locales.PluralRule { + return dav.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dav' +func (dav *dav) PluralsOrdinal() []locales.PluralRule { + return dav.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dav' +func (dav *dav) PluralsRange() []locales.PluralRule { + return dav.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dav' +func (dav *dav) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dav' +func (dav *dav) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dav' +func (dav *dav) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dav *dav) MonthAbbreviated(month time.Month) string { + return dav.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dav *dav) MonthsAbbreviated() []string { + return dav.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dav *dav) MonthNarrow(month time.Month) string { + return dav.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dav *dav) MonthsNarrow() []string { + return dav.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dav *dav) MonthWide(month time.Month) string { + return dav.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dav *dav) MonthsWide() []string { + return dav.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dav *dav) WeekdayAbbreviated(weekday time.Weekday) string { + return dav.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dav *dav) WeekdaysAbbreviated() []string { + return dav.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dav *dav) WeekdayNarrow(weekday time.Weekday) string { + return dav.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dav *dav) WeekdaysNarrow() []string { + return dav.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dav *dav) WeekdayShort(weekday time.Weekday) string { + return dav.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dav *dav) WeekdaysShort() []string { + return dav.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dav *dav) WeekdayWide(weekday time.Weekday) string { + return dav.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dav *dav) WeekdaysWide() []string { + return dav.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dav' and handles both Whole and Real numbers based on 'v' +func (dav *dav) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dav' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dav *dav) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dav' +func (dav *dav) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dav.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dav.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, dav.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dav.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dav' +// in accounting notation. +func (dav *dav) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dav.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dav.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, dav.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dav.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, dav.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dav' +func (dav *dav) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dav' +func (dav *dav) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dav.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dav' +func (dav *dav) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dav.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dav' +func (dav *dav) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dav.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dav.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dav' +func (dav *dav) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dav' +func (dav *dav) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dav' +func (dav *dav) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dav' +func (dav *dav) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dav.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dav/dav_test.go b/vendor/github.com/go-playground/locales/dav/dav_test.go new file mode 100644 index 0000000000..ad597b3f03 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dav/dav_test.go @@ -0,0 +1,1120 @@ +package dav + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dav" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dav_KE/dav_KE.go b/vendor/github.com/go-playground/locales/dav_KE/dav_KE.go new file mode 100644 index 0000000000..6fb4227dee --- /dev/null +++ b/vendor/github.com/go-playground/locales/dav_KE/dav_KE.go @@ -0,0 +1,518 @@ +package dav_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dav_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dav_KE' locale +func New() locales.Translator { + return &dav_KE{ + locale: "dav_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Imb", "Kaw", "Kad", "Kan", "Kas", "Kar", "Mfu", "Wun", "Ike", "Iku", "Imw", "Iwi"}, + monthsNarrow: []string{"", "I", "K", "K", "K", "K", "K", "M", "W", "I", "I", "I", "I"}, + monthsWide: []string{"", "Mori ghwa imbiri", "Mori ghwa kawi", "Mori ghwa kadadu", "Mori ghwa kana", "Mori ghwa kasanu", "Mori ghwa karandadu", "Mori ghwa mfungade", "Mori ghwa wunyanya", "Mori ghwa ikenda", "Mori ghwa ikumi", "Mori ghwa ikumi na imweri", "Mori ghwa ikumi na iwi"}, + daysAbbreviated: []string{"Jum", "Jim", "Kaw", "Kad", "Kan", "Kas", "Ngu"}, + daysNarrow: []string{"J", "J", "K", "K", "K", "K", "N"}, + daysWide: []string{"Ituku ja jumwa", "Kuramuka jimweri", "Kuramuka kawi", "Kuramuka kadadu", "Kuramuka kana", "Kuramuka kasanu", "Kifula nguwo"}, + periodsAbbreviated: []string{"Luma lwa K", "luma lwa p"}, + periodsWide: []string{"Luma lwa K", "luma lwa p"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristo", "Baada ya Kristo"}, + timezones: map[string]string{"WITA": "WITA", "HNPM": "HNPM", "WIT": "WIT", "WART": "WART", "HKT": "HKT", "HNNOMX": "HNNOMX", "AKST": "AKST", "UYT": "UYT", "WIB": "WIB", "AWST": "AWST", "ACWST": "ACWST", "TMST": "TMST", "ART": "ART", "HNT": "HNT", "MDT": "MDT", "HEPMX": "HEPMX", "HNOG": "HNOG", "EST": "EST", "HAT": "HAT", "GFT": "GFT", "LHST": "LHST", "EAT": "EAT", "HNCU": "HNCU", "NZDT": "NZDT", "HEOG": "HEOG", "AEDT": "AEDT", "GMT": "GMT", "AEST": "AEST", "HECU": "HECU", "VET": "VET", "MST": "MST", "HNPMX": "HNPMX", "CLT": "CLT", "CLST": "CLST", "∅∅∅": "∅∅∅", "AWDT": "AWDT", "HADT": "HADT", "ECT": "ECT", "IST": "IST", "WARST": "WARST", "SAST": "SAST", "CDT": "CDT", "OEZ": "OEZ", "OESZ": "OESZ", "EDT": "EDT", "BOT": "BOT", "PST": "PST", "MYT": "MYT", "ARST": "ARST", "ACDT": "ACDT", "HEPM": "HEPM", "CST": "CST", "JST": "JST", "ACST": "ACST", "UYST": "UYST", "ACWDT": "ACWDT", "WEZ": "WEZ", "WAST": "WAST", "COT": "COT", "HEEG": "HEEG", "ChST": "ChST", "GYT": "GYT", "CHADT": "CHADT", "NZST": "NZST", "TMT": "TMT", "HKST": "HKST", "COST": "COST", "HENOMX": "HENOMX", "AKDT": "AKDT", "LHDT": "LHDT", "HAST": "HAST", "ADT": "ADT", "HNEG": "HNEG", "CAT": "CAT", "MEZ": "MEZ", "JDT": "JDT", "AST": "AST", "WAT": "WAT", "BT": "BT", "SRT": "SRT", "CHAST": "CHAST", "SGT": "SGT", "PDT": "PDT", "MESZ": "MESZ", "WESZ": "WESZ"}, + } +} + +// Locale returns the current translators string locale +func (dav *dav_KE) Locale() string { + return dav.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dav_KE' +func (dav *dav_KE) PluralsCardinal() []locales.PluralRule { + return dav.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dav_KE' +func (dav *dav_KE) PluralsOrdinal() []locales.PluralRule { + return dav.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dav_KE' +func (dav *dav_KE) PluralsRange() []locales.PluralRule { + return dav.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dav_KE' +func (dav *dav_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dav_KE' +func (dav *dav_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dav_KE' +func (dav *dav_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dav *dav_KE) MonthAbbreviated(month time.Month) string { + return dav.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dav *dav_KE) MonthsAbbreviated() []string { + return dav.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dav *dav_KE) MonthNarrow(month time.Month) string { + return dav.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dav *dav_KE) MonthsNarrow() []string { + return dav.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dav *dav_KE) MonthWide(month time.Month) string { + return dav.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dav *dav_KE) MonthsWide() []string { + return dav.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dav *dav_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return dav.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dav *dav_KE) WeekdaysAbbreviated() []string { + return dav.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dav *dav_KE) WeekdayNarrow(weekday time.Weekday) string { + return dav.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dav *dav_KE) WeekdaysNarrow() []string { + return dav.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dav *dav_KE) WeekdayShort(weekday time.Weekday) string { + return dav.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dav *dav_KE) WeekdaysShort() []string { + return dav.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dav *dav_KE) WeekdayWide(weekday time.Weekday) string { + return dav.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dav *dav_KE) WeekdaysWide() []string { + return dav.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dav_KE' and handles both Whole and Real numbers based on 'v' +func (dav *dav_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dav_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dav *dav_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dav_KE' +func (dav *dav_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dav.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dav.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, dav.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dav.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dav_KE' +// in accounting notation. +func (dav *dav_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dav.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dav.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, dav.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dav.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, dav.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dav_KE' +func (dav *dav_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dav_KE' +func (dav *dav_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dav.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dav_KE' +func (dav *dav_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dav.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dav_KE' +func (dav *dav_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dav.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dav.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dav_KE' +func (dav *dav_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dav_KE' +func (dav *dav_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dav_KE' +func (dav *dav_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dav_KE' +func (dav *dav_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dav.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dav_KE/dav_KE_test.go b/vendor/github.com/go-playground/locales/dav_KE/dav_KE_test.go new file mode 100644 index 0000000000..6df3607179 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dav_KE/dav_KE_test.go @@ -0,0 +1,1120 @@ +package dav_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dav_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/de/de.go b/vendor/github.com/go-playground/locales/de/de.go new file mode 100644 index 0000000000..b21dedb4d1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de/de.go @@ -0,0 +1,614 @@ +package de + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type de struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'de' locale +func New() locales.Translator { + return &de{ + locale: "de", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "öS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGK", "BGN", "BGJ", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}, + periodsAbbreviated: []string{"vorm.", "nachm."}, + periodsNarrow: []string{"vm.", "nm."}, + periodsWide: []string{"vorm.", "nachm."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"HEEG": "Ostgrönland-Sommerzeit", "COST": "Kolumbianische Sommerzeit", "MESZ": "Mitteleuropäische Sommerzeit", "JST": "Japanische Normalzeit", "WART": "Westargentinische Normalzeit", "CLT": "Chilenische Normalzeit", "AST": "Atlantik-Normalzeit", "MST": "Macau-Normalzeit", "WAST": "Westafrikanische Sommerzeit", "HNPMX": "Mexiko Pazifikzone-Normalzeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "GYT": "Guyana-Zeit", "WIB": "Westindonesische Zeit", "CHAST": "Chatham-Normalzeit", "CHADT": "Chatham-Sommerzeit", "SGT": "Singapur-Zeit", "CAT": "Zentralafrikanische Zeit", "ChST": "Chamorro-Zeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "MDT": "Macau-Sommerzeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "WIT": "Ostindonesische Zeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "MEZ": "Mitteleuropäische Normalzeit", "VET": "Venezuela-Zeit", "OEZ": "Osteuropäische Normalzeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "HAT": "Neufundland-Sommerzeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit", "CST": "Nordamerikanische Inland-Normalzeit", "AWST": "Westaustralische Normalzeit", "GMT": "Mittlere Greenwich-Zeit", "ADT": "Atlantik-Sommerzeit", "WESZ": "Westeuropäische Sommerzeit", "HKST": "Hongkong-Sommerzeit", "BT": "Bhutan-Zeit", "LHDT": "Lord-Howe-Sommerzeit", "SRT": "Suriname-Zeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "WARST": "Westargentinische Sommerzeit", "HEOG": "Westgrönland-Sommerzeit", "TMST": "Turkmenistan-Sommerzeit", "GFT": "Französisch-Guayana-Zeit", "UYST": "Uruguayanische Sommerzeit", "HECU": "Kubanische Sommerzeit", "WEZ": "Westeuropäische Normalzeit", "WAT": "Westafrikanische Normalzeit", "COT": "Kolumbianische Normalzeit", "LHST": "Lord-Howe-Normalzeit", "MYT": "Malaysische Zeit", "WITA": "Zentralindonesische Zeit", "BOT": "Bolivianische Zeit", "IST": "Indische Zeit", "ARST": "Argentinische Sommerzeit", "UYT": "Uruguyanische Normalzeit", "ECT": "Ecuadorianische Zeit", "JDT": "Japanische Sommerzeit", "OESZ": "Osteuropäische Sommerzeit", "AKDT": "Alaska-Sommerzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "HNCU": "Kubanische Normalzeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "CLST": "Chilenische Sommerzeit", "ART": "Argentinische Normalzeit", "HKT": "Hongkong-Normalzeit", "AEDT": "Ostaustralische Sommerzeit", "∅∅∅": "Azoren-Sommerzeit", "ACST": "Zentralaustralische Normalzeit", "HNT": "Neufundland-Normalzeit", "AWDT": "Westaustralische Sommerzeit", "HNOG": "Westgrönland-Normalzeit", "ACDT": "Zentralaustralische Sommerzeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "HAST": "Hawaii-Aleuten-Normalzeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "HNEG": "Ostgrönland-Normalzeit", "AEST": "Ostaustralische Normalzeit", "NZDT": "Neuseeland-Sommerzeit", "EAT": "Ostafrikanische Zeit", "NZST": "Neuseeland-Normalzeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "TMT": "Turkmenistan-Normalzeit", "AKST": "Alaska-Normalzeit", "SAST": "Südafrikanische Zeit"}, + } +} + +// Locale returns the current translators string locale +func (de *de) Locale() string { + return de.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'de' +func (de *de) PluralsCardinal() []locales.PluralRule { + return de.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'de' +func (de *de) PluralsOrdinal() []locales.PluralRule { + return de.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'de' +func (de *de) PluralsRange() []locales.PluralRule { + return de.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de' +func (de *de) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'de' +func (de *de) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de' +func (de *de) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := de.CardinalPluralRule(num1, v1) + end := de.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (de *de) MonthAbbreviated(month time.Month) string { + return de.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (de *de) MonthsAbbreviated() []string { + return de.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (de *de) MonthNarrow(month time.Month) string { + return de.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (de *de) MonthsNarrow() []string { + return de.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (de *de) MonthWide(month time.Month) string { + return de.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (de *de) MonthsWide() []string { + return de.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (de *de) WeekdayAbbreviated(weekday time.Weekday) string { + return de.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (de *de) WeekdaysAbbreviated() []string { + return de.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (de *de) WeekdayNarrow(weekday time.Weekday) string { + return de.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (de *de) WeekdaysNarrow() []string { + return de.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (de *de) WeekdayShort(weekday time.Weekday) string { + return de.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (de *de) WeekdaysShort() []string { + return de.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (de *de) WeekdayWide(weekday time.Weekday) string { + return de.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (de *de) WeekdaysWide() []string { + return de.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'de' and handles both Whole and Real numbers based on 'v' +func (de *de) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'de' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (de *de) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, de.percentSuffix...) + + b = append(b, de.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de' +func (de *de) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, de.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de' +// in accounting notation. +func (de *de) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, de.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, de.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, de.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'de' +func (de *de) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'de' +func (de *de) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'de' +func (de *de) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'de' +func (de *de) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, de.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'de' +func (de *de) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'de' +func (de *de) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'de' +func (de *de) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'de' +func (de *de) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := de.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/de/de_test.go b/vendor/github.com/go-playground/locales/de/de_test.go new file mode 100644 index 0000000000..825cb300ef --- /dev/null +++ b/vendor/github.com/go-playground/locales/de/de_test.go @@ -0,0 +1,1120 @@ +package de + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "de" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/de_AT/de_AT.go b/vendor/github.com/go-playground/locales/de_AT/de_AT.go new file mode 100644 index 0000000000..cdb0b4992a --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_AT/de_AT.go @@ -0,0 +1,633 @@ +package de_AT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type de_AT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'de_AT' locale +func New() locales.Translator { + return &de_AT{ + locale: "de_AT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jän.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Jänner", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}, + periodsAbbreviated: []string{"vorm.", "nachm."}, + periodsNarrow: []string{"vm.", "nm."}, + periodsWide: []string{"vorm.", "nachm."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"HKT": "Hongkong-Normalzeit", "EAT": "Ostafrikanische Zeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "OEZ": "Osteuropäische Normalzeit", "WEZ": "Westeuropäische Normalzeit", "MYT": "Malaysische Zeit", "TMT": "Turkmenistan-Normalzeit", "COT": "Kolumbianische Normalzeit", "BT": "Bhutan-Zeit", "AKST": "Alaska-Normalzeit", "UYST": "Uruguayanische Sommerzeit", "AWST": "Westaustralische Normalzeit", "MESZ": "Mitteleuropäische Sommerzeit", "HEEG": "Ostgrönland-Sommerzeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "SAST": "Südafrikanische Zeit", "LHDT": "Lord-Howe-Sommerzeit", "BOT": "Bolivianische Zeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "HKST": "Hongkong-Sommerzeit", "HNT": "Neufundland-Normalzeit", "WIT": "Ostindonesische Zeit", "CHAST": "Chatham-Normalzeit", "CHADT": "Chatham-Sommerzeit", "NZST": "Neuseeland-Normalzeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "AKDT": "Alaska-Sommerzeit", "HECU": "Kubanische Sommerzeit", "WIB": "Westindonesische Zeit", "NZDT": "Neuseeland-Sommerzeit", "WESZ": "Westeuropäische Sommerzeit", "WAT": "Westafrikanische Normalzeit", "∅∅∅": "Azoren-Sommerzeit", "AWDT": "Westaustralische Sommerzeit", "CLST": "Chilenische Sommerzeit", "ACST": "Zentralaustralische Normalzeit", "MDT": "Rocky-Mountain-Sommerzeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit", "JST": "Japanische Normalzeit", "HNOG": "Westgrönland-Normalzeit", "AST": "Atlantik-Normalzeit", "ChST": "Chamorro-Zeit", "ADT": "Atlantik-Sommerzeit", "TMST": "Turkmenistan-Sommerzeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "SRT": "Suriname-Zeit", "GYT": "Guyana-Zeit", "HAST": "Hawaii-Aleuten-Normalzeit", "IST": "Indische Zeit", "MEZ": "Mitteleuropäische Normalzeit", "ARST": "Argentinische Sommerzeit", "HNCU": "Kubanische Normalzeit", "CST": "Nordamerikanische Inland-Normalzeit", "CAT": "Zentralafrikanische Zeit", "JDT": "Japanische Sommerzeit", "HEOG": "Westgrönland-Sommerzeit", "OESZ": "Osteuropäische Sommerzeit", "HAT": "Neufundland-Sommerzeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "ACDT": "Zentralaustralische Sommerzeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "WARST": "Westargentinische Sommerzeit", "COST": "Kolumbianische Sommerzeit", "WITA": "Zentralindonesische Zeit", "UYT": "Uruguyanische Normalzeit", "VET": "Venezuela-Zeit", "AEST": "Ostaustralische Normalzeit", "LHST": "Lord-Howe-Normalzeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "SGT": "Singapur-Zeit", "WART": "Westargentinische Normalzeit", "ART": "Argentinische Normalzeit", "CLT": "Chilenische Normalzeit", "AEDT": "Ostaustralische Sommerzeit", "MST": "Rocky Mountain-Normalzeit", "GFT": "Französisch-Guayana-Zeit", "HNPMX": "Mexiko Pazifikzone-Normalzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "ECT": "Ecuadorianische Zeit", "GMT": "Mittlere Greenwich-Zeit", "WAST": "Westafrikanische Sommerzeit", "HNEG": "Ostgrönland-Normalzeit"}, + } +} + +// Locale returns the current translators string locale +func (de *de_AT) Locale() string { + return de.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'de_AT' +func (de *de_AT) PluralsCardinal() []locales.PluralRule { + return de.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'de_AT' +func (de *de_AT) PluralsOrdinal() []locales.PluralRule { + return de.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'de_AT' +func (de *de_AT) PluralsRange() []locales.PluralRule { + return de.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de_AT' +func (de *de_AT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'de_AT' +func (de *de_AT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de_AT' +func (de *de_AT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := de.CardinalPluralRule(num1, v1) + end := de.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (de *de_AT) MonthAbbreviated(month time.Month) string { + return de.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (de *de_AT) MonthsAbbreviated() []string { + return de.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (de *de_AT) MonthNarrow(month time.Month) string { + return de.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (de *de_AT) MonthsNarrow() []string { + return de.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (de *de_AT) MonthWide(month time.Month) string { + return de.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (de *de_AT) MonthsWide() []string { + return de.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (de *de_AT) WeekdayAbbreviated(weekday time.Weekday) string { + return de.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (de *de_AT) WeekdaysAbbreviated() []string { + return de.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (de *de_AT) WeekdayNarrow(weekday time.Weekday) string { + return de.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (de *de_AT) WeekdaysNarrow() []string { + return de.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (de *de_AT) WeekdayShort(weekday time.Weekday) string { + return de.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (de *de_AT) WeekdaysShort() []string { + return de.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (de *de_AT) WeekdayWide(weekday time.Weekday) string { + return de.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (de *de_AT) WeekdaysWide() []string { + return de.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'de_AT' and handles both Whole and Real numbers based on 'v' +func (de *de_AT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(de.group) - 1; j >= 0; j-- { + b = append(b, de.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'de_AT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (de *de_AT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, de.percentSuffix...) + + b = append(b, de.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de_AT' +func (de *de_AT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(de.group) - 1; j >= 0; j-- { + b = append(b, de.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de_AT' +// in accounting notation. +func (de *de_AT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(de.group) - 1; j >= 0; j-- { + b = append(b, de.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyNegativePrefix[j]) + } + + b = append(b, de.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'de_AT' +func (de *de_AT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'de_AT' +func (de *de_AT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'de_AT' +func (de *de_AT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'de_AT' +func (de *de_AT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, de.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'de_AT' +func (de *de_AT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'de_AT' +func (de *de_AT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'de_AT' +func (de *de_AT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'de_AT' +func (de *de_AT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := de.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/de_AT/de_AT_test.go b/vendor/github.com/go-playground/locales/de_AT/de_AT_test.go new file mode 100644 index 0000000000..fccc4a7df2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_AT/de_AT_test.go @@ -0,0 +1,1120 @@ +package de_AT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "de_AT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/de_BE/de_BE.go b/vendor/github.com/go-playground/locales/de_BE/de_BE.go new file mode 100644 index 0000000000..ffbfe76d91 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_BE/de_BE.go @@ -0,0 +1,614 @@ +package de_BE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type de_BE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'de_BE' locale +func New() locales.Translator { + return &de_BE{ + locale: "de_BE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}, + periodsAbbreviated: []string{"vorm.", "nachm."}, + periodsNarrow: []string{"vm.", "nm."}, + periodsWide: []string{"vorm.", "nachm."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"GFT": "Französisch-Guayana-Zeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "CST": "Nordamerikanische Inland-Normalzeit", "IST": "Indische Zeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "HEOG": "Westgrönland-Sommerzeit", "WART": "Westargentinische Normalzeit", "WAST": "Westafrikanische Sommerzeit", "MST": "Macau-Normalzeit", "COST": "Kolumbianische Sommerzeit", "AKDT": "Alaska-Sommerzeit", "UYST": "Uruguayanische Sommerzeit", "WEZ": "Westeuropäische Normalzeit", "TMT": "Turkmenistan-Normalzeit", "MDT": "Macau-Sommerzeit", "WITA": "Zentralindonesische Zeit", "JDT": "Japanische Sommerzeit", "ARST": "Argentinische Sommerzeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "BT": "Bhutan-Zeit", "TMST": "Turkmenistan-Sommerzeit", "AEST": "Ostaustralische Normalzeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit", "HNPMX": "Mexiko Pazifikzone-Normalzeit", "EAT": "Ostafrikanische Zeit", "CLT": "Chilenische Normalzeit", "AST": "Atlantik-Normalzeit", "OEZ": "Osteuropäische Normalzeit", "WIB": "Westindonesische Zeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "MESZ": "Mitteleuropäische Sommerzeit", "HAT": "Neufundland-Sommerzeit", "HECU": "Kubanische Sommerzeit", "BOT": "Bolivianische Zeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "AWST": "Westaustralische Normalzeit", "NZDT": "Neuseeland-Sommerzeit", "VET": "Venezuela-Zeit", "ADT": "Atlantik-Sommerzeit", "OESZ": "Osteuropäische Sommerzeit", "COT": "Kolumbianische Normalzeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "CHAST": "Chatham-Normalzeit", "ECT": "Ecuadorianische Zeit", "HNOG": "Westgrönland-Normalzeit", "GMT": "Mittlere Greenwich-Zeit", "ART": "Argentinische Normalzeit", "WAT": "Westafrikanische Normalzeit", "LHST": "Lord-Howe-Normalzeit", "CHADT": "Chatham-Sommerzeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "MEZ": "Mitteleuropäische Normalzeit", "JST": "Japanische Normalzeit", "∅∅∅": "Acre-Sommerzeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "AWDT": "Westaustralische Sommerzeit", "AEDT": "Ostaustralische Sommerzeit", "ACDT": "Zentralaustralische Sommerzeit", "HNT": "Neufundland-Normalzeit", "HNEG": "Ostgrönland-Normalzeit", "AKST": "Alaska-Normalzeit", "SAST": "Südafrikanische Zeit", "HNCU": "Kubanische Normalzeit", "CAT": "Zentralafrikanische Zeit", "HKT": "Hongkong-Normalzeit", "ACST": "Zentralaustralische Normalzeit", "HEEG": "Ostgrönland-Sommerzeit", "WARST": "Westargentinische Sommerzeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "NZST": "Neuseeland-Normalzeit", "SRT": "Suriname-Zeit", "GYT": "Guyana-Zeit", "WIT": "Ostindonesische Zeit", "SGT": "Singapur-Zeit", "HAST": "Hawaii-Aleuten-Normalzeit", "WESZ": "Westeuropäische Sommerzeit", "HKST": "Hongkong-Sommerzeit", "ChST": "Chamorro-Zeit", "CLST": "Chilenische Sommerzeit", "UYT": "Uruguyanische Normalzeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "MYT": "Malaysische Zeit", "LHDT": "Lord-Howe-Sommerzeit"}, + } +} + +// Locale returns the current translators string locale +func (de *de_BE) Locale() string { + return de.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'de_BE' +func (de *de_BE) PluralsCardinal() []locales.PluralRule { + return de.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'de_BE' +func (de *de_BE) PluralsOrdinal() []locales.PluralRule { + return de.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'de_BE' +func (de *de_BE) PluralsRange() []locales.PluralRule { + return de.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de_BE' +func (de *de_BE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'de_BE' +func (de *de_BE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de_BE' +func (de *de_BE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := de.CardinalPluralRule(num1, v1) + end := de.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (de *de_BE) MonthAbbreviated(month time.Month) string { + return de.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (de *de_BE) MonthsAbbreviated() []string { + return de.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (de *de_BE) MonthNarrow(month time.Month) string { + return de.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (de *de_BE) MonthsNarrow() []string { + return de.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (de *de_BE) MonthWide(month time.Month) string { + return de.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (de *de_BE) MonthsWide() []string { + return de.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (de *de_BE) WeekdayAbbreviated(weekday time.Weekday) string { + return de.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (de *de_BE) WeekdaysAbbreviated() []string { + return de.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (de *de_BE) WeekdayNarrow(weekday time.Weekday) string { + return de.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (de *de_BE) WeekdaysNarrow() []string { + return de.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (de *de_BE) WeekdayShort(weekday time.Weekday) string { + return de.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (de *de_BE) WeekdaysShort() []string { + return de.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (de *de_BE) WeekdayWide(weekday time.Weekday) string { + return de.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (de *de_BE) WeekdaysWide() []string { + return de.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'de_BE' and handles both Whole and Real numbers based on 'v' +func (de *de_BE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'de_BE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (de *de_BE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, de.percentSuffix...) + + b = append(b, de.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de_BE' +func (de *de_BE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, de.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de_BE' +// in accounting notation. +func (de *de_BE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, de.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, de.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, de.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'de_BE' +func (de *de_BE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'de_BE' +func (de *de_BE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'de_BE' +func (de *de_BE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'de_BE' +func (de *de_BE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, de.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'de_BE' +func (de *de_BE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'de_BE' +func (de *de_BE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'de_BE' +func (de *de_BE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'de_BE' +func (de *de_BE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := de.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/de_BE/de_BE_test.go b/vendor/github.com/go-playground/locales/de_BE/de_BE_test.go new file mode 100644 index 0000000000..5d56e161b5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_BE/de_BE_test.go @@ -0,0 +1,1120 @@ +package de_BE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "de_BE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/de_CH/de_CH.go b/vendor/github.com/go-playground/locales/de_CH/de_CH.go new file mode 100644 index 0000000000..7324b73ad2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_CH/de_CH.go @@ -0,0 +1,623 @@ +package de_CH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type de_CH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'de_CH' locale +func New() locales.Translator { + return &de_CH{ + locale: "de_CH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: "'", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}, + periodsAbbreviated: []string{"vorm.", "nachm."}, + periodsNarrow: []string{"vm.", "nm."}, + periodsWide: []string{"vorm.", "nachm."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"HNPMX": "Mexiko Pazifikzone-Normalzeit", "WAT": "Westafrikanische Normalzeit", "AKST": "Alaska-Normalzeit", "AEST": "Ostaustralische Normalzeit", "UYT": "Uruguyanische Normalzeit", "EAT": "Ostafrikanische Zeit", "SGT": "Singapur-Zeit", "COT": "Kolumbianische Normalzeit", "NZST": "Neuseeland-Normalzeit", "WESZ": "Westeuropäische Sommerzeit", "HAT": "Neufundland-Sommerzeit", "∅∅∅": "Azoren-Sommerzeit", "ECT": "Ecuadorianische Zeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "CST": "Nordamerikanische Inland-Normalzeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "HNT": "Neufundland-Normalzeit", "CLT": "Chilenische Normalzeit", "HEOG": "Westgrönland-Sommerzeit", "AEDT": "Ostaustralische Sommerzeit", "LHDT": "Lord-Howe-Sommerzeit", "VET": "Venezuela-Zeit", "MEZ": "Mitteleuropäische Normalzeit", "WART": "Westargentinische Normalzeit", "ADT": "Atlantik-Sommerzeit", "ART": "Argentinische Normalzeit", "HKST": "Hongkong-Sommerzeit", "LHST": "Lord-Howe-Normalzeit", "AWST": "Westaustralische Normalzeit", "AWDT": "Westaustralische Sommerzeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "IST": "Indische Zeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "MESZ": "Mitteleuropäische Sommerzeit", "MYT": "Malaysische Zeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "WIB": "Westindonesische Zeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "WEZ": "Westeuropäische Normalzeit", "WIT": "Ostindonesische Zeit", "HAST": "Hawaii-Aleuten-Normalzeit", "JDT": "Japanische Sommerzeit", "SRT": "Suriname-Zeit", "JST": "Japanische Normalzeit", "COST": "Kolumbianische Sommerzeit", "HNOG": "Westgrönland-Normalzeit", "HKT": "Hongkong-Normalzeit", "BT": "Bhutan-Zeit", "GFT": "Französisch-Guayana-Zeit", "ChST": "Chamorro-Zeit", "UYST": "Uruguayanische Sommerzeit", "ACDT": "Zentralaustralische Sommerzeit", "MDT": "Rocky-Mountain-Sommerzeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "GYT": "Guyana-Zeit", "OESZ": "Osteuropäische Sommerzeit", "TMT": "Turkmenistan-Normalzeit", "ARST": "Argentinische Sommerzeit", "AKDT": "Alaska-Sommerzeit", "NZDT": "Neuseeland-Sommerzeit", "OEZ": "Osteuropäische Normalzeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "CAT": "Zentralafrikanische Zeit", "ACST": "Zentralaustralische Normalzeit", "HEEG": "Ostgrönland-Sommerzeit", "MST": "Rocky Mountain-Normalzeit", "SAST": "Südafrikanische Zeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "WARST": "Westargentinische Sommerzeit", "WAST": "Westafrikanische Sommerzeit", "CHAST": "Chatham-Normalzeit", "CHADT": "Chatham-Sommerzeit", "BOT": "Bolivianische Zeit", "CLST": "Chilenische Sommerzeit", "AST": "Atlantik-Normalzeit", "GMT": "Mittlere Greenwich-Zeit", "TMST": "Turkmenistan-Sommerzeit", "WITA": "Zentralindonesische Zeit", "HNCU": "Kubanische Normalzeit", "HECU": "Kubanische Sommerzeit", "HNEG": "Ostgrönland-Normalzeit"}, + } +} + +// Locale returns the current translators string locale +func (de *de_CH) Locale() string { + return de.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'de_CH' +func (de *de_CH) PluralsCardinal() []locales.PluralRule { + return de.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'de_CH' +func (de *de_CH) PluralsOrdinal() []locales.PluralRule { + return de.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'de_CH' +func (de *de_CH) PluralsRange() []locales.PluralRule { + return de.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de_CH' +func (de *de_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'de_CH' +func (de *de_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de_CH' +func (de *de_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := de.CardinalPluralRule(num1, v1) + end := de.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (de *de_CH) MonthAbbreviated(month time.Month) string { + return de.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (de *de_CH) MonthsAbbreviated() []string { + return de.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (de *de_CH) MonthNarrow(month time.Month) string { + return de.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (de *de_CH) MonthsNarrow() []string { + return de.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (de *de_CH) MonthWide(month time.Month) string { + return de.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (de *de_CH) MonthsWide() []string { + return de.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (de *de_CH) WeekdayAbbreviated(weekday time.Weekday) string { + return de.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (de *de_CH) WeekdaysAbbreviated() []string { + return de.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (de *de_CH) WeekdayNarrow(weekday time.Weekday) string { + return de.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (de *de_CH) WeekdaysNarrow() []string { + return de.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (de *de_CH) WeekdayShort(weekday time.Weekday) string { + return de.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (de *de_CH) WeekdaysShort() []string { + return de.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (de *de_CH) WeekdayWide(weekday time.Weekday) string { + return de.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (de *de_CH) WeekdaysWide() []string { + return de.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'de_CH' and handles both Whole and Real numbers based on 'v' +func (de *de_CH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'de_CH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (de *de_CH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, de.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de_CH' +func (de *de_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de_CH' +// in accounting notation. +func (de *de_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyNegativePrefix[j]) + } + + b = append(b, de.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'de_CH' +func (de *de_CH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'de_CH' +func (de *de_CH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'de_CH' +func (de *de_CH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'de_CH' +func (de *de_CH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, de.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'de_CH' +func (de *de_CH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'de_CH' +func (de *de_CH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'de_CH' +func (de *de_CH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'de_CH' +func (de *de_CH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := de.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/de_CH/de_CH_test.go b/vendor/github.com/go-playground/locales/de_CH/de_CH_test.go new file mode 100644 index 0000000000..b528b5c957 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_CH/de_CH_test.go @@ -0,0 +1,1120 @@ +package de_CH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "de_CH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/de_DE/de_DE.go b/vendor/github.com/go-playground/locales/de_DE/de_DE.go new file mode 100644 index 0000000000..272d2e0ac8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_DE/de_DE.go @@ -0,0 +1,614 @@ +package de_DE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type de_DE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'de_DE' locale +func New() locales.Translator { + return &de_DE{ + locale: "de_DE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}, + periodsAbbreviated: []string{"vorm.", "nachm."}, + periodsNarrow: []string{"vm.", "nm."}, + periodsWide: []string{"vorm.", "nachm."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"WAST": "Westafrikanische Sommerzeit", "AWST": "Westaustralische Normalzeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "ECT": "Ecuadorianische Zeit", "∅∅∅": "Acre-Sommerzeit", "GFT": "Französisch-Guayana-Zeit", "UYST": "Uruguayanische Sommerzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "WIT": "Ostindonesische Zeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "JDT": "Japanische Sommerzeit", "TMT": "Turkmenistan-Normalzeit", "WAT": "Westafrikanische Normalzeit", "AKDT": "Alaska-Sommerzeit", "AEST": "Ostaustralische Normalzeit", "SRT": "Suriname-Zeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "ChST": "Chamorro-Zeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "OEZ": "Osteuropäische Normalzeit", "GMT": "Mittlere Greenwich-Zeit", "MDT": "Macau-Sommerzeit", "CHADT": "Chatham-Sommerzeit", "SGT": "Singapur-Zeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "CLST": "Chilenische Sommerzeit", "HNOG": "Westgrönland-Normalzeit", "HNEG": "Ostgrönland-Normalzeit", "CAT": "Zentralafrikanische Zeit", "IST": "Indische Zeit", "BT": "Bhutan-Zeit", "WIB": "Westindonesische Zeit", "CHAST": "Chatham-Normalzeit", "WARST": "Westargentinische Sommerzeit", "ARST": "Argentinische Sommerzeit", "HKST": "Hongkong-Sommerzeit", "ACDT": "Zentralaustralische Sommerzeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "HAST": "Hawaii-Aleuten-Normalzeit", "NZDT": "Neuseeland-Sommerzeit", "MEZ": "Mitteleuropäische Normalzeit", "TMST": "Turkmenistan-Sommerzeit", "ACST": "Zentralaustralische Normalzeit", "COST": "Kolumbianische Sommerzeit", "HAT": "Neufundland-Sommerzeit", "HNCU": "Kubanische Normalzeit", "ADT": "Atlantik-Sommerzeit", "WART": "Westargentinische Normalzeit", "ART": "Argentinische Normalzeit", "AEDT": "Ostaustralische Sommerzeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "OESZ": "Osteuropäische Sommerzeit", "WEZ": "Westeuropäische Normalzeit", "HKT": "Hongkong-Normalzeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "MESZ": "Mitteleuropäische Sommerzeit", "CST": "Nordamerikanische Inland-Normalzeit", "HEOG": "Westgrönland-Sommerzeit", "WESZ": "Westeuropäische Sommerzeit", "MST": "Macau-Normalzeit", "EAT": "Ostafrikanische Zeit", "HECU": "Kubanische Sommerzeit", "UYT": "Uruguyanische Normalzeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "VET": "Venezuela-Zeit", "WITA": "Zentralindonesische Zeit", "AKST": "Alaska-Normalzeit", "SAST": "Südafrikanische Zeit", "LHDT": "Lord-Howe-Sommerzeit", "BOT": "Bolivianische Zeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "JST": "Japanische Normalzeit", "HNPMX": "Mexiko Pazifikzone-Normalzeit", "AWDT": "Westaustralische Sommerzeit", "CLT": "Chilenische Normalzeit", "MYT": "Malaysische Zeit", "COT": "Kolumbianische Normalzeit", "HNT": "Neufundland-Normalzeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit", "NZST": "Neuseeland-Normalzeit", "AST": "Atlantik-Normalzeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "HEEG": "Ostgrönland-Sommerzeit", "LHST": "Lord-Howe-Normalzeit", "GYT": "Guyana-Zeit"}, + } +} + +// Locale returns the current translators string locale +func (de *de_DE) Locale() string { + return de.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'de_DE' +func (de *de_DE) PluralsCardinal() []locales.PluralRule { + return de.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'de_DE' +func (de *de_DE) PluralsOrdinal() []locales.PluralRule { + return de.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'de_DE' +func (de *de_DE) PluralsRange() []locales.PluralRule { + return de.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de_DE' +func (de *de_DE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'de_DE' +func (de *de_DE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de_DE' +func (de *de_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := de.CardinalPluralRule(num1, v1) + end := de.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (de *de_DE) MonthAbbreviated(month time.Month) string { + return de.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (de *de_DE) MonthsAbbreviated() []string { + return de.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (de *de_DE) MonthNarrow(month time.Month) string { + return de.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (de *de_DE) MonthsNarrow() []string { + return de.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (de *de_DE) MonthWide(month time.Month) string { + return de.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (de *de_DE) MonthsWide() []string { + return de.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (de *de_DE) WeekdayAbbreviated(weekday time.Weekday) string { + return de.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (de *de_DE) WeekdaysAbbreviated() []string { + return de.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (de *de_DE) WeekdayNarrow(weekday time.Weekday) string { + return de.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (de *de_DE) WeekdaysNarrow() []string { + return de.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (de *de_DE) WeekdayShort(weekday time.Weekday) string { + return de.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (de *de_DE) WeekdaysShort() []string { + return de.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (de *de_DE) WeekdayWide(weekday time.Weekday) string { + return de.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (de *de_DE) WeekdaysWide() []string { + return de.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'de_DE' and handles both Whole and Real numbers based on 'v' +func (de *de_DE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'de_DE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (de *de_DE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, de.percentSuffix...) + + b = append(b, de.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de_DE' +func (de *de_DE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, de.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de_DE' +// in accounting notation. +func (de *de_DE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, de.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, de.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, de.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'de_DE' +func (de *de_DE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'de_DE' +func (de *de_DE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'de_DE' +func (de *de_DE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'de_DE' +func (de *de_DE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, de.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'de_DE' +func (de *de_DE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'de_DE' +func (de *de_DE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'de_DE' +func (de *de_DE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'de_DE' +func (de *de_DE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := de.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/de_DE/de_DE_test.go b/vendor/github.com/go-playground/locales/de_DE/de_DE_test.go new file mode 100644 index 0000000000..9425f37873 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_DE/de_DE_test.go @@ -0,0 +1,1120 @@ +package de_DE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "de_DE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/de_IT/de_IT.go b/vendor/github.com/go-playground/locales/de_IT/de_IT.go new file mode 100644 index 0000000000..dc898c6fd0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_IT/de_IT.go @@ -0,0 +1,614 @@ +package de_IT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type de_IT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'de_IT' locale +func New() locales.Translator { + return &de_IT{ + locale: "de_IT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jän.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Jänner", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}, + periodsAbbreviated: []string{"vorm.", "nachm."}, + periodsNarrow: []string{"vm.", "nm."}, + periodsWide: []string{"vorm.", "nachm."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"GMT": "Mittlere Greenwich-Zeit", "HKST": "Hongkong-Sommerzeit", "COT": "Kolumbianische Normalzeit", "HNEG": "Ostgrönland-Normalzeit", "UYT": "Uruguyanische Normalzeit", "WIB": "Westindonesische Zeit", "WEZ": "Westeuropäische Normalzeit", "CLST": "Chilenische Sommerzeit", "SAST": "Südafrikanische Zeit", "VET": "Venezuela-Zeit", "ADT": "Atlantik-Sommerzeit", "ARST": "Argentinische Sommerzeit", "COST": "Kolumbianische Sommerzeit", "HEEG": "Ostgrönland-Sommerzeit", "UYST": "Uruguayanische Sommerzeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "WARST": "Westargentinische Sommerzeit", "WAST": "Westafrikanische Sommerzeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "TMST": "Turkmenistan-Sommerzeit", "AKDT": "Alaska-Sommerzeit", "EAT": "Ostafrikanische Zeit", "MESZ": "Mitteleuropäische Sommerzeit", "MST": "Macau-Normalzeit", "ACDT": "Zentralaustralische Sommerzeit", "AEST": "Ostaustralische Normalzeit", "WIT": "Ostindonesische Zeit", "JDT": "Japanische Sommerzeit", "TMT": "Turkmenistan-Normalzeit", "OESZ": "Osteuropäische Sommerzeit", "MDT": "Macau-Sommerzeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "ACST": "Zentralaustralische Normalzeit", "HNT": "Neufundland-Normalzeit", "ChST": "Chamorro-Zeit", "LHDT": "Lord-Howe-Sommerzeit", "AST": "Atlantik-Normalzeit", "IST": "Indische Zeit", "WESZ": "Westeuropäische Sommerzeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "HAT": "Neufundland-Sommerzeit", "HNCU": "Kubanische Normalzeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "OEZ": "Osteuropäische Normalzeit", "WART": "Westargentinische Normalzeit", "CLT": "Chilenische Normalzeit", "WAT": "Westafrikanische Normalzeit", "∅∅∅": "Acre-Sommerzeit", "WITA": "Zentralindonesische Zeit", "CHAST": "Chatham-Normalzeit", "HEOG": "Westgrönland-Sommerzeit", "MEZ": "Mitteleuropäische Normalzeit", "BOT": "Bolivianische Zeit", "AEDT": "Ostaustralische Sommerzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "SGT": "Singapur-Zeit", "CAT": "Zentralafrikanische Zeit", "NZDT": "Neuseeland-Sommerzeit", "AKST": "Alaska-Normalzeit", "GFT": "Französisch-Guayana-Zeit", "LHST": "Lord-Howe-Normalzeit", "CST": "Nordamerikanische Inland-Normalzeit", "AWST": "Westaustralische Normalzeit", "HNOG": "Westgrönland-Normalzeit", "BT": "Bhutan-Zeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit", "HNPMX": "Mexiko Pazifikzone-Normalzeit", "SRT": "Suriname-Zeit", "MYT": "Malaysische Zeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "HKT": "Hongkong-Normalzeit", "HECU": "Kubanische Sommerzeit", "AWDT": "Westaustralische Sommerzeit", "CHADT": "Chatham-Sommerzeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "ART": "Argentinische Normalzeit", "JST": "Japanische Normalzeit", "HAST": "Hawaii-Aleuten-Normalzeit", "ECT": "Ecuadorianische Zeit", "NZST": "Neuseeland-Normalzeit", "GYT": "Guyana-Zeit"}, + } +} + +// Locale returns the current translators string locale +func (de *de_IT) Locale() string { + return de.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'de_IT' +func (de *de_IT) PluralsCardinal() []locales.PluralRule { + return de.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'de_IT' +func (de *de_IT) PluralsOrdinal() []locales.PluralRule { + return de.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'de_IT' +func (de *de_IT) PluralsRange() []locales.PluralRule { + return de.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de_IT' +func (de *de_IT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'de_IT' +func (de *de_IT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de_IT' +func (de *de_IT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := de.CardinalPluralRule(num1, v1) + end := de.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (de *de_IT) MonthAbbreviated(month time.Month) string { + return de.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (de *de_IT) MonthsAbbreviated() []string { + return de.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (de *de_IT) MonthNarrow(month time.Month) string { + return de.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (de *de_IT) MonthsNarrow() []string { + return de.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (de *de_IT) MonthWide(month time.Month) string { + return de.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (de *de_IT) MonthsWide() []string { + return de.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (de *de_IT) WeekdayAbbreviated(weekday time.Weekday) string { + return de.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (de *de_IT) WeekdaysAbbreviated() []string { + return de.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (de *de_IT) WeekdayNarrow(weekday time.Weekday) string { + return de.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (de *de_IT) WeekdaysNarrow() []string { + return de.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (de *de_IT) WeekdayShort(weekday time.Weekday) string { + return de.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (de *de_IT) WeekdaysShort() []string { + return de.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (de *de_IT) WeekdayWide(weekday time.Weekday) string { + return de.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (de *de_IT) WeekdaysWide() []string { + return de.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'de_IT' and handles both Whole and Real numbers based on 'v' +func (de *de_IT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'de_IT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (de *de_IT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, de.percentSuffix...) + + b = append(b, de.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de_IT' +func (de *de_IT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, de.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de_IT' +// in accounting notation. +func (de *de_IT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, de.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, de.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, de.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'de_IT' +func (de *de_IT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'de_IT' +func (de *de_IT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'de_IT' +func (de *de_IT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'de_IT' +func (de *de_IT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, de.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'de_IT' +func (de *de_IT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'de_IT' +func (de *de_IT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'de_IT' +func (de *de_IT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'de_IT' +func (de *de_IT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := de.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/de_IT/de_IT_test.go b/vendor/github.com/go-playground/locales/de_IT/de_IT_test.go new file mode 100644 index 0000000000..e8904680a4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_IT/de_IT_test.go @@ -0,0 +1,1120 @@ +package de_IT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "de_IT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/de_LI/de_LI.go b/vendor/github.com/go-playground/locales/de_LI/de_LI.go new file mode 100644 index 0000000000..26014b60be --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_LI/de_LI.go @@ -0,0 +1,623 @@ +package de_LI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type de_LI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'de_LI' locale +func New() locales.Translator { + return &de_LI{ + locale: "de_LI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: "'", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}, + periodsAbbreviated: []string{"vorm.", "nachm."}, + periodsNarrow: []string{"vm.", "nm."}, + periodsWide: []string{"vorm.", "nachm."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"AEST": "Ostaustralische Normalzeit", "∅∅∅": "Azoren-Sommerzeit", "WIT": "Ostindonesische Zeit", "SGT": "Singapur-Zeit", "NZST": "Neuseeland-Normalzeit", "OESZ": "Osteuropäische Sommerzeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "MST": "Rocky Mountain-Normalzeit", "HKST": "Hongkong-Sommerzeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "MESZ": "Mitteleuropäische Sommerzeit", "TMT": "Turkmenistan-Normalzeit", "HNCU": "Kubanische Normalzeit", "ChST": "Chamorro-Zeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit", "EAT": "Ostafrikanische Zeit", "JST": "Japanische Normalzeit", "MDT": "Rocky-Mountain-Sommerzeit", "JDT": "Japanische Sommerzeit", "ADT": "Atlantik-Sommerzeit", "MEZ": "Mitteleuropäische Normalzeit", "SAST": "Südafrikanische Zeit", "AWDT": "Westaustralische Sommerzeit", "HNOG": "Westgrönland-Normalzeit", "AKST": "Alaska-Normalzeit", "AWST": "Westaustralische Normalzeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "GMT": "Mittlere Greenwich-Zeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "WIB": "Westindonesische Zeit", "HNPMX": "Mexiko Pazifikzone-Normalzeit", "CAT": "Zentralafrikanische Zeit", "IST": "Indische Zeit", "VET": "Venezuela-Zeit", "BT": "Bhutan-Zeit", "HNT": "Neufundland-Normalzeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "CLST": "Chilenische Sommerzeit", "COST": "Kolumbianische Sommerzeit", "HEEG": "Ostgrönland-Sommerzeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "HECU": "Kubanische Sommerzeit", "CST": "Nordamerikanische Inland-Normalzeit", "CHADT": "Chatham-Sommerzeit", "OEZ": "Osteuropäische Normalzeit", "WESZ": "Westeuropäische Sommerzeit", "AEDT": "Ostaustralische Sommerzeit", "CHAST": "Chatham-Normalzeit", "WART": "Westargentinische Normalzeit", "WARST": "Westargentinische Sommerzeit", "CLT": "Chilenische Normalzeit", "WEZ": "Westeuropäische Normalzeit", "ART": "Argentinische Normalzeit", "HKT": "Hongkong-Normalzeit", "LHDT": "Lord-Howe-Sommerzeit", "SRT": "Suriname-Zeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "BOT": "Bolivianische Zeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "TMST": "Turkmenistan-Sommerzeit", "UYT": "Uruguyanische Normalzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "MYT": "Malaysische Zeit", "HEOG": "Westgrönland-Sommerzeit", "WAST": "Westafrikanische Sommerzeit", "GFT": "Französisch-Guayana-Zeit", "LHST": "Lord-Howe-Normalzeit", "ACST": "Zentralaustralische Normalzeit", "COT": "Kolumbianische Normalzeit", "HAT": "Neufundland-Sommerzeit", "UYST": "Uruguayanische Sommerzeit", "ARST": "Argentinische Sommerzeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "ECT": "Ecuadorianische Zeit", "WAT": "Westafrikanische Normalzeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "NZDT": "Neuseeland-Sommerzeit", "AKDT": "Alaska-Sommerzeit", "GYT": "Guyana-Zeit", "HAST": "Hawaii-Aleuten-Normalzeit", "AST": "Atlantik-Normalzeit", "ACDT": "Zentralaustralische Sommerzeit", "HNEG": "Ostgrönland-Normalzeit", "WITA": "Zentralindonesische Zeit"}, + } +} + +// Locale returns the current translators string locale +func (de *de_LI) Locale() string { + return de.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'de_LI' +func (de *de_LI) PluralsCardinal() []locales.PluralRule { + return de.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'de_LI' +func (de *de_LI) PluralsOrdinal() []locales.PluralRule { + return de.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'de_LI' +func (de *de_LI) PluralsRange() []locales.PluralRule { + return de.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de_LI' +func (de *de_LI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'de_LI' +func (de *de_LI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de_LI' +func (de *de_LI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := de.CardinalPluralRule(num1, v1) + end := de.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (de *de_LI) MonthAbbreviated(month time.Month) string { + return de.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (de *de_LI) MonthsAbbreviated() []string { + return de.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (de *de_LI) MonthNarrow(month time.Month) string { + return de.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (de *de_LI) MonthsNarrow() []string { + return de.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (de *de_LI) MonthWide(month time.Month) string { + return de.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (de *de_LI) MonthsWide() []string { + return de.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (de *de_LI) WeekdayAbbreviated(weekday time.Weekday) string { + return de.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (de *de_LI) WeekdaysAbbreviated() []string { + return de.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (de *de_LI) WeekdayNarrow(weekday time.Weekday) string { + return de.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (de *de_LI) WeekdaysNarrow() []string { + return de.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (de *de_LI) WeekdayShort(weekday time.Weekday) string { + return de.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (de *de_LI) WeekdaysShort() []string { + return de.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (de *de_LI) WeekdayWide(weekday time.Weekday) string { + return de.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (de *de_LI) WeekdaysWide() []string { + return de.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'de_LI' and handles both Whole and Real numbers based on 'v' +func (de *de_LI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'de_LI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (de *de_LI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, de.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de_LI' +func (de *de_LI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de_LI' +// in accounting notation. +func (de *de_LI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyNegativePrefix[j]) + } + + b = append(b, de.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(de.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, de.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'de_LI' +func (de *de_LI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'de_LI' +func (de *de_LI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'de_LI' +func (de *de_LI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'de_LI' +func (de *de_LI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, de.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'de_LI' +func (de *de_LI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'de_LI' +func (de *de_LI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'de_LI' +func (de *de_LI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'de_LI' +func (de *de_LI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := de.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/de_LI/de_LI_test.go b/vendor/github.com/go-playground/locales/de_LI/de_LI_test.go new file mode 100644 index 0000000000..83e75bf38a --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_LI/de_LI_test.go @@ -0,0 +1,1120 @@ +package de_LI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "de_LI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/de_LU/de_LU.go b/vendor/github.com/go-playground/locales/de_LU/de_LU.go new file mode 100644 index 0000000000..6bfa87fc12 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_LU/de_LU.go @@ -0,0 +1,614 @@ +package de_LU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type de_LU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'de_LU' locale +func New() locales.Translator { + return &de_LU{ + locale: "de_LU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "F", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mo.", "Di.", "Mi.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}, + periodsAbbreviated: []string{"vorm.", "nachm."}, + periodsNarrow: []string{"vorm.", "nachm."}, + periodsWide: []string{"vorm.", "nachm."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"AKST": "Alaska-Normalzeit", "HNCU": "Kubanische Normalzeit", "WIT": "Ostindonesische Zeit", "MEZ": "Mitteleuropäische Normalzeit", "HNOG": "Westgrönland-Normalzeit", "MYT": "Malaysische Zeit", "AEDT": "Ostaustralische Sommerzeit", "UYST": "Uruguayanische Sommerzeit", "GYT": "Guyana-Zeit", "ART": "Argentinische Normalzeit", "ARST": "Argentinische Sommerzeit", "HKT": "Hongkong-Normalzeit", "AEST": "Ostaustralische Normalzeit", "SAST": "Südafrikanische Zeit", "AWDT": "Westaustralische Sommerzeit", "PST": "Nordamerikanische Westküsten-Normalzeit", "WART": "Westargentinische Normalzeit", "HENOMX": "Mexiko Nordwestliche Zone-Sommerzeit", "HAST": "Hawaii-Aleuten-Normalzeit", "CLT": "Chilenische Normalzeit", "GMT": "Mittlere Greenwich-Zeit", "LHST": "Lord-Howe-Normalzeit", "BOT": "Bolivianische Zeit", "WAT": "Westafrikanische Normalzeit", "COST": "Kolumbianische Sommerzeit", "OESZ": "Osteuropäische Sommerzeit", "TMST": "Turkmenistan-Sommerzeit", "ACST": "Zentralaustralische Normalzeit", "ACDT": "Zentralaustralische Sommerzeit", "CDT": "Nordamerikanische Inland-Sommerzeit", "HADT": "Hawaii-Aleuten-Sommerzeit", "MESZ": "Mitteleuropäische Sommerzeit", "JDT": "Japanische Sommerzeit", "BT": "Bhutan-Zeit", "UYT": "Uruguyanische Normalzeit", "SRT": "Suriname-Zeit", "HECU": "Kubanische Sommerzeit", "WARST": "Westargentinische Sommerzeit", "HEOG": "Westgrönland-Sommerzeit", "ADT": "Atlantik-Sommerzeit", "HNPMX": "Mexiko Pazifikzone-Normalzeit", "HAT": "Neufundland-Sommerzeit", "LHDT": "Lord-Howe-Sommerzeit", "ECT": "Ecuadorianische Zeit", "CAT": "Zentralafrikanische Zeit", "VET": "Venezuela-Zeit", "HNT": "Neufundland-Normalzeit", "MDT": "Macau-Sommerzeit", "EDT": "Nordamerikanische Ostküsten-Sommerzeit", "WITA": "Zentralindonesische Zeit", "EAT": "Ostafrikanische Zeit", "∅∅∅": "Brasília-Sommerzeit", "IST": "Indische Zeit", "JST": "Japanische Normalzeit", "OEZ": "Osteuropäische Normalzeit", "HNEG": "Ostgrönland-Normalzeit", "HEPMX": "Mexiko Pazifikzone-Sommerzeit", "CHAST": "Chatham-Normalzeit", "NZST": "Neuseeland-Normalzeit", "NZDT": "Neuseeland-Sommerzeit", "HNNOMX": "Mexiko Nordwestliche Zone-Normalzeit", "WIB": "Westindonesische Zeit", "ACWDT": "Zentral-/Westaustralische Sommerzeit", "WESZ": "Westeuropäische Sommerzeit", "HKST": "Hongkong-Sommerzeit", "AKDT": "Alaska-Sommerzeit", "ChST": "Chamorro-Zeit", "HNPM": "Saint-Pierre-und-Miquelon-Normalzeit", "PDT": "Nordamerikanische Westküsten-Sommerzeit", "ACWST": "Zentral-/Westaustralische Normalzeit", "AST": "Atlantik-Normalzeit", "COT": "Kolumbianische Normalzeit", "SGT": "Singapur-Zeit", "WEZ": "Westeuropäische Normalzeit", "WAST": "Westafrikanische Sommerzeit", "AWST": "Westaustralische Normalzeit", "TMT": "Turkmenistan-Normalzeit", "MST": "Macau-Normalzeit", "HEEG": "Ostgrönland-Sommerzeit", "CHADT": "Chatham-Sommerzeit", "CLST": "Chilenische Sommerzeit", "EST": "Nordamerikanische Ostküsten-Normalzeit", "GFT": "Französisch-Guayana-Zeit", "CST": "Nordamerikanische Inland-Normalzeit", "HEPM": "Saint-Pierre-und-Miquelon-Sommerzeit"}, + } +} + +// Locale returns the current translators string locale +func (de *de_LU) Locale() string { + return de.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'de_LU' +func (de *de_LU) PluralsCardinal() []locales.PluralRule { + return de.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'de_LU' +func (de *de_LU) PluralsOrdinal() []locales.PluralRule { + return de.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'de_LU' +func (de *de_LU) PluralsRange() []locales.PluralRule { + return de.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'de_LU' +func (de *de_LU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'de_LU' +func (de *de_LU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'de_LU' +func (de *de_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := de.CardinalPluralRule(num1, v1) + end := de.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (de *de_LU) MonthAbbreviated(month time.Month) string { + return de.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (de *de_LU) MonthsAbbreviated() []string { + return de.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (de *de_LU) MonthNarrow(month time.Month) string { + return de.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (de *de_LU) MonthsNarrow() []string { + return de.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (de *de_LU) MonthWide(month time.Month) string { + return de.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (de *de_LU) MonthsWide() []string { + return de.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (de *de_LU) WeekdayAbbreviated(weekday time.Weekday) string { + return de.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (de *de_LU) WeekdaysAbbreviated() []string { + return de.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (de *de_LU) WeekdayNarrow(weekday time.Weekday) string { + return de.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (de *de_LU) WeekdaysNarrow() []string { + return de.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (de *de_LU) WeekdayShort(weekday time.Weekday) string { + return de.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (de *de_LU) WeekdaysShort() []string { + return de.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (de *de_LU) WeekdayWide(weekday time.Weekday) string { + return de.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (de *de_LU) WeekdaysWide() []string { + return de.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'de_LU' and handles both Whole and Real numbers based on 'v' +func (de *de_LU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'de_LU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (de *de_LU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, de.percentSuffix...) + + b = append(b, de.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'de_LU' +func (de *de_LU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, de.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, de.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'de_LU' +// in accounting notation. +func (de *de_LU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := de.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, de.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, de.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, de.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, de.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, de.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, de.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'de_LU' +func (de *de_LU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'de_LU' +func (de *de_LU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'de_LU' +func (de *de_LU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'de_LU' +func (de *de_LU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, de.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, de.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'de_LU' +func (de *de_LU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'de_LU' +func (de *de_LU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'de_LU' +func (de *de_LU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'de_LU' +func (de *de_LU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, de.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, de.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := de.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/de_LU/de_LU_test.go b/vendor/github.com/go-playground/locales/de_LU/de_LU_test.go new file mode 100644 index 0000000000..caef380b77 --- /dev/null +++ b/vendor/github.com/go-playground/locales/de_LU/de_LU_test.go @@ -0,0 +1,1120 @@ +package de_LU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "de_LU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dje/dje.go b/vendor/github.com/go-playground/locales/dje/dje.go new file mode 100644 index 0000000000..c7a1e47054 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dje/dje.go @@ -0,0 +1,563 @@ +package dje + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dje struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dje' locale +func New() locales.Translator { + return &dje{ + locale: "dje", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"}, + monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"}, + daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alz", "Asi"}, + daysNarrow: []string{"H", "T", "T", "L", "M", "Z", "S"}, + daysWide: []string{"Alhadi", "Atinni", "Atalaata", "Alarba", "Alhamisi", "Alzuma", "Asibti"}, + periodsAbbreviated: []string{"Subbaahi", "Zaarikay b"}, + periodsWide: []string{"Subbaahi", "Zaarikay b"}, + erasAbbreviated: []string{"IJ", "IZ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Isaa jine", "Isaa zamanoo"}, + timezones: map[string]string{"HNEG": "HNEG", "AEST": "AEST", "EAT": "EAT", "NZDT": "NZDT", "JDT": "JDT", "CHAST": "CHAST", "ADT": "ADT", "GMT": "GMT", "ACST": "ACST", "OEZ": "OEZ", "WART": "WART", "HENOMX": "HENOMX", "HAT": "HAT", "HNPM": "HNPM", "LHST": "LHST", "WIB": "WIB", "PST": "PST", "BT": "BT", "∅∅∅": "∅∅∅", "LHDT": "LHDT", "HKT": "HKT", "COST": "COST", "HNT": "HNT", "AKST": "AKST", "ACWDT": "ACWDT", "JST": "JST", "ART": "ART", "AEDT": "AEDT", "ACWST": "ACWST", "TMST": "TMST", "EDT": "EDT", "HECU": "HECU", "CST": "CST", "OESZ": "OESZ", "WAST": "WAST", "ACDT": "ACDT", "HEPMX": "HEPMX", "CHADT": "CHADT", "SGT": "SGT", "CAT": "CAT", "CLT": "CLT", "GFT": "GFT", "MEZ": "MEZ", "HEEG": "HEEG", "AWST": "AWST", "IST": "IST", "HEOG": "HEOG", "MYT": "MYT", "TMT": "TMT", "WAT": "WAT", "WITA": "WITA", "CDT": "CDT", "AWDT": "AWDT", "HADT": "HADT", "WESZ": "WESZ", "GYT": "GYT", "WARST": "WARST", "HNNOMX": "HNNOMX", "MDT": "MDT", "SAST": "SAST", "HNPMX": "HNPMX", "ECT": "ECT", "COT": "COT", "VET": "VET", "CLST": "CLST", "AST": "AST", "HEPM": "HEPM", "WIT": "WIT", "PDT": "PDT", "HAST": "HAST", "NZST": "NZST", "WEZ": "WEZ", "ARST": "ARST", "BOT": "BOT", "MESZ": "MESZ", "MST": "MST", "UYT": "UYT", "UYST": "UYST", "SRT": "SRT", "HNCU": "HNCU", "AKDT": "AKDT", "ChST": "ChST", "HNOG": "HNOG", "EST": "EST", "HKST": "HKST"}, + } +} + +// Locale returns the current translators string locale +func (dje *dje) Locale() string { + return dje.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dje' +func (dje *dje) PluralsCardinal() []locales.PluralRule { + return dje.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dje' +func (dje *dje) PluralsOrdinal() []locales.PluralRule { + return dje.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dje' +func (dje *dje) PluralsRange() []locales.PluralRule { + return dje.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dje' +func (dje *dje) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dje' +func (dje *dje) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dje' +func (dje *dje) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dje *dje) MonthAbbreviated(month time.Month) string { + return dje.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dje *dje) MonthsAbbreviated() []string { + return dje.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dje *dje) MonthNarrow(month time.Month) string { + return dje.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dje *dje) MonthsNarrow() []string { + return dje.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dje *dje) MonthWide(month time.Month) string { + return dje.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dje *dje) MonthsWide() []string { + return dje.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dje *dje) WeekdayAbbreviated(weekday time.Weekday) string { + return dje.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dje *dje) WeekdaysAbbreviated() []string { + return dje.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dje *dje) WeekdayNarrow(weekday time.Weekday) string { + return dje.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dje *dje) WeekdaysNarrow() []string { + return dje.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dje *dje) WeekdayShort(weekday time.Weekday) string { + return dje.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dje *dje) WeekdaysShort() []string { + return dje.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dje *dje) WeekdayWide(weekday time.Weekday) string { + return dje.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dje *dje) WeekdaysWide() []string { + return dje.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dje' and handles both Whole and Real numbers based on 'v' +func (dje *dje) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dje.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dje.group) - 1; j >= 0; j-- { + b = append(b, dje.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dje.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dje' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dje *dje) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dje.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dje.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dje.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dje' +func (dje *dje) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dje.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dje.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dje.group) - 1; j >= 0; j-- { + b = append(b, dje.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dje.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dje.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dje' +// in accounting notation. +func (dje *dje) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dje.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dje.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dje.group) - 1; j >= 0; j-- { + b = append(b, dje.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, dje.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dje.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dje' +func (dje *dje) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dje' +func (dje *dje) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dje.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dje' +func (dje *dje) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dje.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dje' +func (dje *dje) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dje.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dje.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dje' +func (dje *dje) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dje.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dje' +func (dje *dje) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dje.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dje.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dje' +func (dje *dje) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dje.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dje.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dje' +func (dje *dje) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dje.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dje.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dje.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dje/dje_test.go b/vendor/github.com/go-playground/locales/dje/dje_test.go new file mode 100644 index 0000000000..533dcfdce8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dje/dje_test.go @@ -0,0 +1,1120 @@ +package dje + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dje" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dje_NE/dje_NE.go b/vendor/github.com/go-playground/locales/dje_NE/dje_NE.go new file mode 100644 index 0000000000..2c6863bc95 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dje_NE/dje_NE.go @@ -0,0 +1,563 @@ +package dje_NE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dje_NE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dje_NE' locale +func New() locales.Translator { + return &dje_NE{ + locale: "dje_NE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"}, + monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"}, + daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alz", "Asi"}, + daysNarrow: []string{"H", "T", "T", "L", "M", "Z", "S"}, + daysWide: []string{"Alhadi", "Atinni", "Atalaata", "Alarba", "Alhamisi", "Alzuma", "Asibti"}, + periodsAbbreviated: []string{"Subbaahi", "Zaarikay b"}, + periodsWide: []string{"Subbaahi", "Zaarikay b"}, + erasAbbreviated: []string{"IJ", "IZ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Isaa jine", "Isaa zamanoo"}, + timezones: map[string]string{"GMT": "GMT", "WIB": "WIB", "PST": "PST", "OESZ": "OESZ", "HEEG": "HEEG", "∅∅∅": "∅∅∅", "TMT": "TMT", "WIT": "WIT", "ECT": "ECT", "PDT": "PDT", "HADT": "HADT", "CAT": "CAT", "IST": "IST", "MESZ": "MESZ", "HKST": "HKST", "BT": "BT", "HNPM": "HNPM", "HNPMX": "HNPMX", "AEDT": "AEDT", "NZST": "NZST", "ACDT": "ACDT", "GFT": "GFT", "HAST": "HAST", "UYT": "UYT", "MYT": "MYT", "WARST": "WARST", "ADT": "ADT", "WEZ": "WEZ", "WAT": "WAT", "AKST": "AKST", "AEST": "AEST", "HECU": "HECU", "CST": "CST", "CDT": "CDT", "ACWDT": "ACWDT", "HNOG": "HNOG", "OEZ": "OEZ", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "HNCU": "HNCU", "HEOG": "HEOG", "ARST": "ARST", "HKT": "HKT", "COT": "COT", "HNT": "HNT", "JST": "JST", "CLST": "CLST", "TMST": "TMST", "MDT": "MDT", "COST": "COST", "AWST": "AWST", "CHAST": "CHAST", "ART": "ART", "HAT": "HAT", "AKDT": "AKDT", "SAST": "SAST", "LHDT": "LHDT", "AST": "AST", "MST": "MST", "HEPM": "HEPM", "SRT": "SRT", "GYT": "GYT", "BOT": "BOT", "NZDT": "NZDT", "HEPMX": "HEPMX", "AWDT": "AWDT", "SGT": "SGT", "VET": "VET", "WESZ": "WESZ", "EDT": "EDT", "ChST": "ChST", "UYST": "UYST", "LHST": "LHST", "ACWST": "ACWST", "WITA": "WITA", "MEZ": "MEZ", "WART": "WART", "CLT": "CLT", "WAST": "WAST", "EST": "EST", "ACST": "ACST", "HNEG": "HNEG", "CHADT": "CHADT", "JDT": "JDT", "EAT": "EAT"}, + } +} + +// Locale returns the current translators string locale +func (dje *dje_NE) Locale() string { + return dje.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dje_NE' +func (dje *dje_NE) PluralsCardinal() []locales.PluralRule { + return dje.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dje_NE' +func (dje *dje_NE) PluralsOrdinal() []locales.PluralRule { + return dje.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dje_NE' +func (dje *dje_NE) PluralsRange() []locales.PluralRule { + return dje.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dje_NE' +func (dje *dje_NE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dje_NE' +func (dje *dje_NE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dje_NE' +func (dje *dje_NE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dje *dje_NE) MonthAbbreviated(month time.Month) string { + return dje.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dje *dje_NE) MonthsAbbreviated() []string { + return dje.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dje *dje_NE) MonthNarrow(month time.Month) string { + return dje.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dje *dje_NE) MonthsNarrow() []string { + return dje.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dje *dje_NE) MonthWide(month time.Month) string { + return dje.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dje *dje_NE) MonthsWide() []string { + return dje.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dje *dje_NE) WeekdayAbbreviated(weekday time.Weekday) string { + return dje.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dje *dje_NE) WeekdaysAbbreviated() []string { + return dje.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dje *dje_NE) WeekdayNarrow(weekday time.Weekday) string { + return dje.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dje *dje_NE) WeekdaysNarrow() []string { + return dje.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dje *dje_NE) WeekdayShort(weekday time.Weekday) string { + return dje.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dje *dje_NE) WeekdaysShort() []string { + return dje.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dje *dje_NE) WeekdayWide(weekday time.Weekday) string { + return dje.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dje *dje_NE) WeekdaysWide() []string { + return dje.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dje_NE' and handles both Whole and Real numbers based on 'v' +func (dje *dje_NE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dje.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dje.group) - 1; j >= 0; j-- { + b = append(b, dje.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dje.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dje_NE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dje *dje_NE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dje.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dje.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dje.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dje_NE' +func (dje *dje_NE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dje.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dje.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dje.group) - 1; j >= 0; j-- { + b = append(b, dje.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dje.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dje.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dje_NE' +// in accounting notation. +func (dje *dje_NE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dje.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dje.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dje.group) - 1; j >= 0; j-- { + b = append(b, dje.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, dje.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dje.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dje_NE' +func (dje *dje_NE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dje_NE' +func (dje *dje_NE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dje.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dje_NE' +func (dje *dje_NE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dje.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dje_NE' +func (dje *dje_NE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dje.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dje.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dje_NE' +func (dje *dje_NE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dje.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dje_NE' +func (dje *dje_NE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dje.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dje.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dje_NE' +func (dje *dje_NE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dje.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dje.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dje_NE' +func (dje *dje_NE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dje.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dje.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dje.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dje_NE/dje_NE_test.go b/vendor/github.com/go-playground/locales/dje_NE/dje_NE_test.go new file mode 100644 index 0000000000..1faaeaf38c --- /dev/null +++ b/vendor/github.com/go-playground/locales/dje_NE/dje_NE_test.go @@ -0,0 +1,1120 @@ +package dje_NE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dje_NE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dsb/dsb.go b/vendor/github.com/go-playground/locales/dsb/dsb.go new file mode 100644 index 0000000000..968e074276 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dsb/dsb.go @@ -0,0 +1,574 @@ +package dsb + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dsb struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dsb' locale +func New() locales.Translator { + return &dsb{ + locale: "dsb", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "zł", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "měr.", "apr.", "maj.", "jun.", "jul.", "awg.", "sep.", "okt.", "now.", "dec."}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januara", "februara", "měrca", "apryla", "maja", "junija", "julija", "awgusta", "septembra", "oktobra", "nowembra", "decembra"}, + daysAbbreviated: []string{"nje", "pón", "wał", "srj", "stw", "pět", "sob"}, + daysNarrow: []string{"n", "p", "w", "s", "s", "p", "s"}, + daysShort: []string{"nj", "pó", "wa", "sr", "st", "pě", "so"}, + daysWide: []string{"njeźela", "pónjeźele", "wałtora", "srjoda", "stwórtk", "pětk", "sobota"}, + periodsAbbreviated: []string{"dopołdnja", "wótpołdnja"}, + periodsNarrow: []string{"dop.", "wótp."}, + periodsWide: []string{"dopołdnja", "wótpołdnja"}, + erasAbbreviated: []string{"pś.Chr.n.", "pó Chr.n."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"pśed Kristusowym naroźenim", "pó Kristusowem naroźenju"}, + timezones: map[string]string{"ARST": "Argentinski lěśojski cas", "ECT": "Ekuadorski cas", "HEOG": "Pódwjacornogrönlandski lěśojski cas", "WARST": "Pódwjacornoargentinski lěśojski cas", "AKST": "Alaskojski standardny cas", "MESZ": "Srjejźoeuropski lěśojski cas", "WEZ": "Pódwjacornoeuropski standardny cas", "CAT": "Srjejźoafriski cas", "VET": "Venezuelski cas", "HNOG": "Pódwjacornogrönlandski standardny cas", "HKST": "Hongkongski lěśojski cas", "HNEG": "Pódzajtšnogrönlandski standardny cas", "AWST": "Pódwjacornoawstralski standardny cas", "NZDT": "Nowoseelandski lěśojski cas", "OESZ": "Pódzajtšnoeuropski lěśojski cas", "HNPM": "St.-Pierre-a-Miqueloński standardny cas", "IST": "Indiski cas", "WART": "Pódwjacornoargentinski standardny cas", "WAT": "Pódwjacornoafriski standardny cas", "WAST": "Pódwjacornoafriski lěśojski cas", "ACDT": "Srjejźoawstralski lěśojski cas", "GFT": "Francojskoguyański cas", "AKDT": "Alaskojski lěśojski cas", "JDT": "Japański lěśojski cas", "OEZ": "Pódzajtšnoeuropski standardny cas", "UYT": "Uruguayski standardny cas", "PDT": "Pódpołnocnoameriski pacifiski lěśojski cas", "HEPM": "St.-Pierre-a-Miqueloński lěśojski cas", "CLT": "Chilski standardny cas", "AST": "Atlantiski standardny cas", "TMST": "Turkmeniski lěśojski cas", "HNT": "Nowofundlandski standardny cas", "CDT": "Pódpołnocnoameriski centralny lěśojski cas", "GMT": "Greenwichski cas", "MST": "MST", "EDT": "Pódpołnocnoameriski pódzajtšny lěśojski cas", "HNNOMX": "Mexiski dłujkowjacorny standardny cas", "LHST": "Standardny cas kupy Lord-Howe", "PST": "Pódpołnocnoameriski pacifiski standardny cas", "ACWST": "Srjejźopódwjacorny awstralski standardny cas", "NZST": "Nowoseelandski standardny cas", "SRT": "Surinamski cas", "AWDT": "Pódwjacornoawstralski lěśojski cas", "CHAST": "Chathamski standardny cas", "JST": "Japański standardny cas", "HENOMX": "Mexiski dłujkowjacorny lěśojski cas", "WITA": "Srjejźoindoneski cas", "HECU": "Kubański lěśojski cas", "WIT": "Pódzajtšnoindoneski", "ACWDT": "Srjejźopódwjacorny awstralski lěśojski cas", "HKT": "Hongkongski standardny cas", "HEEG": "Pódzajtšnogrönlandski lěśojski cas", "ChST": "Chamorrski cas", "HAST": "Hawaiisko-aleutski standardny cas", "ART": "Argentinski standardny cas", "COT": "Kolumbiski standardny cas", "COST": "Kolumbiski lěśojski cas", "BT": "Bhutański cas", "HAT": "Nowofundlandski lěśojski cas", "UYST": "Uruguayski lěśojski cas", "SAST": "Pódpołdnjowoafriski cas", "HADT": "Hawaiisko-aleutski lěśojski cas", "WESZ": "Pódwjacornoeuropski lěśojski cas", "EAT": "Pódzajtšnoafriski cas", "AEST": "Pódzajtšnoawstralski standardny cas", "WIB": "Pódwjacornoindoneski cas", "HNCU": "Kubański standardny cas", "BOT": "Boliwiski cas", "EST": "Pódpołnocnoameriski pódzajtšny standardny cas", "HNPMX": "Mexiski pacifiski standardny cas", "LHDT": "lěśojski cas kupy Lord-Howe", "MYT": "Malajziski cas", "CLST": "Chilski lěśojski cas", "ADT": "Atlantiski lěśojski cas", "TMT": "Turkmeniski standardny cas", "MDT": "MDT", "GYT": "Guyański cas", "CST": "Pódpołnocnoameriski centralny standardny cas", "CHADT": "Chathamski lěśojski cas", "MEZ": "Srjejźoeuropski standardny cas", "ACST": "Srjejźoawstralski standardny cas", "AEDT": "Pódzajtšnoawstralski lěśojski cas", "HEPMX": "Mexiski pacifiski lěśojski cas", "∅∅∅": "Brasília lěśojski cas", "SGT": "Singapurski cas"}, + } +} + +// Locale returns the current translators string locale +func (dsb *dsb) Locale() string { + return dsb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dsb' +func (dsb *dsb) PluralsCardinal() []locales.PluralRule { + return dsb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dsb' +func (dsb *dsb) PluralsOrdinal() []locales.PluralRule { + return dsb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dsb' +func (dsb *dsb) PluralsRange() []locales.PluralRule { + return dsb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dsb' +func (dsb *dsb) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + fMod100 := f % 100 + + if (v == 0 && iMod100 == 1) || (fMod100 == 1) { + return locales.PluralRuleOne + } else if (v == 0 && iMod100 == 2) || (fMod100 == 2) { + return locales.PluralRuleTwo + } else if (v == 0 && iMod100 >= 3 && iMod100 <= 4) || (fMod100 >= 3 && fMod100 <= 4) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dsb' +func (dsb *dsb) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dsb' +func (dsb *dsb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dsb *dsb) MonthAbbreviated(month time.Month) string { + return dsb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dsb *dsb) MonthsAbbreviated() []string { + return dsb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dsb *dsb) MonthNarrow(month time.Month) string { + return dsb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dsb *dsb) MonthsNarrow() []string { + return dsb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dsb *dsb) MonthWide(month time.Month) string { + return dsb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dsb *dsb) MonthsWide() []string { + return dsb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dsb *dsb) WeekdayAbbreviated(weekday time.Weekday) string { + return dsb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dsb *dsb) WeekdaysAbbreviated() []string { + return dsb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dsb *dsb) WeekdayNarrow(weekday time.Weekday) string { + return dsb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dsb *dsb) WeekdaysNarrow() []string { + return dsb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dsb *dsb) WeekdayShort(weekday time.Weekday) string { + return dsb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dsb *dsb) WeekdaysShort() []string { + return dsb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dsb *dsb) WeekdayWide(weekday time.Weekday) string { + return dsb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dsb *dsb) WeekdaysWide() []string { + return dsb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dsb' and handles both Whole and Real numbers based on 'v' +func (dsb *dsb) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dsb' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dsb *dsb) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dsb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dsb.percentSuffix...) + + b = append(b, dsb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dsb' +func (dsb *dsb) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dsb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dsb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, dsb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dsb' +// in accounting notation. +func (dsb *dsb) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dsb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, dsb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dsb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, dsb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, dsb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dsb' +func (dsb *dsb) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dsb' +func (dsb *dsb) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dsb' +func (dsb *dsb) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, dsb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dsb' +func (dsb *dsb) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dsb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, dsb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dsb' +func (dsb *dsb) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dsb' +func (dsb *dsb) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dsb' +func (dsb *dsb) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dsb' +func (dsb *dsb) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dsb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dsb/dsb_test.go b/vendor/github.com/go-playground/locales/dsb/dsb_test.go new file mode 100644 index 0000000000..d770a8a153 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dsb/dsb_test.go @@ -0,0 +1,1120 @@ +package dsb + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dsb" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dsb_DE/dsb_DE.go b/vendor/github.com/go-playground/locales/dsb_DE/dsb_DE.go new file mode 100644 index 0000000000..f38df851ae --- /dev/null +++ b/vendor/github.com/go-playground/locales/dsb_DE/dsb_DE.go @@ -0,0 +1,574 @@ +package dsb_DE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dsb_DE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dsb_DE' locale +func New() locales.Translator { + return &dsb_DE{ + locale: "dsb_DE", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "měr.", "apr.", "maj.", "jun.", "jul.", "awg.", "sep.", "okt.", "now.", "dec."}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januara", "februara", "měrca", "apryla", "maja", "junija", "julija", "awgusta", "septembra", "oktobra", "nowembra", "decembra"}, + daysAbbreviated: []string{"nje", "pón", "wał", "srj", "stw", "pět", "sob"}, + daysNarrow: []string{"n", "p", "w", "s", "s", "p", "s"}, + daysShort: []string{"nj", "pó", "wa", "sr", "st", "pě", "so"}, + daysWide: []string{"njeźela", "pónjeźele", "wałtora", "srjoda", "stwórtk", "pětk", "sobota"}, + periodsAbbreviated: []string{"dopołdnja", "wótpołdnja"}, + periodsNarrow: []string{"dop.", "wótp."}, + periodsWide: []string{"dopołdnja", "wótpołdnja"}, + erasAbbreviated: []string{"pś.Chr.n.", "pó Chr.n."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"pśed Kristusowym naroźenim", "pó Kristusowem naroźenju"}, + timezones: map[string]string{"ARST": "Argentinski lěśojski cas", "HKST": "Hongkongski lěśojski cas", "ACST": "Srjejźoawstralski standardny cas", "AKST": "Alaskojski standardny cas", "HNPM": "St.-Pierre-a-Miqueloński standardny cas", "HNOG": "Pódwjacornogrönlandski standardny cas", "ADT": "Atlantiski lěśojski cas", "WEZ": "Pódwjacornoeuropski standardny cas", "HNNOMX": "Mexiski dłujkowjacorny standardny cas", "AEST": "Pódzajtšnoawstralski standardny cas", "HNPMX": "Mexiski pacifiski standardny cas", "ACWDT": "Srjejźopódwjacorny awstralski lěśojski cas", "∅∅∅": "Amaconaski lěśojski cas", "CDT": "Pódpołnocnoameriski centralny lěśojski cas", "ChST": "Chamorrski cas", "HNCU": "Kubański standardny cas", "HEOG": "Pódwjacornogrönlandski lěśojski cas", "WAT": "Pódwjacornoafriski standardny cas", "WESZ": "Pódwjacornoeuropski lěśojski cas", "CLST": "Chilski lěśojski cas", "NZDT": "Nowoseelandski lěśojski cas", "GMT": "Greenwichski cas", "AST": "Atlantiski standardny cas", "ART": "Argentinski standardny cas", "HEEG": "Pódzajtšnogrönlandski lěśojski cas", "AKDT": "Alaskojski lěśojski cas", "PST": "Pódpołnocnoameriski pacifiski standardny cas", "NZST": "Nowoseelandski standardny cas", "HEPM": "St.-Pierre-a-Miqueloński lěśojski cas", "VET": "Venezuelski cas", "WART": "Pódwjacornoargentinski standardny cas", "MST": "MST", "HNEG": "Pódzajtšnogrönlandski standardny cas", "WITA": "Srjejźoindoneski cas", "LHST": "Standardny cas kupy Lord-Howe", "CHADT": "Chathamski lěśojski cas", "PDT": "Pódpołnocnoameriski pacifiski lěśojski cas", "HKT": "Hongkongski standardny cas", "UYST": "Uruguayski lěśojski cas", "LHDT": "lěśojski cas kupy Lord-Howe", "GYT": "Guyański cas", "HECU": "Kubański lěśojski cas", "CST": "Pódpołnocnoameriski centralny standardny cas", "HADT": "Hawaiisko-aleutski lěśojski cas", "MYT": "Malajziski cas", "AWST": "Pódwjacornoawstralski standardny cas", "HENOMX": "Mexiski dłujkowjacorny lěśojski cas", "HAT": "Nowofundlandski lěśojski cas", "GFT": "Francojskoguyański cas", "SRT": "Surinamski cas", "MESZ": "Srjejźoeuropski lěśojski cas", "TMT": "Turkmeniski standardny cas", "CLT": "Chilski standardny cas", "ACDT": "Srjejźoawstralski lěśojski cas", "COST": "Kolumbiski lěśojski cas", "AEDT": "Pódzajtšnoawstralski lěśojski cas", "SGT": "Singapurski cas", "IST": "Indiski cas", "OEZ": "Pódzajtšnoeuropski standardny cas", "MDT": "MDT", "EDT": "Pódpołnocnoameriski pódzajtšny lěśojski cas", "COT": "Kolumbiski standardny cas", "SAST": "Pódpołdnjowoafriski cas", "AWDT": "Pódwjacornoawstralski lěśojski cas", "HAST": "Hawaiisko-aleutski standardny cas", "WARST": "Pódwjacornoargentinski lěśojski cas", "WAST": "Pódwjacornoafriski lěśojski cas", "HNT": "Nowofundlandski standardny cas", "JDT": "Japański lěśojski cas", "OESZ": "Pódzajtšnoeuropski lěśojski cas", "MEZ": "Srjejźoeuropski standardny cas", "EAT": "Pódzajtšnoafriski cas", "CHAST": "Chathamski standardny cas", "UYT": "Uruguayski standardny cas", "EST": "Pódpołnocnoameriski pódzajtšny standardny cas", "WIB": "Pódwjacornoindoneski cas", "ECT": "Ekuadorski cas", "ACWST": "Srjejźopódwjacorny awstralski standardny cas", "HEPMX": "Mexiski pacifiski lěśojski cas", "WIT": "Pódzajtšnoindoneski", "BOT": "Boliwiski cas", "JST": "Japański standardny cas", "BT": "Bhutański cas", "CAT": "Srjejźoafriski cas", "TMST": "Turkmeniski lěśojski cas"}, + } +} + +// Locale returns the current translators string locale +func (dsb *dsb_DE) Locale() string { + return dsb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dsb_DE' +func (dsb *dsb_DE) PluralsCardinal() []locales.PluralRule { + return dsb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dsb_DE' +func (dsb *dsb_DE) PluralsOrdinal() []locales.PluralRule { + return dsb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dsb_DE' +func (dsb *dsb_DE) PluralsRange() []locales.PluralRule { + return dsb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dsb_DE' +func (dsb *dsb_DE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + fMod100 := f % 100 + + if (v == 0 && iMod100 == 1) || (fMod100 == 1) { + return locales.PluralRuleOne + } else if (v == 0 && iMod100 == 2) || (fMod100 == 2) { + return locales.PluralRuleTwo + } else if (v == 0 && iMod100 >= 3 && iMod100 <= 4) || (fMod100 >= 3 && fMod100 <= 4) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dsb_DE' +func (dsb *dsb_DE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dsb_DE' +func (dsb *dsb_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dsb *dsb_DE) MonthAbbreviated(month time.Month) string { + return dsb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dsb *dsb_DE) MonthsAbbreviated() []string { + return dsb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dsb *dsb_DE) MonthNarrow(month time.Month) string { + return dsb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dsb *dsb_DE) MonthsNarrow() []string { + return dsb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dsb *dsb_DE) MonthWide(month time.Month) string { + return dsb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dsb *dsb_DE) MonthsWide() []string { + return dsb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dsb *dsb_DE) WeekdayAbbreviated(weekday time.Weekday) string { + return dsb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dsb *dsb_DE) WeekdaysAbbreviated() []string { + return dsb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dsb *dsb_DE) WeekdayNarrow(weekday time.Weekday) string { + return dsb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dsb *dsb_DE) WeekdaysNarrow() []string { + return dsb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dsb *dsb_DE) WeekdayShort(weekday time.Weekday) string { + return dsb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dsb *dsb_DE) WeekdaysShort() []string { + return dsb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dsb *dsb_DE) WeekdayWide(weekday time.Weekday) string { + return dsb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dsb *dsb_DE) WeekdaysWide() []string { + return dsb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dsb_DE' and handles both Whole and Real numbers based on 'v' +func (dsb *dsb_DE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dsb_DE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dsb *dsb_DE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dsb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dsb.percentSuffix...) + + b = append(b, dsb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dsb_DE' +func (dsb *dsb_DE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dsb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dsb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, dsb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dsb_DE' +// in accounting notation. +func (dsb *dsb_DE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dsb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, dsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, dsb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dsb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, dsb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, dsb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dsb_DE' +func (dsb *dsb_DE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dsb_DE' +func (dsb *dsb_DE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dsb_DE' +func (dsb *dsb_DE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, dsb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dsb_DE' +func (dsb *dsb_DE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dsb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, dsb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dsb_DE' +func (dsb *dsb_DE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dsb_DE' +func (dsb *dsb_DE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dsb_DE' +func (dsb *dsb_DE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dsb_DE' +func (dsb *dsb_DE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dsb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dsb_DE/dsb_DE_test.go b/vendor/github.com/go-playground/locales/dsb_DE/dsb_DE_test.go new file mode 100644 index 0000000000..0f81371ebe --- /dev/null +++ b/vendor/github.com/go-playground/locales/dsb_DE/dsb_DE_test.go @@ -0,0 +1,1120 @@ +package dsb_DE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dsb_DE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dua/dua.go b/vendor/github.com/go-playground/locales/dua/dua.go new file mode 100644 index 0000000000..0a7adcbe8d --- /dev/null +++ b/vendor/github.com/go-playground/locales/dua/dua.go @@ -0,0 +1,575 @@ +package dua + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dua struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dua' locale +func New() locales.Translator { + return &dua{ + locale: "dua", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "di", "ŋgɔn", "sɔŋ", "diɓ", "emi", "esɔ", "mad", "diŋ", "nyɛt", "may", "tin", "elá"}, + monthsNarrow: []string{"", "d", "ŋ", "s", "d", "e", "e", "m", "d", "n", "m", "t", "e"}, + monthsWide: []string{"", "dimɔ́di", "ŋgɔndɛ", "sɔŋɛ", "diɓáɓá", "emiasele", "esɔpɛsɔpɛ", "madiɓɛ́díɓɛ́", "diŋgindi", "nyɛtɛki", "mayésɛ́", "tiníní", "eláŋgɛ́"}, + daysAbbreviated: []string{"ét", "mɔ́s", "kwa", "muk", "ŋgi", "ɗón", "esa"}, + daysNarrow: []string{"e", "m", "k", "m", "ŋ", "ɗ", "e"}, + daysWide: []string{"éti", "mɔ́sú", "kwasú", "mukɔ́sú", "ŋgisú", "ɗónɛsú", "esaɓasú"}, + periodsAbbreviated: []string{"idiɓa", "ebyámu"}, + periodsWide: []string{"idiɓa", "ebyámu"}, + erasAbbreviated: []string{"ɓ.Ys", "mb.Ys"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ɓoso ɓwá yáɓe lá", "mbúsa kwédi a Yés"}, + timezones: map[string]string{"WARST": "WARST", "LHST": "LHST", "EAT": "EAT", "HAST": "HAST", "VET": "VET", "WART": "WART", "ART": "ART", "HNCU": "HNCU", "SGT": "SGT", "AST": "AST", "HKT": "HKT", "CST": "CST", "CAT": "CAT", "HKST": "HKST", "WITA": "WITA", "AKST": "AKST", "ChST": "ChST", "UYT": "UYT", "HEPM": "HEPM", "CDT": "CDT", "NZST": "NZST", "JST": "JST", "ARST": "ARST", "HEEG": "HEEG", "AKDT": "AKDT", "AEST": "AEST", "LHDT": "LHDT", "WIB": "WIB", "BOT": "BOT", "PST": "PST", "WEZ": "WEZ", "HNNOMX": "HNNOMX", "BT": "BT", "UYST": "UYST", "AWDT": "AWDT", "CHADT": "CHADT", "NZDT": "NZDT", "MEZ": "MEZ", "WESZ": "WESZ", "HENOMX": "HENOMX", "HAT": "HAT", "HNPM": "HNPM", "CLT": "CLT", "OEZ": "OEZ", "COST": "COST", "AEDT": "AEDT", "PDT": "PDT", "HADT": "HADT", "ACWDT": "ACWDT", "TMT": "TMT", "GFT": "GFT", "HNPMX": "HNPMX", "WIT": "WIT", "CLST": "CLST", "HEOG": "HEOG", "IST": "IST", "MYT": "MYT", "TMST": "TMST", "WAST": "WAST", "ACDT": "ACDT", "COT": "COT", "SRT": "SRT", "∅∅∅": "∅∅∅", "ACWST": "ACWST", "ADT": "ADT", "MST": "MST", "EST": "EST", "HNT": "HNT", "MESZ": "MESZ", "EDT": "EDT", "HEPMX": "HEPMX", "GYT": "GYT", "HECU": "HECU", "HNOG": "HNOG", "OESZ": "OESZ", "WAT": "WAT", "HNEG": "HNEG", "AWST": "AWST", "CHAST": "CHAST", "ECT": "ECT", "JDT": "JDT", "GMT": "GMT", "MDT": "MDT", "ACST": "ACST", "SAST": "SAST"}, + } +} + +// Locale returns the current translators string locale +func (dua *dua) Locale() string { + return dua.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dua' +func (dua *dua) PluralsCardinal() []locales.PluralRule { + return dua.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dua' +func (dua *dua) PluralsOrdinal() []locales.PluralRule { + return dua.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dua' +func (dua *dua) PluralsRange() []locales.PluralRule { + return dua.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dua' +func (dua *dua) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dua' +func (dua *dua) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dua' +func (dua *dua) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dua *dua) MonthAbbreviated(month time.Month) string { + return dua.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dua *dua) MonthsAbbreviated() []string { + return dua.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dua *dua) MonthNarrow(month time.Month) string { + return dua.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dua *dua) MonthsNarrow() []string { + return dua.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dua *dua) MonthWide(month time.Month) string { + return dua.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dua *dua) MonthsWide() []string { + return dua.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dua *dua) WeekdayAbbreviated(weekday time.Weekday) string { + return dua.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dua *dua) WeekdaysAbbreviated() []string { + return dua.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dua *dua) WeekdayNarrow(weekday time.Weekday) string { + return dua.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dua *dua) WeekdaysNarrow() []string { + return dua.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dua *dua) WeekdayShort(weekday time.Weekday) string { + return dua.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dua *dua) WeekdaysShort() []string { + return dua.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dua *dua) WeekdayWide(weekday time.Weekday) string { + return dua.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dua *dua) WeekdaysWide() []string { + return dua.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dua' and handles both Whole and Real numbers based on 'v' +func (dua *dua) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dua.group) - 1; j >= 0; j-- { + b = append(b, dua.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dua' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dua *dua) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dua.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dua.percentSuffix...) + + b = append(b, dua.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dua' +func (dua *dua) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dua.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dua.group) - 1; j >= 0; j-- { + b = append(b, dua.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dua.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, dua.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dua' +// in accounting notation. +func (dua *dua) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dua.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dua.group) - 1; j >= 0; j-- { + b = append(b, dua.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, dua.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dua.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, dua.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, dua.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dua' +func (dua *dua) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dua' +func (dua *dua) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dua.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dua' +func (dua *dua) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dua.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dua' +func (dua *dua) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dua.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dua.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dua' +func (dua *dua) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dua' +func (dua *dua) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dua' +func (dua *dua) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dua' +func (dua *dua) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dua.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dua/dua_test.go b/vendor/github.com/go-playground/locales/dua/dua_test.go new file mode 100644 index 0000000000..358f6a8869 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dua/dua_test.go @@ -0,0 +1,1120 @@ +package dua + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dua" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dua_CM/dua_CM.go b/vendor/github.com/go-playground/locales/dua_CM/dua_CM.go new file mode 100644 index 0000000000..45be2cea0c --- /dev/null +++ b/vendor/github.com/go-playground/locales/dua_CM/dua_CM.go @@ -0,0 +1,575 @@ +package dua_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dua_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dua_CM' locale +func New() locales.Translator { + return &dua_CM{ + locale: "dua_CM", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "di", "ŋgɔn", "sɔŋ", "diɓ", "emi", "esɔ", "mad", "diŋ", "nyɛt", "may", "tin", "elá"}, + monthsNarrow: []string{"", "d", "ŋ", "s", "d", "e", "e", "m", "d", "n", "m", "t", "e"}, + monthsWide: []string{"", "dimɔ́di", "ŋgɔndɛ", "sɔŋɛ", "diɓáɓá", "emiasele", "esɔpɛsɔpɛ", "madiɓɛ́díɓɛ́", "diŋgindi", "nyɛtɛki", "mayésɛ́", "tiníní", "eláŋgɛ́"}, + daysAbbreviated: []string{"ét", "mɔ́s", "kwa", "muk", "ŋgi", "ɗón", "esa"}, + daysNarrow: []string{"e", "m", "k", "m", "ŋ", "ɗ", "e"}, + daysWide: []string{"éti", "mɔ́sú", "kwasú", "mukɔ́sú", "ŋgisú", "ɗónɛsú", "esaɓasú"}, + periodsAbbreviated: []string{"idiɓa", "ebyámu"}, + periodsWide: []string{"idiɓa", "ebyámu"}, + erasAbbreviated: []string{"ɓ.Ys", "mb.Ys"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ɓoso ɓwá yáɓe lá", "mbúsa kwédi a Yés"}, + timezones: map[string]string{"CDT": "CDT", "HKT": "HKT", "GFT": "GFT", "MEZ": "MEZ", "JST": "JST", "WART": "WART", "HAST": "HAST", "CAT": "CAT", "MESZ": "MESZ", "ARST": "ARST", "HENOMX": "HENOMX", "HNT": "HNT", "VET": "VET", "MYT": "MYT", "MDT": "MDT", "HAT": "HAT", "HEEG": "HEEG", "LHDT": "LHDT", "HEPMX": "HEPMX", "CLST": "CLST", "OEZ": "OEZ", "AST": "AST", "WEZ": "WEZ", "EDT": "EDT", "SAST": "SAST", "SRT": "SRT", "IST": "IST", "HNOG": "HNOG", "TMT": "TMT", "ACWST": "ACWST", "GMT": "GMT", "HNNOMX": "HNNOMX", "WESZ": "WESZ", "MST": "MST", "ACST": "ACST", "ACDT": "ACDT", "GYT": "GYT", "BOT": "BOT", "JDT": "JDT", "WAT": "WAT", "HNPM": "HNPM", "LHST": "LHST", "EAT": "EAT", "AWST": "AWST", "AWDT": "AWDT", "∅∅∅": "∅∅∅", "WAST": "WAST", "TMST": "TMST", "ART": "ART", "HKST": "HKST", "UYT": "UYT", "UYST": "UYST", "HNCU": "HNCU", "ADT": "ADT", "WARST": "WARST", "WIB": "WIB", "CHADT": "CHADT", "AKDT": "AKDT", "AEST": "AEST", "CST": "CST", "PST": "PST", "NZDT": "NZDT", "HNEG": "HNEG", "AKST": "AKST", "AEDT": "AEDT", "ACWDT": "ACWDT", "BT": "BT", "NZST": "NZST", "CLT": "CLT", "EST": "EST", "COST": "COST", "HNPMX": "HNPMX", "CHAST": "CHAST", "PDT": "PDT", "HADT": "HADT", "WITA": "WITA", "ChST": "ChST", "WIT": "WIT", "SGT": "SGT", "HEOG": "HEOG", "OESZ": "OESZ", "HEPM": "HEPM", "HECU": "HECU", "ECT": "ECT", "COT": "COT"}, + } +} + +// Locale returns the current translators string locale +func (dua *dua_CM) Locale() string { + return dua.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dua_CM' +func (dua *dua_CM) PluralsCardinal() []locales.PluralRule { + return dua.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dua_CM' +func (dua *dua_CM) PluralsOrdinal() []locales.PluralRule { + return dua.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dua_CM' +func (dua *dua_CM) PluralsRange() []locales.PluralRule { + return dua.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dua_CM' +func (dua *dua_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dua_CM' +func (dua *dua_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dua_CM' +func (dua *dua_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dua *dua_CM) MonthAbbreviated(month time.Month) string { + return dua.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dua *dua_CM) MonthsAbbreviated() []string { + return dua.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dua *dua_CM) MonthNarrow(month time.Month) string { + return dua.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dua *dua_CM) MonthsNarrow() []string { + return dua.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dua *dua_CM) MonthWide(month time.Month) string { + return dua.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dua *dua_CM) MonthsWide() []string { + return dua.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dua *dua_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return dua.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dua *dua_CM) WeekdaysAbbreviated() []string { + return dua.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dua *dua_CM) WeekdayNarrow(weekday time.Weekday) string { + return dua.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dua *dua_CM) WeekdaysNarrow() []string { + return dua.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dua *dua_CM) WeekdayShort(weekday time.Weekday) string { + return dua.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dua *dua_CM) WeekdaysShort() []string { + return dua.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dua *dua_CM) WeekdayWide(weekday time.Weekday) string { + return dua.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dua *dua_CM) WeekdaysWide() []string { + return dua.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dua_CM' and handles both Whole and Real numbers based on 'v' +func (dua *dua_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dua.group) - 1; j >= 0; j-- { + b = append(b, dua.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dua_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dua *dua_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dua.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dua.percentSuffix...) + + b = append(b, dua.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dua_CM' +func (dua *dua_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dua.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dua.group) - 1; j >= 0; j-- { + b = append(b, dua.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dua.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, dua.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dua_CM' +// in accounting notation. +func (dua *dua_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dua.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dua.group) - 1; j >= 0; j-- { + b = append(b, dua.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, dua.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dua.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, dua.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, dua.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dua_CM' +func (dua *dua_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dua_CM' +func (dua *dua_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dua.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dua_CM' +func (dua *dua_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dua.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dua_CM' +func (dua *dua_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dua.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dua.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dua_CM' +func (dua *dua_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dua_CM' +func (dua *dua_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dua_CM' +func (dua *dua_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dua_CM' +func (dua *dua_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dua.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dua_CM/dua_CM_test.go b/vendor/github.com/go-playground/locales/dua_CM/dua_CM_test.go new file mode 100644 index 0000000000..b0b0d55991 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dua_CM/dua_CM_test.go @@ -0,0 +1,1120 @@ +package dua_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dua_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dyo/dyo.go b/vendor/github.com/go-playground/locales/dyo/dyo.go new file mode 100644 index 0000000000..034460e90c --- /dev/null +++ b/vendor/github.com/go-playground/locales/dyo/dyo.go @@ -0,0 +1,569 @@ +package dyo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dyo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dyo' locale +func New() locales.Translator { + return &dyo{ + locale: "dyo", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Sa", "Fe", "Ma", "Ab", "Me", "Su", "Sú", "Ut", "Se", "Ok", "No", "De"}, + monthsNarrow: []string{"", "S", "F", "M", "A", "M", "S", "S", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Sanvie", "Fébirie", "Mars", "Aburil", "Mee", "Sueŋ", "Súuyee", "Ut", "Settembar", "Oktobar", "Novembar", "Disambar"}, + daysAbbreviated: []string{"Dim", "Ten", "Tal", "Ala", "Ara", "Arj", "Sib"}, + daysNarrow: []string{"D", "T", "T", "A", "A", "A", "S"}, + daysWide: []string{"Dimas", "Teneŋ", "Talata", "Alarbay", "Aramisay", "Arjuma", "Sibiti"}, + erasAbbreviated: []string{"ArY", "AtY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Ariŋuu Yeesu", "Atooŋe Yeesu"}, + timezones: map[string]string{"HADT": "HADT", "CAT": "CAT", "JST": "JST", "EDT": "EDT", "COT": "COT", "COST": "COST", "HNEG": "HNEG", "HEPM": "HEPM", "SRT": "SRT", "BOT": "BOT", "ACWDT": "ACWDT", "CLST": "CLST", "HENOMX": "HENOMX", "HNT": "HNT", "AEST": "AEST", "HEPMX": "HEPMX", "CHADT": "CHADT", "MYT": "MYT", "WARST": "WARST", "HEOG": "HEOG", "AST": "AST", "OEZ": "OEZ", "WESZ": "WESZ", "MDT": "MDT", "ACDT": "ACDT", "ChST": "ChST", "HNPMX": "HNPMX", "AKDT": "AKDT", "SGT": "SGT", "WEZ": "WEZ", "HKT": "HKT", "HAT": "HAT", "NZST": "NZST", "NZDT": "NZDT", "AKST": "AKST", "GYT": "GYT", "EAT": "EAT", "AWST": "AWST", "AWDT": "AWDT", "MEZ": "MEZ", "TMT": "TMT", "ARST": "ARST", "WITA": "WITA", "LHDT": "LHDT", "CST": "CST", "CHAST": "CHAST", "PDT": "PDT", "OESZ": "OESZ", "EST": "EST", "HKST": "HKST", "HEEG": "HEEG", "CDT": "CDT", "PST": "PST", "HNOG": "HNOG", "UYST": "UYST", "SAST": "SAST", "HAST": "HAST", "WART": "WART", "WAT": "WAT", "HNNOMX": "HNNOMX", "BT": "BT", "LHST": "LHST", "HNCU": "HNCU", "IST": "IST", "ACWST": "ACWST", "ART": "ART", "ACST": "ACST", "HNPM": "HNPM", "HECU": "HECU", "WIB": "WIB", "GMT": "GMT", "TMST": "TMST", "AEDT": "AEDT", "WIT": "WIT", "ECT": "ECT", "∅∅∅": "∅∅∅", "GFT": "GFT", "UYT": "UYT", "MESZ": "MESZ", "VET": "VET", "JDT": "JDT", "CLT": "CLT", "ADT": "ADT", "MST": "MST", "WAST": "WAST"}, + } +} + +// Locale returns the current translators string locale +func (dyo *dyo) Locale() string { + return dyo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dyo' +func (dyo *dyo) PluralsCardinal() []locales.PluralRule { + return dyo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dyo' +func (dyo *dyo) PluralsOrdinal() []locales.PluralRule { + return dyo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dyo' +func (dyo *dyo) PluralsRange() []locales.PluralRule { + return dyo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dyo' +func (dyo *dyo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dyo' +func (dyo *dyo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dyo' +func (dyo *dyo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dyo *dyo) MonthAbbreviated(month time.Month) string { + return dyo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dyo *dyo) MonthsAbbreviated() []string { + return dyo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dyo *dyo) MonthNarrow(month time.Month) string { + return dyo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dyo *dyo) MonthsNarrow() []string { + return dyo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dyo *dyo) MonthWide(month time.Month) string { + return dyo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dyo *dyo) MonthsWide() []string { + return dyo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dyo *dyo) WeekdayAbbreviated(weekday time.Weekday) string { + return dyo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dyo *dyo) WeekdaysAbbreviated() []string { + return dyo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dyo *dyo) WeekdayNarrow(weekday time.Weekday) string { + return dyo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dyo *dyo) WeekdaysNarrow() []string { + return dyo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dyo *dyo) WeekdayShort(weekday time.Weekday) string { + return dyo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dyo *dyo) WeekdaysShort() []string { + return dyo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dyo *dyo) WeekdayWide(weekday time.Weekday) string { + return dyo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dyo *dyo) WeekdaysWide() []string { + return dyo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dyo' and handles both Whole and Real numbers based on 'v' +func (dyo *dyo) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dyo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dyo.group) - 1; j >= 0; j-- { + b = append(b, dyo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dyo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dyo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dyo *dyo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dyo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dyo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dyo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dyo' +func (dyo *dyo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dyo.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dyo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dyo.group) - 1; j >= 0; j-- { + b = append(b, dyo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dyo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dyo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, dyo.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dyo' +// in accounting notation. +func (dyo *dyo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dyo.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dyo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dyo.group) - 1; j >= 0; j-- { + b = append(b, dyo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, dyo.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dyo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, dyo.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, dyo.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dyo' +func (dyo *dyo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dyo' +func (dyo *dyo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dyo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dyo' +func (dyo *dyo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dyo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dyo' +func (dyo *dyo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dyo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dyo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dyo' +func (dyo *dyo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dyo' +func (dyo *dyo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dyo' +func (dyo *dyo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dyo' +func (dyo *dyo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dyo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dyo/dyo_test.go b/vendor/github.com/go-playground/locales/dyo/dyo_test.go new file mode 100644 index 0000000000..f896b316e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dyo/dyo_test.go @@ -0,0 +1,1120 @@ +package dyo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dyo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dyo_SN/dyo_SN.go b/vendor/github.com/go-playground/locales/dyo_SN/dyo_SN.go new file mode 100644 index 0000000000..a46c8065db --- /dev/null +++ b/vendor/github.com/go-playground/locales/dyo_SN/dyo_SN.go @@ -0,0 +1,569 @@ +package dyo_SN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dyo_SN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dyo_SN' locale +func New() locales.Translator { + return &dyo_SN{ + locale: "dyo_SN", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Sa", "Fe", "Ma", "Ab", "Me", "Su", "Sú", "Ut", "Se", "Ok", "No", "De"}, + monthsNarrow: []string{"", "S", "F", "M", "A", "M", "S", "S", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Sanvie", "Fébirie", "Mars", "Aburil", "Mee", "Sueŋ", "Súuyee", "Ut", "Settembar", "Oktobar", "Novembar", "Disambar"}, + daysAbbreviated: []string{"Dim", "Ten", "Tal", "Ala", "Ara", "Arj", "Sib"}, + daysNarrow: []string{"D", "T", "T", "A", "A", "A", "S"}, + daysWide: []string{"Dimas", "Teneŋ", "Talata", "Alarbay", "Aramisay", "Arjuma", "Sibiti"}, + erasAbbreviated: []string{"ArY", "AtY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Ariŋuu Yeesu", "Atooŋe Yeesu"}, + timezones: map[string]string{"CHADT": "CHADT", "ACWDT": "ACWDT", "HKST": "HKST", "ACST": "ACST", "ACDT": "ACDT", "HEEG": "HEEG", "HEPMX": "HEPMX", "HNCU": "HNCU", "CLST": "CLST", "ChST": "ChST", "BOT": "BOT", "HKT": "HKT", "SGT": "SGT", "ECT": "ECT", "MESZ": "MESZ", "AWST": "AWST", "ART": "ART", "WITA": "WITA", "AEST": "AEST", "LHST": "LHST", "JST": "JST", "AST": "AST", "WESZ": "WESZ", "EDT": "EDT", "COST": "COST", "HNNOMX": "HNNOMX", "CAT": "CAT", "HNPMX": "HNPMX", "CST": "CST", "JDT": "JDT", "WARST": "WARST", "HEPM": "HEPM", "WEZ": "WEZ", "HAT": "HAT", "AWDT": "AWDT", "SAST": "SAST", "LHDT": "LHDT", "ARST": "ARST", "BT": "BT", "HNEG": "HNEG", "AEDT": "AEDT", "HNPM": "HNPM", "PDT": "PDT", "NZST": "NZST", "MEZ": "MEZ", "EST": "EST", "GFT": "GFT", "PST": "PST", "GYT": "GYT", "HADT": "HADT", "IST": "IST", "ADT": "ADT", "OEZ": "OEZ", "GMT": "GMT", "MYT": "MYT", "UYST": "UYST", "MST": "MST", "AKDT": "AKDT", "TMT": "TMT", "WIT": "WIT", "VET": "VET", "HNOG": "HNOG", "HEOG": "HEOG", "CDT": "CDT", "HECU": "HECU", "NZDT": "NZDT", "WAT": "WAT", "∅∅∅": "∅∅∅", "EAT": "EAT", "WIB": "WIB", "ACWST": "ACWST", "CLT": "CLT", "TMST": "TMST", "MDT": "MDT", "COT": "COT", "SRT": "SRT", "AKST": "AKST", "HNT": "HNT", "CHAST": "CHAST", "HAST": "HAST", "OESZ": "OESZ", "WART": "WART", "WAST": "WAST", "HENOMX": "HENOMX", "UYT": "UYT"}, + } +} + +// Locale returns the current translators string locale +func (dyo *dyo_SN) Locale() string { + return dyo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dyo_SN' +func (dyo *dyo_SN) PluralsCardinal() []locales.PluralRule { + return dyo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dyo_SN' +func (dyo *dyo_SN) PluralsOrdinal() []locales.PluralRule { + return dyo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dyo_SN' +func (dyo *dyo_SN) PluralsRange() []locales.PluralRule { + return dyo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dyo_SN' +func (dyo *dyo_SN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dyo_SN' +func (dyo *dyo_SN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dyo_SN' +func (dyo *dyo_SN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dyo *dyo_SN) MonthAbbreviated(month time.Month) string { + return dyo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dyo *dyo_SN) MonthsAbbreviated() []string { + return dyo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dyo *dyo_SN) MonthNarrow(month time.Month) string { + return dyo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dyo *dyo_SN) MonthsNarrow() []string { + return dyo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dyo *dyo_SN) MonthWide(month time.Month) string { + return dyo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dyo *dyo_SN) MonthsWide() []string { + return dyo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dyo *dyo_SN) WeekdayAbbreviated(weekday time.Weekday) string { + return dyo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dyo *dyo_SN) WeekdaysAbbreviated() []string { + return dyo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dyo *dyo_SN) WeekdayNarrow(weekday time.Weekday) string { + return dyo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dyo *dyo_SN) WeekdaysNarrow() []string { + return dyo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dyo *dyo_SN) WeekdayShort(weekday time.Weekday) string { + return dyo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dyo *dyo_SN) WeekdaysShort() []string { + return dyo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dyo *dyo_SN) WeekdayWide(weekday time.Weekday) string { + return dyo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dyo *dyo_SN) WeekdaysWide() []string { + return dyo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dyo_SN' and handles both Whole and Real numbers based on 'v' +func (dyo *dyo_SN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dyo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dyo.group) - 1; j >= 0; j-- { + b = append(b, dyo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dyo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dyo_SN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dyo *dyo_SN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dyo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dyo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dyo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dyo_SN' +func (dyo *dyo_SN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dyo.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dyo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dyo.group) - 1; j >= 0; j-- { + b = append(b, dyo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dyo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dyo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, dyo.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dyo_SN' +// in accounting notation. +func (dyo *dyo_SN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dyo.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dyo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(dyo.group) - 1; j >= 0; j-- { + b = append(b, dyo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, dyo.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dyo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, dyo.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, dyo.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dyo_SN' +func (dyo *dyo_SN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dyo_SN' +func (dyo *dyo_SN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dyo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dyo_SN' +func (dyo *dyo_SN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dyo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dyo_SN' +func (dyo *dyo_SN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dyo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, dyo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dyo_SN' +func (dyo *dyo_SN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dyo_SN' +func (dyo *dyo_SN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dyo_SN' +func (dyo *dyo_SN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dyo_SN' +func (dyo *dyo_SN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dyo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dyo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dyo_SN/dyo_SN_test.go b/vendor/github.com/go-playground/locales/dyo_SN/dyo_SN_test.go new file mode 100644 index 0000000000..43316545d1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dyo_SN/dyo_SN_test.go @@ -0,0 +1,1120 @@ +package dyo_SN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dyo_SN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dz/dz.go b/vendor/github.com/go-playground/locales/dz/dz.go new file mode 100644 index 0000000000..f7f902d6bb --- /dev/null +++ b/vendor/github.com/go-playground/locales/dz/dz.go @@ -0,0 +1,676 @@ +package dz + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dz struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dz' locale +func New() locales.Translator { + return &dz{ + locale: "dz", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "གྲངས་མེད", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "Nu.", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KR₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "TH฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩", "༡༠", "༡༡", "12"}, + monthsNarrow: []string{"", "༡", "༢", "༣", "4", "༥", "༦", "༧", "༨", "9", "༡༠", "༡༡", "༡༢"}, + monthsWide: []string{"", "ཟླ་དངཔ་", "ཟླ་གཉིས་པ་", "ཟླ་གསུམ་པ་", "ཟླ་བཞི་པ་", "ཟླ་ལྔ་པ་", "ཟླ་དྲུག་པ", "ཟླ་བདུན་པ་", "ཟླ་བརྒྱད་པ་", "ཟླ་དགུ་པ་", "ཟླ་བཅུ་པ་", "ཟླ་བཅུ་གཅིག་པ་", "ཟླ་བཅུ་གཉིས་པ་"}, + daysAbbreviated: []string{"ཟླ་", "མིར་", "ལྷག་", "ཕུར་", "སངས་", "སྤེན་", "ཉི་"}, + daysNarrow: []string{"ཟླ", "མིར", "ལྷག", "ཕུར", "སངྶ", "སྤེན", "ཉི"}, + daysShort: []string{"ཟླ་", "མིར་", "ལྷག་", "ཕུར་", "སངས་", "སྤེན་", "ཉི་"}, + daysWide: []string{"གཟའ་ཟླ་བ་", "གཟའ་མིག་དམར་", "གཟའ་ལྷག་པ་", "གཟའ་ཕུར་བུ་", "གཟའ་པ་སངས་", "གཟའ་སྤེན་པ་", "གཟའ་ཉི་མ་"}, + periodsAbbreviated: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"}, + periodsNarrow: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"}, + periodsWide: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"TMST": "TMST", "EST": "བྱང་ཨ་མི་རི་ཀ་ཤར་ཕྱོགས་ཚད་ལྡན་ཆུ་ཚོད", "HNEG": "ཤར་ཕྱོགས་གིརིན་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "AEDT": "ཤར་ཕྱོགས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "GYT": "གུ་ཡ་ན་ཆུ་ཚོད", "WITA": "དབུས་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "UYT": "ཡུ་རུ་གུ་ཝཱའི་ཚད་ལྡན་ཆུ་ཚོད", "MEZ": "དབུས་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "COT": "ཀོ་ལོམ་བྷི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "GFT": "ཕིརེནཅ་གི་ཡ་ན་ཆུ་ཚོད", "CHADT": "CHADT", "CAT": "དབུས་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "CLT": "ཅི་ལི་ཚད་ལྡན་ཆུ་ཚོད", "WAT": "ནུབ་ཕྱོགས་ཨཕ་རི་ཀཱ་ཚད་ལྡན་ཆུ་ཚོད", "SAST": "ལྷོ་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "HNCU": "ཀིའུ་བྷ་ཚད་ལྡན་ཆུ་ཚོད", "CDT": "བྱང་ཨ་མི་རི་ཀ་དབུས་ཕྱོགས་ཉིན་སྲུང་ཆུ་ཚོད", "TMT": "TMT", "AKDT": "ཨ་ལསི་ཀ་ཉིན་སྲུང་ཆུ་ཚོད", "ACWST": "དབུས་ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "HEOG": "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་བྱཱར་དུས་ཆུ་ཚོད", "GMT": "གིརིན་ཝིཆ་ལུ་ཡོད་པའི་ཆུ་ཚོད", "MYT": "MYT", "MST": "MST", "HENOMX": "HENOMX", "HEPM": "པའི་རི་དང་མི་ཀི་ལཱོན་ཉིན་སྲུང་ཆུ་ཚོད", "PST": "བྱང་ཨ་མི་རི་ཀ་པེ་སི་ཕིག་ཚད་ལྡན་ཆུ་ཚོད", "ADT": "ཨེཊ་ལེན་ཊིཀ་ཉིན་སྲུང་ཆུ་ཚོད", "ART": "ཨར་ཇེན་ཊི་ན་ཚད་ལྡན་ཆུ་ཚོད", "AEST": "ཤར་ཕྱོགས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "UYST": "ཡུ་རུ་གུ་ཝཱའི་བྱཱར་དུས་ཆུ་ཚོད", "ARST": "ཨར་ཇེན་ཊི་ན་བྱཱར་དུས་ཆུ་ཚོད", "ACST": "དབུས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "AKST": "ཨ་ལསི་ཀ་ཚད་ལྡན་ཆུ་ཚོད", "PDT": "བྱང་ཨ་མི་རི་ཀ་པེ་སི་ཕིག་ཉིན་སྲུང་ཆུ་ཚོད", "NZDT": "ནིའུ་ཛི་ལེནཌ་ཉིན་སྲུང་ཆུ་ཚོད", "VET": "བེ་ནི་ཛུ་ཝེ་ལ་ཆུ་ཚོད", "AST": "ཨེཊ་ལེན་ཊིཀ་ཚད་ལྡན་ཆུ་ཚོད", "WESZ": "ནུབ་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "LHST": "LHST", "SGT": "SGT", "ECT": "ཨེ་ཀུ་ཌཽ་ཆུ་ཚོད", "WAST": "ནུབ་ཕྱོགས་ཨཕ་རི་ཀཱ་བྱཱར་དུས་ཆུ་ཚོད", "HNNOMX": "HNNOMX", "JST": "ཇ་པཱན་ཚད་ལྡན་ཆུ་ཚོད", "HNPM": "པའི་རི་དང་མི་ཀི་ལཱོན་ཚད་ལྡན་ཆུ་ཚོད", "CST": "བྱང་ཨ་མི་རི་ཀ་དབུས་ཕྱོགས་ཚད་ལྡན་ཆུ་ཚོད", "HADT": "ཧ་ཝའི་-ཨེ་ལིའུ་ཤེན་ཉིན་སྲུང་ཆུ་ཚོད", "ACWDT": "དབུས་ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "WIB": "ནུབ་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "IST": "རྒྱ་གར་ཆུ་ཚོད", "WARST": "ནུབ་ཕྱོགས་ཨར་ཇེན་ཊི་ན་བྱཱར་དུས་ཆུ་ཚོད", "CLST": "ཅི་ལི་བྱཱར་དུས་ཆུ་ཚོད", "HNOG": "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "MDT": "MDT", "EDT": "བྱང་ཨ་མི་རི་ཀ་ཤར་ཕྱོགས་ཉིན་སྲུང་ཆུ་ཚོད", "WIT": "ཤར་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "MESZ": "དབུས་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "WART": "ནུབ་ཕྱོགས་ཨར་ཇེན་ཊི་ན་ཚད་ལྡན་ཆུ་ཚོད", "HEEG": "ཤར་ཕྱོགས་གིརིན་ལེནཌ་བྱཱར་དུས་ཆུ་ཚོད", "NZST": "ནིའུ་ཛི་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "WEZ": "ནུབ་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "HKT": "HKT", "HKST": "HKST", "ChST": "ChST", "CHAST": "CHAST", "JDT": "ཇ་པཱན་ཉིན་སྲུང་ཆུ་ཚོད", "OESZ": "ཤར་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "EAT": "ཤར་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "HAST": "ཧ་ཝའི་-ཨེ་ལིའུ་ཤེན་ཚད་ལྡན་ཆུ་ཚོད", "OEZ": "ཤར་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "ACDT": "དབུས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "COST": "ཀོ་ལོམ་བྷི་ཡ་བྱཱར་དུས་ཆུ་ཚོད", "LHDT": "LHDT", "AWST": "ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "AWDT": "ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "BOT": "བྷོ་ལི་བི་ཡ་ཆུ་ཚོད", "BT": "འབྲུག་ཡུལ་ཆུ་ཚོད", "HNT": "ནིའུ་ཕའུནཌ་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "HAT": "ནིའུ་ཕའུནཌ་ལེནཌ་ཉིན་སྲུང་ཆུ་ཚོད", "SRT": "སུ་རི་ནཱམ་ཆུ་ཚོད", "∅∅∅": "ཨེ་ཛོརས་བྱཱར་དུས་ཆུ་ཚོད", "HECU": "ཀིའུ་བྷ་ཉིན་སྲུང་ཆུ་ཚོད"}, + } +} + +// Locale returns the current translators string locale +func (dz *dz) Locale() string { + return dz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dz' +func (dz *dz) PluralsCardinal() []locales.PluralRule { + return dz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dz' +func (dz *dz) PluralsOrdinal() []locales.PluralRule { + return dz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dz' +func (dz *dz) PluralsRange() []locales.PluralRule { + return dz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dz' +func (dz *dz) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dz' +func (dz *dz) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dz' +func (dz *dz) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dz *dz) MonthAbbreviated(month time.Month) string { + return dz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dz *dz) MonthsAbbreviated() []string { + return dz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dz *dz) MonthNarrow(month time.Month) string { + return dz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dz *dz) MonthsNarrow() []string { + return dz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dz *dz) MonthWide(month time.Month) string { + return dz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dz *dz) MonthsWide() []string { + return dz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dz *dz) WeekdayAbbreviated(weekday time.Weekday) string { + return dz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dz *dz) WeekdaysAbbreviated() []string { + return dz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dz *dz) WeekdayNarrow(weekday time.Weekday) string { + return dz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dz *dz) WeekdaysNarrow() []string { + return dz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dz *dz) WeekdayShort(weekday time.Weekday) string { + return dz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dz *dz) WeekdaysShort() []string { + return dz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dz *dz) WeekdayWide(weekday time.Weekday) string { + return dz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dz *dz) WeekdaysWide() []string { + return dz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dz' and handles both Whole and Real numbers based on 'v' +func (dz *dz) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, dz.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dz' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dz *dz) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dz.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dz.percentSuffix...) + + b = append(b, dz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dz' +func (dz *dz) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dz.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, dz.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, dz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dz' +// in accounting notation. +func (dz *dz) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dz.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, dz.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, dz.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dz' +func (dz *dz) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dz' +func (dz *dz) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9f, 0xe0, 0xbe, 0xb3, 0xe0, 0xbc, 0x8b}...) + b = append(b, dz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dz' +func (dz *dz) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, dz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dz' +func (dz *dz) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, dz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dz' +func (dz *dz) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, dz.periodsAbbreviated[0]...) + } else { + b = append(b, dz.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dz' +func (dz *dz) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, dz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, dz.periodsAbbreviated[0]...) + } else { + b = append(b, dz.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dz' +func (dz *dz) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, dz.periodsAbbreviated[0]...) + } else { + b = append(b, dz.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dz' +func (dz *dz) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, dz.periodsAbbreviated[0]...) + } else { + b = append(b, dz.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dz/dz_test.go b/vendor/github.com/go-playground/locales/dz/dz_test.go new file mode 100644 index 0000000000..be07708169 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dz/dz_test.go @@ -0,0 +1,1120 @@ +package dz + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dz" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/dz_BT/dz_BT.go b/vendor/github.com/go-playground/locales/dz_BT/dz_BT.go new file mode 100644 index 0000000000..c4a4ae9058 --- /dev/null +++ b/vendor/github.com/go-playground/locales/dz_BT/dz_BT.go @@ -0,0 +1,676 @@ +package dz_BT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type dz_BT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'dz_BT' locale +func New() locales.Translator { + return &dz_BT{ + locale: "dz_BT", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "གྲངས་མེད", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩", "༡༠", "༡༡", "12"}, + monthsNarrow: []string{"", "༡", "༢", "༣", "4", "༥", "༦", "༧", "༨", "9", "༡༠", "༡༡", "༡༢"}, + monthsWide: []string{"", "ཟླ་དངཔ་", "ཟླ་གཉིས་པ་", "ཟླ་གསུམ་པ་", "ཟླ་བཞི་པ་", "ཟླ་ལྔ་པ་", "ཟླ་དྲུག་པ", "ཟླ་བདུན་པ་", "ཟླ་བརྒྱད་པ་", "ཟླ་དགུ་པ་", "ཟླ་བཅུ་པ་", "ཟླ་བཅུ་གཅིག་པ་", "ཟླ་བཅུ་གཉིས་པ་"}, + daysAbbreviated: []string{"ཟླ་", "མིར་", "ལྷག་", "ཕུར་", "སངས་", "སྤེན་", "ཉི་"}, + daysNarrow: []string{"ཟླ", "མིར", "ལྷག", "ཕུར", "སངྶ", "སྤེན", "ཉི"}, + daysShort: []string{"ཟླ་", "མིར་", "ལྷག་", "ཕུར་", "སངས་", "སྤེན་", "ཉི་"}, + daysWide: []string{"གཟའ་ཟླ་བ་", "གཟའ་མིག་དམར་", "གཟའ་ལྷག་པ་", "གཟའ་ཕུར་བུ་", "གཟའ་པ་སངས་", "གཟའ་སྤེན་པ་", "གཟའ་ཉི་མ་"}, + periodsAbbreviated: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"}, + periodsNarrow: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"}, + periodsWide: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"∅∅∅": "ཨེ་མ་ཛཱོན་བྱཱར་དུས་ཆུ་ཚོད", "WEZ": "ནུབ་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "TMST": "TMST", "CST": "བྱང་ཨ་མི་རི་ཀ་དབུས་ཕྱོགས་ཚད་ལྡན་ཆུ་ཚོད", "HADT": "ཧ་ཝའི་-ཨེ་ལིའུ་ཤེན་ཉིན་སྲུང་ཆུ་ཚོད", "JST": "ཇ་པཱན་ཚད་ལྡན་ཆུ་ཚོད", "CLST": "ཅི་ལི་བྱཱར་དུས་ཆུ་ཚོད", "EST": "བྱང་ཨ་མི་རི་ཀ་ཤར་ཕྱོགས་ཚད་ལྡན་ཆུ་ཚོད", "AKST": "ཨ་ལསི་ཀ་ཚད་ལྡན་ཆུ་ཚོད", "HECU": "ཀིའུ་བྷ་ཉིན་སྲུང་ཆུ་ཚོད", "EAT": "ཤར་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "MEZ": "དབུས་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "OEZ": "ཤར་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "TMT": "TMT", "MDT": "MDT", "HNEG": "ཤར་ཕྱོགས་གིརིན་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "HNPMX": "HNPMX", "NZST": "ནིའུ་ཛི་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "ACWDT": "དབུས་ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "ART": "ཨར་ཇེན་ཊི་ན་ཚད་ལྡན་ཆུ་ཚོད", "BT": "འབྲུག་ཡུལ་ཆུ་ཚོད", "CLT": "ཅི་ལི་ཚད་ལྡན་ཆུ་ཚོད", "AKDT": "ཨ་ལསི་ཀ་ཉིན་སྲུང་ཆུ་ཚོད", "ChST": "ChST", "GFT": "ཕིརེནཅ་གི་ཡ་ན་ཆུ་ཚོད", "SRT": "སུ་རི་ནཱམ་ཆུ་ཚོད", "NZDT": "ནིའུ་ཛི་ལེནཌ་ཉིན་སྲུང་ཆུ་ཚོད", "GMT": "གིརིན་ཝིཆ་ལུ་ཡོད་པའི་ཆུ་ཚོད", "ADT": "ཨེཊ་ལེན་ཊིཀ་ཉིན་སྲུང་ཆུ་ཚོད", "OESZ": "ཤར་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "HKT": "HKT", "HNNOMX": "HNNOMX", "SAST": "ལྷོ་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "COST": "ཀོ་ལོམ་བྷི་ཡ་བྱཱར་དུས་ཆུ་ཚོད", "AEST": "ཤར་ཕྱོགས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "HNCU": "ཀིའུ་བྷ་ཚད་ལྡན་ཆུ་ཚོད", "AEDT": "ཤར་ཕྱོགས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "WITA": "དབུས་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "ECT": "ཨེ་ཀུ་ཌཽ་ཆུ་ཚོད", "MYT": "MYT", "WART": "ནུབ་ཕྱོགས་ཨར་ཇེན་ཊི་ན་ཚད་ལྡན་ཆུ་ཚོད", "HEOG": "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་བྱཱར་དུས་ཆུ་ཚོད", "MST": "MST", "COT": "ཀོ་ལོམ་བྷི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "LHDT": "LHDT", "CDT": "བྱང་ཨ་མི་རི་ཀ་དབུས་ཕྱོགས་ཉིན་སྲུང་ཆུ་ཚོད", "CHADT": "CHADT", "WIT": "ཤར་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "HAST": "ཧ་ཝའི་-ཨེ་ལིའུ་ཤེན་ཚད་ལྡན་ཆུ་ཚོད", "VET": "བེ་ནི་ཛུ་ཝེ་ལ་ཆུ་ཚོད", "WESZ": "ནུབ་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "WAT": "ནུབ་ཕྱོགས་ཨཕ་རི་ཀཱ་ཚད་ལྡན་ཆུ་ཚོད", "HNPM": "པའི་རི་དང་མི་ཀི་ལཱོན་ཚད་ལྡན་ཆུ་ཚོད", "GYT": "གུ་ཡ་ན་ཆུ་ཚོད", "JDT": "ཇ་པཱན་ཉིན་སྲུང་ཆུ་ཚོད", "HKST": "HKST", "HNT": "ནིའུ་ཕའུནཌ་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "HAT": "ནིའུ་ཕའུནཌ་ལེནཌ་ཉིན་སྲུང་ཆུ་ཚོད", "PST": "བྱང་ཨ་མི་རི་ཀ་པེ་སི་ཕིག་ཚད་ལྡན་ཆུ་ཚོད", "CAT": "དབུས་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "IST": "རྒྱ་གར་ཆུ་ཚོད", "WAST": "ནུབ་ཕྱོགས་ཨཕ་རི་ཀཱ་བྱཱར་དུས་ཆུ་ཚོད", "AWDT": "ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "ACWST": "དབུས་ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "HNOG": "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "EDT": "བྱང་ཨ་མི་རི་ཀ་ཤར་ཕྱོགས་ཉིན་སྲུང་ཆུ་ཚོད", "HEPM": "པའི་རི་དང་མི་ཀི་ལཱོན་ཉིན་སྲུང་ཆུ་ཚོད", "LHST": "LHST", "WIB": "ནུབ་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "UYT": "ཡུ་རུ་གུ་ཝཱའི་ཚད་ལྡན་ཆུ་ཚོད", "CHAST": "CHAST", "UYST": "ཡུ་རུ་གུ་ཝཱའི་བྱཱར་དུས་ཆུ་ཚོད", "SGT": "SGT", "WARST": "ནུབ་ཕྱོགས་ཨར་ཇེན་ཊི་ན་བྱཱར་དུས་ཆུ་ཚོད", "AST": "ཨེཊ་ལེན་ཊིཀ་ཚད་ལྡན་ཆུ་ཚོད", "ACST": "དབུས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "ACDT": "དབུས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "HENOMX": "HENOMX", "HEEG": "ཤར་ཕྱོགས་གིརིན་ལེནཌ་བྱཱར་དུས་ཆུ་ཚོད", "MESZ": "དབུས་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "ARST": "ཨར་ཇེན་ཊི་ན་བྱཱར་དུས་ཆུ་ཚོད", "HEPMX": "HEPMX", "AWST": "ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "BOT": "བྷོ་ལི་བི་ཡ་ཆུ་ཚོད", "PDT": "བྱང་ཨ་མི་རི་ཀ་པེ་སི་ཕིག་ཉིན་སྲུང་ཆུ་ཚོད"}, + } +} + +// Locale returns the current translators string locale +func (dz *dz_BT) Locale() string { + return dz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'dz_BT' +func (dz *dz_BT) PluralsCardinal() []locales.PluralRule { + return dz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'dz_BT' +func (dz *dz_BT) PluralsOrdinal() []locales.PluralRule { + return dz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'dz_BT' +func (dz *dz_BT) PluralsRange() []locales.PluralRule { + return dz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dz_BT' +func (dz *dz_BT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dz_BT' +func (dz *dz_BT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dz_BT' +func (dz *dz_BT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (dz *dz_BT) MonthAbbreviated(month time.Month) string { + return dz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (dz *dz_BT) MonthsAbbreviated() []string { + return dz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (dz *dz_BT) MonthNarrow(month time.Month) string { + return dz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (dz *dz_BT) MonthsNarrow() []string { + return dz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (dz *dz_BT) MonthWide(month time.Month) string { + return dz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (dz *dz_BT) MonthsWide() []string { + return dz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (dz *dz_BT) WeekdayAbbreviated(weekday time.Weekday) string { + return dz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (dz *dz_BT) WeekdaysAbbreviated() []string { + return dz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (dz *dz_BT) WeekdayNarrow(weekday time.Weekday) string { + return dz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (dz *dz_BT) WeekdaysNarrow() []string { + return dz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (dz *dz_BT) WeekdayShort(weekday time.Weekday) string { + return dz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (dz *dz_BT) WeekdaysShort() []string { + return dz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (dz *dz_BT) WeekdayWide(weekday time.Weekday) string { + return dz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (dz *dz_BT) WeekdaysWide() []string { + return dz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'dz_BT' and handles both Whole and Real numbers based on 'v' +func (dz *dz_BT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, dz.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'dz_BT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (dz *dz_BT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dz.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, dz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, dz.percentSuffix...) + + b = append(b, dz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dz_BT' +func (dz *dz_BT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dz.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, dz.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, dz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dz_BT' +// in accounting notation. +func (dz *dz_BT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := dz.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, dz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, dz.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, dz.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, dz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'dz_BT' +func (dz *dz_BT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'dz_BT' +func (dz *dz_BT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9f, 0xe0, 0xbe, 0xb3, 0xe0, 0xbc, 0x8b}...) + b = append(b, dz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'dz_BT' +func (dz *dz_BT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, dz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'dz_BT' +func (dz *dz_BT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, dz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, dz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'dz_BT' +func (dz *dz_BT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, dz.periodsAbbreviated[0]...) + } else { + b = append(b, dz.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'dz_BT' +func (dz *dz_BT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, dz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, dz.periodsAbbreviated[0]...) + } else { + b = append(b, dz.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'dz_BT' +func (dz *dz_BT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, dz.periodsAbbreviated[0]...) + } else { + b = append(b, dz.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'dz_BT' +func (dz *dz_BT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, dz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, dz.periodsAbbreviated[0]...) + } else { + b = append(b, dz.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := dz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/dz_BT/dz_BT_test.go b/vendor/github.com/go-playground/locales/dz_BT/dz_BT_test.go new file mode 100644 index 0000000000..f993342f9a --- /dev/null +++ b/vendor/github.com/go-playground/locales/dz_BT/dz_BT_test.go @@ -0,0 +1,1120 @@ +package dz_BT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "dz_BT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ebu/ebu.go b/vendor/github.com/go-playground/locales/ebu/ebu.go new file mode 100644 index 0000000000..5f5f087516 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ebu/ebu.go @@ -0,0 +1,518 @@ +package ebu + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ebu struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ebu' locale +func New() locales.Translator { + return &ebu{ + locale: "ebu", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Mbe", "Kai", "Kat", "Kan", "Gat", "Gan", "Mug", "Knn", "Ken", "Iku", "Imw", "Igi"}, + monthsNarrow: []string{"", "M", "K", "K", "K", "G", "G", "M", "K", "K", "I", "I", "I"}, + monthsWide: []string{"", "Mweri wa mbere", "Mweri wa kaĩri", "Mweri wa kathatũ", "Mweri wa kana", "Mweri wa gatano", "Mweri wa gatantatũ", "Mweri wa mũgwanja", "Mweri wa kanana", "Mweri wa kenda", "Mweri wa ikũmi", "Mweri wa ikũmi na ũmwe", "Mweri wa ikũmi na Kaĩrĩ"}, + daysAbbreviated: []string{"Kma", "Tat", "Ine", "Tan", "Arm", "Maa", "NMM"}, + daysNarrow: []string{"K", "N", "N", "N", "A", "M", "N"}, + daysWide: []string{"Kiumia", "Njumatatu", "Njumaine", "Njumatano", "Aramithi", "Njumaa", "NJumamothii"}, + periodsAbbreviated: []string{"KI", "UT"}, + periodsWide: []string{"KI", "UT"}, + erasAbbreviated: []string{"MK", "TK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbere ya Kristo", "Thutha wa Kristo"}, + timezones: map[string]string{"MEZ": "MEZ", "JDT": "JDT", "MYT": "MYT", "WARST": "WARST", "HEOG": "HEOG", "HECU": "HECU", "ARST": "ARST", "BT": "BT", "HNPM": "HNPM", "SAST": "SAST", "LHST": "LHST", "SRT": "SRT", "WIT": "WIT", "CHADT": "CHADT", "∅∅∅": "∅∅∅", "NZST": "NZST", "AEDT": "AEDT", "CLST": "CLST", "HNOG": "HNOG", "AST": "AST", "AKDT": "AKDT", "AEST": "AEST", "AWST": "AWST", "BOT": "BOT", "ACDT": "ACDT", "ChST": "ChST", "HNPMX": "HNPMX", "ECT": "ECT", "VET": "VET", "CLT": "CLT", "OESZ": "OESZ", "WAT": "WAT", "ACST": "ACST", "UYT": "UYT", "EAT": "EAT", "HAST": "HAST", "ADT": "ADT", "GMT": "GMT", "HNT": "HNT", "OEZ": "OEZ", "MST": "MST", "EDT": "EDT", "LHDT": "LHDT", "GYT": "GYT", "SGT": "SGT", "JST": "JST", "WEZ": "WEZ", "HENOMX": "HENOMX", "CST": "CST", "MDT": "MDT", "HKST": "HKST", "UYST": "UYST", "HNCU": "HNCU", "AWDT": "AWDT", "HNNOMX": "HNNOMX", "HEPMX": "HEPMX", "CHAST": "CHAST", "CAT": "CAT", "ACWDT": "ACWDT", "TMT": "TMT", "HEEG": "HEEG", "GFT": "GFT", "AKST": "AKST", "HEPM": "HEPM", "WIB": "WIB", "WITA": "WITA", "IST": "IST", "ACWST": "ACWST", "MESZ": "MESZ", "TMST": "TMST", "ART": "ART", "PST": "PST", "PDT": "PDT", "WAST": "WAST", "EST": "EST", "HAT": "HAT", "HADT": "HADT", "NZDT": "NZDT", "WART": "WART", "WESZ": "WESZ", "HKT": "HKT", "COT": "COT", "COST": "COST", "HNEG": "HNEG", "CDT": "CDT"}, + } +} + +// Locale returns the current translators string locale +func (ebu *ebu) Locale() string { + return ebu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ebu' +func (ebu *ebu) PluralsCardinal() []locales.PluralRule { + return ebu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ebu' +func (ebu *ebu) PluralsOrdinal() []locales.PluralRule { + return ebu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ebu' +func (ebu *ebu) PluralsRange() []locales.PluralRule { + return ebu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ebu' +func (ebu *ebu) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ebu' +func (ebu *ebu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ebu' +func (ebu *ebu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ebu *ebu) MonthAbbreviated(month time.Month) string { + return ebu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ebu *ebu) MonthsAbbreviated() []string { + return ebu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ebu *ebu) MonthNarrow(month time.Month) string { + return ebu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ebu *ebu) MonthsNarrow() []string { + return ebu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ebu *ebu) MonthWide(month time.Month) string { + return ebu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ebu *ebu) MonthsWide() []string { + return ebu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ebu *ebu) WeekdayAbbreviated(weekday time.Weekday) string { + return ebu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ebu *ebu) WeekdaysAbbreviated() []string { + return ebu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ebu *ebu) WeekdayNarrow(weekday time.Weekday) string { + return ebu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ebu *ebu) WeekdaysNarrow() []string { + return ebu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ebu *ebu) WeekdayShort(weekday time.Weekday) string { + return ebu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ebu *ebu) WeekdaysShort() []string { + return ebu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ebu *ebu) WeekdayWide(weekday time.Weekday) string { + return ebu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ebu *ebu) WeekdaysWide() []string { + return ebu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ebu' and handles both Whole and Real numbers based on 'v' +func (ebu *ebu) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ebu' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ebu *ebu) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ebu' +func (ebu *ebu) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ebu.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ebu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ebu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ebu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ebu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ebu' +// in accounting notation. +func (ebu *ebu) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ebu.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ebu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ebu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ebu.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ebu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ebu.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ebu' +func (ebu *ebu) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ebu' +func (ebu *ebu) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ebu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ebu' +func (ebu *ebu) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ebu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ebu' +func (ebu *ebu) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ebu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ebu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ebu' +func (ebu *ebu) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ebu' +func (ebu *ebu) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ebu' +func (ebu *ebu) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ebu' +func (ebu *ebu) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ebu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ebu/ebu_test.go b/vendor/github.com/go-playground/locales/ebu/ebu_test.go new file mode 100644 index 0000000000..46011e5a78 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ebu/ebu_test.go @@ -0,0 +1,1120 @@ +package ebu + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ebu" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ebu_KE/ebu_KE.go b/vendor/github.com/go-playground/locales/ebu_KE/ebu_KE.go new file mode 100644 index 0000000000..cf0d4d7baf --- /dev/null +++ b/vendor/github.com/go-playground/locales/ebu_KE/ebu_KE.go @@ -0,0 +1,518 @@ +package ebu_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ebu_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ebu_KE' locale +func New() locales.Translator { + return &ebu_KE{ + locale: "ebu_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Mbe", "Kai", "Kat", "Kan", "Gat", "Gan", "Mug", "Knn", "Ken", "Iku", "Imw", "Igi"}, + monthsNarrow: []string{"", "M", "K", "K", "K", "G", "G", "M", "K", "K", "I", "I", "I"}, + monthsWide: []string{"", "Mweri wa mbere", "Mweri wa kaĩri", "Mweri wa kathatũ", "Mweri wa kana", "Mweri wa gatano", "Mweri wa gatantatũ", "Mweri wa mũgwanja", "Mweri wa kanana", "Mweri wa kenda", "Mweri wa ikũmi", "Mweri wa ikũmi na ũmwe", "Mweri wa ikũmi na Kaĩrĩ"}, + daysAbbreviated: []string{"Kma", "Tat", "Ine", "Tan", "Arm", "Maa", "NMM"}, + daysNarrow: []string{"K", "N", "N", "N", "A", "M", "N"}, + daysWide: []string{"Kiumia", "Njumatatu", "Njumaine", "Njumatano", "Aramithi", "Njumaa", "NJumamothii"}, + periodsAbbreviated: []string{"KI", "UT"}, + periodsWide: []string{"KI", "UT"}, + erasAbbreviated: []string{"MK", "TK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbere ya Kristo", "Thutha wa Kristo"}, + timezones: map[string]string{"NZST": "NZST", "CLT": "CLT", "UYST": "UYST", "ARST": "ARST", "EST": "EST", "BT": "BT", "HEPMX": "HEPMX", "CST": "CST", "CHADT": "CHADT", "VET": "VET", "ART": "ART", "SAST": "SAST", "GFT": "GFT", "WITA": "WITA", "HNNOMX": "HNNOMX", "ACDT": "ACDT", "HAT": "HAT", "AEST": "AEST", "ACST": "ACST", "HNT": "HNT", "WIB": "WIB", "AWST": "AWST", "MST": "MST", "WAST": "WAST", "EAT": "EAT", "WIT": "WIT", "ECT": "ECT", "ADT": "ADT", "AKDT": "AKDT", "LHDT": "LHDT", "SGT": "SGT", "MEZ": "MEZ", "GMT": "GMT", "HKST": "HKST", "CHAST": "CHAST", "WART": "WART", "HKT": "HKT", "WAT": "WAT", "SRT": "SRT", "BOT": "BOT", "AST": "AST", "OESZ": "OESZ", "TMT": "TMT", "AEDT": "AEDT", "AKST": "AKST", "HNPM": "HNPM", "IST": "IST", "WEZ": "WEZ", "MYT": "MYT", "HEOG": "HEOG", "HENOMX": "HENOMX", "JST": "JST", "WESZ": "WESZ", "WARST": "WARST", "OEZ": "OEZ", "ChST": "ChST", "GYT": "GYT", "HNCU": "HNCU", "∅∅∅": "∅∅∅", "COT": "COT", "HNEG": "HNEG", "HNPMX": "HNPMX", "CDT": "CDT", "NZDT": "NZDT", "JDT": "JDT", "HEEG": "HEEG", "CAT": "CAT", "MESZ": "MESZ", "HNOG": "HNOG", "MDT": "MDT", "HECU": "HECU", "HAST": "HAST", "PDT": "PDT", "ACWST": "ACWST", "HEPM": "HEPM", "UYT": "UYT", "CLST": "CLST", "TMST": "TMST", "EDT": "EDT", "COST": "COST", "LHST": "LHST", "AWDT": "AWDT", "HADT": "HADT", "PST": "PST", "ACWDT": "ACWDT"}, + } +} + +// Locale returns the current translators string locale +func (ebu *ebu_KE) Locale() string { + return ebu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ebu_KE' +func (ebu *ebu_KE) PluralsCardinal() []locales.PluralRule { + return ebu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ebu_KE' +func (ebu *ebu_KE) PluralsOrdinal() []locales.PluralRule { + return ebu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ebu_KE' +func (ebu *ebu_KE) PluralsRange() []locales.PluralRule { + return ebu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ebu_KE' +func (ebu *ebu_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ebu_KE' +func (ebu *ebu_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ebu_KE' +func (ebu *ebu_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ebu *ebu_KE) MonthAbbreviated(month time.Month) string { + return ebu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ebu *ebu_KE) MonthsAbbreviated() []string { + return ebu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ebu *ebu_KE) MonthNarrow(month time.Month) string { + return ebu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ebu *ebu_KE) MonthsNarrow() []string { + return ebu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ebu *ebu_KE) MonthWide(month time.Month) string { + return ebu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ebu *ebu_KE) MonthsWide() []string { + return ebu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ebu *ebu_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return ebu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ebu *ebu_KE) WeekdaysAbbreviated() []string { + return ebu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ebu *ebu_KE) WeekdayNarrow(weekday time.Weekday) string { + return ebu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ebu *ebu_KE) WeekdaysNarrow() []string { + return ebu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ebu *ebu_KE) WeekdayShort(weekday time.Weekday) string { + return ebu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ebu *ebu_KE) WeekdaysShort() []string { + return ebu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ebu *ebu_KE) WeekdayWide(weekday time.Weekday) string { + return ebu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ebu *ebu_KE) WeekdaysWide() []string { + return ebu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ebu_KE' and handles both Whole and Real numbers based on 'v' +func (ebu *ebu_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ebu_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ebu *ebu_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ebu_KE' +func (ebu *ebu_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ebu.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ebu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ebu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ebu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ebu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ebu_KE' +// in accounting notation. +func (ebu *ebu_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ebu.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ebu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ebu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ebu.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ebu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ebu.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ebu_KE' +func (ebu *ebu_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ebu_KE' +func (ebu *ebu_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ebu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ebu_KE' +func (ebu *ebu_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ebu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ebu_KE' +func (ebu *ebu_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ebu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ebu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ebu_KE' +func (ebu *ebu_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ebu_KE' +func (ebu *ebu_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ebu_KE' +func (ebu *ebu_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ebu_KE' +func (ebu *ebu_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ebu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ebu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ebu_KE/ebu_KE_test.go b/vendor/github.com/go-playground/locales/ebu_KE/ebu_KE_test.go new file mode 100644 index 0000000000..58eeae6120 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ebu_KE/ebu_KE_test.go @@ -0,0 +1,1120 @@ +package ebu_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ebu_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ee/ee.go b/vendor/github.com/go-playground/locales/ee/ee.go new file mode 100644 index 0000000000..720d1fc0a9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ee/ee.go @@ -0,0 +1,564 @@ +package ee + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ee struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ee' locale +func New() locales.Translator { + return &ee{ + locale: "ee", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GH₵", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "dzv", "dzd", "ted", "afɔ", "dam", "mas", "sia", "dea", "any", "kel", "ade", "dzm"}, + monthsNarrow: []string{"", "d", "d", "t", "a", "d", "m", "s", "d", "a", "k", "a", "d"}, + monthsWide: []string{"", "dzove", "dzodze", "tedoxe", "afɔfĩe", "dama", "masa", "siamlɔm", "deasiamime", "anyɔnyɔ", "kele", "adeɛmekpɔxe", "dzome"}, + daysAbbreviated: []string{"kɔs", "dzo", "bla", "kuɖ", "yaw", "fiɖ", "mem"}, + daysNarrow: []string{"k", "d", "b", "k", "y", "f", "m"}, + daysShort: []string{"kɔs", "dzo", "bla", "kuɖ", "yaw", "fiɖ", "mem"}, + daysWide: []string{"kɔsiɖa", "dzoɖa", "blaɖa", "kuɖa", "yawoɖa", "fiɖa", "memleɖa"}, + periodsAbbreviated: []string{"ŋdi", "ɣetrɔ"}, + periodsNarrow: []string{"ŋ", "ɣ"}, + periodsWide: []string{"ŋdi", "ɣetrɔ"}, + erasAbbreviated: []string{"hY", "Yŋ"}, + erasNarrow: []string{"hY", "Yŋ"}, + erasWide: []string{"Hafi Yesu Va Do ŋgɔ", "Yesu Ŋɔli"}, + timezones: map[string]string{"AST": "Atlantic gaƒoƒoɖoanyime", "HKST": "Hɔng Kɔng dzomeŋɔli gaƒoƒome", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "SRT": "Suriname gaƒoƒome", "ECT": "Ikuedɔ dzomeŋɔli gaƒoƒome", "HKT": "Hɔng Kɔng gaƒoƒoɖoanyi me", "GFT": "Frentsi Guiana gaƒoƒome", "ART": "Argentina gaƒoƒoɖoanyime", "VET": "Venezuela gaƒoƒome", "CLT": "Tsile gaƒoƒoɖoanyime", "HEOG": "Ɣetoɖoƒe Grinlanɖ dzomeŋɔli gaƒoƒome", "HAT": "Niufaunɖlanɖ ŋkekeme gaƒoƒome", "AKDT": "Alaska ŋkekeme gaƒoƒome", "HECU": "Kuba ŋkekeme gaƒoƒome", "PST": "Pacific gaƒoƒoɖoanyime", "HADT": "Hawaii-Aleutia ŋkekeme gaƒoƒome", "IST": "IST", "EDT": "Ɣedzeƒe America ŋkekeme gaƒoƒome", "WAT": "Ɣetoɖoƒe Afrika gaƒoƒoɖoanyime", "COST": "Kolombia dzomeŋɔli gaƒoƒome", "ACST": "Titina Australia gaƒoƒoɖoanyime", "CST": "Titina America gaƒoƒoɖoanyime", "WIT": "WIT", "AWDT": "Ɣetoɖoƒe Australia ŋkekeme gaƒoƒome", "JDT": "Japan ŋkekeme gaƒoƒome", "WARST": "Ɣetoɖoƒe Argentina dzomeŋɔli gaƒoƒome", "OEZ": "Ɣedzeƒe Europe gaƒoƒoɖoanyime", "MYT": "MYT", "TMT": "Tɛkmenistan gaƒoƒoɖoanyime", "EST": "Ɣedzeƒe America gaƒoƒoɖoanyime", "∅∅∅": "Eker dzomeŋɔli gaƒoƒome", "AEDT": "Ɣedzeƒe Australia ŋkekeme gaƒoƒome", "HNPMX": "HNPMX", "GYT": "Gayana gaƒoƒome", "ACWDT": "Australia ɣetoɖofe ŋkekeme gaƒoƒome", "MEZ": "Titina Europe gaƒoƒoɖoanyime", "WESZ": "Ɣetoɖoƒe Europe ŋkekeme gaƒoƒome", "HNEG": "Ɣedzeƒe Grinlanɖ gaƒoƒoɖoanyime", "HEEG": "Ɣedzeƒe Grinlanɖ dzomeŋɔli gaƒoƒome", "UYT": "Uruguai gaƒoƒoɖoanyime", "ChST": "ChST", "SAST": "Anyiehe Africa gaƒoƒome", "HNOG": "Ɣetoɖoƒe Grinlanɖ gaƒoƒoɖoanyime", "ACDT": "Titina Australia ŋkekeme gaƒoƒome", "HNPM": "Saint Pierre kple Mikuelon gaƒoƒoɖoanyime", "LHDT": "LHDT", "HEPMX": "HEPMX", "NZDT": "NZDT", "COT": "Kolombia gaƒoƒoɖoanyime", "CHADT": "CHADT", "HAST": "Hawaii-Aleutia gaƒoƒoɖoanyime", "NZST": "NZST", "OESZ": "Ɣedzeƒe Europe ŋkekeme gaƒoƒome", "ADT": "Atlantic ŋkekeme gaƒoƒome", "WITA": "WITA", "UYST": "Uruguai dzomeŋɔli gaƒoƒome", "WIB": "WIB", "CDT": "Titina America ŋkekeme gaƒoƒome", "PDT": "Pacific ŋkekme gaƒoƒome", "MDT": "America Todzidukɔwo ƒe ŋkekme gaƒoƒome", "AWST": "Ɣetoɖoƒe Australia gaƒoƒoɖoanyime", "CHAST": "CHAST", "CAT": "Titina Afrika gaƒoƒome", "WART": "Ɣetoɖoƒe Argentina gaƒoƒoɖoanyime", "MESZ": "Titina Europe ŋkekeme gaƒoƒome", "WEZ": "Ɣetoɖoƒe Europe gaƒoƒoɖoanyime", "GMT": "Greenwich gaƒoƒome", "WAST": "Ɣetoɖoƒe Africa ŋkekeme gaƒoƒome", "BT": "BT", "MST": "America Todzidukɔwo ƒe gaƒoƒoɖoanyime", "HEPM": "Saint Pierre kple Mikuelon ŋkekeme gaƒoƒome", "EAT": "Ɣedzeƒe Africa gaƒoƒome", "CLST": "Tsile dzomeŋɔli gaƒoƒome", "HNCU": "Kuba gaƒoƒoɖoanyime", "BOT": "Bolivia gaƒoƒome", "ACWST": "Australia ɣetoɖofe gaƒoƒoɖoanyime", "HNT": "Niufaunɖlanɖ gaƒoƒoɖoanyime", "AEST": "Ɣedzeƒe Australia gaƒoƒoɖoanyime", "AKST": "Alaska gaƒoƒoɖoanyime", "LHST": "LHST", "SGT": "SGT", "JST": "Japan gaƒoƒoɖanyime", "TMST": "Tɛkmenistan dzomeŋɔli gaƒoƒome", "ARST": "Argentina dzomeŋɔli gaƒoƒome"}, + } +} + +// Locale returns the current translators string locale +func (ee *ee) Locale() string { + return ee.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ee' +func (ee *ee) PluralsCardinal() []locales.PluralRule { + return ee.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ee' +func (ee *ee) PluralsOrdinal() []locales.PluralRule { + return ee.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ee' +func (ee *ee) PluralsRange() []locales.PluralRule { + return ee.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ee' +func (ee *ee) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ee' +func (ee *ee) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ee' +func (ee *ee) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ee *ee) MonthAbbreviated(month time.Month) string { + return ee.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ee *ee) MonthsAbbreviated() []string { + return ee.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ee *ee) MonthNarrow(month time.Month) string { + return ee.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ee *ee) MonthsNarrow() []string { + return ee.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ee *ee) MonthWide(month time.Month) string { + return ee.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ee *ee) MonthsWide() []string { + return ee.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ee *ee) WeekdayAbbreviated(weekday time.Weekday) string { + return ee.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ee *ee) WeekdaysAbbreviated() []string { + return ee.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ee *ee) WeekdayNarrow(weekday time.Weekday) string { + return ee.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ee *ee) WeekdaysNarrow() []string { + return ee.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ee *ee) WeekdayShort(weekday time.Weekday) string { + return ee.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ee *ee) WeekdaysShort() []string { + return ee.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ee *ee) WeekdayWide(weekday time.Weekday) string { + return ee.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ee *ee) WeekdaysWide() []string { + return ee.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ee' and handles both Whole and Real numbers based on 'v' +func (ee *ee) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ee' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ee *ee) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ee' +func (ee *ee) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ee.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ee.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ee.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ee.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ee.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ee' +// in accounting notation. +func (ee *ee) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ee.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ee.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ee.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ee.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ee.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ee.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ee' +func (ee *ee) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ee' +func (ee *ee) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ee' +func (ee *ee) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ee' +func (ee *ee) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ee.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ee' +func (ee *ee) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ee.periodsAbbreviated[0]...) + } else { + b = append(b, ee.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20, 0x67, 0x61}...) + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ee' +func (ee *ee) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ee.periodsAbbreviated[0]...) + } else { + b = append(b, ee.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20, 0x67, 0x61}...) + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ee' +func (ee *ee) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ee.periodsAbbreviated[0]...) + } else { + b = append(b, ee.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20, 0x67, 0x61}...) + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ee' +func (ee *ee) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ee.periodsAbbreviated[0]...) + } else { + b = append(b, ee.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20, 0x67, 0x61}...) + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ee.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ee/ee_test.go b/vendor/github.com/go-playground/locales/ee/ee_test.go new file mode 100644 index 0000000000..dd9eb74cf8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ee/ee_test.go @@ -0,0 +1,1120 @@ +package ee + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ee" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ee_GH/ee_GH.go b/vendor/github.com/go-playground/locales/ee_GH/ee_GH.go new file mode 100644 index 0000000000..4f2a971eb5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ee_GH/ee_GH.go @@ -0,0 +1,564 @@ +package ee_GH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ee_GH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ee_GH' locale +func New() locales.Translator { + return &ee_GH{ + locale: "ee_GH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "dzv", "dzd", "ted", "afɔ", "dam", "mas", "sia", "dea", "any", "kel", "ade", "dzm"}, + monthsNarrow: []string{"", "d", "d", "t", "a", "d", "m", "s", "d", "a", "k", "a", "d"}, + monthsWide: []string{"", "dzove", "dzodze", "tedoxe", "afɔfĩe", "dama", "masa", "siamlɔm", "deasiamime", "anyɔnyɔ", "kele", "adeɛmekpɔxe", "dzome"}, + daysAbbreviated: []string{"kɔs", "dzo", "bla", "kuɖ", "yaw", "fiɖ", "mem"}, + daysNarrow: []string{"k", "d", "b", "k", "y", "f", "m"}, + daysShort: []string{"kɔs", "dzo", "bla", "kuɖ", "yaw", "fiɖ", "mem"}, + daysWide: []string{"kɔsiɖa", "dzoɖa", "blaɖa", "kuɖa", "yawoɖa", "fiɖa", "memleɖa"}, + periodsAbbreviated: []string{"ŋdi", "ɣetrɔ"}, + periodsNarrow: []string{"ŋ", "ɣ"}, + periodsWide: []string{"ŋdi", "ɣetrɔ"}, + erasAbbreviated: []string{"hY", "Yŋ"}, + erasNarrow: []string{"hY", "Yŋ"}, + erasWide: []string{"Hafi Yesu Va Do ŋgɔ", "Yesu Ŋɔli"}, + timezones: map[string]string{"HENOMX": "HENOMX", "HAT": "Niufaunɖlanɖ ŋkekeme gaƒoƒome", "SRT": "Suriname gaƒoƒome", "WIB": "WIB", "CST": "Titina America gaƒoƒoɖoanyime", "CAT": "Titina Afrika gaƒoƒome", "MST": "Makau gaƒoƒoɖoanyime", "HEOG": "Ɣetoɖoƒe Grinlanɖ dzomeŋɔli gaƒoƒome", "WITA": "WITA", "HNPM": "Saint Pierre kple Mikuelon gaƒoƒoɖoanyime", "HNPMX": "HNPMX", "PST": "Pacific gaƒoƒoɖoanyime", "GMT": "Greenwich gaƒoƒome", "BT": "BT", "GFT": "Frentsi Guiana gaƒoƒome", "SGT": "SGT", "MESZ": "Titina Europe ŋkekeme gaƒoƒome", "HADT": "Hawaii-Aleutia ŋkekeme gaƒoƒome", "MYT": "MYT", "CLT": "Tsile gaƒoƒoɖoanyime", "CLST": "Tsile dzomeŋɔli gaƒoƒome", "BOT": "Bolivia gaƒoƒome", "CHADT": "CHADT", "WAST": "Ɣetoɖoƒe Africa ŋkekeme gaƒoƒome", "ART": "Argentina gaƒoƒoɖoanyime", "HKST": "Hɔng Kɔng dzomeŋɔli gaƒoƒome", "HNT": "Niufaunɖlanɖ gaƒoƒoɖoanyime", "HECU": "Kuba ŋkekeme gaƒoƒome", "CHAST": "CHAST", "MEZ": "Titina Europe gaƒoƒoɖoanyime", "MDT": "Makau ŋkekeme gaƒoƒome", "ARST": "Argentina dzomeŋɔli gaƒoƒome", "AKDT": "Alaska ŋkekeme gaƒoƒome", "EAT": "Ɣedzeƒe Africa gaƒoƒome", "CDT": "Titina America ŋkekeme gaƒoƒome", "HAST": "Hawaii-Aleutia gaƒoƒoɖoanyime", "JST": "Japan gaƒoƒoɖanyime", "TMST": "Tɛkmenistan dzomeŋɔli gaƒoƒome", "WAT": "Ɣetoɖoƒe Afrika gaƒoƒoɖoanyime", "NZST": "NZST", "HNOG": "Ɣetoɖoƒe Grinlanɖ gaƒoƒoɖoanyime", "NZDT": "NZDT", "IST": "IST", "HKT": "Hɔng Kɔng gaƒoƒoɖoanyi me", "PDT": "Pacific ŋkekme gaƒoƒome", "ACWDT": "Australia ɣetoɖofe ŋkekeme gaƒoƒome", "COT": "Kolombia gaƒoƒoɖoanyime", "HEEG": "Ɣedzeƒe Grinlanɖ dzomeŋɔli gaƒoƒome", "SAST": "Anyiehe Africa gaƒoƒome", "WIT": "WIT", "VET": "Venezuela gaƒoƒome", "WARST": "Ɣetoɖoƒe Argentina dzomeŋɔli gaƒoƒome", "OESZ": "Ɣedzeƒe Europe ŋkekeme gaƒoƒome", "EST": "Ɣedzeƒe America gaƒoƒoɖoanyime", "ACST": "Titina Australia gaƒoƒoɖoanyime", "ACDT": "Titina Australia ŋkekeme gaƒoƒome", "HNEG": "Ɣedzeƒe Grinlanɖ gaƒoƒoɖoanyime", "UYST": "Uruguai dzomeŋɔli gaƒoƒome", "AWDT": "Ɣetoɖoƒe Australia ŋkekeme gaƒoƒome", "WEZ": "Ɣetoɖoƒe Europe gaƒoƒoɖoanyime", "LHDT": "LHDT", "GYT": "Gayana gaƒoƒome", "AEDT": "Ɣedzeƒe Australia ŋkekeme gaƒoƒome", "UYT": "Uruguai gaƒoƒoɖoanyime", "JDT": "Japan ŋkekeme gaƒoƒome", "COST": "Kolombia dzomeŋɔli gaƒoƒome", "HNNOMX": "HNNOMX", "ChST": "ChST", "HEPMX": "HEPMX", "AWST": "Ɣetoɖoƒe Australia gaƒoƒoɖoanyime", "∅∅∅": "Amazon dzomeŋɔli gaƒoƒome", "AST": "Atlantic gaƒoƒoɖoanyime", "OEZ": "Ɣedzeƒe Europe gaƒoƒoɖoanyime", "EDT": "Ɣedzeƒe America ŋkekeme gaƒoƒome", "LHST": "LHST", "HNCU": "Kuba gaƒoƒoɖoanyime", "WESZ": "Ɣetoɖoƒe Europe ŋkekeme gaƒoƒome", "WART": "Ɣetoɖoƒe Argentina gaƒoƒoɖoanyime", "TMT": "Tɛkmenistan gaƒoƒoɖoanyime", "AEST": "Ɣedzeƒe Australia gaƒoƒoɖoanyime", "ADT": "Atlantic ŋkekeme gaƒoƒome", "AKST": "Alaska gaƒoƒoɖoanyime", "HEPM": "Saint Pierre kple Mikuelon ŋkekeme gaƒoƒome", "ECT": "Ikuedɔ dzomeŋɔli gaƒoƒome", "ACWST": "Australia ɣetoɖofe gaƒoƒoɖoanyime"}, + } +} + +// Locale returns the current translators string locale +func (ee *ee_GH) Locale() string { + return ee.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ee_GH' +func (ee *ee_GH) PluralsCardinal() []locales.PluralRule { + return ee.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ee_GH' +func (ee *ee_GH) PluralsOrdinal() []locales.PluralRule { + return ee.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ee_GH' +func (ee *ee_GH) PluralsRange() []locales.PluralRule { + return ee.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ee_GH' +func (ee *ee_GH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ee_GH' +func (ee *ee_GH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ee_GH' +func (ee *ee_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ee *ee_GH) MonthAbbreviated(month time.Month) string { + return ee.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ee *ee_GH) MonthsAbbreviated() []string { + return ee.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ee *ee_GH) MonthNarrow(month time.Month) string { + return ee.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ee *ee_GH) MonthsNarrow() []string { + return ee.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ee *ee_GH) MonthWide(month time.Month) string { + return ee.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ee *ee_GH) MonthsWide() []string { + return ee.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ee *ee_GH) WeekdayAbbreviated(weekday time.Weekday) string { + return ee.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ee *ee_GH) WeekdaysAbbreviated() []string { + return ee.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ee *ee_GH) WeekdayNarrow(weekday time.Weekday) string { + return ee.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ee *ee_GH) WeekdaysNarrow() []string { + return ee.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ee *ee_GH) WeekdayShort(weekday time.Weekday) string { + return ee.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ee *ee_GH) WeekdaysShort() []string { + return ee.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ee *ee_GH) WeekdayWide(weekday time.Weekday) string { + return ee.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ee *ee_GH) WeekdaysWide() []string { + return ee.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ee_GH' and handles both Whole and Real numbers based on 'v' +func (ee *ee_GH) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ee_GH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ee *ee_GH) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ee_GH' +func (ee *ee_GH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ee.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ee.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ee.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ee.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ee.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ee_GH' +// in accounting notation. +func (ee *ee_GH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ee.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ee.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ee.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ee.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ee.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ee.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ee_GH' +func (ee *ee_GH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ee_GH' +func (ee *ee_GH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ee_GH' +func (ee *ee_GH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ee_GH' +func (ee *ee_GH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ee.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ee_GH' +func (ee *ee_GH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ee.periodsAbbreviated[0]...) + } else { + b = append(b, ee.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20, 0x67, 0x61}...) + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ee_GH' +func (ee *ee_GH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ee.periodsAbbreviated[0]...) + } else { + b = append(b, ee.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20, 0x67, 0x61}...) + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ee_GH' +func (ee *ee_GH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ee.periodsAbbreviated[0]...) + } else { + b = append(b, ee.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20, 0x67, 0x61}...) + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ee_GH' +func (ee *ee_GH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ee.periodsAbbreviated[0]...) + } else { + b = append(b, ee.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20, 0x67, 0x61}...) + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ee.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ee_GH/ee_GH_test.go b/vendor/github.com/go-playground/locales/ee_GH/ee_GH_test.go new file mode 100644 index 0000000000..8ddba1bfd6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ee_GH/ee_GH_test.go @@ -0,0 +1,1120 @@ +package ee_GH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ee_GH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ee_TG/ee_TG.go b/vendor/github.com/go-playground/locales/ee_TG/ee_TG.go new file mode 100644 index 0000000000..29d7f051e4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ee_TG/ee_TG.go @@ -0,0 +1,520 @@ +package ee_TG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ee_TG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ee_TG' locale +func New() locales.Translator { + return &ee_TG{ + locale: "ee_TG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "dzv", "dzd", "ted", "afɔ", "dam", "mas", "sia", "dea", "any", "kel", "ade", "dzm"}, + monthsNarrow: []string{"", "d", "d", "t", "a", "d", "m", "s", "d", "a", "k", "a", "d"}, + monthsWide: []string{"", "dzove", "dzodze", "tedoxe", "afɔfĩe", "dama", "masa", "siamlɔm", "deasiamime", "anyɔnyɔ", "kele", "adeɛmekpɔxe", "dzome"}, + daysAbbreviated: []string{"kɔs", "dzo", "bla", "kuɖ", "yaw", "fiɖ", "mem"}, + daysNarrow: []string{"k", "d", "b", "k", "y", "f", "m"}, + daysShort: []string{"kɔs", "dzo", "bla", "kuɖ", "yaw", "fiɖ", "mem"}, + daysWide: []string{"kɔsiɖa", "dzoɖa", "blaɖa", "kuɖa", "yawoɖa", "fiɖa", "memleɖa"}, + periodsAbbreviated: []string{"ŋdi", "ɣetrɔ"}, + periodsNarrow: []string{"ŋ", "ɣ"}, + periodsWide: []string{"ŋdi", "ɣetrɔ"}, + erasAbbreviated: []string{"hY", "Yŋ"}, + erasNarrow: []string{"hY", "Yŋ"}, + erasWide: []string{"Hafi Yesu Va Do ŋgɔ", "Yesu Ŋɔli"}, + timezones: map[string]string{"WART": "Ɣetoɖoƒe Argentina gaƒoƒoɖoanyime", "WARST": "Ɣetoɖoƒe Argentina dzomeŋɔli gaƒoƒome", "COST": "Kolombia dzomeŋɔli gaƒoƒome", "CDT": "Titina America ŋkekeme gaƒoƒome", "SAST": "Anyiehe Africa gaƒoƒome", "ECT": "Ikuedɔ dzomeŋɔli gaƒoƒome", "JST": "Japan gaƒoƒoɖanyime", "OEZ": "Ɣedzeƒe Europe gaƒoƒoɖoanyime", "HNEG": "Ɣedzeƒe Grinlanɖ gaƒoƒoɖoanyime", "WITA": "WITA", "HNCU": "Kuba gaƒoƒoɖoanyime", "EAT": "Ɣedzeƒe Africa gaƒoƒome", "AEST": "Ɣedzeƒe Australia gaƒoƒoɖoanyime", "HNPM": "Saint Pierre kple Mikuelon gaƒoƒoɖoanyime", "HEPM": "Saint Pierre kple Mikuelon ŋkekeme gaƒoƒome", "LHST": "LHST", "HAST": "Hawaii-Aleutia gaƒoƒoɖoanyime", "MYT": "MYT", "WEZ": "Ɣetoɖoƒe Europe gaƒoƒoɖoanyime", "AKST": "Alaska gaƒoƒoɖoanyime", "WAT": "Ɣetoɖoƒe Afrika gaƒoƒoɖoanyime", "ARST": "Argentina dzomeŋɔli gaƒoƒome", "HADT": "Hawaii-Aleutia ŋkekeme gaƒoƒome", "TMT": "Tɛkmenistan gaƒoƒoɖoanyime", "GYT": "Gayana gaƒoƒome", "WIT": "WIT", "MEZ": "Titina Europe gaƒoƒoɖoanyime", "AST": "Atlantic gaƒoƒoɖoanyime", "HKST": "Hɔng Kɔng dzomeŋɔli gaƒoƒome", "HEEG": "Ɣedzeƒe Grinlanɖ dzomeŋɔli gaƒoƒome", "HEPMX": "HEPMX", "ACWST": "Australia ɣetoɖofe gaƒoƒoɖoanyime", "HNNOMX": "HNNOMX", "HAT": "Niufaunɖlanɖ ŋkekeme gaƒoƒome", "CHADT": "CHADT", "SRT": "Suriname gaƒoƒome", "CST": "Titina America gaƒoƒoɖoanyime", "UYST": "Uruguai dzomeŋɔli gaƒoƒome", "UYT": "Uruguai gaƒoƒoɖoanyime", "AWDT": "Ɣetoɖoƒe Australia ŋkekeme gaƒoƒome", "CHAST": "CHAST", "NZST": "NZST", "NZDT": "NZDT", "GMT": "Greenwich gaƒoƒome", "WAST": "Ɣetoɖoƒe Africa ŋkekeme gaƒoƒome", "GFT": "Frentsi Guiana gaƒoƒome", "HNPMX": "HNPMX", "BOT": "Bolivia gaƒoƒome", "MESZ": "Titina Europe ŋkekeme gaƒoƒome", "HKT": "Hɔng Kɔng gaƒoƒoɖoanyi me", "COT": "Kolombia gaƒoƒoɖoanyime", "LHDT": "LHDT", "IST": "IST", "VET": "Venezuela gaƒoƒome", "OESZ": "Ɣedzeƒe Europe ŋkekeme gaƒoƒome", "HECU": "Kuba ŋkekeme gaƒoƒome", "HEOG": "Ɣetoɖoƒe Grinlanɖ dzomeŋɔli gaƒoƒome", "HENOMX": "HENOMX", "CLST": "Tsile dzomeŋɔli gaƒoƒome", "AKDT": "Alaska ŋkekeme gaƒoƒome", "JDT": "Japan ŋkekeme gaƒoƒome", "HNOG": "Ɣetoɖoƒe Grinlanɖ gaƒoƒoɖoanyime", "ACDT": "Titina Australia ŋkekeme gaƒoƒome", "BT": "BT", "MST": "America Todzidukɔwo ƒe gaƒoƒoɖoanyime", "ACWDT": "Australia ɣetoɖofe ŋkekeme gaƒoƒome", "EST": "Ɣedzeƒe America gaƒoƒoɖoanyime", "MDT": "America Todzidukɔwo ƒe ŋkekme gaƒoƒome", "AWST": "Ɣetoɖoƒe Australia gaƒoƒoɖoanyime", "PST": "Pacific gaƒoƒoɖoanyime", "WESZ": "Ɣetoɖoƒe Europe ŋkekeme gaƒoƒome", "TMST": "Tɛkmenistan dzomeŋɔli gaƒoƒome", "ART": "Argentina gaƒoƒoɖoanyime", "EDT": "Ɣedzeƒe America ŋkekeme gaƒoƒome", "ACST": "Titina Australia gaƒoƒoɖoanyime", "WIB": "WIB", "HNT": "Niufaunɖlanɖ gaƒoƒoɖoanyime", "ChST": "ChST", "∅∅∅": "Azores dzomeŋɔli gaƒoƒome", "SGT": "SGT", "PDT": "Pacific ŋkekme gaƒoƒome", "CAT": "Titina Afrika gaƒoƒome", "CLT": "Tsile gaƒoƒoɖoanyime", "ADT": "Atlantic ŋkekeme gaƒoƒome", "AEDT": "Ɣedzeƒe Australia ŋkekeme gaƒoƒome"}, + } +} + +// Locale returns the current translators string locale +func (ee *ee_TG) Locale() string { + return ee.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ee_TG' +func (ee *ee_TG) PluralsCardinal() []locales.PluralRule { + return ee.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ee_TG' +func (ee *ee_TG) PluralsOrdinal() []locales.PluralRule { + return ee.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ee_TG' +func (ee *ee_TG) PluralsRange() []locales.PluralRule { + return ee.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ee_TG' +func (ee *ee_TG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ee_TG' +func (ee *ee_TG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ee_TG' +func (ee *ee_TG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ee *ee_TG) MonthAbbreviated(month time.Month) string { + return ee.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ee *ee_TG) MonthsAbbreviated() []string { + return ee.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ee *ee_TG) MonthNarrow(month time.Month) string { + return ee.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ee *ee_TG) MonthsNarrow() []string { + return ee.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ee *ee_TG) MonthWide(month time.Month) string { + return ee.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ee *ee_TG) MonthsWide() []string { + return ee.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ee *ee_TG) WeekdayAbbreviated(weekday time.Weekday) string { + return ee.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ee *ee_TG) WeekdaysAbbreviated() []string { + return ee.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ee *ee_TG) WeekdayNarrow(weekday time.Weekday) string { + return ee.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ee *ee_TG) WeekdaysNarrow() []string { + return ee.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ee *ee_TG) WeekdayShort(weekday time.Weekday) string { + return ee.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ee *ee_TG) WeekdaysShort() []string { + return ee.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ee *ee_TG) WeekdayWide(weekday time.Weekday) string { + return ee.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ee *ee_TG) WeekdaysWide() []string { + return ee.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ee_TG' and handles both Whole and Real numbers based on 'v' +func (ee *ee_TG) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ee_TG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ee *ee_TG) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ee_TG' +func (ee *ee_TG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ee.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ee.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ee.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ee.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ee.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ee_TG' +// in accounting notation. +func (ee *ee_TG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ee.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ee.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ee.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ee.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ee.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ee.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ee_TG' +func (ee *ee_TG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ee_TG' +func (ee *ee_TG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ee_TG' +func (ee *ee_TG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ee_TG' +func (ee *ee_TG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ee.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ee.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6c, 0x69, 0x61}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ee_TG' +func (ee *ee_TG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ee_TG' +func (ee *ee_TG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ee_TG' +func (ee *ee_TG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ee_TG' +func (ee *ee_TG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ee.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ee.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ee.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ee_TG/ee_TG_test.go b/vendor/github.com/go-playground/locales/ee_TG/ee_TG_test.go new file mode 100644 index 0000000000..4ea1976fdc --- /dev/null +++ b/vendor/github.com/go-playground/locales/ee_TG/ee_TG_test.go @@ -0,0 +1,1120 @@ +package ee_TG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ee_TG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/el/el.go b/vendor/github.com/go-playground/locales/el/el.go new file mode 100644 index 0000000000..870d4b5426 --- /dev/null +++ b/vendor/github.com/go-playground/locales/el/el.go @@ -0,0 +1,629 @@ +package el + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type el struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'el' locale +func New() locales.Translator { + return &el{ + locale: "el", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "Δρχ", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "Ιαν", "Φεβ", "Μαρ", "Απρ", "Μαΐ", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ"}, + monthsNarrow: []string{"", "Ι", "Φ", "Μ", "Α", "Μ", "Ι", "Ι", "Α", "Σ", "Ο", "Ν", "Δ"}, + monthsWide: []string{"", "Ιανουαρίου", "Φεβρουαρίου", "Μαρτίου", "Απριλίου", "Μαΐου", "Ιουνίου", "Ιουλίου", "Αυγούστου", "Σεπτεμβρίου", "Οκτωβρίου", "Νοεμβρίου", "Δεκεμβρίου"}, + daysAbbreviated: []string{"Κυρ", "Δευ", "Τρί", "Τετ", "Πέμ", "Παρ", "Σάβ"}, + daysNarrow: []string{"Κ", "Δ", "Τ", "Τ", "Π", "Π", "Σ"}, + daysShort: []string{"Κυ", "Δε", "Τρ", "Τε", "Πέ", "Πα", "Σά"}, + daysWide: []string{"Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο"}, + periodsAbbreviated: []string{"π.μ.", "μ.μ."}, + periodsNarrow: []string{"πμ", "μμ"}, + periodsWide: []string{"π.μ.", "μ.μ."}, + erasAbbreviated: []string{"π.Χ.", "μ.Χ."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"προ Χριστού", "μετά Χριστόν"}, + timezones: map[string]string{"ACWST": "Χειμερινή ώρα Κεντροδυτικής Αυστραλίας", "JST": "Χειμερινή ώρα Ιαπωνίας", "OESZ": "Θερινή ώρα Ανατολικής Ευρώπης", "HENOMX": "Θερινή ώρα Βορειοδυτικού Μεξικού", "GYT": "Ώρα Γουιάνας", "WIB": "Ώρα Δυτικής Ινδονησίας", "HNCU": "Χειμερινή ώρα Κούβας", "BOT": "Ώρα Βολιβίας", "HKT": "Χειμερινή ώρα Χονγκ Κονγκ", "WARST": "Θερινή ώρα Δυτικής Αργεντινής", "COT": "Χειμερινή ώρα Κολομβίας", "COST": "Θερινή ώρα Κολομβίας", "MDT": "Ορεινή θερινή ώρα Βόρειας Αμερικής", "ChST": "Ώρα Τσαμόρο", "MESZ": "Θερινή ώρα Κεντρικής Ευρώπης", "AEDT": "Θερινή ώρα Ανατολικής Αυστραλίας", "PST": "Χειμερινή ώρα Βόρειας Αμερικής", "WESZ": "Θερινή ώρα Δυτικής Ευρώπης", "HNOG": "Χειμερινή ώρα Δυτικής Γροιλανδίας", "OEZ": "Χειμερινή ώρα Ανατολικής Ευρώπης", "ACST": "Χειμερινή ώρα Κεντρικής Αυστραλίας", "UYST": "Θερινή ώρα Ουρουγουάης", "VET": "Ώρα Βενεζουέλας", "WAST": "Θερινή ώρα Δυτικής Αφρικής", "AST": "Χειμερινή ώρα Ατλαντικού", "BT": "Ώρα Μπουτάν", "AEST": "Χειμερινή ώρα Ανατολικής Αυστραλίας", "AKST": "Χειμερινή ώρα Αλάσκας", "UYT": "Χειμερινή ώρα Ουρουγουάης", "HEPMX": "Θερινή ώρα Ειρηνικού Μεξικού", "ACDT": "Θερινή ώρα Κεντρικής Αυστραλίας", "HECU": "Θερινή ώρα Κούβας", "CAT": "Ώρα Κεντρικής Αφρικής", "ARST": "Θερινή ώρα Αργεντινής", "EST": "Ανατολική χειμερινή ώρα Βόρειας Αμερικής", "WITA": "Ώρα Κεντρικής Ινδονησίας", "LHDT": "Θερινή ώρα Λορντ Χάου", "WIT": "Ώρα Ανατολικής Ινδονησίας", "NZST": "Χειμερινή ώρα Νέας Ζηλανδίας", "ART": "Χειμερινή ώρα Αργεντινής", "HEEG": "Θερινή ώρα Ανατολικής Γροιλανδίας", "HAT": "Θερινή ώρα Νέας Γης", "EAT": "Ώρα Ανατολικής Αφρικής", "AWDT": "Θερινή ώρα Δυτικής Αυστραλίας", "CHADT": "Θερινή ώρα Τσάθαμ", "HNPMX": "Χειμερινή ώρα Ειρηνικού Μεξικού", "SGT": "Ώρα Σιγκαπούρης", "WEZ": "Χειμερινή ώρα Δυτικής Ευρώπης", "MYT": "Ώρα Μαλαισίας", "WART": "Χειμερινή ώρα Δυτικής Αργεντινής", "ADT": "Θερινή ώρα Ατλαντικού", "TMT": "Χειμερινή ώρα Τουρκμενιστάν", "HNNOMX": "Χειμερινή ώρα Βορειοδυτικού Μεξικού", "SAST": "Χειμερινή ώρα Νότιας Αφρικής", "CST": "Κεντρική χειμερινή ώρα Βόρειας Αμερικής", "HAST": "Χειμερινή ώρα Χαβάης-Αλεούτιων νήσων", "NZDT": "Θερινή ώρα Νέας Ζηλανδίας", "MST": "Ορεινή χειμερινή ώρα Βόρειας Αμερικής", "LHST": "Χειμερινή ώρα Λορντ Χάου", "CHAST": "Χειμερινή ώρα Τσάθαμ", "ACWDT": "Θερινή ώρα Κεντροδυτικής Αυστραλίας", "JDT": "Θερινή ώρα Ιαπωνίας", "AKDT": "Θερινή ώρα Αλάσκας", "PDT": "Θερινή ώρα Βόρειας Αμερικής", "IST": "Ώρα Ινδίας", "MEZ": "Χειμερινή ώρα Κεντρικής Ευρώπης", "TMST": "Θερινή ώρα Τουρκμενιστάν", "HNT": "Χειμερινή ώρα Νέας Γης", "GFT": "Ώρα Γαλλικής Γουιάνας", "HNPM": "Χειμερινή ώρα Σαιντ Πιερ και Μικελόν", "SRT": "Ώρα Σουρινάμ", "EDT": "Ανατολική θερινή ώρα Βόρειας Αμερικής", "HNEG": "Χειμερινή ώρα Ανατολικής Γροιλανδίας", "AWST": "Χειμερινή ώρα Δυτικής Αυστραλίας", "CLST": "Θερινή ώρα Χιλής", "WAT": "Χειμερινή ώρα Δυτικής Αφρικής", "GMT": "Μέση ώρα Γκρίνουιτς", "CLT": "Χειμερινή ώρα Χιλής", "HEOG": "Θερινή ώρα Δυτικής Γροιλανδίας", "∅∅∅": "∅∅∅", "HEPM": "Θερινή ώρα Σαιντ Πιερ και Μικελόν", "CDT": "Κεντρική θερινή ώρα Βόρειας Αμερικής", "HADT": "Θερινή ώρα Χαβάης-Αλεούτιων νήσων", "ECT": "Ώρα Εκουαδόρ", "HKST": "Θερινή ώρα Χονγκ Κονγκ"}, + } +} + +// Locale returns the current translators string locale +func (el *el) Locale() string { + return el.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'el' +func (el *el) PluralsCardinal() []locales.PluralRule { + return el.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'el' +func (el *el) PluralsOrdinal() []locales.PluralRule { + return el.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'el' +func (el *el) PluralsRange() []locales.PluralRule { + return el.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'el' +func (el *el) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'el' +func (el *el) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'el' +func (el *el) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := el.CardinalPluralRule(num1, v1) + end := el.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (el *el) MonthAbbreviated(month time.Month) string { + return el.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (el *el) MonthsAbbreviated() []string { + return el.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (el *el) MonthNarrow(month time.Month) string { + return el.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (el *el) MonthsNarrow() []string { + return el.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (el *el) MonthWide(month time.Month) string { + return el.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (el *el) MonthsWide() []string { + return el.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (el *el) WeekdayAbbreviated(weekday time.Weekday) string { + return el.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (el *el) WeekdaysAbbreviated() []string { + return el.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (el *el) WeekdayNarrow(weekday time.Weekday) string { + return el.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (el *el) WeekdaysNarrow() []string { + return el.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (el *el) WeekdayShort(weekday time.Weekday) string { + return el.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (el *el) WeekdaysShort() []string { + return el.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (el *el) WeekdayWide(weekday time.Weekday) string { + return el.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (el *el) WeekdaysWide() []string { + return el.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'el' and handles both Whole and Real numbers based on 'v' +func (el *el) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'el' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (el *el) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, el.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'el' +func (el *el) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := el.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, el.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, el.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'el' +// in accounting notation. +func (el *el) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := el.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, el.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, el.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, el.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, el.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'el' +func (el *el) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'el' +func (el *el) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'el' +func (el *el) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'el' +func (el *el) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, el.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'el' +func (el *el) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'el' +func (el *el) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'el' +func (el *el) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'el' +func (el *el) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := el.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/el/el_test.go b/vendor/github.com/go-playground/locales/el/el_test.go new file mode 100644 index 0000000000..5cc18ee58a --- /dev/null +++ b/vendor/github.com/go-playground/locales/el/el_test.go @@ -0,0 +1,1120 @@ +package el + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "el" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/el_CY/el_CY.go b/vendor/github.com/go-playground/locales/el_CY/el_CY.go new file mode 100644 index 0000000000..0f44036185 --- /dev/null +++ b/vendor/github.com/go-playground/locales/el_CY/el_CY.go @@ -0,0 +1,629 @@ +package el_CY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type el_CY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'el_CY' locale +func New() locales.Translator { + return &el_CY{ + locale: "el_CY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "Ιαν", "Φεβ", "Μαρ", "Απρ", "Μαΐ", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ"}, + monthsNarrow: []string{"", "Ι", "Φ", "Μ", "Α", "Μ", "Ι", "Ι", "Α", "Σ", "Ο", "Ν", "Δ"}, + monthsWide: []string{"", "Ιανουαρίου", "Φεβρουαρίου", "Μαρτίου", "Απριλίου", "Μαΐου", "Ιουνίου", "Ιουλίου", "Αυγούστου", "Σεπτεμβρίου", "Οκτωβρίου", "Νοεμβρίου", "Δεκεμβρίου"}, + daysAbbreviated: []string{"Κυρ", "Δευ", "Τρί", "Τετ", "Πέμ", "Παρ", "Σάβ"}, + daysNarrow: []string{"Κ", "Δ", "Τ", "Τ", "Π", "Π", "Σ"}, + daysShort: []string{"Κυ", "Δε", "Τρ", "Τε", "Πέ", "Πα", "Σά"}, + daysWide: []string{"Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο"}, + periodsAbbreviated: []string{"π.μ.", "μ.μ."}, + periodsNarrow: []string{"πμ", "μμ"}, + periodsWide: []string{"π.μ.", "μ.μ."}, + erasAbbreviated: []string{"π.Χ.", "μ.Χ."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"προ Χριστού", "μετά Χριστόν"}, + timezones: map[string]string{"IST": "Ώρα Ινδίας", "OESZ": "Θερινή ώρα Ανατολικής Ευρώπης", "WEZ": "Χειμερινή ώρα Δυτικής Ευρώπης", "WARST": "Θερινή ώρα Δυτικής Αργεντινής", "AEST": "Χειμερινή ώρα Ανατολικής Αυστραλίας", "UYST": "Θερινή ώρα Ουρουγουάης", "SGT": "Ώρα Σιγκαπούρης", "ECT": "Ώρα Εκουαδόρ", "ChST": "Ώρα Τσαμόρο", "COST": "Θερινή ώρα Κολομβίας", "HNPM": "Χειμερινή ώρα Σαιντ Πιερ και Μικελόν", "HEPM": "Θερινή ώρα Σαιντ Πιερ και Μικελόν", "HECU": "Θερινή ώρα Κούβας", "NZDT": "Θερινή ώρα Νέας Ζηλανδίας", "JDT": "Θερινή ώρα Ιαπωνίας", "MEZ": "Χειμερινή ώρα Κεντρικής Ευρώπης", "TMT": "Χειμερινή ώρα Τουρκμενιστάν", "ART": "Χειμερινή ώρα Αργεντινής", "MST": "Χειμερινή ώρα Μακάο", "HNPMX": "Χειμερινή ώρα Ειρηνικού Μεξικού", "CST": "Κεντρική χειμερινή ώρα Βόρειας Αμερικής", "AWDT": "Θερινή ώρα Δυτικής Αυστραλίας", "MDT": "Θερινή ώρα Μακάο", "EST": "Ανατολική χειμερινή ώρα Βόρειας Αμερικής", "∅∅∅": "Θερινή ώρα Μπραζίλια", "ARST": "Θερινή ώρα Αργεντινής", "JST": "Χειμερινή ώρα Ιαπωνίας", "MESZ": "Θερινή ώρα Κεντρικής Ευρώπης", "WAT": "Χειμερινή ώρα Δυτικής Αφρικής", "HNT": "Χειμερινή ώρα Νέας Γης", "EAT": "Ώρα Ανατολικής Αφρικής", "CDT": "Κεντρική θερινή ώρα Βόρειας Αμερικής", "ACWDT": "Θερινή ώρα Κεντροδυτικής Αυστραλίας", "SAST": "Χειμερινή ώρα Νότιας Αφρικής", "PDT": "Θερινή ώρα Βόρειας Αμερικής", "AKDT": "Θερινή ώρα Αλάσκας", "HEOG": "Θερινή ώρα Δυτικής Γροιλανδίας", "WAST": "Θερινή ώρα Δυτικής Αφρικής", "LHST": "Χειμερινή ώρα Λορντ Χάου", "WIT": "Ώρα Ανατολικής Ινδονησίας", "BOT": "Ώρα Βολιβίας", "EDT": "Ανατολική θερινή ώρα Βόρειας Αμερικής", "HENOMX": "Θερινή ώρα Βορειοδυτικού Μεξικού", "HAT": "Θερινή ώρα Νέας Γης", "GFT": "Ώρα Γαλλικής Γουιάνας", "AKST": "Χειμερινή ώρα Αλάσκας", "GYT": "Ώρα Γουιάνας", "CHADT": "Θερινή ώρα Τσάθαμ", "VET": "Ώρα Βενεζουέλας", "AWST": "Χειμερινή ώρα Δυτικής Αυστραλίας", "HKT": "Χειμερινή ώρα Χονγκ Κονγκ", "ADT": "Θερινή ώρα Ατλαντικού", "HNOG": "Χειμερινή ώρα Δυτικής Γροιλανδίας", "LHDT": "Θερινή ώρα Λορντ Χάου", "NZST": "Χειμερινή ώρα Νέας Ζηλανδίας", "CAT": "Ώρα Κεντρικής Αφρικής", "BT": "Ώρα Μπουτάν", "CLST": "Θερινή ώρα Χιλής", "COT": "Χειμερινή ώρα Κολομβίας", "HNEG": "Χειμερινή ώρα Ανατολικής Γροιλανδίας", "WITA": "Ώρα Κεντρικής Ινδονησίας", "HEPMX": "Θερινή ώρα Ειρηνικού Μεξικού", "HADT": "Θερινή ώρα Χαβάης-Αλεούτιων νήσων", "GMT": "Μέση ώρα Γκρίνουιτς", "WESZ": "Θερινή ώρα Δυτικής Ευρώπης", "MYT": "Ώρα Μαλαισίας", "AST": "Χειμερινή ώρα Ατλαντικού", "UYT": "Χειμερινή ώρα Ουρουγουάης", "SRT": "Ώρα Σουρινάμ", "PST": "Χειμερινή ώρα Βόρειας Αμερικής", "HAST": "Χειμερινή ώρα Χαβάης-Αλεούτιων νήσων", "ACDT": "Θερινή ώρα Κεντρικής Αυστραλίας", "HEEG": "Θερινή ώρα Ανατολικής Γροιλανδίας", "AEDT": "Θερινή ώρα Ανατολικής Αυστραλίας", "HNCU": "Χειμερινή ώρα Κούβας", "CHAST": "Χειμερινή ώρα Τσάθαμ", "OEZ": "Χειμερινή ώρα Ανατολικής Ευρώπης", "CLT": "Χειμερινή ώρα Χιλής", "TMST": "Θερινή ώρα Τουρκμενιστάν", "HKST": "Θερινή ώρα Χονγκ Κονγκ", "HNNOMX": "Χειμερινή ώρα Βορειοδυτικού Μεξικού", "ACST": "Χειμερινή ώρα Κεντρικής Αυστραλίας", "WIB": "Ώρα Δυτικής Ινδονησίας", "ACWST": "Χειμερινή ώρα Κεντροδυτικής Αυστραλίας", "WART": "Χειμερινή ώρα Δυτικής Αργεντινής"}, + } +} + +// Locale returns the current translators string locale +func (el *el_CY) Locale() string { + return el.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'el_CY' +func (el *el_CY) PluralsCardinal() []locales.PluralRule { + return el.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'el_CY' +func (el *el_CY) PluralsOrdinal() []locales.PluralRule { + return el.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'el_CY' +func (el *el_CY) PluralsRange() []locales.PluralRule { + return el.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'el_CY' +func (el *el_CY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'el_CY' +func (el *el_CY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'el_CY' +func (el *el_CY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := el.CardinalPluralRule(num1, v1) + end := el.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (el *el_CY) MonthAbbreviated(month time.Month) string { + return el.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (el *el_CY) MonthsAbbreviated() []string { + return el.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (el *el_CY) MonthNarrow(month time.Month) string { + return el.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (el *el_CY) MonthsNarrow() []string { + return el.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (el *el_CY) MonthWide(month time.Month) string { + return el.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (el *el_CY) MonthsWide() []string { + return el.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (el *el_CY) WeekdayAbbreviated(weekday time.Weekday) string { + return el.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (el *el_CY) WeekdaysAbbreviated() []string { + return el.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (el *el_CY) WeekdayNarrow(weekday time.Weekday) string { + return el.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (el *el_CY) WeekdaysNarrow() []string { + return el.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (el *el_CY) WeekdayShort(weekday time.Weekday) string { + return el.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (el *el_CY) WeekdaysShort() []string { + return el.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (el *el_CY) WeekdayWide(weekday time.Weekday) string { + return el.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (el *el_CY) WeekdaysWide() []string { + return el.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'el_CY' and handles both Whole and Real numbers based on 'v' +func (el *el_CY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'el_CY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (el *el_CY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, el.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'el_CY' +func (el *el_CY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := el.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, el.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, el.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'el_CY' +// in accounting notation. +func (el *el_CY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := el.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, el.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, el.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, el.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, el.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'el_CY' +func (el *el_CY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'el_CY' +func (el *el_CY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'el_CY' +func (el *el_CY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'el_CY' +func (el *el_CY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, el.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'el_CY' +func (el *el_CY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'el_CY' +func (el *el_CY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'el_CY' +func (el *el_CY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'el_CY' +func (el *el_CY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := el.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/el_CY/el_CY_test.go b/vendor/github.com/go-playground/locales/el_CY/el_CY_test.go new file mode 100644 index 0000000000..44007ebc85 --- /dev/null +++ b/vendor/github.com/go-playground/locales/el_CY/el_CY_test.go @@ -0,0 +1,1120 @@ +package el_CY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "el_CY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/el_GR/el_GR.go b/vendor/github.com/go-playground/locales/el_GR/el_GR.go new file mode 100644 index 0000000000..5704bc548a --- /dev/null +++ b/vendor/github.com/go-playground/locales/el_GR/el_GR.go @@ -0,0 +1,629 @@ +package el_GR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type el_GR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'el_GR' locale +func New() locales.Translator { + return &el_GR{ + locale: "el_GR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "Ιαν", "Φεβ", "Μαρ", "Απρ", "Μαΐ", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ"}, + monthsNarrow: []string{"", "Ι", "Φ", "Μ", "Α", "Μ", "Ι", "Ι", "Α", "Σ", "Ο", "Ν", "Δ"}, + monthsWide: []string{"", "Ιανουαρίου", "Φεβρουαρίου", "Μαρτίου", "Απριλίου", "Μαΐου", "Ιουνίου", "Ιουλίου", "Αυγούστου", "Σεπτεμβρίου", "Οκτωβρίου", "Νοεμβρίου", "Δεκεμβρίου"}, + daysAbbreviated: []string{"Κυρ", "Δευ", "Τρί", "Τετ", "Πέμ", "Παρ", "Σάβ"}, + daysNarrow: []string{"Κ", "Δ", "Τ", "Τ", "Π", "Π", "Σ"}, + daysShort: []string{"Κυ", "Δε", "Τρ", "Τε", "Πέ", "Πα", "Σά"}, + daysWide: []string{"Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο"}, + periodsAbbreviated: []string{"π.μ.", "μ.μ."}, + periodsNarrow: []string{"πμ", "μμ"}, + periodsWide: []string{"π.μ.", "μ.μ."}, + erasAbbreviated: []string{"π.Χ.", "μ.Χ."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"προ Χριστού", "μετά Χριστόν"}, + timezones: map[string]string{"CLST": "Θερινή ώρα Χιλής", "ARST": "Θερινή ώρα Αργεντινής", "HNNOMX": "Χειμερινή ώρα Βορειοδυτικού Μεξικού", "AKDT": "Θερινή ώρα Αλάσκας", "ChST": "Ώρα Τσαμόρο", "ADT": "Θερινή ώρα Ατλαντικού", "HNPMX": "Χειμερινή ώρα Ειρηνικού Μεξικού", "CDT": "Κεντρική θερινή ώρα Βόρειας Αμερικής", "AWDT": "Θερινή ώρα Δυτικής Αυστραλίας", "HEEG": "Θερινή ώρα Ανατολικής Γροιλανδίας", "CHAST": "Χειμερινή ώρα Τσάθαμ", "MESZ": "Θερινή ώρα Κεντρικής Ευρώπης", "HNOG": "Χειμερινή ώρα Δυτικής Γροιλανδίας", "WESZ": "Θερινή ώρα Δυτικής Ευρώπης", "WAT": "Χειμερινή ώρα Δυτικής Αφρικής", "WAST": "Θερινή ώρα Δυτικής Αφρικής", "HKST": "Θερινή ώρα Χονγκ Κονγκ", "NZST": "Χειμερινή ώρα Νέας Ζηλανδίας", "UYT": "Χειμερινή ώρα Ουρουγουάης", "ECT": "Ώρα Εκουαδόρ", "NZDT": "Θερινή ώρα Νέας Ζηλανδίας", "ACWST": "Χειμερινή ώρα Κεντροδυτικής Αυστραλίας", "AST": "Χειμερινή ώρα Ατλαντικού", "EDT": "Ανατολική θερινή ώρα Βόρειας Αμερικής", "UYST": "Θερινή ώρα Ουρουγουάης", "HECU": "Θερινή ώρα Κούβας", "ACST": "Χειμερινή ώρα Κεντρικής Αυστραλίας", "HENOMX": "Θερινή ώρα Βορειοδυτικού Μεξικού", "LHST": "Χειμερινή ώρα Λορντ Χάου", "HEOG": "Θερινή ώρα Δυτικής Γροιλανδίας", "HAT": "Θερινή ώρα Νέας Γης", "SRT": "Ώρα Σουρινάμ", "HNCU": "Χειμερινή ώρα Κούβας", "PDT": "Θερινή ώρα Βόρειας Αμερικής", "ACWDT": "Θερινή ώρα Κεντροδυτικής Αυστραλίας", "ACDT": "Θερινή ώρα Κεντρικής Αυστραλίας", "CHADT": "Θερινή ώρα Τσάθαμ", "BOT": "Ώρα Βολιβίας", "EAT": "Ώρα Ανατολικής Αφρικής", "GMT": "Μέση ώρα Γκρίνουιτς", "OEZ": "Χειμερινή ώρα Ανατολικής Ευρώπης", "TMST": "Θερινή ώρα Τουρκμενιστάν", "AEDT": "Θερινή ώρα Ανατολικής Αυστραλίας", "LHDT": "Θερινή ώρα Λορντ Χάου", "HEPMX": "Θερινή ώρα Ειρηνικού Μεξικού", "MDT": "Θερινή ώρα Μακάο", "AEST": "Χειμερινή ώρα Ανατολικής Αυστραλίας", "WIB": "Ώρα Δυτικής Ινδονησίας", "WIT": "Ώρα Ανατολικής Ινδονησίας", "WARST": "Θερινή ώρα Δυτικής Αργεντινής", "TMT": "Χειμερινή ώρα Τουρκμενιστάν", "ART": "Χειμερινή ώρα Αργεντινής", "HNEG": "Χειμερινή ώρα Ανατολικής Γροιλανδίας", "SGT": "Ώρα Σιγκαπούρης", "COT": "Χειμερινή ώρα Κολομβίας", "COST": "Θερινή ώρα Κολομβίας", "BT": "Ώρα Μπουτάν", "GFT": "Ώρα Γαλλικής Γουιάνας", "CAT": "Ώρα Κεντρικής Αφρικής", "MST": "Χειμερινή ώρα Μακάο", "HAST": "Χειμερινή ώρα Χαβάης-Αλεούτιων νήσων", "AWST": "Χειμερινή ώρα Δυτικής Αυστραλίας", "∅∅∅": "Θερινή ώρα Αμαζονίου", "IST": "Ώρα Ινδίας", "MEZ": "Χειμερινή ώρα Κεντρικής Ευρώπης", "JST": "Χειμερινή ώρα Ιαπωνίας", "WEZ": "Χειμερινή ώρα Δυτικής Ευρώπης", "GYT": "Ώρα Γουιάνας", "HNPM": "Χειμερινή ώρα Σαιντ Πιερ και Μικελόν", "SAST": "Χειμερινή ώρα Νότιας Αφρικής", "MYT": "Ώρα Μαλαισίας", "WART": "Χειμερινή ώρα Δυτικής Αργεντινής", "OESZ": "Θερινή ώρα Ανατολικής Ευρώπης", "HKT": "Χειμερινή ώρα Χονγκ Κονγκ", "HNT": "Χειμερινή ώρα Νέας Γης", "WITA": "Ώρα Κεντρικής Ινδονησίας", "HADT": "Θερινή ώρα Χαβάης-Αλεούτιων νήσων", "CST": "Κεντρική χειμερινή ώρα Βόρειας Αμερικής", "PST": "Χειμερινή ώρα Βόρειας Αμερικής", "VET": "Ώρα Βενεζουέλας", "JDT": "Θερινή ώρα Ιαπωνίας", "CLT": "Χειμερινή ώρα Χιλής", "EST": "Ανατολική χειμερινή ώρα Βόρειας Αμερικής", "AKST": "Χειμερινή ώρα Αλάσκας", "HEPM": "Θερινή ώρα Σαιντ Πιερ και Μικελόν"}, + } +} + +// Locale returns the current translators string locale +func (el *el_GR) Locale() string { + return el.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'el_GR' +func (el *el_GR) PluralsCardinal() []locales.PluralRule { + return el.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'el_GR' +func (el *el_GR) PluralsOrdinal() []locales.PluralRule { + return el.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'el_GR' +func (el *el_GR) PluralsRange() []locales.PluralRule { + return el.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'el_GR' +func (el *el_GR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'el_GR' +func (el *el_GR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'el_GR' +func (el *el_GR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := el.CardinalPluralRule(num1, v1) + end := el.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (el *el_GR) MonthAbbreviated(month time.Month) string { + return el.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (el *el_GR) MonthsAbbreviated() []string { + return el.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (el *el_GR) MonthNarrow(month time.Month) string { + return el.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (el *el_GR) MonthsNarrow() []string { + return el.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (el *el_GR) MonthWide(month time.Month) string { + return el.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (el *el_GR) MonthsWide() []string { + return el.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (el *el_GR) WeekdayAbbreviated(weekday time.Weekday) string { + return el.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (el *el_GR) WeekdaysAbbreviated() []string { + return el.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (el *el_GR) WeekdayNarrow(weekday time.Weekday) string { + return el.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (el *el_GR) WeekdaysNarrow() []string { + return el.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (el *el_GR) WeekdayShort(weekday time.Weekday) string { + return el.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (el *el_GR) WeekdaysShort() []string { + return el.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (el *el_GR) WeekdayWide(weekday time.Weekday) string { + return el.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (el *el_GR) WeekdaysWide() []string { + return el.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'el_GR' and handles both Whole and Real numbers based on 'v' +func (el *el_GR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'el_GR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (el *el_GR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, el.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'el_GR' +func (el *el_GR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := el.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, el.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, el.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, el.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'el_GR' +// in accounting notation. +func (el *el_GR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := el.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, el.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, el.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, el.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, el.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, el.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, el.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'el_GR' +func (el *el_GR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'el_GR' +func (el *el_GR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'el_GR' +func (el *el_GR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'el_GR' +func (el *el_GR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, el.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, el.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'el_GR' +func (el *el_GR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'el_GR' +func (el *el_GR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'el_GR' +func (el *el_GR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'el_GR' +func (el *el_GR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, el.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, el.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, el.periodsAbbreviated[0]...) + } else { + b = append(b, el.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := el.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/el_GR/el_GR_test.go b/vendor/github.com/go-playground/locales/el_GR/el_GR_test.go new file mode 100644 index 0000000000..ef054d755a --- /dev/null +++ b/vendor/github.com/go-playground/locales/el_GR/el_GR_test.go @@ -0,0 +1,1120 @@ +package el_GR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "el_GR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en/benchmarks_test.go b/vendor/github.com/go-playground/locales/en/benchmarks_test.go new file mode 100644 index 0000000000..c2ae6b0b69 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en/benchmarks_test.go @@ -0,0 +1,252 @@ +package en + +import ( + "testing" + "time" + + "github.com/go-playground/locales/currency" +) + +func BenchmarkFmtNumber(b *testing.B) { + + trans := New() + f64 := float64(1234567.43) + precision := uint64(2) + + b.ResetTimer() + + b.Run("", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtNumber(f64, precision) + } + }) + + b.Run("Parallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtNumber(f64, precision) + } + }) + }) +} + +func BenchmarkFmtPercent(b *testing.B) { + + trans := New() + f64 := float64(97.05) + precision := uint64(2) + + b.ResetTimer() + + b.Run("", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtPercent(f64, precision) + } + }) + + b.Run("Parallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtPercent(f64, precision) + } + }) + }) +} + +func BenchmarkFmtCurrency(b *testing.B) { + + trans := New() + f64 := float64(1234567.43) + precision := uint64(2) + + b.ResetTimer() + + b.Run("", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtCurrency(f64, precision, currency.USD) + } + }) + + b.Run("Parallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtCurrency(f64, precision, currency.USD) + } + }) + }) +} + +func BenchmarkFmtAccounting(b *testing.B) { + + trans := New() + f64 := float64(1234567.43) + precision := uint64(2) + + b.ResetTimer() + + b.Run("", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtAccounting(f64, precision, currency.USD) + } + }) + + b.Run("Parallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtAccounting(f64, precision, currency.USD) + } + }) + }) +} + +func BenchmarkFmtDate(b *testing.B) { + + trans := New() + t := time.Now() + + b.ResetTimer() + + b.Run("FmtDateShort", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtDateShort(t) + } + }) + + b.Run("FmtDateShortParallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtDateShort(t) + } + }) + }) + + b.Run("FmtDateMedium", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtDateMedium(t) + } + }) + + b.Run("FmtDateMediumParallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtDateMedium(t) + } + }) + }) + + b.Run("FmtDateLong", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtDateLong(t) + } + }) + + b.Run("FmtDateLongParallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtDateLong(t) + } + }) + }) + + b.Run("FmtDateFull", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtDateFull(t) + } + }) + + b.Run("FmtDateFullParallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtDateFull(t) + } + }) + }) +} + +func BenchmarkFmtTime(b *testing.B) { + + trans := New() + t := time.Now() + + b.ResetTimer() + + b.Run("FmtTimeShort", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtTimeShort(t) + } + }) + + b.Run("FmtTimeShortParallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtTimeShort(t) + } + }) + }) + + b.Run("FmtTimeMedium", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtTimeMedium(t) + } + }) + + b.Run("FmtTimeMediumParallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtTimeMedium(t) + } + }) + }) + + b.Run("FmtTimeLong", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtTimeLong(t) + } + }) + + b.Run("FmtTimeLongParallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtTimeLong(t) + } + }) + }) + + b.Run("FmtTimeFull", func(b *testing.B) { + for i := 0; i < b.N; i++ { + trans.FmtTimeFull(t) + } + }) + + b.Run("FmtTimeFullParallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + trans.FmtTimeFull(t) + } + }) + }) +} diff --git a/vendor/github.com/go-playground/locales/en/en.go b/vendor/github.com/go-playground/locales/en/en.go new file mode 100644 index 0000000000..5cb0ba8275 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en/en.go @@ -0,0 +1,635 @@ +package en + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en' locale +func New() locales.Translator { + return &en{ + locale: "en", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"MST": "Macau Standard Time", "HAT": "Newfoundland Daylight Time", "AEST": "Australian Eastern Standard Time", "EAT": "East Africa Time", "WIT": "Eastern Indonesia Time", "NZST": "New Zealand Standard Time", "AKST": "Alaska Standard Time", "UYT": "Uruguay Standard Time", "AWDT": "Australian Western Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "OEZ": "Eastern European Standard Time", "MYT": "Malaysia Time", "ACST": "Australian Central Standard Time", "AKDT": "Alaska Daylight Time", "HNCU": "Cuba Standard Time", "PST": "Pacific Standard Time", "WEZ": "Western European Standard Time", "COT": "Colombia Standard Time", "HNPMX": "Mexican Pacific Standard Time", "BOT": "Bolivia Time", "IST": "India Standard Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "SRT": "Suriname Time", "GYT": "Guyana Time", "HAST": "Hawaii-Aleutian Standard Time", "ECT": "Ecuador Time", "JDT": "Japan Daylight Time", "WARST": "Western Argentina Summer Time", "WAST": "West Africa Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "UYST": "Uruguay Summer Time", "CST": "Central Standard Time", "ARST": "Argentina Summer Time", "WAT": "West Africa Standard Time", "WIB": "Western Indonesia Time", "MEZ": "Central European Standard Time", "MESZ": "Central European Summer Time", "LHDT": "Lord Howe Daylight Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "ACWST": "Australian Central Western Standard Time", "AST": "Atlantic Standard Time", "COST": "Colombia Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "BT": "Bhutan Time", "∅∅∅": "Acre Summer Time", "AWST": "Australian Western Standard Time", "GFT": "French Guiana Time", "HECU": "Cuba Daylight Time", "CAT": "Central Africa Time", "ACWDT": "Australian Central Western Daylight Time", "WART": "Western Argentina Standard Time", "ChST": "Chamorro Standard Time", "LHST": "Lord Howe Standard Time", "SGT": "Singapore Standard Time", "JST": "Japan Standard Time", "CDT": "Central Daylight Time", "CHAST": "Chatham Standard Time", "PDT": "Pacific Daylight Time", "SAST": "South Africa Standard Time", "CHADT": "Chatham Daylight Time", "ADT": "Atlantic Daylight Time", "GMT": "Greenwich Mean Time", "TMT": "Turkmenistan Standard Time", "ART": "Argentina Standard Time", "HKST": "Hong Kong Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "WITA": "Central Indonesia Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CLT": "Chile Standard Time", "CLST": "Chile Summer Time", "EDT": "Eastern Daylight Time", "HKT": "Hong Kong Standard Time", "HNT": "Newfoundland Standard Time", "HEEG": "East Greenland Summer Time", "HNEG": "East Greenland Standard Time", "VET": "Venezuela Time", "OESZ": "Eastern European Summer Time", "TMST": "Turkmenistan Summer Time", "MDT": "Macau Summer Time", "EST": "Eastern Standard Time", "ACDT": "Australian Central Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en' +func (en *en) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en' +func (en *en) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en' +func (en *en) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en' +func (en *en) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en' +func (en *en) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en' +func (en *en) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en' and handles both Whole and Real numbers based on 'v' +func (en *en) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en' +func (en *en) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en' +// in accounting notation. +func (en *en) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en' +func (en *en) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en' +func (en *en) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en' +func (en *en) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en' +func (en *en) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en' +func (en *en) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en' +func (en *en) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en' +func (en *en) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en' +func (en *en) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en/en_test.go b/vendor/github.com/go-playground/locales/en/en_test.go new file mode 100644 index 0000000000..1d3cd3b172 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en/en_test.go @@ -0,0 +1,1120 @@ +package en + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + { + expected: locales.PluralRuleOther, + }, + } + + rules := trans.PluralsRange() + expected := 1 + if len(rules) != expected { + t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + { + expected: locales.PluralRuleOne, + }, + { + expected: locales.PluralRuleTwo, + }, + { + expected: locales.PluralRuleFew, + }, + { + expected: locales.PluralRuleOther, + }, + } + + rules := trans.PluralsOrdinal() + expected := 4 + if len(rules) != expected { + t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + { + expected: locales.PluralRuleOne, + }, + { + expected: locales.PluralRuleOther, + }, + } + + rules := trans.PluralsCardinal() + expected := 2 + if len(rules) != expected { + t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + { + num1: 1, + v1: 1, + num2: 2, + v2: 2, + expected: locales.PluralRuleOther, + }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + { + num: 1, + v: 0, + expected: locales.PluralRuleOne, + }, + { + num: 2, + v: 0, + expected: locales.PluralRuleTwo, + }, + { + num: 3, + v: 0, + expected: locales.PluralRuleFew, + }, + { + num: 4, + v: 0, + expected: locales.PluralRuleOther, + }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + { + num: 1, + v: 0, + expected: locales.PluralRuleOne, + }, + { + num: 4, + v: 0, + expected: locales.PluralRuleOther, + }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 0, + expected: "Sun", + }, + { + idx: 1, + expected: "Mon", + }, + { + idx: 2, + expected: "Tue", + }, + { + idx: 3, + expected: "Wed", + }, + { + idx: 4, + expected: "Thu", + }, + { + idx: 5, + expected: "Fri", + }, + { + idx: 6, + expected: "Sat", + }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 0, + expected: "S", + }, + { + idx: 1, + expected: "M", + }, + { + idx: 2, + expected: "T", + }, + { + idx: 3, + expected: "W", + }, + { + idx: 4, + expected: "T", + }, + { + idx: 5, + expected: "F", + }, + { + idx: 6, + expected: "S", + }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 0, + expected: "Su", + }, + { + idx: 1, + expected: "Mo", + }, + { + idx: 2, + expected: "Tu", + }, + { + idx: 3, + expected: "We", + }, + { + idx: 4, + expected: "Th", + }, + { + idx: 5, + expected: "Fr", + }, + { + idx: 6, + expected: "Sa", + }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 0, + expected: "Sunday", + }, + { + idx: 1, + expected: "Monday", + }, + { + idx: 2, + expected: "Tuesday", + }, + { + idx: 3, + expected: "Wednesday", + }, + { + idx: 4, + expected: "Thursday", + }, + { + idx: 5, + expected: "Friday", + }, + { + idx: 6, + expected: "Saturday", + }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 1, + expected: "Jan", + }, + { + idx: 2, + expected: "Feb", + }, + { + idx: 3, + expected: "Mar", + }, + { + idx: 4, + expected: "Apr", + }, + { + idx: 5, + expected: "May", + }, + { + idx: 6, + expected: "Jun", + }, + { + idx: 7, + expected: "Jul", + }, + { + idx: 8, + expected: "Aug", + }, + { + idx: 9, + expected: "Sep", + }, + { + idx: 10, + expected: "Oct", + }, + { + idx: 11, + expected: "Nov", + }, + { + idx: 12, + expected: "Dec", + }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 1, + expected: "J", + }, + { + idx: 2, + expected: "F", + }, + { + idx: 3, + expected: "M", + }, + { + idx: 4, + expected: "A", + }, + { + idx: 5, + expected: "M", + }, + { + idx: 6, + expected: "J", + }, + { + idx: 7, + expected: "J", + }, + { + idx: 8, + expected: "A", + }, + { + idx: 9, + expected: "S", + }, + { + idx: 10, + expected: "O", + }, + { + idx: 11, + expected: "N", + }, + { + idx: 12, + expected: "D", + }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 1, + expected: "January", + }, + { + idx: 2, + expected: "February", + }, + { + idx: 3, + expected: "March", + }, + { + idx: 4, + expected: "April", + }, + { + idx: 5, + expected: "May", + }, + { + idx: 6, + expected: "June", + }, + { + idx: 7, + expected: "July", + }, + { + idx: 8, + expected: "August", + }, + { + idx: 9, + expected: "September", + }, + { + idx: 10, + expected: "October", + }, + { + idx: 11, + expected: "November", + }, + { + idx: 12, + expected: "December", + }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + loc, err := time.LoadLocation("America/Toronto") + if err != nil { + t.Errorf("Expected '' Got '%s'", err) + } + + fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + expected: "9:05:01 am Eastern Standard Time", + }, + { + t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + expected: "8:05:01 pm OTHER", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + loc, err := time.LoadLocation("America/Toronto") + if err != nil { + t.Errorf("Expected '' Got '%s'", err) + } + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + expected: "9:05:01 am EST", + }, + { + t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + expected: "8:05:01 pm EST", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + expected: "9:05:01 am", + }, + { + t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + expected: "8:05:01 pm", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + expected: "9:05 am", + }, + { + t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + expected: "8:05 pm", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "Wednesday, February 3, 2016", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "February 3, 2016", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "Feb 3, 2016", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "2/3/16", + }, + { + t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "2/3/500", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + { + num: 1123456.5643, + v: 2, + expected: "1,123,456.56", + }, + { + num: 1123456.5643, + v: 1, + expected: "1,123,456.6", + }, + { + num: 221123456.5643, + v: 3, + expected: "221,123,456.564", + }, + { + num: -221123456.5643, + v: 3, + expected: "-221,123,456.564", + }, + { + num: -221123456.5643, + v: 3, + expected: "-221,123,456.564", + }, + { + num: 0, + v: 2, + expected: "0.00", + }, + { + num: -0, + v: 2, + expected: "0.00", + }, + { + num: -0, + v: 2, + expected: "0.00", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + { + num: 1123456.5643, + v: 2, + currency: currency.USD, + expected: "$1,123,456.56", + }, + { + num: 1123456.5643, + v: 1, + currency: currency.USD, + expected: "$1,123,456.60", + }, + { + num: 221123456.5643, + v: 3, + currency: currency.USD, + expected: "$221,123,456.564", + }, + { + num: -221123456.5643, + v: 3, + currency: currency.USD, + expected: "-$221,123,456.564", + }, + { + num: -221123456.5643, + v: 3, + currency: currency.CAD, + expected: "-CAD221,123,456.564", + }, + { + num: 0, + v: 2, + currency: currency.USD, + expected: "$0.00", + }, + { + num: -0, + v: 2, + currency: currency.USD, + expected: "$0.00", + }, + { + num: -0, + v: 2, + currency: currency.CAD, + expected: "CAD0.00", + }, + { + num: 1.23, + v: 0, + currency: currency.USD, + expected: "$1.00", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + { + num: 1123456.5643, + v: 2, + currency: currency.USD, + expected: "$1,123,456.56", + }, + { + num: 1123456.5643, + v: 1, + currency: currency.USD, + expected: "$1,123,456.60", + }, + { + num: 221123456.5643, + v: 3, + currency: currency.USD, + expected: "$221,123,456.564", + }, + { + num: -221123456.5643, + v: 3, + currency: currency.USD, + expected: "($221,123,456.564)", + }, + { + num: -221123456.5643, + v: 3, + currency: currency.CAD, + expected: "(CAD221,123,456.564)", + }, + { + num: -0, + v: 2, + currency: currency.USD, + expected: "$0.00", + }, + { + num: -0, + v: 2, + currency: currency.CAD, + expected: "CAD0.00", + }, + { + num: 1.23, + v: 0, + currency: currency.USD, + expected: "$1.00", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + { + num: 15, + v: 0, + expected: "15%", + }, + { + num: 15, + v: 2, + expected: "15.00%", + }, + { + num: 434.45, + v: 0, + expected: "434%", + }, + { + num: 34.4, + v: 2, + expected: "34.40%", + }, + { + num: -34, + v: 0, + expected: "-34%", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_001/en_001.go b/vendor/github.com/go-playground/locales/en_001/en_001.go new file mode 100644 index 0000000000..2dae39da9b --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_001/en_001.go @@ -0,0 +1,645 @@ +package en_001 + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_001 struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_001' locale +func New() locales.Translator { + return &en_001{ + locale: "en_001", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"GMT": "Greenwich Mean Time", "ACDT": "Australian Central Daylight Time", "HNEG": "East Greenland Standard Time", "HNPMX": "Mexican Pacific Standard Time", "CAT": "Central Africa Time", "MEZ": "Central European Standard Time", "JDT": "Japan Daylight Time", "ARST": "Argentina Summer Time", "HKT": "Hong Kong Standard Time", "COT": "Colombia Standard Time", "BT": "Bhutan Time", "SGT": "Singapore Standard Time", "ACWST": "Australian Central Western Standard Time", "HEOG": "West Greenland Summer Time", "COST": "Colombia Summer Time", "AKST": "Alaska Standard Time", "WIT": "Eastern Indonesia Time", "CLST": "Chile Summer Time", "CLT": "Chile Standard Time", "HAT": "Newfoundland Daylight Time", "HEEG": "East Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "CST": "Central Standard Time", "VET": "Venezuela Time", "OESZ": "Eastern European Summer Time", "ART": "Argentina Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AWDT": "Australian Western Daylight Time", "IST": "India Standard Time", "OEZ": "Eastern European Standard Time", "MYT": "Malaysia Time", "TMST": "Turkmenistan Summer Time", "EDT": "Eastern Daylight Time", "EAT": "East Africa Time", "WIB": "Western Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "ACST": "Australian Central Standard Time", "LHDT": "Lord Howe Daylight Time", "∅∅∅": "Brasilia Summer Time", "CHAST": "Chatham Standard Time", "ADT": "Atlantic Daylight Time", "GFT": "French Guiana Time", "CDT": "Central Daylight Time", "AST": "Atlantic Standard Time", "WITA": "Central Indonesia Time", "UYST": "Uruguay Summer Time", "SAST": "South Africa Standard Time", "ECT": "Ecuador Time", "WARST": "Western Argentina Summer Time", "MESZ": "Central European Summer Time", "HNOG": "West Greenland Standard Time", "MST": "Macau Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "LHST": "Lord Howe Standard Time", "HECU": "Cuba Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "WART": "Western Argentina Standard Time", "TMT": "Turkmenistan Standard Time", "MDT": "Macau Summer Time", "EST": "Eastern Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "SRT": "Suriname Time", "HADT": "Hawaii-Aleutian Daylight Time", "WESZ": "Western European Summer Time", "WEZ": "Western European Standard Time", "WAST": "West Africa Summer Time", "HKST": "Hong Kong Summer Time", "PST": "Pacific Standard Time", "PDT": "Pacific Daylight Time", "JST": "Japan Standard Time", "AKDT": "Alaska Daylight Time", "ChST": "Chamorro Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNCU": "Cuba Standard Time", "CHADT": "Chatham Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "BOT": "Bolivia Time", "AEST": "Australian Eastern Standard Time", "GYT": "Guyana Time", "HNT": "Newfoundland Standard Time", "UYT": "Uruguay Standard Time", "NZDT": "New Zealand Daylight Time", "WAT": "West Africa Standard Time", "AWST": "Australian Western Standard Time", "NZST": "New Zealand Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_001) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_001' +func (en *en_001) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_001' +func (en *en_001) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_001' +func (en *en_001) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_001' +func (en *en_001) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_001' +func (en *en_001) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_001' +func (en *en_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_001) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_001) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_001) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_001) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_001) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_001) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_001) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_001) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_001) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_001) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_001) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_001) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_001) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_001) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_001' and handles both Whole and Real numbers based on 'v' +func (en *en_001) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_001' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_001) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_001' +func (en *en_001) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_001' +// in accounting notation. +func (en *en_001) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_001' +func (en *en_001) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_001' +func (en *en_001) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_001' +func (en *en_001) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_001' +func (en *en_001) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_001' +func (en *en_001) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_001' +func (en *en_001) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_001' +func (en *en_001) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_001' +func (en *en_001) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_001/en_001_test.go b/vendor/github.com/go-playground/locales/en_001/en_001_test.go new file mode 100644 index 0000000000..11db46d1a4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_001/en_001_test.go @@ -0,0 +1,1120 @@ +package en_001 + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_001" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_150/en_150.go b/vendor/github.com/go-playground/locales/en_150/en_150.go new file mode 100644 index 0000000000..87fef61a83 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_150/en_150.go @@ -0,0 +1,592 @@ +package en_150 + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_150 struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_150' locale +func New() locales.Translator { + return &en_150{ + locale: "en_150", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"TMT": "Turkmenistan Standard Time", "MST": "Macau Standard Time", "CAT": "Central Africa Time", "OESZ": "Eastern European Summer Time", "AST": "Atlantic Standard Time", "WESZ": "Western European Summer Time", "HAT": "Newfoundland Daylight Time", "HEEG": "East Greenland Summer Time", "UYST": "Uruguay Summer Time", "MESZ": "Central European Summer Time", "OEZ": "Eastern European Standard Time", "GYT": "Guyana Time", "HECU": "Cuba Daylight Time", "CHADT": "Chatham Daylight Time", "BOT": "Bolivia Time", "HADT": "Hawaii-Aleutian Daylight Time", "AEDT": "Australian Eastern Daylight Time", "LHDT": "Lord Howe Daylight Time", "CHAST": "Chatham Standard Time", "AEST": "Australian Eastern Standard Time", "SAST": "South Africa Standard Time", "SRT": "Suriname Time", "EAT": "East Africa Time", "WIB": "Western Indonesia Time", "EST": "Eastern Standard Time", "HKT": "Hong Kong Standard Time", "COST": "Colombia Summer Time", "HEOG": "West Greenland Summer Time", "AWST": "Australian Western Standard Time", "JDT": "Japan Daylight Time", "WART": "Western Argentina Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "ADT": "Atlantic Daylight Time", "MDT": "Macau Summer Time", "WAT": "West Africa Standard Time", "CDT": "Central Daylight Time", "GMT": "Greenwich Mean Time", "GFT": "French Guiana Time", "WIT": "Eastern Indonesia Time", "ACWDT": "Australian Central Western Daylight Time", "ACST": "Australian Central Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HNEG": "East Greenland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "PDT": "Pacific Daylight Time", "MYT": "Malaysia Time", "ARST": "Argentina Summer Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "CST": "Central Standard Time", "ACWST": "Australian Central Western Standard Time", "HNOG": "West Greenland Standard Time", "WEZ": "Western European Standard Time", "COT": "Colombia Standard Time", "BT": "Bhutan Time", "WITA": "Central Indonesia Time", "HNCU": "Cuba Standard Time", "WAST": "West Africa Summer Time", "ACDT": "Australian Central Daylight Time", "∅∅∅": "Peru Summer Time", "ChST": "Chamorro Standard Time", "SGT": "Singapore Standard Time", "CLT": "Chile Standard Time", "AKST": "Alaska Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "NZDT": "New Zealand Daylight Time", "MEZ": "Central European Standard Time", "EDT": "Eastern Daylight Time", "UYT": "Uruguay Standard Time", "ECT": "Ecuador Time", "PST": "Pacific Standard Time", "IST": "India Standard Time", "VET": "Venezuela Time", "JST": "Japan Standard Time", "WARST": "Western Argentina Summer Time", "HNT": "Newfoundland Standard Time", "LHST": "Lord Howe Standard Time", "AWDT": "Australian Western Daylight Time", "CLST": "Chile Summer Time", "NZST": "New Zealand Standard Time", "TMST": "Turkmenistan Summer Time", "ART": "Argentina Standard Time", "AKDT": "Alaska Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_150) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_150' +func (en *en_150) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_150' +func (en *en_150) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_150' +func (en *en_150) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_150' +func (en *en_150) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_150' +func (en *en_150) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_150' +func (en *en_150) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_150) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_150) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_150) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_150) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_150) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_150) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_150) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_150) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_150) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_150) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_150) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_150) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_150) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_150) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_150' and handles both Whole and Real numbers based on 'v' +func (en *en_150) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_150' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_150) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_150' +func (en *en_150) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, en.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_150' +// in accounting notation. +func (en *en_150) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, en.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, en.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_150' +func (en *en_150) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_150' +func (en *en_150) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_150' +func (en *en_150) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_150' +func (en *en_150) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_150' +func (en *en_150) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_150' +func (en *en_150) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_150' +func (en *en_150) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_150' +func (en *en_150) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_150/en_150_test.go b/vendor/github.com/go-playground/locales/en_150/en_150_test.go new file mode 100644 index 0000000000..efa2e43959 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_150/en_150_test.go @@ -0,0 +1,1120 @@ +package en_150 + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_150" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_AG/en_AG.go b/vendor/github.com/go-playground/locales/en_AG/en_AG.go new file mode 100644 index 0000000000..8cff9f03e8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AG/en_AG.go @@ -0,0 +1,645 @@ +package en_AG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_AG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_AG' locale +func New() locales.Translator { + return &en_AG{ + locale: "en_AG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WARST": "Western Argentina Summer Time", "TMT": "Turkmenistan Standard Time", "MDT": "Macau Summer Time", "HEEG": "East Greenland Summer Time", "WIT": "Eastern Indonesia Time", "AWDT": "Australian Western Daylight Time", "VET": "Venezuela Time", "PDT": "Pacific Daylight Time", "WEZ": "Western European Standard Time", "MST": "Macau Standard Time", "CLT": "Chile Standard Time", "HAT": "Newfoundland Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "GMT": "Greenwich Mean Time", "AKST": "Alaska Standard Time", "ECT": "Ecuador Time", "IST": "India Standard Time", "AST": "Atlantic Standard Time", "NZDT": "New Zealand Daylight Time", "EDT": "Eastern Daylight Time", "ACST": "Australian Central Standard Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "GYT": "Guyana Time", "BOT": "Bolivia Time", "MEZ": "Central European Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HECU": "Cuba Daylight Time", "CLST": "Chile Summer Time", "WART": "Western Argentina Standard Time", "WAT": "West Africa Standard Time", "LHST": "Lord Howe Standard Time", "CDT": "Central Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "HNCU": "Cuba Standard Time", "SGT": "Singapore Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "SAST": "South Africa Standard Time", "LHDT": "Lord Howe Daylight Time", "TMST": "Turkmenistan Summer Time", "HNOG": "West Greenland Standard Time", "OEZ": "Eastern European Standard Time", "WITA": "Central Indonesia Time", "∅∅∅": "Azores Summer Time", "ACWST": "Australian Central Western Standard Time", "JDT": "Japan Daylight Time", "ART": "Argentina Standard Time", "HKT": "Hong Kong Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNT": "Newfoundland Standard Time", "ChST": "Chamorro Standard Time", "NZST": "New Zealand Standard Time", "JST": "Japan Standard Time", "CHAST": "Chatham Standard Time", "MESZ": "Central European Summer Time", "EST": "Eastern Standard Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "UYST": "Uruguay Summer Time", "SRT": "Suriname Time", "EAT": "East Africa Time", "AEDT": "Australian Eastern Daylight Time", "WAST": "West Africa Summer Time", "COST": "Colombia Summer Time", "HNEG": "East Greenland Standard Time", "AKDT": "Alaska Daylight Time", "UYT": "Uruguay Standard Time", "HNPMX": "Mexican Pacific Standard Time", "WESZ": "Western European Summer Time", "CAT": "Central Africa Time", "ACDT": "Australian Central Daylight Time", "COT": "Colombia Standard Time", "BT": "Bhutan Time", "GFT": "French Guiana Time", "CST": "Central Standard Time", "AWST": "Australian Western Standard Time", "PST": "Pacific Standard Time", "OESZ": "Eastern European Summer Time", "MYT": "Malaysia Time", "AEST": "Australian Eastern Standard Time", "WIB": "Western Indonesia Time", "CHADT": "Chatham Daylight Time", "ADT": "Atlantic Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_AG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_AG' +func (en *en_AG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_AG' +func (en *en_AG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_AG' +func (en *en_AG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_AG' +func (en *en_AG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_AG' +func (en *en_AG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_AG' +func (en *en_AG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_AG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_AG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_AG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_AG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_AG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_AG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_AG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_AG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_AG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_AG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_AG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_AG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_AG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_AG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_AG' and handles both Whole and Real numbers based on 'v' +func (en *en_AG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_AG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_AG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_AG' +func (en *en_AG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_AG' +// in accounting notation. +func (en *en_AG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_AG' +func (en *en_AG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_AG' +func (en *en_AG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_AG' +func (en *en_AG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_AG' +func (en *en_AG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_AG' +func (en *en_AG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_AG' +func (en *en_AG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_AG' +func (en *en_AG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_AG' +func (en *en_AG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_AG/en_AG_test.go b/vendor/github.com/go-playground/locales/en_AG/en_AG_test.go new file mode 100644 index 0000000000..a44c7ea73a --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AG/en_AG_test.go @@ -0,0 +1,1120 @@ +package en_AG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_AG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_AI/en_AI.go b/vendor/github.com/go-playground/locales/en_AI/en_AI.go new file mode 100644 index 0000000000..f3d35c59a2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AI/en_AI.go @@ -0,0 +1,607 @@ +package en_AI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_AI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_AI' locale +func New() locales.Translator { + return &en_AI{ + locale: "en_AI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HNEG": "East Greenland Standard Time", "HEOG": "West Greenland Summer Time", "BT": "Bhutan Time", "HEPMX": "Mexican Pacific Daylight Time", "WESZ": "Western European Summer Time", "EDT": "Eastern Daylight Time", "BOT": "Bolivia Time", "ACWDT": "Australian Central Western Daylight Time", "CLST": "Chile Summer Time", "AWDT": "Australian Western Daylight Time", "SGT": "Singapore Standard Time", "OEZ": "Eastern European Standard Time", "WAT": "West Africa Standard Time", "AKST": "Alaska Standard Time", "AEDT": "Australian Eastern Daylight Time", "UYT": "Uruguay Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "CLT": "Chile Standard Time", "EST": "Eastern Standard Time", "PST": "Pacific Standard Time", "PDT": "Pacific Daylight Time", "VET": "Venezuela Time", "HNNOMX": "Northwest Mexico Standard Time", "ACST": "Australian Central Standard Time", "COT": "Colombia Standard Time", "COST": "Colombia Summer Time", "LHST": "Lord Howe Standard Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "IST": "India Standard Time", "HKST": "Hong Kong Summer Time", "NZDT": "New Zealand Daylight Time", "MYT": "Malaysia Time", "ART": "Argentina Standard Time", "AEST": "Australian Eastern Standard Time", "ACDT": "Australian Central Daylight Time", "HNT": "Newfoundland Standard Time", "∅∅∅": "Acre Summer Time", "GYT": "Guyana Time", "CHADT": "Chatham Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "AST": "Atlantic Standard Time", "HKT": "Hong Kong Standard Time", "ADT": "Atlantic Daylight Time", "MST": "Mountain Standard Time", "EAT": "East Africa Time", "CHAST": "Chatham Standard Time", "WARST": "Western Argentina Summer Time", "ARST": "Argentina Summer Time", "WAST": "West Africa Summer Time", "WITA": "Central Indonesia Time", "SAST": "South Africa Standard Time", "CDT": "Central Daylight Time", "WIT": "Eastern Indonesia Time", "ECT": "Ecuador Time", "WART": "Western Argentina Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AKDT": "Alaska Daylight Time", "AWST": "Australian Western Standard Time", "NZST": "New Zealand Standard Time", "HAT": "Newfoundland Daylight Time", "MEZ": "Central European Standard Time", "JDT": "Japan Daylight Time", "WEZ": "Western European Standard Time", "TMST": "Turkmenistan Summer Time", "HEEG": "East Greenland Summer Time", "ChST": "Chamorro Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ACWST": "Australian Central Western Standard Time", "HNOG": "West Greenland Standard Time", "GFT": "French Guiana Time", "UYST": "Uruguay Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNPMX": "Mexican Pacific Standard Time", "SRT": "Suriname Time", "HNCU": "Cuba Standard Time", "OESZ": "Eastern European Summer Time", "TMT": "Turkmenistan Standard Time", "MDT": "Mountain Daylight Time", "WIB": "Western Indonesia Time", "CAT": "Central Africa Time", "MESZ": "Central European Summer Time", "JST": "Japan Standard Time", "GMT": "Greenwich Mean Time", "LHDT": "Lord Howe Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_AI) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_AI' +func (en *en_AI) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_AI' +func (en *en_AI) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_AI' +func (en *en_AI) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_AI' +func (en *en_AI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_AI' +func (en *en_AI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_AI' +func (en *en_AI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_AI) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_AI) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_AI) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_AI) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_AI) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_AI) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_AI) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_AI) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_AI) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_AI) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_AI) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_AI) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_AI) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_AI) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_AI' and handles both Whole and Real numbers based on 'v' +func (en *en_AI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_AI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_AI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_AI' +func (en *en_AI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_AI' +// in accounting notation. +func (en *en_AI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_AI' +func (en *en_AI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_AI' +func (en *en_AI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_AI' +func (en *en_AI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_AI' +func (en *en_AI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_AI' +func (en *en_AI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_AI' +func (en *en_AI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_AI' +func (en *en_AI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_AI' +func (en *en_AI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_AI/en_AI_test.go b/vendor/github.com/go-playground/locales/en_AI/en_AI_test.go new file mode 100644 index 0000000000..7aaa69dc4e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AI/en_AI_test.go @@ -0,0 +1,1120 @@ +package en_AI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_AI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_AS/en_AS.go b/vendor/github.com/go-playground/locales/en_AS/en_AS.go new file mode 100644 index 0000000000..c6b6697f58 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AS/en_AS.go @@ -0,0 +1,635 @@ +package en_AS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_AS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_AS' locale +func New() locales.Translator { + return &en_AS{ + locale: "en_AS", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"GMT": "Greenwich Mean Time", "OESZ": "Eastern European Summer Time", "WIT": "Eastern Indonesia Time", "ACDT": "Australian Central Daylight Time", "GYT": "Guyana Time", "AKDT": "Alaska Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "CDT": "Central Daylight Time", "BOT": "Bolivia Time", "ACWST": "Australian Central Western Standard Time", "CLST": "Chile Summer Time", "AST": "Atlantic Standard Time", "OEZ": "Eastern European Standard Time", "ART": "Argentina Standard Time", "WIB": "Western Indonesia Time", "JDT": "Japan Daylight Time", "WART": "Western Argentina Standard Time", "MST": "Macau Standard Time", "VET": "Venezuela Time", "AWDT": "Australian Western Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "IST": "India Standard Time", "HEOG": "West Greenland Summer Time", "TMT": "Turkmenistan Standard Time", "HEEG": "East Greenland Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "SRT": "Suriname Time", "WEZ": "Western European Standard Time", "EDT": "Eastern Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "MESZ": "Central European Summer Time", "HECU": "Cuba Daylight Time", "ECT": "Ecuador Time", "MEZ": "Central European Standard Time", "MYT": "Malaysia Time", "ADT": "Atlantic Daylight Time", "AKST": "Alaska Standard Time", "CAT": "Central Africa Time", "JST": "Japan Standard Time", "HKT": "Hong Kong Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HAT": "Newfoundland Daylight Time", "UYST": "Uruguay Summer Time", "CST": "Central Standard Time", "HNCU": "Cuba Standard Time", "HNOG": "West Greenland Standard Time", "EST": "Eastern Standard Time", "∅∅∅": "Acre Summer Time", "AEDT": "Australian Eastern Daylight Time", "SAST": "South Africa Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "COST": "Colombia Summer Time", "BT": "Bhutan Time", "UYT": "Uruguay Standard Time", "PDT": "Pacific Daylight Time", "ACST": "Australian Central Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNPMX": "Mexican Pacific Standard Time", "EAT": "East Africa Time", "SGT": "Singapore Standard Time", "TMST": "Turkmenistan Summer Time", "LHST": "Lord Howe Standard Time", "LHDT": "Lord Howe Daylight Time", "CHAST": "Chatham Standard Time", "HNT": "Newfoundland Standard Time", "AEST": "Australian Eastern Standard Time", "GFT": "French Guiana Time", "WESZ": "Western European Summer Time", "WARST": "Western Argentina Summer Time", "MDT": "Macau Summer Time", "WAST": "West Africa Summer Time", "COT": "Colombia Standard Time", "WITA": "Central Indonesia Time", "ChST": "Chamorro Standard Time", "CHADT": "Chatham Daylight Time", "AWST": "Australian Western Standard Time", "PST": "Pacific Standard Time", "NZST": "New Zealand Standard Time", "CLT": "Chile Standard Time", "ARST": "Argentina Summer Time", "HKST": "Hong Kong Summer Time", "WAT": "West Africa Standard Time", "HNEG": "East Greenland Standard Time", "NZDT": "New Zealand Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_AS) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_AS' +func (en *en_AS) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_AS' +func (en *en_AS) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_AS' +func (en *en_AS) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_AS' +func (en *en_AS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_AS' +func (en *en_AS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_AS' +func (en *en_AS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_AS) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_AS) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_AS) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_AS) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_AS) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_AS) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_AS) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_AS) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_AS) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_AS) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_AS) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_AS) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_AS) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_AS) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_AS' and handles both Whole and Real numbers based on 'v' +func (en *en_AS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_AS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_AS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_AS' +func (en *en_AS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_AS' +// in accounting notation. +func (en *en_AS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_AS' +func (en *en_AS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_AS' +func (en *en_AS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_AS' +func (en *en_AS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_AS' +func (en *en_AS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_AS' +func (en *en_AS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_AS' +func (en *en_AS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_AS' +func (en *en_AS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_AS' +func (en *en_AS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_AS/en_AS_test.go b/vendor/github.com/go-playground/locales/en_AS/en_AS_test.go new file mode 100644 index 0000000000..14f10db209 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AS/en_AS_test.go @@ -0,0 +1,1120 @@ +package en_AS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_AS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_AT/en_AT.go b/vendor/github.com/go-playground/locales/en_AT/en_AT.go new file mode 100644 index 0000000000..b605510b7f --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AT/en_AT.go @@ -0,0 +1,647 @@ +package en_AT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_AT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_AT' locale +func New() locales.Translator { + return &en_AT{ + locale: "en_AT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HADT": "Hawaii-Aleutian Daylight Time", "HEOG": "West Greenland Summer Time", "WESZ": "Western European Summer Time", "WARST": "Western Argentina Summer Time", "EST": "Eastern Standard Time", "ACST": "Australian Central Standard Time", "AEDT": "Australian Eastern Daylight Time", "CHAST": "Chatham Standard Time", "CDT": "Central Daylight Time", "OESZ": "Eastern European Summer Time", "TMST": "Turkmenistan Summer Time", "HKT": "Hong Kong Standard Time", "BT": "Bhutan Time", "WITA": "Central Indonesia Time", "GFT": "French Guiana Time", "HNPM": "St. Pierre & Miquelon Standard Time", "VET": "Venezuela Time", "CLT": "Chile Standard Time", "EDT": "Eastern Daylight Time", "PDT": "Pacific Daylight Time", "ACWST": "Australian Central Western Standard Time", "NZDT": "New Zealand Daylight Time", "JST": "Japan Standard Time", "WEZ": "Western European Standard Time", "MDT": "Macau Summer Time", "HAT": "Newfoundland Daylight Time", "GYT": "Guyana Time", "HEEG": "East Greenland Summer Time", "ChST": "Chamorro Standard Time", "SGT": "Singapore Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "HNOG": "West Greenland Standard Time", "GMT": "Greenwich Mean Time", "WAST": "West Africa Summer Time", "HKST": "Hong Kong Summer Time", "COT": "Colombia Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNPMX": "Mexican Pacific Standard Time", "WIB": "Western Indonesia Time", "CHADT": "Chatham Daylight Time", "MEZ": "Central European Standard Time", "AWST": "Australian Western Standard Time", "ART": "Argentina Standard Time", "ARST": "Argentina Summer Time", "HNT": "Newfoundland Standard Time", "HNEG": "East Greenland Standard Time", "AKDT": "Alaska Daylight Time", "SRT": "Suriname Time", "HNCU": "Cuba Standard Time", "MYT": "Malaysia Time", "PST": "Pacific Standard Time", "ADT": "Atlantic Daylight Time", "ACDT": "Australian Central Daylight Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time", "WART": "Western Argentina Standard Time", "TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "AKST": "Alaska Standard Time", "LHDT": "Lord Howe Daylight Time", "CST": "Central Standard Time", "MESZ": "Central European Summer Time", "OEZ": "Eastern European Standard Time", "BOT": "Bolivia Time", "ACWDT": "Australian Central Western Daylight Time", "MST": "Macau Standard Time", "LHST": "Lord Howe Standard Time", "EAT": "East Africa Time", "CAT": "Central Africa Time", "NZST": "New Zealand Standard Time", "CLST": "Chile Summer Time", "COST": "Colombia Summer Time", "AWDT": "Australian Western Daylight Time", "JDT": "Japan Daylight Time", "WIT": "Eastern Indonesia Time", "AST": "Atlantic Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "∅∅∅": "Acre Summer Time", "UYST": "Uruguay Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "SAST": "South Africa Standard Time", "HECU": "Cuba Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "ECT": "Ecuador Time", "IST": "India Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_AT) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_AT' +func (en *en_AT) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_AT' +func (en *en_AT) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_AT' +func (en *en_AT) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_AT' +func (en *en_AT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_AT' +func (en *en_AT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_AT' +func (en *en_AT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_AT) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_AT) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_AT) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_AT) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_AT) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_AT) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_AT) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_AT) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_AT) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_AT) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_AT) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_AT) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_AT) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_AT) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_AT' and handles both Whole and Real numbers based on 'v' +func (en *en_AT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_AT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_AT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percentSuffix...) + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_AT' +func (en *en_AT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_AT' +// in accounting notation. +func (en *en_AT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyNegativePrefix[j]) + } + + b = append(b, en.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_AT' +func (en *en_AT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_AT' +func (en *en_AT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_AT' +func (en *en_AT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_AT' +func (en *en_AT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_AT' +func (en *en_AT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_AT' +func (en *en_AT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_AT' +func (en *en_AT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_AT' +func (en *en_AT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_AT/en_AT_test.go b/vendor/github.com/go-playground/locales/en_AT/en_AT_test.go new file mode 100644 index 0000000000..91a08f03d9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AT/en_AT_test.go @@ -0,0 +1,1120 @@ +package en_AT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_AT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_AU/en_AU.go b/vendor/github.com/go-playground/locales/en_AU/en_AU.go new file mode 100644 index 0000000000..2d98b784cb --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AU/en_AU.go @@ -0,0 +1,597 @@ +package en_AU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_AU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_AU' locale +func New() locales.Translator { + return &en_AU{ + locale: "en_AU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "Tk", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "$b", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "₱", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "£", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "Kr", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "Gs", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "Rs", "SDD", "SDG", "SDP", "Kr", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "$U", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "CFP", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "Mar.", "Apr.", "May", "Jun.", "Jul.", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun.", "Mon.", "Tue.", "Wed.", "Thu.", "Fri.", "Sat."}, + daysNarrow: []string{"Su.", "M.", "Tu.", "W.", "Th.", "F.", "Sa."}, + daysShort: []string{"Su.", "Mon.", "Tu.", "Wed.", "Th.", "Fri.", "Sat."}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AWDT": "Australian Western Daylight Time", "HNT": "Newfoundland Standard Time", "WITA": "Central Indonesia Time", "PDT": "Pacific Daylight Time", "CAT": "Central Africa Time", "WAST": "West Africa Summer Time", "AEDT": "Australian Eastern Daylight Time", "WART": "Western Argentina Standard Time", "MDT": "Macau Summer Time", "CLT": "Chile Standard Time", "HAT": "Newfoundland Daylight Time", "GYT": "Guyana Time", "SGT": "Singapore Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "∅∅∅": "Amazon Summer Time", "JST": "Japan Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHDT": "Lord Howe Daylight Time", "ACWST": "Australian Central Western Standard Time", "TMST": "Turkmenistan Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "ChST": "Chamorro Standard Time", "CHADT": "Chatham Daylight Time", "JDT": "Japan Summer Time", "GMT": "Greenwich Mean Time", "HNPM": "St. Pierre & Miquelon Standard Time", "WEZ": "Western European Standard Time", "MYT": "Malaysia Time", "WAT": "West Africa Standard Time", "BT": "Bhutan Time", "HKST": "Hong Kong Summer Time", "UYT": "Uruguay Standard Time", "HNCU": "Cuba Standard Time", "CDT": "Central Daylight Time", "MEZ": "Central European Standard Time", "VET": "Venezuela Time", "HEOG": "West Greenland Summer Time", "HKT": "Hong Kong Standard Time", "GFT": "French Guiana Time", "AKST": "Alaska Standard Time", "SAST": "South Africa Standard Time", "CST": "Central Standard Time", "HNOG": "West Greenland Standard Time", "MST": "Macau Standard Time", "EST": "Eastern Standard Time", "COST": "Colombia Summer Time", "AEST": "Australian Eastern Standard Time", "HNPMX": "Mexican Pacific Standard Time", "WIT": "Eastern Indonesia Time", "BOT": "Bolivia Time", "NZST": "New Zealand Standard Time", "WESZ": "Western European Summer Time", "TMT": "Turkmenistan Standard Time", "SRT": "Suriname Time", "EAT": "Eastern Africa Time", "ECT": "Ecuador Time", "NZDT": "New Zealand Daylight Time", "HNEG": "East Greenland Standard Time", "AKDT": "Alaska Daylight Time", "CLST": "Chile Summer Time", "OEZ": "Eastern European Standard Time", "COT": "Colombia Standard Time", "AWST": "Australian Western Standard Time", "CHAST": "Chatham Standard Time", "PST": "Pacific Standard Time", "MESZ": "Central European Summer Time", "IST": "India Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "LHST": "Lord Howe Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "ADT": "Atlantic Daylight Time", "ARST": "Argentina Summer Time", "EDT": "Eastern Daylight Time", "HEEG": "East Greenland Summer Time", "ART": "Argentina Standard Time", "ACST": "Australian Central Standard Time", "UYST": "Uruguay Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "AST": "Atlantic Standard Time", "OESZ": "Eastern European Summer Time", "WARST": "Western Argentina Summer Time", "ACWDT": "Australian Central Western Daylight Time", "ACDT": "Australian Central Daylight Time", "WIB": "Western Indonesia Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_AU) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_AU' +func (en *en_AU) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_AU' +func (en *en_AU) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_AU' +func (en *en_AU) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_AU' +func (en *en_AU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_AU' +func (en *en_AU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_AU' +func (en *en_AU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_AU) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_AU) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_AU) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_AU) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_AU) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_AU) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_AU) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_AU) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_AU) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_AU) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_AU) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_AU) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_AU) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_AU) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_AU' and handles both Whole and Real numbers based on 'v' +func (en *en_AU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_AU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_AU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_AU' +func (en *en_AU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_AU' +// in accounting notation. +func (en *en_AU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_AU' +func (en *en_AU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_AU' +func (en *en_AU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_AU' +func (en *en_AU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_AU' +func (en *en_AU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_AU' +func (en *en_AU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_AU' +func (en *en_AU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_AU' +func (en *en_AU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_AU' +func (en *en_AU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_AU/en_AU_test.go b/vendor/github.com/go-playground/locales/en_AU/en_AU_test.go new file mode 100644 index 0000000000..8b384f37e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_AU/en_AU_test.go @@ -0,0 +1,1120 @@ +package en_AU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_AU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_BB/en_BB.go b/vendor/github.com/go-playground/locales/en_BB/en_BB.go new file mode 100644 index 0000000000..71c864e4ff --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BB/en_BB.go @@ -0,0 +1,645 @@ +package en_BB + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_BB struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_BB' locale +func New() locales.Translator { + return &en_BB{ + locale: "en_BB", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "$", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ACDT": "Australian Central Daylight Time", "WARST": "Western Argentina Summer Time", "AWST": "Australian Western Standard Time", "SGT": "Singapore Standard Time", "ACWST": "Australian Central Western Standard Time", "WAST": "West Africa Summer Time", "AKST": "Alaska Standard Time", "HNCU": "Cuba Standard Time", "AST": "Atlantic Standard Time", "ART": "Argentina Standard Time", "EST": "Eastern Standard Time", "WITA": "Central Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "JDT": "Japan Daylight Time", "GMT": "Greenwich Mean Time", "AKDT": "Alaska Daylight Time", "AEST": "Australian Eastern Standard Time", "GFT": "French Guiana Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HECU": "Cuba Daylight Time", "ECT": "Ecuador Time", "MEZ": "Central European Standard Time", "OEZ": "Eastern European Standard Time", "EDT": "Eastern Daylight Time", "COT": "Colombia Standard Time", "∅∅∅": "Azores Summer Time", "TMST": "Turkmenistan Summer Time", "OESZ": "Eastern European Summer Time", "SRT": "Suriname Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "CHAST": "Chatham Standard Time", "IST": "India Standard Time", "NZDT": "New Zealand Daylight Time", "MESZ": "Central European Summer Time", "HNPMX": "Mexican Pacific Standard Time", "HNEG": "East Greenland Standard Time", "HEEG": "East Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "WEZ": "Western European Standard Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "ADT": "Atlantic Daylight Time", "HKST": "Hong Kong Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "LHDT": "Lord Howe Daylight Time", "EAT": "East Africa Time", "AWDT": "Australian Western Daylight Time", "BOT": "Bolivia Time", "ACWDT": "Australian Central Western Daylight Time", "JST": "Japan Standard Time", "WAT": "West Africa Standard Time", "LHST": "Lord Howe Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "GYT": "Guyana Time", "HEOG": "West Greenland Summer Time", "COST": "Colombia Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "UYST": "Uruguay Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SAST": "South Africa Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "NZST": "New Zealand Standard Time", "CLST": "Chile Summer Time", "BT": "Bhutan Time", "UYT": "Uruguay Standard Time", "PDT": "Pacific Daylight Time", "WESZ": "Western European Summer Time", "CLT": "Chile Standard Time", "TMT": "Turkmenistan Standard Time", "MST": "Macau Standard Time", "CST": "Central Standard Time", "VET": "Venezuela Time", "WART": "Western Argentina Standard Time", "MDT": "Macau Summer Time", "ACST": "Australian Central Standard Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "CAT": "Central Africa Time", "HKT": "Hong Kong Standard Time", "ChST": "Chamorro Standard Time", "ARST": "Argentina Summer Time", "HNOG": "West Greenland Standard Time", "MYT": "Malaysia Time", "CDT": "Central Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_BB) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_BB' +func (en *en_BB) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_BB' +func (en *en_BB) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_BB' +func (en *en_BB) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_BB' +func (en *en_BB) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_BB' +func (en *en_BB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_BB' +func (en *en_BB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_BB) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_BB) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_BB) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_BB) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_BB) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_BB) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_BB) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_BB) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_BB) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_BB) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_BB) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_BB) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_BB) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_BB) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_BB' and handles both Whole and Real numbers based on 'v' +func (en *en_BB) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_BB' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_BB) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_BB' +func (en *en_BB) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_BB' +// in accounting notation. +func (en *en_BB) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_BB' +func (en *en_BB) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_BB' +func (en *en_BB) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_BB' +func (en *en_BB) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_BB' +func (en *en_BB) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_BB' +func (en *en_BB) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_BB' +func (en *en_BB) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_BB' +func (en *en_BB) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_BB' +func (en *en_BB) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_BB/en_BB_test.go b/vendor/github.com/go-playground/locales/en_BB/en_BB_test.go new file mode 100644 index 0000000000..98f325b603 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BB/en_BB_test.go @@ -0,0 +1,1120 @@ +package en_BB + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_BB" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_BE/en_BE.go b/vendor/github.com/go-playground/locales/en_BE/en_BE.go new file mode 100644 index 0000000000..7f65c07b6c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BE/en_BE.go @@ -0,0 +1,606 @@ +package en_BE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_BE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_BE' locale +func New() locales.Translator { + return &en_BE{ + locale: "en_BE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ART": "Argentina Standard Time", "BT": "Bhutan Time", "SRT": "Suriname Time", "EAT": "East Africa Time", "OESZ": "Eastern European Summer Time", "WART": "Western Argentina Standard Time", "WARST": "Western Argentina Summer Time", "AKST": "Alaska Standard Time", "HNPMX": "Mexican Pacific Standard Time", "AWDT": "Australian Western Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "AST": "Atlantic Standard Time", "COT": "Colombia Standard Time", "WIB": "Western Indonesia Time", "MEZ": "Central European Standard Time", "VET": "Venezuela Time", "HECU": "Cuba Daylight Time", "MESZ": "Central European Summer Time", "EST": "Eastern Standard Time", "EDT": "Eastern Daylight Time", "GFT": "French Guiana Time", "WITA": "Central Indonesia Time", "BOT": "Bolivia Time", "HAST": "Hawaii-Aleutian Standard Time", "IST": "India Standard Time", "NZST": "New Zealand Standard Time", "CAT": "Central Africa Time", "MDT": "Macau Summer Time", "ARST": "Argentina Summer Time", "NZDT": "New Zealand Daylight Time", "HAT": "Newfoundland Daylight Time", "AKDT": "Alaska Daylight Time", "CST": "Central Standard Time", "CDT": "Central Daylight Time", "SGT": "Singapore Standard Time", "ACWST": "Australian Central Western Standard Time", "CHAST": "Chatham Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "WAST": "West Africa Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "HNEG": "East Greenland Standard Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "ADT": "Atlantic Daylight Time", "GMT": "Greenwich Mean Time", "AWST": "Australian Western Standard Time", "TMST": "Turkmenistan Summer Time", "WAT": "West Africa Standard Time", "GYT": "Guyana Time", "ECT": "Ecuador Time", "JST": "Japan Standard Time", "WESZ": "Western European Summer Time", "PDT": "Pacific Daylight Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "HNT": "Newfoundland Standard Time", "UYT": "Uruguay Standard Time", "LHST": "Lord Howe Standard Time", "CLST": "Chile Summer Time", "HKST": "Hong Kong Summer Time", "ACDT": "Australian Central Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "ChST": "Chamorro Standard Time", "OEZ": "Eastern European Standard Time", "TMT": "Turkmenistan Standard Time", "HKT": "Hong Kong Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "UYST": "Uruguay Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHDT": "Lord Howe Daylight Time", "HNCU": "Cuba Standard Time", "COST": "Colombia Summer Time", "HEEG": "East Greenland Summer Time", "AEST": "Australian Eastern Standard Time", "WEZ": "Western European Standard Time", "MYT": "Malaysia Time", "MST": "Macau Standard Time", "ACST": "Australian Central Standard Time", "WIT": "Eastern Indonesia Time", "∅∅∅": "Brasilia Summer Time", "JDT": "Japan Daylight Time", "CLT": "Chile Standard Time", "AEDT": "Australian Eastern Daylight Time", "SAST": "South Africa Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_BE) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_BE' +func (en *en_BE) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_BE' +func (en *en_BE) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_BE' +func (en *en_BE) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_BE' +func (en *en_BE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_BE' +func (en *en_BE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_BE' +func (en *en_BE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_BE) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_BE) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_BE) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_BE) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_BE) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_BE) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_BE) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_BE) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_BE) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_BE) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_BE) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_BE) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_BE) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_BE) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_BE' and handles both Whole and Real numbers based on 'v' +func (en *en_BE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_BE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_BE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_BE' +func (en *en_BE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, en.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_BE' +// in accounting notation. +func (en *en_BE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, en.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, en.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_BE' +func (en *en_BE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_BE' +func (en *en_BE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_BE' +func (en *en_BE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_BE' +func (en *en_BE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_BE' +func (en *en_BE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_BE' +func (en *en_BE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_BE' +func (en *en_BE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_BE' +func (en *en_BE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_BE/en_BE_test.go b/vendor/github.com/go-playground/locales/en_BE/en_BE_test.go new file mode 100644 index 0000000000..1ac062776f --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BE/en_BE_test.go @@ -0,0 +1,1120 @@ +package en_BE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_BE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_BI/en_BI.go b/vendor/github.com/go-playground/locales/en_BI/en_BI.go new file mode 100644 index 0000000000..3a4f728829 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BI/en_BI.go @@ -0,0 +1,635 @@ +package en_BI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_BI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_BI' locale +func New() locales.Translator { + return &en_BI{ + locale: "en_BI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "FBu", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"CAT": "Central Africa Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "ChST": "Chamorro Standard Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "JDT": "Japan Daylight Time", "MDT": "Macau Summer Time", "ART": "Argentina Standard Time", "WAST": "West Africa Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "SRT": "Suriname Time", "PDT": "Pacific Daylight Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "MYT": "Malaysia Time", "WART": "Western Argentina Standard Time", "TMT": "Turkmenistan Standard Time", "AEDT": "Australian Eastern Daylight Time", "BOT": "Bolivia Time", "EST": "Eastern Standard Time", "HKT": "Hong Kong Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "ACWST": "Australian Central Western Standard Time", "AST": "Atlantic Standard Time", "OEZ": "Eastern European Standard Time", "ACST": "Australian Central Standard Time", "HAT": "Newfoundland Daylight Time", "WIB": "Western Indonesia Time", "ACWDT": "Australian Central Western Daylight Time", "ADT": "Atlantic Daylight Time", "CLT": "Chile Standard Time", "ARST": "Argentina Summer Time", "AKDT": "Alaska Daylight Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "MST": "Macau Standard Time", "BT": "Bhutan Time", "HEEG": "East Greenland Summer Time", "GYT": "Guyana Time", "ACDT": "Australian Central Daylight Time", "UYST": "Uruguay Summer Time", "PST": "Pacific Standard Time", "CLST": "Chile Summer Time", "WAT": "West Africa Standard Time", "HNEG": "East Greenland Standard Time", "WITA": "Central Indonesia Time", "GFT": "French Guiana Time", "CDT": "Central Daylight Time", "ECT": "Ecuador Time", "JST": "Japan Standard Time", "WEZ": "Western European Standard Time", "GMT": "Greenwich Mean Time", "IST": "India Standard Time", "COST": "Colombia Summer Time", "WIT": "Eastern Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "∅∅∅": "Amazon Summer Time", "HNOG": "West Greenland Standard Time", "AEST": "Australian Eastern Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHST": "Lord Howe Standard Time", "NZST": "New Zealand Standard Time", "HEOG": "West Greenland Summer Time", "OESZ": "Eastern European Summer Time", "WARST": "Western Argentina Summer Time", "EDT": "Eastern Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "EAT": "East Africa Time", "AWDT": "Australian Western Daylight Time", "CHAST": "Chatham Standard Time", "TMST": "Turkmenistan Summer Time", "SAST": "South Africa Standard Time", "AWST": "Australian Western Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "MEZ": "Central European Standard Time", "VET": "Venezuela Time", "HNT": "Newfoundland Standard Time", "AKST": "Alaska Standard Time", "MESZ": "Central European Summer Time", "HKST": "Hong Kong Summer Time", "HNCU": "Cuba Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_BI) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_BI' +func (en *en_BI) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_BI' +func (en *en_BI) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_BI' +func (en *en_BI) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_BI' +func (en *en_BI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_BI' +func (en *en_BI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_BI' +func (en *en_BI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_BI) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_BI) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_BI) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_BI) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_BI) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_BI) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_BI) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_BI) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_BI) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_BI) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_BI) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_BI) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_BI) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_BI) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_BI' and handles both Whole and Real numbers based on 'v' +func (en *en_BI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_BI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_BI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_BI' +func (en *en_BI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_BI' +// in accounting notation. +func (en *en_BI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_BI' +func (en *en_BI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_BI' +func (en *en_BI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_BI' +func (en *en_BI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_BI' +func (en *en_BI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_BI' +func (en *en_BI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_BI' +func (en *en_BI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_BI' +func (en *en_BI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_BI' +func (en *en_BI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_BI/en_BI_test.go b/vendor/github.com/go-playground/locales/en_BI/en_BI_test.go new file mode 100644 index 0000000000..0598ee69eb --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BI/en_BI_test.go @@ -0,0 +1,1120 @@ +package en_BI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_BI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_BM/en_BM.go b/vendor/github.com/go-playground/locales/en_BM/en_BM.go new file mode 100644 index 0000000000..5d4e0466e7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BM/en_BM.go @@ -0,0 +1,645 @@ +package en_BM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_BM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_BM' locale +func New() locales.Translator { + return &en_BM{ + locale: "en_BM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "$", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HNEG": "East Greenland Standard Time", "SAST": "South Africa Standard Time", "BOT": "Bolivia Time", "HAST": "Hawaii-Aleutian Standard Time", "WESZ": "Western European Summer Time", "CLT": "Chile Standard Time", "ACST": "Australian Central Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "LHDT": "Lord Howe Daylight Time", "ACDT": "Australian Central Daylight Time", "AKST": "Alaska Standard Time", "CDT": "Central Daylight Time", "WIT": "Eastern Indonesia Time", "AWST": "Australian Western Standard Time", "PST": "Pacific Standard Time", "JDT": "Japan Daylight Time", "CLST": "Chile Summer Time", "LHST": "Lord Howe Standard Time", "HNCU": "Cuba Standard Time", "WAST": "West Africa Summer Time", "EST": "Eastern Standard Time", "ChST": "Chamorro Standard Time", "HNPMX": "Mexican Pacific Standard Time", "WITA": "Central Indonesia Time", "UYT": "Uruguay Standard Time", "ACWDT": "Australian Central Western Daylight Time", "MEZ": "Central European Standard Time", "WART": "Western Argentina Standard Time", "HKT": "Hong Kong Standard Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "UYST": "Uruguay Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "OEZ": "Eastern European Standard Time", "OESZ": "Eastern European Summer Time", "TMT": "Turkmenistan Standard Time", "∅∅∅": "Brasilia Summer Time", "AWDT": "Australian Western Daylight Time", "ART": "Argentina Standard Time", "COST": "Colombia Summer Time", "HAT": "Newfoundland Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "GYT": "Guyana Time", "WIB": "Western Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "MESZ": "Central European Summer Time", "EDT": "Eastern Daylight Time", "SRT": "Suriname Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "GMT": "Greenwich Mean Time", "AEST": "Australian Eastern Standard Time", "CST": "Central Standard Time", "PDT": "Pacific Daylight Time", "VET": "Venezuela Time", "JST": "Japan Standard Time", "ADT": "Atlantic Daylight Time", "ARST": "Argentina Summer Time", "HEOG": "West Greenland Summer Time", "BT": "Bhutan Time", "AST": "Atlantic Standard Time", "ECT": "Ecuador Time", "ACWST": "Australian Central Western Standard Time", "MST": "Macau Standard Time", "HNT": "Newfoundland Standard Time", "HEEG": "East Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "HNOG": "West Greenland Standard Time", "WARST": "Western Argentina Summer Time", "EAT": "East Africa Time", "CHAST": "Chatham Standard Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "CAT": "Central Africa Time", "IST": "India Standard Time", "MDT": "Macau Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "GFT": "French Guiana Time", "WEZ": "Western European Standard Time", "MYT": "Malaysia Time", "TMST": "Turkmenistan Summer Time", "WAT": "West Africa Standard Time", "HKST": "Hong Kong Summer Time", "AKDT": "Alaska Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_BM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_BM' +func (en *en_BM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_BM' +func (en *en_BM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_BM' +func (en *en_BM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_BM' +func (en *en_BM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_BM' +func (en *en_BM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_BM' +func (en *en_BM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_BM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_BM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_BM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_BM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_BM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_BM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_BM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_BM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_BM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_BM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_BM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_BM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_BM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_BM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_BM' and handles both Whole and Real numbers based on 'v' +func (en *en_BM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_BM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_BM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_BM' +func (en *en_BM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_BM' +// in accounting notation. +func (en *en_BM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_BM' +func (en *en_BM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_BM' +func (en *en_BM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_BM' +func (en *en_BM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_BM' +func (en *en_BM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_BM' +func (en *en_BM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_BM' +func (en *en_BM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_BM' +func (en *en_BM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_BM' +func (en *en_BM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_BM/en_BM_test.go b/vendor/github.com/go-playground/locales/en_BM/en_BM_test.go new file mode 100644 index 0000000000..780cd0bc20 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BM/en_BM_test.go @@ -0,0 +1,1120 @@ +package en_BM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_BM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_BS/en_BS.go b/vendor/github.com/go-playground/locales/en_BS/en_BS.go new file mode 100644 index 0000000000..82eb0c2ba8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BS/en_BS.go @@ -0,0 +1,645 @@ +package en_BS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_BS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_BS' locale +func New() locales.Translator { + return &en_BS{ + locale: "en_BS", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "$", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HKT": "Hong Kong Standard Time", "HNEG": "East Greenland Standard Time", "HEEG": "East Greenland Summer Time", "AKST": "Alaska Standard Time", "ECT": "Ecuador Time", "VET": "Venezuela Time", "MYT": "Malaysia Time", "CLT": "Chile Standard Time", "COT": "Colombia Standard Time", "HECU": "Cuba Daylight Time", "WIB": "Western Indonesia Time", "PST": "Pacific Standard Time", "BT": "Bhutan Time", "LHST": "Lord Howe Standard Time", "SRT": "Suriname Time", "AWDT": "Australian Western Daylight Time", "MESZ": "Central European Summer Time", "EST": "Eastern Standard Time", "HKST": "Hong Kong Summer Time", "HAT": "Newfoundland Daylight Time", "WITA": "Central Indonesia Time", "CHAST": "Chatham Standard Time", "ADT": "Atlantic Daylight Time", "TMT": "Turkmenistan Standard Time", "EAT": "East Africa Time", "WARST": "Western Argentina Summer Time", "TMST": "Turkmenistan Summer Time", "MST": "Macau Standard Time", "WAST": "West Africa Summer Time", "GYT": "Guyana Time", "CHADT": "Chatham Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "SAST": "South Africa Standard Time", "HNPMX": "Mexican Pacific Standard Time", "CST": "Central Standard Time", "PDT": "Pacific Daylight Time", "CLST": "Chile Summer Time", "ACST": "Australian Central Standard Time", "GFT": "French Guiana Time", "AKDT": "Alaska Daylight Time", "SGT": "Singapore Standard Time", "WEZ": "Western European Standard Time", "WAT": "West Africa Standard Time", "ACWST": "Australian Central Western Standard Time", "HEOG": "West Greenland Summer Time", "AST": "Atlantic Standard Time", "ChST": "Chamorro Standard Time", "MEZ": "Central European Standard Time", "JST": "Japan Standard Time", "JDT": "Japan Daylight Time", "HNOG": "West Greenland Standard Time", "COST": "Colombia Summer Time", "UYT": "Uruguay Standard Time", "MDT": "Macau Summer Time", "ARST": "Argentina Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHDT": "Lord Howe Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "AWST": "Australian Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "EDT": "Eastern Daylight Time", "AEST": "Australian Eastern Standard Time", "HNT": "Newfoundland Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CDT": "Central Daylight Time", "BOT": "Bolivia Time", "CAT": "Central Africa Time", "WART": "Western Argentina Standard Time", "OESZ": "Eastern European Summer Time", "ART": "Argentina Standard Time", "WIT": "Eastern Indonesia Time", "∅∅∅": "Brasilia Summer Time", "IST": "India Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "UYST": "Uruguay Summer Time", "AEDT": "Australian Eastern Daylight Time", "HNCU": "Cuba Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "NZST": "New Zealand Standard Time", "OEZ": "Eastern European Standard Time", "GMT": "Greenwich Mean Time", "ACDT": "Australian Central Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_BS) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_BS' +func (en *en_BS) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_BS' +func (en *en_BS) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_BS' +func (en *en_BS) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_BS' +func (en *en_BS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_BS' +func (en *en_BS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_BS' +func (en *en_BS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_BS) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_BS) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_BS) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_BS) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_BS) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_BS) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_BS) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_BS) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_BS) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_BS) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_BS) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_BS) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_BS) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_BS) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_BS' and handles both Whole and Real numbers based on 'v' +func (en *en_BS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_BS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_BS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_BS' +func (en *en_BS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_BS' +// in accounting notation. +func (en *en_BS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_BS' +func (en *en_BS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_BS' +func (en *en_BS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_BS' +func (en *en_BS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_BS' +func (en *en_BS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_BS' +func (en *en_BS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_BS' +func (en *en_BS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_BS' +func (en *en_BS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_BS' +func (en *en_BS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_BS/en_BS_test.go b/vendor/github.com/go-playground/locales/en_BS/en_BS_test.go new file mode 100644 index 0000000000..08053d11a3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BS/en_BS_test.go @@ -0,0 +1,1120 @@ +package en_BS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_BS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_BW/en_BW.go b/vendor/github.com/go-playground/locales/en_BW/en_BW.go new file mode 100644 index 0000000000..bc12b4fa5b --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BW/en_BW.go @@ -0,0 +1,620 @@ +package en_BW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_BW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_BW' locale +func New() locales.Translator { + return &en_BW{ + locale: "en_BW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "P", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"VET": "Venezuela Time", "CLST": "Chile Summer Time", "OESZ": "Eastern European Summer Time", "ACDT": "Australian Central Daylight Time", "COT": "Colombia Standard Time", "AKDT": "Alaska Daylight Time", "SAST": "South Africa Standard Time", "BOT": "Bolivia Time", "ACWST": "Australian Central Western Standard Time", "JDT": "Japan Daylight Time", "AST": "Atlantic Standard Time", "WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "AWST": "Australian Western Standard Time", "CHADT": "Chatham Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "ARST": "Argentina Summer Time", "WAST": "West Africa Summer Time", "HKT": "Hong Kong Standard Time", "ECT": "Ecuador Time", "ADT": "Atlantic Daylight Time", "ACST": "Australian Central Standard Time", "HNT": "Newfoundland Standard Time", "HNEG": "East Greenland Standard Time", "EAT": "East Africa Time", "HECU": "Cuba Daylight Time", "WART": "Western Argentina Standard Time", "WIT": "Eastern Indonesia Time", "NZST": "New Zealand Standard Time", "JST": "Japan Standard Time", "HNOG": "West Greenland Standard Time", "HKST": "Hong Kong Summer Time", "WITA": "Central Indonesia Time", "MST": "Mountain Standard Time", "CDT": "Central Daylight Time", "TMST": "Turkmenistan Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "WIB": "Western Indonesia Time", "AWDT": "Australian Western Daylight Time", "CHAST": "Chatham Standard Time", "CLT": "Chile Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "ChST": "Chamorro Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "MESZ": "Central European Summer Time", "HEEG": "East Greenland Summer Time", "LHST": "Lord Howe Standard Time", "HNPMX": "Mexican Pacific Standard Time", "MDT": "Mountain Daylight Time", "SRT": "Suriname Time", "EST": "Eastern Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "PST": "Pacific Standard Time", "NZDT": "New Zealand Daylight Time", "MYT": "Malaysia Time", "AKST": "Alaska Standard Time", "UYST": "Uruguay Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "AEST": "Australian Eastern Standard Time", "LHDT": "Lord Howe Daylight Time", "WARST": "Western Argentina Summer Time", "ACWDT": "Australian Central Western Daylight Time", "WEZ": "Western European Standard Time", "BT": "Bhutan Time", "UYT": "Uruguay Standard Time", "IST": "India Standard Time", "SGT": "Singapore Standard Time", "WAT": "West Africa Standard Time", "EDT": "Eastern Daylight Time", "COST": "Colombia Summer Time", "GYT": "Guyana Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "GFT": "French Guiana Time", "PDT": "Pacific Daylight Time", "HEOG": "West Greenland Summer Time", "MEZ": "Central European Standard Time", "OEZ": "Eastern European Standard Time", "∅∅∅": "Peru Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "CAT": "Central Africa Time", "ART": "Argentina Standard Time", "HAT": "Newfoundland Daylight Time", "AEDT": "Australian Eastern Daylight Time", "TMT": "Turkmenistan Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_BW) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_BW' +func (en *en_BW) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_BW' +func (en *en_BW) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_BW' +func (en *en_BW) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_BW' +func (en *en_BW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_BW' +func (en *en_BW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_BW' +func (en *en_BW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_BW) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_BW) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_BW) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_BW) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_BW) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_BW) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_BW) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_BW) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_BW) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_BW) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_BW) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_BW) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_BW) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_BW) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_BW' and handles both Whole and Real numbers based on 'v' +func (en *en_BW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_BW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_BW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_BW' +func (en *en_BW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_BW' +// in accounting notation. +func (en *en_BW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_BW' +func (en *en_BW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_BW' +func (en *en_BW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_BW' +func (en *en_BW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_BW' +func (en *en_BW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_BW' +func (en *en_BW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_BW' +func (en *en_BW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_BW' +func (en *en_BW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_BW' +func (en *en_BW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_BW/en_BW_test.go b/vendor/github.com/go-playground/locales/en_BW/en_BW_test.go new file mode 100644 index 0000000000..8aaeb04b15 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BW/en_BW_test.go @@ -0,0 +1,1120 @@ +package en_BW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_BW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_BZ/en_BZ.go b/vendor/github.com/go-playground/locales/en_BZ/en_BZ.go new file mode 100644 index 0000000000..a5d5c2d1cb --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BZ/en_BZ.go @@ -0,0 +1,620 @@ +package en_BZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_BZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_BZ' locale +func New() locales.Translator { + return &en_BZ{ + locale: "en_BZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "$", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AWST": "Australian Western Standard Time", "ART": "Argentina Standard Time", "ARST": "Argentina Summer Time", "HKST": "Hong Kong Summer Time", "ACST": "Australian Central Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "ACDT": "Australian Central Daylight Time", "ACWST": "Australian Central Western Standard Time", "NZDT": "New Zealand Daylight Time", "JST": "Japan Standard Time", "HKT": "Hong Kong Standard Time", "UYT": "Uruguay Standard Time", "SAST": "South Africa Standard Time", "BOT": "Bolivia Time", "HAST": "Hawaii-Aleutian Standard Time", "∅∅∅": "Amazon Summer Time", "HAT": "Newfoundland Daylight Time", "AKST": "Alaska Standard Time", "AKDT": "Alaska Daylight Time", "MDT": "Macau Summer Time", "AEDT": "Australian Eastern Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "CLST": "Chile Summer Time", "HEOG": "West Greenland Summer Time", "AST": "Atlantic Standard Time", "HNT": "Newfoundland Standard Time", "CDT": "Central Daylight Time", "ECT": "Ecuador Time", "OESZ": "Eastern European Summer Time", "WEZ": "Western European Standard Time", "TMT": "Turkmenistan Standard Time", "MST": "Macau Standard Time", "VET": "Venezuela Time", "HNPMX": "Mexican Pacific Standard Time", "WIB": "Western Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNCU": "Cuba Standard Time", "HNEG": "East Greenland Standard Time", "MEZ": "Central European Standard Time", "OEZ": "Eastern European Standard Time", "EST": "Eastern Standard Time", "WAST": "West Africa Summer Time", "CHADT": "Chatham Daylight Time", "WITA": "Central Indonesia Time", "GYT": "Guyana Time", "EAT": "East Africa Time", "AWDT": "Australian Western Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "SRT": "Suriname Time", "WIT": "Eastern Indonesia Time", "NZST": "New Zealand Standard Time", "JDT": "Japan Daylight Time", "MESZ": "Central European Summer Time", "AEST": "Australian Eastern Standard Time", "SGT": "Singapore Standard Time", "CHAST": "Chatham Standard Time", "MYT": "Malaysia Time", "ADT": "Atlantic Daylight Time", "COST": "Colombia Summer Time", "LHST": "Lord Howe Standard Time", "CAT": "Central Africa Time", "GFT": "French Guiana Time", "LHDT": "Lord Howe Daylight Time", "PST": "Pacific Standard Time", "WARST": "Western Argentina Summer Time", "CLT": "Chile Standard Time", "TMST": "Turkmenistan Summer Time", "PDT": "Pacific Daylight Time", "HEEG": "East Greenland Summer Time", "BT": "Bhutan Time", "ChST": "Chamorro Standard Time", "IST": "India Standard Time", "WART": "Western Argentina Standard Time", "EDT": "Eastern Daylight Time", "WAT": "West Africa Standard Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "HNOG": "West Greenland Standard Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "UYST": "Uruguay Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_BZ) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_BZ' +func (en *en_BZ) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_BZ' +func (en *en_BZ) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_BZ' +func (en *en_BZ) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_BZ' +func (en *en_BZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_BZ' +func (en *en_BZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_BZ' +func (en *en_BZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_BZ) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_BZ) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_BZ) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_BZ) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_BZ) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_BZ) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_BZ) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_BZ) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_BZ) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_BZ) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_BZ) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_BZ) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_BZ) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_BZ) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_BZ' and handles both Whole and Real numbers based on 'v' +func (en *en_BZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_BZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_BZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_BZ' +func (en *en_BZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_BZ' +// in accounting notation. +func (en *en_BZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_BZ' +func (en *en_BZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_BZ' +func (en *en_BZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_BZ' +func (en *en_BZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_BZ' +func (en *en_BZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_BZ' +func (en *en_BZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_BZ' +func (en *en_BZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_BZ' +func (en *en_BZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_BZ' +func (en *en_BZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_BZ/en_BZ_test.go b/vendor/github.com/go-playground/locales/en_BZ/en_BZ_test.go new file mode 100644 index 0000000000..45c73c6b67 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_BZ/en_BZ_test.go @@ -0,0 +1,1120 @@ +package en_BZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_BZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_CA/en_CA.go b/vendor/github.com/go-playground/locales/en_CA/en_CA.go new file mode 100644 index 0000000000..b5357c68bc --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CA/en_CA.go @@ -0,0 +1,646 @@ +package en_CA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_CA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_CA' locale +func New() locales.Translator { + return &en_CA{ + locale: "en_CA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"∅∅∅": "Amazon Summer Time", "HKT": "Hong Kong Standard Time", "AEST": "Australian Eastern Standard Time", "ChST": "Chamorro Standard Time", "SAST": "South Africa Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "AWST": "Australian Western Standard Time", "MYT": "Malaysia Time", "EST": "Eastern Standard Time", "HKST": "Hong Kong Summer Time", "AWDT": "Australian Western Daylight Time", "ACDT": "Australian Central Daylight Time", "AEDT": "Australian Eastern Daylight Time", "HNCU": "Cuba Standard Time", "WIT": "Eastern Indonesia Time", "ACWST": "Australian Central Western Standard Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "EAT": "East Africa Time", "HECU": "Cuba Daylight Time", "WIB": "Western Indonesia Time", "CHAST": "Chatham Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "WITA": "Central Indonesia Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "GYT": "Guyana Time", "WAST": "West Africa Summer Time", "PDT": "Pacific Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "JDT": "Japan Daylight Time", "HNOG": "West Greenland Standard Time", "OESZ": "Eastern European Summer Time", "MST": "Macau Standard Time", "ART": "Argentina Standard Time", "COT": "Colombia Standard Time", "GFT": "French Guiana Time", "UYT": "Uruguay Standard Time", "UYST": "Uruguay Summer Time", "SRT": "Suriname Time", "CST": "Central Standard Time", "ACWDT": "Australian Central Western Daylight Time", "MEZ": "Central European Standard Time", "JST": "Japan Standard Time", "BT": "Bhutan Time", "LHST": "Lord Howe Standard Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNPMX": "Mexican Pacific Standard Time", "BOT": "Bolivia Time", "IST": "India Standard Time", "CLT": "Chile Standard Time", "AST": "Atlantic Standard Time", "GMT": "Greenwich Mean Time", "AKST": "Alaska Standard Time", "AKDT": "Alaska Daylight Time", "MDT": "Macau Summer Time", "WAT": "West Africa Standard Time", "HAT": "Newfoundland Daylight Time", "HEEG": "East Greenland Summer Time", "LHDT": "Lord Howe Daylight Time", "WART": "Western Argentina Standard Time", "ADT": "Atlantic Daylight Time", "WEZ": "Western European Standard Time", "WESZ": "Western European Summer Time", "ACST": "Australian Central Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "CDT": "Central Daylight Time", "EDT": "Eastern Daylight Time", "SGT": "Singapore Standard Time", "ECT": "Ecuador Time", "WARST": "Western Argentina Summer Time", "OEZ": "Eastern European Standard Time", "COST": "Colombia Summer Time", "VET": "Venezuela Time", "TMST": "Turkmenistan Summer Time", "CAT": "Central Africa Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "MESZ": "Central European Summer Time", "CLST": "Chile Summer Time", "TMT": "Turkmenistan Standard Time", "HNT": "Newfoundland Standard Time", "HNEG": "East Greenland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_CA) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_CA' +func (en *en_CA) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_CA' +func (en *en_CA) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_CA' +func (en *en_CA) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_CA' +func (en *en_CA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_CA' +func (en *en_CA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_CA' +func (en *en_CA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_CA) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_CA) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_CA) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_CA) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_CA) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_CA) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_CA) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_CA) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_CA) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_CA) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_CA) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_CA) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_CA) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_CA) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_CA' and handles both Whole and Real numbers based on 'v' +func (en *en_CA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_CA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_CA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_CA' +func (en *en_CA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_CA' +// in accounting notation. +func (en *en_CA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_CA' +func (en *en_CA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_CA' +func (en *en_CA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_CA' +func (en *en_CA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_CA' +func (en *en_CA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_CA' +func (en *en_CA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_CA' +func (en *en_CA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_CA' +func (en *en_CA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_CA' +func (en *en_CA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_CA/en_CA_test.go b/vendor/github.com/go-playground/locales/en_CA/en_CA_test.go new file mode 100644 index 0000000000..e09ef02c08 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CA/en_CA_test.go @@ -0,0 +1,1120 @@ +package en_CA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_CA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_CC/en_CC.go b/vendor/github.com/go-playground/locales/en_CC/en_CC.go new file mode 100644 index 0000000000..0bb402cd38 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CC/en_CC.go @@ -0,0 +1,607 @@ +package en_CC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_CC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_CC' locale +func New() locales.Translator { + return &en_CC{ + locale: "en_CC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"CST": "Central Standard Time", "ARST": "Argentina Summer Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "HNT": "Newfoundland Standard Time", "GYT": "Guyana Time", "ACWST": "Australian Central Western Standard Time", "MESZ": "Central European Summer Time", "WEZ": "Western European Standard Time", "WAST": "West Africa Summer Time", "WAT": "West Africa Standard Time", "HKT": "Hong Kong Standard Time", "HEEG": "East Greenland Summer Time", "WITA": "Central Indonesia Time", "SGT": "Singapore Standard Time", "IST": "India Standard Time", "NZDT": "New Zealand Daylight Time", "CLT": "Chile Standard Time", "SRT": "Suriname Time", "UYST": "Uruguay Summer Time", "WIT": "Eastern Indonesia Time", "∅∅∅": "Brasilia Summer Time", "OEZ": "Eastern European Standard Time", "TMST": "Turkmenistan Summer Time", "ACST": "Australian Central Standard Time", "GFT": "French Guiana Time", "CHADT": "Chatham Daylight Time", "VET": "Venezuela Time", "HNEG": "East Greenland Standard Time", "COST": "Colombia Summer Time", "WIB": "Western Indonesia Time", "BOT": "Bolivia Time", "MEZ": "Central European Standard Time", "JST": "Japan Standard Time", "PST": "Pacific Standard Time", "PDT": "Pacific Daylight Time", "WART": "Western Argentina Standard Time", "AKST": "Alaska Standard Time", "MST": "Macau Standard Time", "MDT": "Macau Summer Time", "EST": "Eastern Standard Time", "EDT": "Eastern Daylight Time", "HECU": "Cuba Daylight Time", "CDT": "Central Daylight Time", "ECT": "Ecuador Time", "HAST": "Hawaii-Aleutian Standard Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "HAT": "Newfoundland Daylight Time", "AKDT": "Alaska Daylight Time", "SAST": "South Africa Standard Time", "ACWDT": "Australian Central Western Daylight Time", "NZST": "New Zealand Standard Time", "JDT": "Japan Daylight Time", "HEOG": "West Greenland Summer Time", "LHST": "Lord Howe Standard Time", "AWDT": "Australian Western Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "HNCU": "Cuba Standard Time", "AWST": "Australian Western Standard Time", "CLST": "Chile Summer Time", "GMT": "Greenwich Mean Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHDT": "Lord Howe Daylight Time", "OESZ": "Eastern European Summer Time", "WESZ": "Western European Summer Time", "MYT": "Malaysia Time", "AEST": "Australian Eastern Standard Time", "EAT": "East Africa Time", "TMT": "Turkmenistan Standard Time", "AEDT": "Australian Eastern Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "CAT": "Central Africa Time", "UYT": "Uruguay Standard Time", "AST": "Atlantic Standard Time", "ADT": "Atlantic Daylight Time", "ART": "Argentina Standard Time", "COT": "Colombia Standard Time", "CHAST": "Chatham Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "WARST": "Western Argentina Summer Time", "HNOG": "West Greenland Standard Time", "ChST": "Chamorro Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_CC) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_CC' +func (en *en_CC) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_CC' +func (en *en_CC) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_CC' +func (en *en_CC) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_CC' +func (en *en_CC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_CC' +func (en *en_CC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_CC' +func (en *en_CC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_CC) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_CC) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_CC) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_CC) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_CC) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_CC) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_CC) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_CC) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_CC) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_CC) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_CC) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_CC) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_CC) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_CC) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_CC' and handles both Whole and Real numbers based on 'v' +func (en *en_CC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_CC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_CC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_CC' +func (en *en_CC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_CC' +// in accounting notation. +func (en *en_CC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_CC' +func (en *en_CC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_CC' +func (en *en_CC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_CC' +func (en *en_CC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_CC' +func (en *en_CC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_CC' +func (en *en_CC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_CC' +func (en *en_CC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_CC' +func (en *en_CC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_CC' +func (en *en_CC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_CC/en_CC_test.go b/vendor/github.com/go-playground/locales/en_CC/en_CC_test.go new file mode 100644 index 0000000000..edf216cd5a --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CC/en_CC_test.go @@ -0,0 +1,1120 @@ +package en_CC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_CC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_CH/en_CH.go b/vendor/github.com/go-playground/locales/en_CH/en_CH.go new file mode 100644 index 0000000000..6a86d11dac --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CH/en_CH.go @@ -0,0 +1,639 @@ +package en_CH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_CH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_CH' locale +func New() locales.Translator { + return &en_CH{ + locale: "en_CH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: "-", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"SGT": "Singapore Standard Time", "EDT": "Eastern Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "UYT": "Uruguay Standard Time", "GYT": "Guyana Time", "EAT": "East Africa Time", "HECU": "Cuba Daylight Time", "ECT": "Ecuador Time", "CLT": "Chile Standard Time", "HEEG": "East Greenland Summer Time", "GFT": "French Guiana Time", "HEPMX": "Mexican Pacific Daylight Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "AWST": "Australian Western Standard Time", "MYT": "Malaysia Time", "WART": "Western Argentina Standard Time", "BT": "Bhutan Time", "TMST": "Turkmenistan Summer Time", "GMT": "Greenwich Mean Time", "HNT": "Newfoundland Standard Time", "AEDT": "Australian Eastern Daylight Time", "WIB": "Western Indonesia Time", "ACWDT": "Australian Central Western Daylight Time", "VET": "Venezuela Time", "WAST": "West Africa Summer Time", "ACDT": "Australian Central Daylight Time", "LHST": "Lord Howe Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "ACWST": "Australian Central Western Standard Time", "HEOG": "West Greenland Summer Time", "OEZ": "Eastern European Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "COT": "Colombia Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNPMX": "Mexican Pacific Standard Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "ARST": "Argentina Summer Time", "ACST": "Australian Central Standard Time", "ChST": "Chamorro Standard Time", "LHDT": "Lord Howe Daylight Time", "PDT": "Pacific Daylight Time", "JDT": "Japan Daylight Time", "COST": "Colombia Summer Time", "BOT": "Bolivia Time", "TMT": "Turkmenistan Standard Time", "ART": "Argentina Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CDT": "Central Daylight Time", "AEST": "Australian Eastern Standard Time", "CHADT": "Chatham Daylight Time", "MEZ": "Central European Standard Time", "WARST": "Western Argentina Summer Time", "AST": "Atlantic Standard Time", "HNEG": "East Greenland Standard Time", "SAST": "South Africa Standard Time", "CHAST": "Chatham Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "HKT": "Hong Kong Standard Time", "HKST": "Hong Kong Summer Time", "∅∅∅": "Acre Summer Time", "SRT": "Suriname Time", "IST": "India Standard Time", "WEZ": "Western European Standard Time", "AKDT": "Alaska Daylight Time", "WIT": "Eastern Indonesia Time", "CLST": "Chile Summer Time", "HNOG": "West Greenland Standard Time", "WITA": "Central Indonesia Time", "MDT": "Mountain Daylight Time", "AKST": "Alaska Standard Time", "ADT": "Atlantic Daylight Time", "MST": "Mountain Standard Time", "UYST": "Uruguay Summer Time", "AWDT": "Australian Western Daylight Time", "PST": "Pacific Standard Time", "CAT": "Central Africa Time", "NZST": "New Zealand Standard Time", "MESZ": "Central European Summer Time", "JST": "Japan Standard Time", "HAT": "Newfoundland Daylight Time", "EST": "Eastern Standard Time", "WAT": "West Africa Standard Time", "OESZ": "Eastern European Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_CH) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_CH' +func (en *en_CH) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_CH' +func (en *en_CH) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_CH' +func (en *en_CH) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_CH' +func (en *en_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_CH' +func (en *en_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_CH' +func (en *en_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_CH) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_CH) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_CH) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_CH) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_CH) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_CH) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_CH) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_CH) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_CH) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_CH) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_CH) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_CH) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_CH) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_CH) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_CH' and handles both Whole and Real numbers based on 'v' +func (en *en_CH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_CH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_CH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_CH' +func (en *en_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_CH' +// in accounting notation. +func (en *en_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_CH' +func (en *en_CH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_CH' +func (en *en_CH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_CH' +func (en *en_CH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_CH' +func (en *en_CH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_CH' +func (en *en_CH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_CH' +func (en *en_CH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_CH' +func (en *en_CH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_CH' +func (en *en_CH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_CH/en_CH_test.go b/vendor/github.com/go-playground/locales/en_CH/en_CH_test.go new file mode 100644 index 0000000000..2c06a7399e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CH/en_CH_test.go @@ -0,0 +1,1120 @@ +package en_CH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_CH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_CK/en_CK.go b/vendor/github.com/go-playground/locales/en_CK/en_CK.go new file mode 100644 index 0000000000..d9331d2e18 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CK/en_CK.go @@ -0,0 +1,607 @@ +package en_CK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_CK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_CK' locale +func New() locales.Translator { + return &en_CK{ + locale: "en_CK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"MDT": "Macau Summer Time", "ARST": "Argentina Summer Time", "HNT": "Newfoundland Standard Time", "UYST": "Uruguay Summer Time", "HNPMX": "Mexican Pacific Standard Time", "JST": "Japan Standard Time", "WESZ": "Western European Summer Time", "EDT": "Eastern Daylight Time", "AKDT": "Alaska Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "WITA": "Central Indonesia Time", "SRT": "Suriname Time", "MEZ": "Central European Standard Time", "GMT": "Greenwich Mean Time", "TMT": "Turkmenistan Standard Time", "MST": "Macau Standard Time", "WAT": "West Africa Standard Time", "ACDT": "Australian Central Daylight Time", "WIB": "Western Indonesia Time", "AWDT": "Australian Western Daylight Time", "SGT": "Singapore Standard Time", "AKST": "Alaska Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CDT": "Central Daylight Time", "CHAST": "Chatham Standard Time", "ACWST": "Australian Central Western Standard Time", "NZST": "New Zealand Standard Time", "OEZ": "Eastern European Standard Time", "HKST": "Hong Kong Summer Time", "∅∅∅": "Brasilia Summer Time", "WEZ": "Western European Standard Time", "COT": "Colombia Standard Time", "ChST": "Chamorro Standard Time", "LHDT": "Lord Howe Daylight Time", "ECT": "Ecuador Time", "CAT": "Central Africa Time", "HNNOMX": "Northwest Mexico Standard Time", "HAT": "Newfoundland Daylight Time", "EST": "Eastern Standard Time", "LHST": "Lord Howe Standard Time", "CST": "Central Standard Time", "PST": "Pacific Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "MESZ": "Central European Summer Time", "HEOG": "West Greenland Summer Time", "ART": "Argentina Standard Time", "EAT": "East Africa Time", "HADT": "Hawaii-Aleutian Daylight Time", "VET": "Venezuela Time", "CLST": "Chile Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "IST": "India Standard Time", "MYT": "Malaysia Time", "AEST": "Australian Eastern Standard Time", "GFT": "French Guiana Time", "PDT": "Pacific Daylight Time", "OESZ": "Eastern European Summer Time", "WARST": "Western Argentina Summer Time", "CLT": "Chile Standard Time", "TMST": "Turkmenistan Summer Time", "UYT": "Uruguay Standard Time", "ACST": "Australian Central Standard Time", "BT": "Bhutan Time", "HNCU": "Cuba Standard Time", "HECU": "Cuba Daylight Time", "AWST": "Australian Western Standard Time", "JDT": "Japan Daylight Time", "HNOG": "West Greenland Standard Time", "HKT": "Hong Kong Standard Time", "AEDT": "Australian Eastern Daylight Time", "SAST": "South Africa Standard Time", "GYT": "Guyana Time", "ADT": "Atlantic Daylight Time", "COST": "Colombia Summer Time", "CHADT": "Chatham Daylight Time", "BOT": "Bolivia Time", "WAST": "West Africa Summer Time", "WIT": "Eastern Indonesia Time", "ACWDT": "Australian Central Western Daylight Time", "AST": "Atlantic Standard Time", "HNEG": "East Greenland Standard Time", "NZDT": "New Zealand Daylight Time", "WART": "Western Argentina Standard Time", "HEEG": "East Greenland Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_CK) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_CK' +func (en *en_CK) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_CK' +func (en *en_CK) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_CK' +func (en *en_CK) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_CK' +func (en *en_CK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_CK' +func (en *en_CK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_CK' +func (en *en_CK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_CK) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_CK) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_CK) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_CK) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_CK) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_CK) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_CK) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_CK) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_CK) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_CK) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_CK) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_CK) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_CK) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_CK) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_CK' and handles both Whole and Real numbers based on 'v' +func (en *en_CK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_CK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_CK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_CK' +func (en *en_CK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_CK' +// in accounting notation. +func (en *en_CK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_CK' +func (en *en_CK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_CK' +func (en *en_CK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_CK' +func (en *en_CK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_CK' +func (en *en_CK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_CK' +func (en *en_CK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_CK' +func (en *en_CK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_CK' +func (en *en_CK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_CK' +func (en *en_CK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_CK/en_CK_test.go b/vendor/github.com/go-playground/locales/en_CK/en_CK_test.go new file mode 100644 index 0000000000..8e2abab4d0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CK/en_CK_test.go @@ -0,0 +1,1120 @@ +package en_CK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_CK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_CM/en_CM.go b/vendor/github.com/go-playground/locales/en_CM/en_CM.go new file mode 100644 index 0000000000..3e593c4846 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CM/en_CM.go @@ -0,0 +1,607 @@ +package en_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_CM' locale +func New() locales.Translator { + return &en_CM{ + locale: "en_CM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"MESZ": "Central European Summer Time", "AST": "Atlantic Standard Time", "EAT": "East Africa Time", "CDT": "Central Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HECU": "Cuba Daylight Time", "VET": "Venezuela Time", "HNEG": "East Greenland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNCU": "Cuba Standard Time", "IST": "India Standard Time", "MEZ": "Central European Standard Time", "TMT": "Turkmenistan Standard Time", "HAT": "Newfoundland Daylight Time", "AEDT": "Australian Eastern Daylight Time", "LHST": "Lord Howe Standard Time", "WEZ": "Western European Standard Time", "ChST": "Chamorro Standard Time", "CST": "Central Standard Time", "AWST": "Australian Western Standard Time", "WART": "Western Argentina Standard Time", "NZST": "New Zealand Standard Time", "WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "CLST": "Chile Summer Time", "HEOG": "West Greenland Summer Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "PST": "Pacific Standard Time", "∅∅∅": "Acre Summer Time", "WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "CHADT": "Chatham Daylight Time", "PDT": "Pacific Daylight Time", "HKST": "Hong Kong Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "ACST": "Australian Central Standard Time", "ACWST": "Australian Central Western Standard Time", "JST": "Japan Standard Time", "ARST": "Argentina Summer Time", "MST": "Mountain Standard Time", "GFT": "French Guiana Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CLT": "Chile Standard Time", "ART": "Argentina Standard Time", "CHAST": "Chatham Standard Time", "NZDT": "New Zealand Daylight Time", "JDT": "Japan Daylight Time", "WIT": "Eastern Indonesia Time", "SGT": "Singapore Standard Time", "HNOG": "West Greenland Standard Time", "AKDT": "Alaska Daylight Time", "SAST": "South Africa Standard Time", "WIB": "Western Indonesia Time", "ACWDT": "Australian Central Western Daylight Time", "AKST": "Alaska Standard Time", "AWDT": "Australian Western Daylight Time", "COST": "Colombia Summer Time", "HNT": "Newfoundland Standard Time", "MDT": "Mountain Daylight Time", "COT": "Colombia Standard Time", "AEST": "Australian Eastern Standard Time", "EST": "Eastern Standard Time", "HKT": "Hong Kong Standard Time", "WAST": "West Africa Summer Time", "CAT": "Central Africa Time", "OEZ": "Eastern European Standard Time", "MYT": "Malaysia Time", "WARST": "Western Argentina Summer Time", "ADT": "Atlantic Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "ECT": "Ecuador Time", "TMST": "Turkmenistan Summer Time", "EDT": "Eastern Daylight Time", "UYST": "Uruguay Summer Time", "OESZ": "Eastern European Summer Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "SRT": "Suriname Time", "GYT": "Guyana Time", "BOT": "Bolivia Time", "WAT": "West Africa Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HEEG": "East Greenland Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_CM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_CM' +func (en *en_CM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_CM' +func (en *en_CM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_CM' +func (en *en_CM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_CM' +func (en *en_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_CM' +func (en *en_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_CM' +func (en *en_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_CM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_CM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_CM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_CM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_CM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_CM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_CM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_CM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_CM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_CM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_CM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_CM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_CM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_CM' and handles both Whole and Real numbers based on 'v' +func (en *en_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_CM' +func (en *en_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_CM' +// in accounting notation. +func (en *en_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_CM' +func (en *en_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_CM' +func (en *en_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_CM' +func (en *en_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_CM' +func (en *en_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_CM' +func (en *en_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_CM' +func (en *en_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_CM' +func (en *en_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_CM' +func (en *en_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_CM/en_CM_test.go b/vendor/github.com/go-playground/locales/en_CM/en_CM_test.go new file mode 100644 index 0000000000..8fd33a6d62 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CM/en_CM_test.go @@ -0,0 +1,1120 @@ +package en_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_CX/en_CX.go b/vendor/github.com/go-playground/locales/en_CX/en_CX.go new file mode 100644 index 0000000000..ac9d21de1a --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CX/en_CX.go @@ -0,0 +1,607 @@ +package en_CX + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_CX struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_CX' locale +func New() locales.Translator { + return &en_CX{ + locale: "en_CX", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"PDT": "Pacific Daylight Time", "MYT": "Malaysia Time", "WAT": "West Africa Standard Time", "AKST": "Alaska Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HKT": "Hong Kong Standard Time", "SAST": "South Africa Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MEZ": "Central European Standard Time", "CLT": "Chile Standard Time", "WAST": "West Africa Summer Time", "COT": "Colombia Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "ACWST": "Australian Central Western Standard Time", "JDT": "Japan Daylight Time", "OESZ": "Eastern European Summer Time", "NZST": "New Zealand Standard Time", "ART": "Argentina Standard Time", "ARST": "Argentina Summer Time", "AEDT": "Australian Eastern Daylight Time", "LHDT": "Lord Howe Daylight Time", "EAT": "East Africa Time", "NZDT": "New Zealand Daylight Time", "OEZ": "Eastern European Standard Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "ChST": "Chamorro Standard Time", "CHAST": "Chatham Standard Time", "CAT": "Central Africa Time", "IST": "India Standard Time", "JST": "Japan Standard Time", "WART": "Western Argentina Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "AWST": "Australian Western Standard Time", "PST": "Pacific Standard Time", "WEZ": "Western European Standard Time", "EDT": "Eastern Daylight Time", "HEEG": "East Greenland Summer Time", "SRT": "Suriname Time", "ECT": "Ecuador Time", "MESZ": "Central European Summer Time", "ADT": "Atlantic Daylight Time", "UYST": "Uruguay Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "CLST": "Chile Summer Time", "ACST": "Australian Central Standard Time", "COST": "Colombia Summer Time", "WITA": "Central Indonesia Time", "ACWDT": "Australian Central Western Daylight Time", "WARST": "Western Argentina Summer Time", "TMST": "Turkmenistan Summer Time", "GYT": "Guyana Time", "CST": "Central Standard Time", "CDT": "Central Daylight Time", "TMT": "Turkmenistan Standard Time", "HAT": "Newfoundland Daylight Time", "LHST": "Lord Howe Standard Time", "HEOG": "West Greenland Summer Time", "WESZ": "Western European Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "HNT": "Newfoundland Standard Time", "VET": "Venezuela Time", "GMT": "Greenwich Mean Time", "AWDT": "Australian Western Daylight Time", "BOT": "Bolivia Time", "EST": "Eastern Standard Time", "UYT": "Uruguay Standard Time", "HNEG": "East Greenland Standard Time", "∅∅∅": "Azores Summer Time", "HNCU": "Cuba Standard Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "HNOG": "West Greenland Standard Time", "MDT": "Macau Summer Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "HNPMX": "Mexican Pacific Standard Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "AST": "Atlantic Standard Time", "MST": "Macau Standard Time", "GFT": "French Guiana Time", "AKDT": "Alaska Daylight Time", "AEST": "Australian Eastern Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_CX) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_CX' +func (en *en_CX) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_CX' +func (en *en_CX) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_CX' +func (en *en_CX) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_CX' +func (en *en_CX) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_CX' +func (en *en_CX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_CX' +func (en *en_CX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_CX) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_CX) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_CX) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_CX) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_CX) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_CX) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_CX) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_CX) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_CX) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_CX) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_CX) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_CX) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_CX) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_CX) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_CX' and handles both Whole and Real numbers based on 'v' +func (en *en_CX) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_CX' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_CX) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_CX' +func (en *en_CX) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_CX' +// in accounting notation. +func (en *en_CX) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_CX' +func (en *en_CX) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_CX' +func (en *en_CX) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_CX' +func (en *en_CX) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_CX' +func (en *en_CX) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_CX' +func (en *en_CX) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_CX' +func (en *en_CX) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_CX' +func (en *en_CX) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_CX' +func (en *en_CX) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_CX/en_CX_test.go b/vendor/github.com/go-playground/locales/en_CX/en_CX_test.go new file mode 100644 index 0000000000..aa018e7586 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CX/en_CX_test.go @@ -0,0 +1,1120 @@ +package en_CX + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_CX" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_CY/en_CY.go b/vendor/github.com/go-playground/locales/en_CY/en_CY.go new file mode 100644 index 0000000000..451d1b9d8a --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CY/en_CY.go @@ -0,0 +1,635 @@ +package en_CY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_CY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_CY' locale +func New() locales.Translator { + return &en_CY{ + locale: "en_CY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WITA": "Central Indonesia Time", "HNCU": "Cuba Standard Time", "WIT": "Eastern Indonesia Time", "PST": "Pacific Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "WEZ": "Western European Standard Time", "MDT": "Mountain Daylight Time", "ChST": "Chamorro Standard Time", "AWDT": "Australian Western Daylight Time", "COST": "Colombia Summer Time", "AEST": "Australian Eastern Standard Time", "LHDT": "Lord Howe Daylight Time", "EAT": "East Africa Time", "WIB": "Western Indonesia Time", "CDT": "Central Daylight Time", "CAT": "Central Africa Time", "CLST": "Chile Summer Time", "AKST": "Alaska Standard Time", "LHST": "Lord Howe Standard Time", "COT": "Colombia Standard Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "GFT": "French Guiana Time", "HADT": "Hawaii-Aleutian Daylight Time", "HKT": "Hong Kong Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "UYT": "Uruguay Standard Time", "NZDT": "New Zealand Daylight Time", "GMT": "Greenwich Mean Time", "GYT": "Guyana Time", "BOT": "Bolivia Time", "OEZ": "Eastern European Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "SAST": "South Africa Standard Time", "ECT": "Ecuador Time", "WAST": "West Africa Summer Time", "HKST": "Hong Kong Summer Time", "ACST": "Australian Central Standard Time", "HNEG": "East Greenland Standard Time", "HECU": "Cuba Daylight Time", "PDT": "Pacific Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "ARST": "Argentina Summer Time", "AKDT": "Alaska Daylight Time", "VET": "Venezuela Time", "JDT": "Japan Daylight Time", "TMT": "Turkmenistan Standard Time", "EST": "Eastern Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HEOG": "West Greenland Summer Time", "OESZ": "Eastern European Summer Time", "WESZ": "Western European Summer Time", "MYT": "Malaysia Time", "EDT": "Eastern Daylight Time", "ACDT": "Australian Central Daylight Time", "ART": "Argentina Standard Time", "UYST": "Uruguay Summer Time", "SRT": "Suriname Time", "∅∅∅": "Azores Summer Time", "ACWST": "Australian Central Western Standard Time", "JST": "Japan Standard Time", "AST": "Atlantic Standard Time", "ADT": "Atlantic Daylight Time", "BT": "Bhutan Time", "HEEG": "East Greenland Summer Time", "MST": "Mountain Standard Time", "CHADT": "Chatham Daylight Time", "WARST": "Western Argentina Summer Time", "CLT": "Chile Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "SGT": "Singapore Standard Time", "IST": "India Standard Time", "NZST": "New Zealand Standard Time", "WAT": "West Africa Standard Time", "HNPMX": "Mexican Pacific Standard Time", "AWST": "Australian Western Standard Time", "CHAST": "Chatham Standard Time", "MEZ": "Central European Standard Time", "WART": "Western Argentina Standard Time", "TMST": "Turkmenistan Summer Time", "AEDT": "Australian Eastern Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CST": "Central Standard Time", "MESZ": "Central European Summer Time", "HNOG": "West Greenland Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_CY) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_CY' +func (en *en_CY) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_CY' +func (en *en_CY) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_CY' +func (en *en_CY) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_CY' +func (en *en_CY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_CY' +func (en *en_CY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_CY' +func (en *en_CY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_CY) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_CY) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_CY) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_CY) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_CY) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_CY) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_CY) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_CY) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_CY) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_CY) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_CY) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_CY) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_CY) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_CY) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_CY' and handles both Whole and Real numbers based on 'v' +func (en *en_CY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_CY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_CY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_CY' +func (en *en_CY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_CY' +// in accounting notation. +func (en *en_CY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_CY' +func (en *en_CY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_CY' +func (en *en_CY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_CY' +func (en *en_CY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_CY' +func (en *en_CY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_CY' +func (en *en_CY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_CY' +func (en *en_CY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_CY' +func (en *en_CY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_CY' +func (en *en_CY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_CY/en_CY_test.go b/vendor/github.com/go-playground/locales/en_CY/en_CY_test.go new file mode 100644 index 0000000000..ad9b9681c2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_CY/en_CY_test.go @@ -0,0 +1,1120 @@ +package en_CY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_CY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_DE/en_DE.go b/vendor/github.com/go-playground/locales/en_DE/en_DE.go new file mode 100644 index 0000000000..bb3e06cb35 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_DE/en_DE.go @@ -0,0 +1,639 @@ +package en_DE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_DE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_DE' locale +func New() locales.Translator { + return &en_DE{ + locale: "en_DE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HAT": "Newfoundland Daylight Time", "HNCU": "Cuba Standard Time", "CHAST": "Chatham Standard Time", "MYT": "Malaysia Time", "HEOG": "West Greenland Summer Time", "UYT": "Uruguay Standard Time", "WIT": "Eastern Indonesia Time", "JDT": "Japan Daylight Time", "LHDT": "Lord Howe Daylight Time", "CAT": "Central Africa Time", "ADT": "Atlantic Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "SAST": "South Africa Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "JST": "Japan Standard Time", "MEZ": "Central European Standard Time", "MDT": "Macau Summer Time", "∅∅∅": "Acre Summer Time", "BOT": "Bolivia Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ACWST": "Australian Central Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "IST": "India Standard Time", "WARST": "Western Argentina Summer Time", "CLST": "Chile Summer Time", "ARST": "Argentina Summer Time", "GFT": "French Guiana Time", "HECU": "Cuba Daylight Time", "WITA": "Central Indonesia Time", "AKST": "Alaska Standard Time", "SRT": "Suriname Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time", "ACDT": "Australian Central Daylight Time", "HNEG": "East Greenland Standard Time", "AEDT": "Australian Eastern Daylight Time", "EAT": "East Africa Time", "AWST": "Australian Western Standard Time", "ChST": "Chamorro Standard Time", "PDT": "Pacific Daylight Time", "WEZ": "Western European Standard Time", "EST": "Eastern Standard Time", "EDT": "Eastern Daylight Time", "AEST": "Australian Eastern Standard Time", "WESZ": "Western European Summer Time", "OESZ": "Eastern European Summer Time", "HKST": "Hong Kong Summer Time", "BT": "Bhutan Time", "ECT": "Ecuador Time", "GMT": "Greenwich Mean Time", "WAST": "West Africa Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "MESZ": "Central European Summer Time", "HNPMX": "Mexican Pacific Standard Time", "AWDT": "Australian Western Daylight Time", "PST": "Pacific Standard Time", "HEEG": "East Greenland Summer Time", "CLT": "Chile Standard Time", "AST": "Atlantic Standard Time", "TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "COT": "Colombia Standard Time", "OEZ": "Eastern European Standard Time", "SGT": "Singapore Standard Time", "WART": "Western Argentina Standard Time", "HNOG": "West Greenland Standard Time", "TMST": "Turkmenistan Summer Time", "HNT": "Newfoundland Standard Time", "CST": "Central Standard Time", "CHADT": "Chatham Daylight Time", "HKT": "Hong Kong Standard Time", "COST": "Colombia Summer Time", "AKDT": "Alaska Daylight Time", "UYST": "Uruguay Summer Time", "WIB": "Western Indonesia Time", "CDT": "Central Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "VET": "Venezuela Time", "MST": "Macau Standard Time", "ART": "Argentina Standard Time", "ACST": "Australian Central Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_DE) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_DE' +func (en *en_DE) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_DE' +func (en *en_DE) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_DE' +func (en *en_DE) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_DE' +func (en *en_DE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_DE' +func (en *en_DE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_DE' +func (en *en_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_DE) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_DE) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_DE) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_DE) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_DE) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_DE) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_DE) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_DE) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_DE) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_DE) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_DE) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_DE) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_DE) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_DE) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_DE' and handles both Whole and Real numbers based on 'v' +func (en *en_DE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_DE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_DE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percentSuffix...) + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_DE' +func (en *en_DE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_DE' +// in accounting notation. +func (en *en_DE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_DE' +func (en *en_DE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_DE' +func (en *en_DE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_DE' +func (en *en_DE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_DE' +func (en *en_DE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_DE' +func (en *en_DE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_DE' +func (en *en_DE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_DE' +func (en *en_DE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_DE' +func (en *en_DE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_DE/en_DE_test.go b/vendor/github.com/go-playground/locales/en_DE/en_DE_test.go new file mode 100644 index 0000000000..f5ff5b4b3e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_DE/en_DE_test.go @@ -0,0 +1,1120 @@ +package en_DE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_DE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_DG/en_DG.go b/vendor/github.com/go-playground/locales/en_DG/en_DG.go new file mode 100644 index 0000000000..68ad4ae163 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_DG/en_DG.go @@ -0,0 +1,597 @@ +package en_DG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_DG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_DG' locale +func New() locales.Translator { + return &en_DG{ + locale: "en_DG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"MDT": "Mountain Daylight Time", "GFT": "French Guiana Time", "GYT": "Guyana Time", "WARST": "Western Argentina Summer Time", "CLST": "Chile Summer Time", "AST": "Atlantic Standard Time", "ACDT": "Australian Central Daylight Time", "COT": "Colombia Standard Time", "HNT": "Newfoundland Standard Time", "HNCU": "Cuba Standard Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "PST": "Pacific Standard Time", "MYT": "Malaysia Time", "WART": "Western Argentina Standard Time", "∅∅∅": "Acre Summer Time", "AEDT": "Australian Eastern Daylight Time", "MST": "Mountain Standard Time", "GMT": "Greenwich Mean Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "OEZ": "Eastern European Standard Time", "TMT": "Turkmenistan Standard Time", "ARST": "Argentina Summer Time", "EST": "Eastern Standard Time", "AKDT": "Alaska Daylight Time", "LHST": "Lord Howe Standard Time", "ACWST": "Australian Central Western Standard Time", "WITA": "Central Indonesia Time", "ChST": "Chamorro Standard Time", "AWDT": "Australian Western Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "UYT": "Uruguay Standard Time", "EAT": "East Africa Time", "JST": "Japan Standard Time", "OESZ": "Eastern European Summer Time", "WESZ": "Western European Summer Time", "HKT": "Hong Kong Standard Time", "UYST": "Uruguay Summer Time", "PDT": "Pacific Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "TMST": "Turkmenistan Summer Time", "BT": "Bhutan Time", "HNEG": "East Greenland Standard Time", "SAST": "South Africa Standard Time", "CST": "Central Standard Time", "CHADT": "Chatham Daylight Time", "CLT": "Chile Standard Time", "COST": "Colombia Summer Time", "HAT": "Newfoundland Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "CAT": "Central Africa Time", "MESZ": "Central European Summer Time", "ART": "Argentina Standard Time", "ACST": "Australian Central Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "AWST": "Australian Western Standard Time", "BOT": "Bolivia Time", "WAT": "West Africa Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "IST": "India Standard Time", "WAST": "West Africa Summer Time", "LHDT": "Lord Howe Daylight Time", "CDT": "Central Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "NZDT": "New Zealand Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "SGT": "Singapore Standard Time", "NZST": "New Zealand Standard Time", "MEZ": "Central European Standard Time", "JDT": "Japan Daylight Time", "ADT": "Atlantic Daylight Time", "HKST": "Hong Kong Summer Time", "HEEG": "East Greenland Summer Time", "AEST": "Australian Eastern Standard Time", "SRT": "Suriname Time", "ECT": "Ecuador Time", "EDT": "Eastern Daylight Time", "AKST": "Alaska Standard Time", "CHAST": "Chatham Standard Time", "VET": "Venezuela Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "WEZ": "Western European Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_DG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_DG' +func (en *en_DG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_DG' +func (en *en_DG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_DG' +func (en *en_DG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_DG' +func (en *en_DG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_DG' +func (en *en_DG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_DG' +func (en *en_DG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_DG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_DG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_DG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_DG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_DG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_DG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_DG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_DG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_DG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_DG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_DG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_DG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_DG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_DG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_DG' and handles both Whole and Real numbers based on 'v' +func (en *en_DG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_DG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_DG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_DG' +func (en *en_DG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_DG' +// in accounting notation. +func (en *en_DG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_DG' +func (en *en_DG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_DG' +func (en *en_DG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_DG' +func (en *en_DG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_DG' +func (en *en_DG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_DG' +func (en *en_DG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_DG' +func (en *en_DG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_DG' +func (en *en_DG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_DG' +func (en *en_DG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_DG/en_DG_test.go b/vendor/github.com/go-playground/locales/en_DG/en_DG_test.go new file mode 100644 index 0000000000..d9548ef8e3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_DG/en_DG_test.go @@ -0,0 +1,1120 @@ +package en_DG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_DG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_DK/en_DK.go b/vendor/github.com/go-playground/locales/en_DK/en_DK.go new file mode 100644 index 0000000000..69b7bcd2fe --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_DK/en_DK.go @@ -0,0 +1,601 @@ +package en_DK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_DK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_DK' locale +func New() locales.Translator { + return &en_DK{ + locale: "en_DK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "kr.", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "CDT": "Central Daylight Time", "OEZ": "Eastern European Standard Time", "HKST": "Hong Kong Summer Time", "COT": "Colombia Standard Time", "AEDT": "Australian Eastern Daylight Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "IST": "India Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "COST": "Colombia Summer Time", "SRT": "Suriname Time", "AKST": "Alaska Standard Time", "WIB": "Western Indonesia Time", "JDT": "Japan Daylight Time", "EDT": "Eastern Daylight Time", "ACST": "Australian Central Standard Time", "MST": "Mountain Standard Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time", "HADT": "Hawaii-Aleutian Daylight Time", "NZST": "New Zealand Standard Time", "VET": "Venezuela Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SAST": "South Africa Standard Time", "WIT": "Eastern Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "HNEG": "East Greenland Standard Time", "HNPMX": "Mexican Pacific Standard Time", "UYST": "Uruguay Summer Time", "AWDT": "Australian Western Daylight Time", "WART": "Western Argentina Standard Time", "AST": "Atlantic Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "MESZ": "Central European Summer Time", "HNOG": "West Greenland Standard Time", "TMST": "Turkmenistan Summer Time", "ART": "Argentina Standard Time", "HKT": "Hong Kong Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "ACWST": "Australian Central Western Standard Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "WEZ": "Western European Standard Time", "WESZ": "Western European Summer Time", "AKDT": "Alaska Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "CLST": "Chile Summer Time", "HEOG": "West Greenland Summer Time", "EST": "Eastern Standard Time", "GFT": "French Guiana Time", "ADT": "Atlantic Daylight Time", "BT": "Bhutan Time", "HNT": "Newfoundland Standard Time", "GMT": "Greenwich Mean Time", "HAT": "Newfoundland Daylight Time", "CLT": "Chile Standard Time", "UYT": "Uruguay Standard Time", "AWST": "Australian Western Standard Time", "ECT": "Ecuador Time", "NZDT": "New Zealand Daylight Time", "JST": "Japan Standard Time", "MEZ": "Central European Standard Time", "TMT": "Turkmenistan Standard Time", "AEST": "Australian Eastern Standard Time", "HEEG": "East Greenland Summer Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "PDT": "Pacific Daylight Time", "CAT": "Central Africa Time", "LHDT": "Lord Howe Daylight Time", "MYT": "Malaysia Time", "WAST": "West Africa Summer Time", "ACDT": "Australian Central Daylight Time", "MDT": "Mountain Daylight Time", "∅∅∅": "Azores Summer Time", "HECU": "Cuba Daylight Time", "CHAST": "Chatham Standard Time", "WARST": "Western Argentina Summer Time", "OESZ": "Eastern European Summer Time", "ARST": "Argentina Summer Time", "WAT": "West Africa Standard Time", "ChST": "Chamorro Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_DK) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_DK' +func (en *en_DK) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_DK' +func (en *en_DK) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_DK' +func (en *en_DK) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_DK' +func (en *en_DK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_DK' +func (en *en_DK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_DK' +func (en *en_DK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_DK) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_DK) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_DK) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_DK) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_DK) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_DK) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_DK) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_DK) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_DK) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_DK) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_DK) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_DK) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_DK) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_DK) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_DK' and handles both Whole and Real numbers based on 'v' +func (en *en_DK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_DK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_DK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percentSuffix...) + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_DK' +func (en *en_DK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_DK' +// in accounting notation. +func (en *en_DK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_DK' +func (en *en_DK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_DK' +func (en *en_DK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_DK' +func (en *en_DK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_DK' +func (en *en_DK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_DK' +func (en *en_DK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_DK' +func (en *en_DK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_DK' +func (en *en_DK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_DK' +func (en *en_DK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_DK/en_DK_test.go b/vendor/github.com/go-playground/locales/en_DK/en_DK_test.go new file mode 100644 index 0000000000..225b1f69ae --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_DK/en_DK_test.go @@ -0,0 +1,1120 @@ +package en_DK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_DK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_DM/en_DM.go b/vendor/github.com/go-playground/locales/en_DM/en_DM.go new file mode 100644 index 0000000000..0ae43ca412 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_DM/en_DM.go @@ -0,0 +1,645 @@ +package en_DM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_DM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_DM' locale +func New() locales.Translator { + return &en_DM{ + locale: "en_DM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"LHDT": "Lord Howe Daylight Time", "ADT": "Atlantic Daylight Time", "WESZ": "Western European Summer Time", "ACDT": "Australian Central Daylight Time", "JDT": "Japan Daylight Time", "OESZ": "Eastern European Summer Time", "WEZ": "Western European Standard Time", "WART": "Western Argentina Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HAT": "Newfoundland Daylight Time", "CST": "Central Standard Time", "NZST": "New Zealand Standard Time", "VET": "Venezuela Time", "GMT": "Greenwich Mean Time", "MYT": "Malaysia Time", "HNCU": "Cuba Standard Time", "AEDT": "Australian Eastern Daylight Time", "IST": "India Standard Time", "MST": "Macau Standard Time", "EDT": "Eastern Daylight Time", "SAST": "South Africa Standard Time", "SRT": "Suriname Time", "HECU": "Cuba Daylight Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "COT": "Colombia Standard Time", "WAT": "West Africa Standard Time", "ACST": "Australian Central Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "AWST": "Australian Western Standard Time", "AWDT": "Australian Western Daylight Time", "BOT": "Bolivia Time", "CLT": "Chile Standard Time", "AST": "Atlantic Standard Time", "CDT": "Central Daylight Time", "PDT": "Pacific Daylight Time", "NZDT": "New Zealand Daylight Time", "HKT": "Hong Kong Standard Time", "AEST": "Australian Eastern Standard Time", "EAT": "East Africa Time", "CAT": "Central Africa Time", "JST": "Japan Standard Time", "WARST": "Western Argentina Summer Time", "AKST": "Alaska Standard Time", "ART": "Argentina Standard Time", "WAST": "West Africa Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "MESZ": "Central European Summer Time", "EST": "Eastern Standard Time", "BT": "Bhutan Time", "HNT": "Newfoundland Standard Time", "HNEG": "East Greenland Standard Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time", "ECT": "Ecuador Time", "ACWST": "Australian Central Western Standard Time", "COST": "Colombia Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "WIT": "Eastern Indonesia Time", "HEOG": "West Greenland Summer Time", "HNPMX": "Mexican Pacific Standard Time", "SGT": "Singapore Standard Time", "CLST": "Chile Summer Time", "WITA": "Central Indonesia Time", "HNPM": "St. Pierre & Miquelon Standard Time", "ACWDT": "Australian Central Western Daylight Time", "ARST": "Argentina Summer Time", "HEEG": "East Greenland Summer Time", "TMT": "Turkmenistan Standard Time", "TMST": "Turkmenistan Summer Time", "HKST": "Hong Kong Summer Time", "∅∅∅": "Azores Summer Time", "WIB": "Western Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "MEZ": "Central European Standard Time", "OEZ": "Eastern European Standard Time", "AKDT": "Alaska Daylight Time", "UYT": "Uruguay Standard Time", "UYST": "Uruguay Summer Time", "ChST": "Chamorro Standard Time", "CHAST": "Chatham Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "HNOG": "West Greenland Standard Time", "MDT": "Macau Summer Time", "GFT": "French Guiana Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_DM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_DM' +func (en *en_DM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_DM' +func (en *en_DM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_DM' +func (en *en_DM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_DM' +func (en *en_DM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_DM' +func (en *en_DM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_DM' +func (en *en_DM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_DM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_DM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_DM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_DM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_DM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_DM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_DM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_DM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_DM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_DM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_DM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_DM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_DM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_DM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_DM' and handles both Whole and Real numbers based on 'v' +func (en *en_DM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_DM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_DM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_DM' +func (en *en_DM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_DM' +// in accounting notation. +func (en *en_DM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_DM' +func (en *en_DM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_DM' +func (en *en_DM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_DM' +func (en *en_DM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_DM' +func (en *en_DM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_DM' +func (en *en_DM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_DM' +func (en *en_DM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_DM' +func (en *en_DM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_DM' +func (en *en_DM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_DM/en_DM_test.go b/vendor/github.com/go-playground/locales/en_DM/en_DM_test.go new file mode 100644 index 0000000000..b48f165488 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_DM/en_DM_test.go @@ -0,0 +1,1120 @@ +package en_DM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_DM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_ER/en_ER.go b/vendor/github.com/go-playground/locales/en_ER/en_ER.go new file mode 100644 index 0000000000..84a4c15fca --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_ER/en_ER.go @@ -0,0 +1,645 @@ +package en_ER + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_ER struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_ER' locale +func New() locales.Translator { + return &en_ER{ + locale: "en_ER", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "Nfk", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "AEST": "Australian Eastern Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "NZST": "New Zealand Standard Time", "MEZ": "Central European Standard Time", "JDT": "Japan Daylight Time", "SAST": "South Africa Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "BOT": "Bolivia Time", "ADT": "Atlantic Daylight Time", "WARST": "Western Argentina Summer Time", "AWST": "Australian Western Standard Time", "AWDT": "Australian Western Daylight Time", "NZDT": "New Zealand Daylight Time", "MESZ": "Central European Summer Time", "ARST": "Argentina Summer Time", "ACST": "Australian Central Standard Time", "UYT": "Uruguay Standard Time", "UYST": "Uruguay Summer Time", "HNOG": "West Greenland Standard Time", "BT": "Bhutan Time", "AKST": "Alaska Standard Time", "AEDT": "Australian Eastern Daylight Time", "CDT": "Central Daylight Time", "WEZ": "Western European Standard Time", "ART": "Argentina Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SRT": "Suriname Time", "EAT": "East Africa Time", "SGT": "Singapore Standard Time", "VET": "Venezuela Time", "JST": "Japan Standard Time", "CLST": "Chile Summer Time", "HKT": "Hong Kong Standard Time", "WITA": "Central Indonesia Time", "ChST": "Chamorro Standard Time", "TMST": "Turkmenistan Summer Time", "ACDT": "Australian Central Daylight Time", "HAT": "Newfoundland Daylight Time", "WIB": "Western Indonesia Time", "CAT": "Central Africa Time", "ACWST": "Australian Central Western Standard Time", "OESZ": "Eastern European Summer Time", "HNT": "Newfoundland Standard Time", "GYT": "Guyana Time", "MST": "Macau Standard Time", "CLT": "Chile Standard Time", "HECU": "Cuba Daylight Time", "WIT": "Eastern Indonesia Time", "PST": "Pacific Standard Time", "WAT": "West Africa Standard Time", "EST": "Eastern Standard Time", "COT": "Colombia Standard Time", "HEEG": "East Greenland Summer Time", "GFT": "French Guiana Time", "HEOG": "West Greenland Summer Time", "TMT": "Turkmenistan Standard Time", "EDT": "Eastern Daylight Time", "AKDT": "Alaska Daylight Time", "ECT": "Ecuador Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HNEG": "East Greenland Standard Time", "CHADT": "Chatham Daylight Time", "PDT": "Pacific Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "MYT": "Malaysia Time", "MDT": "Macau Summer Time", "COST": "Colombia Summer Time", "∅∅∅": "Acre Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HNCU": "Cuba Standard Time", "CHAST": "Chatham Standard Time", "AST": "Atlantic Standard Time", "OEZ": "Eastern European Standard Time", "WART": "Western Argentina Standard Time", "WAST": "West Africa Summer Time", "LHST": "Lord Howe Standard Time", "LHDT": "Lord Howe Daylight Time", "CST": "Central Standard Time", "IST": "India Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_ER) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_ER' +func (en *en_ER) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_ER' +func (en *en_ER) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_ER' +func (en *en_ER) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_ER' +func (en *en_ER) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_ER' +func (en *en_ER) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_ER' +func (en *en_ER) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_ER) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_ER) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_ER) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_ER) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_ER) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_ER) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_ER) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_ER) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_ER) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_ER) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_ER) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_ER) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_ER) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_ER) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_ER' and handles both Whole and Real numbers based on 'v' +func (en *en_ER) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_ER' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_ER) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_ER' +func (en *en_ER) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_ER' +// in accounting notation. +func (en *en_ER) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_ER' +func (en *en_ER) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_ER' +func (en *en_ER) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_ER' +func (en *en_ER) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_ER' +func (en *en_ER) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_ER' +func (en *en_ER) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_ER' +func (en *en_ER) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_ER' +func (en *en_ER) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_ER' +func (en *en_ER) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_ER/en_ER_test.go b/vendor/github.com/go-playground/locales/en_ER/en_ER_test.go new file mode 100644 index 0000000000..f56a74aa9d --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_ER/en_ER_test.go @@ -0,0 +1,1120 @@ +package en_ER + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_ER" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_FI/en_FI.go b/vendor/github.com/go-playground/locales/en_FI/en_FI.go new file mode 100644 index 0000000000..5245f36469 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_FI/en_FI.go @@ -0,0 +1,591 @@ +package en_FI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_FI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_FI' locale +func New() locales.Translator { + return &en_FI{ + locale: "en_FI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"MEZ": "Central European Standard Time", "HKST": "Hong Kong Summer Time", "BOT": "Bolivia Time", "CLT": "Chile Standard Time", "SGT": "Singapore Standard Time", "WIT": "Eastern Indonesia Time", "AWDT": "Australian Western Daylight Time", "WARST": "Western Argentina Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "GFT": "French Guiana Time", "UYST": "Uruguay Summer Time", "CDT": "Central Daylight Time", "OESZ": "Eastern European Summer Time", "MYT": "Malaysia Time", "EST": "Eastern Standard Time", "AEST": "Australian Eastern Standard Time", "AST": "Atlantic Standard Time", "CLST": "Chile Summer Time", "MST": "Macau Standard Time", "ECT": "Ecuador Time", "CHADT": "Chatham Daylight Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "ADT": "Atlantic Daylight Time", "COST": "Colombia Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "∅∅∅": "Azores Summer Time", "ACWDT": "Australian Central Western Daylight Time", "VET": "Venezuela Time", "HEOG": "West Greenland Summer Time", "WAST": "West Africa Summer Time", "HKT": "Hong Kong Standard Time", "HAT": "Newfoundland Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHST": "Lord Howe Standard Time", "WEZ": "Western European Standard Time", "TMST": "Turkmenistan Summer Time", "MDT": "Macau Summer Time", "ART": "Argentina Standard Time", "AKST": "Alaska Standard Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "PST": "Pacific Standard Time", "PDT": "Pacific Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "WART": "Western Argentina Standard Time", "EDT": "Eastern Daylight Time", "BT": "Bhutan Time", "WIB": "Western Indonesia Time", "ChST": "Chamorro Standard Time", "AEDT": "Australian Eastern Daylight Time", "IST": "India Standard Time", "JST": "Japan Standard Time", "WESZ": "Western European Summer Time", "HNEG": "East Greenland Standard Time", "EAT": "East Africa Time", "HECU": "Cuba Daylight Time", "AWST": "Australian Western Standard Time", "ACWST": "Australian Central Western Standard Time", "HNOG": "West Greenland Standard Time", "OEZ": "Eastern European Standard Time", "TMT": "Turkmenistan Standard Time", "ARST": "Argentina Summer Time", "HNPMX": "Mexican Pacific Standard Time", "WITA": "Central Indonesia Time", "COT": "Colombia Standard Time", "CAT": "Central Africa Time", "GMT": "Greenwich Mean Time", "ACST": "Australian Central Standard Time", "ACDT": "Australian Central Daylight Time", "HNT": "Newfoundland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHDT": "Lord Howe Daylight Time", "CHAST": "Chatham Standard Time", "AKDT": "Alaska Daylight Time", "SAST": "South Africa Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "JDT": "Japan Daylight Time", "HEEG": "East Greenland Summer Time", "GYT": "Guyana Time", "SRT": "Suriname Time", "MESZ": "Central European Summer Time", "WAT": "West Africa Standard Time", "UYT": "Uruguay Standard Time", "HEPMX": "Mexican Pacific Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_FI) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_FI' +func (en *en_FI) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_FI' +func (en *en_FI) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_FI' +func (en *en_FI) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_FI' +func (en *en_FI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_FI' +func (en *en_FI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_FI' +func (en *en_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_FI) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_FI) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_FI) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_FI) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_FI) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_FI) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_FI) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_FI) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_FI) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_FI) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_FI) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_FI) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_FI) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_FI) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_FI' and handles both Whole and Real numbers based on 'v' +func (en *en_FI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_FI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_FI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percentSuffix...) + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_FI' +func (en *en_FI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_FI' +// in accounting notation. +func (en *en_FI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_FI' +func (en *en_FI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_FI' +func (en *en_FI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_FI' +func (en *en_FI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_FI' +func (en *en_FI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_FI' +func (en *en_FI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_FI' +func (en *en_FI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_FI' +func (en *en_FI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_FI' +func (en *en_FI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_FI/en_FI_test.go b/vendor/github.com/go-playground/locales/en_FI/en_FI_test.go new file mode 100644 index 0000000000..97767454f5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_FI/en_FI_test.go @@ -0,0 +1,1120 @@ +package en_FI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_FI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_FJ/en_FJ.go b/vendor/github.com/go-playground/locales/en_FJ/en_FJ.go new file mode 100644 index 0000000000..c91c8725d3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_FJ/en_FJ.go @@ -0,0 +1,645 @@ +package en_FJ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_FJ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_FJ' locale +func New() locales.Translator { + return &en_FJ{ + locale: "en_FJ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "$", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"IST": "India Standard Time", "AST": "Atlantic Standard Time", "OEZ": "Eastern European Standard Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "EDT": "Eastern Daylight Time", "GFT": "French Guiana Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CST": "Central Standard Time", "PDT": "Pacific Daylight Time", "TMT": "Turkmenistan Standard Time", "ChST": "Chamorro Standard Time", "COT": "Colombia Standard Time", "HNEG": "East Greenland Standard Time", "AKDT": "Alaska Daylight Time", "EST": "Eastern Standard Time", "GMT": "Greenwich Mean Time", "CLST": "Chile Summer Time", "HNOG": "West Greenland Standard Time", "WAST": "West Africa Summer Time", "BT": "Bhutan Time", "AWDT": "Australian Western Daylight Time", "HEEG": "East Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "PST": "Pacific Standard Time", "CAT": "Central Africa Time", "JDT": "Japan Daylight Time", "ART": "Argentina Standard Time", "HKT": "Hong Kong Standard Time", "HNCU": "Cuba Standard Time", "NZST": "New Zealand Standard Time", "ADT": "Atlantic Daylight Time", "OESZ": "Eastern European Summer Time", "MYT": "Malaysia Time", "WART": "Western Argentina Standard Time", "WARST": "Western Argentina Summer Time", "WAT": "West Africa Standard Time", "ACST": "Australian Central Standard Time", "SRT": "Suriname Time", "MEZ": "Central European Standard Time", "HNT": "Newfoundland Standard Time", "WIB": "Western Indonesia Time", "BOT": "Bolivia Time", "WESZ": "Western European Summer Time", "TMST": "Turkmenistan Summer Time", "WITA": "Central Indonesia Time", "SAST": "South Africa Standard Time", "LHST": "Lord Howe Standard Time", "LHDT": "Lord Howe Daylight Time", "EAT": "East Africa Time", "CDT": "Central Daylight Time", "ACWST": "Australian Central Western Standard Time", "NZDT": "New Zealand Daylight Time", "JST": "Japan Standard Time", "CLT": "Chile Standard Time", "UYST": "Uruguay Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "CHADT": "Chatham Daylight Time", "ECT": "Ecuador Time", "HENOMX": "Northwest Mexico Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "WIT": "Eastern Indonesia Time", "SGT": "Singapore Standard Time", "WEZ": "Western European Standard Time", "HKST": "Hong Kong Summer Time", "ACDT": "Australian Central Daylight Time", "HAT": "Newfoundland Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MST": "Macau Standard Time", "COST": "Colombia Summer Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CHAST": "Chatham Standard Time", "MDT": "Macau Summer Time", "GYT": "Guyana Time", "AWST": "Australian Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "∅∅∅": "Amazon Summer Time", "MESZ": "Central European Summer Time", "VET": "Venezuela Time", "HNNOMX": "Northwest Mexico Standard Time", "AKST": "Alaska Standard Time", "HECU": "Cuba Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_FJ) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_FJ' +func (en *en_FJ) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_FJ' +func (en *en_FJ) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_FJ' +func (en *en_FJ) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_FJ' +func (en *en_FJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_FJ' +func (en *en_FJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_FJ' +func (en *en_FJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_FJ) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_FJ) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_FJ) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_FJ) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_FJ) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_FJ) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_FJ) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_FJ) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_FJ) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_FJ) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_FJ) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_FJ) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_FJ) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_FJ) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_FJ' and handles both Whole and Real numbers based on 'v' +func (en *en_FJ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_FJ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_FJ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_FJ' +func (en *en_FJ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_FJ' +// in accounting notation. +func (en *en_FJ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_FJ' +func (en *en_FJ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_FJ' +func (en *en_FJ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_FJ' +func (en *en_FJ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_FJ' +func (en *en_FJ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_FJ' +func (en *en_FJ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_FJ' +func (en *en_FJ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_FJ' +func (en *en_FJ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_FJ' +func (en *en_FJ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_FJ/en_FJ_test.go b/vendor/github.com/go-playground/locales/en_FJ/en_FJ_test.go new file mode 100644 index 0000000000..40df4e7d0a --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_FJ/en_FJ_test.go @@ -0,0 +1,1120 @@ +package en_FJ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_FJ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_FK/en_FK.go b/vendor/github.com/go-playground/locales/en_FK/en_FK.go new file mode 100644 index 0000000000..152a01b852 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_FK/en_FK.go @@ -0,0 +1,597 @@ +package en_FK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_FK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_FK' locale +func New() locales.Translator { + return &en_FK{ + locale: "en_FK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "£", "FRF", "GB£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"JST": "Japan Standard Time", "TMT": "Turkmenistan Standard Time", "UYST": "Uruguay Summer Time", "CHAST": "Chatham Standard Time", "BOT": "Bolivia Time", "IST": "India Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HNT": "Newfoundland Standard Time", "HEEG": "East Greenland Summer Time", "PDT": "Pacific Daylight Time", "OEZ": "Eastern European Standard Time", "COT": "Colombia Standard Time", "EST": "Eastern Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "BT": "Bhutan Time", "GFT": "French Guiana Time", "EAT": "East Africa Time", "HEOG": "West Greenland Summer Time", "WEZ": "Western European Standard Time", "HKT": "Hong Kong Standard Time", "ACDT": "Australian Central Daylight Time", "WITA": "Central Indonesia Time", "ACWDT": "Australian Central Western Daylight Time", "AST": "Atlantic Standard Time", "OESZ": "Eastern European Summer Time", "HKST": "Hong Kong Summer Time", "AWDT": "Australian Western Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "ACWST": "Australian Central Western Standard Time", "∅∅∅": "Azores Summer Time", "TMST": "Turkmenistan Summer Time", "ChST": "Chamorro Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ADT": "Atlantic Daylight Time", "EDT": "Eastern Daylight Time", "AKDT": "Alaska Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHST": "Lord Howe Standard Time", "WIB": "Western Indonesia Time", "NZDT": "New Zealand Daylight Time", "MST": "Macau Standard Time", "COST": "Colombia Summer Time", "UYT": "Uruguay Standard Time", "ECT": "Ecuador Time", "CLT": "Chile Standard Time", "MYT": "Malaysia Time", "HNEG": "East Greenland Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "GYT": "Guyana Time", "SGT": "Singapore Standard Time", "JDT": "Japan Daylight Time", "ACST": "Australian Central Standard Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "WIT": "Eastern Indonesia Time", "WESZ": "Western European Summer Time", "WART": "Western Argentina Standard Time", "HNPMX": "Mexican Pacific Standard Time", "AWST": "Australian Western Standard Time", "CAT": "Central Africa Time", "HADT": "Hawaii-Aleutian Daylight Time", "HNOG": "West Greenland Standard Time", "HAT": "Newfoundland Daylight Time", "LHDT": "Lord Howe Daylight Time", "SRT": "Suriname Time", "CHADT": "Chatham Daylight Time", "ART": "Argentina Standard Time", "WAST": "West Africa Summer Time", "AEST": "Australian Eastern Standard Time", "AEDT": "Australian Eastern Daylight Time", "MEZ": "Central European Standard Time", "MESZ": "Central European Summer Time", "GMT": "Greenwich Mean Time", "AKST": "Alaska Standard Time", "SAST": "South Africa Standard Time", "VET": "Venezuela Time", "CLST": "Chile Summer Time", "NZST": "New Zealand Standard Time", "WARST": "Western Argentina Summer Time", "MDT": "Macau Summer Time", "ARST": "Argentina Summer Time", "WAT": "West Africa Standard Time", "HNCU": "Cuba Standard Time", "CDT": "Central Daylight Time", "PST": "Pacific Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_FK) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_FK' +func (en *en_FK) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_FK' +func (en *en_FK) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_FK' +func (en *en_FK) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_FK' +func (en *en_FK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_FK' +func (en *en_FK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_FK' +func (en *en_FK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_FK) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_FK) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_FK) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_FK) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_FK) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_FK) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_FK) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_FK) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_FK) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_FK) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_FK) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_FK) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_FK) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_FK) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_FK' and handles both Whole and Real numbers based on 'v' +func (en *en_FK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_FK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_FK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_FK' +func (en *en_FK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_FK' +// in accounting notation. +func (en *en_FK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_FK' +func (en *en_FK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_FK' +func (en *en_FK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_FK' +func (en *en_FK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_FK' +func (en *en_FK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_FK' +func (en *en_FK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_FK' +func (en *en_FK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_FK' +func (en *en_FK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_FK' +func (en *en_FK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_FK/en_FK_test.go b/vendor/github.com/go-playground/locales/en_FK/en_FK_test.go new file mode 100644 index 0000000000..95de997a66 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_FK/en_FK_test.go @@ -0,0 +1,1120 @@ +package en_FK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_FK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_FM/en_FM.go b/vendor/github.com/go-playground/locales/en_FM/en_FM.go new file mode 100644 index 0000000000..f29792d602 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_FM/en_FM.go @@ -0,0 +1,645 @@ +package en_FM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_FM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_FM' locale +func New() locales.Translator { + return &en_FM{ + locale: "en_FM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AST": "Atlantic Standard Time", "WAT": "West Africa Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "JDT": "Japan Daylight Time", "ADT": "Atlantic Daylight Time", "ART": "Argentina Standard Time", "BT": "Bhutan Time", "AKDT": "Alaska Daylight Time", "ChST": "Chamorro Standard Time", "CHADT": "Chatham Daylight Time", "IST": "India Standard Time", "CLST": "Chile Summer Time", "HNPMX": "Mexican Pacific Standard Time", "ACWDT": "Australian Central Western Daylight Time", "WAST": "West Africa Summer Time", "EDT": "Eastern Daylight Time", "MYT": "Malaysia Time", "TMT": "Turkmenistan Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AKST": "Alaska Standard Time", "CAT": "Central Africa Time", "CLT": "Chile Standard Time", "ACDT": "Australian Central Daylight Time", "HNT": "Newfoundland Standard Time", "UYST": "Uruguay Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "WIB": "Western Indonesia Time", "MEZ": "Central European Standard Time", "WESZ": "Western European Summer Time", "WIT": "Eastern Indonesia Time", "VET": "Venezuela Time", "ARST": "Argentina Summer Time", "AEST": "Australian Eastern Standard Time", "WART": "Western Argentina Standard Time", "WARST": "Western Argentina Summer Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "OEZ": "Eastern European Standard Time", "MST": "Macau Standard Time", "EST": "Eastern Standard Time", "LHDT": "Lord Howe Daylight Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "CHAST": "Chatham Standard Time", "SGT": "Singapore Standard Time", "∅∅∅": "Amazon Summer Time", "ACWST": "Australian Central Western Standard Time", "NZST": "New Zealand Standard Time", "JST": "Japan Standard Time", "OESZ": "Eastern European Summer Time", "AEDT": "Australian Eastern Daylight Time", "AWST": "Australian Western Standard Time", "PDT": "Pacific Daylight Time", "MESZ": "Central European Summer Time", "TMST": "Turkmenistan Summer Time", "HAT": "Newfoundland Daylight Time", "AWDT": "Australian Western Daylight Time", "ACST": "Australian Central Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CDT": "Central Daylight Time", "ECT": "Ecuador Time", "GMT": "Greenwich Mean Time", "COST": "Colombia Summer Time", "SAST": "South Africa Standard Time", "SRT": "Suriname Time", "HECU": "Cuba Daylight Time", "BOT": "Bolivia Time", "HADT": "Hawaii-Aleutian Daylight Time", "COT": "Colombia Standard Time", "PST": "Pacific Standard Time", "MDT": "Macau Summer Time", "HKST": "Hong Kong Summer Time", "HNEG": "East Greenland Standard Time", "HEEG": "East Greenland Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "NZDT": "New Zealand Daylight Time", "WEZ": "Western European Standard Time", "HKT": "Hong Kong Standard Time", "GFT": "French Guiana Time", "WITA": "Central Indonesia Time", "UYT": "Uruguay Standard Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_FM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_FM' +func (en *en_FM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_FM' +func (en *en_FM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_FM' +func (en *en_FM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_FM' +func (en *en_FM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_FM' +func (en *en_FM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_FM' +func (en *en_FM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_FM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_FM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_FM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_FM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_FM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_FM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_FM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_FM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_FM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_FM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_FM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_FM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_FM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_FM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_FM' and handles both Whole and Real numbers based on 'v' +func (en *en_FM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_FM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_FM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_FM' +func (en *en_FM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_FM' +// in accounting notation. +func (en *en_FM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_FM' +func (en *en_FM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_FM' +func (en *en_FM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_FM' +func (en *en_FM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_FM' +func (en *en_FM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_FM' +func (en *en_FM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_FM' +func (en *en_FM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_FM' +func (en *en_FM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_FM' +func (en *en_FM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_FM/en_FM_test.go b/vendor/github.com/go-playground/locales/en_FM/en_FM_test.go new file mode 100644 index 0000000000..104bdb1ea3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_FM/en_FM_test.go @@ -0,0 +1,1120 @@ +package en_FM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_FM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_GB/en_GB.go b/vendor/github.com/go-playground/locales/en_GB/en_GB.go new file mode 100644 index 0000000000..1c25bb4442 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GB/en_GB.go @@ -0,0 +1,607 @@ +package en_GB + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_GB struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_GB' locale +func New() locales.Translator { + return &en_GB{ + locale: "en_GB", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WART": "Western Argentina Standard Time", "HKT": "Hong Kong Standard Time", "UYST": "Uruguay Summer Time", "SAST": "South Africa Standard Time", "∅∅∅": "Azores Summer Time", "HNCU": "Cuba Standard Time", "AWST": "Australian Western Standard Time", "AKST": "Alaska Standard Time", "AKDT": "Alaska Daylight Time", "AEST": "Australian Eastern Standard Time", "HKST": "Hong Kong Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "CHADT": "Chatham Daylight Time", "IST": "India Standard Time", "CLT": "Chile Standard Time", "ARST": "Argentina Summer Time", "JDT": "Japan Daylight Time", "OEZ": "Eastern European Standard Time", "OESZ": "Eastern European Summer Time", "WAT": "West Africa Standard Time", "HNOG": "West Greenland Standard Time", "AST": "Atlantic Standard Time", "WEZ": "Western European Standard Time", "LHST": "Lord Howe Standard Time", "SRT": "Suriname Time", "CHAST": "Chatham Standard Time", "CAT": "Central Africa Time", "MESZ": "Central European Summer Time", "GFT": "French Guiana Time", "WITA": "Central Indonesia Time", "UYT": "Uruguay Standard Time", "ADT": "Atlantic Daylight Time", "TMST": "Turkmenistan Summer Time", "PDT": "Pacific Daylight Time", "NZST": "New Zealand Standard Time", "HNT": "Newfoundland Standard Time", "MDT": "Mountain Daylight Time", "WIT": "Eastern Indonesia Time", "PST": "Pacific Standard Time", "AEDT": "Australian Eastern Daylight Time", "CST": "Central Standard Time", "TMT": "Turkmenistan Standard Time", "MYT": "Malaysia Time", "HAT": "Newfoundland Daylight Time", "MST": "Mountain Standard Time", "GYT": "Guyana Time", "BOT": "Bolivia Time", "HEEG": "East Greenland Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "EAT": "East Africa Time", "HAST": "Hawaii-Aleutian Standard Time", "ACWDT": "Australian Central Western Daylight Time", "MEZ": "Central European Standard Time", "HEOG": "West Greenland Summer Time", "GMT": "Greenwich Mean Time", "ART": "Argentina Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CDT": "Central Daylight Time", "ACWST": "Australian Central Western Standard Time", "EST": "Eastern Standard Time", "ACST": "Australian Central Standard Time", "ACDT": "Australian Central Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "WIB": "Western Indonesia Time", "JST": "Japan Standard Time", "CLST": "Chile Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "WARST": "Western Argentina Summer Time", "COT": "Colombia Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "WAST": "West Africa Summer Time", "BT": "Bhutan Time", "HNPMX": "Mexican Pacific Standard Time", "SGT": "Singapore Standard Time", "VET": "Venezuela Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "EDT": "Eastern Daylight Time", "COST": "Colombia Summer Time", "HNEG": "East Greenland Standard Time", "ChST": "Chamorro Standard Time", "HECU": "Cuba Daylight Time", "AWDT": "Australian Western Daylight Time", "LHDT": "Lord Howe Daylight Time", "ECT": "Ecuador Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_GB) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_GB' +func (en *en_GB) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GB' +func (en *en_GB) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_GB' +func (en *en_GB) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GB' +func (en *en_GB) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GB' +func (en *en_GB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GB' +func (en *en_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_GB) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_GB) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_GB) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_GB) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_GB) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_GB) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_GB) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_GB) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_GB) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_GB) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_GB) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_GB) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_GB) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_GB) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_GB' and handles both Whole and Real numbers based on 'v' +func (en *en_GB) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_GB' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_GB) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GB' +func (en *en_GB) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GB' +// in accounting notation. +func (en *en_GB) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_GB' +func (en *en_GB) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_GB' +func (en *en_GB) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_GB' +func (en *en_GB) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_GB' +func (en *en_GB) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_GB' +func (en *en_GB) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_GB' +func (en *en_GB) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_GB' +func (en *en_GB) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_GB' +func (en *en_GB) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_GB/en_GB_test.go b/vendor/github.com/go-playground/locales/en_GB/en_GB_test.go new file mode 100644 index 0000000000..cb8359b342 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GB/en_GB_test.go @@ -0,0 +1,1120 @@ +package en_GB + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_GB" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_GD/en_GD.go b/vendor/github.com/go-playground/locales/en_GD/en_GD.go new file mode 100644 index 0000000000..ef758c76a1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GD/en_GD.go @@ -0,0 +1,645 @@ +package en_GD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_GD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_GD' locale +func New() locales.Translator { + return &en_GD{ + locale: "en_GD", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"OESZ": "Eastern European Summer Time", "LHDT": "Lord Howe Daylight Time", "GYT": "Guyana Time", "OEZ": "Eastern European Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "LHST": "Lord Howe Standard Time", "WIB": "Western Indonesia Time", "GMT": "Greenwich Mean Time", "CLT": "Chile Standard Time", "ACST": "Australian Central Standard Time", "ACDT": "Australian Central Daylight Time", "ChST": "Chamorro Standard Time", "ADT": "Atlantic Daylight Time", "WAT": "West Africa Standard Time", "EST": "Eastern Standard Time", "BT": "Bhutan Time", "WAST": "West Africa Summer Time", "JST": "Japan Standard Time", "VET": "Venezuela Time", "ARST": "Argentina Summer Time", "AKDT": "Alaska Daylight Time", "SRT": "Suriname Time", "HAST": "Hawaii-Aleutian Standard Time", "BOT": "Bolivia Time", "MESZ": "Central European Summer Time", "WESZ": "Western European Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "UYST": "Uruguay Summer Time", "EDT": "Eastern Daylight Time", "WITA": "Central Indonesia Time", "JDT": "Japan Daylight Time", "AST": "Atlantic Standard Time", "CHAST": "Chatham Standard Time", "CHADT": "Chatham Daylight Time", "NZST": "New Zealand Standard Time", "WEZ": "Western European Standard Time", "HNEG": "East Greenland Standard Time", "AEST": "Australian Eastern Standard Time", "HECU": "Cuba Daylight Time", "ECT": "Ecuador Time", "CAT": "Central Africa Time", "MYT": "Malaysia Time", "WART": "Western Argentina Standard Time", "WARST": "Western Argentina Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "GFT": "French Guiana Time", "SAST": "South Africa Standard Time", "TMT": "Turkmenistan Standard Time", "CST": "Central Standard Time", "AWST": "Australian Western Standard Time", "CLST": "Chile Summer Time", "HEEG": "East Greenland Summer Time", "HAT": "Newfoundland Daylight Time", "EAT": "East Africa Time", "SGT": "Singapore Standard Time", "NZDT": "New Zealand Daylight Time", "HEOG": "West Greenland Summer Time", "∅∅∅": "Acre Summer Time", "HNPMX": "Mexican Pacific Standard Time", "HNCU": "Cuba Standard Time", "COST": "Colombia Summer Time", "AEDT": "Australian Eastern Daylight Time", "ACWST": "Australian Central Western Standard Time", "MEZ": "Central European Standard Time", "COT": "Colombia Standard Time", "MDT": "Mountain Daylight Time", "UYT": "Uruguay Standard Time", "IST": "India Standard Time", "HNOG": "West Greenland Standard Time", "MST": "Mountain Standard Time", "AWDT": "Australian Western Daylight Time", "PST": "Pacific Standard Time", "AKST": "Alaska Standard Time", "CDT": "Central Daylight Time", "WIT": "Eastern Indonesia Time", "PDT": "Pacific Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "ART": "Argentina Standard Time", "HKST": "Hong Kong Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "HNT": "Newfoundland Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMST": "Turkmenistan Summer Time", "HKT": "Hong Kong Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_GD) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_GD' +func (en *en_GD) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GD' +func (en *en_GD) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_GD' +func (en *en_GD) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GD' +func (en *en_GD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GD' +func (en *en_GD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GD' +func (en *en_GD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_GD) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_GD) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_GD) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_GD) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_GD) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_GD) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_GD) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_GD) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_GD) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_GD) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_GD) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_GD) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_GD) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_GD) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_GD' and handles both Whole and Real numbers based on 'v' +func (en *en_GD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_GD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_GD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GD' +func (en *en_GD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GD' +// in accounting notation. +func (en *en_GD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_GD' +func (en *en_GD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_GD' +func (en *en_GD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_GD' +func (en *en_GD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_GD' +func (en *en_GD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_GD' +func (en *en_GD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_GD' +func (en *en_GD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_GD' +func (en *en_GD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_GD' +func (en *en_GD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_GD/en_GD_test.go b/vendor/github.com/go-playground/locales/en_GD/en_GD_test.go new file mode 100644 index 0000000000..6b92f468a5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GD/en_GD_test.go @@ -0,0 +1,1120 @@ +package en_GD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_GD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_GG/en_GG.go b/vendor/github.com/go-playground/locales/en_GG/en_GG.go new file mode 100644 index 0000000000..31de51360a --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GG/en_GG.go @@ -0,0 +1,607 @@ +package en_GG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_GG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_GG' locale +func New() locales.Translator { + return &en_GG{ + locale: "en_GG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ACWST": "Australian Central Western Standard Time", "WART": "Western Argentina Standard Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "CHADT": "Chatham Daylight Time", "CST": "Central Standard Time", "WEZ": "Western European Standard Time", "MYT": "Malaysia Time", "ACST": "Australian Central Standard Time", "HNT": "Newfoundland Standard Time", "LHDT": "Lord Howe Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "GYT": "Guyana Time", "WIB": "Western Indonesia Time", "HNCU": "Cuba Standard Time", "WIT": "Eastern Indonesia Time", "HKT": "Hong Kong Standard Time", "HNEG": "East Greenland Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ADT": "Atlantic Daylight Time", "OESZ": "Eastern European Summer Time", "AWDT": "Australian Western Daylight Time", "NZST": "New Zealand Standard Time", "VET": "Venezuela Time", "GFT": "French Guiana Time", "ECT": "Ecuador Time", "ACWDT": "Australian Central Western Daylight Time", "UYST": "Uruguay Summer Time", "BOT": "Bolivia Time", "GMT": "Greenwich Mean Time", "CLT": "Chile Standard Time", "MST": "Macau Standard Time", "ARST": "Argentina Summer Time", "COST": "Colombia Summer Time", "EDT": "Eastern Daylight Time", "JDT": "Japan Daylight Time", "UYT": "Uruguay Standard Time", "SAST": "South Africa Standard Time", "AWST": "Australian Western Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "COT": "Colombia Standard Time", "∅∅∅": "Acre Summer Time", "WARST": "Western Argentina Summer Time", "HAT": "Newfoundland Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "WESZ": "Western European Summer Time", "LHST": "Lord Howe Standard Time", "CHAST": "Chatham Standard Time", "NZDT": "New Zealand Daylight Time", "ART": "Argentina Standard Time", "ACDT": "Australian Central Daylight Time", "AKDT": "Alaska Daylight Time", "TMST": "Turkmenistan Summer Time", "MDT": "Macau Summer Time", "BT": "Bhutan Time", "OEZ": "Eastern European Standard Time", "SGT": "Singapore Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "WITA": "Central Indonesia Time", "ChST": "Chamorro Standard Time", "MEZ": "Central European Standard Time", "HNOG": "West Greenland Standard Time", "AEST": "Australian Eastern Standard Time", "AEDT": "Australian Eastern Daylight Time", "AKST": "Alaska Standard Time", "HEOG": "West Greenland Summer Time", "AST": "Atlantic Standard Time", "EST": "Eastern Standard Time", "HECU": "Cuba Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "EAT": "East Africa Time", "IST": "India Standard Time", "CLST": "Chile Summer Time", "WAST": "West Africa Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SRT": "Suriname Time", "CDT": "Central Daylight Time", "CAT": "Central Africa Time", "JST": "Japan Standard Time", "MESZ": "Central European Summer Time", "HEEG": "East Greenland Summer Time", "PST": "Pacific Standard Time", "PDT": "Pacific Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_GG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_GG' +func (en *en_GG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GG' +func (en *en_GG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_GG' +func (en *en_GG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GG' +func (en *en_GG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GG' +func (en *en_GG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GG' +func (en *en_GG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_GG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_GG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_GG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_GG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_GG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_GG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_GG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_GG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_GG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_GG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_GG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_GG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_GG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_GG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_GG' and handles both Whole and Real numbers based on 'v' +func (en *en_GG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_GG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_GG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GG' +func (en *en_GG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GG' +// in accounting notation. +func (en *en_GG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_GG' +func (en *en_GG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_GG' +func (en *en_GG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_GG' +func (en *en_GG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_GG' +func (en *en_GG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_GG' +func (en *en_GG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_GG' +func (en *en_GG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_GG' +func (en *en_GG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_GG' +func (en *en_GG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_GG/en_GG_test.go b/vendor/github.com/go-playground/locales/en_GG/en_GG_test.go new file mode 100644 index 0000000000..66b83cbc90 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GG/en_GG_test.go @@ -0,0 +1,1120 @@ +package en_GG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_GG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_GH/en_GH.go b/vendor/github.com/go-playground/locales/en_GH/en_GH.go new file mode 100644 index 0000000000..7497ec9cd6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GH/en_GH.go @@ -0,0 +1,645 @@ +package en_GH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_GH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_GH' locale +func New() locales.Translator { + return &en_GH{ + locale: "en_GH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GH₵", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"PDT": "Pacific Daylight Time", "GMT": "Greenwich Mean Time", "EDT": "Eastern Daylight Time", "HEEG": "East Greenland Summer Time", "WITA": "Central Indonesia Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "CDT": "Central Daylight Time", "AWDT": "Australian Western Daylight Time", "ECT": "Ecuador Time", "PST": "Pacific Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "ChST": "Chamorro Standard Time", "LHDT": "Lord Howe Daylight Time", "GYT": "Guyana Time", "CHADT": "Chatham Daylight Time", "NZDT": "New Zealand Daylight Time", "MDT": "Macau Summer Time", "SAST": "South Africa Standard Time", "HNT": "Newfoundland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "OESZ": "Eastern European Summer Time", "BT": "Bhutan Time", "VET": "Venezuela Time", "JST": "Japan Standard Time", "WART": "Western Argentina Standard Time", "WAST": "West Africa Summer Time", "AEST": "Australian Eastern Standard Time", "GFT": "French Guiana Time", "AKST": "Alaska Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "WIB": "Western Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "∅∅∅": "Amazon Summer Time", "WESZ": "Western European Summer Time", "TMT": "Turkmenistan Standard Time", "ARST": "Argentina Summer Time", "COST": "Colombia Summer Time", "HAT": "Newfoundland Daylight Time", "CHAST": "Chatham Standard Time", "BOT": "Bolivia Time", "CAT": "Central Africa Time", "MEZ": "Central European Standard Time", "AST": "Atlantic Standard Time", "MST": "Macau Standard Time", "HKT": "Hong Kong Standard Time", "SGT": "Singapore Standard Time", "IST": "India Standard Time", "CLT": "Chile Standard Time", "HECU": "Cuba Daylight Time", "AWST": "Australian Western Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "WARST": "Western Argentina Summer Time", "CLST": "Chile Summer Time", "HNOG": "West Greenland Standard Time", "WAT": "West Africa Standard Time", "EST": "Eastern Standard Time", "ACST": "Australian Central Standard Time", "ADT": "Atlantic Daylight Time", "UYT": "Uruguay Standard Time", "LHST": "Lord Howe Standard Time", "NZST": "New Zealand Standard Time", "ACWDT": "Australian Central Western Daylight Time", "MYT": "Malaysia Time", "HKST": "Hong Kong Summer Time", "COT": "Colombia Standard Time", "JDT": "Japan Daylight Time", "TMST": "Turkmenistan Summer Time", "ART": "Argentina Standard Time", "ACDT": "Australian Central Daylight Time", "AKDT": "Alaska Daylight Time", "UYST": "Uruguay Summer Time", "WIT": "Eastern Indonesia Time", "ACWST": "Australian Central Western Standard Time", "HEOG": "West Greenland Summer Time", "HNEG": "East Greenland Standard Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "MESZ": "Central European Summer Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "AEDT": "Australian Eastern Daylight Time", "SRT": "Suriname Time", "CST": "Central Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_GH) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_GH' +func (en *en_GH) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GH' +func (en *en_GH) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_GH' +func (en *en_GH) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GH' +func (en *en_GH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GH' +func (en *en_GH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GH' +func (en *en_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_GH) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_GH) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_GH) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_GH) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_GH) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_GH) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_GH) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_GH) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_GH) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_GH) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_GH) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_GH) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_GH) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_GH) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_GH' and handles both Whole and Real numbers based on 'v' +func (en *en_GH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_GH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_GH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GH' +func (en *en_GH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GH' +// in accounting notation. +func (en *en_GH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_GH' +func (en *en_GH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_GH' +func (en *en_GH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_GH' +func (en *en_GH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_GH' +func (en *en_GH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_GH' +func (en *en_GH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_GH' +func (en *en_GH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_GH' +func (en *en_GH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_GH' +func (en *en_GH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_GH/en_GH_test.go b/vendor/github.com/go-playground/locales/en_GH/en_GH_test.go new file mode 100644 index 0000000000..967042006c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GH/en_GH_test.go @@ -0,0 +1,1120 @@ +package en_GH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_GH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_GI/en_GI.go b/vendor/github.com/go-playground/locales/en_GI/en_GI.go new file mode 100644 index 0000000000..b493116853 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GI/en_GI.go @@ -0,0 +1,597 @@ +package en_GI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_GI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_GI' locale +func New() locales.Translator { + return &en_GI{ + locale: "en_GI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GB£", "GEK", "GEL", "GHC", "GHS", "£", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HKST": "Hong Kong Summer Time", "PDT": "Pacific Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "WIB": "Western Indonesia Time", "CLT": "Chile Standard Time", "CLST": "Chile Summer Time", "EST": "Eastern Standard Time", "HEEG": "East Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "HNOG": "West Greenland Standard Time", "EDT": "Eastern Daylight Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "BT": "Bhutan Time", "ECT": "Ecuador Time", "NZST": "New Zealand Standard Time", "MEZ": "Central European Standard Time", "OESZ": "Eastern European Summer Time", "HKT": "Hong Kong Standard Time", "SAST": "South Africa Standard Time", "HECU": "Cuba Daylight Time", "CHAST": "Chatham Standard Time", "MESZ": "Central European Summer Time", "WART": "Western Argentina Standard Time", "MDT": "Macau Summer Time", "GYT": "Guyana Time", "ACWDT": "Australian Central Western Daylight Time", "ACDT": "Australian Central Daylight Time", "WITA": "Central Indonesia Time", "ChST": "Chamorro Standard Time", "NZDT": "New Zealand Daylight Time", "JDT": "Japan Daylight Time", "COST": "Colombia Summer Time", "HNPMX": "Mexican Pacific Standard Time", "WIT": "Eastern Indonesia Time", "AWST": "Australian Western Standard Time", "PST": "Pacific Standard Time", "ART": "Argentina Standard Time", "GFT": "French Guiana Time", "HNCU": "Cuba Standard Time", "CHADT": "Chatham Daylight Time", "AWDT": "Australian Western Daylight Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "ARST": "Argentina Summer Time", "MST": "Macau Standard Time", "UYST": "Uruguay Summer Time", "AST": "Atlantic Standard Time", "ACST": "Australian Central Standard Time", "AEST": "Australian Eastern Standard Time", "EAT": "East Africa Time", "ACWST": "Australian Central Western Standard Time", "LHST": "Lord Howe Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "GMT": "Greenwich Mean Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "∅∅∅": "Acre Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "TMT": "Turkmenistan Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "UYT": "Uruguay Standard Time", "CAT": "Central Africa Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "VET": "Venezuela Time", "MYT": "Malaysia Time", "ADT": "Atlantic Daylight Time", "TMST": "Turkmenistan Summer Time", "LHDT": "Lord Howe Daylight Time", "SRT": "Suriname Time", "JST": "Japan Standard Time", "IST": "India Standard Time", "HEOG": "West Greenland Summer Time", "WAT": "West Africa Standard Time", "HNEG": "East Greenland Standard Time", "AKDT": "Alaska Daylight Time", "CDT": "Central Daylight Time", "WESZ": "Western European Summer Time", "WARST": "Western Argentina Summer Time", "CST": "Central Standard Time", "WAST": "West Africa Summer Time", "AKST": "Alaska Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_GI) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_GI' +func (en *en_GI) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GI' +func (en *en_GI) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_GI' +func (en *en_GI) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GI' +func (en *en_GI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GI' +func (en *en_GI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GI' +func (en *en_GI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_GI) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_GI) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_GI) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_GI) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_GI) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_GI) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_GI) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_GI) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_GI) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_GI) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_GI) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_GI) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_GI) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_GI) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_GI' and handles both Whole and Real numbers based on 'v' +func (en *en_GI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_GI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_GI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GI' +func (en *en_GI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GI' +// in accounting notation. +func (en *en_GI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_GI' +func (en *en_GI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_GI' +func (en *en_GI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_GI' +func (en *en_GI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_GI' +func (en *en_GI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_GI' +func (en *en_GI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_GI' +func (en *en_GI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_GI' +func (en *en_GI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_GI' +func (en *en_GI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_GI/en_GI_test.go b/vendor/github.com/go-playground/locales/en_GI/en_GI_test.go new file mode 100644 index 0000000000..9d7d3c363c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GI/en_GI_test.go @@ -0,0 +1,1120 @@ +package en_GI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_GI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_GM/en_GM.go b/vendor/github.com/go-playground/locales/en_GM/en_GM.go new file mode 100644 index 0000000000..4cb80ef0f5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GM/en_GM.go @@ -0,0 +1,645 @@ +package en_GM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_GM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_GM' locale +func New() locales.Translator { + return &en_GM{ + locale: "en_GM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "D", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"SAST": "South Africa Standard Time", "ART": "Argentina Standard Time", "EDT": "Eastern Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "HNT": "Newfoundland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CAT": "Central Africa Time", "IST": "India Standard Time", "HKT": "Hong Kong Standard Time", "HNEG": "East Greenland Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "MEZ": "Central European Standard Time", "WITA": "Central Indonesia Time", "AKST": "Alaska Standard Time", "AEDT": "Australian Eastern Daylight Time", "ARST": "Argentina Summer Time", "COT": "Colombia Standard Time", "HEEG": "East Greenland Summer Time", "EAT": "East Africa Time", "∅∅∅": "Amazon Summer Time", "HEOG": "West Greenland Summer Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "SRT": "Suriname Time", "WIB": "Western Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "VET": "Venezuela Time", "JST": "Japan Standard Time", "AST": "Atlantic Standard Time", "ChST": "Chamorro Standard Time", "JDT": "Japan Daylight Time", "GMT": "Greenwich Mean Time", "MST": "Macau Standard Time", "WIT": "Eastern Indonesia Time", "OESZ": "Eastern European Summer Time", "MYT": "Malaysia Time", "TMT": "Turkmenistan Standard Time", "UYST": "Uruguay Summer Time", "COST": "Colombia Summer Time", "HAT": "Newfoundland Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "WART": "Western Argentina Standard Time", "HNOG": "West Greenland Standard Time", "HKST": "Hong Kong Summer Time", "ACDT": "Australian Central Daylight Time", "AWST": "Australian Western Standard Time", "MESZ": "Central European Summer Time", "TMST": "Turkmenistan Summer Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "AKDT": "Alaska Daylight Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "ACWST": "Australian Central Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "NZST": "New Zealand Standard Time", "CLT": "Chile Standard Time", "AEST": "Australian Eastern Standard Time", "LHST": "Lord Howe Standard Time", "CHAST": "Chatham Standard Time", "PDT": "Pacific Daylight Time", "CLST": "Chile Summer Time", "EST": "Eastern Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "GFT": "French Guiana Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "AWDT": "Australian Western Daylight Time", "WAST": "West Africa Summer Time", "ACST": "Australian Central Standard Time", "HNPMX": "Mexican Pacific Standard Time", "GYT": "Guyana Time", "NZDT": "New Zealand Daylight Time", "ADT": "Atlantic Daylight Time", "WESZ": "Western European Summer Time", "WAT": "West Africa Standard Time", "ECT": "Ecuador Time", "WARST": "Western Argentina Summer Time", "MDT": "Macau Summer Time", "BT": "Bhutan Time", "CDT": "Central Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_GM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_GM' +func (en *en_GM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GM' +func (en *en_GM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_GM' +func (en *en_GM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GM' +func (en *en_GM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GM' +func (en *en_GM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GM' +func (en *en_GM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_GM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_GM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_GM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_GM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_GM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_GM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_GM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_GM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_GM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_GM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_GM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_GM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_GM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_GM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_GM' and handles both Whole and Real numbers based on 'v' +func (en *en_GM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_GM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_GM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GM' +func (en *en_GM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GM' +// in accounting notation. +func (en *en_GM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_GM' +func (en *en_GM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_GM' +func (en *en_GM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_GM' +func (en *en_GM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_GM' +func (en *en_GM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_GM' +func (en *en_GM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_GM' +func (en *en_GM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_GM' +func (en *en_GM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_GM' +func (en *en_GM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_GM/en_GM_test.go b/vendor/github.com/go-playground/locales/en_GM/en_GM_test.go new file mode 100644 index 0000000000..ef80595faf --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GM/en_GM_test.go @@ -0,0 +1,1120 @@ +package en_GM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_GM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_GU/en_GU.go b/vendor/github.com/go-playground/locales/en_GU/en_GU.go new file mode 100644 index 0000000000..4d6a97bc36 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GU/en_GU.go @@ -0,0 +1,635 @@ +package en_GU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_GU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_GU' locale +func New() locales.Translator { + return &en_GU{ + locale: "en_GU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HAT": "Newfoundland Daylight Time", "GFT": "French Guiana Time", "ACST": "Australian Central Standard Time", "WEZ": "Western European Standard Time", "TMT": "Turkmenistan Standard Time", "JST": "Japan Standard Time", "HEOG": "West Greenland Summer Time", "OEZ": "Eastern European Standard Time", "MYT": "Malaysia Time", "ART": "Argentina Standard Time", "ARST": "Argentina Summer Time", "EDT": "Eastern Daylight Time", "HNEG": "East Greenland Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "ECT": "Ecuador Time", "ACWDT": "Australian Central Western Daylight Time", "∅∅∅": "Azores Summer Time", "NZDT": "New Zealand Daylight Time", "CLST": "Chile Summer Time", "AKDT": "Alaska Daylight Time", "UYST": "Uruguay Summer Time", "CHAST": "Chatham Standard Time", "WIT": "Eastern Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "GMT": "Greenwich Mean Time", "COST": "Colombia Summer Time", "AEDT": "Australian Eastern Daylight Time", "LHST": "Lord Howe Standard Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "WITA": "Central Indonesia Time", "AEST": "Australian Eastern Standard Time", "PDT": "Pacific Daylight Time", "EAT": "East Africa Time", "AWDT": "Australian Western Daylight Time", "PST": "Pacific Standard Time", "HNOG": "West Greenland Standard Time", "MDT": "Macau Summer Time", "COT": "Colombia Standard Time", "SRT": "Suriname Time", "WAST": "West Africa Summer Time", "HKT": "Hong Kong Standard Time", "HEEG": "East Greenland Summer Time", "UYT": "Uruguay Standard Time", "TMST": "Turkmenistan Summer Time", "WIB": "Western Indonesia Time", "AWST": "Australian Western Standard Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "NZST": "New Zealand Standard Time", "MESZ": "Central European Summer Time", "WART": "Western Argentina Standard Time", "SAST": "South Africa Standard Time", "CLT": "Chile Standard Time", "EST": "Eastern Standard Time", "AKST": "Alaska Standard Time", "WARST": "Western Argentina Summer Time", "HNPMX": "Mexican Pacific Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "ADT": "Atlantic Daylight Time", "WESZ": "Western European Summer Time", "ChST": "Chamorro Standard Time", "LHDT": "Lord Howe Daylight Time", "MEZ": "Central European Standard Time", "VET": "Venezuela Time", "HKST": "Hong Kong Summer Time", "HNT": "Newfoundland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CHADT": "Chatham Daylight Time", "CAT": "Central Africa Time", "JDT": "Japan Daylight Time", "WAT": "West Africa Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "GYT": "Guyana Time", "AST": "Atlantic Standard Time", "MST": "Macau Standard Time", "CST": "Central Standard Time", "HECU": "Cuba Daylight Time", "CDT": "Central Daylight Time", "IST": "India Standard Time", "ACWST": "Australian Central Western Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HNCU": "Cuba Standard Time", "OESZ": "Eastern European Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_GU) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_GU' +func (en *en_GU) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GU' +func (en *en_GU) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_GU' +func (en *en_GU) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GU' +func (en *en_GU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GU' +func (en *en_GU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GU' +func (en *en_GU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_GU) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_GU) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_GU) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_GU) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_GU) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_GU) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_GU) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_GU) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_GU) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_GU) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_GU) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_GU) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_GU) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_GU) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_GU' and handles both Whole and Real numbers based on 'v' +func (en *en_GU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_GU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_GU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GU' +func (en *en_GU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GU' +// in accounting notation. +func (en *en_GU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_GU' +func (en *en_GU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_GU' +func (en *en_GU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_GU' +func (en *en_GU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_GU' +func (en *en_GU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_GU' +func (en *en_GU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_GU' +func (en *en_GU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_GU' +func (en *en_GU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_GU' +func (en *en_GU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_GU/en_GU_test.go b/vendor/github.com/go-playground/locales/en_GU/en_GU_test.go new file mode 100644 index 0000000000..a4873a6484 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GU/en_GU_test.go @@ -0,0 +1,1120 @@ +package en_GU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_GU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_GY/en_GY.go b/vendor/github.com/go-playground/locales/en_GY/en_GY.go new file mode 100644 index 0000000000..b7cd92eab4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GY/en_GY.go @@ -0,0 +1,645 @@ +package en_GY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_GY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_GY' locale +func New() locales.Translator { + return &en_GY{ + locale: "en_GY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "$", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WAT": "West Africa Standard Time", "UYT": "Uruguay Standard Time", "UYST": "Uruguay Summer Time", "NZDT": "New Zealand Daylight Time", "MESZ": "Central European Summer Time", "OESZ": "Eastern European Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMST": "Turkmenistan Summer Time", "HNT": "Newfoundland Standard Time", "WIB": "Western Indonesia Time", "CST": "Central Standard Time", "AWST": "Australian Western Standard Time", "CHADT": "Chatham Daylight Time", "AKST": "Alaska Standard Time", "AKDT": "Alaska Daylight Time", "WESZ": "Western European Summer Time", "SAST": "South Africa Standard Time", "JDT": "Japan Daylight Time", "EDT": "Eastern Daylight Time", "ECT": "Ecuador Time", "MEZ": "Central European Standard Time", "JST": "Japan Standard Time", "HEEG": "East Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "SGT": "Singapore Standard Time", "ADT": "Atlantic Daylight Time", "OEZ": "Eastern European Standard Time", "HNOG": "West Greenland Standard Time", "AST": "Atlantic Standard Time", "ACST": "Australian Central Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHDT": "Lord Howe Daylight Time", "BOT": "Bolivia Time", "CLT": "Chile Standard Time", "HKT": "Hong Kong Standard Time", "HNEG": "East Greenland Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "GMT": "Greenwich Mean Time", "WARST": "Western Argentina Summer Time", "TMT": "Turkmenistan Standard Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "WITA": "Central Indonesia Time", "ART": "Argentina Standard Time", "ACDT": "Australian Central Daylight Time", "MST": "Mountain Standard Time", "EAT": "East Africa Time", "IST": "India Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "BT": "Bhutan Time", "HEPMX": "Mexican Pacific Daylight Time", "HNCU": "Cuba Standard Time", "WIT": "Eastern Indonesia Time", "ARST": "Argentina Summer Time", "EST": "Eastern Standard Time", "GFT": "French Guiana Time", "LHST": "Lord Howe Standard Time", "HECU": "Cuba Daylight Time", "PST": "Pacific Standard Time", "VET": "Venezuela Time", "COST": "Colombia Summer Time", "ChST": "Chamorro Standard Time", "CDT": "Central Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "NZST": "New Zealand Standard Time", "CLST": "Chile Summer Time", "WAST": "West Africa Summer Time", "HKST": "Hong Kong Summer Time", "∅∅∅": "Acre Summer Time", "MDT": "Mountain Daylight Time", "GYT": "Guyana Time", "PDT": "Pacific Daylight Time", "ACWST": "Australian Central Western Standard Time", "HAT": "Newfoundland Daylight Time", "AEST": "Australian Eastern Standard Time", "SRT": "Suriname Time", "CHAST": "Chatham Standard Time", "MYT": "Malaysia Time", "AWDT": "Australian Western Daylight Time", "CAT": "Central Africa Time", "HEOG": "West Greenland Summer Time", "WEZ": "Western European Standard Time", "WART": "Western Argentina Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_GY) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_GY' +func (en *en_GY) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_GY' +func (en *en_GY) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_GY' +func (en *en_GY) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_GY' +func (en *en_GY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_GY' +func (en *en_GY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_GY' +func (en *en_GY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_GY) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_GY) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_GY) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_GY) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_GY) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_GY) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_GY) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_GY) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_GY) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_GY) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_GY) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_GY) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_GY) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_GY) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_GY' and handles both Whole and Real numbers based on 'v' +func (en *en_GY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_GY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_GY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_GY' +func (en *en_GY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_GY' +// in accounting notation. +func (en *en_GY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_GY' +func (en *en_GY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_GY' +func (en *en_GY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_GY' +func (en *en_GY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_GY' +func (en *en_GY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_GY' +func (en *en_GY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_GY' +func (en *en_GY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_GY' +func (en *en_GY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_GY' +func (en *en_GY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_GY/en_GY_test.go b/vendor/github.com/go-playground/locales/en_GY/en_GY_test.go new file mode 100644 index 0000000000..be496665cf --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_GY/en_GY_test.go @@ -0,0 +1,1120 @@ +package en_GY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_GY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_HK/en_HK.go b/vendor/github.com/go-playground/locales/en_HK/en_HK.go new file mode 100644 index 0000000000..8b98f2ab55 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_HK/en_HK.go @@ -0,0 +1,597 @@ +package en_HK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_HK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_HK' locale +func New() locales.Translator { + return &en_HK{ + locale: "en_HK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"CAT": "Central Africa Time", "ADT": "Atlantic Daylight Time", "WEZ": "Western European Standard Time", "CLST": "Chile Summer Time", "MST": "Macau Standard Time", "ART": "Argentina Standard Time", "WAT": "West Africa Standard Time", "EST": "Eastern Standard Time", "BT": "Bhutan Time", "TMST": "Turkmenistan Summer Time", "AKST": "Alaska Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "PDT": "Pacific Daylight Time", "VET": "Venezuela Time", "OESZ": "Eastern European Summer Time", "AEDT": "Australian Eastern Daylight Time", "∅∅∅": "Brasilia Summer Time", "SGT": "Singapore Standard Time", "ACWDT": "Australian Central Western Daylight Time", "AST": "Atlantic Standard Time", "WART": "Western Argentina Standard Time", "WITA": "Central Indonesia Time", "AEST": "Australian Eastern Standard Time", "HNPMX": "Mexican Pacific Standard Time", "SRT": "Suriname Time", "EAT": "East Africa Time", "HECU": "Cuba Daylight Time", "CHAST": "Chatham Standard Time", "BOT": "Bolivia Time", "OEZ": "Eastern European Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HNT": "Newfoundland Standard Time", "HNEG": "East Greenland Standard Time", "GFT": "French Guiana Time", "HAST": "Hawaii-Aleutian Standard Time", "IST": "India Standard Time", "WARST": "Western Argentina Summer Time", "ARST": "Argentina Summer Time", "COT": "Colombia Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HNCU": "Cuba Standard Time", "AWDT": "Australian Western Daylight Time", "ACWST": "Australian Central Western Standard Time", "HNOG": "West Greenland Standard Time", "WESZ": "Western European Summer Time", "ACDT": "Australian Central Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMT": "Turkmenistan Standard Time", "UYST": "Uruguay Summer Time", "CST": "Central Standard Time", "ACST": "Australian Central Standard Time", "HAT": "Newfoundland Daylight Time", "HEEG": "East Greenland Summer Time", "PST": "Pacific Standard Time", "MDT": "Macau Summer Time", "HKT": "Hong Kong Standard Time", "COST": "Colombia Summer Time", "LHDT": "Lord Howe Daylight Time", "GYT": "Guyana Time", "AWST": "Australian Western Standard Time", "CHADT": "Chatham Daylight Time", "CLT": "Chile Standard Time", "WAST": "West Africa Summer Time", "HKST": "Hong Kong Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "UYT": "Uruguay Standard Time", "SAST": "South Africa Standard Time", "NZST": "New Zealand Standard Time", "HEOG": "West Greenland Summer Time", "MYT": "Malaysia Time", "EDT": "Eastern Daylight Time", "AKDT": "Alaska Daylight Time", "WIB": "Western Indonesia Time", "LHST": "Lord Howe Standard Time", "WIT": "Eastern Indonesia Time", "MEZ": "Central European Standard Time", "MESZ": "Central European Summer Time", "CDT": "Central Daylight Time", "ECT": "Ecuador Time", "NZDT": "New Zealand Daylight Time", "JST": "Japan Standard Time", "JDT": "Japan Daylight Time", "GMT": "Greenwich Mean Time", "ChST": "Chamorro Standard Time", "HEPMX": "Mexican Pacific Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_HK) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_HK' +func (en *en_HK) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_HK' +func (en *en_HK) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_HK' +func (en *en_HK) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_HK' +func (en *en_HK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_HK' +func (en *en_HK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_HK' +func (en *en_HK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_HK) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_HK) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_HK) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_HK) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_HK) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_HK) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_HK) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_HK) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_HK) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_HK) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_HK) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_HK) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_HK) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_HK) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_HK' and handles both Whole and Real numbers based on 'v' +func (en *en_HK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_HK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_HK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_HK' +func (en *en_HK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_HK' +// in accounting notation. +func (en *en_HK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_HK' +func (en *en_HK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_HK' +func (en *en_HK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_HK' +func (en *en_HK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_HK' +func (en *en_HK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_HK' +func (en *en_HK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_HK' +func (en *en_HK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_HK' +func (en *en_HK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_HK' +func (en *en_HK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_HK/en_HK_test.go b/vendor/github.com/go-playground/locales/en_HK/en_HK_test.go new file mode 100644 index 0000000000..c25ded2a86 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_HK/en_HK_test.go @@ -0,0 +1,1120 @@ +package en_HK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_HK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_IE/en_IE.go b/vendor/github.com/go-playground/locales/en_IE/en_IE.go new file mode 100644 index 0000000000..dd8de68bda --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IE/en_IE.go @@ -0,0 +1,597 @@ +package en_IE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_IE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_IE' locale +func New() locales.Translator { + return &en_IE{ + locale: "en_IE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WIT": "Eastern Indonesia Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "HEEG": "East Greenland Summer Time", "AKDT": "Alaska Daylight Time", "EDT": "Eastern Daylight Time", "HKST": "Hong Kong Summer Time", "WIB": "Western Indonesia Time", "HNNOMX": "Northwest Mexico Standard Time", "PST": "Pacific Standard Time", "NZST": "New Zealand Standard Time", "CAT": "Central Africa Time", "WESZ": "Western European Summer Time", "TMST": "Turkmenistan Summer Time", "MDT": "Macau Summer Time", "AWDT": "Australian Western Daylight Time", "ACWST": "Australian Central Western Standard Time", "MEZ": "Central European Standard Time", "HNT": "Newfoundland Standard Time", "NZDT": "New Zealand Daylight Time", "VET": "Venezuela Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "WEZ": "Western European Standard Time", "WAST": "West Africa Summer Time", "CDT": "Central Daylight Time", "SAST": "South Africa Standard Time", "EAT": "East Africa Time", "ACWDT": "Australian Central Western Daylight Time", "ART": "Argentina Standard Time", "ARST": "Argentina Summer Time", "HNEG": "East Greenland Standard Time", "AKST": "Alaska Standard Time", "LHDT": "Lord Howe Daylight Time", "JST": "Japan Standard Time", "HAT": "Newfoundland Daylight Time", "ChST": "Chamorro Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "MST": "Macau Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "CST": "Central Standard Time", "CHAST": "Chatham Standard Time", "BOT": "Bolivia Time", "JDT": "Japan Daylight Time", "AST": "Atlantic Standard Time", "TMT": "Turkmenistan Standard Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time", "GYT": "Guyana Time", "HADT": "Hawaii-Aleutian Daylight Time", "WARST": "Western Argentina Summer Time", "CLST": "Chile Summer Time", "OESZ": "Eastern European Summer Time", "BT": "Bhutan Time", "GFT": "French Guiana Time", "∅∅∅": "Brasilia Summer Time", "ADT": "Atlantic Daylight Time", "WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "WART": "Western Argentina Standard Time", "LHST": "Lord Howe Standard Time", "HECU": "Cuba Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "WAT": "West Africa Standard Time", "EST": "Eastern Standard Time", "ACDT": "Australian Central Daylight Time", "COT": "Colombia Standard Time", "UYST": "Uruguay Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNCU": "Cuba Standard Time", "AWST": "Australian Western Standard Time", "ECT": "Ecuador Time", "IST": "India Standard Time", "MESZ": "Central European Summer Time", "GMT": "Greenwich Mean Time", "AEDT": "Australian Eastern Daylight Time", "OEZ": "Eastern European Standard Time", "COST": "Colombia Summer Time", "HNPMX": "Mexican Pacific Standard Time", "PDT": "Pacific Daylight Time", "MYT": "Malaysia Time", "CLT": "Chile Standard Time", "HKT": "Hong Kong Standard Time", "ACST": "Australian Central Standard Time", "SRT": "Suriname Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_IE) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_IE' +func (en *en_IE) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_IE' +func (en *en_IE) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_IE' +func (en *en_IE) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_IE' +func (en *en_IE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_IE' +func (en *en_IE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_IE' +func (en *en_IE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_IE) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_IE) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_IE) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_IE) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_IE) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_IE) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_IE) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_IE) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_IE) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_IE) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_IE) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_IE) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_IE) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_IE) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_IE' and handles both Whole and Real numbers based on 'v' +func (en *en_IE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_IE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_IE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_IE' +func (en *en_IE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_IE' +// in accounting notation. +func (en *en_IE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_IE' +func (en *en_IE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_IE' +func (en *en_IE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_IE' +func (en *en_IE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_IE' +func (en *en_IE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_IE' +func (en *en_IE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_IE' +func (en *en_IE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_IE' +func (en *en_IE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_IE' +func (en *en_IE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_IE/en_IE_test.go b/vendor/github.com/go-playground/locales/en_IE/en_IE_test.go new file mode 100644 index 0000000000..3953406a77 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IE/en_IE_test.go @@ -0,0 +1,1120 @@ +package en_IE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_IE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_IL/en_IL.go b/vendor/github.com/go-playground/locales/en_IL/en_IL.go new file mode 100644 index 0000000000..7cdb9aaa71 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IL/en_IL.go @@ -0,0 +1,581 @@ +package en_IL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_IL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_IL' locale +func New() locales.Translator { + return &en_IL{ + locale: "en_IL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ACDT": "Australian Central Daylight Time", "UYST": "Uruguay Summer Time", "ACWST": "Australian Central Western Standard Time", "ACST": "Australian Central Standard Time", "WIT": "Eastern Indonesia Time", "ARST": "Argentina Summer Time", "EDT": "Eastern Daylight Time", "NZDT": "New Zealand Daylight Time", "∅∅∅": "Amazon Summer Time", "WART": "Western Argentina Standard Time", "HNOG": "West Greenland Standard Time", "AST": "Atlantic Standard Time", "HNT": "Newfoundland Standard Time", "AEDT": "Australian Eastern Daylight Time", "UYT": "Uruguay Standard Time", "JST": "Japan Standard Time", "JDT": "Japan Daylight Time", "GYT": "Guyana Time", "ADT": "Atlantic Daylight Time", "TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "WAST": "West Africa Summer Time", "EAT": "East Africa Time", "VET": "Venezuela Time", "CLST": "Chile Summer Time", "HKST": "Hong Kong Summer Time", "HNPMX": "Mexican Pacific Standard Time", "AWDT": "Australian Western Daylight Time", "CHAST": "Chatham Standard Time", "OEZ": "Eastern European Standard Time", "CLT": "Chile Standard Time", "HKT": "Hong Kong Standard Time", "AKDT": "Alaska Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHST": "Lord Howe Standard Time", "SGT": "Singapore Standard Time", "PST": "Pacific Standard Time", "PDT": "Pacific Daylight Time", "GFT": "French Guiana Time", "SAST": "South Africa Standard Time", "TMST": "Turkmenistan Summer Time", "COT": "Colombia Standard Time", "ChST": "Chamorro Standard Time", "AWST": "Australian Western Standard Time", "CHADT": "Chatham Daylight Time", "MYT": "Malaysia Time", "WITA": "Central Indonesia Time", "AEST": "Australian Eastern Standard Time", "BOT": "Bolivia Time", "HAST": "Hawaii-Aleutian Standard Time", "ACWDT": "Australian Central Western Daylight Time", "SRT": "Suriname Time", "HNCU": "Cuba Standard Time", "WIB": "Western Indonesia Time", "HNEG": "East Greenland Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "LHDT": "Lord Howe Daylight Time", "IST": "India Standard Time", "EST": "Eastern Standard Time", "WESZ": "Western European Summer Time", "HEOG": "West Greenland Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "HEEG": "East Greenland Summer Time", "BT": "Bhutan Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "WEZ": "Western European Standard Time", "CST": "Central Standard Time", "CDT": "Central Daylight Time", "GMT": "Greenwich Mean Time", "WARST": "Western Argentina Summer Time", "MST": "Macau Standard Time", "HECU": "Cuba Daylight Time", "CAT": "Central Africa Time", "MEZ": "Central European Standard Time", "ART": "Argentina Standard Time", "MDT": "Macau Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HAT": "Newfoundland Daylight Time", "ECT": "Ecuador Time", "MESZ": "Central European Summer Time", "COST": "Colombia Summer Time", "AKST": "Alaska Standard Time", "NZST": "New Zealand Standard Time", "OESZ": "Eastern European Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_IL) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_IL' +func (en *en_IL) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_IL' +func (en *en_IL) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_IL' +func (en *en_IL) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_IL' +func (en *en_IL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_IL' +func (en *en_IL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_IL' +func (en *en_IL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_IL) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_IL) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_IL) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_IL) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_IL) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_IL) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_IL) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_IL) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_IL) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_IL) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_IL) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_IL) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_IL) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_IL) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_IL' and handles both Whole and Real numbers based on 'v' +func (en *en_IL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_IL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_IL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_IL' +func (en *en_IL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_IL' +// in accounting notation. +func (en *en_IL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_IL' +func (en *en_IL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_IL' +func (en *en_IL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_IL' +func (en *en_IL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_IL' +func (en *en_IL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_IL' +func (en *en_IL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_IL' +func (en *en_IL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_IL' +func (en *en_IL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_IL' +func (en *en_IL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_IL/en_IL_test.go b/vendor/github.com/go-playground/locales/en_IL/en_IL_test.go new file mode 100644 index 0000000000..2718a2a3e0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IL/en_IL_test.go @@ -0,0 +1,1120 @@ +package en_IL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_IL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_IM/en_IM.go b/vendor/github.com/go-playground/locales/en_IM/en_IM.go new file mode 100644 index 0000000000..8efb9418b3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IM/en_IM.go @@ -0,0 +1,597 @@ +package en_IM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_IM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_IM' locale +func New() locales.Translator { + return &en_IM{ + locale: "en_IM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"COT": "Colombia Standard Time", "AST": "Atlantic Standard Time", "OESZ": "Eastern European Summer Time", "AEST": "Australian Eastern Standard Time", "HECU": "Cuba Daylight Time", "AWST": "Australian Western Standard Time", "IST": "India Standard Time", "TMT": "Turkmenistan Standard Time", "PST": "Pacific Standard Time", "HKST": "Hong Kong Summer Time", "CDT": "Central Daylight Time", "TMST": "Turkmenistan Summer Time", "HKT": "Hong Kong Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "NZDT": "New Zealand Daylight Time", "MESZ": "Central European Summer Time", "WIT": "Eastern Indonesia Time", "WAST": "West Africa Summer Time", "ECT": "Ecuador Time", "JDT": "Japan Daylight Time", "MST": "Macau Standard Time", "WIB": "Western Indonesia Time", "HNCU": "Cuba Standard Time", "CHAST": "Chatham Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "ART": "Argentina Standard Time", "AEDT": "Australian Eastern Daylight Time", "CHADT": "Chatham Daylight Time", "WEZ": "Western European Standard Time", "CLST": "Chile Summer Time", "MDT": "Macau Summer Time", "ARST": "Argentina Summer Time", "COST": "Colombia Summer Time", "HNEG": "East Greenland Standard Time", "SAST": "South Africa Standard Time", "EAT": "East Africa Time", "NZST": "New Zealand Standard Time", "WESZ": "Western European Summer Time", "WITA": "Central Indonesia Time", "UYST": "Uruguay Summer Time", "∅∅∅": "Amazon Summer Time", "EDT": "Eastern Daylight Time", "CST": "Central Standard Time", "HNOG": "West Greenland Standard Time", "AKST": "Alaska Standard Time", "WART": "Western Argentina Standard Time", "WARST": "Western Argentina Summer Time", "WAT": "West Africa Standard Time", "ChST": "Chamorro Standard Time", "HNPMX": "Mexican Pacific Standard Time", "ACWST": "Australian Central Western Standard Time", "VET": "Venezuela Time", "BT": "Bhutan Time", "SRT": "Suriname Time", "GYT": "Guyana Time", "ACWDT": "Australian Central Western Daylight Time", "ADT": "Atlantic Daylight Time", "OEZ": "Eastern European Standard Time", "ACST": "Australian Central Standard Time", "HAT": "Newfoundland Daylight Time", "AKDT": "Alaska Daylight Time", "LHST": "Lord Howe Standard Time", "BOT": "Bolivia Time", "CAT": "Central Africa Time", "JST": "Japan Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "PDT": "Pacific Daylight Time", "HEEG": "East Greenland Summer Time", "GFT": "French Guiana Time", "MYT": "Malaysia Time", "ACDT": "Australian Central Daylight Time", "EST": "Eastern Standard Time", "HNT": "Newfoundland Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "AWDT": "Australian Western Daylight Time", "SGT": "Singapore Standard Time", "MEZ": "Central European Standard Time", "GMT": "Greenwich Mean Time", "HENOMX": "Northwest Mexico Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CLT": "Chile Standard Time", "HEOG": "West Greenland Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_IM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_IM' +func (en *en_IM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_IM' +func (en *en_IM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_IM' +func (en *en_IM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_IM' +func (en *en_IM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_IM' +func (en *en_IM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_IM' +func (en *en_IM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_IM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_IM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_IM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_IM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_IM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_IM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_IM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_IM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_IM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_IM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_IM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_IM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_IM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_IM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_IM' and handles both Whole and Real numbers based on 'v' +func (en *en_IM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_IM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_IM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_IM' +func (en *en_IM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_IM' +// in accounting notation. +func (en *en_IM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_IM' +func (en *en_IM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_IM' +func (en *en_IM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_IM' +func (en *en_IM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_IM' +func (en *en_IM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_IM' +func (en *en_IM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_IM' +func (en *en_IM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_IM' +func (en *en_IM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_IM' +func (en *en_IM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_IM/en_IM_test.go b/vendor/github.com/go-playground/locales/en_IM/en_IM_test.go new file mode 100644 index 0000000000..4143a8a6c1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IM/en_IM_test.go @@ -0,0 +1,1120 @@ +package en_IM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_IM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_IN/en_IN.go b/vendor/github.com/go-playground/locales/en_IN/en_IN.go new file mode 100644 index 0000000000..1cb1de49c4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IN/en_IN.go @@ -0,0 +1,646 @@ +package en_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_IN' locale +func New() locales.Translator { + return &en_IN{ + locale: "en_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HNOG": "West Greenland Standard Time", "UYST": "Uruguay Summer Time", "AWST": "Australian Western Standard Time", "WEZ": "Western European Standard Time", "HNT": "Newfoundland Standard Time", "AEDT": "Australian Eastern Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "BOT": "Bolivia Time", "CHADT": "Chatham Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "ACST": "Australian Central Standard Time", "PST": "Pacific Standard Time", "CLT": "Chile Standard Time", "OEZ": "Eastern European Standard Time", "CHAST": "Chatham Standard Time", "CLST": "Chile Summer Time", "HAT": "Newfoundland Daylight Time", "MYT": "Malaysia Time", "EDT": "Eastern Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "OESZ": "Eastern European Summer Time", "WAT": "West Africa Standard Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "CDT": "Central Daylight Time", "SGT": "Singapore Standard Time", "ADT": "Atlantic Daylight Time", "ART": "Argentina Standard Time", "MST": "Mountain Standard Time", "AKDT": "Alaska Daylight Time", "WIT": "Eastern Indonesia Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time", "MESZ": "Central European Summer Time", "ACDT": "Australian Central Daylight Time", "HEEG": "East Greenland Summer Time", "∅∅∅": "Acre Summer Time", "ACWST": "Australian Central Western Standard Time", "HEOG": "West Greenland Summer Time", "WITA": "Central Indonesia Time", "WIB": "Western Indonesia Time", "HNCU": "Cuba Standard Time", "CAT": "Central Africa Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "LHST": "Lord Howe Standard Time", "TMT": "Turkmenistan Standard Time", "GFT": "French Guiana Time", "IST": "India Standard Time", "WART": "Western Argentina Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ChST": "Chamorro Standard Time", "AST": "Atlantic Standard Time", "JST": "Japan Standard Time", "AKST": "Alaska Standard Time", "LHDT": "Lord Howe Daylight Time", "EAT": "East Africa Time", "ECT": "Ecuador Time", "MEZ": "Central European Standard Time", "HKT": "Hong Kong Standard Time", "HKST": "Hong Kong Summer Time", "WAST": "West Africa Summer Time", "HNEG": "East Greenland Standard Time", "GYT": "Guyana Time", "AWDT": "Australian Western Daylight Time", "TMST": "Turkmenistan Summer Time", "COST": "Colombia Summer Time", "SRT": "Suriname Time", "WARST": "Western Argentina Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "PDT": "Pacific Daylight Time", "NZDT": "New Zealand Daylight Time", "JDT": "Japan Daylight Time", "WESZ": "Western European Summer Time", "COT": "Colombia Standard Time", "BT": "Bhutan Time", "SAST": "South Africa Standard Time", "GMT": "Greenwich Mean Time", "ARST": "Argentina Summer Time", "EST": "Eastern Standard Time", "MDT": "Mountain Daylight Time", "NZST": "New Zealand Standard Time", "VET": "Venezuela Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_IN) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_IN' +func (en *en_IN) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_IN' +func (en *en_IN) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_IN' +func (en *en_IN) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_IN' +func (en *en_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_IN' +func (en *en_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_IN' +func (en *en_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_IN) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_IN) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_IN) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_IN) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_IN) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_IN) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_IN) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_IN) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_IN) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_IN) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_IN) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_IN) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_IN) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_IN' and handles both Whole and Real numbers based on 'v' +func (en *en_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, en.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_IN' +func (en *en_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, en.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_IN' +// in accounting notation. +func (en *en_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, en.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyNegativePrefix[j]) + } + + b = append(b, en.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_IN' +func (en *en_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_IN' +func (en *en_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_IN' +func (en *en_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_IN' +func (en *en_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_IN' +func (en *en_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_IN' +func (en *en_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_IN' +func (en *en_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_IN' +func (en *en_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_IN/en_IN_test.go b/vendor/github.com/go-playground/locales/en_IN/en_IN_test.go new file mode 100644 index 0000000000..8c4abad135 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IN/en_IN_test.go @@ -0,0 +1,1120 @@ +package en_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_IO/en_IO.go b/vendor/github.com/go-playground/locales/en_IO/en_IO.go new file mode 100644 index 0000000000..5f5245157c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IO/en_IO.go @@ -0,0 +1,597 @@ +package en_IO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_IO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_IO' locale +func New() locales.Translator { + return &en_IO{ + locale: "en_IO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ACST": "Australian Central Standard Time", "SRT": "Suriname Time", "SAST": "South Africa Standard Time", "WIB": "Western Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "HKST": "Hong Kong Summer Time", "NZST": "New Zealand Standard Time", "MESZ": "Central European Summer Time", "HNEG": "East Greenland Standard Time", "LHDT": "Lord Howe Daylight Time", "AWST": "Australian Western Standard Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "ECT": "Ecuador Time", "AEDT": "Australian Eastern Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "EAT": "East Africa Time", "CST": "Central Standard Time", "CHAST": "Chatham Standard Time", "JDT": "Japan Daylight Time", "LHST": "Lord Howe Standard Time", "PST": "Pacific Standard Time", "CLST": "Chile Summer Time", "OEZ": "Eastern European Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CDT": "Central Daylight Time", "BOT": "Bolivia Time", "PDT": "Pacific Daylight Time", "ARST": "Argentina Summer Time", "ART": "Argentina Standard Time", "HKT": "Hong Kong Standard Time", "EST": "Eastern Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AKST": "Alaska Standard Time", "GYT": "Guyana Time", "TMST": "Turkmenistan Summer Time", "ACDT": "Australian Central Daylight Time", "COT": "Colombia Standard Time", "MDT": "Macau Summer Time", "HAT": "Newfoundland Daylight Time", "HECU": "Cuba Daylight Time", "WIT": "Eastern Indonesia Time", "ACWST": "Australian Central Western Standard Time", "GMT": "Greenwich Mean Time", "ADT": "Atlantic Daylight Time", "WART": "Western Argentina Standard Time", "AST": "Atlantic Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "UYT": "Uruguay Standard Time", "∅∅∅": "Azores Summer Time", "NZDT": "New Zealand Daylight Time", "MEZ": "Central European Standard Time", "WEZ": "Western European Standard Time", "AEST": "Australian Eastern Standard Time", "COST": "Colombia Summer Time", "HNPMX": "Mexican Pacific Standard Time", "AWDT": "Australian Western Daylight Time", "CAT": "Central Africa Time", "HNOG": "West Greenland Standard Time", "WAT": "West Africa Standard Time", "ACWDT": "Australian Central Western Daylight Time", "MYT": "Malaysia Time", "BT": "Bhutan Time", "AKDT": "Alaska Daylight Time", "EDT": "Eastern Daylight Time", "HNCU": "Cuba Standard Time", "VET": "Venezuela Time", "HEOG": "West Greenland Summer Time", "OESZ": "Eastern European Summer Time", "TMT": "Turkmenistan Standard Time", "HNT": "Newfoundland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "ChST": "Chamorro Standard Time", "UYST": "Uruguay Summer Time", "JST": "Japan Standard Time", "HEEG": "East Greenland Summer Time", "WAST": "West Africa Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "IST": "India Standard Time", "WESZ": "Western European Summer Time", "WARST": "Western Argentina Summer Time", "MST": "Macau Standard Time", "CLT": "Chile Standard Time", "GFT": "French Guiana Time", "WITA": "Central Indonesia Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_IO) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_IO' +func (en *en_IO) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_IO' +func (en *en_IO) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_IO' +func (en *en_IO) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_IO' +func (en *en_IO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_IO' +func (en *en_IO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_IO' +func (en *en_IO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_IO) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_IO) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_IO) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_IO) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_IO) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_IO) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_IO) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_IO) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_IO) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_IO) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_IO) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_IO) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_IO) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_IO) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_IO' and handles both Whole and Real numbers based on 'v' +func (en *en_IO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_IO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_IO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_IO' +func (en *en_IO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_IO' +// in accounting notation. +func (en *en_IO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_IO' +func (en *en_IO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_IO' +func (en *en_IO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_IO' +func (en *en_IO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_IO' +func (en *en_IO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_IO' +func (en *en_IO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_IO' +func (en *en_IO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_IO' +func (en *en_IO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_IO' +func (en *en_IO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_IO/en_IO_test.go b/vendor/github.com/go-playground/locales/en_IO/en_IO_test.go new file mode 100644 index 0000000000..4602edc4b1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_IO/en_IO_test.go @@ -0,0 +1,1120 @@ +package en_IO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_IO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_JE/en_JE.go b/vendor/github.com/go-playground/locales/en_JE/en_JE.go new file mode 100644 index 0000000000..faf37c05e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_JE/en_JE.go @@ -0,0 +1,597 @@ +package en_JE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_JE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_JE' locale +func New() locales.Translator { + return &en_JE{ + locale: "en_JE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AEST": "Australian Eastern Standard Time", "SAST": "South Africa Standard Time", "ACWDT": "Australian Central Western Daylight Time", "TMST": "Turkmenistan Summer Time", "EST": "Eastern Standard Time", "CHAST": "Chatham Standard Time", "PST": "Pacific Standard Time", "JST": "Japan Standard Time", "ACDT": "Australian Central Daylight Time", "WITA": "Central Indonesia Time", "UYT": "Uruguay Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HECU": "Cuba Daylight Time", "WART": "Western Argentina Standard Time", "HNOG": "West Greenland Standard Time", "TMT": "Turkmenistan Standard Time", "MYT": "Malaysia Time", "MDT": "Mountain Daylight Time", "LHDT": "Lord Howe Daylight Time", "WIB": "Western Indonesia Time", "ACWST": "Australian Central Western Standard Time", "OESZ": "Eastern European Summer Time", "COT": "Colombia Standard Time", "HNEG": "East Greenland Standard Time", "HNCU": "Cuba Standard Time", "PDT": "Pacific Daylight Time", "EDT": "Eastern Daylight Time", "SGT": "Singapore Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "WAT": "West Africa Standard Time", "IST": "India Standard Time", "EAT": "East Africa Time", "WEZ": "Western European Standard Time", "WESZ": "Western European Summer Time", "CLT": "Chile Standard Time", "CLST": "Chile Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "BT": "Bhutan Time", "AKDT": "Alaska Daylight Time", "AWDT": "Australian Western Daylight Time", "OEZ": "Eastern European Standard Time", "HKT": "Hong Kong Standard Time", "HAT": "Newfoundland Daylight Time", "AEDT": "Australian Eastern Daylight Time", "MST": "Mountain Standard Time", "WIT": "Eastern Indonesia Time", "CST": "Central Standard Time", "ART": "Argentina Standard Time", "WAST": "West Africa Summer Time", "ACST": "Australian Central Standard Time", "∅∅∅": "Acre Summer Time", "AKST": "Alaska Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MESZ": "Central European Summer Time", "HKST": "Hong Kong Summer Time", "COST": "Colombia Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ECT": "Ecuador Time", "WARST": "Western Argentina Summer Time", "GMT": "Greenwich Mean Time", "HEOG": "West Greenland Summer Time", "LHST": "Lord Howe Standard Time", "AWST": "Australian Western Standard Time", "CHADT": "Chatham Daylight Time", "VET": "Venezuela Time", "MEZ": "Central European Standard Time", "SRT": "Suriname Time", "NZST": "New Zealand Standard Time", "CAT": "Central Africa Time", "JDT": "Japan Daylight Time", "AST": "Atlantic Standard Time", "HEEG": "East Greenland Summer Time", "ChST": "Chamorro Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "GYT": "Guyana Time", "BOT": "Bolivia Time", "NZDT": "New Zealand Daylight Time", "ADT": "Atlantic Daylight Time", "ARST": "Argentina Summer Time", "HNT": "Newfoundland Standard Time", "GFT": "French Guiana Time", "UYST": "Uruguay Summer Time", "HNPMX": "Mexican Pacific Standard Time", "CDT": "Central Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_JE) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_JE' +func (en *en_JE) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_JE' +func (en *en_JE) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_JE' +func (en *en_JE) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_JE' +func (en *en_JE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_JE' +func (en *en_JE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_JE' +func (en *en_JE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_JE) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_JE) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_JE) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_JE) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_JE) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_JE) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_JE) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_JE) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_JE) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_JE) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_JE) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_JE) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_JE) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_JE) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_JE' and handles both Whole and Real numbers based on 'v' +func (en *en_JE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_JE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_JE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_JE' +func (en *en_JE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_JE' +// in accounting notation. +func (en *en_JE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_JE' +func (en *en_JE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_JE' +func (en *en_JE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_JE' +func (en *en_JE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_JE' +func (en *en_JE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_JE' +func (en *en_JE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_JE' +func (en *en_JE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_JE' +func (en *en_JE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_JE' +func (en *en_JE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_JE/en_JE_test.go b/vendor/github.com/go-playground/locales/en_JE/en_JE_test.go new file mode 100644 index 0000000000..83be533a39 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_JE/en_JE_test.go @@ -0,0 +1,1120 @@ +package en_JE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_JE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_JM/en_JM.go b/vendor/github.com/go-playground/locales/en_JM/en_JM.go new file mode 100644 index 0000000000..57b05a97d0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_JM/en_JM.go @@ -0,0 +1,635 @@ +package en_JM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_JM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_JM' locale +func New() locales.Translator { + return &en_JM{ + locale: "en_JM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "$", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"CHAST": "Chatham Standard Time", "COT": "Colombia Standard Time", "WIB": "Western Indonesia Time", "SGT": "Singapore Standard Time", "NZST": "New Zealand Standard Time", "EDT": "Eastern Daylight Time", "COST": "Colombia Summer Time", "BT": "Bhutan Time", "HNPMX": "Mexican Pacific Standard Time", "HNEG": "East Greenland Standard Time", "AEDT": "Australian Eastern Daylight Time", "AWDT": "Australian Western Daylight Time", "PDT": "Pacific Daylight Time", "ACWST": "Australian Central Western Standard Time", "NZDT": "New Zealand Daylight Time", "ACST": "Australian Central Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "ACWDT": "Australian Central Western Daylight Time", "OESZ": "Eastern European Summer Time", "GMT": "Greenwich Mean Time", "HENOMX": "Northwest Mexico Daylight Time", "HNT": "Newfoundland Standard Time", "MEZ": "Central European Standard Time", "JST": "Japan Standard Time", "ADT": "Atlantic Daylight Time", "WITA": "Central Indonesia Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHST": "Lord Howe Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "VET": "Venezuela Time", "MYT": "Malaysia Time", "CLT": "Chile Standard Time", "HAT": "Newfoundland Daylight Time", "ChST": "Chamorro Standard Time", "CHADT": "Chatham Daylight Time", "JDT": "Japan Daylight Time", "OEZ": "Eastern European Standard Time", "WAST": "West Africa Summer Time", "BOT": "Bolivia Time", "CLST": "Chile Summer Time", "HNOG": "West Greenland Standard Time", "WEZ": "Western European Standard Time", "TMST": "Turkmenistan Summer Time", "AKDT": "Alaska Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "GYT": "Guyana Time", "WIT": "Eastern Indonesia Time", "IST": "India Standard Time", "AST": "Atlantic Standard Time", "HKST": "Hong Kong Summer Time", "AKST": "Alaska Standard Time", "UYT": "Uruguay Standard Time", "PST": "Pacific Standard Time", "MESZ": "Central European Summer Time", "MST": "Macau Standard Time", "SRT": "Suriname Time", "UYST": "Uruguay Summer Time", "HECU": "Cuba Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "CAT": "Central Africa Time", "WESZ": "Western European Summer Time", "TMT": "Turkmenistan Standard Time", "ARST": "Argentina Summer Time", "AEST": "Australian Eastern Standard Time", "CDT": "Central Daylight Time", "MDT": "Macau Summer Time", "HKT": "Hong Kong Standard Time", "GFT": "French Guiana Time", "HNPM": "St. Pierre & Miquelon Standard Time", "ART": "Argentina Standard Time", "ACDT": "Australian Central Daylight Time", "WART": "Western Argentina Standard Time", "HEOG": "West Greenland Summer Time", "EST": "Eastern Standard Time", "SAST": "South Africa Standard Time", "LHDT": "Lord Howe Daylight Time", "AWST": "Australian Western Standard Time", "ECT": "Ecuador Time", "∅∅∅": "Brasilia Summer Time", "WARST": "Western Argentina Summer Time", "WAT": "West Africa Standard Time", "HEEG": "East Greenland Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_JM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_JM' +func (en *en_JM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_JM' +func (en *en_JM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_JM' +func (en *en_JM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_JM' +func (en *en_JM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_JM' +func (en *en_JM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_JM' +func (en *en_JM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_JM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_JM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_JM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_JM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_JM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_JM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_JM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_JM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_JM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_JM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_JM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_JM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_JM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_JM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_JM' and handles both Whole and Real numbers based on 'v' +func (en *en_JM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_JM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_JM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_JM' +func (en *en_JM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_JM' +// in accounting notation. +func (en *en_JM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_JM' +func (en *en_JM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_JM' +func (en *en_JM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_JM' +func (en *en_JM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_JM' +func (en *en_JM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_JM' +func (en *en_JM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_JM' +func (en *en_JM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_JM' +func (en *en_JM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_JM' +func (en *en_JM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_JM/en_JM_test.go b/vendor/github.com/go-playground/locales/en_JM/en_JM_test.go new file mode 100644 index 0000000000..3772f86a84 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_JM/en_JM_test.go @@ -0,0 +1,1120 @@ +package en_JM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_JM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_KE/en_KE.go b/vendor/github.com/go-playground/locales/en_KE/en_KE.go new file mode 100644 index 0000000000..b4585dc497 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_KE/en_KE.go @@ -0,0 +1,607 @@ +package en_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_KE' locale +func New() locales.Translator { + return &en_KE{ + locale: "en_KE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AKST": "Alaska Standard Time", "CST": "Central Standard Time", "ACWST": "Australian Central Western Standard Time", "HNOG": "West Greenland Standard Time", "AST": "Atlantic Standard Time", "ART": "Argentina Standard Time", "WART": "Western Argentina Standard Time", "PDT": "Pacific Daylight Time", "IST": "India Standard Time", "NZST": "New Zealand Standard Time", "CLST": "Chile Summer Time", "GYT": "Guyana Time", "VET": "Venezuela Time", "HKST": "Hong Kong Summer Time", "WITA": "Central Indonesia Time", "UYT": "Uruguay Standard Time", "MST": "Macau Standard Time", "ChST": "Chamorro Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HECU": "Cuba Daylight Time", "PST": "Pacific Standard Time", "JST": "Japan Standard Time", "CLT": "Chile Standard Time", "HNEG": "East Greenland Standard Time", "SRT": "Suriname Time", "BOT": "Bolivia Time", "WEZ": "Western European Standard Time", "MDT": "Macau Summer Time", "COST": "Colombia Summer Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "AWDT": "Australian Western Daylight Time", "MEZ": "Central European Standard Time", "JDT": "Japan Daylight Time", "ARST": "Argentina Summer Time", "EAT": "East Africa Time", "EDT": "Eastern Daylight Time", "HKT": "Hong Kong Standard Time", "ACST": "Australian Central Standard Time", "BT": "Bhutan Time", "HEOG": "West Greenland Summer Time", "MYT": "Malaysia Time", "TMST": "Turkmenistan Summer Time", "WAT": "West Africa Standard Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "AEST": "Australian Eastern Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MESZ": "Central European Summer Time", "AEDT": "Australian Eastern Daylight Time", "CHADT": "Chatham Daylight Time", "WARST": "Western Argentina Summer Time", "TMT": "Turkmenistan Standard Time", "ACDT": "Australian Central Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "GFT": "French Guiana Time", "AKDT": "Alaska Daylight Time", "CHAST": "Chatham Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "NZDT": "New Zealand Daylight Time", "ADT": "Atlantic Daylight Time", "HNCU": "Cuba Standard Time", "CDT": "Central Daylight Time", "SGT": "Singapore Standard Time", "∅∅∅": "Amazon Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "AWST": "Australian Western Standard Time", "OEZ": "Eastern European Standard Time", "OESZ": "Eastern European Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "HEEG": "East Greenland Summer Time", "UYST": "Uruguay Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "SAST": "South Africa Standard Time", "ECT": "Ecuador Time", "GMT": "Greenwich Mean Time", "EST": "Eastern Standard Time", "COT": "Colombia Standard Time", "LHST": "Lord Howe Standard Time", "LHDT": "Lord Howe Daylight Time", "CAT": "Central Africa Time", "WESZ": "Western European Summer Time", "ACWDT": "Australian Central Western Daylight Time", "WAST": "West Africa Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_KE) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_KE' +func (en *en_KE) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_KE' +func (en *en_KE) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_KE' +func (en *en_KE) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_KE' +func (en *en_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_KE' +func (en *en_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_KE' +func (en *en_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_KE) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_KE) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_KE) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_KE) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_KE) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_KE) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_KE) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_KE) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_KE) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_KE) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_KE) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_KE) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_KE) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_KE' and handles both Whole and Real numbers based on 'v' +func (en *en_KE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_KE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_KE' +func (en *en_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_KE' +// in accounting notation. +func (en *en_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_KE' +func (en *en_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_KE' +func (en *en_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_KE' +func (en *en_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_KE' +func (en *en_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_KE' +func (en *en_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_KE' +func (en *en_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_KE' +func (en *en_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_KE' +func (en *en_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_KE/en_KE_test.go b/vendor/github.com/go-playground/locales/en_KE/en_KE_test.go new file mode 100644 index 0000000000..36cbdcd3d0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_KE/en_KE_test.go @@ -0,0 +1,1120 @@ +package en_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_KI/en_KI.go b/vendor/github.com/go-playground/locales/en_KI/en_KI.go new file mode 100644 index 0000000000..66c2774fac --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_KI/en_KI.go @@ -0,0 +1,645 @@ +package en_KI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_KI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_KI' locale +func New() locales.Translator { + return &en_KI{ + locale: "en_KI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HEPM": "St. Pierre & Miquelon Daylight Time", "SGT": "Singapore Standard Time", "PST": "Pacific Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "JDT": "Japan Daylight Time", "OESZ": "Eastern European Summer Time", "COST": "Colombia Summer Time", "HAT": "Newfoundland Daylight Time", "JST": "Japan Standard Time", "PDT": "Pacific Daylight Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "WIT": "Eastern Indonesia Time", "AKST": "Alaska Standard Time", "WIB": "Western Indonesia Time", "AWDT": "Australian Western Daylight Time", "WEZ": "Western European Standard Time", "TMT": "Turkmenistan Standard Time", "AKDT": "Alaska Daylight Time", "AWST": "Australian Western Standard Time", "MESZ": "Central European Summer Time", "VET": "Venezuela Time", "WART": "Western Argentina Standard Time", "ADT": "Atlantic Daylight Time", "WESZ": "Western European Summer Time", "WAT": "West Africa Standard Time", "ChST": "Chamorro Standard Time", "AEDT": "Australian Eastern Daylight Time", "HNOG": "West Greenland Standard Time", "AEST": "Australian Eastern Standard Time", "MEZ": "Central European Standard Time", "AST": "Atlantic Standard Time", "LHDT": "Lord Howe Daylight Time", "IST": "India Standard Time", "NZDT": "New Zealand Daylight Time", "CLST": "Chile Summer Time", "ART": "Argentina Standard Time", "EST": "Eastern Standard Time", "ACST": "Australian Central Standard Time", "BOT": "Bolivia Time", "HAST": "Hawaii-Aleutian Standard Time", "COT": "Colombia Standard Time", "CDT": "Central Daylight Time", "HEOG": "West Greenland Summer Time", "WAST": "West Africa Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "CLT": "Chile Standard Time", "∅∅∅": "Acre Summer Time", "MDT": "Mountain Daylight Time", "SAST": "South Africa Standard Time", "CAT": "Central Africa Time", "ACWDT": "Australian Central Western Daylight Time", "EDT": "Eastern Daylight Time", "BT": "Bhutan Time", "SRT": "Suriname Time", "HECU": "Cuba Daylight Time", "OEZ": "Eastern European Standard Time", "HKST": "Hong Kong Summer Time", "HNPMX": "Mexican Pacific Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHST": "Lord Howe Standard Time", "ECT": "Ecuador Time", "TMST": "Turkmenistan Summer Time", "ARST": "Argentina Summer Time", "ACDT": "Australian Central Daylight Time", "HNEG": "East Greenland Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "GYT": "Guyana Time", "CHADT": "Chatham Daylight Time", "WITA": "Central Indonesia Time", "HEEG": "East Greenland Summer Time", "UYST": "Uruguay Summer Time", "CST": "Central Standard Time", "MYT": "Malaysia Time", "WARST": "Western Argentina Summer Time", "GMT": "Greenwich Mean Time", "HENOMX": "Northwest Mexico Daylight Time", "HNT": "Newfoundland Standard Time", "GFT": "French Guiana Time", "UYT": "Uruguay Standard Time", "CHAST": "Chatham Standard Time", "ACWST": "Australian Central Western Standard Time", "NZST": "New Zealand Standard Time", "HKT": "Hong Kong Standard Time", "MST": "Mountain Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_KI) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_KI' +func (en *en_KI) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_KI' +func (en *en_KI) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_KI' +func (en *en_KI) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_KI' +func (en *en_KI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_KI' +func (en *en_KI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_KI' +func (en *en_KI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_KI) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_KI) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_KI) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_KI) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_KI) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_KI) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_KI) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_KI) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_KI) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_KI) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_KI) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_KI) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_KI) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_KI) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_KI' and handles both Whole and Real numbers based on 'v' +func (en *en_KI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_KI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_KI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_KI' +func (en *en_KI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_KI' +// in accounting notation. +func (en *en_KI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_KI' +func (en *en_KI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_KI' +func (en *en_KI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_KI' +func (en *en_KI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_KI' +func (en *en_KI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_KI' +func (en *en_KI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_KI' +func (en *en_KI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_KI' +func (en *en_KI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_KI' +func (en *en_KI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_KI/en_KI_test.go b/vendor/github.com/go-playground/locales/en_KI/en_KI_test.go new file mode 100644 index 0000000000..db2a86d741 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_KI/en_KI_test.go @@ -0,0 +1,1120 @@ +package en_KI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_KI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_KN/en_KN.go b/vendor/github.com/go-playground/locales/en_KN/en_KN.go new file mode 100644 index 0000000000..830135a471 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_KN/en_KN.go @@ -0,0 +1,645 @@ +package en_KN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_KN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_KN' locale +func New() locales.Translator { + return &en_KN{ + locale: "en_KN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"BOT": "Bolivia Time", "ECT": "Ecuador Time", "ACWDT": "Australian Central Western Daylight Time", "JDT": "Japan Daylight Time", "WITA": "Central Indonesia Time", "WIT": "Eastern Indonesia Time", "MST": "Macau Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "UYST": "Uruguay Summer Time", "HNCU": "Cuba Standard Time", "MESZ": "Central European Summer Time", "CAT": "Central Africa Time", "WARST": "Western Argentina Summer Time", "OESZ": "Eastern European Summer Time", "HKST": "Hong Kong Summer Time", "AEDT": "Australian Eastern Daylight Time", "CDT": "Central Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HNOG": "West Greenland Standard Time", "OEZ": "Eastern European Standard Time", "WAST": "West Africa Summer Time", "BT": "Bhutan Time", "AWDT": "Australian Western Daylight Time", "PDT": "Pacific Daylight Time", "ACST": "Australian Central Standard Time", "AKST": "Alaska Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SRT": "Suriname Time", "CST": "Central Standard Time", "CHAST": "Chatham Standard Time", "NZST": "New Zealand Standard Time", "WART": "Western Argentina Standard Time", "COST": "Colombia Summer Time", "ACWST": "Australian Central Western Standard Time", "TMT": "Turkmenistan Standard Time", "HAT": "Newfoundland Daylight Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time", "LHST": "Lord Howe Standard Time", "∅∅∅": "Brasilia Summer Time", "MEZ": "Central European Standard Time", "MYT": "Malaysia Time", "ADT": "Atlantic Daylight Time", "ART": "Argentina Standard Time", "EDT": "Eastern Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "IST": "India Standard Time", "MDT": "Macau Summer Time", "HNT": "Newfoundland Standard Time", "HNEG": "East Greenland Standard Time", "SAST": "South Africa Standard Time", "GYT": "Guyana Time", "AWST": "Australian Western Standard Time", "SGT": "Singapore Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "ARST": "Argentina Summer Time", "WAT": "West Africa Standard Time", "GFT": "French Guiana Time", "CHADT": "Chatham Daylight Time", "JST": "Japan Standard Time", "HKT": "Hong Kong Standard Time", "ChST": "Chamorro Standard Time", "NZDT": "New Zealand Daylight Time", "CLST": "Chile Summer Time", "WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "TMST": "Turkmenistan Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CLT": "Chile Standard Time", "HEOG": "West Greenland Summer Time", "AST": "Atlantic Standard Time", "WEZ": "Western European Standard Time", "ACDT": "Australian Central Daylight Time", "HEEG": "East Greenland Summer Time", "AKDT": "Alaska Daylight Time", "HECU": "Cuba Daylight Time", "WIB": "Western Indonesia Time", "PST": "Pacific Standard Time", "VET": "Venezuela Time", "EST": "Eastern Standard Time", "COT": "Colombia Standard Time", "LHDT": "Lord Howe Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "EAT": "East Africa Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_KN) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_KN' +func (en *en_KN) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_KN' +func (en *en_KN) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_KN' +func (en *en_KN) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_KN' +func (en *en_KN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_KN' +func (en *en_KN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_KN' +func (en *en_KN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_KN) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_KN) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_KN) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_KN) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_KN) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_KN) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_KN) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_KN) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_KN) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_KN) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_KN) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_KN) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_KN) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_KN) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_KN' and handles both Whole and Real numbers based on 'v' +func (en *en_KN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_KN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_KN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_KN' +func (en *en_KN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_KN' +// in accounting notation. +func (en *en_KN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_KN' +func (en *en_KN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_KN' +func (en *en_KN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_KN' +func (en *en_KN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_KN' +func (en *en_KN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_KN' +func (en *en_KN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_KN' +func (en *en_KN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_KN' +func (en *en_KN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_KN' +func (en *en_KN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_KN/en_KN_test.go b/vendor/github.com/go-playground/locales/en_KN/en_KN_test.go new file mode 100644 index 0000000000..3c7d6eae25 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_KN/en_KN_test.go @@ -0,0 +1,1120 @@ +package en_KN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_KN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_KY/en_KY.go b/vendor/github.com/go-playground/locales/en_KY/en_KY.go new file mode 100644 index 0000000000..90d3327e64 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_KY/en_KY.go @@ -0,0 +1,645 @@ +package en_KY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_KY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_KY' locale +func New() locales.Translator { + return &en_KY{ + locale: "en_KY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "$", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"TMT": "Turkmenistan Standard Time", "LHST": "Lord Howe Standard Time", "HNCU": "Cuba Standard Time", "WIT": "Eastern Indonesia Time", "JST": "Japan Standard Time", "MYT": "Malaysia Time", "SAST": "South Africa Standard Time", "HECU": "Cuba Daylight Time", "WIB": "Western Indonesia Time", "CAT": "Central Africa Time", "ACWDT": "Australian Central Western Daylight Time", "GMT": "Greenwich Mean Time", "WAT": "West Africa Standard Time", "HNT": "Newfoundland Standard Time", "UYST": "Uruguay Summer Time", "ACDT": "Australian Central Daylight Time", "AEST": "Australian Eastern Standard Time", "SGT": "Singapore Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "NZST": "New Zealand Standard Time", "MESZ": "Central European Summer Time", "CLST": "Chile Summer Time", "HEOG": "West Greenland Summer Time", "AKST": "Alaska Standard Time", "AKDT": "Alaska Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CST": "Central Standard Time", "EST": "Eastern Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "BT": "Bhutan Time", "SRT": "Suriname Time", "HNEG": "East Greenland Standard Time", "CHADT": "Chatham Daylight Time", "BOT": "Bolivia Time", "JDT": "Japan Daylight Time", "CLT": "Chile Standard Time", "WESZ": "Western European Summer Time", "COST": "Colombia Summer Time", "NZDT": "New Zealand Daylight Time", "OESZ": "Eastern European Summer Time", "MDT": "Macau Summer Time", "EDT": "Eastern Daylight Time", "UYT": "Uruguay Standard Time", "CDT": "Central Daylight Time", "PST": "Pacific Standard Time", "MEZ": "Central European Standard Time", "WARST": "Western Argentina Summer Time", "GFT": "French Guiana Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "EAT": "East Africa Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMST": "Turkmenistan Summer Time", "ACST": "Australian Central Standard Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "IST": "India Standard Time", "HKT": "Hong Kong Standard Time", "GYT": "Guyana Time", "AWST": "Australian Western Standard Time", "ACWST": "Australian Central Western Standard Time", "AST": "Atlantic Standard Time", "OEZ": "Eastern European Standard Time", "ART": "Argentina Standard Time", "ChST": "Chamorro Standard Time", "CHAST": "Chatham Standard Time", "ECT": "Ecuador Time", "VET": "Venezuela Time", "WEZ": "Western European Standard Time", "HKST": "Hong Kong Summer Time", "LHDT": "Lord Howe Daylight Time", "HEEG": "East Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "AWDT": "Australian Western Daylight Time", "PDT": "Pacific Daylight Time", "∅∅∅": "Amazon Summer Time", "WART": "Western Argentina Standard Time", "MST": "Macau Standard Time", "HAT": "Newfoundland Daylight Time", "HNOG": "West Greenland Standard Time", "ADT": "Atlantic Daylight Time", "ARST": "Argentina Summer Time", "WAST": "West Africa Summer Time", "WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_KY) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_KY' +func (en *en_KY) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_KY' +func (en *en_KY) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_KY' +func (en *en_KY) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_KY' +func (en *en_KY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_KY' +func (en *en_KY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_KY' +func (en *en_KY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_KY) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_KY) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_KY) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_KY) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_KY) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_KY) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_KY) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_KY) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_KY) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_KY) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_KY) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_KY) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_KY) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_KY) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_KY' and handles both Whole and Real numbers based on 'v' +func (en *en_KY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_KY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_KY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_KY' +func (en *en_KY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_KY' +// in accounting notation. +func (en *en_KY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_KY' +func (en *en_KY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_KY' +func (en *en_KY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_KY' +func (en *en_KY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_KY' +func (en *en_KY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_KY' +func (en *en_KY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_KY' +func (en *en_KY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_KY' +func (en *en_KY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_KY' +func (en *en_KY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_KY/en_KY_test.go b/vendor/github.com/go-playground/locales/en_KY/en_KY_test.go new file mode 100644 index 0000000000..708fd98645 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_KY/en_KY_test.go @@ -0,0 +1,1120 @@ +package en_KY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_KY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_LC/en_LC.go b/vendor/github.com/go-playground/locales/en_LC/en_LC.go new file mode 100644 index 0000000000..026be122f9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_LC/en_LC.go @@ -0,0 +1,645 @@ +package en_LC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_LC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_LC' locale +func New() locales.Translator { + return &en_LC{ + locale: "en_LC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"JST": "Japan Standard Time", "CLT": "Chile Standard Time", "CLST": "Chile Summer Time", "WAT": "West Africa Standard Time", "ACST": "Australian Central Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "WIB": "Western Indonesia Time", "EDT": "Eastern Daylight Time", "∅∅∅": "Acre Summer Time", "ChST": "Chamorro Standard Time", "CST": "Central Standard Time", "NZST": "New Zealand Standard Time", "IST": "India Standard Time", "HNT": "Newfoundland Standard Time", "LHDT": "Lord Howe Daylight Time", "HNCU": "Cuba Standard Time", "WEZ": "Western European Standard Time", "OESZ": "Eastern European Summer Time", "WAST": "West Africa Summer Time", "HECU": "Cuba Daylight Time", "AWST": "Australian Western Standard Time", "UYST": "Uruguay Summer Time", "OEZ": "Eastern European Standard Time", "CHAST": "Chatham Standard Time", "CAT": "Central Africa Time", "MESZ": "Central European Summer Time", "WESZ": "Western European Summer Time", "MYT": "Malaysia Time", "AEST": "Australian Eastern Standard Time", "MDT": "Mountain Daylight Time", "CDT": "Central Daylight Time", "GFT": "French Guiana Time", "HEPMX": "Mexican Pacific Daylight Time", "LHST": "Lord Howe Standard Time", "JDT": "Japan Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "ACDT": "Australian Central Daylight Time", "COST": "Colombia Summer Time", "EAT": "East Africa Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "ART": "Argentina Standard Time", "BT": "Bhutan Time", "HAT": "Newfoundland Daylight Time", "AEDT": "Australian Eastern Daylight Time", "SGT": "Singapore Standard Time", "AST": "Atlantic Standard Time", "HNEG": "East Greenland Standard Time", "SRT": "Suriname Time", "CHADT": "Chatham Daylight Time", "ACWST": "Australian Central Western Standard Time", "COT": "Colombia Standard Time", "GYT": "Guyana Time", "BOT": "Bolivia Time", "WITA": "Central Indonesia Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "UYT": "Uruguay Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "PST": "Pacific Standard Time", "HKST": "Hong Kong Summer Time", "HEEG": "East Greenland Summer Time", "MST": "Mountain Standard Time", "WARST": "Western Argentina Summer Time", "PDT": "Pacific Daylight Time", "ARST": "Argentina Summer Time", "WIT": "Eastern Indonesia Time", "WART": "Western Argentina Standard Time", "AKST": "Alaska Standard Time", "AKDT": "Alaska Daylight Time", "SAST": "South Africa Standard Time", "GMT": "Greenwich Mean Time", "TMT": "Turkmenistan Standard Time", "TMST": "Turkmenistan Summer Time", "AWDT": "Australian Western Daylight Time", "ECT": "Ecuador Time", "NZDT": "New Zealand Daylight Time", "MEZ": "Central European Standard Time", "VET": "Venezuela Time", "HKT": "Hong Kong Standard Time", "EST": "Eastern Standard Time", "HNPMX": "Mexican Pacific Standard Time", "ADT": "Atlantic Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "ACWDT": "Australian Central Western Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_LC) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_LC' +func (en *en_LC) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_LC' +func (en *en_LC) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_LC' +func (en *en_LC) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_LC' +func (en *en_LC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_LC' +func (en *en_LC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_LC' +func (en *en_LC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_LC) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_LC) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_LC) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_LC) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_LC) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_LC) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_LC) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_LC) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_LC) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_LC) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_LC) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_LC) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_LC) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_LC) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_LC' and handles both Whole and Real numbers based on 'v' +func (en *en_LC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_LC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_LC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_LC' +func (en *en_LC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_LC' +// in accounting notation. +func (en *en_LC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_LC' +func (en *en_LC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_LC' +func (en *en_LC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_LC' +func (en *en_LC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_LC' +func (en *en_LC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_LC' +func (en *en_LC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_LC' +func (en *en_LC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_LC' +func (en *en_LC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_LC' +func (en *en_LC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_LC/en_LC_test.go b/vendor/github.com/go-playground/locales/en_LC/en_LC_test.go new file mode 100644 index 0000000000..b59330b6c8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_LC/en_LC_test.go @@ -0,0 +1,1120 @@ +package en_LC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_LC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_LR/en_LR.go b/vendor/github.com/go-playground/locales/en_LR/en_LR.go new file mode 100644 index 0000000000..e08a3670d6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_LR/en_LR.go @@ -0,0 +1,645 @@ +package en_LR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_LR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_LR' locale +func New() locales.Translator { + return &en_LR{ + locale: "en_LR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "$", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AWST": "Australian Western Standard Time", "HKT": "Hong Kong Standard Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "ChST": "Chamorro Standard Time", "PST": "Pacific Standard Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "SRT": "Suriname Time", "VET": "Venezuela Time", "HNNOMX": "Northwest Mexico Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "AWDT": "Australian Western Daylight Time", "WESZ": "Western European Summer Time", "WART": "Western Argentina Standard Time", "ARST": "Argentina Summer Time", "AKST": "Alaska Standard Time", "AKDT": "Alaska Daylight Time", "GFT": "French Guiana Time", "HEPMX": "Mexican Pacific Daylight Time", "MDT": "Macau Summer Time", "COT": "Colombia Standard Time", "COST": "Colombia Summer Time", "AEDT": "Australian Eastern Daylight Time", "UYT": "Uruguay Standard Time", "WAT": "West Africa Standard Time", "LHST": "Lord Howe Standard Time", "LHDT": "Lord Howe Daylight Time", "GYT": "Guyana Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "ACWDT": "Australian Central Western Daylight Time", "ADT": "Atlantic Daylight Time", "HKST": "Hong Kong Summer Time", "HEEG": "East Greenland Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "MEZ": "Central European Standard Time", "MESZ": "Central European Summer Time", "JDT": "Japan Daylight Time", "WARST": "Western Argentina Summer Time", "EST": "Eastern Standard Time", "BT": "Bhutan Time", "UYST": "Uruguay Summer Time", "WIT": "Eastern Indonesia Time", "CHAST": "Chatham Standard Time", "ACWST": "Australian Central Western Standard Time", "NZDT": "New Zealand Daylight Time", "GMT": "Greenwich Mean Time", "ACDT": "Australian Central Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MYT": "Malaysia Time", "TMST": "Turkmenistan Summer Time", "SAST": "South Africa Standard Time", "HNPMX": "Mexican Pacific Standard Time", "CST": "Central Standard Time", "IST": "India Standard Time", "TMT": "Turkmenistan Standard Time", "WITA": "Central Indonesia Time", "HNEG": "East Greenland Standard Time", "HNCU": "Cuba Standard Time", "HECU": "Cuba Daylight Time", "WIB": "Western Indonesia Time", "BOT": "Bolivia Time", "CAT": "Central Africa Time", "OESZ": "Eastern European Summer Time", "HEOG": "West Greenland Summer Time", "∅∅∅": "Azores Summer Time", "ART": "Argentina Standard Time", "JST": "Japan Standard Time", "AST": "Atlantic Standard Time", "CLST": "Chile Summer Time", "HNOG": "West Greenland Standard Time", "CDT": "Central Daylight Time", "PDT": "Pacific Daylight Time", "NZST": "New Zealand Standard Time", "WAST": "West Africa Summer Time", "EDT": "Eastern Daylight Time", "ACST": "Australian Central Standard Time", "AEST": "Australian Eastern Standard Time", "EAT": "East Africa Time", "ECT": "Ecuador Time", "CLT": "Chile Standard Time", "MST": "Macau Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_LR) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_LR' +func (en *en_LR) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_LR' +func (en *en_LR) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_LR' +func (en *en_LR) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_LR' +func (en *en_LR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_LR' +func (en *en_LR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_LR' +func (en *en_LR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_LR) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_LR) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_LR) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_LR) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_LR) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_LR) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_LR) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_LR) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_LR) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_LR) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_LR) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_LR) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_LR) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_LR) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_LR' and handles both Whole and Real numbers based on 'v' +func (en *en_LR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_LR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_LR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_LR' +func (en *en_LR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_LR' +// in accounting notation. +func (en *en_LR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_LR' +func (en *en_LR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_LR' +func (en *en_LR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_LR' +func (en *en_LR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_LR' +func (en *en_LR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_LR' +func (en *en_LR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_LR' +func (en *en_LR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_LR' +func (en *en_LR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_LR' +func (en *en_LR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_LR/en_LR_test.go b/vendor/github.com/go-playground/locales/en_LR/en_LR_test.go new file mode 100644 index 0000000000..face3848bb --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_LR/en_LR_test.go @@ -0,0 +1,1120 @@ +package en_LR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_LR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_LS/en_LS.go b/vendor/github.com/go-playground/locales/en_LS/en_LS.go new file mode 100644 index 0000000000..152e9c64c9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_LS/en_LS.go @@ -0,0 +1,645 @@ +package en_LS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_LS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_LS' locale +func New() locales.Translator { + return &en_LS{ + locale: "en_LS", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "R", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HNOG": "West Greenland Standard Time", "WAT": "West Africa Standard Time", "EDT": "Eastern Daylight Time", "AEST": "Australian Eastern Standard Time", "AWST": "Australian Western Standard Time", "HKST": "Hong Kong Summer Time", "ACDT": "Australian Central Daylight Time", "COST": "Colombia Summer Time", "UYT": "Uruguay Standard Time", "WIB": "Western Indonesia Time", "VET": "Venezuela Time", "AST": "Atlantic Standard Time", "MDT": "Macau Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "EAT": "East Africa Time", "WIT": "Eastern Indonesia Time", "PDT": "Pacific Daylight Time", "CAT": "Central Africa Time", "WARST": "Western Argentina Summer Time", "HEEG": "East Greenland Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SGT": "Singapore Standard Time", "IST": "India Standard Time", "NZST": "New Zealand Standard Time", "OEZ": "Eastern European Standard Time", "ACST": "Australian Central Standard Time", "ChST": "Chamorro Standard Time", "AWDT": "Australian Western Daylight Time", "CHAST": "Chatham Standard Time", "CHADT": "Chatham Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "MESZ": "Central European Summer Time", "ADT": "Atlantic Daylight Time", "ARST": "Argentina Summer Time", "HNEG": "East Greenland Standard Time", "ECT": "Ecuador Time", "ACWST": "Australian Central Western Standard Time", "MYT": "Malaysia Time", "HEPMX": "Mexican Pacific Daylight Time", "GYT": "Guyana Time", "HNCU": "Cuba Standard Time", "WEZ": "Western European Standard Time", "COT": "Colombia Standard Time", "HAT": "Newfoundland Daylight Time", "GFT": "French Guiana Time", "WART": "Western Argentina Standard Time", "WAST": "West Africa Summer Time", "HECU": "Cuba Daylight Time", "PST": "Pacific Standard Time", "OESZ": "Eastern European Summer Time", "MST": "Macau Standard Time", "AKDT": "Alaska Daylight Time", "LHDT": "Lord Howe Daylight Time", "JST": "Japan Standard Time", "HKT": "Hong Kong Standard Time", "HNT": "Newfoundland Standard Time", "AEDT": "Australian Eastern Daylight Time", "SRT": "Suriname Time", "SAST": "South Africa Standard Time", "LHST": "Lord Howe Standard Time", "MEZ": "Central European Standard Time", "TMT": "Turkmenistan Standard Time", "AKST": "Alaska Standard Time", "CDT": "Central Daylight Time", "GMT": "Greenwich Mean Time", "HEOG": "West Greenland Summer Time", "ART": "Argentina Standard Time", "WITA": "Central Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "JDT": "Japan Daylight Time", "WESZ": "Western European Summer Time", "BT": "Bhutan Time", "UYST": "Uruguay Summer Time", "HNPMX": "Mexican Pacific Standard Time", "ACWDT": "Australian Central Western Daylight Time", "CLT": "Chile Standard Time", "CLST": "Chile Summer Time", "TMST": "Turkmenistan Summer Time", "EST": "Eastern Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "∅∅∅": "Acre Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CST": "Central Standard Time", "BOT": "Bolivia Time", "NZDT": "New Zealand Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_LS) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_LS' +func (en *en_LS) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_LS' +func (en *en_LS) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_LS' +func (en *en_LS) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_LS' +func (en *en_LS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_LS' +func (en *en_LS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_LS' +func (en *en_LS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_LS) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_LS) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_LS) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_LS) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_LS) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_LS) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_LS) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_LS) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_LS) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_LS) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_LS) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_LS) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_LS) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_LS) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_LS' and handles both Whole and Real numbers based on 'v' +func (en *en_LS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_LS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_LS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_LS' +func (en *en_LS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_LS' +// in accounting notation. +func (en *en_LS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_LS' +func (en *en_LS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_LS' +func (en *en_LS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_LS' +func (en *en_LS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_LS' +func (en *en_LS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_LS' +func (en *en_LS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_LS' +func (en *en_LS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_LS' +func (en *en_LS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_LS' +func (en *en_LS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_LS/en_LS_test.go b/vendor/github.com/go-playground/locales/en_LS/en_LS_test.go new file mode 100644 index 0000000000..0fbbb47fc3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_LS/en_LS_test.go @@ -0,0 +1,1120 @@ +package en_LS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_LS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MG/en_MG.go b/vendor/github.com/go-playground/locales/en_MG/en_MG.go new file mode 100644 index 0000000000..2229b94bb1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MG/en_MG.go @@ -0,0 +1,607 @@ +package en_MG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MG' locale +func New() locales.Translator { + return &en_MG{ + locale: "en_MG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "Ar", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AWST": "Australian Western Standard Time", "PST": "Pacific Standard Time", "MESZ": "Central European Summer Time", "HEOG": "West Greenland Summer Time", "WAT": "West Africa Standard Time", "ACST": "Australian Central Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "NZST": "New Zealand Standard Time", "WESZ": "Western European Summer Time", "HKST": "Hong Kong Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AWDT": "Australian Western Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "MEZ": "Central European Standard Time", "ART": "Argentina Standard Time", "WAST": "West Africa Summer Time", "AEDT": "Australian Eastern Daylight Time", "SAST": "South Africa Standard Time", "EST": "Eastern Standard Time", "CAT": "Central Africa Time", "HEEG": "East Greenland Summer Time", "CST": "Central Standard Time", "WIT": "Eastern Indonesia Time", "CHAST": "Chatham Standard Time", "SGT": "Singapore Standard Time", "WART": "Western Argentina Standard Time", "COST": "Colombia Summer Time", "∅∅∅": "Acre Summer Time", "UYST": "Uruguay Summer Time", "WARST": "Western Argentina Summer Time", "MDT": "Mountain Daylight Time", "ACWST": "Australian Central Western Standard Time", "GMT": "Greenwich Mean Time", "UYT": "Uruguay Standard Time", "HNOG": "West Greenland Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "IST": "India Standard Time", "VET": "Venezuela Time", "MYT": "Malaysia Time", "CLT": "Chile Standard Time", "ChST": "Chamorro Standard Time", "LHDT": "Lord Howe Daylight Time", "HECU": "Cuba Daylight Time", "CLST": "Chile Summer Time", "AST": "Atlantic Standard Time", "EAT": "East Africa Time", "JDT": "Japan Daylight Time", "HKT": "Hong Kong Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "GYT": "Guyana Time", "HNT": "Newfoundland Standard Time", "AEST": "Australian Eastern Standard Time", "BOT": "Bolivia Time", "CHADT": "Chatham Daylight Time", "PDT": "Pacific Daylight Time", "EDT": "Eastern Daylight Time", "COT": "Colombia Standard Time", "BT": "Bhutan Time", "TMT": "Turkmenistan Standard Time", "LHST": "Lord Howe Standard Time", "ECT": "Ecuador Time", "JST": "Japan Standard Time", "WEZ": "Western European Standard Time", "ADT": "Atlantic Daylight Time", "HAT": "Newfoundland Daylight Time", "MST": "Mountain Standard Time", "AKDT": "Alaska Daylight Time", "OEZ": "Eastern European Standard Time", "OESZ": "Eastern European Summer Time", "CDT": "Central Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMST": "Turkmenistan Summer Time", "HNEG": "East Greenland Standard Time", "GFT": "French Guiana Time", "WIB": "Western Indonesia Time", "HNPMX": "Mexican Pacific Standard Time", "SRT": "Suriname Time", "HNCU": "Cuba Standard Time", "ACDT": "Australian Central Daylight Time", "WITA": "Central Indonesia Time", "AKST": "Alaska Standard Time", "NZDT": "New Zealand Daylight Time", "ARST": "Argentina Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MG' +func (en *en_MG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MG' +func (en *en_MG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MG' +func (en *en_MG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MG' +func (en *en_MG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MG' +func (en *en_MG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MG' +func (en *en_MG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MG' and handles both Whole and Real numbers based on 'v' +func (en *en_MG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MG' +func (en *en_MG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MG' +// in accounting notation. +func (en *en_MG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MG' +func (en *en_MG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MG' +func (en *en_MG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MG' +func (en *en_MG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MG' +func (en *en_MG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MG' +func (en *en_MG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MG' +func (en *en_MG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MG' +func (en *en_MG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MG' +func (en *en_MG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MG/en_MG_test.go b/vendor/github.com/go-playground/locales/en_MG/en_MG_test.go new file mode 100644 index 0000000000..36b91f7897 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MG/en_MG_test.go @@ -0,0 +1,1120 @@ +package en_MG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MH/en_MH.go b/vendor/github.com/go-playground/locales/en_MH/en_MH.go new file mode 100644 index 0000000000..57a29e9952 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MH/en_MH.go @@ -0,0 +1,635 @@ +package en_MH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MH' locale +func New() locales.Translator { + return &en_MH{ + locale: "en_MH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"MYT": "Malaysia Time", "TMST": "Turkmenistan Summer Time", "ART": "Argentina Standard Time", "ARST": "Argentina Summer Time", "∅∅∅": "Acre Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "EST": "Eastern Standard Time", "AEST": "Australian Eastern Standard Time", "SAST": "South Africa Standard Time", "WIT": "Eastern Indonesia Time", "HEOG": "West Greenland Summer Time", "TMT": "Turkmenistan Standard Time", "EDT": "Eastern Daylight Time", "COST": "Colombia Summer Time", "HNPMX": "Mexican Pacific Standard Time", "AWDT": "Australian Western Daylight Time", "NZDT": "New Zealand Daylight Time", "ACWST": "Australian Central Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "JST": "Japan Standard Time", "ADT": "Atlantic Daylight Time", "WAST": "West Africa Summer Time", "ACDT": "Australian Central Daylight Time", "AKST": "Alaska Standard Time", "AEDT": "Australian Eastern Daylight Time", "UYT": "Uruguay Standard Time", "AWST": "Australian Western Standard Time", "BOT": "Bolivia Time", "VET": "Venezuela Time", "WART": "Western Argentina Standard Time", "HNOG": "West Greenland Standard Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HEEG": "East Greenland Summer Time", "LHST": "Lord Howe Standard Time", "WIB": "Western Indonesia Time", "WAT": "West Africa Standard Time", "LHDT": "Lord Howe Daylight Time", "CDT": "Central Daylight Time", "CHADT": "Chatham Daylight Time", "MEZ": "Central European Standard Time", "WESZ": "Western European Summer Time", "WARST": "Western Argentina Summer Time", "HAT": "Newfoundland Daylight Time", "SRT": "Suriname Time", "GYT": "Guyana Time", "IST": "India Standard Time", "AKDT": "Alaska Daylight Time", "ChST": "Chamorro Standard Time", "PST": "Pacific Standard Time", "HKST": "Hong Kong Summer Time", "WITA": "Central Indonesia Time", "CST": "Central Standard Time", "CHAST": "Chatham Standard Time", "SGT": "Singapore Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "NZST": "New Zealand Standard Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "GMT": "Greenwich Mean Time", "ACST": "Australian Central Standard Time", "BT": "Bhutan Time", "HNT": "Newfoundland Standard Time", "UYST": "Uruguay Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "ECT": "Ecuador Time", "CLT": "Chile Standard Time", "CLST": "Chile Summer Time", "MDT": "Macau Summer Time", "HKT": "Hong Kong Standard Time", "HNEG": "East Greenland Standard Time", "GFT": "French Guiana Time", "CAT": "Central Africa Time", "JDT": "Japan Daylight Time", "OESZ": "Eastern European Summer Time", "MST": "Macau Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNCU": "Cuba Standard Time", "MESZ": "Central European Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "EAT": "East Africa Time", "PDT": "Pacific Daylight Time", "AST": "Atlantic Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MH) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MH' +func (en *en_MH) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MH' +func (en *en_MH) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MH' +func (en *en_MH) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MH' +func (en *en_MH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MH' +func (en *en_MH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MH' +func (en *en_MH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MH) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MH) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MH) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MH) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MH) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MH) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MH) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MH) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MH) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MH) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MH) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MH) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MH) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MH) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MH' and handles both Whole and Real numbers based on 'v' +func (en *en_MH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MH' +func (en *en_MH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MH' +// in accounting notation. +func (en *en_MH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MH' +func (en *en_MH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MH' +func (en *en_MH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MH' +func (en *en_MH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MH' +func (en *en_MH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MH' +func (en *en_MH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MH' +func (en *en_MH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MH' +func (en *en_MH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MH' +func (en *en_MH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MH/en_MH_test.go b/vendor/github.com/go-playground/locales/en_MH/en_MH_test.go new file mode 100644 index 0000000000..d9b2334bc5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MH/en_MH_test.go @@ -0,0 +1,1120 @@ +package en_MH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MO/en_MO.go b/vendor/github.com/go-playground/locales/en_MO/en_MO.go new file mode 100644 index 0000000000..e14d5f2764 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MO/en_MO.go @@ -0,0 +1,607 @@ +package en_MO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MO' locale +func New() locales.Translator { + return &en_MO{ + locale: "en_MO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP$", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "ACWST": "Australian Central Western Standard Time", "WARST": "Western Argentina Summer Time", "AKST": "Alaska Standard Time", "LHDT": "Lord Howe Daylight Time", "MEZ": "Central European Standard Time", "HEOG": "West Greenland Summer Time", "WEZ": "Western European Standard Time", "MST": "Macau Standard Time", "COST": "Colombia Summer Time", "AEDT": "Australian Eastern Daylight Time", "GYT": "Guyana Time", "ADT": "Atlantic Daylight Time", "OESZ": "Eastern European Summer Time", "IST": "India Standard Time", "HNOG": "West Greenland Standard Time", "HKT": "Hong Kong Standard Time", "BOT": "Bolivia Time", "PDT": "Pacific Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "WIB": "Western Indonesia Time", "WART": "Western Argentina Standard Time", "ACST": "Australian Central Standard Time", "HNEG": "East Greenland Standard Time", "CST": "Central Standard Time", "ECT": "Ecuador Time", "CAT": "Central Africa Time", "CHAST": "Chatham Standard Time", "SRT": "Suriname Time", "ART": "Argentina Standard Time", "EDT": "Eastern Daylight Time", "HAT": "Newfoundland Daylight Time", "HNCU": "Cuba Standard Time", "HECU": "Cuba Daylight Time", "∅∅∅": "Amazon Summer Time", "GMT": "Greenwich Mean Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "BT": "Bhutan Time", "AWST": "Australian Western Standard Time", "NZST": "New Zealand Standard Time", "ARST": "Argentina Summer Time", "HKST": "Hong Kong Summer Time", "EAT": "East Africa Time", "CDT": "Central Daylight Time", "WIT": "Eastern Indonesia Time", "PST": "Pacific Standard Time", "EST": "Eastern Standard Time", "MYT": "Malaysia Time", "ChST": "Chamorro Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CHADT": "Chatham Daylight Time", "JDT": "Japan Daylight Time", "VET": "Venezuela Time", "HNPMX": "Mexican Pacific Standard Time", "MESZ": "Central European Summer Time", "JST": "Japan Standard Time", "OEZ": "Eastern European Standard Time", "TMST": "Turkmenistan Summer Time", "UYT": "Uruguay Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "NZDT": "New Zealand Daylight Time", "WAST": "West Africa Summer Time", "ACDT": "Australian Central Daylight Time", "AKDT": "Alaska Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "SAST": "South Africa Standard Time", "LHST": "Lord Howe Standard Time", "AST": "Atlantic Standard Time", "MDT": "Macau Summer Time", "HNT": "Newfoundland Standard Time", "HEEG": "East Greenland Summer Time", "GFT": "French Guiana Time", "SGT": "Singapore Standard Time", "CLST": "Chile Summer Time", "WESZ": "Western European Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "AEST": "Australian Eastern Standard Time", "UYST": "Uruguay Summer Time", "AWDT": "Australian Western Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "CLT": "Chile Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MO) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MO' +func (en *en_MO) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MO' +func (en *en_MO) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MO' +func (en *en_MO) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MO' +func (en *en_MO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MO' +func (en *en_MO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MO' +func (en *en_MO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MO) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MO) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MO) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MO) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MO) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MO) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MO) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MO) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MO) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MO) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MO) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MO) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MO) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MO) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MO' and handles both Whole and Real numbers based on 'v' +func (en *en_MO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MO' +func (en *en_MO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MO' +// in accounting notation. +func (en *en_MO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MO' +func (en *en_MO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MO' +func (en *en_MO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MO' +func (en *en_MO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MO' +func (en *en_MO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MO' +func (en *en_MO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MO' +func (en *en_MO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MO' +func (en *en_MO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MO' +func (en *en_MO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MO/en_MO_test.go b/vendor/github.com/go-playground/locales/en_MO/en_MO_test.go new file mode 100644 index 0000000000..26a61cae9c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MO/en_MO_test.go @@ -0,0 +1,1120 @@ +package en_MO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MP/en_MP.go b/vendor/github.com/go-playground/locales/en_MP/en_MP.go new file mode 100644 index 0000000000..73d84f05a2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MP/en_MP.go @@ -0,0 +1,635 @@ +package en_MP + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MP struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MP' locale +func New() locales.Translator { + return &en_MP{ + locale: "en_MP", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"CAT": "Central Africa Time", "JST": "Japan Standard Time", "MYT": "Malaysia Time", "COST": "Colombia Summer Time", "AKDT": "Alaska Daylight Time", "LHDT": "Lord Howe Daylight Time", "∅∅∅": "Amazon Summer Time", "MESZ": "Central European Summer Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "OEZ": "Eastern European Standard Time", "COT": "Colombia Standard Time", "WITA": "Central Indonesia Time", "ChST": "Chamorro Standard Time", "EAT": "East Africa Time", "HECU": "Cuba Daylight Time", "EDT": "Eastern Daylight Time", "ACWST": "Australian Central Western Standard Time", "NZST": "New Zealand Standard Time", "WART": "Western Argentina Standard Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "EST": "Eastern Standard Time", "WEZ": "Western European Standard Time", "MDT": "Macau Summer Time", "HKST": "Hong Kong Summer Time", "HNEG": "East Greenland Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CHADT": "Chatham Daylight Time", "IST": "India Standard Time", "ACDT": "Australian Central Daylight Time", "HNT": "Newfoundland Standard Time", "AWDT": "Australian Western Daylight Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "TMT": "Turkmenistan Standard Time", "UYT": "Uruguay Standard Time", "CHAST": "Chatham Standard Time", "ECT": "Ecuador Time", "ACWDT": "Australian Central Western Daylight Time", "MST": "Macau Standard Time", "WAT": "West Africa Standard Time", "AEST": "Australian Eastern Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "PDT": "Pacific Daylight Time", "ADT": "Atlantic Daylight Time", "GMT": "Greenwich Mean Time", "HNNOMX": "Northwest Mexico Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AKST": "Alaska Standard Time", "GYT": "Guyana Time", "NZDT": "New Zealand Daylight Time", "LHST": "Lord Howe Standard Time", "CDT": "Central Daylight Time", "WIT": "Eastern Indonesia Time", "PST": "Pacific Standard Time", "VET": "Venezuela Time", "JDT": "Japan Daylight Time", "AEDT": "Australian Eastern Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "WIB": "Western Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "AST": "Atlantic Standard Time", "HKT": "Hong Kong Standard Time", "ACST": "Australian Central Standard Time", "HEEG": "East Greenland Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CLST": "Chile Summer Time", "WESZ": "Western European Summer Time", "ART": "Argentina Standard Time", "GFT": "French Guiana Time", "SAST": "South Africa Standard Time", "SRT": "Suriname Time", "BT": "Bhutan Time", "AWST": "Australian Western Standard Time", "MEZ": "Central European Standard Time", "WARST": "Western Argentina Summer Time", "CLT": "Chile Standard Time", "OESZ": "Eastern European Summer Time", "TMST": "Turkmenistan Summer Time", "WAST": "West Africa Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "HNOG": "West Greenland Standard Time", "HAT": "Newfoundland Daylight Time", "UYST": "Uruguay Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MP) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MP' +func (en *en_MP) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MP' +func (en *en_MP) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MP' +func (en *en_MP) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MP' +func (en *en_MP) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MP' +func (en *en_MP) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MP' +func (en *en_MP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MP) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MP) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MP) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MP) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MP) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MP) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MP) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MP) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MP) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MP) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MP) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MP) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MP) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MP) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MP' and handles both Whole and Real numbers based on 'v' +func (en *en_MP) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MP' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MP) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MP' +func (en *en_MP) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MP' +// in accounting notation. +func (en *en_MP) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MP' +func (en *en_MP) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MP' +func (en *en_MP) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MP' +func (en *en_MP) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MP' +func (en *en_MP) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MP' +func (en *en_MP) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MP' +func (en *en_MP) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MP' +func (en *en_MP) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MP' +func (en *en_MP) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MP/en_MP_test.go b/vendor/github.com/go-playground/locales/en_MP/en_MP_test.go new file mode 100644 index 0000000000..15a373c82b --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MP/en_MP_test.go @@ -0,0 +1,1120 @@ +package en_MP + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MP" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MS/en_MS.go b/vendor/github.com/go-playground/locales/en_MS/en_MS.go new file mode 100644 index 0000000000..c2dc589d96 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MS/en_MS.go @@ -0,0 +1,607 @@ +package en_MS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MS' locale +func New() locales.Translator { + return &en_MS{ + locale: "en_MS", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HAST": "Hawaii-Aleutian Standard Time", "IST": "India Standard Time", "ART": "Argentina Standard Time", "EST": "Eastern Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "LHDT": "Lord Howe Daylight Time", "HECU": "Cuba Daylight Time", "VET": "Venezuela Time", "HEOG": "West Greenland Summer Time", "MST": "Macau Standard Time", "WAST": "West Africa Summer Time", "BT": "Bhutan Time", "AEDT": "Australian Eastern Daylight Time", "ADT": "Atlantic Daylight Time", "OEZ": "Eastern European Standard Time", "SRT": "Suriname Time", "PST": "Pacific Standard Time", "JDT": "Japan Daylight Time", "ACDT": "Australian Central Daylight Time", "HNEG": "East Greenland Standard Time", "CST": "Central Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "JST": "Japan Standard Time", "CLT": "Chile Standard Time", "WART": "Western Argentina Standard Time", "ACST": "Australian Central Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ECT": "Ecuador Time", "HNOG": "West Greenland Standard Time", "TMST": "Turkmenistan Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "ACWST": "Australian Central Western Standard Time", "NZST": "New Zealand Standard Time", "MDT": "Macau Summer Time", "HKST": "Hong Kong Summer Time", "EAT": "East Africa Time", "CDT": "Central Daylight Time", "AWST": "Australian Western Standard Time", "WARST": "Western Argentina Summer Time", "WAT": "West Africa Standard Time", "AWDT": "Australian Western Daylight Time", "CHAST": "Chatham Standard Time", "CAT": "Central Africa Time", "SAST": "South Africa Standard Time", "WIT": "Eastern Indonesia Time", "GMT": "Greenwich Mean Time", "∅∅∅": "Acre Summer Time", "UYST": "Uruguay Summer Time", "CHADT": "Chatham Daylight Time", "GFT": "French Guiana Time", "AKDT": "Alaska Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "PDT": "Pacific Daylight Time", "MESZ": "Central European Summer Time", "HNCU": "Cuba Standard Time", "BOT": "Bolivia Time", "CLST": "Chile Summer Time", "AST": "Atlantic Standard Time", "TMT": "Turkmenistan Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HAT": "Newfoundland Daylight Time", "WEZ": "Western European Standard Time", "COST": "Colombia Summer Time", "HEEG": "East Greenland Summer Time", "AKST": "Alaska Standard Time", "WIB": "Western Indonesia Time", "ChST": "Chamorro Standard Time", "UYT": "Uruguay Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "OESZ": "Eastern European Summer Time", "WESZ": "Western European Summer Time", "ARST": "Argentina Summer Time", "HKT": "Hong Kong Standard Time", "COT": "Colombia Standard Time", "HNT": "Newfoundland Standard Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time", "ACWDT": "Australian Central Western Daylight Time", "NZDT": "New Zealand Daylight Time", "MEZ": "Central European Standard Time", "MYT": "Malaysia Time", "EDT": "Eastern Daylight Time", "WITA": "Central Indonesia Time", "AEST": "Australian Eastern Standard Time", "SGT": "Singapore Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MS) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MS' +func (en *en_MS) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MS' +func (en *en_MS) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MS' +func (en *en_MS) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MS' +func (en *en_MS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MS' +func (en *en_MS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MS' +func (en *en_MS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MS) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MS) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MS) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MS) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MS) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MS) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MS) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MS) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MS) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MS) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MS) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MS) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MS) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MS) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MS' and handles both Whole and Real numbers based on 'v' +func (en *en_MS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MS' +func (en *en_MS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MS' +// in accounting notation. +func (en *en_MS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MS' +func (en *en_MS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MS' +func (en *en_MS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MS' +func (en *en_MS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MS' +func (en *en_MS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MS' +func (en *en_MS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MS' +func (en *en_MS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MS' +func (en *en_MS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MS' +func (en *en_MS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MS/en_MS_test.go b/vendor/github.com/go-playground/locales/en_MS/en_MS_test.go new file mode 100644 index 0000000000..4edd78e7fe --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MS/en_MS_test.go @@ -0,0 +1,1120 @@ +package en_MS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MT/en_MT.go b/vendor/github.com/go-playground/locales/en_MT/en_MT.go new file mode 100644 index 0000000000..ec4ac25c21 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MT/en_MT.go @@ -0,0 +1,605 @@ +package en_MT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MT' locale +func New() locales.Translator { + return &en_MT{ + locale: "en_MT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GB£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HKT": "Hong Kong Standard Time", "WAST": "West Africa Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "GYT": "Guyana Time", "∅∅∅": "Amazon Summer Time", "WEZ": "Western European Standard Time", "AST": "Atlantic Standard Time", "MDT": "Macau Summer Time", "IST": "India Standard Time", "WARST": "Western Argentina Summer Time", "AEST": "Australian Eastern Standard Time", "HNCU": "Cuba Standard Time", "CAT": "Central Africa Time", "UYT": "Uruguay Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "GMT": "Greenwich Mean Time", "MST": "Macau Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "ECT": "Ecuador Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "OESZ": "Eastern European Summer Time", "CST": "Central Standard Time", "MEZ": "Central European Standard Time", "WIT": "Eastern Indonesia Time", "CHAST": "Chatham Standard Time", "OEZ": "Eastern European Standard Time", "BT": "Bhutan Time", "WITA": "Central Indonesia Time", "UYST": "Uruguay Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "JST": "Japan Standard Time", "JDT": "Japan Daylight Time", "WART": "Western Argentina Standard Time", "AKDT": "Alaska Daylight Time", "AEDT": "Australian Eastern Daylight Time", "AKST": "Alaska Standard Time", "ChST": "Chamorro Standard Time", "EAT": "East Africa Time", "HEOG": "West Greenland Summer Time", "COT": "Colombia Standard Time", "ACST": "Australian Central Standard Time", "ACDT": "Australian Central Daylight Time", "EDT": "Eastern Daylight Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "GFT": "French Guiana Time", "HADT": "Hawaii-Aleutian Daylight Time", "ACWST": "Australian Central Western Standard Time", "CLST": "Chile Summer Time", "EST": "Eastern Standard Time", "SRT": "Suriname Time", "AWDT": "Australian Western Daylight Time", "PDT": "Pacific Daylight Time", "CLT": "Chile Standard Time", "ARST": "Argentina Summer Time", "CDT": "Central Daylight Time", "HEEG": "East Greenland Summer Time", "BOT": "Bolivia Time", "PST": "Pacific Standard Time", "TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "HECU": "Cuba Daylight Time", "WIB": "Western Indonesia Time", "VET": "Venezuela Time", "WESZ": "Western European Summer Time", "ADT": "Atlantic Daylight Time", "ART": "Argentina Standard Time", "SAST": "South Africa Standard Time", "AWST": "Australian Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "MESZ": "Central European Summer Time", "HKST": "Hong Kong Summer Time", "HNEG": "East Greenland Standard Time", "COST": "Colombia Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "CHADT": "Chatham Daylight Time", "MYT": "Malaysia Time", "HNOG": "West Greenland Standard Time", "TMST": "Turkmenistan Summer Time", "LHST": "Lord Howe Standard Time", "SGT": "Singapore Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "LHDT": "Lord Howe Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MT) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MT' +func (en *en_MT) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MT' +func (en *en_MT) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MT' +func (en *en_MT) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MT' +func (en *en_MT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MT' +func (en *en_MT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MT' +func (en *en_MT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MT) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MT) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MT) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MT) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MT) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MT) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MT) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MT) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MT) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MT) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MT) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MT) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MT) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MT) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MT' and handles both Whole and Real numbers based on 'v' +func (en *en_MT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MT' +func (en *en_MT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MT' +// in accounting notation. +func (en *en_MT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MT' +func (en *en_MT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MT' +func (en *en_MT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MT' +func (en *en_MT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MT' +func (en *en_MT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MT' +func (en *en_MT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MT' +func (en *en_MT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MT' +func (en *en_MT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MT' +func (en *en_MT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MT/en_MT_test.go b/vendor/github.com/go-playground/locales/en_MT/en_MT_test.go new file mode 100644 index 0000000000..7b4880d9c0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MT/en_MT_test.go @@ -0,0 +1,1120 @@ +package en_MT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MU/en_MU.go b/vendor/github.com/go-playground/locales/en_MU/en_MU.go new file mode 100644 index 0000000000..735481e55e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MU/en_MU.go @@ -0,0 +1,607 @@ +package en_MU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MU' locale +func New() locales.Translator { + return &en_MU{ + locale: "en_MU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "Rs", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AST": "Atlantic Standard Time", "ART": "Argentina Standard Time", "EDT": "Eastern Daylight Time", "AEST": "Australian Eastern Standard Time", "WAT": "West Africa Standard Time", "EST": "Eastern Standard Time", "HNEG": "East Greenland Standard Time", "WITA": "Central Indonesia Time", "IST": "India Standard Time", "JST": "Japan Standard Time", "MESZ": "Central European Summer Time", "TMST": "Turkmenistan Summer Time", "ChST": "Chamorro Standard Time", "∅∅∅": "Brasilia Summer Time", "PST": "Pacific Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "ACWST": "Australian Central Western Standard Time", "HNOG": "West Greenland Standard Time", "GMT": "Greenwich Mean Time", "BT": "Bhutan Time", "LHDT": "Lord Howe Daylight Time", "CHAST": "Chatham Standard Time", "ECT": "Ecuador Time", "EAT": "East Africa Time", "CDT": "Central Daylight Time", "MDT": "Macau Summer Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "AKST": "Alaska Standard Time", "AEDT": "Australian Eastern Daylight Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "COT": "Colombia Standard Time", "HAT": "Newfoundland Daylight Time", "SRT": "Suriname Time", "GYT": "Guyana Time", "AWST": "Australian Western Standard Time", "WART": "Western Argentina Standard Time", "OESZ": "Eastern European Summer Time", "COST": "Colombia Summer Time", "WIT": "Eastern Indonesia Time", "CLT": "Chile Standard Time", "TMT": "Turkmenistan Standard Time", "WAST": "West Africa Summer Time", "HEEG": "East Greenland Summer Time", "GFT": "French Guiana Time", "BOT": "Bolivia Time", "PDT": "Pacific Daylight Time", "HEOG": "West Greenland Summer Time", "MST": "Macau Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "SAST": "South Africa Standard Time", "HECU": "Cuba Daylight Time", "WIB": "Western Indonesia Time", "CST": "Central Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "MEZ": "Central European Standard Time", "JDT": "Japan Daylight Time", "CLST": "Chile Summer Time", "ADT": "Atlantic Daylight Time", "WESZ": "Western European Summer Time", "HNT": "Newfoundland Standard Time", "SGT": "Singapore Standard Time", "NZDT": "New Zealand Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHST": "Lord Howe Standard Time", "HNCU": "Cuba Standard Time", "AKDT": "Alaska Daylight Time", "UYST": "Uruguay Summer Time", "VET": "Venezuela Time", "ARST": "Argentina Summer Time", "HNPMX": "Mexican Pacific Standard Time", "AWDT": "Australian Western Daylight Time", "CAT": "Central Africa Time", "HKT": "Hong Kong Standard Time", "ACST": "Australian Central Standard Time", "UYT": "Uruguay Standard Time", "NZST": "New Zealand Standard Time", "MYT": "Malaysia Time", "WARST": "Western Argentina Summer Time", "ACDT": "Australian Central Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CHADT": "Chatham Daylight Time", "ACWDT": "Australian Central Western Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MU) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MU' +func (en *en_MU) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MU' +func (en *en_MU) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MU' +func (en *en_MU) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MU' +func (en *en_MU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MU' +func (en *en_MU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MU' +func (en *en_MU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MU) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MU) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MU) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MU) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MU) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MU) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MU) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MU) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MU) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MU) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MU) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MU) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MU) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MU) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MU' and handles both Whole and Real numbers based on 'v' +func (en *en_MU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MU' +func (en *en_MU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MU' +// in accounting notation. +func (en *en_MU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MU' +func (en *en_MU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MU' +func (en *en_MU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MU' +func (en *en_MU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MU' +func (en *en_MU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MU' +func (en *en_MU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MU' +func (en *en_MU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MU' +func (en *en_MU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MU' +func (en *en_MU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MU/en_MU_test.go b/vendor/github.com/go-playground/locales/en_MU/en_MU_test.go new file mode 100644 index 0000000000..a108dd0da4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MU/en_MU_test.go @@ -0,0 +1,1120 @@ +package en_MU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MW/en_MW.go b/vendor/github.com/go-playground/locales/en_MW/en_MW.go new file mode 100644 index 0000000000..0a7373c085 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MW/en_MW.go @@ -0,0 +1,645 @@ +package en_MW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MW' locale +func New() locales.Translator { + return &en_MW{ + locale: "en_MW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AKST": "Alaska Standard Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "SAST": "South Africa Standard Time", "WIT": "Eastern Indonesia Time", "NZDT": "New Zealand Daylight Time", "COST": "Colombia Summer Time", "AEDT": "Australian Eastern Daylight Time", "CDT": "Central Daylight Time", "ECT": "Ecuador Time", "AST": "Atlantic Standard Time", "TMT": "Turkmenistan Standard Time", "TMST": "Turkmenistan Summer Time", "ART": "Argentina Standard Time", "AEST": "Australian Eastern Standard Time", "HAT": "Newfoundland Daylight Time", "ChST": "Chamorro Standard Time", "LHST": "Lord Howe Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MESZ": "Central European Summer Time", "OEZ": "Eastern European Standard Time", "CLST": "Chile Summer Time", "EST": "Eastern Standard Time", "GYT": "Guyana Time", "HEEG": "East Greenland Summer Time", "MST": "Mountain Standard Time", "HNPMX": "Mexican Pacific Standard Time", "WIB": "Western Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "HEOG": "West Greenland Summer Time", "HKT": "Hong Kong Standard Time", "WARST": "Western Argentina Summer Time", "CAT": "Central Africa Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "AWST": "Australian Western Standard Time", "VET": "Venezuela Time", "JDT": "Japan Daylight Time", "AKDT": "Alaska Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "EAT": "East Africa Time", "ACWST": "Australian Central Western Standard Time", "MEZ": "Central European Standard Time", "ACST": "Australian Central Standard Time", "UYT": "Uruguay Standard Time", "AWDT": "Australian Western Daylight Time", "PST": "Pacific Standard Time", "GFT": "French Guiana Time", "WAST": "West Africa Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "SRT": "Suriname Time", "IST": "India Standard Time", "ACWDT": "Australian Central Western Daylight Time", "ADT": "Atlantic Daylight Time", "WAT": "West Africa Standard Time", "HNEG": "East Greenland Standard Time", "WITA": "Central Indonesia Time", "CHADT": "Chatham Daylight Time", "NZST": "New Zealand Standard Time", "OESZ": "Eastern European Summer Time", "GMT": "Greenwich Mean Time", "CLT": "Chile Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "PDT": "Pacific Daylight Time", "JST": "Japan Standard Time", "HNOG": "West Greenland Standard Time", "ARST": "Argentina Summer Time", "MDT": "Mountain Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "CHAST": "Chatham Standard Time", "WESZ": "Western European Summer Time", "WART": "Western Argentina Standard Time", "UYST": "Uruguay Summer Time", "COT": "Colombia Standard Time", "HNT": "Newfoundland Standard Time", "SGT": "Singapore Standard Time", "MYT": "Malaysia Time", "HKST": "Hong Kong Summer Time", "∅∅∅": "Acre Summer Time", "LHDT": "Lord Howe Daylight Time", "HNCU": "Cuba Standard Time", "BOT": "Bolivia Time", "WEZ": "Western European Standard Time", "EDT": "Eastern Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MW) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MW' +func (en *en_MW) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MW' +func (en *en_MW) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MW' +func (en *en_MW) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MW' +func (en *en_MW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MW' +func (en *en_MW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MW' +func (en *en_MW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MW) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MW) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MW) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MW) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MW) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MW) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MW) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MW) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MW) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MW) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MW) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MW) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MW) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MW) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MW' and handles both Whole and Real numbers based on 'v' +func (en *en_MW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MW' +func (en *en_MW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MW' +// in accounting notation. +func (en *en_MW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MW' +func (en *en_MW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MW' +func (en *en_MW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MW' +func (en *en_MW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MW' +func (en *en_MW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MW' +func (en *en_MW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MW' +func (en *en_MW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MW' +func (en *en_MW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MW' +func (en *en_MW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MW/en_MW_test.go b/vendor/github.com/go-playground/locales/en_MW/en_MW_test.go new file mode 100644 index 0000000000..cf2f5e2d16 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MW/en_MW_test.go @@ -0,0 +1,1120 @@ +package en_MW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_MY/en_MY.go b/vendor/github.com/go-playground/locales/en_MY/en_MY.go new file mode 100644 index 0000000000..889fa25519 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MY/en_MY.go @@ -0,0 +1,645 @@ +package en_MY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_MY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_MY' locale +func New() locales.Translator { + return &en_MY{ + locale: "en_MY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "RM", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ChST": "Chamorro Standard Time", "CDT": "Central Daylight Time", "PST": "Pacific Standard Time", "MESZ": "Central European Summer Time", "WARST": "Western Argentina Summer Time", "WAT": "West Africa Standard Time", "ACST": "Australian Central Standard Time", "AKDT": "Alaska Daylight Time", "AWDT": "Australian Western Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "WIT": "Eastern Indonesia Time", "EST": "Eastern Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HAT": "Newfoundland Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHDT": "Lord Howe Daylight Time", "NZDT": "New Zealand Daylight Time", "GMT": "Greenwich Mean Time", "MYT": "Malaysia Time", "EDT": "Eastern Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "MDT": "Macau Summer Time", "WAST": "West Africa Summer Time", "CHAST": "Chatham Standard Time", "ECT": "Ecuador Time", "NZST": "New Zealand Standard Time", "MEZ": "Central European Standard Time", "WART": "Western Argentina Standard Time", "TMST": "Turkmenistan Summer Time", "HEEG": "East Greenland Summer Time", "SGT": "Singapore Standard Time", "CLST": "Chile Summer Time", "HNOG": "West Greenland Standard Time", "WESZ": "Western European Summer Time", "SAST": "South Africa Standard Time", "VET": "Venezuela Time", "AST": "Atlantic Standard Time", "OEZ": "Eastern European Standard Time", "BOT": "Bolivia Time", "PDT": "Pacific Daylight Time", "COST": "Colombia Summer Time", "HNPMX": "Mexican Pacific Standard Time", "∅∅∅": "Amazon Summer Time", "IST": "India Standard Time", "BT": "Bhutan Time", "HNT": "Newfoundland Standard Time", "WEZ": "Western European Standard Time", "TMT": "Turkmenistan Standard Time", "HKT": "Hong Kong Standard Time", "AEDT": "Australian Eastern Daylight Time", "AKST": "Alaska Standard Time", "EAT": "East Africa Time", "ADT": "Atlantic Daylight Time", "MST": "Macau Standard Time", "GYT": "Guyana Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "UYST": "Uruguay Summer Time", "HNCU": "Cuba Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "CAT": "Central Africa Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "HKST": "Hong Kong Summer Time", "ACDT": "Australian Central Daylight Time", "LHST": "Lord Howe Standard Time", "WIB": "Western Indonesia Time", "ART": "Argentina Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "GFT": "French Guiana Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CHADT": "Chatham Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "JST": "Japan Standard Time", "OESZ": "Eastern European Summer Time", "COT": "Colombia Standard Time", "AEST": "Australian Eastern Standard Time", "SRT": "Suriname Time", "AWST": "Australian Western Standard Time", "ACWST": "Australian Central Western Standard Time", "JDT": "Japan Daylight Time", "CLT": "Chile Standard Time", "HNEG": "East Greenland Standard Time", "WITA": "Central Indonesia Time", "UYT": "Uruguay Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_MY) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_MY' +func (en *en_MY) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_MY' +func (en *en_MY) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_MY' +func (en *en_MY) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_MY' +func (en *en_MY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_MY' +func (en *en_MY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_MY' +func (en *en_MY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_MY) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_MY) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_MY) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_MY) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_MY) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_MY) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_MY) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_MY) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_MY) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_MY) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_MY) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_MY) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_MY) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_MY) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_MY' and handles both Whole and Real numbers based on 'v' +func (en *en_MY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_MY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_MY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_MY' +func (en *en_MY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_MY' +// in accounting notation. +func (en *en_MY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_MY' +func (en *en_MY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_MY' +func (en *en_MY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_MY' +func (en *en_MY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_MY' +func (en *en_MY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_MY' +func (en *en_MY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_MY' +func (en *en_MY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_MY' +func (en *en_MY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_MY' +func (en *en_MY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_MY/en_MY_test.go b/vendor/github.com/go-playground/locales/en_MY/en_MY_test.go new file mode 100644 index 0000000000..6d352bdc75 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_MY/en_MY_test.go @@ -0,0 +1,1120 @@ +package en_MY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_MY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_NA/en_NA.go b/vendor/github.com/go-playground/locales/en_NA/en_NA.go new file mode 100644 index 0000000000..3a1fa12079 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NA/en_NA.go @@ -0,0 +1,645 @@ +package en_NA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_NA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_NA' locale +func New() locales.Translator { + return &en_NA{ + locale: "en_NA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "$", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"TMT": "Turkmenistan Standard Time", "ACDT": "Australian Central Daylight Time", "AKDT": "Alaska Daylight Time", "UYST": "Uruguay Summer Time", "SRT": "Suriname Time", "GYT": "Guyana Time", "CHADT": "Chatham Daylight Time", "ECT": "Ecuador Time", "HECU": "Cuba Daylight Time", "ART": "Argentina Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "MEZ": "Central European Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "BT": "Bhutan Time", "WITA": "Central Indonesia Time", "UYT": "Uruguay Standard Time", "WAT": "West Africa Standard Time", "HEEG": "East Greenland Summer Time", "SAST": "South Africa Standard Time", "CST": "Central Standard Time", "CHAST": "Chatham Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "∅∅∅": "Acre Summer Time", "LHST": "Lord Howe Standard Time", "LHDT": "Lord Howe Daylight Time", "HNOG": "West Greenland Standard Time", "ARST": "Argentina Summer Time", "EST": "Eastern Standard Time", "COST": "Colombia Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "AEDT": "Australian Eastern Daylight Time", "HKT": "Hong Kong Standard Time", "WIT": "Eastern Indonesia Time", "PST": "Pacific Standard Time", "NZST": "New Zealand Standard Time", "VET": "Venezuela Time", "TMST": "Turkmenistan Summer Time", "EAT": "East Africa Time", "HKST": "Hong Kong Summer Time", "COT": "Colombia Standard Time", "HNT": "Newfoundland Standard Time", "MDT": "Mountain Daylight Time", "ChST": "Chamorro Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "AWDT": "Australian Western Daylight Time", "ACWST": "Australian Central Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "JST": "Japan Standard Time", "WEZ": "Western European Standard Time", "HAT": "Newfoundland Daylight Time", "AKST": "Alaska Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "BOT": "Bolivia Time", "MYT": "Malaysia Time", "WART": "Western Argentina Standard Time", "WIB": "Western Indonesia Time", "GMT": "Greenwich Mean Time", "WARST": "Western Argentina Summer Time", "CLT": "Chile Standard Time", "OEZ": "Eastern European Standard Time", "ACST": "Australian Central Standard Time", "HNEG": "East Greenland Standard Time", "AWST": "Australian Western Standard Time", "MESZ": "Central European Summer Time", "HEOG": "West Greenland Summer Time", "WAST": "West Africa Summer Time", "HNCU": "Cuba Standard Time", "SGT": "Singapore Standard Time", "NZDT": "New Zealand Daylight Time", "CAT": "Central Africa Time", "AEST": "Australian Eastern Standard Time", "OESZ": "Eastern European Summer Time", "WESZ": "Western European Summer Time", "EDT": "Eastern Daylight Time", "MST": "Mountain Standard Time", "GFT": "French Guiana Time", "PDT": "Pacific Daylight Time", "IST": "India Standard Time", "CLST": "Chile Summer Time", "ADT": "Atlantic Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "CDT": "Central Daylight Time", "JDT": "Japan Daylight Time", "AST": "Atlantic Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_NA) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_NA' +func (en *en_NA) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_NA' +func (en *en_NA) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_NA' +func (en *en_NA) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_NA' +func (en *en_NA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_NA' +func (en *en_NA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_NA' +func (en *en_NA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_NA) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_NA) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_NA) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_NA) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_NA) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_NA) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_NA) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_NA) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_NA) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_NA) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_NA) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_NA) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_NA) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_NA) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_NA' and handles both Whole and Real numbers based on 'v' +func (en *en_NA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_NA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_NA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_NA' +func (en *en_NA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_NA' +// in accounting notation. +func (en *en_NA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_NA' +func (en *en_NA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_NA' +func (en *en_NA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_NA' +func (en *en_NA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_NA' +func (en *en_NA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_NA' +func (en *en_NA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_NA' +func (en *en_NA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_NA' +func (en *en_NA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_NA' +func (en *en_NA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_NA/en_NA_test.go b/vendor/github.com/go-playground/locales/en_NA/en_NA_test.go new file mode 100644 index 0000000000..295a18514b --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NA/en_NA_test.go @@ -0,0 +1,1120 @@ +package en_NA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_NA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_NF/en_NF.go b/vendor/github.com/go-playground/locales/en_NF/en_NF.go new file mode 100644 index 0000000000..3497578fff --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NF/en_NF.go @@ -0,0 +1,607 @@ +package en_NF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_NF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_NF' locale +func New() locales.Translator { + return &en_NF{ + locale: "en_NF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HADT": "Hawaii-Aleutian Daylight Time", "WEZ": "Western European Standard Time", "AST": "Atlantic Standard Time", "ARST": "Argentina Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "BT": "Bhutan Time", "CDT": "Central Daylight Time", "SGT": "Singapore Standard Time", "VET": "Venezuela Time", "AKST": "Alaska Standard Time", "ECT": "Ecuador Time", "NZST": "New Zealand Standard Time", "MESZ": "Central European Summer Time", "OEZ": "Eastern European Standard Time", "HNOG": "West Greenland Standard Time", "ADT": "Atlantic Daylight Time", "AWDT": "Australian Western Daylight Time", "PDT": "Pacific Daylight Time", "HKT": "Hong Kong Standard Time", "ART": "Argentina Standard Time", "MDT": "Macau Summer Time", "ACWDT": "Australian Central Western Daylight Time", "HKST": "Hong Kong Summer Time", "HEEG": "East Greenland Summer Time", "WITA": "Central Indonesia Time", "SAST": "South Africa Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "ACWST": "Australian Central Western Standard Time", "HNPMX": "Mexican Pacific Standard Time", "∅∅∅": "Brasilia Summer Time", "PST": "Pacific Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "GYT": "Guyana Time", "MST": "Macau Standard Time", "EDT": "Eastern Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CHADT": "Chatham Daylight Time", "TMST": "Turkmenistan Summer Time", "WESZ": "Western European Summer Time", "MYT": "Malaysia Time", "CLT": "Chile Standard Time", "HNCU": "Cuba Standard Time", "WIB": "Western Indonesia Time", "CAT": "Central Africa Time", "WART": "Western Argentina Standard Time", "EST": "Eastern Standard Time", "WAST": "West Africa Summer Time", "COT": "Colombia Standard Time", "ACST": "Australian Central Standard Time", "CHAST": "Chatham Standard Time", "NZDT": "New Zealand Daylight Time", "HAT": "Newfoundland Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "GFT": "French Guiana Time", "ChST": "Chamorro Standard Time", "SRT": "Suriname Time", "BOT": "Bolivia Time", "MEZ": "Central European Standard Time", "UYST": "Uruguay Summer Time", "AWST": "Australian Western Standard Time", "HEOG": "West Greenland Summer Time", "TMT": "Turkmenistan Standard Time", "CST": "Central Standard Time", "JST": "Japan Standard Time", "JDT": "Japan Daylight Time", "AEDT": "Australian Eastern Daylight Time", "EAT": "East Africa Time", "IST": "India Standard Time", "HNT": "Newfoundland Standard Time", "LHDT": "Lord Howe Daylight Time", "WIT": "Eastern Indonesia Time", "GMT": "Greenwich Mean Time", "WAT": "West Africa Standard Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time", "HECU": "Cuba Daylight Time", "WARST": "Western Argentina Summer Time", "COST": "Colombia Summer Time", "ACDT": "Australian Central Daylight Time", "HNEG": "East Greenland Standard Time", "AKDT": "Alaska Daylight Time", "LHST": "Lord Howe Standard Time", "OESZ": "Eastern European Summer Time", "CLST": "Chile Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_NF) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_NF' +func (en *en_NF) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_NF' +func (en *en_NF) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_NF' +func (en *en_NF) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_NF' +func (en *en_NF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_NF' +func (en *en_NF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_NF' +func (en *en_NF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_NF) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_NF) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_NF) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_NF) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_NF) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_NF) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_NF) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_NF) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_NF) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_NF) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_NF) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_NF) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_NF) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_NF) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_NF' and handles both Whole and Real numbers based on 'v' +func (en *en_NF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_NF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_NF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_NF' +func (en *en_NF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_NF' +// in accounting notation. +func (en *en_NF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_NF' +func (en *en_NF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_NF' +func (en *en_NF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_NF' +func (en *en_NF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_NF' +func (en *en_NF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_NF' +func (en *en_NF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_NF' +func (en *en_NF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_NF' +func (en *en_NF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_NF' +func (en *en_NF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_NF/en_NF_test.go b/vendor/github.com/go-playground/locales/en_NF/en_NF_test.go new file mode 100644 index 0000000000..cd1026d1d3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NF/en_NF_test.go @@ -0,0 +1,1120 @@ +package en_NF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_NF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_NG/en_NG.go b/vendor/github.com/go-playground/locales/en_NG/en_NG.go new file mode 100644 index 0000000000..d47230cbe9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NG/en_NG.go @@ -0,0 +1,645 @@ +package en_NG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_NG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_NG' locale +func New() locales.Translator { + return &en_NG{ + locale: "en_NG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "₦", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AEST": "Australian Eastern Standard Time", "UYST": "Uruguay Summer Time", "WIB": "Western Indonesia Time", "∅∅∅": "Brasilia Summer Time", "AWDT": "Australian Western Daylight Time", "BOT": "Bolivia Time", "HAST": "Hawaii-Aleutian Standard Time", "ACWST": "Australian Central Western Standard Time", "LHST": "Lord Howe Standard Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "ART": "Argentina Standard Time", "HKT": "Hong Kong Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "PDT": "Pacific Daylight Time", "ADT": "Atlantic Daylight Time", "WARST": "Western Argentina Summer Time", "GYT": "Guyana Time", "ACWDT": "Australian Central Western Daylight Time", "MYT": "Malaysia Time", "CLST": "Chile Summer Time", "ACST": "Australian Central Standard Time", "COST": "Colombia Summer Time", "BT": "Bhutan Time", "HADT": "Hawaii-Aleutian Daylight Time", "JST": "Japan Standard Time", "OEZ": "Eastern European Standard Time", "CLT": "Chile Standard Time", "HNT": "Newfoundland Standard Time", "WART": "Western Argentina Standard Time", "HNEG": "East Greenland Standard Time", "SAST": "South Africa Standard Time", "ChST": "Chamorro Standard Time", "WIT": "Eastern Indonesia Time", "OESZ": "Eastern European Summer Time", "WEZ": "Western European Standard Time", "EDT": "Eastern Daylight Time", "ACDT": "Australian Central Daylight Time", "AKDT": "Alaska Daylight Time", "CHADT": "Chatham Daylight Time", "ECT": "Ecuador Time", "MDT": "Macau Summer Time", "COT": "Colombia Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "TMT": "Turkmenistan Standard Time", "TMST": "Turkmenistan Summer Time", "ARST": "Argentina Summer Time", "HKST": "Hong Kong Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CHAST": "Chatham Standard Time", "WESZ": "Western European Summer Time", "MST": "Macau Standard Time", "WAT": "West Africa Standard Time", "WAST": "West Africa Summer Time", "UYT": "Uruguay Standard Time", "IST": "India Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AEDT": "Australian Eastern Daylight Time", "CST": "Central Standard Time", "CDT": "Central Daylight Time", "SGT": "Singapore Standard Time", "VET": "Venezuela Time", "WITA": "Central Indonesia Time", "AKST": "Alaska Standard Time", "JDT": "Japan Daylight Time", "HNOG": "West Greenland Standard Time", "HAT": "Newfoundland Daylight Time", "HEEG": "East Greenland Summer Time", "SRT": "Suriname Time", "HNPMX": "Mexican Pacific Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "EAT": "East Africa Time", "AWST": "Australian Western Standard Time", "HEOG": "West Greenland Summer Time", "GMT": "Greenwich Mean Time", "GFT": "French Guiana Time", "LHDT": "Lord Howe Daylight Time", "HECU": "Cuba Daylight Time", "MESZ": "Central European Summer Time", "AST": "Atlantic Standard Time", "HNCU": "Cuba Standard Time", "PST": "Pacific Standard Time", "CAT": "Central Africa Time", "MEZ": "Central European Standard Time", "EST": "Eastern Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_NG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_NG' +func (en *en_NG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_NG' +func (en *en_NG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_NG' +func (en *en_NG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_NG' +func (en *en_NG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_NG' +func (en *en_NG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_NG' +func (en *en_NG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_NG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_NG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_NG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_NG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_NG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_NG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_NG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_NG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_NG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_NG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_NG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_NG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_NG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_NG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_NG' and handles both Whole and Real numbers based on 'v' +func (en *en_NG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_NG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_NG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_NG' +func (en *en_NG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_NG' +// in accounting notation. +func (en *en_NG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_NG' +func (en *en_NG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_NG' +func (en *en_NG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_NG' +func (en *en_NG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_NG' +func (en *en_NG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_NG' +func (en *en_NG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_NG' +func (en *en_NG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_NG' +func (en *en_NG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_NG' +func (en *en_NG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_NG/en_NG_test.go b/vendor/github.com/go-playground/locales/en_NG/en_NG_test.go new file mode 100644 index 0000000000..a638b5329c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NG/en_NG_test.go @@ -0,0 +1,1120 @@ +package en_NG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_NG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_NL/en_NL.go b/vendor/github.com/go-playground/locales/en_NL/en_NL.go new file mode 100644 index 0000000000..66218e2711 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NL/en_NL.go @@ -0,0 +1,647 @@ +package en_NL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_NL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_NL' locale +func New() locales.Translator { + return &en_NL{ + locale: "en_NL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: "( ", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"∅∅∅": "Azores Summer Time", "EAT": "East Africa Time", "CST": "Central Standard Time", "WARST": "Western Argentina Summer Time", "WAST": "West Africa Summer Time", "HAT": "Newfoundland Daylight Time", "MST": "Mountain Standard Time", "HECU": "Cuba Daylight Time", "SGT": "Singapore Standard Time", "EST": "Eastern Standard Time", "JDT": "Japan Daylight Time", "ARST": "Argentina Summer Time", "EDT": "Eastern Daylight Time", "COT": "Colombia Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNEG": "East Greenland Standard Time", "WITA": "Central Indonesia Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SAST": "South Africa Standard Time", "CDT": "Central Daylight Time", "AWST": "Australian Western Standard Time", "HKST": "Hong Kong Summer Time", "HEEG": "East Greenland Summer Time", "NZDT": "New Zealand Daylight Time", "OEZ": "Eastern European Standard Time", "MYT": "Malaysia Time", "UYST": "Uruguay Summer Time", "BOT": "Bolivia Time", "WART": "Western Argentina Standard Time", "CLT": "Chile Standard Time", "TMST": "Turkmenistan Summer Time", "WAT": "West Africa Standard Time", "AEST": "Australian Eastern Standard Time", "ChST": "Chamorro Standard Time", "LHST": "Lord Howe Standard Time", "WIT": "Eastern Indonesia Time", "HKT": "Hong Kong Standard Time", "BT": "Bhutan Time", "UYT": "Uruguay Standard Time", "HNCU": "Cuba Standard Time", "CHAST": "Chatham Standard Time", "CAT": "Central Africa Time", "OESZ": "Eastern European Summer Time", "ACWDT": "Australian Central Western Daylight Time", "ADT": "Atlantic Daylight Time", "ART": "Argentina Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "AWDT": "Australian Western Daylight Time", "ECT": "Ecuador Time", "AST": "Atlantic Standard Time", "ACDT": "Australian Central Daylight Time", "PDT": "Pacific Daylight Time", "NZST": "New Zealand Standard Time", "VET": "Venezuela Time", "GMT": "Greenwich Mean Time", "MEZ": "Central European Standard Time", "AEDT": "Australian Eastern Daylight Time", "LHDT": "Lord Howe Daylight Time", "SRT": "Suriname Time", "WIB": "Western Indonesia Time", "CHADT": "Chatham Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMT": "Turkmenistan Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AKDT": "Alaska Daylight Time", "ACWST": "Australian Central Western Standard Time", "CLST": "Chile Summer Time", "HEOG": "West Greenland Summer Time", "MESZ": "Central European Summer Time", "HNOG": "West Greenland Standard Time", "ACST": "Australian Central Standard Time", "COST": "Colombia Summer Time", "MDT": "Mountain Daylight Time", "GFT": "French Guiana Time", "PST": "Pacific Standard Time", "IST": "India Standard Time", "WEZ": "Western European Standard Time", "WESZ": "Western European Summer Time", "AKST": "Alaska Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "GYT": "Guyana Time", "JST": "Japan Standard Time", "HNT": "Newfoundland Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_NL) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_NL' +func (en *en_NL) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_NL' +func (en *en_NL) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_NL' +func (en *en_NL) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_NL' +func (en *en_NL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_NL' +func (en *en_NL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_NL' +func (en *en_NL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_NL) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_NL) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_NL) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_NL) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_NL) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_NL) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_NL) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_NL) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_NL) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_NL) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_NL) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_NL) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_NL) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_NL) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_NL' and handles both Whole and Real numbers based on 'v' +func (en *en_NL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_NL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_NL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_NL' +func (en *en_NL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_NL' +// in accounting notation. +func (en *en_NL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyNegativePrefix[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_NL' +func (en *en_NL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_NL' +func (en *en_NL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_NL' +func (en *en_NL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_NL' +func (en *en_NL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_NL' +func (en *en_NL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_NL' +func (en *en_NL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_NL' +func (en *en_NL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_NL' +func (en *en_NL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_NL/en_NL_test.go b/vendor/github.com/go-playground/locales/en_NL/en_NL_test.go new file mode 100644 index 0000000000..8f38259ae1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NL/en_NL_test.go @@ -0,0 +1,1120 @@ +package en_NL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_NL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_NR/en_NR.go b/vendor/github.com/go-playground/locales/en_NR/en_NR.go new file mode 100644 index 0000000000..a7cdc535cd --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NR/en_NR.go @@ -0,0 +1,607 @@ +package en_NR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_NR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_NR' locale +func New() locales.Translator { + return &en_NR{ + locale: "en_NR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ECT": "Ecuador Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CST": "Central Standard Time", "BOT": "Bolivia Time", "ACWST": "Australian Central Western Standard Time", "VET": "Venezuela Time", "EST": "Eastern Standard Time", "OEZ": "Eastern European Standard Time", "WART": "Western Argentina Standard Time", "MST": "Macau Standard Time", "HNT": "Newfoundland Standard Time", "HEEG": "East Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "WIB": "Western Indonesia Time", "JST": "Japan Standard Time", "GMT": "Greenwich Mean Time", "EDT": "Eastern Daylight Time", "ACDT": "Australian Central Daylight Time", "AKST": "Alaska Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "PST": "Pacific Standard Time", "HNOG": "West Greenland Standard Time", "AST": "Atlantic Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "AWDT": "Australian Western Daylight Time", "PDT": "Pacific Daylight Time", "JDT": "Japan Daylight Time", "WESZ": "Western European Summer Time", "TMT": "Turkmenistan Standard Time", "HKST": "Hong Kong Summer Time", "WIT": "Eastern Indonesia Time", "AWST": "Australian Western Standard Time", "OESZ": "Eastern European Summer Time", "CLT": "Chile Standard Time", "WAT": "West Africa Standard Time", "COST": "Colombia Summer Time", "SAST": "South Africa Standard Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "ADT": "Atlantic Daylight Time", "TMST": "Turkmenistan Summer Time", "WITA": "Central Indonesia Time", "HECU": "Cuba Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "IST": "India Standard Time", "CLST": "Chile Summer Time", "UYT": "Uruguay Standard Time", "ACST": "Australian Central Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "ChST": "Chamorro Standard Time", "HNCU": "Cuba Standard Time", "WARST": "Western Argentina Summer Time", "BT": "Bhutan Time", "AEST": "Australian Eastern Standard Time", "HNPMX": "Mexican Pacific Standard Time", "SRT": "Suriname Time", "∅∅∅": "Brasilia Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "CAT": "Central Africa Time", "MYT": "Malaysia Time", "WAST": "West Africa Summer Time", "COT": "Colombia Standard Time", "AKDT": "Alaska Daylight Time", "UYST": "Uruguay Summer Time", "CDT": "Central Daylight Time", "MESZ": "Central European Summer Time", "WEZ": "Western European Standard Time", "ART": "Argentina Standard Time", "CHAST": "Chatham Standard Time", "ACWDT": "Australian Central Western Daylight Time", "MDT": "Macau Summer Time", "ARST": "Argentina Summer Time", "HKT": "Hong Kong Standard Time", "HAT": "Newfoundland Daylight Time", "GFT": "French Guiana Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHDT": "Lord Howe Daylight Time", "EAT": "East Africa Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "MEZ": "Central European Standard Time", "HEOG": "West Greenland Summer Time", "HNEG": "East Greenland Standard Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_NR) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_NR' +func (en *en_NR) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_NR' +func (en *en_NR) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_NR' +func (en *en_NR) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_NR' +func (en *en_NR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_NR' +func (en *en_NR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_NR' +func (en *en_NR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_NR) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_NR) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_NR) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_NR) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_NR) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_NR) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_NR) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_NR) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_NR) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_NR) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_NR) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_NR) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_NR) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_NR) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_NR' and handles both Whole and Real numbers based on 'v' +func (en *en_NR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_NR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_NR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_NR' +func (en *en_NR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_NR' +// in accounting notation. +func (en *en_NR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_NR' +func (en *en_NR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_NR' +func (en *en_NR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_NR' +func (en *en_NR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_NR' +func (en *en_NR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_NR' +func (en *en_NR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_NR' +func (en *en_NR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_NR' +func (en *en_NR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_NR' +func (en *en_NR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_NR/en_NR_test.go b/vendor/github.com/go-playground/locales/en_NR/en_NR_test.go new file mode 100644 index 0000000000..061fe7584e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NR/en_NR_test.go @@ -0,0 +1,1120 @@ +package en_NR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_NR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_NU/en_NU.go b/vendor/github.com/go-playground/locales/en_NU/en_NU.go new file mode 100644 index 0000000000..8bac64c045 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NU/en_NU.go @@ -0,0 +1,607 @@ +package en_NU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_NU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_NU' locale +func New() locales.Translator { + return &en_NU{ + locale: "en_NU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WART": "Western Argentina Standard Time", "CLT": "Chile Standard Time", "AST": "Atlantic Standard Time", "ART": "Argentina Standard Time", "EDT": "Eastern Daylight Time", "ACST": "Australian Central Standard Time", "BOT": "Bolivia Time", "JST": "Japan Standard Time", "AKST": "Alaska Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "AWST": "Australian Western Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "PDT": "Pacific Daylight Time", "OESZ": "Eastern European Summer Time", "LHST": "Lord Howe Standard Time", "CHAST": "Chatham Standard Time", "ECT": "Ecuador Time", "WARST": "Western Argentina Summer Time", "MDT": "Macau Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "HNT": "Newfoundland Standard Time", "UYT": "Uruguay Standard Time", "UYST": "Uruguay Summer Time", "∅∅∅": "Brasilia Summer Time", "ACWDT": "Australian Central Western Daylight Time", "SRT": "Suriname Time", "HEOG": "West Greenland Summer Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "WAT": "West Africa Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HNEG": "East Greenland Standard Time", "CAT": "Central Africa Time", "HNOG": "West Greenland Standard Time", "GYT": "Guyana Time", "HEEG": "East Greenland Summer Time", "WITA": "Central Indonesia Time", "EST": "Eastern Standard Time", "EAT": "East Africa Time", "MEZ": "Central European Standard Time", "IST": "India Standard Time", "JDT": "Japan Daylight Time", "CLST": "Chile Summer Time", "GMT": "Greenwich Mean Time", "MYT": "Malaysia Time", "COT": "Colombia Standard Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "NZST": "New Zealand Standard Time", "MESZ": "Central European Summer Time", "WESZ": "Western European Summer Time", "TMST": "Turkmenistan Summer Time", "MST": "Macau Standard Time", "HKST": "Hong Kong Summer Time", "PST": "Pacific Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "AKDT": "Alaska Daylight Time", "LHDT": "Lord Howe Daylight Time", "CHADT": "Chatham Daylight Time", "BT": "Bhutan Time", "SGT": "Singapore Standard Time", "NZDT": "New Zealand Daylight Time", "TMT": "Turkmenistan Standard Time", "HKT": "Hong Kong Standard Time", "AEST": "Australian Eastern Standard Time", "SAST": "South Africa Standard Time", "HECU": "Cuba Daylight Time", "CDT": "Central Daylight Time", "COST": "Colombia Summer Time", "GFT": "French Guiana Time", "AEDT": "Australian Eastern Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "HNCU": "Cuba Standard Time", "AWDT": "Australian Western Daylight Time", "ARST": "Argentina Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "CST": "Central Standard Time", "ADT": "Atlantic Daylight Time", "WAST": "West Africa Summer Time", "ACDT": "Australian Central Daylight Time", "HAT": "Newfoundland Daylight Time", "ChST": "Chamorro Standard Time", "ACWST": "Australian Central Western Standard Time", "VET": "Venezuela Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_NU) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_NU' +func (en *en_NU) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_NU' +func (en *en_NU) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_NU' +func (en *en_NU) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_NU' +func (en *en_NU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_NU' +func (en *en_NU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_NU' +func (en *en_NU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_NU) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_NU) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_NU) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_NU) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_NU) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_NU) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_NU) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_NU) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_NU) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_NU) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_NU) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_NU) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_NU) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_NU) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_NU' and handles both Whole and Real numbers based on 'v' +func (en *en_NU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_NU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_NU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_NU' +func (en *en_NU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_NU' +// in accounting notation. +func (en *en_NU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_NU' +func (en *en_NU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_NU' +func (en *en_NU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_NU' +func (en *en_NU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_NU' +func (en *en_NU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_NU' +func (en *en_NU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_NU' +func (en *en_NU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_NU' +func (en *en_NU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_NU' +func (en *en_NU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_NU/en_NU_test.go b/vendor/github.com/go-playground/locales/en_NU/en_NU_test.go new file mode 100644 index 0000000000..c5954bc309 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NU/en_NU_test.go @@ -0,0 +1,1120 @@ +package en_NU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_NU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_NZ/en_NZ.go b/vendor/github.com/go-playground/locales/en_NZ/en_NZ.go new file mode 100644 index 0000000000..62fb95c7d7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NZ/en_NZ.go @@ -0,0 +1,609 @@ +package en_NZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_NZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_NZ' locale +func New() locales.Translator { + return &en_NZ{ + locale: "en_NZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AWDT": "Australian Western Daylight Time", "MESZ": "Central European Summer Time", "WESZ": "Western European Summer Time", "MDT": "Macau Summer Time", "GFT": "French Guiana Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "PST": "Pacific Standard Time", "AST": "Atlantic Standard Time", "ACDT": "Australian Central Daylight Time", "AKST": "Alaska Standard Time", "AKDT": "Alaska Daylight Time", "ChST": "Chamorro Standard Time", "BOT": "Bolivia Time", "ACWST": "Australian Central Western Standard Time", "WAST": "West Africa Summer Time", "COST": "Colombia Summer Time", "UYST": "Uruguay Summer Time", "HNPMX": "Mexican Pacific Standard Time", "HEOG": "West Greenland Summer Time", "EST": "Eastern Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "SAST": "South Africa Standard Time", "NZST": "New Zealand Standard Time", "∅∅∅": "Amazon Summer Time", "GMT": "Greenwich Mean Time", "HKT": "Hong Kong Standard Time", "HNEG": "East Greenland Standard Time", "OESZ": "Eastern European Summer Time", "WEZ": "Western European Standard Time", "TMT": "Turkmenistan Standard Time", "TMST": "Turkmenistan Summer Time", "COT": "Colombia Standard Time", "HEEG": "East Greenland Summer Time", "CDT": "Central Daylight Time", "CHAST": "Chatham Standard Time", "ART": "Argentina Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "IST": "India Standard Time", "HAT": "Newfoundland Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHST": "Lord Howe Standard Time", "LHDT": "Lord Howe Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "SGT": "Singapore Standard Time", "CAT": "Central Africa Time", "JST": "Japan Standard Time", "JDT": "Japan Daylight Time", "WART": "Western Argentina Standard Time", "CST": "Central Standard Time", "CLST": "Chile Summer Time", "AEST": "Australian Eastern Standard Time", "GYT": "Guyana Time", "ADT": "Atlantic Daylight Time", "ARST": "Argentina Summer Time", "ACWDT": "Australian Central Western Daylight Time", "VET": "Venezuela Time", "HNOG": "West Greenland Standard Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "MEZ": "Central European Standard Time", "EDT": "Eastern Daylight Time", "HKST": "Hong Kong Summer Time", "ACST": "Australian Central Standard Time", "HNT": "Newfoundland Standard Time", "WITA": "Central Indonesia Time", "UYT": "Uruguay Standard Time", "OEZ": "Eastern European Standard Time", "WAT": "West Africa Standard Time", "BT": "Bhutan Time", "AWST": "Australian Western Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "NZDT": "New Zealand Daylight Time", "MYT": "Malaysia Time", "WARST": "Western Argentina Summer Time", "MST": "Macau Standard Time", "CHADT": "Chatham Daylight Time", "PDT": "Pacific Daylight Time", "ECT": "Ecuador Time", "CLT": "Chile Standard Time", "AEDT": "Australian Eastern Daylight Time", "SRT": "Suriname Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_NZ) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_NZ' +func (en *en_NZ) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_NZ' +func (en *en_NZ) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_NZ' +func (en *en_NZ) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_NZ' +func (en *en_NZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_NZ' +func (en *en_NZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_NZ' +func (en *en_NZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_NZ) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_NZ) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_NZ) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_NZ) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_NZ) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_NZ) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_NZ) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_NZ) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_NZ) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_NZ) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_NZ) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_NZ) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_NZ) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_NZ) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_NZ' and handles both Whole and Real numbers based on 'v' +func (en *en_NZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_NZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_NZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_NZ' +func (en *en_NZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_NZ' +// in accounting notation. +func (en *en_NZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_NZ' +func (en *en_NZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_NZ' +func (en *en_NZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_NZ' +func (en *en_NZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_NZ' +func (en *en_NZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_NZ' +func (en *en_NZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_NZ' +func (en *en_NZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_NZ' +func (en *en_NZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_NZ' +func (en *en_NZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_NZ/en_NZ_test.go b/vendor/github.com/go-playground/locales/en_NZ/en_NZ_test.go new file mode 100644 index 0000000000..9a9b0ef3bc --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_NZ/en_NZ_test.go @@ -0,0 +1,1120 @@ +package en_NZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_NZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_PG/en_PG.go b/vendor/github.com/go-playground/locales/en_PG/en_PG.go new file mode 100644 index 0000000000..178826407b --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PG/en_PG.go @@ -0,0 +1,645 @@ +package en_PG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_PG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_PG' locale +func New() locales.Translator { + return &en_PG{ + locale: "en_PG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "K", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"MESZ": "Central European Summer Time", "JST": "Japan Standard Time", "CLT": "Chile Standard Time", "TMST": "Turkmenistan Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "SAST": "South Africa Standard Time", "LHDT": "Lord Howe Daylight Time", "EST": "Eastern Standard Time", "HECU": "Cuba Daylight Time", "CHADT": "Chatham Daylight Time", "CLST": "Chile Summer Time", "EDT": "Eastern Daylight Time", "HKST": "Hong Kong Summer Time", "ACST": "Australian Central Standard Time", "HNEG": "East Greenland Standard Time", "HEEG": "East Greenland Summer Time", "HNPMX": "Mexican Pacific Standard Time", "GYT": "Guyana Time", "HAST": "Hawaii-Aleutian Standard Time", "MYT": "Malaysia Time", "WARST": "Western Argentina Summer Time", "AEST": "Australian Eastern Standard Time", "CHAST": "Chatham Standard Time", "HKT": "Hong Kong Standard Time", "COST": "Colombia Summer Time", "AWDT": "Australian Western Daylight Time", "ACWST": "Australian Central Western Standard Time", "OEZ": "Eastern European Standard Time", "TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "AEDT": "Australian Eastern Daylight Time", "∅∅∅": "Azores Summer Time", "IST": "India Standard Time", "HEOG": "West Greenland Summer Time", "WEZ": "Western European Standard Time", "ART": "Argentina Standard Time", "AKST": "Alaska Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "EAT": "East Africa Time", "ACWDT": "Australian Central Western Daylight Time", "MDT": "Macau Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "GFT": "French Guiana Time", "WIT": "Eastern Indonesia Time", "PST": "Pacific Standard Time", "ECT": "Ecuador Time", "MST": "Macau Standard Time", "ARST": "Argentina Summer Time", "AKDT": "Alaska Daylight Time", "CDT": "Central Daylight Time", "AST": "Atlantic Standard Time", "WART": "Western Argentina Standard Time", "BT": "Bhutan Time", "HNT": "Newfoundland Standard Time", "NZDT": "New Zealand Daylight Time", "JDT": "Japan Daylight Time", "OESZ": "Eastern European Summer Time", "ChST": "Chamorro Standard Time", "UYT": "Uruguay Standard Time", "WIB": "Western Indonesia Time", "AWST": "Australian Western Standard Time", "SGT": "Singapore Standard Time", "WAST": "West Africa Summer Time", "GMT": "Greenwich Mean Time", "UYST": "Uruguay Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "PDT": "Pacific Daylight Time", "VET": "Venezuela Time", "HNOG": "West Greenland Standard Time", "HNCU": "Cuba Standard Time", "BOT": "Bolivia Time", "WESZ": "Western European Summer Time", "ACDT": "Australian Central Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHST": "Lord Howe Standard Time", "NZST": "New Zealand Standard Time", "WITA": "Central Indonesia Time", "CST": "Central Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "CAT": "Central Africa Time", "MEZ": "Central European Standard Time", "COT": "Colombia Standard Time", "SRT": "Suriname Time", "ADT": "Atlantic Daylight Time", "HAT": "Newfoundland Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_PG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_PG' +func (en *en_PG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_PG' +func (en *en_PG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_PG' +func (en *en_PG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_PG' +func (en *en_PG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_PG' +func (en *en_PG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_PG' +func (en *en_PG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_PG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_PG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_PG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_PG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_PG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_PG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_PG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_PG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_PG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_PG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_PG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_PG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_PG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_PG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_PG' and handles both Whole and Real numbers based on 'v' +func (en *en_PG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_PG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_PG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_PG' +func (en *en_PG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_PG' +// in accounting notation. +func (en *en_PG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_PG' +func (en *en_PG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_PG' +func (en *en_PG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_PG' +func (en *en_PG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_PG' +func (en *en_PG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_PG' +func (en *en_PG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_PG' +func (en *en_PG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_PG' +func (en *en_PG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_PG' +func (en *en_PG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_PG/en_PG_test.go b/vendor/github.com/go-playground/locales/en_PG/en_PG_test.go new file mode 100644 index 0000000000..6b6a1b9469 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PG/en_PG_test.go @@ -0,0 +1,1120 @@ +package en_PG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_PG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_PH/en_PH.go b/vendor/github.com/go-playground/locales/en_PH/en_PH.go new file mode 100644 index 0000000000..514a095141 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PH/en_PH.go @@ -0,0 +1,645 @@ +package en_PH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_PH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_PH' locale +func New() locales.Translator { + return &en_PH{ + locale: "en_PH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "₱", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AKDT": "Alaska Daylight Time", "CST": "Central Standard Time", "GMT": "Greenwich Mean Time", "OEZ": "Eastern European Standard Time", "HECU": "Cuba Daylight Time", "AWST": "Australian Western Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "WESZ": "Western European Summer Time", "LHDT": "Lord Howe Daylight Time", "LHST": "Lord Howe Standard Time", "PDT": "Pacific Daylight Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "OESZ": "Eastern European Summer Time", "WAST": "West Africa Summer Time", "HNEG": "East Greenland Standard Time", "SAST": "South Africa Standard Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "JST": "Japan Standard Time", "JDT": "Japan Daylight Time", "AST": "Atlantic Standard Time", "TMT": "Turkmenistan Standard Time", "COST": "Colombia Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "GFT": "French Guiana Time", "HEEG": "East Greenland Summer Time", "MST": "Macau Standard Time", "HNPMX": "Mexican Pacific Standard Time", "WIB": "Western Indonesia Time", "MEZ": "Central European Standard Time", "CLST": "Chile Summer Time", "HAT": "Newfoundland Daylight Time", "SRT": "Suriname Time", "UYST": "Uruguay Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "AWDT": "Australian Western Daylight Time", "EST": "Eastern Standard Time", "AEDT": "Australian Eastern Daylight Time", "UYT": "Uruguay Standard Time", "ACWST": "Australian Central Western Standard Time", "VET": "Venezuela Time", "HNNOMX": "Northwest Mexico Standard Time", "CHADT": "Chatham Daylight Time", "CHAST": "Chatham Standard Time", "SGT": "Singapore Standard Time", "PST": "Pacific Standard Time", "WEZ": "Western European Standard Time", "WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "CLT": "Chile Standard Time", "ADT": "Atlantic Daylight Time", "WAT": "West Africa Standard Time", "EDT": "Eastern Daylight Time", "AEST": "Australian Eastern Standard Time", "WART": "Western Argentina Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "HNOG": "West Greenland Standard Time", "TMST": "Turkmenistan Summer Time", "ACDT": "Australian Central Daylight Time", "CDT": "Central Daylight Time", "WIT": "Eastern Indonesia Time", "BOT": "Bolivia Time", "MYT": "Malaysia Time", "COT": "Colombia Standard Time", "ChST": "Chamorro Standard Time", "GYT": "Guyana Time", "CAT": "Central Africa Time", "MESZ": "Central European Summer Time", "ARST": "Argentina Summer Time", "ACST": "Australian Central Standard Time", "BT": "Bhutan Time", "∅∅∅": "Azores Summer Time", "WARST": "Western Argentina Summer Time", "HEOG": "West Greenland Summer Time", "ART": "Argentina Standard Time", "HKT": "Hong Kong Standard Time", "ACWDT": "Australian Central Western Daylight Time", "IST": "India Standard Time", "MDT": "Macau Summer Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HNT": "Newfoundland Standard Time", "AKST": "Alaska Standard Time", "ECT": "Ecuador Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_PH) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_PH' +func (en *en_PH) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_PH' +func (en *en_PH) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_PH' +func (en *en_PH) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_PH' +func (en *en_PH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_PH' +func (en *en_PH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_PH' +func (en *en_PH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_PH) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_PH) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_PH) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_PH) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_PH) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_PH) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_PH) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_PH) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_PH) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_PH) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_PH) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_PH) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_PH) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_PH) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_PH' and handles both Whole and Real numbers based on 'v' +func (en *en_PH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_PH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_PH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_PH' +func (en *en_PH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_PH' +// in accounting notation. +func (en *en_PH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_PH' +func (en *en_PH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_PH' +func (en *en_PH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_PH' +func (en *en_PH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_PH' +func (en *en_PH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_PH' +func (en *en_PH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_PH' +func (en *en_PH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_PH' +func (en *en_PH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_PH' +func (en *en_PH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_PH/en_PH_test.go b/vendor/github.com/go-playground/locales/en_PH/en_PH_test.go new file mode 100644 index 0000000000..5e4927a465 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PH/en_PH_test.go @@ -0,0 +1,1120 @@ +package en_PH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_PH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_PK/en_PK.go b/vendor/github.com/go-playground/locales/en_PK/en_PK.go new file mode 100644 index 0000000000..61db10e544 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PK/en_PK.go @@ -0,0 +1,601 @@ +package en_PK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_PK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_PK' locale +func New() locales.Translator { + return &en_PK{ + locale: "en_PK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "Rs", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"PST": "Pacific Standard Time", "HEOG": "West Greenland Summer Time", "BT": "Bhutan Time", "AKST": "Alaska Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "∅∅∅": "Brasilia Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "NZST": "New Zealand Standard Time", "ACWST": "Australian Central Western Standard Time", "MEZ": "Central European Standard Time", "HKT": "Hong Kong Standard Time", "MYT": "Malaysia Time", "ADT": "Atlantic Daylight Time", "WEZ": "Western European Standard Time", "GFT": "French Guiana Time", "CST": "Central Standard Time", "CHAST": "Chatham Standard Time", "JDT": "Japan Daylight Time", "WART": "Western Argentina Standard Time", "ACST": "Australian Central Standard Time", "COT": "Colombia Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "AEDT": "Australian Eastern Daylight Time", "AKDT": "Alaska Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "JST": "Japan Standard Time", "TMT": "Turkmenistan Standard Time", "MDT": "Macau Summer Time", "WITA": "Central Indonesia Time", "UYST": "Uruguay Summer Time", "GYT": "Guyana Time", "GMT": "Greenwich Mean Time", "AST": "Atlantic Standard Time", "WESZ": "Western European Summer Time", "ARST": "Argentina Summer Time", "EDT": "Eastern Daylight Time", "WAST": "West Africa Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "BOT": "Bolivia Time", "ART": "Argentina Standard Time", "HNCU": "Cuba Standard Time", "PDT": "Pacific Daylight Time", "ChST": "Chamorro Standard Time", "SRT": "Suriname Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "ECT": "Ecuador Time", "NZDT": "New Zealand Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "CLT": "Chile Standard Time", "CLST": "Chile Summer Time", "OEZ": "Eastern European Standard Time", "HKST": "Hong Kong Summer Time", "HNT": "Newfoundland Standard Time", "EAT": "East Africa Time", "WIB": "Western Indonesia Time", "WAT": "West Africa Standard Time", "SAST": "South Africa Standard Time", "LHST": "Lord Howe Standard Time", "HECU": "Cuba Daylight Time", "AWDT": "Australian Western Daylight Time", "IST": "India Standard Time", "VET": "Venezuela Time", "TMST": "Turkmenistan Summer Time", "CDT": "Central Daylight Time", "HNEG": "East Greenland Standard Time", "LHDT": "Lord Howe Daylight Time", "CAT": "Central Africa Time", "MESZ": "Central European Summer Time", "HAT": "Newfoundland Daylight Time", "AEST": "Australian Eastern Standard Time", "AWST": "Australian Western Standard Time", "HNOG": "West Greenland Standard Time", "COST": "Colombia Summer Time", "HEEG": "East Greenland Summer Time", "WIT": "Eastern Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "WARST": "Western Argentina Summer Time", "OESZ": "Eastern European Summer Time", "MST": "Macau Standard Time", "EST": "Eastern Standard Time", "ACDT": "Australian Central Daylight Time", "UYT": "Uruguay Standard Time", "HEPMX": "Mexican Pacific Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_PK) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_PK' +func (en *en_PK) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_PK' +func (en *en_PK) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_PK' +func (en *en_PK) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_PK' +func (en *en_PK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_PK' +func (en *en_PK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_PK' +func (en *en_PK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_PK) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_PK) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_PK) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_PK) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_PK) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_PK) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_PK) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_PK) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_PK) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_PK) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_PK) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_PK) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_PK) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_PK) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_PK' and handles both Whole and Real numbers based on 'v' +func (en *en_PK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_PK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_PK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_PK' +func (en *en_PK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_PK' +// in accounting notation. +func (en *en_PK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_PK' +func (en *en_PK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_PK' +func (en *en_PK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_PK' +func (en *en_PK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_PK' +func (en *en_PK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_PK' +func (en *en_PK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_PK' +func (en *en_PK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_PK' +func (en *en_PK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_PK' +func (en *en_PK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_PK/en_PK_test.go b/vendor/github.com/go-playground/locales/en_PK/en_PK_test.go new file mode 100644 index 0000000000..e397e1f4bd --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PK/en_PK_test.go @@ -0,0 +1,1120 @@ +package en_PK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_PK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_PN/en_PN.go b/vendor/github.com/go-playground/locales/en_PN/en_PN.go new file mode 100644 index 0000000000..2ea7fd0dd1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PN/en_PN.go @@ -0,0 +1,607 @@ +package en_PN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_PN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_PN' locale +func New() locales.Translator { + return &en_PN{ + locale: "en_PN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"GMT": "Greenwich Mean Time", "AKDT": "Alaska Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "BOT": "Bolivia Time", "NZST": "New Zealand Standard Time", "JST": "Japan Standard Time", "NZDT": "New Zealand Daylight Time", "EST": "Eastern Standard Time", "HKT": "Hong Kong Standard Time", "HNT": "Newfoundland Standard Time", "HNCU": "Cuba Standard Time", "CDT": "Central Daylight Time", "PDT": "Pacific Daylight Time", "IST": "India Standard Time", "CHAST": "Chatham Standard Time", "GFT": "French Guiana Time", "AEDT": "Australian Eastern Daylight Time", "ChST": "Chamorro Standard Time", "PST": "Pacific Standard Time", "ECT": "Ecuador Time", "LHST": "Lord Howe Standard Time", "HECU": "Cuba Daylight Time", "CHADT": "Chatham Daylight Time", "EDT": "Eastern Daylight Time", "COT": "Colombia Standard Time", "LHDT": "Lord Howe Daylight Time", "GYT": "Guyana Time", "AWDT": "Australian Western Daylight Time", "HKST": "Hong Kong Summer Time", "UYST": "Uruguay Summer Time", "WARST": "Western Argentina Summer Time", "UYT": "Uruguay Standard Time", "SGT": "Singapore Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "∅∅∅": "Amazon Summer Time", "WAST": "West Africa Summer Time", "VET": "Venezuela Time", "TMST": "Turkmenistan Summer Time", "MDT": "Macau Summer Time", "WAT": "West Africa Standard Time", "COST": "Colombia Summer Time", "BT": "Bhutan Time", "CST": "Central Standard Time", "HEOG": "West Greenland Summer Time", "WEZ": "Western European Standard Time", "OESZ": "Eastern European Summer Time", "ACST": "Australian Central Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HNEG": "East Greenland Standard Time", "EAT": "East Africa Time", "CLT": "Chile Standard Time", "OEZ": "Eastern European Standard Time", "TMT": "Turkmenistan Standard Time", "MST": "Macau Standard Time", "ARST": "Argentina Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "MEZ": "Central European Standard Time", "AST": "Atlantic Standard Time", "AEST": "Australian Eastern Standard Time", "WIB": "Western Indonesia Time", "MESZ": "Central European Summer Time", "WESZ": "Western European Summer Time", "WART": "Western Argentina Standard Time", "ACDT": "Australian Central Daylight Time", "HAT": "Newfoundland Daylight Time", "HEEG": "East Greenland Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "WIT": "Eastern Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "ACWDT": "Australian Central Western Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "WITA": "Central Indonesia Time", "SAST": "South Africa Standard Time", "AWST": "Australian Western Standard Time", "JDT": "Japan Daylight Time", "ART": "Argentina Standard Time", "HNOG": "West Greenland Standard Time", "MYT": "Malaysia Time", "HNPM": "St. Pierre & Miquelon Standard Time", "ACWST": "Australian Central Western Standard Time", "CLST": "Chile Summer Time", "AKST": "Alaska Standard Time", "SRT": "Suriname Time", "CAT": "Central Africa Time", "ADT": "Atlantic Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_PN) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_PN' +func (en *en_PN) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_PN' +func (en *en_PN) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_PN' +func (en *en_PN) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_PN' +func (en *en_PN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_PN' +func (en *en_PN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_PN' +func (en *en_PN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_PN) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_PN) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_PN) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_PN) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_PN) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_PN) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_PN) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_PN) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_PN) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_PN) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_PN) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_PN) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_PN) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_PN) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_PN' and handles both Whole and Real numbers based on 'v' +func (en *en_PN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_PN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_PN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_PN' +func (en *en_PN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_PN' +// in accounting notation. +func (en *en_PN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_PN' +func (en *en_PN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_PN' +func (en *en_PN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_PN' +func (en *en_PN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_PN' +func (en *en_PN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_PN' +func (en *en_PN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_PN' +func (en *en_PN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_PN' +func (en *en_PN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_PN' +func (en *en_PN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_PN/en_PN_test.go b/vendor/github.com/go-playground/locales/en_PN/en_PN_test.go new file mode 100644 index 0000000000..72e1ed6252 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PN/en_PN_test.go @@ -0,0 +1,1120 @@ +package en_PN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_PN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_PR/en_PR.go b/vendor/github.com/go-playground/locales/en_PR/en_PR.go new file mode 100644 index 0000000000..c7d96752c1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PR/en_PR.go @@ -0,0 +1,635 @@ +package en_PR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_PR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_PR' locale +func New() locales.Translator { + return &en_PR{ + locale: "en_PR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"TMT": "Turkmenistan Standard Time", "MST": "Macau Standard Time", "AKST": "Alaska Standard Time", "WIB": "Western Indonesia Time", "PST": "Pacific Standard Time", "IST": "India Standard Time", "ACWST": "Australian Central Western Standard Time", "OEZ": "Eastern European Standard Time", "WAT": "West Africa Standard Time", "SAST": "South Africa Standard Time", "WIT": "Eastern Indonesia Time", "MESZ": "Central European Summer Time", "HNOG": "West Greenland Standard Time", "ARST": "Argentina Summer Time", "AKDT": "Alaska Daylight Time", "GFT": "French Guiana Time", "ChST": "Chamorro Standard Time", "SRT": "Suriname Time", "HNCU": "Cuba Standard Time", "GMT": "Greenwich Mean Time", "HKT": "Hong Kong Standard Time", "PDT": "Pacific Daylight Time", "MEZ": "Central European Standard Time", "AST": "Atlantic Standard Time", "COST": "Colombia Summer Time", "BT": "Bhutan Time", "HAT": "Newfoundland Daylight Time", "AEDT": "Australian Eastern Daylight Time", "∅∅∅": "Azores Summer Time", "AWST": "Australian Western Standard Time", "CAT": "Central Africa Time", "WARST": "Western Argentina Summer Time", "WAST": "West Africa Summer Time", "CHADT": "Chatham Daylight Time", "CLT": "Chile Standard Time", "EST": "Eastern Standard Time", "HKST": "Hong Kong Summer Time", "ACST": "Australian Central Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CST": "Central Standard Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "UYST": "Uruguay Summer Time", "HNPMX": "Mexican Pacific Standard Time", "WART": "Western Argentina Standard Time", "MDT": "Macau Summer Time", "WITA": "Central Indonesia Time", "TMST": "Turkmenistan Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "JST": "Japan Standard Time", "CDT": "Central Daylight Time", "BOT": "Bolivia Time", "ART": "Argentina Standard Time", "HEOG": "West Greenland Summer Time", "EDT": "Eastern Daylight Time", "ACDT": "Australian Central Daylight Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "ECT": "Ecuador Time", "VET": "Venezuela Time", "CLST": "Chile Summer Time", "GYT": "Guyana Time", "JDT": "Japan Daylight Time", "ADT": "Atlantic Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "HNEG": "East Greenland Standard Time", "EAT": "East Africa Time", "SGT": "Singapore Standard Time", "HNT": "Newfoundland Standard Time", "WEZ": "Western European Standard Time", "MYT": "Malaysia Time", "COT": "Colombia Standard Time", "LHST": "Lord Howe Standard Time", "AWDT": "Australian Western Daylight Time", "CHAST": "Chatham Standard Time", "NZST": "New Zealand Standard Time", "OESZ": "Eastern European Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HEEG": "East Greenland Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "AEST": "Australian Eastern Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_PR) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_PR' +func (en *en_PR) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_PR' +func (en *en_PR) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_PR' +func (en *en_PR) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_PR' +func (en *en_PR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_PR' +func (en *en_PR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_PR' +func (en *en_PR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_PR) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_PR) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_PR) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_PR) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_PR) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_PR) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_PR) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_PR) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_PR) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_PR) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_PR) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_PR) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_PR) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_PR) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_PR' and handles both Whole and Real numbers based on 'v' +func (en *en_PR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_PR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_PR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_PR' +func (en *en_PR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_PR' +// in accounting notation. +func (en *en_PR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_PR' +func (en *en_PR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_PR' +func (en *en_PR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_PR' +func (en *en_PR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_PR' +func (en *en_PR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_PR' +func (en *en_PR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_PR' +func (en *en_PR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_PR' +func (en *en_PR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_PR' +func (en *en_PR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_PR/en_PR_test.go b/vendor/github.com/go-playground/locales/en_PR/en_PR_test.go new file mode 100644 index 0000000000..f0baaf4ead --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PR/en_PR_test.go @@ -0,0 +1,1120 @@ +package en_PR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_PR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_PW/en_PW.go b/vendor/github.com/go-playground/locales/en_PW/en_PW.go new file mode 100644 index 0000000000..4bac37edea --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PW/en_PW.go @@ -0,0 +1,645 @@ +package en_PW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_PW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_PW' locale +func New() locales.Translator { + return &en_PW{ + locale: "en_PW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WIT": "Eastern Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "TMST": "Turkmenistan Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "HNEG": "East Greenland Standard Time", "GFT": "French Guiana Time", "CHAST": "Chatham Standard Time", "VET": "Venezuela Time", "MEZ": "Central European Standard Time", "WEZ": "Western European Standard Time", "CHADT": "Chatham Daylight Time", "WAST": "West Africa Summer Time", "HNPMX": "Mexican Pacific Standard Time", "AWST": "Australian Western Standard Time", "ARST": "Argentina Summer Time", "WIB": "Western Indonesia Time", "EAT": "East Africa Time", "SGT": "Singapore Standard Time", "GMT": "Greenwich Mean Time", "HEOG": "West Greenland Summer Time", "LHDT": "Lord Howe Daylight Time", "OEZ": "Eastern European Standard Time", "AST": "Atlantic Standard Time", "HECU": "Cuba Daylight Time", "AKDT": "Alaska Daylight Time", "∅∅∅": "Brasilia Summer Time", "CDT": "Central Daylight Time", "ACWST": "Australian Central Western Standard Time", "ACST": "Australian Central Standard Time", "SRT": "Suriname Time", "NZST": "New Zealand Standard Time", "CLT": "Chile Standard Time", "HNT": "Newfoundland Standard Time", "UYT": "Uruguay Standard Time", "ART": "Argentina Standard Time", "AEST": "Australian Eastern Standard Time", "WITA": "Central Indonesia Time", "UYST": "Uruguay Summer Time", "AWDT": "Australian Western Daylight Time", "PDT": "Pacific Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "HNOG": "West Greenland Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time", "ADT": "Atlantic Daylight Time", "EDT": "Eastern Daylight Time", "HKT": "Hong Kong Standard Time", "WAT": "West Africa Standard Time", "HKST": "Hong Kong Summer Time", "CST": "Central Standard Time", "MESZ": "Central European Summer Time", "WESZ": "Western European Summer Time", "TMT": "Turkmenistan Standard Time", "HEEG": "East Greenland Summer Time", "ECT": "Ecuador Time", "NZDT": "New Zealand Daylight Time", "JST": "Japan Standard Time", "COT": "Colombia Standard Time", "WARST": "Western Argentina Summer Time", "AEDT": "Australian Eastern Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SAST": "South Africa Standard Time", "CAT": "Central Africa Time", "JDT": "Japan Daylight Time", "OESZ": "Eastern European Summer Time", "WART": "Western Argentina Standard Time", "HNCU": "Cuba Standard Time", "HAT": "Newfoundland Daylight Time", "ChST": "Chamorro Standard Time", "IST": "India Standard Time", "MDT": "Macau Summer Time", "EST": "Eastern Standard Time", "COST": "Colombia Summer Time", "CLST": "Chile Summer Time", "MST": "Macau Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AKST": "Alaska Standard Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "BOT": "Bolivia Time", "PST": "Pacific Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MYT": "Malaysia Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_PW) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_PW' +func (en *en_PW) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_PW' +func (en *en_PW) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_PW' +func (en *en_PW) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_PW' +func (en *en_PW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_PW' +func (en *en_PW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_PW' +func (en *en_PW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_PW) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_PW) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_PW) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_PW) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_PW) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_PW) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_PW) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_PW) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_PW) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_PW) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_PW) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_PW) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_PW) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_PW) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_PW' and handles both Whole and Real numbers based on 'v' +func (en *en_PW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_PW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_PW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_PW' +func (en *en_PW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_PW' +// in accounting notation. +func (en *en_PW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_PW' +func (en *en_PW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_PW' +func (en *en_PW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_PW' +func (en *en_PW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_PW' +func (en *en_PW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_PW' +func (en *en_PW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_PW' +func (en *en_PW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_PW' +func (en *en_PW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_PW' +func (en *en_PW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_PW/en_PW_test.go b/vendor/github.com/go-playground/locales/en_PW/en_PW_test.go new file mode 100644 index 0000000000..90a3ab0674 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_PW/en_PW_test.go @@ -0,0 +1,1120 @@ +package en_PW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_PW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_RW/en_RW.go b/vendor/github.com/go-playground/locales/en_RW/en_RW.go new file mode 100644 index 0000000000..2fa62eb661 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_RW/en_RW.go @@ -0,0 +1,607 @@ +package en_RW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_RW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_RW' locale +func New() locales.Translator { + return &en_RW{ + locale: "en_RW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"BOT": "Bolivia Time", "PDT": "Pacific Daylight Time", "NZST": "New Zealand Standard Time", "HNOG": "West Greenland Standard Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "HNCU": "Cuba Standard Time", "PST": "Pacific Standard Time", "ACWDT": "Australian Central Western Daylight Time", "ART": "Argentina Standard Time", "WAT": "West Africa Standard Time", "EST": "Eastern Standard Time", "HKT": "Hong Kong Standard Time", "CDT": "Central Daylight Time", "TMT": "Turkmenistan Standard Time", "GYT": "Guyana Time", "MEZ": "Central European Standard Time", "VET": "Venezuela Time", "UYT": "Uruguay Standard Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "CHADT": "Chatham Daylight Time", "ACWST": "Australian Central Western Standard Time", "WARST": "Western Argentina Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "NZDT": "New Zealand Daylight Time", "JDT": "Japan Daylight Time", "GMT": "Greenwich Mean Time", "ARST": "Argentina Summer Time", "HEEG": "East Greenland Summer Time", "GFT": "French Guiana Time", "ChST": "Chamorro Standard Time", "LHST": "Lord Howe Standard Time", "EAT": "East Africa Time", "AWST": "Australian Western Standard Time", "COT": "Colombia Standard Time", "BT": "Bhutan Time", "LHDT": "Lord Howe Daylight Time", "SRT": "Suriname Time", "HADT": "Hawaii-Aleutian Daylight Time", "CAT": "Central Africa Time", "JST": "Japan Standard Time", "WART": "Western Argentina Standard Time", "HNEG": "East Greenland Standard Time", "CHAST": "Chatham Standard Time", "OESZ": "Eastern European Summer Time", "CLST": "Chile Summer Time", "AKST": "Alaska Standard Time", "∅∅∅": "Brasilia Summer Time", "WESZ": "Western European Summer Time", "CLT": "Chile Standard Time", "MST": "Macau Standard Time", "HKST": "Hong Kong Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "UYST": "Uruguay Summer Time", "ECT": "Ecuador Time", "ADT": "Atlantic Daylight Time", "HNT": "Newfoundland Standard Time", "AEDT": "Australian Eastern Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SAST": "South Africa Standard Time", "MESZ": "Central European Summer Time", "TMST": "Turkmenistan Summer Time", "ACDT": "Australian Central Daylight Time", "AEST": "Australian Eastern Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "AWDT": "Australian Western Daylight Time", "SGT": "Singapore Standard Time", "MYT": "Malaysia Time", "MDT": "Macau Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "WIB": "Western Indonesia Time", "HEOG": "West Greenland Summer Time", "WAST": "West Africa Summer Time", "ACST": "Australian Central Standard Time", "HAT": "Newfoundland Daylight Time", "WITA": "Central Indonesia Time", "HNPMX": "Mexican Pacific Standard Time", "WIT": "Eastern Indonesia Time", "IST": "India Standard Time", "AST": "Atlantic Standard Time", "EDT": "Eastern Daylight Time", "COST": "Colombia Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "AKDT": "Alaska Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_RW) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_RW' +func (en *en_RW) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_RW' +func (en *en_RW) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_RW' +func (en *en_RW) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_RW' +func (en *en_RW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_RW' +func (en *en_RW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_RW' +func (en *en_RW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_RW) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_RW) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_RW) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_RW) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_RW) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_RW) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_RW) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_RW) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_RW) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_RW) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_RW) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_RW) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_RW) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_RW) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_RW' and handles both Whole and Real numbers based on 'v' +func (en *en_RW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_RW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_RW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_RW' +func (en *en_RW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_RW' +// in accounting notation. +func (en *en_RW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_RW' +func (en *en_RW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_RW' +func (en *en_RW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_RW' +func (en *en_RW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_RW' +func (en *en_RW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_RW' +func (en *en_RW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_RW' +func (en *en_RW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_RW' +func (en *en_RW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_RW' +func (en *en_RW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_RW/en_RW_test.go b/vendor/github.com/go-playground/locales/en_RW/en_RW_test.go new file mode 100644 index 0000000000..7698296cb5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_RW/en_RW_test.go @@ -0,0 +1,1120 @@ +package en_RW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_RW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SB/en_SB.go b/vendor/github.com/go-playground/locales/en_SB/en_SB.go new file mode 100644 index 0000000000..f348113438 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SB/en_SB.go @@ -0,0 +1,645 @@ +package en_SB + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SB struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SB' locale +func New() locales.Translator { + return &en_SB{ + locale: "en_SB", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "$", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HNT": "Newfoundland Standard Time", "CHADT": "Chatham Daylight Time", "IST": "India Standard Time", "VET": "Venezuela Time", "CLT": "Chile Standard Time", "LHDT": "Lord Howe Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "ECT": "Ecuador Time", "ACWST": "Australian Central Western Standard Time", "UYST": "Uruguay Summer Time", "CDT": "Central Daylight Time", "JDT": "Japan Daylight Time", "WARST": "Western Argentina Summer Time", "ADT": "Atlantic Daylight Time", "WEZ": "Western European Standard Time", "GMT": "Greenwich Mean Time", "WART": "Western Argentina Standard Time", "HNOG": "West Greenland Standard Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "WIT": "Eastern Indonesia Time", "MEZ": "Central European Standard Time", "AST": "Atlantic Standard Time", "ChST": "Chamorro Standard Time", "HNPMX": "Mexican Pacific Standard Time", "WAT": "West Africa Standard Time", "BT": "Bhutan Time", "UYT": "Uruguay Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "NZST": "New Zealand Standard Time", "MDT": "Macau Summer Time", "ARST": "Argentina Summer Time", "HKT": "Hong Kong Standard Time", "COST": "Colombia Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CST": "Central Standard Time", "AWDT": "Australian Western Daylight Time", "OEZ": "Eastern European Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "GYT": "Guyana Time", "WESZ": "Western European Summer Time", "AEDT": "Australian Eastern Daylight Time", "HEEG": "East Greenland Summer Time", "AEST": "Australian Eastern Standard Time", "BOT": "Bolivia Time", "HADT": "Hawaii-Aleutian Daylight Time", "CLST": "Chile Summer Time", "TMT": "Turkmenistan Standard Time", "GFT": "French Guiana Time", "PST": "Pacific Standard Time", "HEOG": "West Greenland Summer Time", "HKST": "Hong Kong Summer Time", "EDT": "Eastern Daylight Time", "LHST": "Lord Howe Standard Time", "PDT": "Pacific Daylight Time", "ACDT": "Australian Central Daylight Time", "AKST": "Alaska Standard Time", "SAST": "South Africa Standard Time", "AKDT": "Alaska Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "WAST": "West Africa Summer Time", "HAT": "Newfoundland Daylight Time", "SRT": "Suriname Time", "CHAST": "Chatham Standard Time", "NZDT": "New Zealand Daylight Time", "OESZ": "Eastern European Summer Time", "MST": "Macau Standard Time", "WIB": "Western Indonesia Time", "HECU": "Cuba Daylight Time", "MESZ": "Central European Summer Time", "ART": "Argentina Standard Time", "AWST": "Australian Western Standard Time", "SGT": "Singapore Standard Time", "MYT": "Malaysia Time", "TMST": "Turkmenistan Summer Time", "ACST": "Australian Central Standard Time", "COT": "Colombia Standard Time", "WITA": "Central Indonesia Time", "∅∅∅": "Brasilia Summer Time", "ACWDT": "Australian Central Western Daylight Time", "CAT": "Central Africa Time", "HENOMX": "Northwest Mexico Daylight Time", "JST": "Japan Standard Time", "EST": "Eastern Standard Time", "HNEG": "East Greenland Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SB) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SB' +func (en *en_SB) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SB' +func (en *en_SB) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SB' +func (en *en_SB) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SB' +func (en *en_SB) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SB' +func (en *en_SB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SB' +func (en *en_SB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SB) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SB) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SB) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SB) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SB) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SB) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SB) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SB) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SB) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SB) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SB) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SB) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SB) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SB) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SB' and handles both Whole and Real numbers based on 'v' +func (en *en_SB) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SB' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SB) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SB' +func (en *en_SB) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SB' +// in accounting notation. +func (en *en_SB) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SB' +func (en *en_SB) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SB' +func (en *en_SB) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SB' +func (en *en_SB) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SB' +func (en *en_SB) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SB' +func (en *en_SB) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SB' +func (en *en_SB) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SB' +func (en *en_SB) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SB' +func (en *en_SB) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SB/en_SB_test.go b/vendor/github.com/go-playground/locales/en_SB/en_SB_test.go new file mode 100644 index 0000000000..b799bcdfbc --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SB/en_SB_test.go @@ -0,0 +1,1120 @@ +package en_SB + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SB" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SC/en_SC.go b/vendor/github.com/go-playground/locales/en_SC/en_SC.go new file mode 100644 index 0000000000..832c467037 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SC/en_SC.go @@ -0,0 +1,607 @@ +package en_SC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SC' locale +func New() locales.Translator { + return &en_SC{ + locale: "en_SC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"GFT": "French Guiana Time", "SAST": "South Africa Standard Time", "HECU": "Cuba Daylight Time", "WIT": "Eastern Indonesia Time", "OESZ": "Eastern European Summer Time", "MDT": "Macau Summer Time", "HKST": "Hong Kong Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "ACWST": "Australian Central Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "HNCU": "Cuba Standard Time", "CHADT": "Chatham Daylight Time", "WEZ": "Western European Standard Time", "MST": "Macau Standard Time", "ART": "Argentina Standard Time", "SRT": "Suriname Time", "CLT": "Chile Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "WIB": "Western Indonesia Time", "CDT": "Central Daylight Time", "HNOG": "West Greenland Standard Time", "WAT": "West Africa Standard Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "PDT": "Pacific Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "ECT": "Ecuador Time", "VET": "Venezuela Time", "∅∅∅": "Acre Summer Time", "HNPMX": "Mexican Pacific Standard Time", "PST": "Pacific Standard Time", "LHDT": "Lord Howe Daylight Time", "SGT": "Singapore Standard Time", "AST": "Atlantic Standard Time", "TMT": "Turkmenistan Standard Time", "ACST": "Australian Central Standard Time", "AKST": "Alaska Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "NZST": "New Zealand Standard Time", "JDT": "Japan Daylight Time", "WITA": "Central Indonesia Time", "ChST": "Chamorro Standard Time", "AWDT": "Australian Western Daylight Time", "WART": "Western Argentina Standard Time", "EDT": "Eastern Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "LHST": "Lord Howe Standard Time", "NZDT": "New Zealand Daylight Time", "MESZ": "Central European Summer Time", "HEOG": "West Greenland Summer Time", "MYT": "Malaysia Time", "COT": "Colombia Standard Time", "AWST": "Australian Western Standard Time", "WARST": "Western Argentina Summer Time", "COST": "Colombia Summer Time", "AEDT": "Australian Eastern Daylight Time", "CST": "Central Standard Time", "BOT": "Bolivia Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "GYT": "Guyana Time", "OEZ": "Eastern European Standard Time", "TMST": "Turkmenistan Summer Time", "EST": "Eastern Standard Time", "UYT": "Uruguay Standard Time", "EAT": "East Africa Time", "CAT": "Central Africa Time", "JST": "Japan Standard Time", "ADT": "Atlantic Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "HNEG": "East Greenland Standard Time", "HEEG": "East Greenland Summer Time", "AEST": "Australian Eastern Standard Time", "CHAST": "Chatham Standard Time", "IST": "India Standard Time", "CLST": "Chile Summer Time", "WESZ": "Western European Summer Time", "HKT": "Hong Kong Standard Time", "BT": "Bhutan Time", "MEZ": "Central European Standard Time", "GMT": "Greenwich Mean Time", "ARST": "Argentina Summer Time", "WAST": "West Africa Summer Time", "ACDT": "Australian Central Daylight Time", "AKDT": "Alaska Daylight Time", "UYST": "Uruguay Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SC) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SC' +func (en *en_SC) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SC' +func (en *en_SC) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SC' +func (en *en_SC) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SC' +func (en *en_SC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SC' +func (en *en_SC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SC' +func (en *en_SC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SC) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SC) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SC) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SC) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SC) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SC) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SC) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SC) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SC) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SC) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SC) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SC) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SC) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SC) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SC' and handles both Whole and Real numbers based on 'v' +func (en *en_SC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SC' +func (en *en_SC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SC' +// in accounting notation. +func (en *en_SC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SC' +func (en *en_SC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SC' +func (en *en_SC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SC' +func (en *en_SC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SC' +func (en *en_SC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SC' +func (en *en_SC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SC' +func (en *en_SC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SC' +func (en *en_SC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SC' +func (en *en_SC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SC/en_SC_test.go b/vendor/github.com/go-playground/locales/en_SC/en_SC_test.go new file mode 100644 index 0000000000..f7db7e1f58 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SC/en_SC_test.go @@ -0,0 +1,1120 @@ +package en_SC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SD/en_SD.go b/vendor/github.com/go-playground/locales/en_SD/en_SD.go new file mode 100644 index 0000000000..5121c048f7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SD/en_SD.go @@ -0,0 +1,645 @@ +package en_SD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SD' locale +func New() locales.Translator { + return &en_SD{ + locale: "en_SD", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"TMST": "Turkmenistan Summer Time", "ARST": "Argentina Summer Time", "EST": "Eastern Standard Time", "∅∅∅": "Peru Summer Time", "HNPMX": "Mexican Pacific Standard Time", "CAT": "Central Africa Time", "ACDT": "Australian Central Daylight Time", "HNEG": "East Greenland Standard Time", "HECU": "Cuba Daylight Time", "ACWST": "Australian Central Western Standard Time", "WAT": "West Africa Standard Time", "COT": "Colombia Standard Time", "CHAST": "Chatham Standard Time", "IST": "India Standard Time", "VET": "Venezuela Time", "CLT": "Chile Standard Time", "GMT": "Greenwich Mean Time", "MDT": "Mountain Daylight Time", "SRT": "Suriname Time", "ECT": "Ecuador Time", "JDT": "Japan Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "LHST": "Lord Howe Standard Time", "SGT": "Singapore Standard Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "AKDT": "Alaska Daylight Time", "AEDT": "Australian Eastern Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "OESZ": "Eastern European Summer Time", "HKT": "Hong Kong Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "WART": "Western Argentina Standard Time", "WARST": "Western Argentina Summer Time", "HEEG": "East Greenland Summer Time", "SAST": "South Africa Standard Time", "PDT": "Pacific Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "NZDT": "New Zealand Daylight Time", "CLST": "Chile Summer Time", "MYT": "Malaysia Time", "ACST": "Australian Central Standard Time", "MST": "Mountain Standard Time", "UYT": "Uruguay Standard Time", "CDT": "Central Daylight Time", "WIT": "Eastern Indonesia Time", "ACWDT": "Australian Central Western Daylight Time", "GFT": "French Guiana Time", "EAT": "East Africa Time", "NZST": "New Zealand Standard Time", "TMT": "Turkmenistan Standard Time", "COST": "Colombia Summer Time", "BT": "Bhutan Time", "HNT": "Newfoundland Standard Time", "HNOG": "West Greenland Standard Time", "ART": "Argentina Standard Time", "EDT": "Eastern Daylight Time", "HKST": "Hong Kong Summer Time", "AEST": "Australian Eastern Standard Time", "LHDT": "Lord Howe Daylight Time", "WIB": "Western Indonesia Time", "AWDT": "Australian Western Daylight Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "AKST": "Alaska Standard Time", "UYST": "Uruguay Summer Time", "GYT": "Guyana Time", "MESZ": "Central European Summer Time", "HEOG": "West Greenland Summer Time", "WEZ": "Western European Standard Time", "BOT": "Bolivia Time", "JST": "Japan Standard Time", "AST": "Atlantic Standard Time", "ADT": "Atlantic Daylight Time", "WESZ": "Western European Summer Time", "HAT": "Newfoundland Daylight Time", "ChST": "Chamorro Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "MEZ": "Central European Standard Time", "OEZ": "Eastern European Standard Time", "WAST": "West Africa Summer Time", "WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "AWST": "Australian Western Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SD) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SD' +func (en *en_SD) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SD' +func (en *en_SD) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SD' +func (en *en_SD) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SD' +func (en *en_SD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SD' +func (en *en_SD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SD' +func (en *en_SD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SD) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SD) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SD) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SD) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SD) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SD) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SD) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SD) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SD) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SD) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SD) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SD) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SD) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SD) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SD' and handles both Whole and Real numbers based on 'v' +func (en *en_SD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SD' +func (en *en_SD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SD' +// in accounting notation. +func (en *en_SD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SD' +func (en *en_SD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SD' +func (en *en_SD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SD' +func (en *en_SD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SD' +func (en *en_SD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SD' +func (en *en_SD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SD' +func (en *en_SD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SD' +func (en *en_SD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SD' +func (en *en_SD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SD/en_SD_test.go b/vendor/github.com/go-playground/locales/en_SD/en_SD_test.go new file mode 100644 index 0000000000..a420973b6d --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SD/en_SD_test.go @@ -0,0 +1,1120 @@ +package en_SD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SE/en_SE.go b/vendor/github.com/go-playground/locales/en_SE/en_SE.go new file mode 100644 index 0000000000..9e99918792 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SE/en_SE.go @@ -0,0 +1,656 @@ +package en_SE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SE' locale +func New() locales.Translator { + return &en_SE{ + locale: "en_SE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "kr", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AWST": "Australian Western Standard Time", "ECT": "Ecuador Time", "MESZ": "Central European Summer Time", "HECU": "Cuba Daylight Time", "ART": "Argentina Standard Time", "AEDT": "Australian Eastern Daylight Time", "LHST": "Lord Howe Standard Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "JDT": "Japan Daylight Time", "TMT": "Turkmenistan Standard Time", "HKST": "Hong Kong Summer Time", "WITA": "Central Indonesia Time", "ADT": "Atlantic Daylight Time", "WART": "Western Argentina Standard Time", "SGT": "Singapore Standard Time", "GFT": "French Guiana Time", "ACWDT": "Australian Central Western Daylight Time", "VET": "Venezuela Time", "OEZ": "Eastern European Standard Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "TMST": "Turkmenistan Summer Time", "MST": "Mountain Standard Time", "ACDT": "Australian Central Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "AKDT": "Alaska Daylight Time", "UYT": "Uruguay Standard Time", "HNCU": "Cuba Standard Time", "WEZ": "Western European Standard Time", "HKT": "Hong Kong Standard Time", "ACST": "Australian Central Standard Time", "UYST": "Uruguay Summer Time", "HNPMX": "Mexican Pacific Standard Time", "CHADT": "Chatham Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "MEZ": "Central European Standard Time", "MYT": "Malaysia Time", "∅∅∅": "Acre Summer Time", "HEEG": "East Greenland Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "CDT": "Central Daylight Time", "AWDT": "Australian Western Daylight Time", "CLT": "Chile Standard Time", "BT": "Bhutan Time", "AKST": "Alaska Standard Time", "ChST": "Chamorro Standard Time", "SAST": "South Africa Standard Time", "ACWST": "Australian Central Western Standard Time", "CLST": "Chile Summer Time", "COST": "Colombia Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "SRT": "Suriname Time", "CHAST": "Chatham Standard Time", "COT": "Colombia Standard Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "WARST": "Western Argentina Summer Time", "ARST": "Argentina Summer Time", "LHDT": "Lord Howe Daylight Time", "HNEG": "East Greenland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "GYT": "Guyana Time", "CAT": "Central Africa Time", "JST": "Japan Standard Time", "HAT": "Newfoundland Daylight Time", "PST": "Pacific Standard Time", "PDT": "Pacific Daylight Time", "AST": "Atlantic Standard Time", "OESZ": "Eastern European Summer Time", "WAST": "West Africa Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CST": "Central Standard Time", "IST": "India Standard Time", "WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "WAT": "West Africa Standard Time", "EDT": "Eastern Daylight Time", "MDT": "Mountain Daylight Time", "AEST": "Australian Eastern Standard Time", "EAT": "East Africa Time", "BOT": "Bolivia Time", "EST": "Eastern Standard Time", "HNT": "Newfoundland Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SE) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SE' +func (en *en_SE) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SE' +func (en *en_SE) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SE' +func (en *en_SE) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SE' +func (en *en_SE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SE' +func (en *en_SE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SE' +func (en *en_SE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SE) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SE) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SE) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SE) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SE) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SE) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SE) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SE) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SE) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SE) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SE) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SE) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SE) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SE) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SE' and handles both Whole and Real numbers based on 'v' +func (en *en_SE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percentSuffix...) + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SE' +func (en *en_SE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SE' +// in accounting notation. +func (en *en_SE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SE' +func (en *en_SE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SE' +func (en *en_SE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SE' +func (en *en_SE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SE' +func (en *en_SE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SE' +func (en *en_SE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SE' +func (en *en_SE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SE' +func (en *en_SE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SE' +func (en *en_SE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SE/en_SE_test.go b/vendor/github.com/go-playground/locales/en_SE/en_SE_test.go new file mode 100644 index 0000000000..8aedecdf5e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SE/en_SE_test.go @@ -0,0 +1,1120 @@ +package en_SE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SG/en_SG.go b/vendor/github.com/go-playground/locales/en_SG/en_SG.go new file mode 100644 index 0000000000..6f979253a6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SG/en_SG.go @@ -0,0 +1,597 @@ +package en_SG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SG' locale +func New() locales.Translator { + return &en_SG{ + locale: "en_SG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "$", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ARST": "Argentina Summer Time", "HKST": "Hong Kong Summer Time", "ACDT": "Australian Central Daylight Time", "CDT": "Central Daylight Time", "PDT": "Pacific Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "IST": "India Standard Time", "TMST": "Turkmenistan Summer Time", "HEEG": "East Greenland Summer Time", "UYST": "Uruguay Summer Time", "LHST": "Lord Howe Standard Time", "WIT": "Eastern Indonesia Time", "EST": "Eastern Standard Time", "ChST": "Chamorro Standard Time", "HNPMX": "Mexican Pacific Standard Time", "AWDT": "Australian Western Daylight Time", "SGT": "Singapore Standard Time", "JDT": "Japan Daylight Time", "GMT": "Greenwich Mean Time", "WART": "Western Argentina Standard Time", "TMT": "Turkmenistan Standard Time", "BT": "Bhutan Time", "MST": "Mountain Standard Time", "HECU": "Cuba Daylight Time", "BOT": "Bolivia Time", "CHAST": "Chatham Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "AKDT": "Alaska Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHDT": "Lord Howe Daylight Time", "VET": "Venezuela Time", "HAST": "Hawaii-Aleutian Standard Time", "NZDT": "New Zealand Daylight Time", "COST": "Colombia Summer Time", "UYT": "Uruguay Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SAST": "South Africa Standard Time", "EAT": "East Africa Time", "CST": "Central Standard Time", "CLST": "Chile Summer Time", "HEOG": "West Greenland Summer Time", "∅∅∅": "Acre Summer Time", "CHADT": "Chatham Daylight Time", "ACWST": "Australian Central Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "MESZ": "Central European Summer Time", "CLT": "Chile Standard Time", "EDT": "Eastern Daylight Time", "WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "PST": "Pacific Standard Time", "WAT": "West Africa Standard Time", "HNEG": "East Greenland Standard Time", "GFT": "French Guiana Time", "OESZ": "Eastern European Summer Time", "ACST": "Australian Central Standard Time", "AEST": "Australian Eastern Standard Time", "MDT": "Mountain Daylight Time", "WARST": "Western Argentina Summer Time", "HKT": "Hong Kong Standard Time", "WAST": "West Africa Summer Time", "GYT": "Guyana Time", "ECT": "Ecuador Time", "JST": "Japan Standard Time", "AST": "Atlantic Standard Time", "ADT": "Atlantic Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "HAT": "Newfoundland Daylight Time", "WIB": "Western Indonesia Time", "WEZ": "Western European Standard Time", "WESZ": "Western European Summer Time", "HNOG": "West Greenland Standard Time", "AKST": "Alaska Standard Time", "AWST": "Australian Western Standard Time", "NZST": "New Zealand Standard Time", "MYT": "Malaysia Time", "ART": "Argentina Standard Time", "HNT": "Newfoundland Standard Time", "AEDT": "Australian Eastern Daylight Time", "HNCU": "Cuba Standard Time", "MEZ": "Central European Standard Time", "OEZ": "Eastern European Standard Time", "SRT": "Suriname Time", "CAT": "Central Africa Time", "COT": "Colombia Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SG' +func (en *en_SG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SG' +func (en *en_SG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SG' +func (en *en_SG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SG' +func (en *en_SG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SG' +func (en *en_SG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SG' +func (en *en_SG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SG' and handles both Whole and Real numbers based on 'v' +func (en *en_SG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SG' +func (en *en_SG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SG' +// in accounting notation. +func (en *en_SG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SG' +func (en *en_SG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SG' +func (en *en_SG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SG' +func (en *en_SG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SG' +func (en *en_SG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SG' +func (en *en_SG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SG' +func (en *en_SG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SG' +func (en *en_SG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SG' +func (en *en_SG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SG/en_SG_test.go b/vendor/github.com/go-playground/locales/en_SG/en_SG_test.go new file mode 100644 index 0000000000..cac886126b --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SG/en_SG_test.go @@ -0,0 +1,1120 @@ +package en_SG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SH/en_SH.go b/vendor/github.com/go-playground/locales/en_SH/en_SH.go new file mode 100644 index 0000000000..101b29bf53 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SH/en_SH.go @@ -0,0 +1,607 @@ +package en_SH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SH' locale +func New() locales.Translator { + return &en_SH{ + locale: "en_SH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GB£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "£", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WIB": "Western Indonesia Time", "AWDT": "Australian Western Daylight Time", "PST": "Pacific Standard Time", "ADT": "Atlantic Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "WITA": "Central Indonesia Time", "LHST": "Lord Howe Standard Time", "EAT": "East Africa Time", "HEOG": "West Greenland Summer Time", "OEZ": "Eastern European Standard Time", "WESZ": "Western European Summer Time", "ART": "Argentina Standard Time", "HEEG": "East Greenland Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SAST": "South Africa Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "WEZ": "Western European Standard Time", "WARST": "Western Argentina Summer Time", "MDT": "Macau Summer Time", "COST": "Colombia Summer Time", "HKT": "Hong Kong Standard Time", "HNEG": "East Greenland Standard Time", "ChST": "Chamorro Standard Time", "HNT": "Newfoundland Standard Time", "BOT": "Bolivia Time", "CAT": "Central Africa Time", "EDT": "Eastern Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "AEDT": "Australian Eastern Daylight Time", "SGT": "Singapore Standard Time", "NZDT": "New Zealand Daylight Time", "∅∅∅": "Amazon Summer Time", "JST": "Japan Standard Time", "AST": "Atlantic Standard Time", "EST": "Eastern Standard Time", "VET": "Venezuela Time", "MYT": "Malaysia Time", "COT": "Colombia Standard Time", "UYST": "Uruguay Summer Time", "OESZ": "Eastern European Summer Time", "WART": "Western Argentina Standard Time", "GFT": "French Guiana Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "PDT": "Pacific Daylight Time", "MESZ": "Central European Summer Time", "GMT": "Greenwich Mean Time", "HKST": "Hong Kong Summer Time", "HNPMX": "Mexican Pacific Standard Time", "CST": "Central Standard Time", "WAST": "West Africa Summer Time", "HAT": "Newfoundland Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "HNCU": "Cuba Standard Time", "ACWST": "Australian Central Western Standard Time", "MEZ": "Central European Standard Time", "HNOG": "West Greenland Standard Time", "MST": "Macau Standard Time", "ARST": "Argentina Summer Time", "GYT": "Guyana Time", "WAT": "West Africa Standard Time", "ACST": "Australian Central Standard Time", "AEST": "Australian Eastern Standard Time", "WIT": "Eastern Indonesia Time", "CDT": "Central Daylight Time", "CHAST": "Chatham Standard Time", "CLT": "Chile Standard Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "AKST": "Alaska Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "SRT": "Suriname Time", "CHADT": "Chatham Daylight Time", "ECT": "Ecuador Time", "ACWDT": "Australian Central Western Daylight Time", "NZST": "New Zealand Standard Time", "JDT": "Japan Daylight Time", "CLST": "Chile Summer Time", "AKDT": "Alaska Daylight Time", "IST": "India Standard Time", "TMT": "Turkmenistan Standard Time", "TMST": "Turkmenistan Summer Time", "HECU": "Cuba Daylight Time", "AWST": "Australian Western Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SH) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SH' +func (en *en_SH) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SH' +func (en *en_SH) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SH' +func (en *en_SH) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SH' +func (en *en_SH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SH' +func (en *en_SH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SH' +func (en *en_SH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SH) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SH) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SH) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SH) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SH) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SH) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SH) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SH) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SH) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SH) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SH) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SH) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SH) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SH) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SH' and handles both Whole and Real numbers based on 'v' +func (en *en_SH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SH' +func (en *en_SH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SH' +// in accounting notation. +func (en *en_SH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SH' +func (en *en_SH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SH' +func (en *en_SH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SH' +func (en *en_SH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SH' +func (en *en_SH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SH' +func (en *en_SH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SH' +func (en *en_SH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SH' +func (en *en_SH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SH' +func (en *en_SH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SH/en_SH_test.go b/vendor/github.com/go-playground/locales/en_SH/en_SH_test.go new file mode 100644 index 0000000000..72529e0d9e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SH/en_SH_test.go @@ -0,0 +1,1120 @@ +package en_SH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SI/en_SI.go b/vendor/github.com/go-playground/locales/en_SI/en_SI.go new file mode 100644 index 0000000000..e0cacaa6f8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SI/en_SI.go @@ -0,0 +1,630 @@ +package en_SI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SI' locale +func New() locales.Translator { + return &en_SI{ + locale: "en_SI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " )", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"ACDT": "Australian Central Daylight Time", "∅∅∅": "Acre Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNCU": "Cuba Standard Time", "AWDT": "Australian Western Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "CST": "Central Standard Time", "ECT": "Ecuador Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "COST": "Colombia Summer Time", "IST": "India Standard Time", "JST": "Japan Standard Time", "WAT": "West Africa Standard Time", "AEDT": "Australian Eastern Daylight Time", "GFT": "French Guiana Time", "SRT": "Suriname Time", "EAT": "East Africa Time", "WIT": "Eastern Indonesia Time", "CLST": "Chile Summer Time", "TMST": "Turkmenistan Summer Time", "MDT": "Mountain Daylight Time", "UYT": "Uruguay Standard Time", "BOT": "Bolivia Time", "MESZ": "Central European Summer Time", "OESZ": "Eastern European Summer Time", "BT": "Bhutan Time", "LHDT": "Lord Howe Daylight Time", "HECU": "Cuba Daylight Time", "CAT": "Central Africa Time", "MEZ": "Central European Standard Time", "AST": "Atlantic Standard Time", "OEZ": "Eastern European Standard Time", "CLT": "Chile Standard Time", "EST": "Eastern Standard Time", "AKST": "Alaska Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "HNOG": "West Greenland Standard Time", "GYT": "Guyana Time", "WIB": "Western Indonesia Time", "JDT": "Japan Daylight Time", "CDT": "Central Daylight Time", "CHAST": "Chatham Standard Time", "NZST": "New Zealand Standard Time", "TMT": "Turkmenistan Standard Time", "HAT": "Newfoundland Daylight Time", "MST": "Mountain Standard Time", "LHST": "Lord Howe Standard Time", "CHADT": "Chatham Daylight Time", "ADT": "Atlantic Daylight Time", "EDT": "Eastern Daylight Time", "HKT": "Hong Kong Standard Time", "ACST": "Australian Central Standard Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "PDT": "Pacific Daylight Time", "MYT": "Malaysia Time", "WART": "Western Argentina Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "ChST": "Chamorro Standard Time", "UYST": "Uruguay Summer Time", "AWST": "Australian Western Standard Time", "GMT": "Greenwich Mean Time", "ART": "Argentina Standard Time", "HNEG": "East Greenland Standard Time", "AKDT": "Alaska Daylight Time", "AEST": "Australian Eastern Standard Time", "SAST": "South Africa Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "WAST": "West Africa Summer Time", "HNT": "Newfoundland Standard Time", "PST": "Pacific Standard Time", "ACWST": "Australian Central Western Standard Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "HKST": "Hong Kong Summer Time", "HEEG": "East Greenland Summer Time", "WITA": "Central Indonesia Time", "SGT": "Singapore Standard Time", "ACWDT": "Australian Central Western Daylight Time", "VET": "Venezuela Time", "WEZ": "Western European Standard Time", "WARST": "Western Argentina Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SI) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SI' +func (en *en_SI) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SI' +func (en *en_SI) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SI' +func (en *en_SI) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SI' +func (en *en_SI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SI' +func (en *en_SI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SI' +func (en *en_SI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SI) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SI) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SI) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SI) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SI) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SI) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SI) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SI) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SI) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SI) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SI) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SI) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SI) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SI) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SI' and handles both Whole and Real numbers based on 'v' +func (en *en_SI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SI' +func (en *en_SI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, en.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SI' +// in accounting notation. +func (en *en_SI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, en.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, en.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SI' +func (en *en_SI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SI' +func (en *en_SI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SI' +func (en *en_SI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SI' +func (en *en_SI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SI' +func (en *en_SI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SI' +func (en *en_SI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SI' +func (en *en_SI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SI' +func (en *en_SI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SI/en_SI_test.go b/vendor/github.com/go-playground/locales/en_SI/en_SI_test.go new file mode 100644 index 0000000000..b50c3e07b6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SI/en_SI_test.go @@ -0,0 +1,1120 @@ +package en_SI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SL/en_SL.go b/vendor/github.com/go-playground/locales/en_SL/en_SL.go new file mode 100644 index 0000000000..79424e106c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SL/en_SL.go @@ -0,0 +1,645 @@ +package en_SL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SL' locale +func New() locales.Translator { + return &en_SL{ + locale: "en_SL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "Le", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"AEDT": "Australian Eastern Daylight Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "AWDT": "Australian Western Daylight Time", "ACWST": "Australian Central Western Standard Time", "SRT": "Suriname Time", "HECU": "Cuba Daylight Time", "MESZ": "Central European Summer Time", "CLT": "Chile Standard Time", "OEZ": "Eastern European Standard Time", "WESZ": "Western European Summer Time", "COST": "Colombia Summer Time", "AKST": "Alaska Standard Time", "CHAST": "Chatham Standard Time", "SGT": "Singapore Standard Time", "HNCU": "Cuba Standard Time", "WEZ": "Western European Standard Time", "MDT": "Macau Summer Time", "HAT": "Newfoundland Daylight Time", "AEST": "Australian Eastern Standard Time", "WIT": "Eastern Indonesia Time", "VET": "Venezuela Time", "CLST": "Chile Summer Time", "AST": "Atlantic Standard Time", "WART": "Western Argentina Standard Time", "MST": "Macau Standard Time", "ACST": "Australian Central Standard Time", "ACDT": "Australian Central Daylight Time", "HNEG": "East Greenland Standard Time", "AWST": "Australian Western Standard Time", "CAT": "Central Africa Time", "HNPMX": "Mexican Pacific Standard Time", "WAT": "West Africa Standard Time", "HKT": "Hong Kong Standard Time", "ChST": "Chamorro Standard Time", "LHST": "Lord Howe Standard Time", "TMST": "Turkmenistan Summer Time", "ARST": "Argentina Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "MEZ": "Central European Standard Time", "HEEG": "East Greenland Summer Time", "PST": "Pacific Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "WARST": "Western Argentina Summer Time", "TMT": "Turkmenistan Standard Time", "AKDT": "Alaska Daylight Time", "CHADT": "Chatham Daylight Time", "OESZ": "Eastern European Summer Time", "NZDT": "New Zealand Daylight Time", "HNT": "Newfoundland Standard Time", "GFT": "French Guiana Time", "GYT": "Guyana Time", "EAT": "East Africa Time", "BOT": "Bolivia Time", "NZST": "New Zealand Standard Time", "CDT": "Central Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "MYT": "Malaysia Time", "WAST": "West Africa Summer Time", "EST": "Eastern Standard Time", "COT": "Colombia Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "BT": "Bhutan Time", "HNOG": "West Greenland Standard Time", "ADT": "Atlantic Daylight Time", "WITA": "Central Indonesia Time", "WIB": "Western Indonesia Time", "HEOG": "West Greenland Summer Time", "ART": "Argentina Standard Time", "SAST": "South Africa Standard Time", "ECT": "Ecuador Time", "JDT": "Japan Daylight Time", "∅∅∅": "Amazon Summer Time", "JST": "Japan Standard Time", "GMT": "Greenwich Mean Time", "EDT": "Eastern Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHDT": "Lord Howe Daylight Time", "PDT": "Pacific Daylight Time", "IST": "India Standard Time", "CST": "Central Standard Time", "UYST": "Uruguay Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "UYT": "Uruguay Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SL) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SL' +func (en *en_SL) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SL' +func (en *en_SL) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SL' +func (en *en_SL) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SL' +func (en *en_SL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SL' +func (en *en_SL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SL' +func (en *en_SL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SL) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SL) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SL) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SL) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SL) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SL) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SL) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SL) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SL) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SL) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SL) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SL) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SL) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SL) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SL' and handles both Whole and Real numbers based on 'v' +func (en *en_SL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SL' +func (en *en_SL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SL' +// in accounting notation. +func (en *en_SL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SL' +func (en *en_SL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SL' +func (en *en_SL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SL' +func (en *en_SL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SL' +func (en *en_SL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SL' +func (en *en_SL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SL' +func (en *en_SL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SL' +func (en *en_SL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SL' +func (en *en_SL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SL/en_SL_test.go b/vendor/github.com/go-playground/locales/en_SL/en_SL_test.go new file mode 100644 index 0000000000..b69a27ae14 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SL/en_SL_test.go @@ -0,0 +1,1120 @@ +package en_SL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SS/en_SS.go b/vendor/github.com/go-playground/locales/en_SS/en_SS.go new file mode 100644 index 0000000000..613edf5fbb --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SS/en_SS.go @@ -0,0 +1,645 @@ +package en_SS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SS' locale +func New() locales.Translator { + return &en_SS{ + locale: "en_SS", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GB£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "£", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"PDT": "Pacific Daylight Time", "ECT": "Ecuador Time", "IST": "India Standard Time", "GFT": "French Guiana Time", "WITA": "Central Indonesia Time", "HNPMX": "Mexican Pacific Standard Time", "EAT": "East Africa Time", "HNCU": "Cuba Standard Time", "AWST": "Australian Western Standard Time", "MYT": "Malaysia Time", "ACST": "Australian Central Standard Time", "BT": "Bhutan Time", "AKDT": "Alaska Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "WART": "Western Argentina Standard Time", "HEOG": "West Greenland Summer Time", "TMST": "Turkmenistan Summer Time", "WAT": "West Africa Standard Time", "ACDT": "Australian Central Daylight Time", "NZST": "New Zealand Standard Time", "WAST": "West Africa Summer Time", "COST": "Colombia Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "UYT": "Uruguay Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "ADT": "Atlantic Daylight Time", "CHAST": "Chatham Standard Time", "BOT": "Bolivia Time", "CLT": "Chile Standard Time", "AST": "Atlantic Standard Time", "HKT": "Hong Kong Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SRT": "Suriname Time", "LHDT": "Lord Howe Daylight Time", "EST": "Eastern Standard Time", "HKST": "Hong Kong Summer Time", "MST": "Mountain Standard Time", "JST": "Japan Standard Time", "CLST": "Chile Summer Time", "OESZ": "Eastern European Summer Time", "WARST": "Western Argentina Summer Time", "WIB": "Western Indonesia Time", "SGT": "Singapore Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "CAT": "Central Africa Time", "WEZ": "Western European Standard Time", "MDT": "Mountain Daylight Time", "WIT": "Eastern Indonesia Time", "CHADT": "Chatham Daylight Time", "VET": "Venezuela Time", "GMT": "Greenwich Mean Time", "AEST": "Australian Eastern Standard Time", "ACWST": "Australian Central Western Standard Time", "NZDT": "New Zealand Daylight Time", "MESZ": "Central European Summer Time", "HNOG": "West Greenland Standard Time", "OEZ": "Eastern European Standard Time", "AKST": "Alaska Standard Time", "ChST": "Chamorro Standard Time", "LHST": "Lord Howe Standard Time", "AWDT": "Australian Western Daylight Time", "MEZ": "Central European Standard Time", "TMT": "Turkmenistan Standard Time", "HEEG": "East Greenland Summer Time", "SAST": "South Africa Standard Time", "HECU": "Cuba Daylight Time", "CDT": "Central Daylight Time", "PST": "Pacific Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "AEDT": "Australian Eastern Daylight Time", "GYT": "Guyana Time", "CST": "Central Standard Time", "JDT": "Japan Daylight Time", "WESZ": "Western European Summer Time", "EDT": "Eastern Daylight Time", "COT": "Colombia Standard Time", "HNEG": "East Greenland Standard Time", "ARST": "Argentina Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ART": "Argentina Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "∅∅∅": "Acre Summer Time", "UYST": "Uruguay Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SS) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SS' +func (en *en_SS) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SS' +func (en *en_SS) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SS' +func (en *en_SS) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SS' +func (en *en_SS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SS' +func (en *en_SS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SS' +func (en *en_SS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SS) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SS) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SS) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SS) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SS) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SS) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SS) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SS) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SS) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SS) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SS) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SS) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SS) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SS) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SS' and handles both Whole and Real numbers based on 'v' +func (en *en_SS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SS' +func (en *en_SS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SS' +// in accounting notation. +func (en *en_SS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SS' +func (en *en_SS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SS' +func (en *en_SS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SS' +func (en *en_SS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SS' +func (en *en_SS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SS' +func (en *en_SS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SS' +func (en *en_SS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SS' +func (en *en_SS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SS' +func (en *en_SS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SS/en_SS_test.go b/vendor/github.com/go-playground/locales/en_SS/en_SS_test.go new file mode 100644 index 0000000000..edc48b1b5a --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SS/en_SS_test.go @@ -0,0 +1,1120 @@ +package en_SS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SX/en_SX.go b/vendor/github.com/go-playground/locales/en_SX/en_SX.go new file mode 100644 index 0000000000..764c6b7306 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SX/en_SX.go @@ -0,0 +1,607 @@ +package en_SX + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SX struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SX' locale +func New() locales.Translator { + return &en_SX{ + locale: "en_SX", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "NAf.", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WIB": "Western Indonesia Time", "ARST": "Argentina Summer Time", "GFT": "French Guiana Time", "EAT": "East Africa Time", "SGT": "Singapore Standard Time", "ADT": "Atlantic Daylight Time", "AKDT": "Alaska Daylight Time", "∅∅∅": "Brasilia Summer Time", "AWDT": "Australian Western Daylight Time", "CHADT": "Chatham Daylight Time", "OEZ": "Eastern European Standard Time", "EST": "Eastern Standard Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "LHST": "Lord Howe Standard Time", "ECT": "Ecuador Time", "JST": "Japan Standard Time", "EDT": "Eastern Daylight Time", "PST": "Pacific Standard Time", "WESZ": "Western European Summer Time", "WART": "Western Argentina Standard Time", "MDT": "Macau Summer Time", "ACDT": "Australian Central Daylight Time", "COST": "Colombia Summer Time", "GYT": "Guyana Time", "WARST": "Western Argentina Summer Time", "HEOG": "West Greenland Summer Time", "WAT": "West Africa Standard Time", "HKST": "Hong Kong Summer Time", "HEEG": "East Greenland Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SRT": "Suriname Time", "CHAST": "Chatham Standard Time", "BOT": "Bolivia Time", "MESZ": "Central European Summer Time", "MYT": "Malaysia Time", "WAST": "West Africa Summer Time", "ACST": "Australian Central Standard Time", "SAST": "South Africa Standard Time", "WIT": "Eastern Indonesia Time", "ACWST": "Australian Central Western Standard Time", "TMST": "Turkmenistan Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "UYT": "Uruguay Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "TMT": "Turkmenistan Standard Time", "ART": "Argentina Standard Time", "CDT": "Central Daylight Time", "AWST": "Australian Western Standard Time", "CAT": "Central Africa Time", "IST": "India Standard Time", "GMT": "Greenwich Mean Time", "HNOG": "West Greenland Standard Time", "HNEG": "East Greenland Standard Time", "ACWDT": "Australian Central Western Daylight Time", "NZDT": "New Zealand Daylight Time", "CLST": "Chile Summer Time", "HAT": "Newfoundland Daylight Time", "AKST": "Alaska Standard Time", "HECU": "Cuba Daylight Time", "MEZ": "Central European Standard Time", "VET": "Venezuela Time", "WEZ": "Western European Standard Time", "HKT": "Hong Kong Standard Time", "PDT": "Pacific Daylight Time", "OESZ": "Eastern European Summer Time", "AEST": "Australian Eastern Standard Time", "AEDT": "Australian Eastern Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "HNCU": "Cuba Standard Time", "WITA": "Central Indonesia Time", "UYST": "Uruguay Summer Time", "HAST": "Hawaii-Aleutian Standard Time", "AST": "Atlantic Standard Time", "CLT": "Chile Standard Time", "HNT": "Newfoundland Standard Time", "ChST": "Chamorro Standard Time", "CST": "Central Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "NZST": "New Zealand Standard Time", "JDT": "Japan Daylight Time", "MST": "Macau Standard Time", "BT": "Bhutan Time", "LHDT": "Lord Howe Daylight Time", "HEPMX": "Mexican Pacific Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SX) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SX' +func (en *en_SX) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SX' +func (en *en_SX) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SX' +func (en *en_SX) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SX' +func (en *en_SX) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SX' +func (en *en_SX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SX' +func (en *en_SX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SX) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SX) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SX) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SX) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SX) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SX) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SX) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SX) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SX) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SX) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SX) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SX) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SX) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SX) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SX' and handles both Whole and Real numbers based on 'v' +func (en *en_SX) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SX' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SX) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SX' +func (en *en_SX) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SX' +// in accounting notation. +func (en *en_SX) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SX' +func (en *en_SX) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SX' +func (en *en_SX) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SX' +func (en *en_SX) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SX' +func (en *en_SX) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SX' +func (en *en_SX) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SX' +func (en *en_SX) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SX' +func (en *en_SX) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SX' +func (en *en_SX) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SX/en_SX_test.go b/vendor/github.com/go-playground/locales/en_SX/en_SX_test.go new file mode 100644 index 0000000000..c9b7d5e4d6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SX/en_SX_test.go @@ -0,0 +1,1120 @@ +package en_SX + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SX" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_SZ/en_SZ.go b/vendor/github.com/go-playground/locales/en_SZ/en_SZ.go new file mode 100644 index 0000000000..738a7e4163 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SZ/en_SZ.go @@ -0,0 +1,645 @@ +package en_SZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_SZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_SZ' locale +func New() locales.Translator { + return &en_SZ{ + locale: "en_SZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "E", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WART": "Western Argentina Standard Time", "HNEG": "East Greenland Standard Time", "HEEG": "East Greenland Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "LHST": "Lord Howe Standard Time", "PDT": "Pacific Daylight Time", "AWDT": "Australian Western Daylight Time", "HEOG": "West Greenland Summer Time", "AEDT": "Australian Eastern Daylight Time", "WITA": "Central Indonesia Time", "AKST": "Alaska Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "∅∅∅": "Azores Summer Time", "CST": "Central Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ARST": "Argentina Summer Time", "BT": "Bhutan Time", "AEST": "Australian Eastern Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MYT": "Malaysia Time", "EST": "Eastern Standard Time", "JST": "Japan Standard Time", "GMT": "Greenwich Mean Time", "WARST": "Western Argentina Summer Time", "TMST": "Turkmenistan Summer Time", "COT": "Colombia Standard Time", "SGT": "Singapore Standard Time", "CHAST": "Chatham Standard Time", "PST": "Pacific Standard Time", "ACST": "Australian Central Standard Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "BOT": "Bolivia Time", "ACWDT": "Australian Central Western Daylight Time", "MDT": "Macau Summer Time", "IST": "India Standard Time", "VET": "Venezuela Time", "HKT": "Hong Kong Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "ACDT": "Australian Central Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "GYT": "Guyana Time", "CHADT": "Chatham Daylight Time", "WAST": "West Africa Summer Time", "GFT": "French Guiana Time", "AKDT": "Alaska Daylight Time", "EAT": "East Africa Time", "WESZ": "Western European Summer Time", "CLT": "Chile Standard Time", "HKST": "Hong Kong Summer Time", "MEZ": "Central European Standard Time", "CLST": "Chile Summer Time", "ART": "Argentina Standard Time", "LHDT": "Lord Howe Daylight Time", "WIT": "Eastern Indonesia Time", "JDT": "Japan Daylight Time", "ADT": "Atlantic Daylight Time", "COST": "Colombia Summer Time", "CDT": "Central Daylight Time", "OEZ": "Eastern European Standard Time", "HNOG": "West Greenland Standard Time", "MST": "Macau Standard Time", "EDT": "Eastern Daylight Time", "WAT": "West Africa Standard Time", "ECT": "Ecuador Time", "ACWST": "Australian Central Western Standard Time", "NZST": "New Zealand Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "CAT": "Central Africa Time", "MESZ": "Central European Summer Time", "AST": "Atlantic Standard Time", "UYST": "Uruguay Summer Time", "ChST": "Chamorro Standard Time", "AWST": "Australian Western Standard Time", "WEZ": "Western European Standard Time", "SAST": "South Africa Standard Time", "WIB": "Western Indonesia Time", "OESZ": "Eastern European Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "UYT": "Uruguay Standard Time", "HNCU": "Cuba Standard Time", "TMT": "Turkmenistan Standard Time", "SRT": "Suriname Time", "HECU": "Cuba Daylight Time", "NZDT": "New Zealand Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_SZ) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_SZ' +func (en *en_SZ) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SZ' +func (en *en_SZ) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_SZ' +func (en *en_SZ) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SZ' +func (en *en_SZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SZ' +func (en *en_SZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SZ' +func (en *en_SZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_SZ) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_SZ) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_SZ) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_SZ) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_SZ) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_SZ) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_SZ) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_SZ) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_SZ) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_SZ) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_SZ) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_SZ) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_SZ) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_SZ) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_SZ' and handles both Whole and Real numbers based on 'v' +func (en *en_SZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_SZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_SZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SZ' +func (en *en_SZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SZ' +// in accounting notation. +func (en *en_SZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_SZ' +func (en *en_SZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_SZ' +func (en *en_SZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_SZ' +func (en *en_SZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_SZ' +func (en *en_SZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_SZ' +func (en *en_SZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_SZ' +func (en *en_SZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_SZ' +func (en *en_SZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_SZ' +func (en *en_SZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_SZ/en_SZ_test.go b/vendor/github.com/go-playground/locales/en_SZ/en_SZ_test.go new file mode 100644 index 0000000000..502f2dead6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_SZ/en_SZ_test.go @@ -0,0 +1,1120 @@ +package en_SZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_SZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_TC/en_TC.go b/vendor/github.com/go-playground/locales/en_TC/en_TC.go new file mode 100644 index 0000000000..ee3e0ee411 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TC/en_TC.go @@ -0,0 +1,645 @@ +package en_TC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_TC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_TC' locale +func New() locales.Translator { + return &en_TC{ + locale: "en_TC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WART": "Western Argentina Standard Time", "CLST": "Chile Summer Time", "HNOG": "West Greenland Standard Time", "ADT": "Atlantic Daylight Time", "SGT": "Singapore Standard Time", "∅∅∅": "Amazon Summer Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "BT": "Bhutan Time", "GFT": "French Guiana Time", "ChST": "Chamorro Standard Time", "GYT": "Guyana Time", "CAT": "Central Africa Time", "OESZ": "Eastern European Summer Time", "MST": "Macau Standard Time", "WAST": "West Africa Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "WEZ": "Western European Standard Time", "CLT": "Chile Standard Time", "HEOG": "West Greenland Summer Time", "TMT": "Turkmenistan Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CHADT": "Chatham Daylight Time", "OEZ": "Eastern European Standard Time", "HKST": "Hong Kong Summer Time", "JST": "Japan Standard Time", "TMST": "Turkmenistan Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "MESZ": "Central European Summer Time", "WAT": "West Africa Standard Time", "WITA": "Central Indonesia Time", "HNPMX": "Mexican Pacific Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CHAST": "Chatham Standard Time", "PDT": "Pacific Daylight Time", "SRT": "Suriname Time", "CST": "Central Standard Time", "HNEG": "East Greenland Standard Time", "HEEG": "East Greenland Summer Time", "AEST": "Australian Eastern Standard Time", "HECU": "Cuba Daylight Time", "AWDT": "Australian Western Daylight Time", "ACST": "Australian Central Standard Time", "ACDT": "Australian Central Daylight Time", "AEDT": "Australian Eastern Daylight Time", "AKDT": "Alaska Daylight Time", "WESZ": "Western European Summer Time", "COST": "Colombia Summer Time", "WARST": "Western Argentina Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "WIB": "Western Indonesia Time", "NZDT": "New Zealand Daylight Time", "MEZ": "Central European Standard Time", "VET": "Venezuela Time", "EDT": "Eastern Daylight Time", "HNT": "Newfoundland Standard Time", "UYT": "Uruguay Standard Time", "LHST": "Lord Howe Standard Time", "AWST": "Australian Western Standard Time", "IST": "India Standard Time", "ACWDT": "Australian Central Western Daylight Time", "HNCU": "Cuba Standard Time", "AST": "Atlantic Standard Time", "LHDT": "Lord Howe Daylight Time", "HAT": "Newfoundland Daylight Time", "CDT": "Central Daylight Time", "ARST": "Argentina Summer Time", "EST": "Eastern Standard Time", "ECT": "Ecuador Time", "GMT": "Greenwich Mean Time", "PST": "Pacific Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "ART": "Argentina Standard Time", "BOT": "Bolivia Time", "MYT": "Malaysia Time", "SAST": "South Africa Standard Time", "WIT": "Eastern Indonesia Time", "HKT": "Hong Kong Standard Time", "AKST": "Alaska Standard Time", "JDT": "Japan Daylight Time", "MDT": "Macau Summer Time", "UYST": "Uruguay Summer Time", "EAT": "East Africa Time", "ACWST": "Australian Central Western Standard Time", "NZST": "New Zealand Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_TC) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_TC' +func (en *en_TC) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_TC' +func (en *en_TC) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_TC' +func (en *en_TC) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_TC' +func (en *en_TC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_TC' +func (en *en_TC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_TC' +func (en *en_TC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_TC) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_TC) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_TC) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_TC) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_TC) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_TC) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_TC) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_TC) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_TC) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_TC) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_TC) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_TC) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_TC) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_TC) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_TC' and handles both Whole and Real numbers based on 'v' +func (en *en_TC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_TC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_TC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_TC' +func (en *en_TC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_TC' +// in accounting notation. +func (en *en_TC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_TC' +func (en *en_TC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_TC' +func (en *en_TC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_TC' +func (en *en_TC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_TC' +func (en *en_TC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_TC' +func (en *en_TC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_TC' +func (en *en_TC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_TC' +func (en *en_TC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_TC' +func (en *en_TC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_TC/en_TC_test.go b/vendor/github.com/go-playground/locales/en_TC/en_TC_test.go new file mode 100644 index 0000000000..2aedceaa33 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TC/en_TC_test.go @@ -0,0 +1,1120 @@ +package en_TC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_TC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_TK/en_TK.go b/vendor/github.com/go-playground/locales/en_TK/en_TK.go new file mode 100644 index 0000000000..54210155d2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TK/en_TK.go @@ -0,0 +1,607 @@ +package en_TK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_TK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_TK' locale +func New() locales.Translator { + return &en_TK{ + locale: "en_TK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HAST": "Hawaii-Aleutian Standard Time", "CLT": "Chile Standard Time", "ACDT": "Australian Central Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNPMX": "Mexican Pacific Standard Time", "AST": "Atlantic Standard Time", "COT": "Colombia Standard Time", "UYST": "Uruguay Summer Time", "SAST": "South Africa Standard Time", "OESZ": "Eastern European Summer Time", "WEZ": "Western European Standard Time", "AWDT": "Australian Western Daylight Time", "CHAST": "Chatham Standard Time", "CAT": "Central Africa Time", "NZST": "New Zealand Standard Time", "VET": "Venezuela Time", "JDT": "Japan Daylight Time", "WAST": "West Africa Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "HEEG": "East Greenland Summer Time", "AKDT": "Alaska Daylight Time", "BOT": "Bolivia Time", "MEZ": "Central European Standard Time", "GYT": "Guyana Time", "JST": "Japan Standard Time", "ACST": "Australian Central Standard Time", "COST": "Colombia Summer Time", "AKST": "Alaska Standard Time", "WITA": "Central Indonesia Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "PDT": "Pacific Daylight Time", "OEZ": "Eastern European Standard Time", "WARST": "Western Argentina Summer Time", "ART": "Argentina Standard Time", "ARST": "Argentina Summer Time", "EST": "Eastern Standard Time", "CDT": "Central Daylight Time", "GMT": "Greenwich Mean Time", "EDT": "Eastern Daylight Time", "HKT": "Hong Kong Standard Time", "LHDT": "Lord Howe Daylight Time", "ACWST": "Australian Central Western Standard Time", "HKST": "Hong Kong Summer Time", "SRT": "Suriname Time", "WIB": "Western Indonesia Time", "CHADT": "Chatham Daylight Time", "SGT": "Singapore Standard Time", "∅∅∅": "Amazon Summer Time", "TMT": "Turkmenistan Standard Time", "LHST": "Lord Howe Standard Time", "EAT": "East Africa Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "CST": "Central Standard Time", "PST": "Pacific Standard Time", "ACWDT": "Australian Central Western Daylight Time", "AEDT": "Australian Eastern Daylight Time", "ChST": "Chamorro Standard Time", "HECU": "Cuba Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "HEOG": "West Greenland Summer Time", "MST": "Macau Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "WIT": "Eastern Indonesia Time", "ECT": "Ecuador Time", "NZDT": "New Zealand Daylight Time", "ADT": "Atlantic Daylight Time", "WESZ": "Western European Summer Time", "WART": "Western Argentina Standard Time", "WAT": "West Africa Standard Time", "MYT": "Malaysia Time", "TMST": "Turkmenistan Summer Time", "HNEG": "East Greenland Standard Time", "HNCU": "Cuba Standard Time", "AWST": "Australian Western Standard Time", "CLST": "Chile Summer Time", "BT": "Bhutan Time", "GFT": "French Guiana Time", "HEPMX": "Mexican Pacific Daylight Time", "IST": "India Standard Time", "MESZ": "Central European Summer Time", "HNOG": "West Greenland Standard Time", "MDT": "Macau Summer Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_TK) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_TK' +func (en *en_TK) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_TK' +func (en *en_TK) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_TK' +func (en *en_TK) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_TK' +func (en *en_TK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_TK' +func (en *en_TK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_TK' +func (en *en_TK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_TK) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_TK) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_TK) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_TK) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_TK) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_TK) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_TK) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_TK) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_TK) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_TK) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_TK) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_TK) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_TK) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_TK) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_TK' and handles both Whole and Real numbers based on 'v' +func (en *en_TK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_TK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_TK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_TK' +func (en *en_TK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_TK' +// in accounting notation. +func (en *en_TK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_TK' +func (en *en_TK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_TK' +func (en *en_TK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_TK' +func (en *en_TK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_TK' +func (en *en_TK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_TK' +func (en *en_TK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_TK' +func (en *en_TK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_TK' +func (en *en_TK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_TK' +func (en *en_TK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_TK/en_TK_test.go b/vendor/github.com/go-playground/locales/en_TK/en_TK_test.go new file mode 100644 index 0000000000..2d51568045 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TK/en_TK_test.go @@ -0,0 +1,1120 @@ +package en_TK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_TK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_TO/en_TO.go b/vendor/github.com/go-playground/locales/en_TO/en_TO.go new file mode 100644 index 0000000000..c140d4426e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TO/en_TO.go @@ -0,0 +1,645 @@ +package en_TO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_TO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_TO' locale +func New() locales.Translator { + return &en_TO{ + locale: "en_TO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "T$", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HECU": "Cuba Daylight Time", "ACWST": "Australian Central Western Standard Time", "ACST": "Australian Central Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "VET": "Venezuela Time", "AEDT": "Australian Eastern Daylight Time", "SAST": "South Africa Standard Time", "CDT": "Central Daylight Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "TMT": "Turkmenistan Standard Time", "WITA": "Central Indonesia Time", "ECT": "Ecuador Time", "WEZ": "Western European Standard Time", "ARST": "Argentina Summer Time", "HKT": "Hong Kong Standard Time", "UYST": "Uruguay Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "EAT": "East Africa Time", "NZST": "New Zealand Standard Time", "WARST": "Western Argentina Summer Time", "JST": "Japan Standard Time", "HNOG": "West Greenland Standard Time", "MST": "Macau Standard Time", "EST": "Eastern Standard Time", "HNEG": "East Greenland Standard Time", "ChST": "Chamorro Standard Time", "CHAST": "Chatham Standard Time", "ACWDT": "Australian Central Western Daylight Time", "BOT": "Bolivia Time", "GMT": "Greenwich Mean Time", "WART": "Western Argentina Standard Time", "ART": "Argentina Standard Time", "HKST": "Hong Kong Summer Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time", "PDT": "Pacific Daylight Time", "OEZ": "Eastern European Standard Time", "HNCU": "Cuba Standard Time", "HEEG": "East Greenland Summer Time", "BT": "Bhutan Time", "MDT": "Macau Summer Time", "COST": "Colombia Summer Time", "HNT": "Newfoundland Standard Time", "HAT": "Newfoundland Daylight Time", "AKST": "Alaska Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "AWST": "Australian Western Standard Time", "HEOG": "West Greenland Summer Time", "HNPMX": "Mexican Pacific Standard Time", "MESZ": "Central European Summer Time", "COT": "Colombia Standard Time", "AKDT": "Alaska Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "WIT": "Eastern Indonesia Time", "SGT": "Singapore Standard Time", "∅∅∅": "Amazon Summer Time", "MEZ": "Central European Standard Time", "MYT": "Malaysia Time", "TMST": "Turkmenistan Summer Time", "WAST": "West Africa Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "SRT": "Suriname Time", "AWDT": "Australian Western Daylight Time", "CAT": "Central Africa Time", "CLT": "Chile Standard Time", "AST": "Atlantic Standard Time", "GFT": "French Guiana Time", "LHDT": "Lord Howe Daylight Time", "WIB": "Western Indonesia Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "EDT": "Eastern Daylight Time", "GYT": "Guyana Time", "JDT": "Japan Daylight Time", "ADT": "Atlantic Daylight Time", "CST": "Central Standard Time", "IST": "India Standard Time", "ACDT": "Australian Central Daylight Time", "OESZ": "Eastern European Summer Time", "LHST": "Lord Howe Standard Time", "WAT": "West Africa Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "CLST": "Chile Summer Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_TO) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_TO' +func (en *en_TO) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_TO' +func (en *en_TO) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_TO' +func (en *en_TO) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_TO' +func (en *en_TO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_TO' +func (en *en_TO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_TO' +func (en *en_TO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_TO) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_TO) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_TO) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_TO) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_TO) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_TO) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_TO) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_TO) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_TO) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_TO) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_TO) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_TO) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_TO) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_TO) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_TO' and handles both Whole and Real numbers based on 'v' +func (en *en_TO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_TO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_TO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_TO' +func (en *en_TO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_TO' +// in accounting notation. +func (en *en_TO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_TO' +func (en *en_TO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_TO' +func (en *en_TO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_TO' +func (en *en_TO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_TO' +func (en *en_TO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_TO' +func (en *en_TO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_TO' +func (en *en_TO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_TO' +func (en *en_TO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_TO' +func (en *en_TO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_TO/en_TO_test.go b/vendor/github.com/go-playground/locales/en_TO/en_TO_test.go new file mode 100644 index 0000000000..5fc4e9303c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TO/en_TO_test.go @@ -0,0 +1,1120 @@ +package en_TO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_TO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_TT/en_TT.go b/vendor/github.com/go-playground/locales/en_TT/en_TT.go new file mode 100644 index 0000000000..67e0fad898 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TT/en_TT.go @@ -0,0 +1,645 @@ +package en_TT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_TT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_TT' locale +func New() locales.Translator { + return &en_TT{ + locale: "en_TT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "$", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HKT": "Hong Kong Standard Time", "WAT": "West Africa Standard Time", "HNT": "Newfoundland Standard Time", "AEDT": "Australian Eastern Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "ACWST": "Australian Central Western Standard Time", "WESZ": "Western European Summer Time", "TMST": "Turkmenistan Summer Time", "CST": "Central Standard Time", "COST": "Colombia Summer Time", "∅∅∅": "Azores Summer Time", "GYT": "Guyana Time", "ECT": "Ecuador Time", "IST": "India Standard Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "EAT": "East Africa Time", "WIT": "Eastern Indonesia Time", "AWDT": "Australian Western Daylight Time", "MYT": "Malaysia Time", "HNOG": "West Greenland Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "UYST": "Uruguay Summer Time", "ChST": "Chamorro Standard Time", "LHST": "Lord Howe Standard Time", "SRT": "Suriname Time", "PDT": "Pacific Daylight Time", "HEEG": "East Greenland Summer Time", "MDT": "Mountain Daylight Time", "WIB": "Western Indonesia Time", "BOT": "Bolivia Time", "JDT": "Japan Daylight Time", "WAST": "West Africa Summer Time", "ACST": "Australian Central Standard Time", "HNEG": "East Greenland Standard Time", "AWST": "Australian Western Standard Time", "SGT": "Singapore Standard Time", "OEZ": "Eastern European Standard Time", "EDT": "Eastern Daylight Time", "COT": "Colombia Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "AST": "Atlantic Standard Time", "TMT": "Turkmenistan Standard Time", "LHDT": "Lord Howe Daylight Time", "SAST": "South Africa Standard Time", "HNCU": "Cuba Standard Time", "HECU": "Cuba Daylight Time", "CHAST": "Chatham Standard Time", "ACDT": "Australian Central Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "GMT": "Greenwich Mean Time", "CLST": "Chile Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "WITA": "Central Indonesia Time", "HEPMX": "Mexican Pacific Daylight Time", "HKST": "Hong Kong Summer Time", "AEST": "Australian Eastern Standard Time", "OESZ": "Eastern European Summer Time", "AKDT": "Alaska Daylight Time", "JST": "Japan Standard Time", "WART": "Western Argentina Standard Time", "HAT": "Newfoundland Daylight Time", "WEZ": "Western European Standard Time", "GFT": "French Guiana Time", "ACWDT": "Australian Central Western Daylight Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "MEZ": "Central European Standard Time", "BT": "Bhutan Time", "MST": "Mountain Standard Time", "HNPMX": "Mexican Pacific Standard Time", "PST": "Pacific Standard Time", "VET": "Venezuela Time", "EST": "Eastern Standard Time", "CLT": "Chile Standard Time", "AKST": "Alaska Standard Time", "CDT": "Central Daylight Time", "CHADT": "Chatham Daylight Time", "MESZ": "Central European Summer Time", "WARST": "Western Argentina Summer Time", "UYT": "Uruguay Standard Time", "CAT": "Central Africa Time", "ADT": "Atlantic Daylight Time", "ART": "Argentina Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_TT) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_TT' +func (en *en_TT) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_TT' +func (en *en_TT) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_TT' +func (en *en_TT) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_TT' +func (en *en_TT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_TT' +func (en *en_TT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_TT' +func (en *en_TT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_TT) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_TT) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_TT) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_TT) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_TT) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_TT) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_TT) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_TT) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_TT) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_TT) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_TT) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_TT) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_TT) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_TT) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_TT' and handles both Whole and Real numbers based on 'v' +func (en *en_TT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_TT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_TT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_TT' +func (en *en_TT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_TT' +// in accounting notation. +func (en *en_TT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_TT' +func (en *en_TT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_TT' +func (en *en_TT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_TT' +func (en *en_TT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_TT' +func (en *en_TT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_TT' +func (en *en_TT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_TT' +func (en *en_TT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_TT' +func (en *en_TT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_TT' +func (en *en_TT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_TT/en_TT_test.go b/vendor/github.com/go-playground/locales/en_TT/en_TT_test.go new file mode 100644 index 0000000000..b6bcc9eb4e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TT/en_TT_test.go @@ -0,0 +1,1120 @@ +package en_TT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_TT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_TV/en_TV.go b/vendor/github.com/go-playground/locales/en_TV/en_TV.go new file mode 100644 index 0000000000..8d6a7ff577 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TV/en_TV.go @@ -0,0 +1,607 @@ +package en_TV + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_TV struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_TV' locale +func New() locales.Translator { + return &en_TV{ + locale: "en_TV", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"SAST": "South Africa Standard Time", "WIB": "Western Indonesia Time", "CAT": "Central Africa Time", "ADT": "Atlantic Daylight Time", "WAST": "West Africa Summer Time", "HADT": "Hawaii-Aleutian Daylight Time", "NZST": "New Zealand Standard Time", "HKST": "Hong Kong Summer Time", "MEZ": "Central European Standard Time", "AST": "Atlantic Standard Time", "OESZ": "Eastern European Summer Time", "WITA": "Central Indonesia Time", "UYST": "Uruguay Summer Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "PDT": "Pacific Daylight Time", "GYT": "Guyana Time", "HAST": "Hawaii-Aleutian Standard Time", "IST": "India Standard Time", "WEZ": "Western European Standard Time", "AEST": "Australian Eastern Standard Time", "BOT": "Bolivia Time", "MESZ": "Central European Summer Time", "ACST": "Australian Central Standard Time", "HNT": "Newfoundland Standard Time", "CDT": "Central Daylight Time", "AWDT": "Australian Western Daylight Time", "HEOG": "West Greenland Summer Time", "WESZ": "Western European Summer Time", "ARST": "Argentina Summer Time", "HAT": "Newfoundland Daylight Time", "AKST": "Alaska Standard Time", "AEDT": "Australian Eastern Daylight Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "ACWST": "Australian Central Western Standard Time", "HKT": "Hong Kong Standard Time", "ACDT": "Australian Central Daylight Time", "COT": "Colombia Standard Time", "ChST": "Chamorro Standard Time", "EAT": "East Africa Time", "HECU": "Cuba Daylight Time", "GMT": "Greenwich Mean Time", "EDT": "Eastern Daylight Time", "TMT": "Turkmenistan Standard Time", "WARST": "Western Argentina Summer Time", "TMST": "Turkmenistan Summer Time", "ART": "Argentina Standard Time", "BT": "Bhutan Time", "∅∅∅": "Peru Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "WART": "Western Argentina Standard Time", "WAT": "West Africa Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "CST": "Central Standard Time", "WIT": "Eastern Indonesia Time", "NZDT": "New Zealand Daylight Time", "HNEG": "East Greenland Standard Time", "GFT": "French Guiana Time", "MDT": "Mountain Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "SRT": "Suriname Time", "VET": "Venezuela Time", "JDT": "Japan Daylight Time", "OEZ": "Eastern European Standard Time", "MYT": "Malaysia Time", "COST": "Colombia Summer Time", "HEEG": "East Greenland Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "AWST": "Australian Western Standard Time", "JST": "Japan Standard Time", "CLT": "Chile Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "SGT": "Singapore Standard Time", "ECT": "Ecuador Time", "HNOG": "West Greenland Standard Time", "AKDT": "Alaska Daylight Time", "MST": "Mountain Standard Time", "CLST": "Chile Summer Time", "EST": "Eastern Standard Time", "LHST": "Lord Howe Standard Time", "HNCU": "Cuba Standard Time", "CHAST": "Chatham Standard Time", "HNNOMX": "Northwest Mexico Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_TV) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_TV' +func (en *en_TV) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_TV' +func (en *en_TV) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_TV' +func (en *en_TV) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_TV' +func (en *en_TV) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_TV' +func (en *en_TV) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_TV' +func (en *en_TV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_TV) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_TV) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_TV) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_TV) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_TV) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_TV) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_TV) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_TV) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_TV) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_TV) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_TV) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_TV) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_TV) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_TV) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_TV' and handles both Whole and Real numbers based on 'v' +func (en *en_TV) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_TV' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_TV) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_TV' +func (en *en_TV) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_TV' +// in accounting notation. +func (en *en_TV) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_TV' +func (en *en_TV) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_TV' +func (en *en_TV) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_TV' +func (en *en_TV) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_TV' +func (en *en_TV) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_TV' +func (en *en_TV) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_TV' +func (en *en_TV) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_TV' +func (en *en_TV) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_TV' +func (en *en_TV) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_TV/en_TV_test.go b/vendor/github.com/go-playground/locales/en_TV/en_TV_test.go new file mode 100644 index 0000000000..db75dbbe7d --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TV/en_TV_test.go @@ -0,0 +1,1120 @@ +package en_TV + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_TV" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_TZ/en_TZ.go b/vendor/github.com/go-playground/locales/en_TZ/en_TZ.go new file mode 100644 index 0000000000..9ef8a21d51 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TZ/en_TZ.go @@ -0,0 +1,607 @@ +package en_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_TZ' locale +func New() locales.Translator { + return &en_TZ{ + locale: "en_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"JDT": "Japan Daylight Time", "MST": "Macau Standard Time", "BT": "Bhutan Time", "ChST": "Chamorro Standard Time", "CST": "Central Standard Time", "WIT": "Eastern Indonesia Time", "MEZ": "Central European Standard Time", "OEZ": "Eastern European Standard Time", "GMT": "Greenwich Mean Time", "HNNOMX": "Northwest Mexico Standard Time", "AWST": "Australian Western Standard Time", "CLST": "Chile Summer Time", "EST": "Eastern Standard Time", "UYT": "Uruguay Standard Time", "AWDT": "Australian Western Daylight Time", "ADT": "Atlantic Daylight Time", "CDT": "Central Daylight Time", "ACWST": "Australian Central Western Standard Time", "HEOG": "West Greenland Summer Time", "HKST": "Hong Kong Summer Time", "COT": "Colombia Standard Time", "HNEG": "East Greenland Standard Time", "∅∅∅": "Acre Summer Time", "WITA": "Central Indonesia Time", "LHDT": "Lord Howe Daylight Time", "WAST": "West Africa Summer Time", "HEEG": "East Greenland Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "JST": "Japan Standard Time", "TMST": "Turkmenistan Summer Time", "COST": "Colombia Summer Time", "MESZ": "Central European Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "CAT": "Central Africa Time", "HNOG": "West Greenland Standard Time", "WEZ": "Western European Standard Time", "AEST": "Australian Eastern Standard Time", "HECU": "Cuba Daylight Time", "CHADT": "Chatham Daylight Time", "NZST": "New Zealand Standard Time", "AST": "Atlantic Standard Time", "WART": "Western Argentina Standard Time", "WARST": "Western Argentina Summer Time", "CLT": "Chile Standard Time", "ACST": "Australian Central Standard Time", "GFT": "French Guiana Time", "IST": "India Standard Time", "VET": "Venezuela Time", "WAT": "West Africa Standard Time", "HNT": "Newfoundland Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time", "PDT": "Pacific Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "EDT": "Eastern Daylight Time", "ACDT": "Australian Central Daylight Time", "AKST": "Alaska Standard Time", "UYST": "Uruguay Summer Time", "SAST": "South Africa Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HNCU": "Cuba Standard Time", "CHAST": "Chatham Standard Time", "NZDT": "New Zealand Daylight Time", "MDT": "Macau Summer Time", "ARST": "Argentina Summer Time", "HKT": "Hong Kong Standard Time", "AKDT": "Alaska Daylight Time", "SRT": "Suriname Time", "EAT": "East Africa Time", "WIB": "Western Indonesia Time", "PST": "Pacific Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "WESZ": "Western European Summer Time", "MYT": "Malaysia Time", "OESZ": "Eastern European Summer Time", "TMT": "Turkmenistan Standard Time", "ART": "Argentina Standard Time", "HAT": "Newfoundland Daylight Time", "AEDT": "Australian Eastern Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "ECT": "Ecuador Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_TZ) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_TZ' +func (en *en_TZ) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_TZ' +func (en *en_TZ) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_TZ' +func (en *en_TZ) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_TZ' +func (en *en_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_TZ' +func (en *en_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_TZ' +func (en *en_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_TZ) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_TZ) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_TZ) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_TZ) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_TZ) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_TZ) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_TZ) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_TZ) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_TZ) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_TZ) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_TZ) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_TZ) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_TZ) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_TZ' and handles both Whole and Real numbers based on 'v' +func (en *en_TZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_TZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_TZ' +func (en *en_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_TZ' +// in accounting notation. +func (en *en_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_TZ' +func (en *en_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_TZ' +func (en *en_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_TZ' +func (en *en_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_TZ' +func (en *en_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_TZ' +func (en *en_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_TZ' +func (en *en_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_TZ' +func (en *en_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_TZ' +func (en *en_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_TZ/en_TZ_test.go b/vendor/github.com/go-playground/locales/en_TZ/en_TZ_test.go new file mode 100644 index 0000000000..c2bcc58226 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_TZ/en_TZ_test.go @@ -0,0 +1,1120 @@ +package en_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_UG/en_UG.go b/vendor/github.com/go-playground/locales/en_UG/en_UG.go new file mode 100644 index 0000000000..3ec07ec74d --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_UG/en_UG.go @@ -0,0 +1,607 @@ +package en_UG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_UG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_UG' locale +func New() locales.Translator { + return &en_UG{ + locale: "en_UG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "USh", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"SRT": "Suriname Time", "ACWST": "Australian Central Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "JST": "Japan Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CHADT": "Chatham Daylight Time", "CAT": "Central Africa Time", "NZST": "New Zealand Standard Time", "GMT": "Greenwich Mean Time", "COST": "Colombia Summer Time", "CST": "Central Standard Time", "GYT": "Guyana Time", "AWST": "Australian Western Standard Time", "AWDT": "Australian Western Daylight Time", "HNOG": "West Greenland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SAST": "South Africa Standard Time", "MESZ": "Central European Summer Time", "JDT": "Japan Daylight Time", "CLST": "Chile Summer Time", "ADT": "Atlantic Daylight Time", "WESZ": "Western European Summer Time", "HNT": "Newfoundland Standard Time", "ACST": "Australian Central Standard Time", "CDT": "Central Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MEZ": "Central European Standard Time", "MYT": "Malaysia Time", "WARST": "Western Argentina Summer Time", "ART": "Argentina Standard Time", "EDT": "Eastern Daylight Time", "GFT": "French Guiana Time", "MST": "Mountain Standard Time", "AKST": "Alaska Standard Time", "LHST": "Lord Howe Standard Time", "CLT": "Chile Standard Time", "TMST": "Turkmenistan Summer Time", "EST": "Eastern Standard Time", "HKT": "Hong Kong Standard Time", "∅∅∅": "Acre Summer Time", "HKST": "Hong Kong Summer Time", "EAT": "East Africa Time", "ECT": "Ecuador Time", "BT": "Bhutan Time", "OESZ": "Eastern European Summer Time", "WAT": "West Africa Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HECU": "Cuba Daylight Time", "MDT": "Mountain Daylight Time", "WITA": "Central Indonesia Time", "HNPMX": "Mexican Pacific Standard Time", "HNCU": "Cuba Standard Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "ACDT": "Australian Central Daylight Time", "HEEG": "East Greenland Summer Time", "ChST": "Chamorro Standard Time", "AKDT": "Alaska Daylight Time", "UYST": "Uruguay Summer Time", "WIB": "Western Indonesia Time", "WART": "Western Argentina Standard Time", "WAST": "West Africa Summer Time", "AEDT": "Australian Eastern Daylight Time", "WIT": "Eastern Indonesia Time", "AST": "Atlantic Standard Time", "WEZ": "Western European Standard Time", "COT": "Colombia Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "IST": "India Standard Time", "VET": "Venezuela Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "AEST": "Australian Eastern Standard Time", "PST": "Pacific Standard Time", "OEZ": "Eastern European Standard Time", "HAT": "Newfoundland Daylight Time", "CHAST": "Chatham Standard Time", "PDT": "Pacific Daylight Time", "NZDT": "New Zealand Daylight Time", "TMT": "Turkmenistan Standard Time", "HNEG": "East Greenland Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_UG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_UG' +func (en *en_UG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_UG' +func (en *en_UG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_UG' +func (en *en_UG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_UG' +func (en *en_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_UG' +func (en *en_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_UG' +func (en *en_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_UG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_UG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_UG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_UG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_UG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_UG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_UG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_UG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_UG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_UG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_UG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_UG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_UG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_UG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_UG' and handles both Whole and Real numbers based on 'v' +func (en *en_UG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_UG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_UG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_UG' +func (en *en_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_UG' +// in accounting notation. +func (en *en_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_UG' +func (en *en_UG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_UG' +func (en *en_UG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_UG' +func (en *en_UG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_UG' +func (en *en_UG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_UG' +func (en *en_UG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_UG' +func (en *en_UG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_UG' +func (en *en_UG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_UG' +func (en *en_UG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_UG/en_UG_test.go b/vendor/github.com/go-playground/locales/en_UG/en_UG_test.go new file mode 100644 index 0000000000..ef51782d47 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_UG/en_UG_test.go @@ -0,0 +1,1120 @@ +package en_UG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_UG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_UM/en_UM.go b/vendor/github.com/go-playground/locales/en_UM/en_UM.go new file mode 100644 index 0000000000..0c8176b50c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_UM/en_UM.go @@ -0,0 +1,635 @@ +package en_UM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_UM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_UM' locale +func New() locales.Translator { + return &en_UM{ + locale: "en_UM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"GFT": "French Guiana Time", "SRT": "Suriname Time", "EAT": "East Africa Time", "AST": "Atlantic Standard Time", "GMT": "Greenwich Mean Time", "ART": "Argentina Standard Time", "CHAST": "Chatham Standard Time", "MEZ": "Central European Standard Time", "HNOG": "West Greenland Standard Time", "EDT": "Eastern Daylight Time", "MST": "Mountain Standard Time", "UYST": "Uruguay Summer Time", "SGT": "Singapore Standard Time", "HEOG": "West Greenland Summer Time", "ADT": "Atlantic Daylight Time", "LHST": "Lord Howe Standard Time", "GYT": "Guyana Time", "COT": "Colombia Standard Time", "ACWST": "Australian Central Western Standard Time", "ARST": "Argentina Summer Time", "CLST": "Chile Summer Time", "AEST": "Australian Eastern Standard Time", "MDT": "Mountain Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "∅∅∅": "Azores Summer Time", "BOT": "Bolivia Time", "HAST": "Hawaii-Aleutian Standard Time", "HKST": "Hong Kong Summer Time", "BT": "Bhutan Time", "AKDT": "Alaska Daylight Time", "MESZ": "Central European Summer Time", "VET": "Venezuela Time", "HENOMX": "Northwest Mexico Daylight Time", "HAT": "Newfoundland Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "IST": "India Standard Time", "WAT": "West Africa Standard Time", "HNT": "Newfoundland Standard Time", "LHDT": "Lord Howe Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "CAT": "Central Africa Time", "CLT": "Chile Standard Time", "HNCU": "Cuba Standard Time", "HECU": "Cuba Daylight Time", "CST": "Central Standard Time", "WARST": "Western Argentina Summer Time", "TMST": "Turkmenistan Summer Time", "HNEG": "East Greenland Standard Time", "UYT": "Uruguay Standard Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "PDT": "Pacific Daylight Time", "MYT": "Malaysia Time", "ACDT": "Australian Central Daylight Time", "WITA": "Central Indonesia Time", "ChST": "Chamorro Standard Time", "ECT": "Ecuador Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "CDT": "Central Daylight Time", "AWST": "Australian Western Standard Time", "ACWDT": "Australian Central Western Daylight Time", "JST": "Japan Standard Time", "HKT": "Hong Kong Standard Time", "COST": "Colombia Summer Time", "HEEG": "East Greenland Summer Time", "CHADT": "Chatham Daylight Time", "JDT": "Japan Daylight Time", "OESZ": "Eastern European Summer Time", "WESZ": "Western European Summer Time", "EST": "Eastern Standard Time", "ACST": "Australian Central Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "AKST": "Alaska Standard Time", "AEDT": "Australian Eastern Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "OEZ": "Eastern European Standard Time", "WART": "Western Argentina Standard Time", "WAST": "West Africa Summer Time", "SAST": "South Africa Standard Time", "AWDT": "Australian Western Daylight Time", "PST": "Pacific Standard Time", "WEZ": "Western European Standard Time", "TMT": "Turkmenistan Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_UM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_UM' +func (en *en_UM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_UM' +func (en *en_UM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_UM' +func (en *en_UM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_UM' +func (en *en_UM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_UM' +func (en *en_UM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_UM' +func (en *en_UM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_UM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_UM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_UM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_UM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_UM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_UM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_UM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_UM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_UM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_UM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_UM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_UM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_UM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_UM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_UM' and handles both Whole and Real numbers based on 'v' +func (en *en_UM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_UM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_UM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_UM' +func (en *en_UM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_UM' +// in accounting notation. +func (en *en_UM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_UM' +func (en *en_UM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_UM' +func (en *en_UM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_UM' +func (en *en_UM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_UM' +func (en *en_UM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_UM' +func (en *en_UM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_UM' +func (en *en_UM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_UM' +func (en *en_UM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_UM' +func (en *en_UM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_UM/en_UM_test.go b/vendor/github.com/go-playground/locales/en_UM/en_UM_test.go new file mode 100644 index 0000000000..f15ecdc8c5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_UM/en_UM_test.go @@ -0,0 +1,1120 @@ +package en_UM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_UM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_US/en_US.go b/vendor/github.com/go-playground/locales/en_US/en_US.go new file mode 100644 index 0000000000..6a512e847c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_US/en_US.go @@ -0,0 +1,635 @@ +package en_US + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_US struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_US' locale +func New() locales.Translator { + return &en_US{ + locale: "en_US", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WART": "Western Argentina Standard Time", "AKST": "Alaska Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNCU": "Cuba Standard Time", "ACWST": "Australian Central Western Standard Time", "ART": "Argentina Standard Time", "HNEG": "East Greenland Standard Time", "LHDT": "Lord Howe Daylight Time", "CST": "Central Standard Time", "VET": "Venezuela Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "TMT": "Turkmenistan Standard Time", "MDT": "Macau Summer Time", "WAT": "West Africa Standard Time", "AKDT": "Alaska Daylight Time", "HECU": "Cuba Daylight Time", "CLT": "Chile Standard Time", "AEST": "Australian Eastern Standard Time", "SRT": "Suriname Time", "MESZ": "Central European Summer Time", "GYT": "Guyana Time", "CHADT": "Chatham Daylight Time", "ECT": "Ecuador Time", "ARST": "Argentina Summer Time", "COT": "Colombia Standard Time", "UYT": "Uruguay Standard Time", "CHAST": "Chatham Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "ADT": "Atlantic Daylight Time", "EDT": "Eastern Daylight Time", "HKT": "Hong Kong Standard Time", "ChST": "Chamorro Standard Time", "PDT": "Pacific Daylight Time", "IST": "India Standard Time", "NZST": "New Zealand Standard Time", "JST": "Japan Standard Time", "HAT": "Newfoundland Daylight Time", "AEDT": "Australian Eastern Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "AST": "Atlantic Standard Time", "CLST": "Chile Summer Time", "∅∅∅": "Acre Summer Time", "SAST": "South Africa Standard Time", "LHST": "Lord Howe Standard Time", "CDT": "Central Daylight Time", "MST": "Macau Standard Time", "HEEG": "East Greenland Summer Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "WEZ": "Western European Standard Time", "WAST": "West Africa Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "MEZ": "Central European Standard Time", "JDT": "Japan Daylight Time", "HKST": "Hong Kong Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "WITA": "Central Indonesia Time", "EAT": "East Africa Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "CAT": "Central Africa Time", "WARST": "Western Argentina Summer Time", "COST": "Colombia Summer Time", "HNT": "Newfoundland Standard Time", "AWDT": "Australian Western Daylight Time", "OESZ": "Eastern European Summer Time", "MYT": "Malaysia Time", "GFT": "French Guiana Time", "AWST": "Australian Western Standard Time", "PST": "Pacific Standard Time", "NZDT": "New Zealand Daylight Time", "WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "TMST": "Turkmenistan Summer Time", "ACST": "Australian Central Standard Time", "BT": "Bhutan Time", "UYST": "Uruguay Summer Time", "OEZ": "Eastern European Standard Time", "EST": "Eastern Standard Time", "ACDT": "Australian Central Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "HNPMX": "Mexican Pacific Standard Time", "ACWDT": "Australian Central Western Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_US) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_US' +func (en *en_US) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_US' +func (en *en_US) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_US' +func (en *en_US) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_US' +func (en *en_US) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_US' +func (en *en_US) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_US' +func (en *en_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_US) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_US) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_US) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_US) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_US) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_US) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_US) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_US) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_US) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_US) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_US) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_US) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_US) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_US) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_US' and handles both Whole and Real numbers based on 'v' +func (en *en_US) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_US' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_US) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_US' +func (en *en_US) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_US' +// in accounting notation. +func (en *en_US) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_US' +func (en *en_US) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_US' +func (en *en_US) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_US' +func (en *en_US) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_US' +func (en *en_US) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_US' +func (en *en_US) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_US' +func (en *en_US) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_US' +func (en *en_US) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_US' +func (en *en_US) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_US/en_US_test.go b/vendor/github.com/go-playground/locales/en_US/en_US_test.go new file mode 100644 index 0000000000..9b43fecd1c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_US/en_US_test.go @@ -0,0 +1,1120 @@ +package en_US + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_US" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_US_POSIX/en_US_POSIX.go b/vendor/github.com/go-playground/locales/en_US_POSIX/en_US_POSIX.go new file mode 100644 index 0000000000..1b2e620b5c --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_US_POSIX/en_US_POSIX.go @@ -0,0 +1,610 @@ +package en_US_POSIX + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_US_POSIX struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_US_POSIX' locale +func New() locales.Translator { + return &en_US_POSIX{ + locale: "en_US_POSIX", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "0/00", + timeSeparator: ":", + inifinity: "INF", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WIB": "Western Indonesia Time", "BOT": "Bolivia Time", "UYST": "Uruguay Summer Time", "SRT": "Suriname Time", "ECT": "Ecuador Time", "MESZ": "Central European Summer Time", "OESZ": "Eastern European Summer Time", "HNT": "Newfoundland Standard Time", "∅∅∅": "Azores Summer Time", "WART": "Western Argentina Standard Time", "MST": "Macau Standard Time", "MDT": "Macau Summer Time", "COST": "Colombia Summer Time", "WITA": "Central Indonesia Time", "HEOG": "West Greenland Summer Time", "CHAST": "Chatham Standard Time", "TMST": "Turkmenistan Summer Time", "HECU": "Cuba Daylight Time", "CHADT": "Chatham Daylight Time", "VET": "Venezuela Time", "JST": "Japan Standard Time", "OEZ": "Eastern European Standard Time", "GMT": "Greenwich Mean Time", "MYT": "Malaysia Time", "ARST": "Argentina Summer Time", "AWDT": "Australian Western Daylight Time", "HEEG": "East Greenland Summer Time", "HNEG": "East Greenland Standard Time", "ART": "Argentina Standard Time", "EST": "Eastern Standard Time", "AEST": "Australian Eastern Standard Time", "UYT": "Uruguay Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHDT": "Lord Howe Daylight Time", "WIT": "Eastern Indonesia Time", "HADT": "Hawaii-Aleutian Daylight Time", "AST": "Atlantic Standard Time", "CLT": "Chile Standard Time", "ACST": "Australian Central Standard Time", "SAST": "South Africa Standard Time", "SGT": "Singapore Standard Time", "CAT": "Central Africa Time", "ADT": "Atlantic Daylight Time", "WARST": "Western Argentina Summer Time", "TMT": "Turkmenistan Standard Time", "HKST": "Hong Kong Summer Time", "ACDT": "Australian Central Daylight Time", "CDT": "Central Daylight Time", "PDT": "Pacific Daylight Time", "HNOG": "West Greenland Standard Time", "HAT": "Newfoundland Daylight Time", "HNCU": "Cuba Standard Time", "NZDT": "New Zealand Daylight Time", "AKST": "Alaska Standard Time", "ACWDT": "Australian Central Western Daylight Time", "PST": "Pacific Standard Time", "JDT": "Japan Daylight Time", "AKDT": "Alaska Daylight Time", "AWST": "Australian Western Standard Time", "WESZ": "Western European Summer Time", "WAST": "West Africa Summer Time", "HKT": "Hong Kong Standard Time", "GYT": "Guyana Time", "EAT": "East Africa Time", "HAST": "Hawaii-Aleutian Standard Time", "MEZ": "Central European Standard Time", "CLST": "Chile Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "BT": "Bhutan Time", "HNPMX": "Mexican Pacific Standard Time", "AEDT": "Australian Eastern Daylight Time", "ChST": "Chamorro Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "WAT": "West Africa Standard Time", "EDT": "Eastern Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "GFT": "French Guiana Time", "ACWST": "Australian Central Western Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "CST": "Central Standard Time", "IST": "India Standard Time", "NZST": "New Zealand Standard Time", "WEZ": "Western European Standard Time", "COT": "Colombia Standard Time", "LHST": "Lord Howe Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_US_POSIX) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_US_POSIX' +func (en *en_US_POSIX) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_US_POSIX' +func (en *en_US_POSIX) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_US_POSIX' +func (en *en_US_POSIX) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_US_POSIX' +func (en *en_US_POSIX) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_US_POSIX' +func (en *en_US_POSIX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_US_POSIX' +func (en *en_US_POSIX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_US_POSIX) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_US_POSIX) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_US_POSIX) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_US_POSIX) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_US_POSIX) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_US_POSIX) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_US_POSIX) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_US_POSIX) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_US_POSIX) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_US_POSIX) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_US_POSIX) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_US_POSIX) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_US_POSIX) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_US_POSIX) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_US_POSIX' and handles both Whole and Real numbers based on 'v' +func (en *en_US_POSIX) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_US_POSIX' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_US_POSIX) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_US_POSIX' +// in accounting notation. +func (en *en_US_POSIX) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyNegativePrefix[j]) + } + + b = append(b, en.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(en.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, en.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_US_POSIX' +func (en *en_US_POSIX) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_US_POSIX/en_US_POSIX_test.go b/vendor/github.com/go-playground/locales/en_US_POSIX/en_US_POSIX_test.go new file mode 100644 index 0000000000..23734629e0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_US_POSIX/en_US_POSIX_test.go @@ -0,0 +1,1120 @@ +package en_US_POSIX + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_US_POSIX" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_VC/en_VC.go b/vendor/github.com/go-playground/locales/en_VC/en_VC.go new file mode 100644 index 0000000000..79f8fe4d91 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_VC/en_VC.go @@ -0,0 +1,645 @@ +package en_VC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_VC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_VC' locale +func New() locales.Translator { + return &en_VC{ + locale: "en_VC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"MYT": "Malaysia Time", "MDT": "Macau Summer Time", "AEST": "Australian Eastern Standard Time", "GFT": "French Guiana Time", "ACWST": "Australian Central Western Standard Time", "JST": "Japan Standard Time", "CLT": "Chile Standard Time", "TMT": "Turkmenistan Standard Time", "EDT": "Eastern Daylight Time", "AWDT": "Australian Western Daylight Time", "HEEG": "East Greenland Summer Time", "WITA": "Central Indonesia Time", "IST": "India Standard Time", "CLST": "Chile Summer Time", "HNOG": "West Greenland Standard Time", "ADT": "Atlantic Daylight Time", "HKT": "Hong Kong Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "UYST": "Uruguay Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "MESZ": "Central European Summer Time", "OEZ": "Eastern European Standard Time", "AWST": "Australian Western Standard Time", "ECT": "Ecuador Time", "PDT": "Pacific Daylight Time", "LHST": "Lord Howe Standard Time", "WIB": "Western Indonesia Time", "MEZ": "Central European Standard Time", "OESZ": "Eastern European Summer Time", "WESZ": "Western European Summer Time", "TMST": "Turkmenistan Summer Time", "COT": "Colombia Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "BOT": "Bolivia Time", "HEOG": "West Greenland Summer Time", "WAT": "West Africa Standard Time", "ACST": "Australian Central Standard Time", "COST": "Colombia Summer Time", "WIT": "Eastern Indonesia Time", "CHAST": "Chatham Standard Time", "NZST": "New Zealand Standard Time", "ACWDT": "Australian Central Western Daylight Time", "EST": "Eastern Standard Time", "HNEG": "East Greenland Standard Time", "AKST": "Alaska Standard Time", "GYT": "Guyana Time", "GMT": "Greenwich Mean Time", "ARST": "Argentina Summer Time", "ChST": "Chamorro Standard Time", "WARST": "Western Argentina Summer Time", "HAT": "Newfoundland Daylight Time", "SAST": "South Africa Standard Time", "CDT": "Central Daylight Time", "BT": "Bhutan Time", "UYT": "Uruguay Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNPMX": "Mexican Pacific Standard Time", "EAT": "East Africa Time", "CHADT": "Chatham Daylight Time", "∅∅∅": "Amazon Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "LHDT": "Lord Howe Daylight Time", "NZDT": "New Zealand Daylight Time", "JDT": "Japan Daylight Time", "AEDT": "Australian Eastern Daylight Time", "AST": "Atlantic Standard Time", "WEZ": "Western European Standard Time", "ACDT": "Australian Central Daylight Time", "HECU": "Cuba Daylight Time", "VET": "Venezuela Time", "HKST": "Hong Kong Summer Time", "SGT": "Singapore Standard Time", "PST": "Pacific Standard Time", "WART": "Western Argentina Standard Time", "MST": "Macau Standard Time", "HNT": "Newfoundland Standard Time", "SRT": "Suriname Time", "CAT": "Central Africa Time", "ART": "Argentina Standard Time", "WAST": "West Africa Summer Time", "AKDT": "Alaska Daylight Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_VC) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_VC' +func (en *en_VC) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_VC' +func (en *en_VC) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_VC' +func (en *en_VC) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_VC' +func (en *en_VC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_VC' +func (en *en_VC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_VC' +func (en *en_VC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_VC) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_VC) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_VC) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_VC) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_VC) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_VC) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_VC) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_VC) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_VC) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_VC) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_VC) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_VC) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_VC) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_VC) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_VC' and handles both Whole and Real numbers based on 'v' +func (en *en_VC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_VC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_VC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_VC' +func (en *en_VC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_VC' +// in accounting notation. +func (en *en_VC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_VC' +func (en *en_VC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_VC' +func (en *en_VC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_VC' +func (en *en_VC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_VC' +func (en *en_VC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_VC' +func (en *en_VC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_VC' +func (en *en_VC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_VC' +func (en *en_VC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_VC' +func (en *en_VC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_VC/en_VC_test.go b/vendor/github.com/go-playground/locales/en_VC/en_VC_test.go new file mode 100644 index 0000000000..26cfaa2d54 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_VC/en_VC_test.go @@ -0,0 +1,1120 @@ +package en_VC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_VC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_VG/en_VG.go b/vendor/github.com/go-playground/locales/en_VG/en_VG.go new file mode 100644 index 0000000000..d63f83914b --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_VG/en_VG.go @@ -0,0 +1,607 @@ +package en_VG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_VG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_VG' locale +func New() locales.Translator { + return &en_VG{ + locale: "en_VG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"JST": "Japan Standard Time", "MST": "Macau Standard Time", "ART": "Argentina Standard Time", "HKST": "Hong Kong Summer Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "WAST": "West Africa Summer Time", "WITA": "Central Indonesia Time", "WIT": "Eastern Indonesia Time", "CHAST": "Chatham Standard Time", "GMT": "Greenwich Mean Time", "MYT": "Malaysia Time", "WESZ": "Western European Summer Time", "EDT": "Eastern Daylight Time", "ACST": "Australian Central Standard Time", "AWDT": "Australian Western Daylight Time", "AEDT": "Australian Eastern Daylight Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CHADT": "Chatham Daylight Time", "IST": "India Standard Time", "JDT": "Japan Daylight Time", "HNOG": "West Greenland Standard Time", "ARST": "Argentina Summer Time", "HNEG": "East Greenland Standard Time", "CST": "Central Standard Time", "PDT": "Pacific Daylight Time", "NZST": "New Zealand Standard Time", "MEZ": "Central European Standard Time", "EST": "Eastern Standard Time", "COST": "Colombia Summer Time", "HNT": "Newfoundland Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "CAT": "Central Africa Time", "HKT": "Hong Kong Standard Time", "HAT": "Newfoundland Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "GYT": "Guyana Time", "ECT": "Ecuador Time", "WARST": "Western Argentina Summer Time", "AST": "Atlantic Standard Time", "OEZ": "Eastern European Standard Time", "ChST": "Chamorro Standard Time", "SAST": "South Africa Standard Time", "∅∅∅": "Amazon Summer Time", "WART": "Western Argentina Standard Time", "EAT": "East Africa Time", "CLST": "Chile Summer Time", "ADT": "Atlantic Daylight Time", "OESZ": "Eastern European Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "SRT": "Suriname Time", "WIB": "Western Indonesia Time", "HEEG": "East Greenland Summer Time", "GFT": "French Guiana Time", "LHST": "Lord Howe Standard Time", "PST": "Pacific Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "WAT": "West Africa Standard Time", "AEST": "Australian Eastern Standard Time", "AWST": "Australian Western Standard Time", "SGT": "Singapore Standard Time", "CLT": "Chile Standard Time", "TMST": "Turkmenistan Summer Time", "MDT": "Macau Summer Time", "AKST": "Alaska Standard Time", "UYT": "Uruguay Standard Time", "ACWDT": "Australian Central Western Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "HECU": "Cuba Daylight Time", "NZDT": "New Zealand Daylight Time", "UYST": "Uruguay Summer Time", "HEPMX": "Mexican Pacific Daylight Time", "ACWST": "Australian Central Western Standard Time", "MESZ": "Central European Summer Time", "HEOG": "West Greenland Summer Time", "COT": "Colombia Standard Time", "LHDT": "Lord Howe Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "CDT": "Central Daylight Time", "BOT": "Bolivia Time", "VET": "Venezuela Time", "WEZ": "Western European Standard Time", "TMT": "Turkmenistan Standard Time", "AKDT": "Alaska Daylight Time", "HNCU": "Cuba Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_VG) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_VG' +func (en *en_VG) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_VG' +func (en *en_VG) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_VG' +func (en *en_VG) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_VG' +func (en *en_VG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_VG' +func (en *en_VG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_VG' +func (en *en_VG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_VG) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_VG) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_VG) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_VG) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_VG) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_VG) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_VG) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_VG) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_VG) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_VG) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_VG) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_VG) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_VG) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_VG) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_VG' and handles both Whole and Real numbers based on 'v' +func (en *en_VG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_VG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_VG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_VG' +func (en *en_VG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_VG' +// in accounting notation. +func (en *en_VG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_VG' +func (en *en_VG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_VG' +func (en *en_VG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_VG' +func (en *en_VG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_VG' +func (en *en_VG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_VG' +func (en *en_VG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_VG' +func (en *en_VG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_VG' +func (en *en_VG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_VG' +func (en *en_VG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_VG/en_VG_test.go b/vendor/github.com/go-playground/locales/en_VG/en_VG_test.go new file mode 100644 index 0000000000..21d8fa9f0f --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_VG/en_VG_test.go @@ -0,0 +1,1120 @@ +package en_VG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_VG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_VI/en_VI.go b/vendor/github.com/go-playground/locales/en_VI/en_VI.go new file mode 100644 index 0000000000..670dbb93d0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_VI/en_VI.go @@ -0,0 +1,635 @@ +package en_VI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_VI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_VI' locale +func New() locales.Translator { + return &en_VI{ + locale: "en_VI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "HEOG": "West Greenland Summer Time", "HNT": "Newfoundland Standard Time", "SRT": "Suriname Time", "AWST": "Australian Western Standard Time", "VET": "Venezuela Time", "CLT": "Chile Standard Time", "HNOG": "West Greenland Standard Time", "ACDT": "Australian Central Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "TMT": "Turkmenistan Standard Time", "HKT": "Hong Kong Standard Time", "HEEG": "East Greenland Summer Time", "GFT": "French Guiana Time", "EAT": "East Africa Time", "AWDT": "Australian Western Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "MESZ": "Central European Summer Time", "ART": "Argentina Standard Time", "PST": "Pacific Standard Time", "IST": "India Standard Time", "CLST": "Chile Summer Time", "SAST": "South Africa Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "HECU": "Cuba Daylight Time", "PDT": "Pacific Daylight Time", "MST": "Macau Standard Time", "AKST": "Alaska Standard Time", "HNCU": "Cuba Standard Time", "SGT": "Singapore Standard Time", "BT": "Bhutan Time", "AKDT": "Alaska Daylight Time", "MEZ": "Central European Standard Time", "JDT": "Japan Daylight Time", "ADT": "Atlantic Daylight Time", "ARST": "Argentina Summer Time", "COST": "Colombia Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "NZST": "New Zealand Standard Time", "∅∅∅": "Amazon Summer Time", "TMST": "Turkmenistan Summer Time", "HKST": "Hong Kong Summer Time", "WITA": "Central Indonesia Time", "GYT": "Guyana Time", "ACWST": "Australian Central Western Standard Time", "MYT": "Malaysia Time", "CST": "Central Standard Time", "CHADT": "Chatham Daylight Time", "AST": "Atlantic Standard Time", "CDT": "Central Daylight Time", "ECT": "Ecuador Time", "WARST": "Western Argentina Summer Time", "ACST": "Australian Central Standard Time", "COT": "Colombia Standard Time", "HNPMX": "Mexican Pacific Standard Time", "CHAST": "Chatham Standard Time", "HAT": "Newfoundland Daylight Time", "LHST": "Lord Howe Standard Time", "WIT": "Eastern Indonesia Time", "BOT": "Bolivia Time", "UYT": "Uruguay Standard Time", "LHDT": "Lord Howe Daylight Time", "OEZ": "Eastern European Standard Time", "WART": "Western Argentina Standard Time", "MDT": "Macau Summer Time", "WAT": "West Africa Standard Time", "WAST": "West Africa Summer Time", "AEDT": "Australian Eastern Daylight Time", "OESZ": "Eastern European Summer Time", "EDT": "Eastern Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "AEST": "Australian Eastern Standard Time", "ChST": "Chamorro Standard Time", "WIB": "Western Indonesia Time", "CAT": "Central Africa Time", "NZDT": "New Zealand Daylight Time", "WEZ": "Western European Standard Time", "EST": "Eastern Standard Time", "UYST": "Uruguay Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "JST": "Japan Standard Time", "HNEG": "East Greenland Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_VI) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_VI' +func (en *en_VI) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_VI' +func (en *en_VI) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_VI' +func (en *en_VI) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_VI' +func (en *en_VI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_VI' +func (en *en_VI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_VI' +func (en *en_VI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_VI) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_VI) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_VI) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_VI) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_VI) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_VI) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_VI) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_VI) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_VI) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_VI) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_VI) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_VI) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_VI) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_VI) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_VI' and handles both Whole and Real numbers based on 'v' +func (en *en_VI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_VI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_VI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_VI' +func (en *en_VI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_VI' +// in accounting notation. +func (en *en_VI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_VI' +func (en *en_VI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_VI' +func (en *en_VI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_VI' +func (en *en_VI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_VI' +func (en *en_VI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_VI' +func (en *en_VI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_VI' +func (en *en_VI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_VI' +func (en *en_VI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_VI' +func (en *en_VI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_VI/en_VI_test.go b/vendor/github.com/go-playground/locales/en_VI/en_VI_test.go new file mode 100644 index 0000000000..979be2da9b --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_VI/en_VI_test.go @@ -0,0 +1,1120 @@ +package en_VI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_VI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_VU/en_VU.go b/vendor/github.com/go-playground/locales/en_VU/en_VU.go new file mode 100644 index 0000000000..008a66ffe6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_VU/en_VU.go @@ -0,0 +1,645 @@ +package en_VU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_VU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_VU' locale +func New() locales.Translator { + return &en_VU{ + locale: "en_VU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VT", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HKT": "Hong Kong Standard Time", "WAT": "West Africa Standard Time", "WAST": "West Africa Summer Time", "HNPMX": "Mexican Pacific Standard Time", "BOT": "Bolivia Time", "ACWDT": "Australian Central Western Daylight Time", "VET": "Venezuela Time", "ACDT": "Australian Central Daylight Time", "UYT": "Uruguay Standard Time", "CHADT": "Chatham Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "COST": "Colombia Summer Time", "AEDT": "Australian Eastern Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "SRT": "Suriname Time", "ACWST": "Australian Central Western Standard Time", "JST": "Japan Standard Time", "GFT": "French Guiana Time", "SAST": "South Africa Standard Time", "ECT": "Ecuador Time", "NZDT": "New Zealand Daylight Time", "JDT": "Japan Daylight Time", "ARST": "Argentina Summer Time", "MDT": "Macau Summer Time", "WITA": "Central Indonesia Time", "EAT": "East Africa Time", "CHAST": "Chatham Standard Time", "AWDT": "Australian Western Daylight Time", "LHDT": "Lord Howe Daylight Time", "CLT": "Chile Standard Time", "ART": "Argentina Standard Time", "BT": "Bhutan Time", "HECU": "Cuba Daylight Time", "MEZ": "Central European Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "HNOG": "West Greenland Standard Time", "HEOG": "West Greenland Summer Time", "UYST": "Uruguay Summer Time", "GYT": "Guyana Time", "CST": "Central Standard Time", "PST": "Pacific Standard Time", "TMT": "Turkmenistan Standard Time", "COT": "Colombia Standard Time", "AKDT": "Alaska Daylight Time", "CAT": "Central Africa Time", "WARST": "Western Argentina Summer Time", "OEZ": "Eastern European Standard Time", "WEZ": "Western European Standard Time", "WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "EST": "Eastern Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "WIB": "Western Indonesia Time", "IST": "India Standard Time", "ChST": "Chamorro Standard Time", "LHST": "Lord Howe Standard Time", "ACST": "Australian Central Standard Time", "AKST": "Alaska Standard Time", "HKST": "Hong Kong Summer Time", "HNNOMX": "Northwest Mexico Standard Time", "MST": "Macau Standard Time", "EDT": "Eastern Daylight Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "CDT": "Central Daylight Time", "OESZ": "Eastern European Summer Time", "NZST": "New Zealand Standard Time", "MYT": "Malaysia Time", "WART": "Western Argentina Standard Time", "CLST": "Chile Summer Time", "AST": "Atlantic Standard Time", "HNEG": "East Greenland Standard Time", "WIT": "Eastern Indonesia Time", "PDT": "Pacific Daylight Time", "HEEG": "East Greenland Summer Time", "TMST": "Turkmenistan Summer Time", "HAT": "Newfoundland Daylight Time", "∅∅∅": "Brasilia Summer Time", "AWST": "Australian Western Standard Time", "ADT": "Atlantic Daylight Time", "AEST": "Australian Eastern Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "SGT": "Singapore Standard Time", "MESZ": "Central European Summer Time", "HNCU": "Cuba Standard Time", "HNT": "Newfoundland Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_VU) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_VU' +func (en *en_VU) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_VU' +func (en *en_VU) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_VU' +func (en *en_VU) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_VU' +func (en *en_VU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_VU' +func (en *en_VU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_VU' +func (en *en_VU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_VU) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_VU) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_VU) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_VU) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_VU) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_VU) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_VU) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_VU) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_VU) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_VU) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_VU) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_VU) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_VU) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_VU) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_VU' and handles both Whole and Real numbers based on 'v' +func (en *en_VU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_VU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_VU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_VU' +func (en *en_VU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_VU' +// in accounting notation. +func (en *en_VU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_VU' +func (en *en_VU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_VU' +func (en *en_VU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_VU' +func (en *en_VU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_VU' +func (en *en_VU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_VU' +func (en *en_VU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_VU' +func (en *en_VU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_VU' +func (en *en_VU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_VU' +func (en *en_VU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_VU/en_VU_test.go b/vendor/github.com/go-playground/locales/en_VU/en_VU_test.go new file mode 100644 index 0000000000..8df491b168 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_VU/en_VU_test.go @@ -0,0 +1,1120 @@ +package en_VU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_VU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_WS/en_WS.go b/vendor/github.com/go-playground/locales/en_WS/en_WS.go new file mode 100644 index 0000000000..5a40563561 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_WS/en_WS.go @@ -0,0 +1,645 @@ +package en_WS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_WS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_WS' locale +func New() locales.Translator { + return &en_WS{ + locale: "en_WS", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WS$", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"EDT": "Eastern Daylight Time", "CDT": "Central Daylight Time", "AWST": "Australian Western Standard Time", "HKT": "Hong Kong Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "TMST": "Turkmenistan Summer Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "UYST": "Uruguay Summer Time", "NZDT": "New Zealand Daylight Time", "IST": "India Standard Time", "EST": "Eastern Standard Time", "WARST": "Western Argentina Summer Time", "OESZ": "Eastern European Summer Time", "WAT": "West Africa Standard Time", "HNCU": "Cuba Standard Time", "JST": "Japan Standard Time", "MEZ": "Central European Standard Time", "CLST": "Chile Summer Time", "ART": "Argentina Standard Time", "HENOMX": "Northwest Mexico Daylight Time", "COT": "Colombia Standard Time", "∅∅∅": "Azores Summer Time", "WIT": "Eastern Indonesia Time", "MESZ": "Central European Summer Time", "WITA": "Central Indonesia Time", "CHAST": "Chatham Standard Time", "GMT": "Greenwich Mean Time", "ADT": "Atlantic Daylight Time", "HADT": "Hawaii-Aleutian Daylight Time", "ACWST": "Australian Central Western Standard Time", "CAT": "Central Africa Time", "WEZ": "Western European Standard Time", "ChST": "Chamorro Standard Time", "SRT": "Suriname Time", "HECU": "Cuba Daylight Time", "CHADT": "Chatham Daylight Time", "AKST": "Alaska Standard Time", "LHDT": "Lord Howe Daylight Time", "CST": "Central Standard Time", "WAST": "West Africa Summer Time", "ARST": "Argentina Summer Time", "ACDT": "Australian Central Daylight Time", "BT": "Bhutan Time", "NZST": "New Zealand Standard Time", "WESZ": "Western European Summer Time", "HEOG": "West Greenland Summer Time", "OEZ": "Eastern European Standard Time", "ACST": "Australian Central Standard Time", "LHST": "Lord Howe Standard Time", "WIB": "Western Indonesia Time", "HAST": "Hawaii-Aleutian Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "AEST": "Australian Eastern Standard Time", "SAST": "South Africa Standard Time", "ECT": "Ecuador Time", "MDT": "Macau Summer Time", "PDT": "Pacific Daylight Time", "JDT": "Japan Daylight Time", "COST": "Colombia Summer Time", "HNEG": "East Greenland Standard Time", "HNT": "Newfoundland Standard Time", "GYT": "Guyana Time", "AWDT": "Australian Western Daylight Time", "PST": "Pacific Standard Time", "GFT": "French Guiana Time", "HKST": "Hong Kong Summer Time", "EAT": "East Africa Time", "MYT": "Malaysia Time", "CLT": "Chile Standard Time", "HEEG": "East Greenland Summer Time", "HAT": "Newfoundland Daylight Time", "AKDT": "Alaska Daylight Time", "BOT": "Bolivia Time", "WART": "Western Argentina Standard Time", "HNOG": "West Greenland Standard Time", "VET": "Venezuela Time", "AST": "Atlantic Standard Time", "TMT": "Turkmenistan Standard Time", "MST": "Macau Standard Time", "AEDT": "Australian Eastern Daylight Time", "HNPMX": "Mexican Pacific Standard Time", "SGT": "Singapore Standard Time", "ACWDT": "Australian Central Western Daylight Time", "UYT": "Uruguay Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_WS) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_WS' +func (en *en_WS) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_WS' +func (en *en_WS) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_WS' +func (en *en_WS) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_WS' +func (en *en_WS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_WS' +func (en *en_WS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_WS' +func (en *en_WS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_WS) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_WS) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_WS) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_WS) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_WS) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_WS) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_WS) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_WS) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_WS) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_WS) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_WS) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_WS) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_WS) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_WS) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_WS' and handles both Whole and Real numbers based on 'v' +func (en *en_WS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_WS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_WS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_WS' +func (en *en_WS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_WS' +// in accounting notation. +func (en *en_WS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_WS' +func (en *en_WS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_WS' +func (en *en_WS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_WS' +func (en *en_WS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_WS' +func (en *en_WS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_WS' +func (en *en_WS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_WS' +func (en *en_WS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_WS' +func (en *en_WS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_WS' +func (en *en_WS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_WS/en_WS_test.go b/vendor/github.com/go-playground/locales/en_WS/en_WS_test.go new file mode 100644 index 0000000000..156e856b34 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_WS/en_WS_test.go @@ -0,0 +1,1120 @@ +package en_WS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_WS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_ZA/en_ZA.go b/vendor/github.com/go-playground/locales/en_ZA/en_ZA.go new file mode 100644 index 0000000000..6ab3f7d720 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_ZA/en_ZA.go @@ -0,0 +1,627 @@ +package en_ZA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_ZA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_ZA' locale +func New() locales.Translator { + return &en_ZA{ + locale: "en_ZA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "R", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"WART": "Western Argentina Standard Time", "WAST": "West Africa Summer Time", "ART": "Argentina Standard Time", "WAT": "West Africa Standard Time", "HNT": "Newfoundland Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "WESZ": "Western European Summer Time", "GMT": "Greenwich Mean Time", "TMT": "Turkmenistan Standard Time", "MST": "Macau Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "GFT": "French Guiana Time", "UYST": "Uruguay Summer Time", "SAST": "South Africa Standard Time", "JDT": "Japan Daylight Time", "HKST": "Hong Kong Summer Time", "WITA": "Central Indonesia Time", "AKDT": "Alaska Daylight Time", "GYT": "Guyana Time", "HADT": "Hawaii-Aleutian Daylight Time", "ARST": "Argentina Summer Time", "HNCU": "Cuba Standard Time", "CST": "Central Standard Time", "AWDT": "Australian Western Daylight Time", "ACWDT": "Australian Central Western Daylight Time", "TMST": "Turkmenistan Summer Time", "HAT": "Newfoundland Daylight Time", "ACST": "Australian Central Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "VET": "Venezuela Time", "CLT": "Chile Standard Time", "ADT": "Atlantic Daylight Time", "EST": "Eastern Standard Time", "LHST": "Lord Howe Standard Time", "LHDT": "Lord Howe Daylight Time", "CHADT": "Chatham Daylight Time", "PST": "Pacific Standard Time", "ChST": "Chamorro Standard Time", "HEEG": "East Greenland Summer Time", "HECU": "Cuba Daylight Time", "HNEG": "East Greenland Standard Time", "EAT": "East Africa Time", "CDT": "Central Daylight Time", "SGT": "Singapore Standard Time", "BOT": "Bolivia Time", "IST": "India Standard Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "∅∅∅": "Acre Summer Time", "MYT": "Malaysia Time", "PDT": "Pacific Daylight Time", "JST": "Japan Standard Time", "CLST": "Chile Summer Time", "HEOG": "West Greenland Summer Time", "OEZ": "Eastern European Standard Time", "SRT": "Suriname Time", "WIT": "Eastern Indonesia Time", "AEDT": "Australian Eastern Daylight Time", "HENOMX": "Northwest Mexico Daylight Time", "AKST": "Alaska Standard Time", "AEST": "Australian Eastern Standard Time", "MDT": "Macau Summer Time", "COT": "Colombia Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "ECT": "Ecuador Time", "CAT": "Central Africa Time", "WARST": "Western Argentina Summer Time", "ACDT": "Australian Central Daylight Time", "AST": "Atlantic Standard Time", "COST": "Colombia Summer Time", "UYT": "Uruguay Standard Time", "MEZ": "Central European Standard Time", "EDT": "Eastern Daylight Time", "BT": "Bhutan Time", "WIB": "Western Indonesia Time", "CHAST": "Chatham Standard Time", "OESZ": "Eastern European Summer Time", "WEZ": "Western European Standard Time", "HKT": "Hong Kong Standard Time", "ACWST": "Australian Central Western Standard Time", "MESZ": "Central European Summer Time", "HNOG": "West Greenland Standard Time", "AWST": "Australian Western Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_ZA) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_ZA' +func (en *en_ZA) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_ZA' +func (en *en_ZA) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_ZA' +func (en *en_ZA) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_ZA' +func (en *en_ZA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_ZA' +func (en *en_ZA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_ZA' +func (en *en_ZA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_ZA) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_ZA) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_ZA) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_ZA) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_ZA) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_ZA) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_ZA) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_ZA) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_ZA) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_ZA) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_ZA) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_ZA) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_ZA) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_ZA) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_ZA' and handles both Whole and Real numbers based on 'v' +func (en *en_ZA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_ZA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_ZA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_ZA' +func (en *en_ZA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_ZA' +// in accounting notation. +func (en *en_ZA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(en.group) - 1; j >= 0; j-- { + b = append(b, en.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_ZA' +func (en *en_ZA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_ZA' +func (en *en_ZA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_ZA' +func (en *en_ZA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_ZA' +func (en *en_ZA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_ZA' +func (en *en_ZA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_ZA' +func (en *en_ZA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_ZA' +func (en *en_ZA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_ZA' +func (en *en_ZA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_ZA/en_ZA_test.go b/vendor/github.com/go-playground/locales/en_ZA/en_ZA_test.go new file mode 100644 index 0000000000..2c6b52b17f --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_ZA/en_ZA_test.go @@ -0,0 +1,1120 @@ +package en_ZA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_ZA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_ZM/en_ZM.go b/vendor/github.com/go-playground/locales/en_ZM/en_ZM.go new file mode 100644 index 0000000000..62f3d2a29e --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_ZM/en_ZM.go @@ -0,0 +1,645 @@ +package en_ZM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_ZM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_ZM' locale +func New() locales.Translator { + return &en_ZM{ + locale: "en_ZM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "K", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"VET": "Venezuela Time", "JDT": "Japan Daylight Time", "WARST": "Western Argentina Summer Time", "HNT": "Newfoundland Standard Time", "ChST": "Chamorro Standard Time", "EAT": "East Africa Time", "CST": "Central Standard Time", "ECT": "Ecuador Time", "OESZ": "Eastern European Summer Time", "HKT": "Hong Kong Standard Time", "HNPM": "St. Pierre & Miquelon Standard Time", "CHADT": "Chatham Daylight Time", "CAT": "Central Africa Time", "MEZ": "Central European Standard Time", "WESZ": "Western European Summer Time", "GFT": "French Guiana Time", "UYT": "Uruguay Standard Time", "GYT": "Guyana Time", "ACWST": "Australian Central Western Standard Time", "MESZ": "Central European Summer Time", "TMST": "Turkmenistan Summer Time", "MST": "Macau Standard Time", "MDT": "Macau Summer Time", "EST": "Eastern Standard Time", "BT": "Bhutan Time", "AKST": "Alaska Standard Time", "JST": "Japan Standard Time", "WART": "Western Argentina Standard Time", "CLST": "Chile Summer Time", "TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "ACDT": "Australian Central Daylight Time", "HEEG": "East Greenland Summer Time", "WEZ": "Western European Standard Time", "HKST": "Hong Kong Summer Time", "ACST": "Australian Central Standard Time", "LHST": "Lord Howe Standard Time", "SGT": "Singapore Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "MYT": "Malaysia Time", "HEOG": "West Greenland Summer Time", "ARST": "Argentina Summer Time", "EDT": "Eastern Daylight Time", "HNNOMX": "Northwest Mexico Standard Time", "WITA": "Central Indonesia Time", "SRT": "Suriname Time", "AWDT": "Australian Western Daylight Time", "IST": "India Standard Time", "AEST": "Australian Eastern Standard Time", "WIB": "Western Indonesia Time", "GMT": "Greenwich Mean Time", "COT": "Colombia Standard Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "BOT": "Bolivia Time", "ACWDT": "Australian Central Western Daylight Time", "HNOG": "West Greenland Standard Time", "AST": "Atlantic Standard Time", "WAST": "West Africa Summer Time", "SAST": "South Africa Standard Time", "PDT": "Pacific Daylight Time", "COST": "Colombia Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HAT": "Newfoundland Daylight Time", "AWST": "Australian Western Standard Time", "HNEG": "East Greenland Standard Time", "HNCU": "Cuba Standard Time", "CHAST": "Chatham Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "AEDT": "Australian Eastern Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "PST": "Pacific Standard Time", "ART": "Argentina Standard Time", "UYST": "Uruguay Summer Time", "HECU": "Cuba Daylight Time", "WIT": "Eastern Indonesia Time", "∅∅∅": "Amazon Summer Time", "ADT": "Atlantic Daylight Time", "LHDT": "Lord Howe Daylight Time", "CDT": "Central Daylight Time", "NZST": "New Zealand Standard Time", "NZDT": "New Zealand Daylight Time", "CLT": "Chile Standard Time", "OEZ": "Eastern European Standard Time", "AKDT": "Alaska Daylight Time", "HNPMX": "Mexican Pacific Standard Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_ZM) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_ZM' +func (en *en_ZM) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_ZM' +func (en *en_ZM) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_ZM' +func (en *en_ZM) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_ZM' +func (en *en_ZM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_ZM' +func (en *en_ZM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_ZM' +func (en *en_ZM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_ZM) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_ZM) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_ZM) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_ZM) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_ZM) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_ZM) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_ZM) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_ZM) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_ZM) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_ZM) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_ZM) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_ZM) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_ZM) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_ZM) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_ZM' and handles both Whole and Real numbers based on 'v' +func (en *en_ZM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_ZM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_ZM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_ZM' +func (en *en_ZM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_ZM' +// in accounting notation. +func (en *en_ZM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_ZM' +func (en *en_ZM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_ZM' +func (en *en_ZM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_ZM' +func (en *en_ZM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_ZM' +func (en *en_ZM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_ZM' +func (en *en_ZM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_ZM' +func (en *en_ZM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_ZM' +func (en *en_ZM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_ZM' +func (en *en_ZM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, en.periodsAbbreviated[0]...) + } else { + b = append(b, en.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_ZM/en_ZM_test.go b/vendor/github.com/go-playground/locales/en_ZM/en_ZM_test.go new file mode 100644 index 0000000000..69ba0ed508 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_ZM/en_ZM_test.go @@ -0,0 +1,1120 @@ +package en_ZM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_ZM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/en_ZW/en_ZW.go b/vendor/github.com/go-playground/locales/en_ZW/en_ZW.go new file mode 100644 index 0000000000..31639ac724 --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_ZW/en_ZW.go @@ -0,0 +1,610 @@ +package en_ZW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type en_ZW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'en_ZW' locale +func New() locales.Translator { + return &en_ZW{ + locale: "en_ZW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}, + daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}, + daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"B", "A"}, + erasWide: []string{"Before Christ", "Anno Domini"}, + timezones: map[string]string{"HNPM": "St. Pierre & Miquelon Standard Time", "LHST": "Lord Howe Standard Time", "COT": "Colombia Standard Time", "GFT": "French Guiana Time", "WARST": "Western Argentina Summer Time", "TMT": "Turkmenistan Standard Time", "WAT": "West Africa Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HEEG": "East Greenland Summer Time", "PST": "Pacific Standard Time", "WEZ": "Western European Standard Time", "CLT": "Chile Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "ACWST": "Australian Central Western Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HEPMX": "Mexican Pacific Daylight Time", "HNCU": "Cuba Standard Time", "SGT": "Singapore Standard Time", "TMST": "Turkmenistan Summer Time", "MYT": "Malaysia Time", "ACST": "Australian Central Standard Time", "HNEG": "East Greenland Standard Time", "HECU": "Cuba Daylight Time", "IST": "India Standard Time", "GMT": "Greenwich Mean Time", "JDT": "Japan Daylight Time", "HKT": "Hong Kong Standard Time", "ACDT": "Australian Central Daylight Time", "EAT": "East Africa Time", "CST": "Central Standard Time", "NZDT": "New Zealand Daylight Time", "UYST": "Uruguay Summer Time", "WIT": "Eastern Indonesia Time", "CHADT": "Chatham Daylight Time", "SAST": "South Africa Standard Time", "ARST": "Argentina Summer Time", "SRT": "Suriname Time", "BT": "Bhutan Time", "HENOMX": "Northwest Mexico Daylight Time", "COST": "Colombia Summer Time", "MEZ": "Central European Standard Time", "AST": "Atlantic Standard Time", "HAT": "Newfoundland Daylight Time", "UYT": "Uruguay Standard Time", "∅∅∅": "Brasilia Summer Time", "AWDT": "Australian Western Daylight Time", "GYT": "Guyana Time", "ACWDT": "Australian Central Western Daylight Time", "VET": "Venezuela Time", "AKDT": "Alaska Daylight Time", "NZST": "New Zealand Standard Time", "EDT": "Eastern Daylight Time", "WART": "Western Argentina Standard Time", "HEOG": "West Greenland Summer Time", "MST": "Macau Standard Time", "MDT": "Macau Summer Time", "HKST": "Hong Kong Summer Time", "HEPM": "St. Pierre & Miquelon Daylight Time", "AWST": "Australian Western Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "CAT": "Central Africa Time", "MESZ": "Central European Summer Time", "WAST": "West Africa Summer Time", "EST": "Eastern Standard Time", "HNT": "Newfoundland Standard Time", "WITA": "Central Indonesia Time", "CHAST": "Chatham Standard Time", "PDT": "Pacific Daylight Time", "ChST": "Chamorro Standard Time", "ADT": "Atlantic Daylight Time", "AEDT": "Australian Eastern Daylight Time", "AKST": "Alaska Standard Time", "CDT": "Central Daylight Time", "CLST": "Chile Summer Time", "JST": "Japan Standard Time", "WESZ": "Western European Summer Time", "HNOG": "West Greenland Standard Time", "OEZ": "Eastern European Standard Time", "OESZ": "Eastern European Summer Time", "ART": "Argentina Standard Time", "BOT": "Bolivia Time", "ECT": "Ecuador Time", "WIB": "Western Indonesia Time", "AEST": "Australian Eastern Standard Time", "LHDT": "Lord Howe Daylight Time"}, + } +} + +// Locale returns the current translators string locale +func (en *en_ZW) Locale() string { + return en.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'en_ZW' +func (en *en_ZW) PluralsCardinal() []locales.PluralRule { + return en.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'en_ZW' +func (en *en_ZW) PluralsOrdinal() []locales.PluralRule { + return en.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'en_ZW' +func (en *en_ZW) PluralsRange() []locales.PluralRule { + return en.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_ZW' +func (en *en_ZW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_ZW' +func (en *en_ZW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + + if nMod10 == 1 && nMod100 != 11 { + return locales.PluralRuleOne + } else if nMod10 == 2 && nMod100 != 12 { + return locales.PluralRuleTwo + } else if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_ZW' +func (en *en_ZW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (en *en_ZW) MonthAbbreviated(month time.Month) string { + return en.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (en *en_ZW) MonthsAbbreviated() []string { + return en.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (en *en_ZW) MonthNarrow(month time.Month) string { + return en.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (en *en_ZW) MonthsNarrow() []string { + return en.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (en *en_ZW) MonthWide(month time.Month) string { + return en.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (en *en_ZW) MonthsWide() []string { + return en.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (en *en_ZW) WeekdayAbbreviated(weekday time.Weekday) string { + return en.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (en *en_ZW) WeekdaysAbbreviated() []string { + return en.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (en *en_ZW) WeekdayNarrow(weekday time.Weekday) string { + return en.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (en *en_ZW) WeekdaysNarrow() []string { + return en.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (en *en_ZW) WeekdayShort(weekday time.Weekday) string { + return en.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (en *en_ZW) WeekdaysShort() []string { + return en.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (en *en_ZW) WeekdayWide(weekday time.Weekday) string { + return en.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (en *en_ZW) WeekdaysWide() []string { + return en.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'en_ZW' and handles both Whole and Real numbers based on 'v' +func (en *en_ZW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'en_ZW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (en *en_ZW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, en.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_ZW' +func (en *en_ZW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, en.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_ZW' +// in accounting notation. +func (en *en_ZW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := en.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, en.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, en.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, en.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, en.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, en.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'en_ZW' +func (en *en_ZW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'en_ZW' +func (en *en_ZW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'en_ZW' +func (en *en_ZW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'en_ZW' +func (en *en_ZW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, en.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, en.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'en_ZW' +func (en *en_ZW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'en_ZW' +func (en *en_ZW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'en_ZW' +func (en *en_ZW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'en_ZW' +func (en *en_ZW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, en.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, en.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := en.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/en_ZW/en_ZW_test.go b/vendor/github.com/go-playground/locales/en_ZW/en_ZW_test.go new file mode 100644 index 0000000000..36a726e94a --- /dev/null +++ b/vendor/github.com/go-playground/locales/en_ZW/en_ZW_test.go @@ -0,0 +1,1120 @@ +package en_ZW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "en_ZW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/eo/eo.go b/vendor/github.com/go-playground/locales/eo/eo.go new file mode 100644 index 0000000000..bc9cb85456 --- /dev/null +++ b/vendor/github.com/go-playground/locales/eo/eo.go @@ -0,0 +1,586 @@ +package eo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type eo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'eo' locale +func New() locales.Translator { + return &eo{ + locale: "eo", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "₺", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "aŭg", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januaro", "februaro", "marto", "aprilo", "majo", "junio", "julio", "aŭgusto", "septembro", "oktobro", "novembro", "decembro"}, + daysAbbreviated: []string{"di", "lu", "ma", "me", "ĵa", "ve", "sa"}, + daysNarrow: []string{"D", "L", "M", "M", "Ĵ", "V", "S"}, + daysWide: []string{"dimanĉo", "lundo", "mardo", "merkredo", "ĵaŭdo", "vendredo", "sabato"}, + periodsAbbreviated: []string{"atm", "ptm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"atm", "ptm"}, + erasAbbreviated: []string{"aK", "pK"}, + erasNarrow: []string{"aK", "pK"}, + erasWide: []string{"aK", "pK"}, + timezones: map[string]string{"ART": "ART", "ACDT": "centra aŭstralia somera tempo", "HECU": "HECU", "CHAST": "CHAST", "HADT": "HADT", "NZST": "NZST", "WART": "WART", "AST": "atlantika nord-amerika norma tempo", "BT": "BT", "MST": "MST", "EDT": "orienta nord-amerika somera tempo", "UYT": "UYT", "VET": "VET", "WAT": "okcidenta afrika norma tempo", "WAST": "okcidenta afrika somera tempo", "AWDT": "okcidenta aŭstralia somera tempo", "HAST": "HAST", "CAT": "centra afrika tempo", "HKST": "HKST", "ChST": "ChST", "CDT": "centra nord-amerika somera tempo", "∅∅∅": "∅∅∅", "AWST": "okcidenta aŭstralia norma tempo", "AEST": "orienta aŭstralia norma tempo", "HNPMX": "HNPMX", "CST": "centra nord-amerika norma tempo", "PDT": "pacifika nord-amerika somera tempo", "COST": "COST", "WESZ": "okcidenta eŭropa somera tempo", "HENOMX": "HENOMX", "NZDT": "NZDT", "WEZ": "okcidenta eŭropa norma tempo", "MDT": "MDT", "ACST": "centra aŭstralia norma tempo", "HAT": "HAT", "GYT": "GYT", "WIT": "orienta indonezia tempo", "ECT": "ECT", "CLT": "CLT", "HNT": "HNT", "AEDT": "orienta aŭstralia somera tempo", "HNNOMX": "HNNOMX", "GFT": "GFT", "ACWDT": "centrokcidenta aŭstralia somera tempo", "MESZ": "centra eŭropa somera tempo", "HNOG": "HNOG", "ADT": "atlantika nord-amerika somera tempo", "OESZ": "orienta eŭropa somera tempo", "HKT": "HKT", "WITA": "centra indonezia tempo", "UYST": "UYST", "SRT": "SRT", "EST": "orienta nord-amerika norma tempo", "SAST": "suda afrika tempo", "HNCU": "HNCU", "BOT": "BOT", "ACWST": "centrokcidenta aŭstralia norma tempo", "JST": "japana norma tempo", "JDT": "japana somera tempo", "WARST": "WARST", "SGT": "SGT", "PST": "pacifika nord-amerika norma tempo", "MYT": "MYT", "CLST": "CLST", "OEZ": "orienta eŭropa norma tempo", "HNPM": "HNPM", "LHDT": "LHDT", "MEZ": "centra eŭropa norma tempo", "HEOG": "HEOG", "TMST": "TMST", "COT": "COT", "HNEG": "HNEG", "HEEG": "HEEG", "HEPMX": "HEPMX", "CHADT": "CHADT", "IST": "barata tempo", "GMT": "universala tempo kunordigita", "AKST": "AKST", "HEPM": "HEPM", "LHST": "LHST", "EAT": "orienta afrika tempo", "WIB": "okcidenta indonezia tempo", "TMT": "TMT", "ARST": "ARST", "AKDT": "AKDT"}, + } +} + +// Locale returns the current translators string locale +func (eo *eo) Locale() string { + return eo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'eo' +func (eo *eo) PluralsCardinal() []locales.PluralRule { + return eo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'eo' +func (eo *eo) PluralsOrdinal() []locales.PluralRule { + return eo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'eo' +func (eo *eo) PluralsRange() []locales.PluralRule { + return eo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'eo' +func (eo *eo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'eo' +func (eo *eo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'eo' +func (eo *eo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (eo *eo) MonthAbbreviated(month time.Month) string { + return eo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (eo *eo) MonthsAbbreviated() []string { + return eo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (eo *eo) MonthNarrow(month time.Month) string { + return eo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (eo *eo) MonthsNarrow() []string { + return eo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (eo *eo) MonthWide(month time.Month) string { + return eo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (eo *eo) MonthsWide() []string { + return eo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (eo *eo) WeekdayAbbreviated(weekday time.Weekday) string { + return eo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (eo *eo) WeekdaysAbbreviated() []string { + return eo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (eo *eo) WeekdayNarrow(weekday time.Weekday) string { + return eo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (eo *eo) WeekdaysNarrow() []string { + return eo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (eo *eo) WeekdayShort(weekday time.Weekday) string { + return eo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (eo *eo) WeekdaysShort() []string { + return eo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (eo *eo) WeekdayWide(weekday time.Weekday) string { + return eo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (eo *eo) WeekdaysWide() []string { + return eo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'eo' and handles both Whole and Real numbers based on 'v' +func (eo *eo) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(eo.group) - 1; j >= 0; j-- { + b = append(b, eo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(eo.minus) - 1; j >= 0; j-- { + b = append(b, eo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'eo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (eo *eo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(eo.minus) - 1; j >= 0; j-- { + b = append(b, eo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, eo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'eo' +func (eo *eo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := eo.currencies[currency] + l := len(s) + len(symbol) + 7 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(eo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, eo.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(eo.minus) - 1; j >= 0; j-- { + b = append(b, eo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, eo.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'eo' +// in accounting notation. +func (eo *eo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := eo.currencies[currency] + l := len(s) + len(symbol) + 7 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(eo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, eo.currencyNegativePrefix[j]) + } + + for j := len(eo.minus) - 1; j >= 0; j-- { + b = append(b, eo.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(eo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, eo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, eo.currencyNegativeSuffix...) + } else { + + b = append(b, eo.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'eo' +func (eo *eo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'eo' +func (eo *eo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + b = append(b, eo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'eo' +func (eo *eo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + b = append(b, eo.monthsWide[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'eo' +func (eo *eo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, eo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d, 0x61}...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, eo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'eo' +func (eo *eo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'eo' +func (eo *eo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'eo' +func (eo *eo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'eo' +func (eo *eo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2d, 0x61}...) + b = append(b, []byte{0x20, 0x68, 0x6f, 0x72, 0x6f}...) + b = append(b, []byte{0x20, 0x6b, 0x61, 0x6a}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := eo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/eo/eo_test.go b/vendor/github.com/go-playground/locales/eo/eo_test.go new file mode 100644 index 0000000000..154f529320 --- /dev/null +++ b/vendor/github.com/go-playground/locales/eo/eo_test.go @@ -0,0 +1,1120 @@ +package eo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "eo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/eo_001/eo_001.go b/vendor/github.com/go-playground/locales/eo_001/eo_001.go new file mode 100644 index 0000000000..9aa3db91dd --- /dev/null +++ b/vendor/github.com/go-playground/locales/eo_001/eo_001.go @@ -0,0 +1,586 @@ +package eo_001 + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type eo_001 struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'eo_001' locale +func New() locales.Translator { + return &eo_001{ + locale: "eo_001", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "aŭg", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januaro", "februaro", "marto", "aprilo", "majo", "junio", "julio", "aŭgusto", "septembro", "oktobro", "novembro", "decembro"}, + daysAbbreviated: []string{"di", "lu", "ma", "me", "ĵa", "ve", "sa"}, + daysNarrow: []string{"D", "L", "M", "M", "Ĵ", "V", "S"}, + daysWide: []string{"dimanĉo", "lundo", "mardo", "merkredo", "ĵaŭdo", "vendredo", "sabato"}, + periodsAbbreviated: []string{"atm", "ptm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"atm", "ptm"}, + erasAbbreviated: []string{"aK", "pK"}, + erasNarrow: []string{"aK", "pK"}, + erasWide: []string{"aK", "pK"}, + timezones: map[string]string{"CDT": "centra nord-amerika somera tempo", "AWST": "okcidenta aŭstralia norma tempo", "ARST": "ARST", "HEEG": "HEEG", "GFT": "GFT", "WITA": "centra indonezia tempo", "AKST": "AKST", "EAT": "orienta afrika tempo", "JDT": "japana somera tempo", "MYT": "MYT", "COST": "COST", "HNNOMX": "HNNOMX", "WARST": "WARST", "OESZ": "orienta eŭropa somera tempo", "SAST": "suda afrika tempo", "PST": "pacifika nord-amerika norma tempo", "LHST": "LHST", "CHADT": "CHADT", "WAST": "okcidenta afrika somera tempo", "AEST": "orienta aŭstralia norma tempo", "ChST": "ChST", "HEPM": "HEPM", "ADT": "atlantika nord-amerika somera tempo", "EDT": "orienta nord-amerika somera tempo", "AKDT": "AKDT", "HECU": "HECU", "WIT": "orienta indonezia tempo", "MESZ": "centra eŭropa somera tempo", "VET": "VET", "TMST": "TMST", "MDT": "MDT", "ECT": "ECT", "SRT": "SRT", "GYT": "GYT", "NZST": "NZST", "HNOG": "HNOG", "WAT": "okcidenta afrika norma tempo", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "WEZ": "okcidenta eŭropa norma tempo", "CHAST": "CHAST", "PDT": "pacifika nord-amerika somera tempo", "ACWDT": "centrokcidenta aŭstralia somera tempo", "WART": "WART", "CLT": "CLT", "HNT": "HNT", "HADT": "HADT", "HEOG": "HEOG", "HNPMX": "HNPMX", "MST": "MST", "COT": "COT", "HAT": "HAT", "HEPMX": "HEPMX", "MEZ": "centra eŭropa norma tempo", "JST": "japana norma tempo", "OEZ": "orienta eŭropa norma tempo", "TMT": "TMT", "HAST": "HAST", "HNEG": "HNEG", "UYT": "UYT", "HNPM": "HNPM", "ACWST": "centrokcidenta aŭstralia norma tempo", "AST": "atlantika nord-amerika norma tempo", "WESZ": "okcidenta eŭropa somera tempo", "ART": "ART", "ACDT": "centra aŭstralia somera tempo", "ACST": "centra aŭstralia norma tempo", "CAT": "centra afrika tempo", "LHDT": "LHDT", "WIB": "okcidenta indonezia tempo", "CLST": "CLST", "GMT": "universala tempo kunordigita", "EST": "orienta nord-amerika norma tempo", "HKST": "HKST", "CST": "centra nord-amerika norma tempo", "AWDT": "okcidenta aŭstralia somera tempo", "SGT": "SGT", "HNCU": "HNCU", "BOT": "BOT", "IST": "barata tempo", "NZDT": "NZDT", "HKT": "HKT", "BT": "BT", "AEDT": "orienta aŭstralia somera tempo", "UYST": "UYST"}, + } +} + +// Locale returns the current translators string locale +func (eo *eo_001) Locale() string { + return eo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'eo_001' +func (eo *eo_001) PluralsCardinal() []locales.PluralRule { + return eo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'eo_001' +func (eo *eo_001) PluralsOrdinal() []locales.PluralRule { + return eo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'eo_001' +func (eo *eo_001) PluralsRange() []locales.PluralRule { + return eo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'eo_001' +func (eo *eo_001) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'eo_001' +func (eo *eo_001) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'eo_001' +func (eo *eo_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (eo *eo_001) MonthAbbreviated(month time.Month) string { + return eo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (eo *eo_001) MonthsAbbreviated() []string { + return eo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (eo *eo_001) MonthNarrow(month time.Month) string { + return eo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (eo *eo_001) MonthsNarrow() []string { + return eo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (eo *eo_001) MonthWide(month time.Month) string { + return eo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (eo *eo_001) MonthsWide() []string { + return eo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (eo *eo_001) WeekdayAbbreviated(weekday time.Weekday) string { + return eo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (eo *eo_001) WeekdaysAbbreviated() []string { + return eo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (eo *eo_001) WeekdayNarrow(weekday time.Weekday) string { + return eo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (eo *eo_001) WeekdaysNarrow() []string { + return eo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (eo *eo_001) WeekdayShort(weekday time.Weekday) string { + return eo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (eo *eo_001) WeekdaysShort() []string { + return eo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (eo *eo_001) WeekdayWide(weekday time.Weekday) string { + return eo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (eo *eo_001) WeekdaysWide() []string { + return eo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'eo_001' and handles both Whole and Real numbers based on 'v' +func (eo *eo_001) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(eo.group) - 1; j >= 0; j-- { + b = append(b, eo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(eo.minus) - 1; j >= 0; j-- { + b = append(b, eo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'eo_001' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (eo *eo_001) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(eo.minus) - 1; j >= 0; j-- { + b = append(b, eo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, eo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'eo_001' +func (eo *eo_001) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := eo.currencies[currency] + l := len(s) + len(symbol) + 7 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(eo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, eo.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(eo.minus) - 1; j >= 0; j-- { + b = append(b, eo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, eo.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'eo_001' +// in accounting notation. +func (eo *eo_001) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := eo.currencies[currency] + l := len(s) + len(symbol) + 7 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(eo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, eo.currencyNegativePrefix[j]) + } + + for j := len(eo.minus) - 1; j >= 0; j-- { + b = append(b, eo.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(eo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, eo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, eo.currencyNegativeSuffix...) + } else { + + b = append(b, eo.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'eo_001' +func (eo *eo_001) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'eo_001' +func (eo *eo_001) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + b = append(b, eo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'eo_001' +func (eo *eo_001) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + b = append(b, eo.monthsWide[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'eo_001' +func (eo *eo_001) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, eo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d, 0x61}...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, eo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'eo_001' +func (eo *eo_001) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'eo_001' +func (eo *eo_001) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'eo_001' +func (eo *eo_001) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'eo_001' +func (eo *eo_001) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2d, 0x61}...) + b = append(b, []byte{0x20, 0x68, 0x6f, 0x72, 0x6f}...) + b = append(b, []byte{0x20, 0x6b, 0x61, 0x6a}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := eo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/eo_001/eo_001_test.go b/vendor/github.com/go-playground/locales/eo_001/eo_001_test.go new file mode 100644 index 0000000000..c9feb90470 --- /dev/null +++ b/vendor/github.com/go-playground/locales/eo_001/eo_001_test.go @@ -0,0 +1,1120 @@ +package eo_001 + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "eo_001" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es/es.go b/vendor/github.com/go-playground/locales/es/es.go new file mode 100644 index 0000000000..146fd20240 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es/es.go @@ -0,0 +1,572 @@ +package es + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es' locale +func New() locales.Translator { + return &es{ + locale: "es", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "₧", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"CHADT": "hora de verano de Chatham", "CAT": "hora de África central", "HNOG": "hora estándar de Groenlandia occidental", "HKT": "hora estándar de Hong Kong", "AKST": "hora estándar de Alaska", "GYT": "hora de Guyana", "AST": "hora estándar del Atlántico", "HNEG": "hora estándar de Groenlandia oriental", "UYT": "hora estándar de Uruguay", "HECU": "hora de verano de Cuba", "AEST": "hora estándar de Australia oriental", "HEPMX": "hora de verano del Pacífico de México", "CST": "hora estándar central", "AWST": "hora estándar de Australia occidental", "ACWST": "hora estándar de Australia centroccidental", "WART": "hora estándar de Argentina occidental", "EDT": "hora de verano oriental", "COST": "hora de verano de Colombia", "MST": "Hora estándar de Macao", "ChST": "hora estándar de Chamorro", "HNCU": "hora estándar de Cuba", "ECT": "hora de Ecuador", "HADT": "hora de verano de Hawái-Aleutiano", "CLST": "hora de verano de Chile", "MDT": "Hora de verano de Macao", "WAT": "hora estándar de África occidental", "HNT": "hora estándar de Terranova", "AKDT": "hora de verano de Alaska", "HEPM": "hora de verano de San Pedro y Miquelón", "EAT": "hora de África oriental", "SGT": "hora de Singapur", "MESZ": "hora de verano de Europa central", "WAST": "hora de verano de África occidental", "ACDT": "hora de verano de Australia central", "PDT": "hora de verano del Pacífico", "NZDT": "hora de verano de Nueva Zelanda", "MEZ": "hora estándar de Europa central", "HEOG": "hora de verano de Groenlandia occidental", "LHST": "hora estándar de Lord Howe", "HNPM": "hora estándar de San Pedro y Miquelón", "SAST": "hora de Sudáfrica", "IST": "hora estándar de la India", "NZST": "hora estándar de Nueva Zelanda", "JDT": "hora de verano de Japón", "EST": "hora estándar oriental", "BT": "hora de Bután", "HAT": "hora de verano de Terranova", "HKST": "hora de verano de Hong Kong", "HNPMX": "hora estándar del Pacífico de México", "WIB": "hora de Indonesia occidental", "WESZ": "hora de verano de Europa occidental", "TMT": "hora estándar de Turkmenistán", "ACST": "hora estándar de Australia central", "ADT": "hora de verano del Atlántico", "WEZ": "hora estándar de Europa occidental", "∅∅∅": "hora de verano de Brasilia", "AWDT": "hora de verano de Australia occidental", "ACWDT": "hora de verano de Australia centroccidental", "VET": "hora de Venezuela", "JST": "hora estándar de Japón", "WARST": "hora de verano de Argentina occidental", "COT": "hora estándar de Colombia", "HEEG": "hora de verano de Groenlandia oriental", "GMT": "hora del meridiano de Greenwich", "ART": "hora estándar de Argentina", "HNNOMX": "hora estándar del noroeste de México", "HENOMX": "hora de verano del noroeste de México", "LHDT": "hora de verano de Lord Howe", "SRT": "hora de Surinam", "WITA": "hora de Indonesia central", "WIT": "hora de Indonesia oriental", "CHAST": "hora estándar de Chatham", "BOT": "hora de Bolivia", "MYT": "hora de Malasia", "CLT": "hora estándar de Chile", "ARST": "hora de verano de Argentina", "OESZ": "hora de verano de Europa oriental", "TMST": "hora de verano de Turkmenistán", "UYST": "hora de verano de Uruguay", "CDT": "hora de verano central", "PST": "hora estándar del Pacífico", "HAST": "hora estándar de Hawái-Aleutiano", "OEZ": "hora estándar de Europa oriental", "GFT": "hora de la Guayana Francesa", "AEDT": "hora de verano de Australia oriental"}, + } +} + +// Locale returns the current translators string locale +func (es *es) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es' +func (es *es) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es' +func (es *es) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es' +func (es *es) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es' +func (es *es) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es' +func (es *es) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es' +func (es *es) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es' and handles both Whole and Real numbers based on 'v' +func (es *es) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es' +func (es *es) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es' +// in accounting notation. +func (es *es) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es' +func (es *es) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es' +func (es *es) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es' +func (es *es) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es' +func (es *es) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es' +func (es *es) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es' +func (es *es) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es' +func (es *es) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es' +func (es *es) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es/es_test.go b/vendor/github.com/go-playground/locales/es/es_test.go new file mode 100644 index 0000000000..1a9d0eb61e --- /dev/null +++ b/vendor/github.com/go-playground/locales/es/es_test.go @@ -0,0 +1,1120 @@ +package es + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_419/es_419.go b/vendor/github.com/go-playground/locales/es_419/es_419.go new file mode 100644 index 0000000000..21d5a0cdaa --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_419/es_419.go @@ -0,0 +1,583 @@ +package es_419 + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_419 struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_419' locale +func New() locales.Translator { + return &es_419{ + locale: "es_419", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "E£", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "BsF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sep.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "e", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"d", "l", "m", "m", "j", "v", "s"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"SRT": "hora de Surinam", "TMST": "hora de verano de Turkmenistán", "CAT": "hora de África central", "TMT": "hora estándar de Turkmenistán", "MDT": "Hora de verano de Macao", "WAT": "hora estándar de África occidental", "ChST": "hora estándar de Chamorro", "WIB": "hora de Indonesia occidental", "CHADT": "hora de verano de Chatham", "HAST": "hora estándar de Hawái-Aleutianas", "HADT": "hora de verano de Hawái-Aleutianas", "ARST": "hora de verano de Argentina", "UYT": "hora estándar de Uruguay", "UYST": "hora de verano de Uruguay", "HNCU": "hora estándar de Cuba", "PDT": "hora de verano del Pacífico", "ACWST": "hora estándar de Australia centroccidental", "AST": "hora estándar del Atlántico", "ADT": "hora de verano del Atlántico", "EST": "hora estándar oriental", "COST": "hora de verano de Colombia", "BT": "hora de Bután", "SAST": "hora de Sudáfrica", "AWST": "hora estándar de Australia occidental", "SGT": "hora de Singapur", "JST": "hora estándar de Japón", "HKT": "hora estándar de Hong Kong", "AEST": "hora estándar de Australia oriental", "LHST": "hora estándar de Lord Howe", "MEZ": "hora estándar de Europa central", "WESZ": "hora de verano de Europa occidental", "CLT": "hora estándar de Chile", "EDT": "hora de verano oriental", "COT": "hora estándar de Colombia", "VET": "hora de Venezuela", "WEZ": "hora estándar de Europa occidental", "∅∅∅": "Hora de verano de Acre", "AEDT": "hora de verano de Australia oriental", "HECU": "hora de verano de Cuba", "WART": "hora estándar de Argentina occidental", "MST": "Hora estándar de Macao", "HKST": "hora de verano de Hong Kong", "CST": "hora estándar central", "GMT": "hora del meridiano de Greenwich", "WARST": "hora de verano de Argentina occidental", "ART": "hora estándar de Argentina", "GFT": "hora de la Guayana Francesa", "CHAST": "hora estándar de Chatham", "HEPMX": "hora de verano del Pacífico de México", "MESZ": "hora de verano de Europa central", "HEOG": "hora de verano de Groenlandia occidental", "HENOMX": "hora de verano del noroeste de México", "HNEG": "hora estándar de Groenlandia oriental", "HNPM": "hora estándar de San Pedro y Miquelón", "WIT": "hora de Indonesia oriental", "PST": "hora estándar del Pacífico", "OEZ": "hora estándar de Europa oriental", "HNOG": "hora estándar de Groenlandia occidental", "AKDT": "hora de verano de Alaska", "HNPMX": "hora estándar del Pacífico de México", "EAT": "hora de África oriental", "HAT": "hora de verano de Terranova", "WITA": "hora de Indonesia central", "GYT": "hora de Guyana", "AWDT": "hora de verano de Australia occidental", "CLST": "hora de verano de Chile", "LHDT": "hora de verano de Lord Howe", "OESZ": "hora de verano de Europa oriental", "HNNOMX": "hora estándar del noroeste de México", "HNT": "hora estándar de Terranova", "HEPM": "hora de verano de San Pedro y Miquelón", "MYT": "hora de Malasia", "ACDT": "hora de verano de Australia central", "HEEG": "hora de verano de Groenlandia oriental", "AKST": "hora estándar de Alaska", "BOT": "hora de Bolivia", "ECT": "hora de Ecuador", "IST": "hora de India", "ACWDT": "hora de verano de Australia centroccidental", "NZST": "hora estándar de Nueva Zelanda", "WAST": "hora de verano de África occidental", "ACST": "hora estándar de Australia central", "CDT": "hora de verano central", "NZDT": "hora de verano de Nueva Zelanda", "JDT": "hora de verano de Japón"}, + } +} + +// Locale returns the current translators string locale +func (es *es_419) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_419' +func (es *es_419) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_419' +func (es *es_419) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_419' +func (es *es_419) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_419' +func (es *es_419) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_419' +func (es *es_419) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_419' +func (es *es_419) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_419) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_419) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_419) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_419) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_419) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_419) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_419) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_419) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_419) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_419) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_419) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_419) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_419) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_419) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_419' and handles both Whole and Real numbers based on 'v' +func (es *es_419) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_419' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_419) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_419' +func (es *es_419) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_419' +// in accounting notation. +func (es *es_419) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_419' +func (es *es_419) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_419' +func (es *es_419) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_419' +func (es *es_419) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_419' +func (es *es_419) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_419' +func (es *es_419) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_419' +func (es *es_419) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_419' +func (es *es_419) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_419' +func (es *es_419) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_419/es_419_test.go b/vendor/github.com/go-playground/locales/es_419/es_419_test.go new file mode 100644 index 0000000000..9ccc5b9a73 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_419/es_419_test.go @@ -0,0 +1,1120 @@ +package es_419 + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_419" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_AR/es_AR.go b/vendor/github.com/go-playground/locales/es_AR/es_AR.go new file mode 100644 index 0000000000..7678229de5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_AR/es_AR.go @@ -0,0 +1,589 @@ +package es_AR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_AR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_AR' locale +func New() locales.Translator { + return &es_AR{ + locale: "es_AR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "$", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: "( ", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"OESZ": "hora de verano de Europa oriental", "TMST": "hora de verano de Turkmenistán", "HKT": "hora estándar de Hong Kong", "EAT": "hora de África oriental", "ACWST": "hora estándar de Australia centroccidental", "WART": "hora estándar de Argentina occidental", "HNOG": "hora estándar de Groenlandia occidental", "AWST": "hora estándar de Australia occidental", "ECT": "hora de Ecuador", "PDT": "hora de verano del Pacífico", "EDT": "hora de verano oriental", "SAST": "hora de Sudáfrica", "ChST": "hora estándar de Chamorro", "CST": "hora estándar central", "NZST": "hora estándar de Nueva Zelanda", "ARST": "hora de verano de Argentina", "∅∅∅": "hora de verano de Perú", "SGT": "hora de Singapur", "NZDT": "hora de verano de Nueva Zelanda", "WARST": "hora de verano de Argentina occidental", "CHADT": "hora de verano de Chatham", "MYT": "hora de Malasia", "MST": "Hora estándar de Macao", "COT": "hora estándar de Colombia", "GFT": "hora de la Guayana Francesa", "IST": "hora estándar de la India", "CLST": "hora de verano de Chile", "OEZ": "hora estándar de Europa oriental", "WAT": "hora estándar de África occidental", "BT": "hora de Bután", "AEDT": "hora de verano de Australia oriental", "UYT": "hora estándar de Uruguay", "HNPM": "hora estándar de San Pedro y Miquelón", "EST": "hora estándar oriental", "HNEG": "hora estándar de Groenlandia oriental", "HNPMX": "hora estándar del Pacífico de México", "SRT": "hora de Surinam", "CDT": "hora de verano central", "HADT": "hora de verano de Hawái-Aleutiano", "WESZ": "hora de verano de Europa occidental", "GMT": "hora del meridiano de Greenwich", "HNT": "hora estándar de Terranova", "HEPM": "hora de verano de San Pedro y Miquelón", "LHDT": "hora de verano de Lord Howe", "ACWDT": "hora de verano de Australia centroccidental", "MESZ": "hora de verano de Europa central", "COST": "hora de verano de Colombia", "ACST": "hora estándar de Australia central", "HNNOMX": "hora estándar del noroeste de México", "HEEG": "hora de verano de Groenlandia oriental", "JST": "hora estándar de Japón", "MDT": "Hora de verano de Macao", "JDT": "hora de verano de Japón", "CLT": "hora estándar de Chile", "HECU": "hora de verano de Cuba", "WIB": "hora de Indonesia occidental", "WIT": "hora de Indonesia oriental", "MEZ": "hora estándar de Europa central", "VET": "hora de Venezuela", "ACDT": "hora de verano de Australia central", "WITA": "hora de Indonesia central", "HNCU": "hora estándar de Cuba", "WAST": "hora de verano de África occidental", "HKST": "hora de verano de Hong Kong", "HENOMX": "hora de verano del noroeste de México", "HAT": "hora de verano de Terranova", "AKST": "hora estándar de Alaska", "HEPMX": "hora de verano del Pacífico de México", "HAST": "hora estándar de Hawái-Aleutiano", "CAT": "hora de África central", "AST": "hora estándar del Atlántico", "TMT": "hora estándar de Turkmenistán", "LHST": "hora estándar de Lord Howe", "GYT": "hora de Guyana", "AWDT": "hora de verano de Australia occidental", "AEST": "hora estándar de Australia oriental", "UYST": "hora de verano de Uruguay", "ART": "hora estándar de Argentina", "CHAST": "hora estándar de Chatham", "WEZ": "hora estándar de Europa occidental", "AKDT": "hora de verano de Alaska", "BOT": "hora de Bolivia", "PST": "hora estándar del Pacífico", "HEOG": "hora de verano de Groenlandia occidental", "ADT": "hora de verano del Atlántico"}, + } +} + +// Locale returns the current translators string locale +func (es *es_AR) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_AR' +func (es *es_AR) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_AR' +func (es *es_AR) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_AR' +func (es *es_AR) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_AR' +func (es *es_AR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_AR' +func (es *es_AR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_AR' +func (es *es_AR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_AR) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_AR) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_AR) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_AR) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_AR) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_AR) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_AR) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_AR) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_AR) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_AR) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_AR) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_AR) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_AR) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_AR) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_AR' and handles both Whole and Real numbers based on 'v' +func (es *es_AR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_AR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_AR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_AR' +func (es *es_AR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_AR' +// in accounting notation. +func (es *es_AR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyNegativePrefix[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_AR' +func (es *es_AR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_AR' +func (es *es_AR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_AR' +func (es *es_AR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_AR' +func (es *es_AR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_AR' +func (es *es_AR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_AR' +func (es *es_AR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_AR' +func (es *es_AR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_AR' +func (es *es_AR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_AR/es_AR_test.go b/vendor/github.com/go-playground/locales/es_AR/es_AR_test.go new file mode 100644 index 0000000000..ce4a210e84 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_AR/es_AR_test.go @@ -0,0 +1,1120 @@ +package es_AR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_AR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_BO/es_BO.go b/vendor/github.com/go-playground/locales/es_BO/es_BO.go new file mode 100644 index 0000000000..03d76de4d5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_BO/es_BO.go @@ -0,0 +1,573 @@ +package es_BO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_BO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_BO' locale +func New() locales.Translator { + return &es_BO{ + locale: "es_BO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "Bs", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"HNT": "hora estándar de Terranova", "HEPMX": "hora de verano del Pacífico de México", "NZST": "hora estándar de Nueva Zelanda", "WART": "hora estándar de Argentina occidental", "ART": "hora estándar de Argentina", "ACDT": "hora de verano de Australia central", "MST": "Hora estándar de Macao", "BT": "hora de Bután", "UYT": "hora estándar de Uruguay", "EAT": "hora de África oriental", "CST": "hora estándar central", "SGT": "hora de Singapur", "ADT": "hora de verano del Atlántico", "MESZ": "hora de verano de Europa central", "VET": "hora de Venezuela", "CLT": "hora estándar de Chile", "ARST": "hora de verano de Argentina", "WIT": "hora de Indonesia oriental", "EDT": "hora de verano oriental", "EST": "hora estándar oriental", "COT": "hora estándar de Colombia", "COST": "hora de verano de Colombia", "PST": "hora estándar del Pacífico", "NZDT": "hora de verano de Nueva Zelanda", "MEZ": "hora estándar de Europa central", "AST": "hora estándar del Atlántico", "WESZ": "hora de verano de Europa occidental", "HNNOMX": "hora estándar del noroeste de México", "HAT": "hora de verano de Terranova", "GFT": "hora de la Guayana Francesa", "SAST": "hora de Sudáfrica", "LHDT": "hora de verano de Lord Howe", "AWST": "hora estándar de Australia occidental", "WARST": "hora de verano de Argentina occidental", "WAST": "hora de verano de África occidental", "AKST": "hora estándar de Alaska", "HECU": "hora de verano de Cuba", "JDT": "hora de verano de Japón", "GMT": "hora del meridiano de Greenwich", "MDT": "Hora de verano de Macao", "HEEG": "hora de verano de Groenlandia oriental", "CHADT": "hora de verano de Chatham", "HENOMX": "hora de verano del noroeste de México", "AEST": "hora estándar de Australia oriental", "ChST": "hora estándar de Chamorro", "GYT": "hora de Guyana", "HNCU": "hora estándar de Cuba", "AWDT": "hora de verano de Australia occidental", "ECT": "hora de Ecuador", "ACWST": "hora estándar de Australia centroccidental", "AEDT": "hora de verano de Australia oriental", "HEOG": "hora de verano de Groenlandia occidental", "WEZ": "hora estándar de Europa occidental", "HKT": "hora estándar de Hong Kong", "HEPM": "hora de verano de San Pedro y Miquelón", "LHST": "hora estándar de Lord Howe", "SRT": "hora de Surinam", "IST": "hora estándar de la India", "ACWDT": "hora de verano de Australia centroccidental", "WITA": "hora de Indonesia central", "CDT": "hora de verano central", "HAST": "hora estándar de Hawái-Aleutiano", "JST": "hora estándar de Japón", "TMST": "hora de verano de Turkmenistán", "HNEG": "hora estándar de Groenlandia oriental", "ACST": "hora estándar de Australia central", "PDT": "hora de verano del Pacífico", "HADT": "hora de verano de Hawái-Aleutiano", "HNOG": "hora estándar de Groenlandia occidental", "WAT": "hora estándar de África occidental", "HKST": "hora de verano de Hong Kong", "∅∅∅": "hora de verano de las Azores", "CHAST": "hora estándar de Chatham", "BOT": "hora de Bolivia", "OESZ": "hora de verano de Europa oriental", "AKDT": "hora de verano de Alaska", "WIB": "hora de Indonesia occidental", "MYT": "hora de Malasia", "OEZ": "hora estándar de Europa oriental", "TMT": "hora estándar de Turkmenistán", "UYST": "hora de verano de Uruguay", "HNPM": "hora estándar de San Pedro y Miquelón", "HNPMX": "hora estándar del Pacífico de México", "CAT": "hora de África central", "CLST": "hora de verano de Chile"}, + } +} + +// Locale returns the current translators string locale +func (es *es_BO) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_BO' +func (es *es_BO) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_BO' +func (es *es_BO) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_BO' +func (es *es_BO) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_BO' +func (es *es_BO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_BO' +func (es *es_BO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_BO' +func (es *es_BO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_BO) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_BO) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_BO) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_BO) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_BO) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_BO) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_BO) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_BO) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_BO) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_BO) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_BO) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_BO) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_BO) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_BO) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_BO' and handles both Whole and Real numbers based on 'v' +func (es *es_BO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_BO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_BO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_BO' +func (es *es_BO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_BO' +// in accounting notation. +func (es *es_BO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_BO' +func (es *es_BO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_BO' +func (es *es_BO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_BO' +func (es *es_BO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_BO' +func (es *es_BO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_BO' +func (es *es_BO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_BO' +func (es *es_BO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_BO' +func (es *es_BO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_BO' +func (es *es_BO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_BO/es_BO_test.go b/vendor/github.com/go-playground/locales/es_BO/es_BO_test.go new file mode 100644 index 0000000000..8f0415405a --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_BO/es_BO_test.go @@ -0,0 +1,1120 @@ +package es_BO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_BO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_BR/es_BR.go b/vendor/github.com/go-playground/locales/es_BR/es_BR.go new file mode 100644 index 0000000000..629113a483 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_BR/es_BR.go @@ -0,0 +1,572 @@ +package es_BR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_BR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_BR' locale +func New() locales.Translator { + return &es_BR{ + locale: "es_BR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"HECU": "hora de verano de Cuba", "ADT": "hora de verano del Atlántico", "HKST": "hora de verano de Hong Kong", "AKST": "hora estándar de Alaska", "AKDT": "hora de verano de Alaska", "SRT": "hora de Surinam", "WIT": "hora de Indonesia oriental", "AWDT": "hora de verano de Australia occidental", "HAST": "hora estándar de Hawái-Aleutiano", "ART": "hora estándar de Argentina", "AEST": "hora estándar de Australia oriental", "ChST": "hora estándar de Chamorro", "CST": "hora estándar central", "OESZ": "hora de verano de Europa oriental", "ACST": "hora estándar de Australia central", "HNNOMX": "hora estándar del noroeste de México", "BT": "hora de Bután", "SAST": "hora de Sudáfrica", "HADT": "hora de verano de Hawái-Aleutiano", "MST": "Hora estándar de Macao", "HKT": "hora estándar de Hong Kong", "COT": "hora estándar de Colombia", "GYT": "hora de Guyana", "ACWDT": "hora de verano de Australia centroccidental", "MYT": "hora de Malasia", "UYT": "hora estándar de Uruguay", "HNCU": "hora estándar de Cuba", "NZDT": "hora de verano de Nueva Zelanda", "VET": "hora de Venezuela", "HEOG": "hora de verano de Groenlandia occidental", "EAT": "hora de África oriental", "WIB": "hora de Indonesia occidental", "CLST": "hora de verano de Chile", "TMST": "hora de verano de Turkmenistán", "CAT": "hora de África central", "ARST": "hora de verano de Argentina", "WAT": "hora estándar de África occidental", "EDT": "hora de verano oriental", "HEPM": "hora de verano de San Pedro y Miquelón", "HNPMX": "hora estándar del Pacífico de México", "CHAST": "hora estándar de Chatham", "SGT": "hora de Singapur", "TMT": "hora estándar de Turkmenistán", "BOT": "hora de Bolivia", "IST": "hora estándar de la India", "AST": "hora estándar del Atlántico", "COST": "hora de verano de Colombia", "CHADT": "hora de verano de Chatham", "PDT": "hora de verano del Pacífico", "NZST": "hora estándar de Nueva Zelanda", "JDT": "hora de verano de Japón", "WESZ": "hora de verano de Europa occidental", "WAST": "hora de verano de África occidental", "AWST": "hora estándar de Australia occidental", "ACDT": "hora de verano de Australia central", "HNT": "hora estándar de Terranova", "WART": "hora estándar de Argentina occidental", "OEZ": "hora estándar de Europa oriental", "EST": "hora estándar oriental", "∅∅∅": "Hora de verano de Acre", "UYST": "hora de verano de Uruguay", "LHDT": "hora de verano de Lord Howe", "HEPMX": "hora de verano del Pacífico de México", "MDT": "Hora de verano de Macao", "HNEG": "hora estándar de Groenlandia oriental", "GFT": "hora de la Guayana Francesa", "AEDT": "hora de verano de Australia oriental", "HNPM": "hora estándar de San Pedro y Miquelón", "LHST": "hora estándar de Lord Howe", "GMT": "hora del meridiano de Greenwich", "HEEG": "hora de verano de Groenlandia oriental", "CDT": "hora de verano central", "ECT": "hora de Ecuador", "JST": "hora estándar de Japón", "CLT": "hora estándar de Chile", "HNOG": "hora estándar de Groenlandia occidental", "WEZ": "hora estándar de Europa occidental", "WARST": "hora de verano de Argentina occidental", "HENOMX": "hora de verano del noroeste de México", "HAT": "hora de verano de Terranova", "WITA": "hora de Indonesia central", "PST": "hora estándar del Pacífico", "ACWST": "hora estándar de Australia centroccidental", "MEZ": "hora estándar de Europa central", "MESZ": "hora de verano de Europa central"}, + } +} + +// Locale returns the current translators string locale +func (es *es_BR) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_BR' +func (es *es_BR) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_BR' +func (es *es_BR) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_BR' +func (es *es_BR) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_BR' +func (es *es_BR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_BR' +func (es *es_BR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_BR' +func (es *es_BR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_BR) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_BR) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_BR) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_BR) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_BR) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_BR) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_BR) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_BR) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_BR) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_BR) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_BR) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_BR) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_BR) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_BR) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_BR' and handles both Whole and Real numbers based on 'v' +func (es *es_BR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_BR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_BR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_BR' +func (es *es_BR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_BR' +// in accounting notation. +func (es *es_BR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_BR' +func (es *es_BR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_BR' +func (es *es_BR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_BR' +func (es *es_BR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_BR' +func (es *es_BR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_BR' +func (es *es_BR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_BR' +func (es *es_BR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_BR' +func (es *es_BR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_BR' +func (es *es_BR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_BR/es_BR_test.go b/vendor/github.com/go-playground/locales/es_BR/es_BR_test.go new file mode 100644 index 0000000000..fab5afc5e8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_BR/es_BR_test.go @@ -0,0 +1,1120 @@ +package es_BR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_BR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_CL/es_CL.go b/vendor/github.com/go-playground/locales/es_CL/es_CL.go new file mode 100644 index 0000000000..246e1fccf5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_CL/es_CL.go @@ -0,0 +1,589 @@ +package es_CL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_CL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_CL' locale +func New() locales.Translator { + return &es_CL{ + locale: "es_CL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "$", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"do", "lu", "ma", "mi", "ju", "vi", "sá"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"HENOMX": "hora de verano del noroeste de México", "BT": "hora de Bután", "HAT": "hora de verano de Terranova", "AKDT": "hora de verano de Alaska", "HKT": "hora estándar de Hong Kong", "LHST": "hora estándar de Lord Howe", "HECU": "hora de verano de Cuba", "AWST": "hora estándar de Australia occidental", "CAT": "hora de África central", "ACWST": "hora estándar de Australia centroccidental", "MYT": "hora de Malasia", "MDT": "hora de verano de las Montañas", "AEDT": "hora de verano de Australia oriental", "HEPM": "hora de verano de San Pedro y Miquelón", "PDT": "hora de verano del Pacífico", "HADT": "hora de verano de Hawái-Aleutiano", "WESZ": "hora de verano de Europa occidental", "HNNOMX": "hora estándar del noroeste de México", "NZST": "hora estándar de Nueva Zelanda", "TMT": "hora estándar de Turkmenistán", "CHAST": "hora estándar de Chatham", "SAST": "hora de Sudáfrica", "LHDT": "hora de verano de Lord Howe", "CST": "hora estándar central", "IST": "hora estándar de la India", "CLT": "hora estándar de Chile", "∅∅∅": "Hora de verano de Acre", "UYST": "hora de verano de Uruguay", "AKST": "hora estándar de Alaska", "EAT": "hora de África oriental", "JST": "hora estándar de Japón", "WARST": "hora de verano de Argentina occidental", "ART": "hora estándar de Argentina", "UYT": "hora estándar de Uruguay", "HNT": "hora estándar de Terranova", "GFT": "hora de la Guayana Francesa", "AEST": "hora estándar de Australia oriental", "ADT": "hora de verano del Atlántico", "WAST": "hora de verano de África occidental", "HNEG": "hora estándar de Groenlandia oriental", "ChST": "hora estándar de Chamorro", "ACDT": "hora de verano de Australia central", "HNCU": "hora estándar de Cuba", "MEZ": "hora estándar de Europa central", "HNOG": "hora estándar de Groenlandia occidental", "HNPMX": "hora estándar del Pacífico de México", "COT": "hora estándar de Colombia", "GYT": "hora de Guyana", "HAST": "hora estándar de Hawái-Aleutiano", "JDT": "hora de verano de Japón", "CLST": "hora de verano de Chile", "AST": "hora estándar del Atlántico", "OESZ": "hora de verano de Europa oriental", "ACST": "hora estándar de Australia central", "GMT": "hora del meridiano de Greenwich", "WIT": "hora de Indonesia oriental", "SGT": "hora de Singapur", "ECT": "hora de Ecuador", "HEPMX": "hora de verano del Pacífico de México", "EDT": "hora de verano oriental", "MST": "hora estándar de las Montañas", "WITA": "hora de Indonesia central", "BOT": "hora de Bolivia", "OEZ": "hora estándar de Europa oriental", "TMST": "hora de verano de Turkmenistán", "WAT": "hora estándar de África occidental", "HEEG": "hora de verano de Groenlandia oriental", "SRT": "hora de Surinam", "PST": "hora estándar del Pacífico", "NZDT": "hora de verano de Nueva Zelanda", "WART": "hora estándar de Argentina occidental", "HEOG": "hora de verano de Groenlandia occidental", "COST": "hora de verano de Colombia", "CDT": "hora de verano central", "MESZ": "hora de verano de Europa central", "VET": "hora de Venezuela", "ARST": "hora de verano de Argentina", "HNPM": "hora estándar de San Pedro y Miquelón", "HKST": "hora de verano de Hong Kong", "WIB": "hora de Indonesia occidental", "AWDT": "hora de verano de Australia occidental", "CHADT": "hora de verano de Chatham", "ACWDT": "hora de verano de Australia centroccidental", "WEZ": "hora estándar de Europa occidental", "EST": "hora estándar oriental"}, + } +} + +// Locale returns the current translators string locale +func (es *es_CL) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_CL' +func (es *es_CL) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_CL' +func (es *es_CL) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_CL' +func (es *es_CL) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_CL' +func (es *es_CL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_CL' +func (es *es_CL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_CL' +func (es *es_CL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_CL) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_CL) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_CL) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_CL) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_CL) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_CL) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_CL) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_CL) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_CL) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_CL) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_CL) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_CL) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_CL) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_CL) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_CL' and handles both Whole and Real numbers based on 'v' +func (es *es_CL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_CL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_CL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_CL' +func (es *es_CL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_CL' +// in accounting notation. +func (es *es_CL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_CL' +func (es *es_CL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_CL' +func (es *es_CL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_CL' +func (es *es_CL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_CL' +func (es *es_CL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_CL' +func (es *es_CL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_CL' +func (es *es_CL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_CL' +func (es *es_CL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_CL' +func (es *es_CL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_CL/es_CL_test.go b/vendor/github.com/go-playground/locales/es_CL/es_CL_test.go new file mode 100644 index 0000000000..3f0df68cdb --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_CL/es_CL_test.go @@ -0,0 +1,1120 @@ +package es_CL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_CL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_CO/es_CO.go b/vendor/github.com/go-playground/locales/es_CO/es_CO.go new file mode 100644 index 0000000000..8c055488b2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_CO/es_CO.go @@ -0,0 +1,645 @@ +package es_CO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_CO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_CO' locale +func New() locales.Translator { + return &es_CO{ + locale: "es_CO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "$", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"JST": "hora estándar de Japón", "GMT": "hora del meridiano de Greenwich", "MYT": "hora de Malasia", "MST": "hora estándar de las Montañas", "CHAST": "hora estándar de Chatham", "HEOG": "hora de verano de Groenlandia occidental", "CLST": "hora de verano de Chile", "TMST": "hora de verano de Turkmenistán", "LHST": "hora estándar de Lord Howe", "ACST": "hora estándar de Australia central", "COT": "hora estándar de Colombia", "HEPMX": "hora de verano del Pacífico de México", "HECU": "hora de verano de Cuba", "CST": "hora estándar central", "CDT": "hora de verano central", "CHADT": "hora de verano de Chatham", "WAT": "hora estándar de África occidental", "HADT": "hora de verano de Hawái-Aleutiano", "ChST": "hora estándar de Chamorro", "SAST": "hora de Sudáfrica", "PST": "hora estándar del Pacífico", "HNT": "hora estándar de Terranova", "NZDT": "hora de verano de Nueva Zelanda", "ECT": "hora de Ecuador", "AEDT": "hora de verano de Australia oriental", "MDT": "hora de verano de las Montañas", "PDT": "hora de verano del Pacífico", "HKT": "hora estándar de Hong Kong", "UYT": "hora estándar de Uruguay", "EAT": "hora de África oriental", "WIB": "hora de Indonesia occidental", "IST": "hora estándar de la India", "NZST": "hora estándar de Nueva Zelanda", "MEZ": "hora estándar de Europa central", "JDT": "hora de verano de Japón", "COST": "hora de verano de Colombia", "WART": "hora estándar de Argentina occidental", "AKST": "hora estándar de Alaska", "GYT": "hora de Guyana", "ACWDT": "hora de verano de Australia centroccidental", "HENOMX": "hora de verano del noroeste de México", "HNEG": "hora estándar de Groenlandia oriental", "AEST": "hora estándar de Australia oriental", "HEPM": "hora de verano de San Pedro y Miquelón", "HAST": "hora estándar de Hawái-Aleutiano", "ACWST": "hora estándar de Australia centroccidental", "ARST": "hora de verano de Argentina", "ACDT": "hora de verano de Australia central", "GFT": "hora de la Guayana Francesa", "BOT": "hora de Bolivia", "MESZ": "hora de verano de Europa central", "TMT": "hora estándar de Turkmenistán", "HEEG": "hora de verano de Groenlandia oriental", "SRT": "hora de Surinam", "VET": "hora de Venezuela", "OEZ": "hora estándar de Europa oriental", "HNPM": "hora estándar de San Pedro y Miquelón", "LHDT": "hora de verano de Lord Howe", "HNCU": "hora estándar de Cuba", "OESZ": "hora de verano de Europa oriental", "AKDT": "hora de verano de Alaska", "∅∅∅": "Hora de verano de Acre", "EDT": "hora de verano oriental", "WIT": "hora de Indonesia oriental", "HNOG": "hora estándar de Groenlandia occidental", "EST": "hora estándar oriental", "WITA": "hora de Indonesia central", "CAT": "hora de África central", "WESZ": "hora de verano de Europa occidental", "CLT": "hora estándar de Chile", "ART": "hora estándar de Argentina", "WAST": "hora de verano de África occidental", "HNNOMX": "hora estándar del noroeste de México", "BT": "hora de Bután", "HAT": "hora de verano de Terranova", "UYST": "hora de verano de Uruguay", "HNPMX": "hora estándar del Pacífico de México", "AWST": "hora estándar de Australia occidental", "AWDT": "hora de verano de Australia occidental", "HKST": "hora de verano de Hong Kong", "AST": "hora estándar del Atlántico", "ADT": "hora de verano del Atlántico", "WEZ": "hora estándar de Europa occidental", "WARST": "hora de verano de Argentina occidental", "SGT": "hora de Singapur"}, + } +} + +// Locale returns the current translators string locale +func (es *es_CO) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_CO' +func (es *es_CO) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_CO' +func (es *es_CO) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_CO' +func (es *es_CO) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_CO' +func (es *es_CO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_CO' +func (es *es_CO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_CO' +func (es *es_CO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_CO) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_CO) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_CO) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_CO) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_CO) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_CO) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_CO) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_CO) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_CO) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_CO) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_CO) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_CO) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_CO) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_CO) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_CO' and handles both Whole and Real numbers based on 'v' +func (es *es_CO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_CO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_CO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_CO' +func (es *es_CO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_CO' +// in accounting notation. +func (es *es_CO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyNegativePrefix[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_CO' +func (es *es_CO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_CO' +func (es *es_CO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_CO' +func (es *es_CO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_CO' +func (es *es_CO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_CO' +func (es *es_CO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_CO' +func (es *es_CO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_CO' +func (es *es_CO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_CO' +func (es *es_CO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_CO/es_CO_test.go b/vendor/github.com/go-playground/locales/es_CO/es_CO_test.go new file mode 100644 index 0000000000..7dcfde5d1e --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_CO/es_CO_test.go @@ -0,0 +1,1120 @@ +package es_CO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_CO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_CR/es_CR.go b/vendor/github.com/go-playground/locales/es_CR/es_CR.go new file mode 100644 index 0000000000..e74bd2cdb4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_CR/es_CR.go @@ -0,0 +1,578 @@ +package es_CR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_CR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_CR' locale +func New() locales.Translator { + return &es_CR{ + locale: "es_CR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "₡", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"EDT": "hora de verano oriental", "HKST": "hora de verano de Hong Kong", "HEEG": "hora de verano de Groenlandia oriental", "HAST": "hora estándar de Hawái-Aleutiano", "NZDT": "hora de verano de Nueva Zelanda", "AKST": "hora estándar de Alaska", "UYT": "hora estándar de Uruguay", "HNPM": "hora estándar de San Pedro y Miquelón", "SAST": "hora de Sudáfrica", "CST": "hora estándar central", "ADT": "hora de verano del Atlántico", "HNPMX": "hora estándar del Pacífico de México", "MYT": "hora de Malasia", "WART": "hora estándar de Argentina occidental", "HNT": "hora estándar de Terranova", "AKDT": "hora de verano de Alaska", "NZST": "hora estándar de Nueva Zelanda", "COT": "hora estándar de Colombia", "GFT": "hora de la Guayana Francesa", "AEST": "hora estándar de Australia oriental", "AEDT": "hora de verano de Australia oriental", "LHST": "hora estándar de Lord Howe", "GYT": "hora de Guyana", "AWDT": "hora de verano de Australia occidental", "IST": "hora estándar de la India", "OESZ": "hora de verano de Europa oriental", "TMT": "hora estándar de Turkmenistán", "ART": "hora estándar de Argentina", "WAT": "hora estándar de África occidental", "EST": "hora estándar oriental", "COST": "hora de verano de Colombia", "EAT": "hora de África oriental", "PST": "hora estándar del Pacífico", "JST": "hora estándar de Japón", "JDT": "hora de verano de Japón", "GMT": "hora del meridiano de Greenwich", "SRT": "hora de Surinam", "CHAST": "hora estándar de Chatham", "MEZ": "hora estándar de Europa central", "ACWST": "hora estándar de Australia centroccidental", "VET": "hora de Venezuela", "HNOG": "hora estándar de Groenlandia occidental", "OEZ": "hora estándar de Europa oriental", "WARST": "hora de verano de Argentina occidental", "TMST": "hora de verano de Turkmenistán", "WIT": "hora de Indonesia oriental", "HADT": "hora de verano de Hawái-Aleutiano", "HEPMX": "hora de verano del Pacífico de México", "ACWDT": "hora de verano de Australia centroccidental", "WAST": "hora de verano de África occidental", "HNNOMX": "hora estándar del noroeste de México", "BOT": "hora de Bolivia", "ECT": "hora de Ecuador", "PDT": "hora de verano del Pacífico", "WEZ": "hora estándar de Europa occidental", "WESZ": "hora de verano de Europa occidental", "BT": "hora de Bután", "HECU": "hora de verano de Cuba", "WIB": "hora de Indonesia occidental", "HKT": "hora estándar de Hong Kong", "ACST": "hora estándar de Australia central", "HENOMX": "hora de verano del noroeste de México", "CDT": "hora de verano central", "SGT": "hora de Singapur", "HAT": "hora de verano de Terranova", "HNEG": "hora estándar de Groenlandia oriental", "LHDT": "hora de verano de Lord Howe", "HNCU": "hora estándar de Cuba", "CLT": "hora estándar de Chile", "WITA": "hora de Indonesia central", "UYST": "hora de verano de Uruguay", "∅∅∅": "hora de verano de Brasilia", "AST": "hora estándar del Atlántico", "MDT": "Hora de verano de Macao", "ChST": "hora estándar de Chamorro", "CAT": "hora de África central", "HEOG": "hora de verano de Groenlandia occidental", "MST": "Hora estándar de Macao", "ARST": "hora de verano de Argentina", "ACDT": "hora de verano de Australia central", "MESZ": "hora de verano de Europa central", "CLST": "hora de verano de Chile", "HEPM": "hora de verano de San Pedro y Miquelón", "AWST": "hora estándar de Australia occidental", "CHADT": "hora de verano de Chatham"}, + } +} + +// Locale returns the current translators string locale +func (es *es_CR) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_CR' +func (es *es_CR) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_CR' +func (es *es_CR) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_CR' +func (es *es_CR) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_CR' +func (es *es_CR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_CR' +func (es *es_CR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_CR' +func (es *es_CR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_CR) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_CR) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_CR) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_CR) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_CR) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_CR) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_CR) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_CR) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_CR) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_CR) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_CR) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_CR) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_CR) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_CR) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_CR' and handles both Whole and Real numbers based on 'v' +func (es *es_CR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(es.group) - 1; j >= 0; j-- { + b = append(b, es.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_CR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_CR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_CR' +func (es *es_CR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(es.group) - 1; j >= 0; j-- { + b = append(b, es.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_CR' +// in accounting notation. +func (es *es_CR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(es.group) - 1; j >= 0; j-- { + b = append(b, es.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_CR' +func (es *es_CR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_CR' +func (es *es_CR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_CR' +func (es *es_CR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_CR' +func (es *es_CR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_CR' +func (es *es_CR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_CR' +func (es *es_CR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_CR' +func (es *es_CR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_CR' +func (es *es_CR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_CR/es_CR_test.go b/vendor/github.com/go-playground/locales/es_CR/es_CR_test.go new file mode 100644 index 0000000000..bbc670391a --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_CR/es_CR_test.go @@ -0,0 +1,1120 @@ +package es_CR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_CR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_CU/es_CU.go b/vendor/github.com/go-playground/locales/es_CU/es_CU.go new file mode 100644 index 0000000000..cf91ceb0b5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_CU/es_CU.go @@ -0,0 +1,572 @@ +package es_CU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_CU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_CU' locale +func New() locales.Translator { + return &es_CU{ + locale: "es_CU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "$", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"GYT": "hora de Guyana", "ACWDT": "hora de verano de Australia centroccidental", "MST": "Hora estándar de Macao", "HEPM": "hora de verano de San Pedro y Miquelón", "HEPMX": "hora de verano del Pacífico de México", "SRT": "hora de Surinam", "JST": "hora estándar de Japón", "ART": "hora estándar de Argentina", "HNPM": "hora estándar de San Pedro y Miquelón", "ECT": "hora de Ecuador", "HAST": "hora estándar de Hawái-Aleutiano", "OESZ": "hora de verano de Europa oriental", "WIT": "hora de Indonesia oriental", "BOT": "hora de Bolivia", "CHADT": "hora de verano de Chatham", "WAT": "hora estándar de África occidental", "HAT": "hora de verano de Terranova", "LHDT": "hora de verano de Lord Howe", "CST": "hora estándar central", "AKDT": "hora de verano de Alaska", "HNPMX": "hora estándar del Pacífico de México", "WIB": "hora de Indonesia occidental", "MESZ": "hora de verano de Europa central", "AST": "hora estándar del Atlántico", "EDT": "hora de verano oriental", "BT": "hora de Bután", "TMST": "hora de verano de Turkmenistán", "UYST": "hora de verano de Uruguay", "CAT": "hora de África central", "HNT": "hora estándar de Terranova", "SGT": "hora de Singapur", "NZST": "hora estándar de Nueva Zelanda", "GMT": "hora del meridiano de Greenwich", "CLST": "hora de verano de Chile", "TMT": "hora estándar de Turkmenistán", "MDT": "Hora de verano de Macao", "SAST": "hora de Sudáfrica", "JDT": "hora de verano de Japón", "WESZ": "hora de verano de Europa occidental", "ACST": "hora estándar de Australia central", "UYT": "hora estándar de Uruguay", "HENOMX": "hora de verano del noroeste de México", "VET": "hora de Venezuela", "WEZ": "hora estándar de Europa occidental", "WART": "hora estándar de Argentina occidental", "HKT": "hora estándar de Hong Kong", "PST": "hora estándar del Pacífico", "MYT": "hora de Malasia", "WARST": "hora de verano de Argentina occidental", "CLT": "hora estándar de Chile", "HEEG": "hora de verano de Groenlandia oriental", "CDT": "hora de verano central", "PDT": "hora de verano del Pacífico", "ACWST": "hora estándar de Australia centroccidental", "WAST": "hora de verano de África occidental", "COST": "hora de verano de Colombia", "∅∅∅": "Hora de verano de Acre", "AEDT": "hora de verano de Australia oriental", "HNCU": "hora estándar de Cuba", "HECU": "hora de verano de Cuba", "MEZ": "hora estándar de Europa central", "HNOG": "hora estándar de Groenlandia occidental", "AWDT": "hora de verano de Australia occidental", "ACDT": "hora de verano de Australia central", "AEST": "hora estándar de Australia oriental", "ChST": "hora estándar de Chamorro", "AWST": "hora estándar de Australia occidental", "ADT": "hora de verano del Atlántico", "ARST": "hora de verano de Argentina", "EST": "hora estándar oriental", "HNNOMX": "hora estándar del noroeste de México", "NZDT": "hora de verano de Nueva Zelanda", "GFT": "hora de la Guayana Francesa", "WITA": "hora de Indonesia central", "LHST": "hora estándar de Lord Howe", "CHAST": "hora estándar de Chatham", "OEZ": "hora estándar de Europa oriental", "HEOG": "hora de verano de Groenlandia occidental", "HKST": "hora de verano de Hong Kong", "HNEG": "hora estándar de Groenlandia oriental", "HADT": "hora de verano de Hawái-Aleutiano", "COT": "hora estándar de Colombia", "AKST": "hora estándar de Alaska", "EAT": "hora de África oriental", "IST": "hora estándar de la India"}, + } +} + +// Locale returns the current translators string locale +func (es *es_CU) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_CU' +func (es *es_CU) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_CU' +func (es *es_CU) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_CU' +func (es *es_CU) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_CU' +func (es *es_CU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_CU' +func (es *es_CU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_CU' +func (es *es_CU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_CU) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_CU) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_CU) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_CU) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_CU) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_CU) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_CU) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_CU) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_CU) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_CU) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_CU) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_CU) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_CU) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_CU) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_CU' and handles both Whole and Real numbers based on 'v' +func (es *es_CU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_CU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_CU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_CU' +func (es *es_CU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_CU' +// in accounting notation. +func (es *es_CU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_CU' +func (es *es_CU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_CU' +func (es *es_CU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_CU' +func (es *es_CU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_CU' +func (es *es_CU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_CU' +func (es *es_CU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_CU' +func (es *es_CU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_CU' +func (es *es_CU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_CU' +func (es *es_CU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_CU/es_CU_test.go b/vendor/github.com/go-playground/locales/es_CU/es_CU_test.go new file mode 100644 index 0000000000..f59992139c --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_CU/es_CU_test.go @@ -0,0 +1,1120 @@ +package es_CU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_CU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_DO/es_DO.go b/vendor/github.com/go-playground/locales/es_DO/es_DO.go new file mode 100644 index 0000000000..15bda7e628 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_DO/es_DO.go @@ -0,0 +1,630 @@ +package es_DO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_DO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_DO' locale +func New() locales.Translator { + return &es_DO{ + locale: "es_DO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "RD$", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: ")", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de la Era Común", "Era Común"}, + timezones: map[string]string{"MST": "Hora estándar de Macao", "HEPM": "hora de verano de San Pedro y Miquelón", "HNPMX": "hora estándar del Pacífico de México", "SGT": "hora de Singapur", "WAT": "hora estándar de África occidental", "WAST": "hora de verano de África occidental", "AEDT": "hora de verano de Australia oriental", "HECU": "hora de verano de Cuba", "AWST": "hora estándar de Australia occidental", "ACWST": "hora estándar de Australia centroccidental", "NZDT": "hora de verano de Nueva Zelanda", "MEZ": "hora estándar de Europa central", "VET": "hora de Venezuela", "WEZ": "hora estándar de Europa occidental", "COST": "hora de verano de Colombia", "WITA": "hora de Indonesia central", "LHDT": "hora de verano de Lord Howe", "HNOG": "hora estándar de Groenlandia occidental", "AST": "hora estándar del Atlántico", "MYT": "hora de Malasia", "CLST": "hora de verano de Chile", "AKST": "hora estándar de Alaska", "CHADT": "hora de verano de Chatham", "EDT": "hora de verano oriental", "SAST": "hora de Sudáfrica", "EAT": "hora de África oriental", "HNCU": "hora estándar de Cuba", "CDT": "hora de verano central", "AWDT": "hora de verano de Australia occidental", "ADT": "hora de verano del Atlántico", "LHST": "hora estándar de Lord Howe", "SRT": "hora de Surinam", "GFT": "hora de la Guayana Francesa", "GYT": "hora de Guyana", "∅∅∅": "hora de verano de Brasilia", "WESZ": "hora de verano de Europa occidental", "ART": "hora estándar de Argentina", "HNEG": "hora estándar de Groenlandia oriental", "HNNOMX": "hora estándar del noroeste de México", "WIT": "hora de Indonesia oriental", "CHAST": "hora estándar de Chatham", "IST": "hora estándar de la India", "OEZ": "hora estándar de Europa oriental", "WARST": "hora de verano de Argentina occidental", "TMT": "hora estándar de Turkmenistán", "ACST": "hora estándar de Australia central", "ACDT": "hora de verano de Australia central", "COT": "hora estándar de Colombia", "ChST": "hora estándar de Chamorro", "UYST": "hora de verano de Uruguay", "HADT": "hora de verano de Hawái-Aleutiano", "MESZ": "hora de verano de Europa central", "GMT": "hora del meridiano de Greenwich", "WART": "hora estándar de Argentina occidental", "CLT": "hora estándar de Chile", "HNT": "hora estándar de Terranova", "CST": "hora estándar central", "BOT": "hora de Bolivia", "NZST": "hora estándar de Nueva Zelanda", "AKDT": "hora de verano de Alaska", "AEST": "hora estándar de Australia oriental", "HNPM": "hora estándar de San Pedro y Miquelón", "WIB": "hora de Indonesia occidental", "ACWDT": "hora de verano de Australia centroccidental", "TMST": "hora de verano de Turkmenistán", "HENOMX": "hora de verano del noroeste de México", "HEPMX": "hora de verano del Pacífico de México", "JDT": "hora de verano de Japón", "HKST": "hora de verano de Hong Kong", "BT": "hora de Bután", "HAT": "hora de verano de Terranova", "HEEG": "hora de verano de Groenlandia oriental", "UYT": "hora estándar de Uruguay", "PST": "hora estándar del Pacífico", "ECT": "hora de Ecuador", "CAT": "hora de África central", "HEOG": "hora de verano de Groenlandia occidental", "OESZ": "hora de verano de Europa oriental", "MDT": "Hora de verano de Macao", "ARST": "hora de verano de Argentina", "PDT": "hora de verano del Pacífico", "HAST": "hora estándar de Hawái-Aleutiano", "JST": "hora estándar de Japón", "EST": "hora estándar oriental", "HKT": "hora estándar de Hong Kong"}, + } +} + +// Locale returns the current translators string locale +func (es *es_DO) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_DO' +func (es *es_DO) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_DO' +func (es *es_DO) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_DO' +func (es *es_DO) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_DO' +func (es *es_DO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_DO' +func (es *es_DO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_DO' +func (es *es_DO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_DO) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_DO) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_DO) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_DO) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_DO) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_DO) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_DO) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_DO) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_DO) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_DO) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_DO) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_DO) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_DO) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_DO) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_DO' and handles both Whole and Real numbers based on 'v' +func (es *es_DO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_DO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_DO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_DO' +func (es *es_DO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_DO' +// in accounting notation. +func (es *es_DO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_DO' +func (es *es_DO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_DO' +func (es *es_DO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_DO' +func (es *es_DO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_DO' +func (es *es_DO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_DO' +func (es *es_DO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_DO' +func (es *es_DO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_DO' +func (es *es_DO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_DO' +func (es *es_DO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_DO/es_DO_test.go b/vendor/github.com/go-playground/locales/es_DO/es_DO_test.go new file mode 100644 index 0000000000..408334668d --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_DO/es_DO_test.go @@ -0,0 +1,1120 @@ +package es_DO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_DO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_EA/es_EA.go b/vendor/github.com/go-playground/locales/es_EA/es_EA.go new file mode 100644 index 0000000000..ab9afc5d70 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_EA/es_EA.go @@ -0,0 +1,572 @@ +package es_EA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_EA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_EA' locale +func New() locales.Translator { + return &es_EA{ + locale: "es_EA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"BOT": "hora de Bolivia", "PDT": "hora de verano del Pacífico", "ECT": "hora de Ecuador", "HKT": "hora estándar de Hong Kong", "∅∅∅": "Hora de verano de Acre", "HNPMX": "hora estándar del Pacífico de México", "SRT": "hora de Surinam", "HECU": "hora de verano de Cuba", "HAT": "hora de verano de Terranova", "EAT": "hora de África oriental", "AWST": "hora estándar de Australia occidental", "CAT": "hora de África central", "MST": "hora estándar de las Montañas", "HADT": "hora de verano de Hawái-Aleutiano", "CLT": "hora estándar de Chile", "HEOG": "hora de verano de Groenlandia occidental", "HENOMX": "hora de verano del noroeste de México", "GYT": "hora de Guyana", "IST": "hora estándar de la India", "ACWDT": "hora de verano de Australia centroccidental", "MEZ": "hora estándar de Europa central", "TMT": "hora estándar de Turkmenistán", "HNT": "hora estándar de Terranova", "CDT": "hora de verano central", "ACWST": "hora estándar de Australia centroccidental", "JDT": "hora de verano de Japón", "ADT": "hora de verano del Atlántico", "VET": "hora de Venezuela", "JST": "hora estándar de Japón", "CLST": "hora de verano de Chile", "EST": "hora estándar oriental", "ACST": "hora estándar de Australia central", "HNNOMX": "hora estándar del noroeste de México", "AKDT": "hora de verano de Alaska", "NZDT": "hora de verano de Nueva Zelanda", "AST": "hora estándar del Atlántico", "OEZ": "hora estándar de Europa oriental", "ACDT": "hora de verano de Australia central", "WITA": "hora de Indonesia central", "LHDT": "hora de verano de Lord Howe", "HAST": "hora estándar de Hawái-Aleutiano", "WESZ": "hora de verano de Europa occidental", "HKST": "hora de verano de Hong Kong", "COT": "hora estándar de Colombia", "HNCU": "hora estándar de Cuba", "WIB": "hora de Indonesia occidental", "CHADT": "hora de verano de Chatham", "HNEG": "hora estándar de Groenlandia oriental", "CST": "hora estándar central", "SGT": "hora de Singapur", "PST": "hora estándar del Pacífico", "AEST": "hora estándar de Australia oriental", "AEDT": "hora de verano de Australia oriental", "SAST": "hora de Sudáfrica", "HNOG": "hora estándar de Groenlandia occidental", "WARST": "hora de verano de Argentina occidental", "MDT": "hora de verano de las Montañas", "WIT": "hora de Indonesia oriental", "GMT": "hora del meridiano de Greenwich", "MYT": "hora de Malasia", "ART": "hora estándar de Argentina", "UYST": "hora de verano de Uruguay", "HEPM": "hora de verano de San Pedro y Miquelón", "LHST": "hora estándar de Lord Howe", "NZST": "hora estándar de Nueva Zelanda", "WAST": "hora de verano de África occidental", "COST": "hora de verano de Colombia", "HEEG": "hora de verano de Groenlandia oriental", "UYT": "hora estándar de Uruguay", "HNPM": "hora estándar de San Pedro y Miquelón", "OESZ": "hora de verano de Europa oriental", "WEZ": "hora estándar de Europa occidental", "TMST": "hora de verano de Turkmenistán", "ARST": "hora de verano de Argentina", "HEPMX": "hora de verano del Pacífico de México", "CHAST": "hora estándar de Chatham", "MESZ": "hora de verano de Europa central", "WAT": "hora estándar de África occidental", "EDT": "hora de verano oriental", "BT": "hora de Bután", "GFT": "hora de la Guayana Francesa", "ChST": "hora estándar de Chamorro", "WART": "hora estándar de Argentina occidental", "AKST": "hora estándar de Alaska", "AWDT": "hora de verano de Australia occidental"}, + } +} + +// Locale returns the current translators string locale +func (es *es_EA) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_EA' +func (es *es_EA) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_EA' +func (es *es_EA) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_EA' +func (es *es_EA) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_EA' +func (es *es_EA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_EA' +func (es *es_EA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_EA' +func (es *es_EA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_EA) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_EA) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_EA) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_EA) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_EA) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_EA) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_EA) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_EA) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_EA) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_EA) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_EA) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_EA) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_EA) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_EA) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_EA' and handles both Whole and Real numbers based on 'v' +func (es *es_EA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_EA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_EA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_EA' +func (es *es_EA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_EA' +// in accounting notation. +func (es *es_EA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_EA' +func (es *es_EA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_EA' +func (es *es_EA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_EA' +func (es *es_EA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_EA' +func (es *es_EA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_EA' +func (es *es_EA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_EA' +func (es *es_EA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_EA' +func (es *es_EA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_EA' +func (es *es_EA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_EA/es_EA_test.go b/vendor/github.com/go-playground/locales/es_EA/es_EA_test.go new file mode 100644 index 0000000000..82edcc7b0d --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_EA/es_EA_test.go @@ -0,0 +1,1120 @@ +package es_EA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_EA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_EC/es_EC.go b/vendor/github.com/go-playground/locales/es_EC/es_EC.go new file mode 100644 index 0000000000..ddc002ba19 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_EC/es_EC.go @@ -0,0 +1,569 @@ +package es_EC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_EC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_EC' locale +func New() locales.Translator { + return &es_EC{ + locale: "es_EC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"SRT": "hora de Surinam", "CHAST": "hora estándar de Chatham", "∅∅∅": "hora de verano del Amazonas", "HEEG": "hora de verano de Groenlandia oriental", "HNPM": "hora estándar de San Pedro y Miquelón", "MESZ": "hora de verano de Europa central", "ADT": "hora de verano del Atlántico", "AKDT": "hora de verano de Alaska", "AWST": "hora estándar de Australia occidental", "HADT": "hora de verano de Hawái-Aleutiano", "HNEG": "hora estándar de Groenlandia oriental", "BT": "hora de Bután", "WITA": "hora de Indonesia central", "HEPM": "hora de verano de San Pedro y Miquelón", "CST": "hora estándar central", "VET": "hora de Venezuela", "JST": "hora estándar de Japón", "WEZ": "hora estándar de Europa occidental", "HNNOMX": "hora estándar del noroeste de México", "IST": "hora estándar de la India", "ACWST": "hora estándar de Australia centroccidental", "ARST": "hora de verano de Argentina", "WAST": "hora de verano de África occidental", "CAT": "hora de África central", "CLST": "hora de verano de Chile", "HEOG": "hora de verano de Groenlandia occidental", "HAT": "hora de verano de Terranova", "CHADT": "hora de verano de Chatham", "PST": "hora estándar del Pacífico", "ACWDT": "hora de verano de Australia centroccidental", "NZST": "hora estándar de Nueva Zelanda", "LHDT": "hora de verano de Lord Howe", "SAST": "hora de Sudáfrica", "WIB": "hora de Indonesia occidental", "CDT": "hora de verano central", "OEZ": "hora estándar de Europa oriental", "WESZ": "hora de verano de Europa occidental", "WARST": "hora de verano de Argentina occidental", "AST": "hora estándar del Atlántico", "HKT": "hora estándar de Hong Kong", "ACST": "hora estándar de Australia central", "AKST": "hora estándar de Alaska", "HNCU": "hora estándar de Cuba", "EST": "hora estándar oriental", "UYST": "hora de verano de Uruguay", "LHST": "hora estándar de Lord Howe", "SGT": "hora de Singapur", "CLT": "hora estándar de Chile", "TMT": "hora estándar de Turkmenistán", "MDT": "Hora de verano de Macao", "COT": "hora estándar de Colombia", "UYT": "hora estándar de Uruguay", "AWDT": "hora de verano de Australia occidental", "PDT": "hora de verano del Pacífico", "NZDT": "hora de verano de Nueva Zelanda", "HKST": "hora de verano de Hong Kong", "WAT": "hora estándar de África occidental", "JDT": "hora de verano de Japón", "WART": "hora estándar de Argentina occidental", "HENOMX": "hora de verano del noroeste de México", "ACDT": "hora de verano de Australia central", "AEDT": "hora de verano de Australia oriental", "GYT": "hora de Guyana", "MEZ": "hora estándar de Europa central", "TMST": "hora de verano de Turkmenistán", "ART": "hora estándar de Argentina", "MST": "Hora estándar de Macao", "GFT": "hora de la Guayana Francesa", "ChST": "hora estándar de Chamorro", "BOT": "hora de Bolivia", "HAST": "hora estándar de Hawái-Aleutiano", "HNOG": "hora estándar de Groenlandia occidental", "AEST": "hora estándar de Australia oriental", "HECU": "hora de verano de Cuba", "EAT": "hora de África oriental", "WIT": "hora de Indonesia oriental", "ECT": "hora de Ecuador", "GMT": "hora del meridiano de Greenwich", "HNT": "hora estándar de Terranova", "HEPMX": "hora de verano del Pacífico de México", "HNPMX": "hora estándar del Pacífico de México", "OESZ": "hora de verano de Europa oriental", "MYT": "hora de Malasia", "EDT": "hora de verano oriental", "COST": "hora de verano de Colombia"}, + } +} + +// Locale returns the current translators string locale +func (es *es_EC) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_EC' +func (es *es_EC) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_EC' +func (es *es_EC) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_EC' +func (es *es_EC) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_EC' +func (es *es_EC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_EC' +func (es *es_EC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_EC' +func (es *es_EC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_EC) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_EC) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_EC) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_EC) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_EC) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_EC) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_EC) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_EC) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_EC) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_EC) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_EC) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_EC) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_EC) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_EC) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_EC' and handles both Whole and Real numbers based on 'v' +func (es *es_EC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_EC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_EC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_EC' +func (es *es_EC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_EC' +// in accounting notation. +func (es *es_EC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_EC' +func (es *es_EC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_EC' +func (es *es_EC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_EC' +func (es *es_EC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_EC' +func (es *es_EC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_EC' +func (es *es_EC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_EC' +func (es *es_EC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_EC' +func (es *es_EC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_EC' +func (es *es_EC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_EC/es_EC_test.go b/vendor/github.com/go-playground/locales/es_EC/es_EC_test.go new file mode 100644 index 0000000000..c53d362688 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_EC/es_EC_test.go @@ -0,0 +1,1120 @@ +package es_EC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_EC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_ES/es_ES.go b/vendor/github.com/go-playground/locales/es_ES/es_ES.go new file mode 100644 index 0000000000..0e6bd96567 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_ES/es_ES.go @@ -0,0 +1,572 @@ +package es_ES + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_ES struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_ES' locale +func New() locales.Translator { + return &es_ES{ + locale: "es_ES", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"TMST": "hora de verano de Turkmenistán", "MDT": "hora de verano de las Montañas", "JST": "hora estándar de Japón", "WESZ": "hora de verano de Europa occidental", "EST": "hora estándar oriental", "HNNOMX": "hora estándar del noroeste de México", "CHAST": "hora estándar de Chatham", "HAST": "hora estándar de Hawái-Aleutiano", "ACWDT": "hora de verano de Australia centroccidental", "ARST": "hora de verano de Argentina", "WAT": "hora estándar de África occidental", "GFT": "hora de la Guayana Francesa", "UYT": "hora estándar de Uruguay", "HECU": "hora de verano de Cuba", "EDT": "hora de verano oriental", "HKST": "hora de verano de Hong Kong", "HENOMX": "hora de verano del noroeste de México", "HEPM": "hora de verano de San Pedro y Miquelón", "HADT": "hora de verano de Hawái-Aleutiano", "WEZ": "hora estándar de Europa occidental", "WARST": "hora de verano de Argentina occidental", "AEDT": "hora de verano de Australia oriental", "CST": "hora estándar central", "MEZ": "hora estándar de Europa central", "PST": "hora estándar del Pacífico", "MESZ": "hora de verano de Europa central", "OESZ": "hora de verano de Europa oriental", "WART": "hora estándar de Argentina occidental", "MST": "hora estándar de las Montañas", "WIT": "hora de Indonesia oriental", "SGT": "hora de Singapur", "CLT": "hora estándar de Chile", "HEOG": "hora de verano de Groenlandia occidental", "ACDT": "hora de verano de Australia central", "ECT": "hora de Ecuador", "CAT": "hora de África central", "JDT": "hora de verano de Japón", "EAT": "hora de África oriental", "WIB": "hora de Indonesia occidental", "NZDT": "hora de verano de Nueva Zelanda", "ADT": "hora de verano del Atlántico", "GMT": "hora del meridiano de Greenwich", "AEST": "hora estándar de Australia oriental", "ChST": "hora estándar de Chamorro", "HNPMX": "hora estándar del Pacífico de México", "ACST": "hora estándar de Australia central", "GYT": "hora de Guyana", "ACWST": "hora estándar de Australia centroccidental", "AST": "hora estándar del Atlántico", "COST": "hora de verano de Colombia", "AKST": "hora estándar de Alaska", "MYT": "hora de Malasia", "COT": "hora estándar de Colombia", "HNOG": "hora estándar de Groenlandia occidental", "WITA": "hora de Indonesia central", "HEPMX": "hora de verano del Pacífico de México", "CLST": "hora de verano de Chile", "IST": "hora estándar de la India", "AKDT": "hora de verano de Alaska", "HNPM": "hora estándar de San Pedro y Miquelón", "PDT": "hora de verano del Pacífico", "CDT": "hora de verano central", "ART": "hora estándar de Argentina", "BT": "hora de Bután", "HNT": "hora estándar de Terranova", "SRT": "hora de Surinam", "OEZ": "hora estándar de Europa oriental", "HKT": "hora estándar de Hong Kong", "HEEG": "hora de verano de Groenlandia oriental", "∅∅∅": "Hora de verano de Acre", "LHST": "hora estándar de Lord Howe", "LHDT": "hora de verano de Lord Howe", "AWDT": "hora de verano de Australia occidental", "VET": "hora de Venezuela", "TMT": "hora estándar de Turkmenistán", "WAST": "hora de verano de África occidental", "HAT": "hora de verano de Terranova", "UYST": "hora de verano de Uruguay", "SAST": "hora de Sudáfrica", "CHADT": "hora de verano de Chatham", "BOT": "hora de Bolivia", "NZST": "hora estándar de Nueva Zelanda", "HNEG": "hora estándar de Groenlandia oriental", "HNCU": "hora estándar de Cuba", "AWST": "hora estándar de Australia occidental"}, + } +} + +// Locale returns the current translators string locale +func (es *es_ES) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_ES' +func (es *es_ES) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_ES' +func (es *es_ES) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_ES' +func (es *es_ES) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_ES' +func (es *es_ES) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_ES' +func (es *es_ES) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_ES' +func (es *es_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_ES) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_ES) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_ES) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_ES) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_ES) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_ES) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_ES) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_ES) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_ES) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_ES) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_ES) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_ES) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_ES) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_ES) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_ES' and handles both Whole and Real numbers based on 'v' +func (es *es_ES) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_ES' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_ES) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_ES' +func (es *es_ES) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_ES' +// in accounting notation. +func (es *es_ES) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_ES' +func (es *es_ES) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_ES' +func (es *es_ES) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_ES' +func (es *es_ES) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_ES' +func (es *es_ES) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_ES' +func (es *es_ES) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_ES' +func (es *es_ES) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_ES' +func (es *es_ES) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_ES' +func (es *es_ES) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_ES/es_ES_test.go b/vendor/github.com/go-playground/locales/es_ES/es_ES_test.go new file mode 100644 index 0000000000..1968501e8c --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_ES/es_ES_test.go @@ -0,0 +1,1120 @@ +package es_ES + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_ES" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_GQ/es_GQ.go b/vendor/github.com/go-playground/locales/es_GQ/es_GQ.go new file mode 100644 index 0000000000..7e8eae70dd --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_GQ/es_GQ.go @@ -0,0 +1,569 @@ +package es_GQ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_GQ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_GQ' locale +func New() locales.Translator { + return &es_GQ{ + locale: "es_GQ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"HNCU": "hora estándar de Cuba", "CAT": "hora de África central", "MDT": "Hora de verano de Macao", "HNEG": "hora estándar de Groenlandia oriental", "ChST": "hora estándar de Chamorro", "COT": "hora estándar de Colombia", "AEST": "hora estándar de Australia oriental", "AKST": "hora estándar de Alaska", "HEPM": "hora de verano de San Pedro y Miquelón", "CST": "hora estándar central", "BOT": "hora de Bolivia", "ACWDT": "hora de verano de Australia centroccidental", "CLT": "hora estándar de Chile", "WIB": "hora de Indonesia occidental", "CDT": "hora de verano central", "CHADT": "hora de verano de Chatham", "IST": "hora estándar de la India", "ARST": "hora de verano de Argentina", "HENOMX": "hora de verano del noroeste de México", "HAT": "hora de verano de Terranova", "AKDT": "hora de verano de Alaska", "HECU": "hora de verano de Cuba", "AWST": "hora estándar de Australia occidental", "NZDT": "hora de verano de Nueva Zelanda", "JDT": "hora de verano de Japón", "ART": "hora estándar de Argentina", "SAST": "hora de Sudáfrica", "OEZ": "hora estándar de Europa oriental", "WEZ": "hora estándar de Europa occidental", "TMST": "hora de verano de Turkmenistán", "HNT": "hora estándar de Terranova", "PDT": "hora de verano del Pacífico", "HADT": "hora de verano de Hawái-Aleutiano", "UYT": "hora estándar de Uruguay", "HNPM": "hora estándar de San Pedro y Miquelón", "GMT": "hora del meridiano de Greenwich", "HKT": "hora estándar de Hong Kong", "WAT": "hora estándar de África occidental", "ACDT": "hora de verano de Australia central", "AEDT": "hora de verano de Australia oriental", "HNPMX": "hora estándar del Pacífico de México", "CHAST": "hora estándar de Chatham", "MYT": "hora de Malasia", "ADT": "hora de verano del Atlántico", "EDT": "hora de verano oriental", "HNNOMX": "hora estándar del noroeste de México", "LHST": "hora estándar de Lord Howe", "ECT": "hora de Ecuador", "WESZ": "hora de verano de Europa occidental", "WART": "hora estándar de Argentina occidental", "MST": "Hora estándar de Macao", "AST": "hora estándar del Atlántico", "TMT": "hora estándar de Turkmenistán", "COST": "hora de verano de Colombia", "AWDT": "hora de verano de Australia occidental", "ACWST": "hora estándar de Australia centroccidental", "JST": "hora estándar de Japón", "CLST": "hora de verano de Chile", "GYT": "hora de Guyana", "SGT": "hora de Singapur", "HAST": "hora estándar de Hawái-Aleutiano", "MEZ": "hora estándar de Europa central", "HEPMX": "hora de verano del Pacífico de México", "OESZ": "hora de verano de Europa oriental", "WITA": "hora de Indonesia central", "HEEG": "hora de verano de Groenlandia oriental", "GFT": "hora de la Guayana Francesa", "VET": "hora de Venezuela", "MESZ": "hora de verano de Europa central", "HEOG": "hora de verano de Groenlandia occidental", "WAST": "hora de verano de África occidental", "EST": "hora estándar oriental", "HKST": "hora de verano de Hong Kong", "SRT": "hora de Surinam", "PST": "hora estándar del Pacífico", "NZST": "hora estándar de Nueva Zelanda", "WARST": "hora de verano de Argentina occidental", "HNOG": "hora estándar de Groenlandia occidental", "WIT": "hora de Indonesia oriental", "ACST": "hora estándar de Australia central", "BT": "hora de Bután", "LHDT": "hora de verano de Lord Howe", "∅∅∅": "hora de verano de Brasilia", "UYST": "hora de verano de Uruguay", "EAT": "hora de África oriental"}, + } +} + +// Locale returns the current translators string locale +func (es *es_GQ) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_GQ' +func (es *es_GQ) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_GQ' +func (es *es_GQ) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_GQ' +func (es *es_GQ) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_GQ' +func (es *es_GQ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_GQ' +func (es *es_GQ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_GQ' +func (es *es_GQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_GQ) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_GQ) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_GQ) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_GQ) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_GQ) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_GQ) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_GQ) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_GQ) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_GQ) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_GQ) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_GQ) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_GQ) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_GQ) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_GQ) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_GQ' and handles both Whole and Real numbers based on 'v' +func (es *es_GQ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_GQ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_GQ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_GQ' +func (es *es_GQ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_GQ' +// in accounting notation. +func (es *es_GQ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_GQ' +func (es *es_GQ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_GQ' +func (es *es_GQ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_GQ' +func (es *es_GQ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_GQ' +func (es *es_GQ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_GQ' +func (es *es_GQ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_GQ' +func (es *es_GQ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_GQ' +func (es *es_GQ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_GQ' +func (es *es_GQ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_GQ/es_GQ_test.go b/vendor/github.com/go-playground/locales/es_GQ/es_GQ_test.go new file mode 100644 index 0000000000..8eed144ba1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_GQ/es_GQ_test.go @@ -0,0 +1,1120 @@ +package es_GQ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_GQ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_GT/es_GT.go b/vendor/github.com/go-playground/locales/es_GT/es_GT.go new file mode 100644 index 0000000000..173c60b059 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_GT/es_GT.go @@ -0,0 +1,550 @@ +package es_GT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_GT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_GT' locale +func New() locales.Translator { + return &es_GT{ + locale: "es_GT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "Q", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: "K", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"ACWDT": "hora de verano de Australia centroccidental", "AEDT": "hora de verano de Australia oriental", "UYT": "hora estándar de Uruguay", "WIB": "hora de Indonesia occidental", "BOT": "hora de Bolivia", "MEZ": "hora estándar de Europa central", "ACST": "hora estándar de Australia central", "AKDT": "hora de verano de Alaska", "ECT": "hora de Ecuador", "WART": "hora estándar de Argentina occidental", "WAST": "hora de verano de África occidental", "GFT": "hora de la Guayana Francesa", "AKST": "hora estándar de Alaska", "WAT": "hora estándar de África occidental", "HENOMX": "hora de verano del noroeste de México", "AWST": "hora estándar de Australia occidental", "HADT": "hora de verano de Hawái-Aleutiano", "VET": "hora de Venezuela", "JST": "hora estándar de Japón", "HNOG": "hora estándar de Groenlandia occidental", "MDT": "Hora de verano de Macao", "ChST": "hora estándar de Chamorro", "EAT": "hora de África oriental", "HECU": "hora de verano de Cuba", "MESZ": "hora de verano de Europa central", "ACDT": "hora de verano de Australia central", "COST": "hora de verano de Colombia", "HNEG": "hora estándar de Groenlandia oriental", "LHST": "hora estándar de Lord Howe", "LHDT": "hora de verano de Lord Howe", "∅∅∅": "hora de verano de Brasilia", "ACWST": "hora estándar de Australia centroccidental", "NZDT": "hora de verano de Nueva Zelanda", "CLST": "hora de verano de Chile", "HEOG": "hora de verano de Groenlandia occidental", "WITA": "hora de Indonesia central", "COT": "hora estándar de Colombia", "HNPM": "hora estándar de San Pedro y Miquelón", "SRT": "hora de Surinam", "GYT": "hora de Guyana", "WIT": "hora de Indonesia oriental", "AWDT": "hora de verano de Australia occidental", "JDT": "hora de verano de Japón", "TMST": "hora de verano de Turkmenistán", "ART": "hora estándar de Argentina", "EDT": "hora de verano oriental", "BT": "hora de Bután", "CST": "hora estándar central", "CDT": "hora de verano central", "PST": "hora estándar del Pacífico", "IST": "hora estándar de la India", "NZST": "hora estándar de Nueva Zelanda", "WEZ": "hora estándar de Europa occidental", "MYT": "hora de Malasia", "OESZ": "hora de verano de Europa oriental", "HEPM": "hora de verano de San Pedro y Miquelón", "HAST": "hora estándar de Hawái-Aleutiano", "WARST": "hora de verano de Argentina occidental", "TMT": "hora estándar de Turkmenistán", "HKT": "hora estándar de Hong Kong", "HAT": "hora de verano de Terranova", "HNCU": "hora estándar de Cuba", "SGT": "hora de Singapur", "CLT": "hora estándar de Chile", "HNT": "hora estándar de Terranova", "AEST": "hora estándar de Australia oriental", "CHAST": "hora estándar de Chatham", "ADT": "hora de verano del Atlántico", "OEZ": "hora estándar de Europa oriental", "GMT": "hora del meridiano de Greenwich", "HEEG": "hora de verano de Groenlandia oriental", "UYST": "hora de verano de Uruguay", "SAST": "hora de Sudáfrica", "PDT": "hora de verano del Pacífico", "CAT": "hora de África central", "WESZ": "hora de verano de Europa occidental", "MST": "Hora estándar de Macao", "EST": "hora estándar oriental", "HNNOMX": "hora estándar del noroeste de México", "HNPMX": "hora estándar del Pacífico de México", "HEPMX": "hora de verano del Pacífico de México", "CHADT": "hora de verano de Chatham", "AST": "hora estándar del Atlántico", "ARST": "hora de verano de Argentina", "HKST": "hora de verano de Hong Kong"}, + } +} + +// Locale returns the current translators string locale +func (es *es_GT) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_GT' +func (es *es_GT) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_GT' +func (es *es_GT) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_GT' +func (es *es_GT) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_GT' +func (es *es_GT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_GT' +func (es *es_GT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_GT' +func (es *es_GT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_GT) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_GT) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_GT) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_GT) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_GT) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_GT) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_GT) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_GT) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_GT) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_GT) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_GT) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_GT) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_GT) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_GT) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_GT' and handles both Whole and Real numbers based on 'v' +func (es *es_GT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_GT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_GT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_GT' +func (es *es_GT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_GT' +// in accounting notation. +func (es *es_GT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_GT' +func (es *es_GT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_GT' +func (es *es_GT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_GT' +func (es *es_GT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_GT' +func (es *es_GT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_GT' +func (es *es_GT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_GT' +func (es *es_GT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_GT' +func (es *es_GT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_GT' +func (es *es_GT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_GT/es_GT_test.go b/vendor/github.com/go-playground/locales/es_GT/es_GT_test.go new file mode 100644 index 0000000000..605734d26c --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_GT/es_GT_test.go @@ -0,0 +1,1120 @@ +package es_GT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_GT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_HN/es_HN.go b/vendor/github.com/go-playground/locales/es_HN/es_HN.go new file mode 100644 index 0000000000..4b30b10085 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_HN/es_HN.go @@ -0,0 +1,581 @@ +package es_HN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_HN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_HN' locale +func New() locales.Translator { + return &es_HN{ + locale: "es_HN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "L", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"ACWDT": "hora de verano de Australia centroccidental", "VET": "hora de Venezuela", "MDT": "Hora de verano de Macao", "HNNOMX": "hora estándar del noroeste de México", "HNPMX": "hora estándar del Pacífico de México", "HNCU": "hora estándar de Cuba", "CHAST": "hora estándar de Chatham", "NZDT": "hora de verano de Nueva Zelanda", "JDT": "hora de verano de Japón", "AST": "hora estándar del Atlántico", "OEZ": "hora estándar de Europa oriental", "CLT": "hora estándar de Chile", "EAT": "hora de África oriental", "HKT": "hora estándar de Hong Kong", "GMT": "hora del meridiano de Greenwich", "ChST": "hora estándar de Chamorro", "WEZ": "hora estándar de Europa occidental", "ACWST": "hora estándar de Australia centroccidental", "LHDT": "hora de verano de Lord Howe", "AWST": "hora estándar de Australia occidental", "ECT": "hora de Ecuador", "NZST": "hora estándar de Nueva Zelanda", "HEOG": "hora de verano de Groenlandia occidental", "ADT": "hora de verano del Atlántico", "WAT": "hora estándar de África occidental", "LHST": "hora estándar de Lord Howe", "GFT": "hora de la Guayana Francesa", "HAT": "hora de verano de Terranova", "EDT": "hora de verano oriental", "CDT": "hora de verano central", "SRT": "hora de Surinam", "WIT": "hora de Indonesia oriental", "AWDT": "hora de verano de Australia occidental", "CHADT": "hora de verano de Chatham", "HAST": "hora estándar de Hawái-Aleutiano", "MESZ": "hora de verano de Europa central", "WARST": "hora de verano de Argentina occidental", "SAST": "hora de Sudáfrica", "COST": "hora de verano de Colombia", "MST": "Hora estándar de Macao", "ARST": "hora de verano de Argentina", "WITA": "hora de Indonesia central", "OESZ": "hora de verano de Europa oriental", "PDT": "hora de verano del Pacífico", "HADT": "hora de verano de Hawái-Aleutiano", "CAT": "hora de África central", "HNOG": "hora estándar de Groenlandia occidental", "TMT": "hora estándar de Turkmenistán", "TMST": "hora de verano de Turkmenistán", "HKST": "hora de verano de Hong Kong", "PST": "hora estándar del Pacífico", "ART": "hora estándar de Argentina", "AKST": "hora estándar de Alaska", "MEZ": "hora estándar de Europa central", "∅∅∅": "hora de verano de las Azores", "CST": "hora estándar central", "WART": "hora estándar de Argentina occidental", "HNEG": "hora estándar de Groenlandia oriental", "AEST": "hora estándar de Australia oriental", "AEDT": "hora de verano de Australia oriental", "HEPMX": "hora de verano del Pacífico de México", "ACST": "hora estándar de Australia central", "HENOMX": "hora de verano del noroeste de México", "WIB": "hora de Indonesia occidental", "HECU": "hora de verano de Cuba", "SGT": "hora de Singapur", "IST": "hora estándar de la India", "HNT": "hora estándar de Terranova", "UYT": "hora estándar de Uruguay", "UYST": "hora de verano de Uruguay", "HNPM": "hora estándar de San Pedro y Miquelón", "GYT": "hora de Guyana", "WAST": "hora de verano de África occidental", "EST": "hora estándar oriental", "COT": "hora estándar de Colombia", "BT": "hora de Bután", "HEPM": "hora de verano de San Pedro y Miquelón", "WESZ": "hora de verano de Europa occidental", "AKDT": "hora de verano de Alaska", "BOT": "hora de Bolivia", "MYT": "hora de Malasia", "CLST": "hora de verano de Chile", "ACDT": "hora de verano de Australia central", "HEEG": "hora de verano de Groenlandia oriental", "JST": "hora estándar de Japón"}, + } +} + +// Locale returns the current translators string locale +func (es *es_HN) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_HN' +func (es *es_HN) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_HN' +func (es *es_HN) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_HN' +func (es *es_HN) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_HN' +func (es *es_HN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_HN' +func (es *es_HN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_HN' +func (es *es_HN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_HN) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_HN) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_HN) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_HN) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_HN) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_HN) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_HN) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_HN) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_HN) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_HN) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_HN) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_HN) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_HN) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_HN) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_HN' and handles both Whole and Real numbers based on 'v' +func (es *es_HN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_HN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_HN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_HN' +func (es *es_HN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_HN' +// in accounting notation. +func (es *es_HN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_HN' +func (es *es_HN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_HN' +func (es *es_HN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_HN' +func (es *es_HN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_HN' +func (es *es_HN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_HN' +func (es *es_HN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_HN' +func (es *es_HN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_HN' +func (es *es_HN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_HN' +func (es *es_HN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_HN/es_HN_test.go b/vendor/github.com/go-playground/locales/es_HN/es_HN_test.go new file mode 100644 index 0000000000..2275be3bd8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_HN/es_HN_test.go @@ -0,0 +1,1120 @@ +package es_HN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_HN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_IC/es_IC.go b/vendor/github.com/go-playground/locales/es_IC/es_IC.go new file mode 100644 index 0000000000..177ab6bf0e --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_IC/es_IC.go @@ -0,0 +1,572 @@ +package es_IC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_IC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_IC' locale +func New() locales.Translator { + return &es_IC{ + locale: "es_IC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"PDT": "hora de verano del Pacífico", "IST": "hora estándar de la India", "WITA": "hora de Indonesia central", "HAST": "hora estándar de Hawái-Aleutiano", "NZDT": "hora de verano de Nueva Zelanda", "ACDT": "hora de verano de Australia central", "COT": "hora estándar de Colombia", "BT": "hora de Bután", "ART": "hora estándar de Argentina", "HKT": "hora estándar de Hong Kong", "WART": "hora estándar de Argentina occidental", "AST": "hora estándar del Atlántico", "VET": "hora de Venezuela", "HECU": "hora de verano de Cuba", "SGT": "hora de Singapur", "PST": "hora estándar del Pacífico", "AEDT": "hora de verano de Australia oriental", "UYST": "hora de verano de Uruguay", "GYT": "hora de Guyana", "CST": "hora estándar central", "WIT": "hora de Indonesia oriental", "WAT": "hora estándar de África occidental", "WAST": "hora de verano de África occidental", "HNEG": "hora estándar de Groenlandia oriental", "CHAST": "hora estándar de Chatham", "HNCU": "hora estándar de Cuba", "WIB": "hora de Indonesia occidental", "ECT": "hora de Ecuador", "ACWDT": "hora de verano de Australia centroccidental", "JST": "hora estándar de Japón", "HNNOMX": "hora estándar del noroeste de México", "HAT": "hora de verano de Terranova", "∅∅∅": "hora de verano de Perú", "AKDT": "hora de verano de Alaska", "HNPM": "hora estándar de San Pedro y Miquelón", "EAT": "hora de África oriental", "ACST": "hora estándar de Australia central", "CDT": "hora de verano central", "AWST": "hora estándar de Australia occidental", "OESZ": "hora de verano de Europa oriental", "TMT": "hora estándar de Turkmenistán", "HKST": "hora de verano de Hong Kong", "LHST": "hora estándar de Lord Howe", "HEPMX": "hora de verano del Pacífico de México", "HNOG": "hora estándar de Groenlandia occidental", "ADT": "hora de verano del Atlántico", "MST": "Hora estándar de Macao", "SAST": "hora de Sudáfrica", "ACWST": "hora estándar de Australia centroccidental", "MEZ": "hora estándar de Europa central", "HEOG": "hora de verano de Groenlandia occidental", "HENOMX": "hora de verano del noroeste de México", "UYT": "hora estándar de Uruguay", "HNPMX": "hora estándar del Pacífico de México", "NZST": "hora estándar de Nueva Zelanda", "JDT": "hora de verano de Japón", "CLST": "hora de verano de Chile", "MDT": "Hora de verano de Macao", "COST": "hora de verano de Colombia", "EST": "hora estándar oriental", "HNT": "hora estándar de Terranova", "AKST": "hora estándar de Alaska", "HEPM": "hora de verano de San Pedro y Miquelón", "CHADT": "hora de verano de Chatham", "WEZ": "hora estándar de Europa occidental", "WESZ": "hora de verano de Europa occidental", "TMST": "hora de verano de Turkmenistán", "HADT": "hora de verano de Hawái-Aleutiano", "EDT": "hora de verano oriental", "ChST": "hora estándar de Chamorro", "AWDT": "hora de verano de Australia occidental", "CLT": "hora estándar de Chile", "OEZ": "hora estándar de Europa oriental", "GMT": "hora del meridiano de Greenwich", "GFT": "hora de la Guayana Francesa", "AEST": "hora estándar de Australia oriental", "BOT": "hora de Bolivia", "CAT": "hora de África central", "MESZ": "hora de verano de Europa central", "WARST": "hora de verano de Argentina occidental", "MYT": "hora de Malasia", "ARST": "hora de verano de Argentina", "HEEG": "hora de verano de Groenlandia oriental", "LHDT": "hora de verano de Lord Howe", "SRT": "hora de Surinam"}, + } +} + +// Locale returns the current translators string locale +func (es *es_IC) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_IC' +func (es *es_IC) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_IC' +func (es *es_IC) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_IC' +func (es *es_IC) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_IC' +func (es *es_IC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_IC' +func (es *es_IC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_IC' +func (es *es_IC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_IC) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_IC) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_IC) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_IC) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_IC) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_IC) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_IC) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_IC) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_IC) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_IC) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_IC) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_IC) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_IC) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_IC) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_IC' and handles both Whole and Real numbers based on 'v' +func (es *es_IC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_IC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_IC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_IC' +func (es *es_IC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_IC' +// in accounting notation. +func (es *es_IC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_IC' +func (es *es_IC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_IC' +func (es *es_IC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_IC' +func (es *es_IC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_IC' +func (es *es_IC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_IC' +func (es *es_IC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_IC' +func (es *es_IC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_IC' +func (es *es_IC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_IC' +func (es *es_IC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_IC/es_IC_test.go b/vendor/github.com/go-playground/locales/es_IC/es_IC_test.go new file mode 100644 index 0000000000..816901472b --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_IC/es_IC_test.go @@ -0,0 +1,1120 @@ +package es_IC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_IC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_MX/es_MX.go b/vendor/github.com/go-playground/locales/es_MX/es_MX.go new file mode 100644 index 0000000000..5a7433e2f6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_MX/es_MX.go @@ -0,0 +1,588 @@ +package es_MX + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_MX struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_MX' locale +func New() locales.Translator { + return &es_MX{ + locale: "es_MX", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "Af", "ALK", "ALL", "AMD", "Naf", "Kz", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "$a", "ATS", "AU$", "Afl.", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "Br", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "RD$", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "lei", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TL", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene", "feb", "mar", "abr", "may", "jun", "jul", "ago", "sep", "oct", "nov", "dic"}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"do", "lu", "ma", "mi", "ju", "vi", "sá"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"JST": "hora estándar de Japón", "ACST": "Hora estándar de Australia Central", "ECT": "Hora de Ecuador", "PDT": "hora de verano del Pacífico", "CAT": "Hora de África Central", "OESZ": "Hora de verano de Europa del Este", "ART": "hora estándar de Argentina", "∅∅∅": "Hora de verano de las Azores", "MEZ": "Hora estándar de Europa Central", "WESZ": "Hora de verano de Europa Occidental", "CHAST": "Hora estándar de Chatham", "HKST": "hora de verano de Hong Kong", "UYT": "Hora estándar de Uruguay", "WIB": "hora de Indonesia occidental", "CDT": "hora de verano central", "WIT": "hora de Indonesia oriental", "HAT": "hora de verano de Terranova", "ACWST": "Hora estándar de Australia Centroccidental", "VET": "Hora de Venezuela", "GMT": "Hora del meridiano de Greenwich", "CLT": "hora estándar de Chile", "HEOG": "hora de verano de Groenlandia occidental", "HNPMX": "hora estándar del Pacífico de México", "AWST": "Hora estándar de Australia Occidental", "SGT": "hora de Singapur", "WAT": "Hora estándar de África Occidental", "HENOMX": "hora de verano del noroeste de México", "AKDT": "hora de verano de Alaska", "ChST": "Hora estándar de Chamorro", "UYST": "Hora de verano de Uruguay", "NZST": "Hora estándar de Nueva Zelanda", "JDT": "hora de verano de Japón", "WITA": "hora de Indonesia central", "HEPMX": "hora de verano del Pacífico de México", "HECU": "hora de verano de Cuba", "CHADT": "Hora de verano de Chatham", "AEST": "Hora estándar de Australia Oriental", "AKST": "hora estándar de Alaska", "ADT": "hora de verano del Atlántico", "ARST": "hora de verano de Argentina", "HKT": "hora estándar de Hong Kong", "WARST": "hora de verano de Argentina occidental", "CLST": "hora de verano de Chile", "COT": "Hora estándar de Colombia", "HNEG": "hora estándar de Groenlandia oriental", "HEEG": "hora de verano de Groenlandia oriental", "SAST": "Hora de Sudáfrica", "HADT": "hora de verano de Hawái-Aleutiano", "IST": "hora estándar de la India", "MDT": "Hora de verano de Macao", "COST": "Hora de verano de Colombia", "BT": "hora de Bután", "HAST": "hora estándar de Hawái-Aleutiano", "MESZ": "Hora de verano de Europa Central", "HNOG": "hora estándar de Groenlandia occidental", "BOT": "hora de Bolivia", "TMT": "Hora estándar de Turkmenistán", "EDT": "hora de verano oriental", "NZDT": "Hora de verano de Nueva Zelanda", "MST": "Hora estándar de Macao", "EST": "hora estándar oriental", "HNNOMX": "hora estándar del noroeste de México", "ACDT": "Hora de verano de Australia Central", "SRT": "Hora de Surinam", "LHST": "Hora estándar de Lord Howe", "EAT": "Hora de África Oriental", "HNT": "hora estándar de Terranova", "AEDT": "Hora de verano de Australia Oriental", "AST": "hora estándar del Atlántico", "OEZ": "Hora estándar de Europa del Este", "HEPM": "hora de verano de San Pedro y Miquelón", "GYT": "Hora de Guyana", "AWDT": "Hora de verano de Australia Occidental", "PST": "hora estándar del Pacífico", "ACWDT": "Hora de verano de Australia Centroccidental", "WART": "hora estándar de Argentina occidental", "WAST": "Hora de verano de África Occidental", "GFT": "Hora de la Guayana Francesa", "LHDT": "Hora de verano de Lord Howe", "HNCU": "hora estándar de Cuba", "CST": "hora estándar central", "TMST": "Hora de verano de Turkmenistán", "HNPM": "hora estándar de San Pedro y Miquelón", "WEZ": "Hora estándar de Europa Occidental", "MYT": "hora de Malasia"}, + } +} + +// Locale returns the current translators string locale +func (es *es_MX) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_MX' +func (es *es_MX) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_MX' +func (es *es_MX) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_MX' +func (es *es_MX) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_MX' +func (es *es_MX) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_MX' +func (es *es_MX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_MX' +func (es *es_MX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_MX) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_MX) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_MX) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_MX) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_MX) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_MX) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_MX) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_MX) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_MX) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_MX) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_MX) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_MX) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_MX) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_MX) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_MX' and handles both Whole and Real numbers based on 'v' +func (es *es_MX) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_MX' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_MX) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_MX' +func (es *es_MX) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_MX' +// in accounting notation. +func (es *es_MX) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_MX' +func (es *es_MX) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_MX' +func (es *es_MX) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_MX' +func (es *es_MX) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_MX' +func (es *es_MX) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_MX' +func (es *es_MX) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_MX' +func (es *es_MX) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_MX' +func (es *es_MX) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_MX' +func (es *es_MX) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_MX/es_MX_test.go b/vendor/github.com/go-playground/locales/es_MX/es_MX_test.go new file mode 100644 index 0000000000..b0616f8c31 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_MX/es_MX_test.go @@ -0,0 +1,1120 @@ +package es_MX + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_MX" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_NI/es_NI.go b/vendor/github.com/go-playground/locales/es_NI/es_NI.go new file mode 100644 index 0000000000..dc5cdd48c8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_NI/es_NI.go @@ -0,0 +1,572 @@ +package es_NI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_NI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_NI' locale +func New() locales.Translator { + return &es_NI{ + locale: "es_NI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "C$", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"UYT": "hora estándar de Uruguay", "GYT": "hora de Guyana", "CAT": "hora de África central", "ACWST": "hora estándar de Australia centroccidental", "VET": "hora de Venezuela", "MST": "hora estándar de las Montañas", "WIT": "hora de Indonesia oriental", "JDT": "hora de verano de Japón", "WEZ": "hora estándar de Europa occidental", "ARST": "hora de verano de Argentina", "BT": "hora de Bután", "HEEG": "hora de verano de Groenlandia oriental", "AEDT": "hora de verano de Australia oriental", "MDT": "hora de verano de las Montañas", "WIB": "hora de Indonesia occidental", "EDT": "hora de verano oriental", "HECU": "hora de verano de Cuba", "CHADT": "hora de verano de Chatham", "WESZ": "hora de verano de Europa occidental", "TMT": "hora estándar de Turkmenistán", "WAST": "hora de verano de África occidental", "SRT": "hora de Surinam", "AWDT": "hora de verano de Australia occidental", "ACWDT": "hora de verano de Australia centroccidental", "HKST": "hora de verano de Hong Kong", "HNPM": "hora estándar de San Pedro y Miquelón", "HEPM": "hora de verano de San Pedro y Miquelón", "HAST": "hora estándar de Hawái-Aleutiano", "MYT": "hora de Malasia", "WARST": "hora de verano de Argentina occidental", "TMST": "hora de verano de Turkmenistán", "COT": "hora estándar de Colombia", "SGT": "hora de Singapur", "HADT": "hora de verano de Hawái-Aleutiano", "IST": "hora estándar de la India", "ADT": "hora de verano del Atlántico", "GFT": "hora de la Guayana Francesa", "LHDT": "hora de verano de Lord Howe", "CHAST": "hora estándar de Chatham", "MESZ": "hora de verano de Europa central", "HNNOMX": "hora estándar del noroeste de México", "PST": "hora estándar del Pacífico", "MEZ": "hora estándar de Europa central", "WART": "hora estándar de Argentina occidental", "HKT": "hora estándar de Hong Kong", "OESZ": "hora de verano de Europa oriental", "ART": "hora estándar de Argentina", "WAT": "hora estándar de África occidental", "HNT": "hora estándar de Terranova", "HNPMX": "hora estándar del Pacífico de México", "HEPMX": "hora de verano del Pacífico de México", "CDT": "hora de verano central", "AWST": "hora estándar de Australia occidental", "ACDT": "hora de verano de Australia central", "WITA": "hora de Indonesia central", "NZST": "hora estándar de Nueva Zelanda", "CLT": "hora estándar de Chile", "GMT": "hora del meridiano de Greenwich", "COST": "hora de verano de Colombia", "HENOMX": "hora de verano del noroeste de México", "HAT": "hora de verano de Terranova", "∅∅∅": "Hora de verano de Acre", "HNCU": "hora estándar de Cuba", "EST": "hora estándar oriental", "PDT": "hora de verano del Pacífico", "ECT": "hora de Ecuador", "CLST": "hora de verano de Chile", "HNEG": "hora estándar de Groenlandia oriental", "AKST": "hora estándar de Alaska", "AKDT": "hora de verano de Alaska", "EAT": "hora de África oriental", "CST": "hora estándar central", "HNOG": "hora estándar de Groenlandia occidental", "HEOG": "hora de verano de Groenlandia occidental", "AST": "hora estándar del Atlántico", "OEZ": "hora estándar de Europa oriental", "JST": "hora estándar de Japón", "ACST": "hora estándar de Australia central", "UYST": "hora de verano de Uruguay", "LHST": "hora estándar de Lord Howe", "BOT": "hora de Bolivia", "NZDT": "hora de verano de Nueva Zelanda", "AEST": "hora estándar de Australia oriental", "ChST": "hora estándar de Chamorro", "SAST": "hora de Sudáfrica"}, + } +} + +// Locale returns the current translators string locale +func (es *es_NI) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_NI' +func (es *es_NI) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_NI' +func (es *es_NI) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_NI' +func (es *es_NI) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_NI' +func (es *es_NI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_NI' +func (es *es_NI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_NI' +func (es *es_NI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_NI) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_NI) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_NI) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_NI) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_NI) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_NI) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_NI) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_NI) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_NI) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_NI) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_NI) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_NI) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_NI) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_NI) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_NI' and handles both Whole and Real numbers based on 'v' +func (es *es_NI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_NI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_NI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_NI' +func (es *es_NI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_NI' +// in accounting notation. +func (es *es_NI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_NI' +func (es *es_NI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_NI' +func (es *es_NI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_NI' +func (es *es_NI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_NI' +func (es *es_NI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_NI' +func (es *es_NI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_NI' +func (es *es_NI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_NI' +func (es *es_NI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_NI' +func (es *es_NI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_NI/es_NI_test.go b/vendor/github.com/go-playground/locales/es_NI/es_NI_test.go new file mode 100644 index 0000000000..23f9f96287 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_NI/es_NI_test.go @@ -0,0 +1,1120 @@ +package es_NI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_NI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_PA/es_PA.go b/vendor/github.com/go-playground/locales/es_PA/es_PA.go new file mode 100644 index 0000000000..732ca8c0ba --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PA/es_PA.go @@ -0,0 +1,644 @@ +package es_PA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_PA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_PA' locale +func New() locales.Translator { + return &es_PA{ + locale: "es_PA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "B/.", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"HADT": "hora de verano de Hawái-Aleutiano", "CLST": "hora de verano de Chile", "WAT": "hora estándar de África occidental", "EST": "hora estándar oriental", "UYT": "hora estándar de Uruguay", "CHADT": "hora de verano de Chatham", "PST": "hora estándar del Pacífico", "HEOG": "hora de verano de Groenlandia occidental", "ART": "hora estándar de Argentina", "SAST": "hora de Sudáfrica", "ACWST": "hora estándar de Australia centroccidental", "IST": "hora estándar de la India", "HENOMX": "hora de verano del noroeste de México", "HNPMX": "hora estándar del Pacífico de México", "CHAST": "hora estándar de Chatham", "HNNOMX": "hora estándar del noroeste de México", "AEST": "hora estándar de Australia oriental", "HNPM": "hora estándar de San Pedro y Miquelón", "∅∅∅": "hora de verano de Brasilia", "JST": "hora estándar de Japón", "MDT": "Hora de verano de Macao", "LHDT": "hora de verano de Lord Howe", "TMST": "hora de verano de Turkmenistán", "AEDT": "hora de verano de Australia oriental", "HAST": "hora estándar de Hawái-Aleutiano", "ECT": "hora de Ecuador", "JDT": "hora de verano de Japón", "MEZ": "hora estándar de Europa central", "COST": "hora de verano de Colombia", "HNT": "hora estándar de Terranova", "WITA": "hora de Indonesia central", "WIB": "hora de Indonesia occidental", "SGT": "hora de Singapur", "MESZ": "hora de verano de Europa central", "WEZ": "hora estándar de Europa occidental", "ADT": "hora de verano del Atlántico", "ARST": "hora de verano de Argentina", "ChST": "hora estándar de Chamorro", "VET": "hora de Venezuela", "WARST": "hora de verano de Argentina occidental", "OESZ": "hora de verano de Europa oriental", "MST": "Hora estándar de Macao", "HNEG": "hora estándar de Groenlandia oriental", "LHST": "hora estándar de Lord Howe", "NZST": "hora estándar de Nueva Zelanda", "AST": "hora estándar del Atlántico", "HKT": "hora estándar de Hong Kong", "HKST": "hora de verano de Hong Kong", "CDT": "hora de verano central", "CLT": "hora estándar de Chile", "WAST": "hora de verano de África occidental", "BT": "hora de Bután", "EAT": "hora de África oriental", "HECU": "hora de verano de Cuba", "AWST": "hora estándar de Australia occidental", "ACWDT": "hora de verano de Australia centroccidental", "TMT": "hora estándar de Turkmenistán", "ACDT": "hora de verano de Australia central", "CAT": "hora de África central", "GMT": "hora del meridiano de Greenwich", "HEPMX": "hora de verano del Pacífico de México", "HAT": "hora de verano de Terranova", "GFT": "hora de la Guayana Francesa", "UYST": "hora de verano de Uruguay", "GYT": "hora de Guyana", "CST": "hora estándar central", "AWDT": "hora de verano de Australia occidental", "EDT": "hora de verano oriental", "HEEG": "hora de verano de Groenlandia oriental", "WIT": "hora de Indonesia oriental", "WESZ": "hora de verano de Europa occidental", "SRT": "hora de Surinam", "NZDT": "hora de verano de Nueva Zelanda", "WART": "hora estándar de Argentina occidental", "OEZ": "hora estándar de Europa oriental", "HNCU": "hora estándar de Cuba", "ACST": "hora estándar de Australia central", "COT": "hora estándar de Colombia", "AKST": "hora estándar de Alaska", "AKDT": "hora de verano de Alaska", "BOT": "hora de Bolivia", "PDT": "hora de verano del Pacífico", "MYT": "hora de Malasia", "HNOG": "hora estándar de Groenlandia occidental", "HEPM": "hora de verano de San Pedro y Miquelón"}, + } +} + +// Locale returns the current translators string locale +func (es *es_PA) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_PA' +func (es *es_PA) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_PA' +func (es *es_PA) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_PA' +func (es *es_PA) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_PA' +func (es *es_PA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_PA' +func (es *es_PA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_PA' +func (es *es_PA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_PA) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_PA) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_PA) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_PA) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_PA) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_PA) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_PA) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_PA) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_PA) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_PA) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_PA) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_PA) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_PA) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_PA) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_PA' and handles both Whole and Real numbers based on 'v' +func (es *es_PA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_PA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_PA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_PA' +func (es *es_PA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_PA' +// in accounting notation. +func (es *es_PA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_PA' +func (es *es_PA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_PA' +func (es *es_PA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_PA' +func (es *es_PA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_PA' +func (es *es_PA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_PA' +func (es *es_PA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_PA' +func (es *es_PA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_PA' +func (es *es_PA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_PA' +func (es *es_PA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_PA/es_PA_test.go b/vendor/github.com/go-playground/locales/es_PA/es_PA_test.go new file mode 100644 index 0000000000..448d921798 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PA/es_PA_test.go @@ -0,0 +1,1120 @@ +package es_PA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_PA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_PE/es_PE.go b/vendor/github.com/go-playground/locales/es_PE/es_PE.go new file mode 100644 index 0000000000..aeb070edef --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PE/es_PE.go @@ -0,0 +1,578 @@ +package es_PE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_PE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_PE' locale +func New() locales.Translator { + return &es_PE{ + locale: "es_PE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "S/", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "set.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "setiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"CST": "hora estándar central", "WIT": "hora de Indonesia oriental", "CHAST": "hora estándar de Chatham", "HEOG": "hora de verano de Groenlandia occidental", "HKT": "hora estándar de Hong Kong", "HNPMX": "hora estándar del Pacífico de México", "HNEG": "hora estándar de Groenlandia oriental", "HEEG": "hora de verano de Groenlandia oriental", "LHDT": "hora de verano de Lord Howe", "BOT": "hora de Bolivia", "MYT": "hora de Malasia", "ARST": "hora de verano de Argentina", "WAT": "hora estándar de África occidental", "EAT": "hora de África oriental", "AST": "hora estándar del Atlántico", "ADT": "hora de verano del Atlántico", "OEZ": "hora estándar de Europa oriental", "WEZ": "hora estándar de Europa occidental", "WESZ": "hora de verano de Europa occidental", "CLT": "hora estándar de Chile", "EDT": "hora de verano oriental", "IST": "hora estándar de la India", "BT": "hora de Bután", "CHADT": "hora de verano de Chatham", "HENOMX": "hora de verano del noroeste de México", "HNT": "hora estándar de Terranova", "AEDT": "hora de verano de Australia oriental", "SRT": "hora de Surinam", "ACWDT": "hora de verano de Australia centroccidental", "MESZ": "hora de verano de Europa central", "WITA": "hora de Indonesia central", "CAT": "hora de África central", "SGT": "hora de Singapur", "NZDT": "hora de verano de Nueva Zelanda", "JDT": "hora de verano de Japón", "COT": "hora estándar de Colombia", "CDT": "hora de verano central", "WIB": "hora de Indonesia occidental", "NZST": "hora estándar de Nueva Zelanda", "MST": "Hora estándar de Macao", "MDT": "Hora de verano de Macao", "EST": "hora estándar oriental", "GFT": "hora de la Guayana Francesa", "∅∅∅": "hora de verano de las Azores", "AWST": "hora estándar de Australia occidental", "GMT": "hora del meridiano de Greenwich", "ACST": "hora estándar de Australia central", "HNNOMX": "hora estándar del noroeste de México", "AKST": "hora estándar de Alaska", "SAST": "hora de Sudáfrica", "JST": "hora estándar de Japón", "AKDT": "hora de verano de Alaska", "GYT": "hora de Guyana", "HNCU": "hora estándar de Cuba", "ECT": "hora de Ecuador", "VET": "hora de Venezuela", "CLST": "hora de verano de Chile", "HKST": "hora de verano de Hong Kong", "HEPM": "hora de verano de San Pedro y Miquelón", "LHST": "hora estándar de Lord Howe", "TMT": "hora estándar de Turkmenistán", "ACDT": "hora de verano de Australia central", "HAT": "hora de verano de Terranova", "UYST": "hora de verano de Uruguay", "HAST": "hora estándar de Hawái-Aleutiano", "OESZ": "hora de verano de Europa oriental", "PST": "hora estándar del Pacífico", "MEZ": "hora estándar de Europa central", "HNOG": "hora estándar de Groenlandia occidental", "ART": "hora estándar de Argentina", "HNPM": "hora estándar de San Pedro y Miquelón", "HECU": "hora de verano de Cuba", "AWDT": "hora de verano de Australia occidental", "PDT": "hora de verano del Pacífico", "HADT": "hora de verano de Hawái-Aleutiano", "WART": "hora estándar de Argentina occidental", "WARST": "hora de verano de Argentina occidental", "TMST": "hora de verano de Turkmenistán", "WAST": "hora de verano de África occidental", "HEPMX": "hora de verano del Pacífico de México", "COST": "hora de verano de Colombia", "AEST": "hora estándar de Australia oriental", "ChST": "hora estándar de Chamorro", "UYT": "hora estándar de Uruguay", "ACWST": "hora estándar de Australia centroccidental"}, + } +} + +// Locale returns the current translators string locale +func (es *es_PE) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_PE' +func (es *es_PE) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_PE' +func (es *es_PE) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_PE' +func (es *es_PE) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_PE' +func (es *es_PE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_PE' +func (es *es_PE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_PE' +func (es *es_PE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_PE) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_PE) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_PE) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_PE) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_PE) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_PE) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_PE) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_PE) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_PE) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_PE) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_PE) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_PE) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_PE) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_PE) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_PE' and handles both Whole and Real numbers based on 'v' +func (es *es_PE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_PE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_PE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_PE' +func (es *es_PE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_PE' +// in accounting notation. +func (es *es_PE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_PE' +func (es *es_PE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_PE' +func (es *es_PE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_PE' +func (es *es_PE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_PE' +func (es *es_PE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_PE' +func (es *es_PE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_PE' +func (es *es_PE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_PE' +func (es *es_PE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_PE' +func (es *es_PE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_PE/es_PE_test.go b/vendor/github.com/go-playground/locales/es_PE/es_PE_test.go new file mode 100644 index 0000000000..9e17cb6154 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PE/es_PE_test.go @@ -0,0 +1,1120 @@ +package es_PE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_PE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_PH/es_PH.go b/vendor/github.com/go-playground/locales/es_PH/es_PH.go new file mode 100644 index 0000000000..a7c64ce11f --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PH/es_PH.go @@ -0,0 +1,624 @@ +package es_PH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_PH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_PH' locale +func New() locales.Translator { + return &es_PH{ + locale: "es_PH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "₱", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"AWST": "hora estándar de Australia occidental", "AWDT": "hora de verano de Australia occidental", "HADT": "hora de verano de Hawái-Aleutiano", "JST": "hora estándar de Japón", "WART": "hora estándar de Argentina occidental", "AEDT": "hora de verano de Australia oriental", "ChST": "hora estándar de Chamorro", "MEZ": "hora estándar de Europa central", "AEST": "hora estándar de Australia oriental", "JDT": "hora de verano de Japón", "HKST": "hora de verano de Hong Kong", "ECT": "hora de Ecuador", "HEPMX": "hora de verano del Pacífico de México", "LHST": "hora estándar de Lord Howe", "NZST": "hora estándar de Nueva Zelanda", "NZDT": "hora de verano de Nueva Zelanda", "CLST": "hora de verano de Chile", "EST": "hora estándar oriental", "HEEG": "hora de verano de Groenlandia oriental", "HAT": "hora de verano de Terranova", "SRT": "hora de Surinam", "CHADT": "hora de verano de Chatham", "MESZ": "hora de verano de Europa central", "VET": "hora de Venezuela", "HNOG": "hora estándar de Groenlandia occidental", "AKST": "hora estándar de Alaska", "WAT": "hora estándar de África occidental", "HNT": "hora estándar de Terranova", "UYT": "hora estándar de Uruguay", "GYT": "hora de Guyana", "GFT": "hora de la Guayana Francesa", "EAT": "hora de África oriental", "WEZ": "hora estándar de Europa occidental", "CLT": "hora estándar de Chile", "ADT": "hora de verano del Atlántico", "HKT": "hora estándar de Hong Kong", "TMT": "hora estándar de Turkmenistán", "ACDT": "hora de verano de Australia central", "BT": "hora de Bután", "PST": "hora estándar del Pacífico", "ARST": "hora de verano de Argentina", "CDT": "hora de verano central", "HNEG": "hora estándar de Groenlandia oriental", "HNPM": "hora estándar de San Pedro y Miquelón", "HEPM": "hora de verano de San Pedro y Miquelón", "BOT": "hora de Bolivia", "GMT": "hora del meridiano de Greenwich", "OEZ": "hora estándar de Europa oriental", "WAST": "hora de verano de África occidental", "EDT": "hora de verano oriental", "WITA": "hora de Indonesia central", "SGT": "hora de Singapur", "MYT": "hora de Malasia", "TMST": "hora de verano de Turkmenistán", "ART": "hora estándar de Argentina", "COST": "hora de verano de Colombia", "LHDT": "hora de verano de Lord Howe", "WIT": "hora de Indonesia oriental", "WIB": "hora de Indonesia occidental", "PDT": "hora de verano del Pacífico", "ACWST": "hora estándar de Australia centroccidental", "CAT": "hora de África central", "HEOG": "hora de verano de Groenlandia occidental", "HNNOMX": "hora estándar del noroeste de México", "HENOMX": "hora de verano del noroeste de México", "ACST": "hora estándar de Australia central", "CHAST": "hora estándar de Chatham", "ACWDT": "hora de verano de Australia centroccidental", "IST": "hora estándar de la India", "MST": "Hora estándar de Macao", "MDT": "Hora de verano de Macao", "UYST": "hora de verano de Uruguay", "SAST": "hora de Sudáfrica", "CST": "hora estándar central", "HAST": "hora estándar de Hawái-Aleutiano", "WARST": "hora de verano de Argentina occidental", "AST": "hora estándar del Atlántico", "COT": "hora estándar de Colombia", "HNCU": "hora estándar de Cuba", "HNPMX": "hora estándar del Pacífico de México", "HECU": "hora de verano de Cuba", "WESZ": "hora de verano de Europa occidental", "OESZ": "hora de verano de Europa oriental", "∅∅∅": "Hora de verano de Acre", "AKDT": "hora de verano de Alaska"}, + } +} + +// Locale returns the current translators string locale +func (es *es_PH) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_PH' +func (es *es_PH) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_PH' +func (es *es_PH) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_PH' +func (es *es_PH) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_PH' +func (es *es_PH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_PH' +func (es *es_PH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_PH' +func (es *es_PH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_PH) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_PH) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_PH) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_PH) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_PH) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_PH) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_PH) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_PH) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_PH) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_PH) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_PH) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_PH) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_PH) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_PH) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_PH' and handles both Whole and Real numbers based on 'v' +func (es *es_PH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_PH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_PH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_PH' +func (es *es_PH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_PH' +// in accounting notation. +func (es *es_PH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_PH' +func (es *es_PH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_PH' +func (es *es_PH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_PH' +func (es *es_PH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_PH' +func (es *es_PH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_PH' +func (es *es_PH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_PH' +func (es *es_PH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_PH' +func (es *es_PH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_PH' +func (es *es_PH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_PH/es_PH_test.go b/vendor/github.com/go-playground/locales/es_PH/es_PH_test.go new file mode 100644 index 0000000000..29a9c545b5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PH/es_PH_test.go @@ -0,0 +1,1120 @@ +package es_PH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_PH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_PR/es_PR.go b/vendor/github.com/go-playground/locales/es_PR/es_PR.go new file mode 100644 index 0000000000..630de9ba84 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PR/es_PR.go @@ -0,0 +1,644 @@ +package es_PR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_PR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_PR' locale +func New() locales.Translator { + return &es_PR{ + locale: "es_PR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"WITA": "hora de Indonesia central", "CST": "hora estándar central", "CHAST": "hora estándar de Chatham", "NZST": "hora estándar de Nueva Zelanda", "NZDT": "hora de verano de Nueva Zelanda", "OESZ": "hora de verano de Europa oriental", "CLST": "hora de verano de Chile", "GYT": "hora de Guyana", "CAT": "hora de África central", "TMT": "hora estándar de Turkmenistán", "COT": "hora estándar de Colombia", "HEEG": "hora de verano de Groenlandia oriental", "ARST": "hora de verano de Argentina", "HEPM": "hora de verano de San Pedro y Miquelón", "ECT": "hora de Ecuador", "JDT": "hora de verano de Japón", "GMT": "hora del meridiano de Greenwich", "WARST": "hora de verano de Argentina occidental", "HNOG": "hora estándar de Groenlandia occidental", "∅∅∅": "hora de verano del Amazonas", "ADT": "hora de verano del Atlántico", "EAT": "hora de África oriental", "BOT": "hora de Bolivia", "HNCU": "hora estándar de Cuba", "WIB": "hora de Indonesia occidental", "HAST": "hora estándar de Hawái-Aleutiano", "WESZ": "hora de verano de Europa occidental", "HNPM": "hora estándar de San Pedro y Miquelón", "LHST": "hora estándar de Lord Howe", "SRT": "hora de Surinam", "UYST": "hora de verano de Uruguay", "HKT": "hora estándar de Hong Kong", "WAT": "hora estándar de África occidental", "ACST": "hora estándar de Australia central", "BT": "hora de Bután", "MEZ": "hora estándar de Europa central", "GFT": "hora de la Guayana Francesa", "CDT": "hora de verano central", "WEZ": "hora estándar de Europa occidental", "AEST": "hora estándar de Australia oriental", "AWDT": "hora de verano de Australia occidental", "MST": "Hora estándar de Macao", "UYT": "hora estándar de Uruguay", "ChST": "hora estándar de Chamorro", "HECU": "hora de verano de Cuba", "IST": "hora estándar de la India", "WART": "hora estándar de Argentina occidental", "HEOG": "hora de verano de Groenlandia occidental", "SAST": "hora de Sudáfrica", "TMST": "hora de verano de Turkmenistán", "HAT": "hora de verano de Terranova", "AKST": "hora estándar de Alaska", "HEPMX": "hora de verano del Pacífico de México", "MDT": "Hora de verano de Macao", "HENOMX": "hora de verano del noroeste de México", "AKDT": "hora de verano de Alaska", "WIT": "hora de Indonesia oriental", "SGT": "hora de Singapur", "JST": "hora estándar de Japón", "ART": "hora estándar de Argentina", "EST": "hora estándar oriental", "ACDT": "hora de verano de Australia central", "PDT": "hora de verano del Pacífico", "HADT": "hora de verano de Hawái-Aleutiano", "MESZ": "hora de verano de Europa central", "WAST": "hora de verano de África occidental", "HNPMX": "hora estándar del Pacífico de México", "CHADT": "hora de verano de Chatham", "AWST": "hora estándar de Australia occidental", "ACWST": "hora estándar de Australia centroccidental", "VET": "hora de Venezuela", "EDT": "hora de verano oriental", "COST": "hora de verano de Colombia", "AST": "hora estándar del Atlántico", "HKST": "hora de verano de Hong Kong", "HNNOMX": "hora estándar del noroeste de México", "HNT": "hora estándar de Terranova", "ACWDT": "hora de verano de Australia centroccidental", "OEZ": "hora estándar de Europa oriental", "MYT": "hora de Malasia", "CLT": "hora estándar de Chile", "HNEG": "hora estándar de Groenlandia oriental", "AEDT": "hora de verano de Australia oriental", "LHDT": "hora de verano de Lord Howe", "PST": "hora estándar del Pacífico"}, + } +} + +// Locale returns the current translators string locale +func (es *es_PR) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_PR' +func (es *es_PR) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_PR' +func (es *es_PR) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_PR' +func (es *es_PR) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_PR' +func (es *es_PR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_PR' +func (es *es_PR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_PR' +func (es *es_PR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_PR) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_PR) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_PR) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_PR) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_PR) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_PR) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_PR) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_PR) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_PR) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_PR) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_PR) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_PR) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_PR) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_PR) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_PR' and handles both Whole and Real numbers based on 'v' +func (es *es_PR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_PR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_PR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_PR' +func (es *es_PR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_PR' +// in accounting notation. +func (es *es_PR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_PR' +func (es *es_PR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_PR' +func (es *es_PR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_PR' +func (es *es_PR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_PR' +func (es *es_PR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_PR' +func (es *es_PR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_PR' +func (es *es_PR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_PR' +func (es *es_PR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_PR' +func (es *es_PR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_PR/es_PR_test.go b/vendor/github.com/go-playground/locales/es_PR/es_PR_test.go new file mode 100644 index 0000000000..f26815181c --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PR/es_PR_test.go @@ -0,0 +1,1120 @@ +package es_PR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_PR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_PY/es_PY.go b/vendor/github.com/go-playground/locales/es_PY/es_PY.go new file mode 100644 index 0000000000..eb21f4421d --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PY/es_PY.go @@ -0,0 +1,585 @@ +package es_PY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_PY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_PY' locale +func New() locales.Translator { + return &es_PY{ + locale: "es_PY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "Gs.", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"do", "lu", "ma", "mi", "ju", "vi", "sa"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"MEZ": "hora estándar de Europa central", "VET": "hora de Venezuela", "EST": "hora estándar oriental", "CST": "hora estándar central", "WARST": "hora de verano de Argentina occidental", "TMT": "hora estándar de Turkmenistán", "ARST": "hora de verano de Argentina", "ACST": "hora estándar de Australia central", "LHST": "hora estándar de Lord Howe", "EAT": "hora de África oriental", "WAST": "hora de verano de África occidental", "HEEG": "hora de verano de Groenlandia oriental", "AKST": "hora estándar de Alaska", "CDT": "hora de verano central", "WIT": "hora de Indonesia oriental", "HKST": "hora de verano de Hong Kong", "ChST": "hora estándar de Chamorro", "PST": "hora estándar del Pacífico", "HAST": "hora estándar de Hawái-Aleutiano", "JDT": "hora de verano de Japón", "HNOG": "hora estándar de Groenlandia occidental", "TMST": "hora de verano de Turkmenistán", "HNEG": "hora estándar de Groenlandia oriental", "AWST": "hora estándar de Australia occidental", "NZDT": "hora de verano de Nueva Zelanda", "SAST": "hora de Sudáfrica", "SRT": "hora de Surinam", "MESZ": "hora de verano de Europa central", "HNT": "hora estándar de Terranova", "HAT": "hora de verano de Terranova", "AEDT": "hora de verano de Australia oriental", "WITA": "hora de Indonesia central", "UYT": "hora estándar de Uruguay", "AWDT": "hora de verano de Australia occidental", "HADT": "hora de verano de Hawái-Aleutiano", "CLST": "hora de verano de Chile", "HNNOMX": "hora estándar del noroeste de México", "UYST": "hora de verano de Uruguay", "GYT": "hora de Guyana", "CHAST": "hora estándar de Chatham", "WEZ": "hora estándar de Europa occidental", "HENOMX": "hora de verano del noroeste de México", "CHADT": "hora de verano de Chatham", "ECT": "hora de Ecuador", "CAT": "hora de África central", "OEZ": "hora estándar de Europa oriental", "COT": "hora estándar de Colombia", "HNPMX": "hora estándar del Pacífico de México", "HEPMX": "hora de verano del Pacífico de México", "WIB": "hora de Indonesia occidental", "IST": "hora estándar de la India", "MDT": "Hora de verano de Macao", "WAT": "hora estándar de África occidental", "COST": "hora de verano de Colombia", "ACWDT": "hora de verano de Australia centroccidental", "AST": "hora estándar del Atlántico", "WESZ": "hora de verano de Europa occidental", "ART": "hora estándar de Argentina", "ACDT": "hora de verano de Australia central", "MYT": "hora de Malasia", "WART": "hora estándar de Argentina occidental", "HNCU": "hora estándar de Cuba", "HECU": "hora de verano de Cuba", "BOT": "hora de Bolivia", "ACWST": "hora estándar de Australia centroccidental", "GMT": "hora del meridiano de Greenwich", "EDT": "hora de verano oriental", "∅∅∅": "Hora de verano de Acre", "AKDT": "hora de verano de Alaska", "HNPM": "hora estándar de San Pedro y Miquelón", "NZST": "hora estándar de Nueva Zelanda", "BT": "hora de Bután", "JST": "hora estándar de Japón", "ADT": "hora de verano del Atlántico", "HEOG": "hora de verano de Groenlandia occidental", "HKT": "hora estándar de Hong Kong", "SGT": "hora de Singapur", "PDT": "hora de verano del Pacífico", "LHDT": "hora de verano de Lord Howe", "OESZ": "hora de verano de Europa oriental", "CLT": "hora estándar de Chile", "MST": "Hora estándar de Macao", "AEST": "hora estándar de Australia oriental", "GFT": "hora de la Guayana Francesa", "HEPM": "hora de verano de San Pedro y Miquelón"}, + } +} + +// Locale returns the current translators string locale +func (es *es_PY) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_PY' +func (es *es_PY) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_PY' +func (es *es_PY) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_PY' +func (es *es_PY) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_PY' +func (es *es_PY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_PY' +func (es *es_PY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_PY' +func (es *es_PY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_PY) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_PY) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_PY) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_PY) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_PY) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_PY) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_PY) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_PY) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_PY) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_PY) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_PY) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_PY) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_PY) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_PY) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_PY' and handles both Whole and Real numbers based on 'v' +func (es *es_PY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_PY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_PY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_PY' +func (es *es_PY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_PY' +// in accounting notation. +func (es *es_PY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyNegativePrefix[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_PY' +func (es *es_PY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_PY' +func (es *es_PY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_PY' +func (es *es_PY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_PY' +func (es *es_PY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_PY' +func (es *es_PY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_PY' +func (es *es_PY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_PY' +func (es *es_PY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_PY' +func (es *es_PY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_PY/es_PY_test.go b/vendor/github.com/go-playground/locales/es_PY/es_PY_test.go new file mode 100644 index 0000000000..9e7b14d593 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_PY/es_PY_test.go @@ -0,0 +1,1120 @@ +package es_PY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_PY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_SV/es_SV.go b/vendor/github.com/go-playground/locales/es_SV/es_SV.go new file mode 100644 index 0000000000..0324b35d81 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_SV/es_SV.go @@ -0,0 +1,572 @@ +package es_SV + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_SV struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_SV' locale +func New() locales.Translator { + return &es_SV{ + locale: "es_SV", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"PDT": "hora de verano del Pacífico", "NZDT": "hora de verano de Nueva Zelanda", "WESZ": "hora de verano de Europa occidental", "HEEG": "hora de verano de Groenlandia oriental", "HENOMX": "hora de verano del noroeste de México", "SRT": "hora de Surinam", "SGT": "hora de Singapur", "HEOG": "hora de verano de Groenlandia occidental", "ARST": "hora de verano de Argentina", "AEST": "hora estándar de Australia oriental", "GYT": "hora de Guyana", "EAT": "hora de África oriental", "CHAST": "hora estándar de Chatham", "CAT": "hora de África central", "MEZ": "hora estándar de Europa central", "VET": "hora de Venezuela", "LHST": "hora estándar de Lord Howe", "ACWST": "hora estándar de Australia centroccidental", "HNEG": "hora estándar de Groenlandia oriental", "WITA": "hora de Indonesia central", "WIB": "hora de Indonesia occidental", "WART": "hora estándar de Argentina occidental", "HECU": "hora de verano de Cuba", "ECT": "hora de Ecuador", "OESZ": "hora de verano de Europa oriental", "COST": "hora de verano de Colombia", "CLST": "hora de verano de Chile", "BT": "hora de Bután", "MESZ": "hora de verano de Europa central", "JDT": "hora de verano de Japón", "GFT": "hora de la Guayana Francesa", "AKDT": "hora de verano de Alaska", "AEDT": "hora de verano de Australia oriental", "HADT": "hora de verano de Hawái-Aleutiano", "TMST": "hora de verano de Turkmenistán", "ACDT": "hora de verano de Australia central", "WAST": "hora de verano de África occidental", "HKST": "hora de verano de Hong Kong", "UYT": "hora estándar de Uruguay", "HEPMX": "hora de verano del Pacífico de México", "CLT": "hora estándar de Chile", "MDT": "Hora de verano de Macao", "CDT": "hora de verano central", "PST": "hora estándar del Pacífico", "GMT": "hora del meridiano de Greenwich", "TMT": "hora estándar de Turkmenistán", "HAST": "hora estándar de Hawái-Aleutiano", "IST": "hora estándar de la India", "ACWDT": "hora de verano de Australia centroccidental", "NZST": "hora estándar de Nueva Zelanda", "MST": "Hora estándar de Macao", "HNCU": "hora estándar de Cuba", "AST": "hora estándar del Atlántico", "WEZ": "hora estándar de Europa occidental", "WIT": "hora de Indonesia oriental", "AWDT": "hora de verano de Australia occidental", "JST": "hora estándar de Japón", "HNOG": "hora estándar de Groenlandia occidental", "MYT": "hora de Malasia", "UYST": "hora de verano de Uruguay", "COT": "hora estándar de Colombia", "HNT": "hora estándar de Terranova", "HAT": "hora de verano de Terranova", "HNPM": "hora estándar de San Pedro y Miquelón", "HEPM": "hora de verano de San Pedro y Miquelón", "LHDT": "hora de verano de Lord Howe", "WAT": "hora estándar de África occidental", "HKT": "hora estándar de Hong Kong", "ACST": "hora estándar de Australia central", "∅∅∅": "Hora de verano de Acre", "ChST": "hora estándar de Chamorro", "SAST": "hora de Sudáfrica", "AWST": "hora estándar de Australia occidental", "OEZ": "hora estándar de Europa oriental", "EST": "hora estándar oriental", "ART": "hora estándar de Argentina", "EDT": "hora de verano oriental", "HNNOMX": "hora estándar del noroeste de México", "AKST": "hora estándar de Alaska", "HNPMX": "hora estándar del Pacífico de México", "CST": "hora estándar central", "ADT": "hora de verano del Atlántico", "WARST": "hora de verano de Argentina occidental", "CHADT": "hora de verano de Chatham", "BOT": "hora de Bolivia"}, + } +} + +// Locale returns the current translators string locale +func (es *es_SV) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_SV' +func (es *es_SV) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_SV' +func (es *es_SV) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_SV' +func (es *es_SV) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_SV' +func (es *es_SV) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_SV' +func (es *es_SV) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_SV' +func (es *es_SV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_SV) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_SV) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_SV) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_SV) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_SV) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_SV) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_SV) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_SV) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_SV) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_SV) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_SV) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_SV) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_SV) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_SV) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_SV' and handles both Whole and Real numbers based on 'v' +func (es *es_SV) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_SV' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_SV) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_SV' +func (es *es_SV) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_SV' +// in accounting notation. +func (es *es_SV) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_SV' +func (es *es_SV) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_SV' +func (es *es_SV) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_SV' +func (es *es_SV) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_SV' +func (es *es_SV) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_SV' +func (es *es_SV) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_SV' +func (es *es_SV) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_SV' +func (es *es_SV) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_SV' +func (es *es_SV) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_SV/es_SV_test.go b/vendor/github.com/go-playground/locales/es_SV/es_SV_test.go new file mode 100644 index 0000000000..cb55eb8f65 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_SV/es_SV_test.go @@ -0,0 +1,1120 @@ +package es_SV + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_SV" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_US/es_US.go b/vendor/github.com/go-playground/locales/es_US/es_US.go new file mode 100644 index 0000000000..7954f87eca --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_US/es_US.go @@ -0,0 +1,624 @@ +package es_US + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_US struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_US' locale +func New() locales.Translator { + return &es_US{ + locale: "es_US", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "lei", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"WITA": "hora de Indonesia central", "SAST": "hora de Sudáfrica", "CHADT": "hora de verano de Chatham", "TMST": "hora de verano de Turkmenistán", "HAT": "hora de verano de Terranova", "HNEG": "hora estándar de Groenlandia oriental", "AEST": "hora estándar de Australia oriental", "HECU": "hora de verano de Cuba", "OEZ": "hora estándar de Europa oriental", "COT": "hora estándar de Colombia", "HEEG": "hora de verano de Groenlandia oriental", "MST": "hora estándar de las Montañas", "HNPM": "hora estándar de San Pedro y Miquelón", "WIB": "hora de Indonesia occidental", "NZDT": "hora de verano de Nueva Zelanda", "VET": "hora de Venezuela", "JDT": "hora de verano de Japón", "ACST": "hora estándar de Australia central", "MDT": "hora de verano de las Montañas", "ACWST": "hora estándar de Australia centroccidental", "AKST": "hora estándar de Alaska", "AKDT": "hora de verano de Alaska", "LHDT": "hora de verano de Lord Howe", "GYT": "hora de Guyana", "BOT": "hora de Bolivia", "HADT": "hora de verano de Hawái-Aleutiano", "ART": "hora estándar de Argentina", "MYT": "hora de Malasia", "WESZ": "hora de verano de Europa occidental", "EST": "hora estándar oriental", "HKST": "hora de verano de Hong Kong", "GFT": "hora de la Guayana Francesa", "LHST": "hora estándar de Lord Howe", "CDT": "hora de verano central", "IST": "hora estándar de la India", "CLT": "hora estándar de Chile", "HEOG": "hora de verano de Groenlandia occidental", "MEZ": "hora estándar de Europa central", "OESZ": "hora de verano de Europa oriental", "EDT": "hora de verano oriental", "COST": "hora de verano de Colombia", "∅∅∅": "hora de verano de las Azores", "EAT": "hora de África oriental", "NZST": "hora estándar de Nueva Zelanda", "JST": "hora estándar de Japón", "HKT": "hora estándar de Hong Kong", "BT": "hora de Bután", "HNT": "hora estándar de Terranova", "CST": "hora estándar central", "AWDT": "hora de verano de Australia occidental", "WAST": "hora de verano de África occidental", "HNCU": "hora estándar de Cuba", "ECT": "hora de Ecuador", "HNOG": "hora estándar de Groenlandia occidental", "AST": "hora estándar del Atlántico", "WEZ": "hora estándar de Europa occidental", "ACDT": "hora de verano de Australia central", "UYST": "hora de verano de Uruguay", "HNPMX": "hora estándar del Pacífico de México", "CHAST": "hora estándar de Chatham", "MESZ": "hora de verano de Europa central", "HNNOMX": "hora estándar del noroeste de México", "WAT": "hora estándar de África occidental", "ChST": "hora de Chamorro", "UYT": "hora estándar de Uruguay", "SGT": "hora de Singapur", "HAST": "hora estándar de Hawái-Aleutiano", "CAT": "hora de África central", "ADT": "hora de verano del Atlántico", "ARST": "hora de verano de Argentina", "HENOMX": "hora de verano del noroeste de México", "AEDT": "hora de verano de Australia oriental", "SRT": "hora de Surinam", "HEPMX": "hora de verano del Pacífico de México", "AWST": "hora estándar de Australia occidental", "PST": "hora estándar del Pacífico", "GMT": "hora del meridiano de Greenwich", "TMT": "hora estándar de Turkmenistán", "HEPM": "hora de verano de San Pedro y Miquelón", "ACWDT": "hora de verano de Australia centroccidental", "WART": "hora estándar de Argentina occidental", "WIT": "hora de Indonesia oriental", "PDT": "hora de verano del Pacífico", "WARST": "hora de verano de Argentina occidental", "CLST": "hora de verano de Chile"}, + } +} + +// Locale returns the current translators string locale +func (es *es_US) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_US' +func (es *es_US) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_US' +func (es *es_US) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_US' +func (es *es_US) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_US' +func (es *es_US) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_US' +func (es *es_US) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_US' +func (es *es_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_US) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_US) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_US) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_US) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_US) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_US) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_US) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_US) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_US) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_US) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_US) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_US) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_US) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_US) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_US' and handles both Whole and Real numbers based on 'v' +func (es *es_US) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_US' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_US) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_US' +func (es *es_US) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, es.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_US' +// in accounting notation. +func (es *es_US) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, es.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, es.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_US' +func (es *es_US) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_US' +func (es *es_US) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_US' +func (es *es_US) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_US' +func (es *es_US) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_US' +func (es *es_US) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_US' +func (es *es_US) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_US' +func (es *es_US) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_US' +func (es *es_US) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_US/es_US_test.go b/vendor/github.com/go-playground/locales/es_US/es_US_test.go new file mode 100644 index 0000000000..93fd0026f8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_US/es_US_test.go @@ -0,0 +1,1120 @@ +package es_US + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_US" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_UY/es_UY.go b/vendor/github.com/go-playground/locales/es_UY/es_UY.go new file mode 100644 index 0000000000..c334a5c84e --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_UY/es_UY.go @@ -0,0 +1,589 @@ +package es_UY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_UY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_UY' locale +func New() locales.Translator { + return &es_UY{ + locale: "es_UY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "$", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: "( ", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "set.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "setiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"DO", "LU", "MA", "MI", "JU", "VI", "SA"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"AWST": "hora estándar de Australia occidental", "SGT": "hora de Singapur", "HADT": "hora de verano de Hawái-Aleutiano", "OEZ": "hora estándar de Europa oriental", "HNNOMX": "hora estándar del noroeste de México", "LHDT": "hora de verano de Lord Howe", "NZDT": "hora de verano de Nueva Zelanda", "VET": "hora de Venezuela", "ADT": "hora de verano del Atlántico", "MDT": "Hora de verano de Macao", "PDT": "hora de verano del Pacífico", "COST": "hora de verano de Colombia", "GFT": "hora de la Guayana Francesa", "WIB": "hora de Indonesia occidental", "AWDT": "hora de verano de Australia occidental", "CHADT": "hora de verano de Chatham", "WARST": "hora de verano de Argentina occidental", "WAT": "hora estándar de África occidental", "CHAST": "hora estándar de Chatham", "MYT": "hora de Malasia", "AKDT": "hora de verano de Alaska", "HNPM": "hora estándar de San Pedro y Miquelón", "CLT": "hora estándar de Chile", "HNOG": "hora estándar de Groenlandia occidental", "HEOG": "hora de verano de Groenlandia occidental", "GMT": "hora del meridiano de Greenwich", "AKST": "hora estándar de Alaska", "IST": "hora estándar de la India", "ACWST": "hora estándar de Australia centroccidental", "MST": "Hora estándar de Macao", "EDT": "hora de verano oriental", "HNT": "hora estándar de Terranova", "HEEG": "hora de verano de Groenlandia oriental", "UYST": "hora de verano de Uruguay", "BOT": "hora de Bolivia", "CAT": "hora de África central", "∅∅∅": "hora de verano del Amazonas", "ARST": "hora de verano de Argentina", "ACST": "hora estándar de Australia central", "BT": "hora de Bután", "GYT": "hora de Guyana", "JST": "hora estándar de Japón", "WEZ": "hora estándar de Europa occidental", "EST": "hora estándar oriental", "HKT": "hora estándar de Hong Kong", "WAST": "hora de verano de África occidental", "WITA": "hora de Indonesia central", "AEDT": "hora de verano de Australia oriental", "HECU": "hora de verano de Cuba", "ACDT": "hora de verano de Australia central", "CST": "hora estándar central", "ECT": "hora de Ecuador", "WESZ": "hora de verano de Europa occidental", "TMST": "hora de verano de Turkmenistán", "ART": "hora estándar de Argentina", "AEST": "hora estándar de Australia oriental", "SRT": "hora de Surinam", "EAT": "hora de África oriental", "HAST": "hora estándar de Hawái-Aleutiano", "ACWDT": "hora de verano de Australia centroccidental", "OESZ": "hora de verano de Europa oriental", "HNEG": "hora estándar de Groenlandia oriental", "HEPM": "hora de verano de San Pedro y Miquelón", "HEPMX": "hora de verano del Pacífico de México", "WIT": "hora de Indonesia oriental", "CDT": "hora de verano central", "CLST": "hora de verano de Chile", "AST": "hora estándar del Atlántico", "COT": "hora estándar de Colombia", "LHST": "hora estándar de Lord Howe", "SAST": "hora de Sudáfrica", "HNCU": "hora estándar de Cuba", "MEZ": "hora estándar de Europa central", "WART": "hora estándar de Argentina occidental", "HAT": "hora de verano de Terranova", "UYT": "hora estándar de Uruguay", "TMT": "hora estándar de Turkmenistán", "HKST": "hora de verano de Hong Kong", "HENOMX": "hora de verano del noroeste de México", "ChST": "hora estándar de Chamorro", "PST": "hora estándar del Pacífico", "NZST": "hora estándar de Nueva Zelanda", "MESZ": "hora de verano de Europa central", "JDT": "hora de verano de Japón", "HNPMX": "hora estándar del Pacífico de México"}, + } +} + +// Locale returns the current translators string locale +func (es *es_UY) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_UY' +func (es *es_UY) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_UY' +func (es *es_UY) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_UY' +func (es *es_UY) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_UY' +func (es *es_UY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_UY' +func (es *es_UY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_UY' +func (es *es_UY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_UY) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_UY) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_UY) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_UY) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_UY) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_UY) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_UY) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_UY) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_UY) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_UY) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_UY) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_UY) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_UY) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_UY) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_UY' and handles both Whole and Real numbers based on 'v' +func (es *es_UY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_UY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_UY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_UY' +func (es *es_UY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_UY' +// in accounting notation. +func (es *es_UY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyNegativePrefix[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(es.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, es.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, es.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_UY' +func (es *es_UY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_UY' +func (es *es_UY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_UY' +func (es *es_UY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_UY' +func (es *es_UY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_UY' +func (es *es_UY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_UY' +func (es *es_UY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_UY' +func (es *es_UY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_UY' +func (es *es_UY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_UY/es_UY_test.go b/vendor/github.com/go-playground/locales/es_UY/es_UY_test.go new file mode 100644 index 0000000000..bcec99e6ef --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_UY/es_UY_test.go @@ -0,0 +1,1120 @@ +package es_UY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_UY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/es_VE/es_VE.go b/vendor/github.com/go-playground/locales/es_VE/es_VE.go new file mode 100644 index 0000000000..48b8217131 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_VE/es_VE.go @@ -0,0 +1,621 @@ +package es_VE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type es_VE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'es_VE' locale +func New() locales.Translator { + return &es_VE{ + locale: "es_VE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "Bs.", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "ene.", "feb.", "mar.", "abr.", "may.", "jun.", "jul.", "ago.", "sept.", "oct.", "nov.", "dic."}, + monthsNarrow: []string{"", "E", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}, + daysAbbreviated: []string{"dom.", "lun.", "mar.", "mié.", "jue.", "vie.", "sáb."}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa"}, + daysWide: []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}, + periodsAbbreviated: []string{"a. m.", "p. m."}, + periodsNarrow: []string{"a. m.", "p. m."}, + periodsWide: []string{"a. m.", "p. m."}, + erasAbbreviated: []string{"a. C.", "d. C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "después de Cristo"}, + timezones: map[string]string{"AKDT": "hora de verano de Alaska", "GYT": "hora de Guyana", "CDT": "hora de verano central", "MEZ": "hora estándar de Europa central", "OEZ": "hora estándar de Europa oriental", "AEST": "hora estándar de Australia oriental", "UYST": "hora de verano de Uruguay", "HAST": "hora estándar de Hawái-Aleutiano", "JST": "hora estándar de Japón", "WAT": "hora estándar de África occidental", "CHADT": "hora de verano de Chatham", "ECT": "hora de Ecuador", "NZST": "hora estándar de Nueva Zelanda", "HEPM": "hora de verano de San Pedro y Miquelón", "TMT": "hora estándar de Turkmenistán", "COST": "hora de verano de Colombia", "HAT": "hora de verano de Terranova", "HNCU": "hora estándar de Cuba", "AWST": "hora estándar de Australia occidental", "∅∅∅": "hora de verano del Amazonas", "JDT": "hora de verano de Japón", "ADT": "hora de verano del Atlántico", "AWDT": "hora de verano de Australia occidental", "ARST": "hora de verano de Argentina", "EAT": "hora de África oriental", "BOT": "hora de Bolivia", "PST": "hora estándar del Pacífico", "VET": "hora de Venezuela", "HNOG": "hora estándar de Groenlandia occidental", "HENOMX": "hora de verano del noroeste de México", "COT": "hora estándar de Colombia", "HEEG": "hora de verano de Groenlandia oriental", "GFT": "hora de la Guayana Francesa", "ACWST": "hora estándar de Australia centroccidental", "MST": "Hora estándar de Macao", "ART": "hora estándar de Argentina", "WIT": "hora de Indonesia oriental", "SGT": "hora de Singapur", "ACWDT": "hora de verano de Australia centroccidental", "AST": "hora estándar del Atlántico", "ACDT": "hora de verano de Australia central", "WAST": "hora de verano de África occidental", "HNEG": "hora estándar de Groenlandia oriental", "HNPMX": "hora estándar del Pacífico de México", "HECU": "hora de verano de Cuba", "MESZ": "hora de verano de Europa central", "WESZ": "hora de verano de Europa occidental", "HKST": "hora de verano de Hong Kong", "EST": "hora estándar oriental", "HNT": "hora estándar de Terranova", "SAST": "hora de Sudáfrica", "WIB": "hora de Indonesia occidental", "CLT": "hora estándar de Chile", "UYT": "hora estándar de Uruguay", "SRT": "hora de Surinam", "LHST": "hora estándar de Lord Howe", "CST": "hora estándar central", "MYT": "hora de Malasia", "HEOG": "hora de verano de Groenlandia occidental", "HKT": "hora estándar de Hong Kong", "TMST": "hora de verano de Turkmenistán", "ACST": "hora estándar de Australia central", "ChST": "hora estándar de Chamorro", "PDT": "hora de verano del Pacífico", "WARST": "hora de verano de Argentina occidental", "CLST": "hora de verano de Chile", "BT": "hora de Bután", "HEPMX": "hora de verano del Pacífico de México", "CAT": "hora de África central", "WEZ": "hora estándar de Europa occidental", "GMT": "hora del meridiano de Greenwich", "EDT": "hora de verano oriental", "HNNOMX": "hora estándar del noroeste de México", "AKST": "hora estándar de Alaska", "HNPM": "hora estándar de San Pedro y Miquelón", "HADT": "hora de verano de Hawái-Aleutiano", "IST": "hora estándar de la India", "WART": "hora estándar de Argentina occidental", "AEDT": "hora de verano de Australia oriental", "WITA": "hora de Indonesia central", "LHDT": "hora de verano de Lord Howe", "CHAST": "hora estándar de Chatham", "NZDT": "hora de verano de Nueva Zelanda", "OESZ": "hora de verano de Europa oriental", "MDT": "Hora de verano de Macao"}, + } +} + +// Locale returns the current translators string locale +func (es *es_VE) Locale() string { + return es.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'es_VE' +func (es *es_VE) PluralsCardinal() []locales.PluralRule { + return es.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'es_VE' +func (es *es_VE) PluralsOrdinal() []locales.PluralRule { + return es.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'es_VE' +func (es *es_VE) PluralsRange() []locales.PluralRule { + return es.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'es_VE' +func (es *es_VE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'es_VE' +func (es *es_VE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'es_VE' +func (es *es_VE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (es *es_VE) MonthAbbreviated(month time.Month) string { + return es.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (es *es_VE) MonthsAbbreviated() []string { + return es.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (es *es_VE) MonthNarrow(month time.Month) string { + return es.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (es *es_VE) MonthsNarrow() []string { + return es.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (es *es_VE) MonthWide(month time.Month) string { + return es.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (es *es_VE) MonthsWide() []string { + return es.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (es *es_VE) WeekdayAbbreviated(weekday time.Weekday) string { + return es.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (es *es_VE) WeekdaysAbbreviated() []string { + return es.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (es *es_VE) WeekdayNarrow(weekday time.Weekday) string { + return es.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (es *es_VE) WeekdaysNarrow() []string { + return es.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (es *es_VE) WeekdayShort(weekday time.Weekday) string { + return es.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (es *es_VE) WeekdaysShort() []string { + return es.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (es *es_VE) WeekdayWide(weekday time.Weekday) string { + return es.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (es *es_VE) WeekdaysWide() []string { + return es.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'es_VE' and handles both Whole and Real numbers based on 'v' +func (es *es_VE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'es_VE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (es *es_VE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, es.percentSuffix...) + + b = append(b, es.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'es_VE' +func (es *es_VE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, es.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'es_VE' +// in accounting notation. +func (es *es_VE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := es.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, es.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, es.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, es.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, es.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'es_VE' +func (es *es_VE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'es_VE' +func (es *es_VE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'es_VE' +func (es *es_VE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'es_VE' +func (es *es_VE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, es.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, es.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'es_VE' +func (es *es_VE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'es_VE' +func (es *es_VE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'es_VE' +func (es *es_VE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'es_VE' +func (es *es_VE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, es.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, es.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, es.periodsAbbreviated[0]...) + } else { + b = append(b, es.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := es.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/es_VE/es_VE_test.go b/vendor/github.com/go-playground/locales/es_VE/es_VE_test.go new file mode 100644 index 0000000000..9a5dfbbe26 --- /dev/null +++ b/vendor/github.com/go-playground/locales/es_VE/es_VE_test.go @@ -0,0 +1,1120 @@ +package es_VE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "es_VE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/et/et.go b/vendor/github.com/go-playground/locales/et/et.go new file mode 100644 index 0000000000..c31c19a8ea --- /dev/null +++ b/vendor/github.com/go-playground/locales/et/et.go @@ -0,0 +1,603 @@ +package et + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type et struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'et' locale +func New() locales.Translator { + return &et{ + locale: "et", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "kr", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jaan", "veebr", "märts", "apr", "mai", "juuni", "juuli", "aug", "sept", "okt", "nov", "dets"}, + monthsNarrow: []string{"", "J", "V", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "jaanuar", "veebruar", "märts", "aprill", "mai", "juuni", "juuli", "august", "september", "oktoober", "november", "detsember"}, + daysAbbreviated: []string{"P", "E", "T", "K", "N", "R", "L"}, + daysNarrow: []string{"P", "E", "T", "K", "N", "R", "L"}, + daysShort: []string{"P", "E", "T", "K", "N", "R", "L"}, + daysWide: []string{"pühapäev", "esmaspäev", "teisipäev", "kolmapäev", "neljapäev", "reede", "laupäev"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"eKr", "pKr"}, + erasNarrow: []string{"eKr", "pKr"}, + erasWide: []string{"enne Kristust", "pärast Kristust"}, + timezones: map[string]string{"SAST": "Lõuna-Aafrika standardaeg", "SGT": "Singapuri standardaeg", "PST": "Vaikse ookeani standardaeg", "MEZ": "Kesk-Euroopa standardaeg", "OEZ": "Ida-Euroopa standardaeg", "OESZ": "Ida-Euroopa suveaeg", "MST": "MST", "∅∅∅": "Assooride suveaeg", "HEEG": "Ida-Gröönimaa suveaeg", "HKST": "Hongkongi suveaeg", "CHAST": "Chathami standardaeg", "NZST": "Uus-Meremaa standardaeg", "JDT": "Jaapani suveaeg", "MDT": "MDT", "COST": "Colombia suveaeg", "WIB": "Lääne-Indoneesia aeg", "AWST": "Lääne-Austraalia standardaeg", "CLT": "Tšiili standardaeg", "HNNOMX": "Loode-Mehhiko standardaeg", "HAT": "Newfoundlandi suveaeg", "AKST": "Alaska standardaeg", "AKDT": "Alaska suveaeg", "SRT": "Suriname aeg", "WIT": "Ida-Indoneesia aeg", "WESZ": "Lääne-Euroopa suveaeg", "ACDT": "Kesk-Austraalia suveaeg", "HEPMX": "Mehhiko Vaikse ookeani suveaeg", "HECU": "Kuuba suveaeg", "ACWST": "Kesk-Lääne Austraalia standardaeg", "HEOG": "Lääne-Gröönimaa suveaeg", "HEPM": "Saint-Pierre’i ja Miqueloni suveaeg", "GYT": "Guyana aeg", "HAST": "Hawaii-Aleuudi standardaeg", "ACWDT": "Kesk-Lääne Austraalia suveaeg", "GMT": "Greenwichi aeg", "MYT": "Malaisia \u200b\u200baeg", "ART": "Argentina standardaeg", "CST": "Kesk-Ameerika standardaeg", "EAT": "Ida-Aafrika aeg", "NZDT": "Uus-Meremaa suveaeg", "TMT": "Türkmenistani standardaeg", "TMST": "Türkmenistani suveaeg", "LHDT": "Lord Howe’i suveaeg", "WITA": "Kesk-Indoneesia aeg", "EDT": "Idaranniku suveaeg", "HNCU": "Kuuba standardaeg", "CDT": "Kesk-Ameerika suveaeg", "WART": "Lääne-Argentina standardaeg", "HNOG": "Lääne-Gröönimaa standardaeg", "HNPM": "Saint-Pierre’i ja Miqueloni standardaeg", "HNPMX": "Mehhiko Vaikse ookeani standardaeg", "CHADT": "Chathami suveaeg", "HADT": "Hawaii-Aleuudi suveaeg", "VET": "Venezuela aeg", "EST": "Idaranniku standardaeg", "HENOMX": "Loode-Mehhiko suveaeg", "AWDT": "Lääne-Austraalia suveaeg", "CAT": "Kesk-Aafrika aeg", "MESZ": "Kesk-Euroopa suveaeg", "CLST": "Tšiili suveaeg", "ADT": "Atlandi suveaeg", "WAT": "Lääne-Aafrika standardaeg", "GFT": "Prantsuse Guajaana aeg", "ChST": "Tšamorro standardaeg", "ECT": "Ecuadori aeg", "UYST": "Uruguay suveaeg", "ARST": "Argentina suveaeg", "HKT": "Hongkongi standardaeg", "AEST": "Ida-Austraalia standardaeg", "AEDT": "Ida-Austraalia suveaeg", "PDT": "Vaikse ookeani suveaeg", "ACST": "Kesk-Austraalia standardaeg", "HNEG": "Ida-Gröönimaa standardaeg", "AST": "Atlandi standardaeg", "WEZ": "Lääne-Euroopa standardaeg", "WAST": "Lääne-Aafrika suveaeg", "HNT": "Newfoundlandi standardaeg", "BOT": "Boliivia aeg", "JST": "Jaapani standardaeg", "WARST": "Lääne-Argentina suveaeg", "COT": "Colombia standardaeg", "BT": "Bhutani aeg", "UYT": "Uruguay standardaeg", "IST": "India aeg", "LHST": "Lord Howe’i standardaeg"}, + } +} + +// Locale returns the current translators string locale +func (et *et) Locale() string { + return et.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'et' +func (et *et) PluralsCardinal() []locales.PluralRule { + return et.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'et' +func (et *et) PluralsOrdinal() []locales.PluralRule { + return et.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'et' +func (et *et) PluralsRange() []locales.PluralRule { + return et.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'et' +func (et *et) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'et' +func (et *et) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'et' +func (et *et) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (et *et) MonthAbbreviated(month time.Month) string { + return et.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (et *et) MonthsAbbreviated() []string { + return et.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (et *et) MonthNarrow(month time.Month) string { + return et.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (et *et) MonthsNarrow() []string { + return et.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (et *et) MonthWide(month time.Month) string { + return et.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (et *et) MonthsWide() []string { + return et.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (et *et) WeekdayAbbreviated(weekday time.Weekday) string { + return et.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (et *et) WeekdaysAbbreviated() []string { + return et.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (et *et) WeekdayNarrow(weekday time.Weekday) string { + return et.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (et *et) WeekdaysNarrow() []string { + return et.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (et *et) WeekdayShort(weekday time.Weekday) string { + return et.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (et *et) WeekdaysShort() []string { + return et.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (et *et) WeekdayWide(weekday time.Weekday) string { + return et.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (et *et) WeekdaysWide() []string { + return et.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'et' and handles both Whole and Real numbers based on 'v' +func (et *et) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, et.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(et.group) - 1; j >= 0; j-- { + b = append(b, et.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(et.minus) - 1; j >= 0; j-- { + b = append(b, et.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'et' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (et *et) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, et.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(et.minus) - 1; j >= 0; j-- { + b = append(b, et.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, et.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'et' +func (et *et) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := et.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, et.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(et.group) - 1; j >= 0; j-- { + b = append(b, et.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(et.minus) - 1; j >= 0; j-- { + b = append(b, et.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, et.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, et.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'et' +// in accounting notation. +func (et *et) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := et.currencies[currency] + l := len(s) + len(symbol) + 8 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, et.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(et.group) - 1; j >= 0; j-- { + b = append(b, et.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, et.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, et.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, et.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, et.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'et' +func (et *et) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'et' +func (et *et) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, et.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'et' +func (et *et) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, et.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'et' +func (et *et) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, et.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, et.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'et' +func (et *et) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, et.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'et' +func (et *et) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, et.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, et.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'et' +func (et *et) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, et.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, et.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'et' +func (et *et) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, et.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, et.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := et.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/et/et_test.go b/vendor/github.com/go-playground/locales/et/et_test.go new file mode 100644 index 0000000000..f472b64ef0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/et/et_test.go @@ -0,0 +1,1120 @@ +package et + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "et" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/et_EE/et_EE.go b/vendor/github.com/go-playground/locales/et_EE/et_EE.go new file mode 100644 index 0000000000..34ebcf0516 --- /dev/null +++ b/vendor/github.com/go-playground/locales/et_EE/et_EE.go @@ -0,0 +1,603 @@ +package et_EE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type et_EE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'et_EE' locale +func New() locales.Translator { + return &et_EE{ + locale: "et_EE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jaan", "veebr", "märts", "apr", "mai", "juuni", "juuli", "aug", "sept", "okt", "nov", "dets"}, + monthsNarrow: []string{"", "J", "V", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "jaanuar", "veebruar", "märts", "aprill", "mai", "juuni", "juuli", "august", "september", "oktoober", "november", "detsember"}, + daysAbbreviated: []string{"P", "E", "T", "K", "N", "R", "L"}, + daysNarrow: []string{"P", "E", "T", "K", "N", "R", "L"}, + daysShort: []string{"P", "E", "T", "K", "N", "R", "L"}, + daysWide: []string{"pühapäev", "esmaspäev", "teisipäev", "kolmapäev", "neljapäev", "reede", "laupäev"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"eKr", "pKr"}, + erasNarrow: []string{"eKr", "pKr"}, + erasWide: []string{"enne Kristust", "pärast Kristust"}, + timezones: map[string]string{"∅∅∅": "Brasiilia suveaeg", "WARST": "Lääne-Argentina suveaeg", "HNPMX": "Mehhiko Vaikse ookeani standardaeg", "CAT": "Kesk-Aafrika aeg", "WITA": "Kesk-Indoneesia aeg", "HNCU": "Kuuba standardaeg", "CLST": "Tšiili suveaeg", "HENOMX": "Loode-Mehhiko suveaeg", "HEPMX": "Mehhiko Vaikse ookeani suveaeg", "CDT": "Kesk-Ameerika suveaeg", "ECT": "Ecuadori aeg", "NZST": "Uus-Meremaa standardaeg", "JST": "Jaapani standardaeg", "HNOG": "Lääne-Gröönimaa standardaeg", "HNPM": "Saint-Pierre’i ja Miqueloni standardaeg", "SRT": "Suriname aeg", "GYT": "Guyana aeg", "PST": "Vaikse ookeani standardaeg", "MESZ": "Kesk-Euroopa suveaeg", "OEZ": "Ida-Euroopa standardaeg", "OESZ": "Ida-Euroopa suveaeg", "ACST": "Kesk-Austraalia standardaeg", "COST": "Colombia suveaeg", "WIB": "Lääne-Indoneesia aeg", "CHAST": "Chathami standardaeg", "IST": "India aeg", "ACWST": "Kesk-Lääne Austraalia standardaeg", "WESZ": "Lääne-Euroopa suveaeg", "EST": "Idaranniku standardaeg", "HKST": "Hongkongi suveaeg", "HEEG": "Ida-Gröönimaa suveaeg", "BOT": "Boliivia aeg", "MYT": "Malaisia \u200b\u200baeg", "WART": "Lääne-Argentina standardaeg", "CLT": "Tšiili standardaeg", "HKT": "Hongkongi standardaeg", "HAT": "Newfoundlandi suveaeg", "AEST": "Ida-Austraalia standardaeg", "UYST": "Uruguay suveaeg", "HECU": "Kuuba suveaeg", "PDT": "Vaikse ookeani suveaeg", "MST": "MST", "ARST": "Argentina suveaeg", "AKST": "Alaska standardaeg", "AEDT": "Ida-Austraalia suveaeg", "GFT": "Prantsuse Guajaana aeg", "ChST": "Tšamorro standardaeg", "EAT": "Ida-Aafrika aeg", "NZDT": "Uus-Meremaa suveaeg", "JDT": "Jaapani suveaeg", "WEZ": "Lääne-Euroopa standardaeg", "MDT": "MDT", "ACDT": "Kesk-Austraalia suveaeg", "HNNOMX": "Loode-Mehhiko standardaeg", "AKDT": "Alaska suveaeg", "HADT": "Hawaii-Aleuudi suveaeg", "ADT": "Atlandi suveaeg", "HNEG": "Ida-Gröönimaa standardaeg", "AWST": "Lääne-Austraalia standardaeg", "AWDT": "Lääne-Austraalia suveaeg", "ACWDT": "Kesk-Lääne Austraalia suveaeg", "HNT": "Newfoundlandi standardaeg", "CST": "Kesk-Ameerika standardaeg", "WIT": "Ida-Indoneesia aeg", "TMT": "Türkmenistani standardaeg", "WAT": "Lääne-Aafrika standardaeg", "WAST": "Lääne-Aafrika suveaeg", "UYT": "Uruguay standardaeg", "LHST": "Lord Howe’i standardaeg", "LHDT": "Lord Howe’i suveaeg", "CHADT": "Chathami suveaeg", "SGT": "Singapuri standardaeg", "MEZ": "Kesk-Euroopa standardaeg", "AST": "Atlandi standardaeg", "GMT": "Greenwichi aeg", "EDT": "Idaranniku suveaeg", "BT": "Bhutani aeg", "ART": "Argentina standardaeg", "COT": "Colombia standardaeg", "HEPM": "Saint-Pierre’i ja Miqueloni suveaeg", "VET": "Venezuela aeg", "HEOG": "Lääne-Gröönimaa suveaeg", "TMST": "Türkmenistani suveaeg", "SAST": "Lõuna-Aafrika standardaeg", "HAST": "Hawaii-Aleuudi standardaeg"}, + } +} + +// Locale returns the current translators string locale +func (et *et_EE) Locale() string { + return et.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'et_EE' +func (et *et_EE) PluralsCardinal() []locales.PluralRule { + return et.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'et_EE' +func (et *et_EE) PluralsOrdinal() []locales.PluralRule { + return et.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'et_EE' +func (et *et_EE) PluralsRange() []locales.PluralRule { + return et.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'et_EE' +func (et *et_EE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'et_EE' +func (et *et_EE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'et_EE' +func (et *et_EE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (et *et_EE) MonthAbbreviated(month time.Month) string { + return et.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (et *et_EE) MonthsAbbreviated() []string { + return et.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (et *et_EE) MonthNarrow(month time.Month) string { + return et.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (et *et_EE) MonthsNarrow() []string { + return et.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (et *et_EE) MonthWide(month time.Month) string { + return et.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (et *et_EE) MonthsWide() []string { + return et.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (et *et_EE) WeekdayAbbreviated(weekday time.Weekday) string { + return et.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (et *et_EE) WeekdaysAbbreviated() []string { + return et.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (et *et_EE) WeekdayNarrow(weekday time.Weekday) string { + return et.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (et *et_EE) WeekdaysNarrow() []string { + return et.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (et *et_EE) WeekdayShort(weekday time.Weekday) string { + return et.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (et *et_EE) WeekdaysShort() []string { + return et.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (et *et_EE) WeekdayWide(weekday time.Weekday) string { + return et.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (et *et_EE) WeekdaysWide() []string { + return et.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'et_EE' and handles both Whole and Real numbers based on 'v' +func (et *et_EE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, et.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(et.group) - 1; j >= 0; j-- { + b = append(b, et.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(et.minus) - 1; j >= 0; j-- { + b = append(b, et.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'et_EE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (et *et_EE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, et.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(et.minus) - 1; j >= 0; j-- { + b = append(b, et.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, et.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'et_EE' +func (et *et_EE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := et.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, et.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(et.group) - 1; j >= 0; j-- { + b = append(b, et.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(et.minus) - 1; j >= 0; j-- { + b = append(b, et.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, et.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, et.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'et_EE' +// in accounting notation. +func (et *et_EE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := et.currencies[currency] + l := len(s) + len(symbol) + 8 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, et.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(et.group) - 1; j >= 0; j-- { + b = append(b, et.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, et.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, et.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, et.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, et.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'et_EE' +func (et *et_EE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'et_EE' +func (et *et_EE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, et.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'et_EE' +func (et *et_EE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, et.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'et_EE' +func (et *et_EE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, et.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, et.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'et_EE' +func (et *et_EE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, et.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'et_EE' +func (et *et_EE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, et.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, et.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'et_EE' +func (et *et_EE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, et.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, et.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'et_EE' +func (et *et_EE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, et.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, et.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := et.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/et_EE/et_EE_test.go b/vendor/github.com/go-playground/locales/et_EE/et_EE_test.go new file mode 100644 index 0000000000..3d807f6fb4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/et_EE/et_EE_test.go @@ -0,0 +1,1120 @@ +package et_EE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "et_EE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/eu/eu.go b/vendor/github.com/go-playground/locales/eu/eu.go new file mode 100644 index 0000000000..e15094930c --- /dev/null +++ b/vendor/github.com/go-playground/locales/eu/eu.go @@ -0,0 +1,607 @@ +package eu + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type eu struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentPrefix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'eu' locale +func New() locales.Translator { + return &eu{ + locale: "eu", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "₧", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentPrefix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "urt.", "ots.", "mar.", "api.", "mai.", "eka.", "uzt.", "abu.", "ira.", "urr.", "aza.", "abe."}, + monthsNarrow: []string{"", "U", "O", "M", "A", "M", "E", "U", "A", "I", "U", "A", "A"}, + monthsWide: []string{"", "urtarrila", "otsaila", "martxoa", "apirila", "maiatza", "ekaina", "uztaila", "abuztua", "iraila", "urria", "azaroa", "abendua"}, + daysAbbreviated: []string{"ig.", "al.", "ar.", "az.", "og.", "or.", "lr."}, + daysNarrow: []string{"I", "A", "A", "A", "O", "O", "L"}, + daysShort: []string{"ig.", "al.", "ar.", "az.", "og.", "or.", "lr."}, + daysWide: []string{"igandea", "astelehena", "asteartea", "asteazkena", "osteguna", "ostirala", "larunbata"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"g", "a"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"K.a.", "K.o."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"K.a.", "Kristo ondoren"}, + timezones: map[string]string{"EST": "Ipar Amerikako ekialdeko ordutegi estandarra", "UYST": "Uruguayko udako ordua", "SGT": "Singapurreko ordu estandarra", "PDT": "Ipar Amerikako Pazifikoko udako ordutegia", "ECT": "Ekuadorreko ordua", "ADT": "Atlantikoko udako ordutegia", "WESZ": "Europa mendebaldeko udako ordua", "MYT": "Malaysiako ordua", "HEPM": "Saint-Pierre eta Mikeluneko udako ordutegia", "HECU": "Kubako udako ordutegia", "MEZ": "Europa erdialdeko ordu estandarra", "AST": "Atlantikoko ordutegi estandarra", "MST": "MST", "ART": "Argentinako ordutegi estandarra", "UYT": "Uruguayko ordu estandarra", "WIB": "Indonesia mendebaldeko ordua", "BOT": "Boliviako ordutegia", "WAST": "Afrika mendebaldeko udako ordua", "COST": "Kolonbiako udako ordua", "BT": "Bhutango ordua", "ChST": "Chamorroko ordu estandarra", "HEPMX": "Mexikoko Pazifikoko udako ordutegia", "HNOG": "Groenlandia mendebaldeko ordutegi estandarra", "WART": "Argentina mendebaldeko ordutegia estandarra", "ARST": "Argentinako udako ordutegia", "ACST": "Australia erdialdeko ordu estandarra", "HNPMX": "Mexikoko Pazifikoko ordutegi estandarra", "GYT": "Guyanako ordua", "CAT": "Afrika erdialdeko ordua", "WEZ": "Europa mendebaldeko ordu estandarra", "HEEG": "Groenlandia ekialdeko udako ordutegia", "EAT": "Afrika ekialdeko ordua", "WIT": "Indonesia ekialdeko ordua", "NZDT": "Zeelanda Berriko udako ordua", "MESZ": "Europa erdialdeko udako ordua", "OEZ": "Europa ekialdeko ordu estandarra", "OESZ": "Europa ekialdeko udako ordua", "WARST": "Argentina mendebaldeko udako ordutegia", "CLT": "Txileko ordu estandarra", "PST": "Ipar Amerikako Pazifikoko ordutegi estandarra", "HAST": "Hawaii-Aleutiar uharteetako ordutegi estandarra", "CLST": "Txileko udako ordua", "TMST": "Turkmenistango udako ordua", "CST": "Ipar Amerikako erdialdeko ordu estandarra", "CHAST": "Chathamgo ordu estandarra", "VET": "Venezuelako ordua", "LHST": "Lord Howeko ordu estandarra", "HNCU": "Kubako ordutegi estandarra", "ACWST": "Australia erdi-mendebaldeko ordu estandarra", "MDT": "MDT", "HAT": "Ternuako udako ordutegia", "∅∅∅": "Amazoniako udako ordutegia", "HKT": "Hong Kongo ordu estandarra", "ACDT": "Australia erdialdeko udako ordua", "GFT": "Guyana Frantseseko ordua", "AWST": "Australia mendebaldeko ordu estandarra", "ACWDT": "Australia erdi-mendebaldeko udako ordua", "HKST": "Hong Kongo udako ordua", "HENOMX": "Mexikoko ipar-ekialdeko udako ordutegia", "AKDT": "Alaskako udako ordutegia", "LHDT": "Lord Howeko udako ordua", "NZST": "Zeelanda Berriko ordu estandarra", "WAT": "Afrika mendebaldeko ordu estandarra", "COT": "Kolonbiako ordu estandarra", "HNT": "Ternuako ordutegi estandarra", "WITA": "Indonesia erdialdeko ordua", "HNPM": "Saint-Pierre eta Mikeluneko ordutegi estandarra", "HADT": "Hawaii-Aleutiar uharteetako udako ordutegia", "HEOG": "Groenlandia mendebaldeko udako ordutegia", "GMT": "Greenwich meridianoko ordua", "HNEG": "Groenlandia ekialdeko ordutegi estandarra", "AEDT": "Australia ekialdeko udako ordua", "JST": "Japoniako ordu estandarra", "JDT": "Japoniako udako ordua", "TMT": "Turkmenistango ordu estandarra", "AEST": "Australia ekialdeko ordu estandarra", "IST": "Indiako ordua", "EDT": "Ipar Amerikako ekialdeko udako ordutegia", "SAST": "Afrika hegoaldeko ordua", "SRT": "Surinamgo ordua", "CDT": "Ipar Amerikako erdialdeko udako ordutegia", "AWDT": "Australia mendebaldeko udako ordua", "CHADT": "Chathamgo udako ordua", "HNNOMX": "Mexikoko ipar-ekialdeko ordutegi estandarra", "AKST": "Alaskako ordutegi estandarra"}, + } +} + +// Locale returns the current translators string locale +func (eu *eu) Locale() string { + return eu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'eu' +func (eu *eu) PluralsCardinal() []locales.PluralRule { + return eu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'eu' +func (eu *eu) PluralsOrdinal() []locales.PluralRule { + return eu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'eu' +func (eu *eu) PluralsRange() []locales.PluralRule { + return eu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'eu' +func (eu *eu) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'eu' +func (eu *eu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'eu' +func (eu *eu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (eu *eu) MonthAbbreviated(month time.Month) string { + return eu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (eu *eu) MonthsAbbreviated() []string { + return eu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (eu *eu) MonthNarrow(month time.Month) string { + return eu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (eu *eu) MonthsNarrow() []string { + return eu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (eu *eu) MonthWide(month time.Month) string { + return eu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (eu *eu) MonthsWide() []string { + return eu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (eu *eu) WeekdayAbbreviated(weekday time.Weekday) string { + return eu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (eu *eu) WeekdaysAbbreviated() []string { + return eu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (eu *eu) WeekdayNarrow(weekday time.Weekday) string { + return eu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (eu *eu) WeekdaysNarrow() []string { + return eu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (eu *eu) WeekdayShort(weekday time.Weekday) string { + return eu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (eu *eu) WeekdaysShort() []string { + return eu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (eu *eu) WeekdayWide(weekday time.Weekday) string { + return eu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (eu *eu) WeekdaysWide() []string { + return eu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'eu' and handles both Whole and Real numbers based on 'v' +func (eu *eu) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, eu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'eu' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (eu *eu) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eu.decimal[0]) + inWhole = true + + continue + } + + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, eu.minus[0]) + } + + for j := len(eu.percentPrefix) - 1; j >= 0; j-- { + b = append(b, eu.percentPrefix[j]) + } + + b = append(b, eu.percent[0]) + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'eu' +func (eu *eu) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := eu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, eu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, eu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, eu.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'eu' +// in accounting notation. +func (eu *eu) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := eu.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, eu.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, eu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, eu.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, eu.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'eu' +func (eu *eu) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'eu' +func (eu *eu) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, eu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'eu' +func (eu *eu) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x28, 0x65}...) + b = append(b, []byte{0x29, 0x6b, 0x6f}...) + b = append(b, []byte{0x20}...) + b = append(b, eu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'eu' +func (eu *eu) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x28, 0x65}...) + b = append(b, []byte{0x29, 0x6b, 0x6f}...) + b = append(b, []byte{0x20}...) + b = append(b, eu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, eu.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'eu' +func (eu *eu) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'eu' +func (eu *eu) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'eu' +func (eu *eu) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'eu' +func (eu *eu) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := eu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/eu/eu_test.go b/vendor/github.com/go-playground/locales/eu/eu_test.go new file mode 100644 index 0000000000..457bae3ffc --- /dev/null +++ b/vendor/github.com/go-playground/locales/eu/eu_test.go @@ -0,0 +1,1120 @@ +package eu + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "eu" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/eu/ue_test.go b/vendor/github.com/go-playground/locales/eu/ue_test.go new file mode 100644 index 0000000000..c431979224 --- /dev/null +++ b/vendor/github.com/go-playground/locales/eu/ue_test.go @@ -0,0 +1,42 @@ +package eu + +import "testing" + +func TestPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + { + num: 23, + v: 0, + expected: "%\u00a023", + }, + { + num: 23.45, + v: 2, + expected: "%\u00a023,45", + }, + { + num: 1023.45, + v: 2, + expected: "%\u00a01.023,45", + }, + { + num: -1023.45, + v: 2, + expected: "%\u00a0-1.023,45", + }, + } + + trans := New() + + for _, tt := range tests { + s := string(trans.FmtPercent(tt.num, tt.v)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/eu_ES/eu_ES.go b/vendor/github.com/go-playground/locales/eu_ES/eu_ES.go new file mode 100644 index 0000000000..de496212ec --- /dev/null +++ b/vendor/github.com/go-playground/locales/eu_ES/eu_ES.go @@ -0,0 +1,607 @@ +package eu_ES + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type eu_ES struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentPrefix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'eu_ES' locale +func New() locales.Translator { + return &eu_ES{ + locale: "eu_ES", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentPrefix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "urt.", "ots.", "mar.", "api.", "mai.", "eka.", "uzt.", "abu.", "ira.", "urr.", "aza.", "abe."}, + monthsNarrow: []string{"", "U", "O", "M", "A", "M", "E", "U", "A", "I", "U", "A", "A"}, + monthsWide: []string{"", "urtarrila", "otsaila", "martxoa", "apirila", "maiatza", "ekaina", "uztaila", "abuztua", "iraila", "urria", "azaroa", "abendua"}, + daysAbbreviated: []string{"ig.", "al.", "ar.", "az.", "og.", "or.", "lr."}, + daysNarrow: []string{"I", "A", "A", "A", "O", "O", "L"}, + daysShort: []string{"ig.", "al.", "ar.", "az.", "og.", "or.", "lr."}, + daysWide: []string{"igandea", "astelehena", "asteartea", "asteazkena", "osteguna", "ostirala", "larunbata"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"g", "a"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"K.a.", "K.o."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"K.a.", "Kristo ondoren"}, + timezones: map[string]string{"AKST": "Alaskako ordutegi estandarra", "ChST": "Chamorroko ordu estandarra", "LHST": "Lord Howeko ordu estandarra", "IST": "Indiako ordua", "OEZ": "Europa ekialdeko ordu estandarra", "GFT": "Guyana Frantseseko ordua", "HENOMX": "Mexikoko ipar-ekialdeko udako ordutegia", "LHDT": "Lord Howeko udako ordua", "HKST": "Hong Kongo udako ordua", "HNNOMX": "Mexikoko ipar-ekialdeko ordutegi estandarra", "COST": "Kolonbiako udako ordua", "ACWDT": "Australia erdi-mendebaldeko udako ordua", "WAT": "Afrika mendebaldeko ordu estandarra", "SRT": "Surinamgo ordua", "GYT": "Guyanako ordua", "WIB": "Indonesia mendebaldeko ordua", "CHAST": "Chathamgo ordu estandarra", "WART": "Argentina mendebaldeko ordutegia estandarra", "MDT": "MDT", "HNCU": "Kubako ordutegi estandarra", "PST": "Ipar Amerikako Pazifikoko ordutegi estandarra", "HNT": "Ternuako ordutegi estandarra", "HAT": "Ternuako udako ordutegia", "AWDT": "Australia mendebaldeko udako ordua", "CHADT": "Chathamgo udako ordua", "HNOG": "Groenlandia mendebaldeko ordutegi estandarra", "HEOG": "Groenlandia mendebaldeko udako ordutegia", "HECU": "Kubako udako ordutegia", "WESZ": "Europa mendebaldeko udako ordua", "ACST": "Australia erdialdeko ordu estandarra", "HNPMX": "Mexikoko Pazifikoko ordutegi estandarra", "AWST": "Australia mendebaldeko ordu estandarra", "SGT": "Singapurreko ordu estandarra", "CAT": "Afrika erdialdeko ordua", "MEZ": "Europa erdialdeko ordu estandarra", "WEZ": "Europa mendebaldeko ordu estandarra", "HEEG": "Groenlandia ekialdeko udako ordutegia", "WITA": "Indonesia erdialdeko ordua", "HEPM": "Saint-Pierre eta Mikeluneko udako ordutegia", "MESZ": "Europa erdialdeko udako ordua", "TMST": "Turkmenistango udako ordua", "HEPMX": "Mexikoko Pazifikoko udako ordutegia", "HADT": "Hawaii-Aleutiar uharteetako udako ordutegia", "JST": "Japoniako ordu estandarra", "ARST": "Argentinako udako ordutegia", "UYT": "Uruguayko ordu estandarra", "EAT": "Afrika ekialdeko ordua", "CST": "Ipar Amerikako erdialdeko ordu estandarra", "HAST": "Hawaii-Aleutiar uharteetako ordutegi estandarra", "ACWST": "Australia erdi-mendebaldeko ordu estandarra", "OESZ": "Europa ekialdeko udako ordua", "HKT": "Hong Kongo ordu estandarra", "∅∅∅": "Peruko udako ordua", "AKDT": "Alaskako udako ordutegia", "WIT": "Indonesia ekialdeko ordua", "ECT": "Ekuadorreko ordua", "WARST": "Argentina mendebaldeko udako ordutegia", "BT": "Bhutango ordua", "EST": "Ipar Amerikako ekialdeko ordutegi estandarra", "AST": "Atlantikoko ordutegi estandarra", "GMT": "Greenwich meridianoko ordua", "TMT": "Turkmenistango ordu estandarra", "AEDT": "Australia ekialdeko udako ordua", "UYST": "Uruguayko udako ordua", "HNPM": "Saint-Pierre eta Mikeluneko ordutegi estandarra", "JDT": "Japoniako udako ordua", "CLT": "Txileko ordu estandarra", "CDT": "Ipar Amerikako erdialdeko udako ordutegia", "NZDT": "Zeelanda Berriko udako ordua", "ART": "Argentinako ordutegi estandarra", "EDT": "Ipar Amerikako ekialdeko udako ordutegia", "COT": "Kolonbiako ordu estandarra", "HNEG": "Groenlandia ekialdeko ordutegi estandarra", "AEST": "Australia ekialdeko ordu estandarra", "PDT": "Ipar Amerikako Pazifikoko udako ordutegia", "VET": "Venezuelako ordua", "MYT": "Malaysiako ordua", "MST": "MST", "WAST": "Afrika mendebaldeko udako ordua", "ACDT": "Australia erdialdeko udako ordua", "SAST": "Afrika hegoaldeko ordua", "BOT": "Boliviako ordutegia", "NZST": "Zeelanda Berriko ordu estandarra", "CLST": "Txileko udako ordua", "ADT": "Atlantikoko udako ordutegia"}, + } +} + +// Locale returns the current translators string locale +func (eu *eu_ES) Locale() string { + return eu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'eu_ES' +func (eu *eu_ES) PluralsCardinal() []locales.PluralRule { + return eu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'eu_ES' +func (eu *eu_ES) PluralsOrdinal() []locales.PluralRule { + return eu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'eu_ES' +func (eu *eu_ES) PluralsRange() []locales.PluralRule { + return eu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'eu_ES' +func (eu *eu_ES) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'eu_ES' +func (eu *eu_ES) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'eu_ES' +func (eu *eu_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (eu *eu_ES) MonthAbbreviated(month time.Month) string { + return eu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (eu *eu_ES) MonthsAbbreviated() []string { + return eu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (eu *eu_ES) MonthNarrow(month time.Month) string { + return eu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (eu *eu_ES) MonthsNarrow() []string { + return eu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (eu *eu_ES) MonthWide(month time.Month) string { + return eu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (eu *eu_ES) MonthsWide() []string { + return eu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (eu *eu_ES) WeekdayAbbreviated(weekday time.Weekday) string { + return eu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (eu *eu_ES) WeekdaysAbbreviated() []string { + return eu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (eu *eu_ES) WeekdayNarrow(weekday time.Weekday) string { + return eu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (eu *eu_ES) WeekdaysNarrow() []string { + return eu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (eu *eu_ES) WeekdayShort(weekday time.Weekday) string { + return eu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (eu *eu_ES) WeekdaysShort() []string { + return eu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (eu *eu_ES) WeekdayWide(weekday time.Weekday) string { + return eu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (eu *eu_ES) WeekdaysWide() []string { + return eu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'eu_ES' and handles both Whole and Real numbers based on 'v' +func (eu *eu_ES) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, eu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'eu_ES' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (eu *eu_ES) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eu.decimal[0]) + inWhole = true + + continue + } + + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, eu.minus[0]) + } + + for j := len(eu.percentPrefix) - 1; j >= 0; j-- { + b = append(b, eu.percentPrefix[j]) + } + + b = append(b, eu.percent[0]) + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'eu_ES' +func (eu *eu_ES) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := eu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, eu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, eu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, eu.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'eu_ES' +// in accounting notation. +func (eu *eu_ES) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := eu.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, eu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, eu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, eu.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, eu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, eu.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, eu.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'eu_ES' +func (eu *eu_ES) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'eu_ES' +func (eu *eu_ES) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, eu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'eu_ES' +func (eu *eu_ES) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x28, 0x65}...) + b = append(b, []byte{0x29, 0x6b, 0x6f}...) + b = append(b, []byte{0x20}...) + b = append(b, eu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'eu_ES' +func (eu *eu_ES) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x28, 0x65}...) + b = append(b, []byte{0x29, 0x6b, 0x6f}...) + b = append(b, []byte{0x20}...) + b = append(b, eu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, eu.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'eu_ES' +func (eu *eu_ES) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'eu_ES' +func (eu *eu_ES) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'eu_ES' +func (eu *eu_ES) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'eu_ES' +func (eu *eu_ES) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, eu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, eu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := eu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/eu_ES/eu_ES_test.go b/vendor/github.com/go-playground/locales/eu_ES/eu_ES_test.go new file mode 100644 index 0000000000..85f0e3fee1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/eu_ES/eu_ES_test.go @@ -0,0 +1,1120 @@ +package eu_ES + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "eu_ES" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ewo/ewo.go b/vendor/github.com/go-playground/locales/ewo/ewo.go new file mode 100644 index 0000000000..7eb519aa2e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ewo/ewo.go @@ -0,0 +1,571 @@ +package ewo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ewo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ewo' locale +func New() locales.Translator { + return &ewo{ + locale: "ewo", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ngo", "ngb", "ngl", "ngn", "ngt", "ngs", "ngz", "ngm", "nge", "nga", "ngad", "ngab"}, + monthsNarrow: []string{"", "o", "b", "l", "n", "t", "s", "z", "m", "e", "a", "d", "b"}, + monthsWide: []string{"", "ngɔn osú", "ngɔn bɛ̌", "ngɔn lála", "ngɔn nyina", "ngɔn tána", "ngɔn saməna", "ngɔn zamgbála", "ngɔn mwom", "ngɔn ebulú", "ngɔn awóm", "ngɔn awóm ai dziá", "ngɔn awóm ai bɛ̌"}, + daysAbbreviated: []string{"sɔ́n", "mɔ́n", "smb", "sml", "smn", "fúl", "sér"}, + daysNarrow: []string{"s", "m", "s", "s", "s", "f", "s"}, + daysWide: []string{"sɔ́ndɔ", "mɔ́ndi", "sɔ́ndɔ məlú mə́bɛ̌", "sɔ́ndɔ məlú mə́lɛ́", "sɔ́ndɔ məlú mə́nyi", "fúladé", "séradé"}, + periodsAbbreviated: []string{"kíkíríg", "ngəgógəle"}, + periodsWide: []string{"kíkíríg", "ngəgógəle"}, + erasAbbreviated: []string{"oyk", "ayk"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"osúsúa Yésus kiri", "ámvus Yésus Kirís"}, + timezones: map[string]string{"COT": "COT", "ChST": "ChST", "SAST": "SAST", "AWST": "AWST", "HENOMX": "HENOMX", "HNPMX": "HNPMX", "EST": "EST", "ACDT": "ACDT", "WESZ": "WESZ", "HEOG": "HEOG", "HEPM": "HEPM", "CHADT": "CHADT", "ACWST": "ACWST", "HKST": "HKST", "HEPMX": "HEPMX", "WITA": "WITA", "AKST": "AKST", "EAT": "EAT", "SGT": "SGT", "WAST": "WAST", "TMST": "TMST", "BT": "BT", "UYT": "UYT", "LHST": "LHST", "HECU": "HECU", "CHAST": "CHAST", "WART": "WART", "JDT": "JDT", "HNOG": "HNOG", "AST": "AST", "EDT": "EDT", "HNEG": "HNEG", "GYT": "GYT", "AWDT": "AWDT", "PST": "PST", "CDT": "CDT", "MYT": "MYT", "ART": "ART", "ARST": "ARST", "HAST": "HAST", "MESZ": "MESZ", "∅∅∅": "∅∅∅", "GMT": "GMT", "HKT": "HKT", "ACST": "ACST", "UYST": "UYST", "WIB": "WIB", "PDT": "PDT", "ACWDT": "ACWDT", "MDT": "MDT", "WIT": "WIT", "WEZ": "WEZ", "MST": "MST", "OEZ": "OEZ", "HEEG": "HEEG", "CST": "CST", "WARST": "WARST", "CLT": "CLT", "ADT": "ADT", "HNT": "HNT", "SRT": "SRT", "HADT": "HADT", "CAT": "CAT", "NZDT": "NZDT", "MEZ": "MEZ", "VET": "VET", "TMT": "TMT", "BOT": "BOT", "ECT": "ECT", "HNNOMX": "HNNOMX", "COST": "COST", "HAT": "HAT", "AEST": "AEST", "GFT": "GFT", "LHDT": "LHDT", "NZST": "NZST", "JST": "JST", "HNPM": "HNPM", "CLST": "CLST", "AKDT": "AKDT", "WAT": "WAT", "AEDT": "AEDT", "HNCU": "HNCU", "IST": "IST", "OESZ": "OESZ"}, + } +} + +// Locale returns the current translators string locale +func (ewo *ewo) Locale() string { + return ewo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ewo' +func (ewo *ewo) PluralsCardinal() []locales.PluralRule { + return ewo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ewo' +func (ewo *ewo) PluralsOrdinal() []locales.PluralRule { + return ewo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ewo' +func (ewo *ewo) PluralsRange() []locales.PluralRule { + return ewo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ewo' +func (ewo *ewo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ewo' +func (ewo *ewo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ewo' +func (ewo *ewo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ewo *ewo) MonthAbbreviated(month time.Month) string { + return ewo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ewo *ewo) MonthsAbbreviated() []string { + return ewo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ewo *ewo) MonthNarrow(month time.Month) string { + return ewo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ewo *ewo) MonthsNarrow() []string { + return ewo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ewo *ewo) MonthWide(month time.Month) string { + return ewo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ewo *ewo) MonthsWide() []string { + return ewo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ewo *ewo) WeekdayAbbreviated(weekday time.Weekday) string { + return ewo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ewo *ewo) WeekdaysAbbreviated() []string { + return ewo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ewo *ewo) WeekdayNarrow(weekday time.Weekday) string { + return ewo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ewo *ewo) WeekdaysNarrow() []string { + return ewo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ewo *ewo) WeekdayShort(weekday time.Weekday) string { + return ewo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ewo *ewo) WeekdaysShort() []string { + return ewo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ewo *ewo) WeekdayWide(weekday time.Weekday) string { + return ewo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ewo *ewo) WeekdaysWide() []string { + return ewo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ewo' and handles both Whole and Real numbers based on 'v' +func (ewo *ewo) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ewo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ewo.group) - 1; j >= 0; j-- { + b = append(b, ewo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ewo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ewo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ewo *ewo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ewo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ewo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ewo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ewo' +func (ewo *ewo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ewo.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ewo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ewo.group) - 1; j >= 0; j-- { + b = append(b, ewo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ewo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ewo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ewo.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ewo' +// in accounting notation. +func (ewo *ewo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ewo.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ewo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ewo.group) - 1; j >= 0; j-- { + b = append(b, ewo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ewo.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ewo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ewo.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ewo.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ewo' +func (ewo *ewo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ewo' +func (ewo *ewo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ewo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ewo' +func (ewo *ewo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ewo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ewo' +func (ewo *ewo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ewo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ewo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ewo' +func (ewo *ewo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ewo' +func (ewo *ewo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ewo' +func (ewo *ewo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ewo' +func (ewo *ewo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ewo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ewo/ewo_test.go b/vendor/github.com/go-playground/locales/ewo/ewo_test.go new file mode 100644 index 0000000000..0aabd74ec8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ewo/ewo_test.go @@ -0,0 +1,1120 @@ +package ewo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ewo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ewo_CM/ewo_CM.go b/vendor/github.com/go-playground/locales/ewo_CM/ewo_CM.go new file mode 100644 index 0000000000..99f68121d3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ewo_CM/ewo_CM.go @@ -0,0 +1,571 @@ +package ewo_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ewo_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ewo_CM' locale +func New() locales.Translator { + return &ewo_CM{ + locale: "ewo_CM", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ngo", "ngb", "ngl", "ngn", "ngt", "ngs", "ngz", "ngm", "nge", "nga", "ngad", "ngab"}, + monthsNarrow: []string{"", "o", "b", "l", "n", "t", "s", "z", "m", "e", "a", "d", "b"}, + monthsWide: []string{"", "ngɔn osú", "ngɔn bɛ̌", "ngɔn lála", "ngɔn nyina", "ngɔn tána", "ngɔn saməna", "ngɔn zamgbála", "ngɔn mwom", "ngɔn ebulú", "ngɔn awóm", "ngɔn awóm ai dziá", "ngɔn awóm ai bɛ̌"}, + daysAbbreviated: []string{"sɔ́n", "mɔ́n", "smb", "sml", "smn", "fúl", "sér"}, + daysNarrow: []string{"s", "m", "s", "s", "s", "f", "s"}, + daysWide: []string{"sɔ́ndɔ", "mɔ́ndi", "sɔ́ndɔ məlú mə́bɛ̌", "sɔ́ndɔ məlú mə́lɛ́", "sɔ́ndɔ məlú mə́nyi", "fúladé", "séradé"}, + periodsAbbreviated: []string{"kíkíríg", "ngəgógəle"}, + periodsWide: []string{"kíkíríg", "ngəgógəle"}, + erasAbbreviated: []string{"oyk", "ayk"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"osúsúa Yésus kiri", "ámvus Yésus Kirís"}, + timezones: map[string]string{"HAT": "HAT", "AWST": "AWST", "WARST": "WARST", "MDT": "MDT", "WAT": "WAT", "HKST": "HKST", "ACDT": "ACDT", "AKDT": "AKDT", "GYT": "GYT", "JST": "JST", "HNT": "HNT", "GFT": "GFT", "SAST": "SAST", "HNCU": "HNCU", "CHADT": "CHADT", "HADT": "HADT", "OEZ": "OEZ", "OESZ": "OESZ", "WEZ": "WEZ", "BOT": "BOT", "CAT": "CAT", "WART": "WART", "WESZ": "WESZ", "WAST": "WAST", "COST": "COST", "HEPM": "HEPM", "CDT": "CDT", "CHAST": "CHAST", "TMST": "TMST", "ART": "ART", "WITA": "WITA", "ChST": "ChST", "WIB": "WIB", "PST": "PST", "MYT": "MYT", "AST": "AST", "HKT": "HKT", "HNEG": "HNEG", "HECU": "HECU", "PDT": "PDT", "JDT": "JDT", "CLT": "CLT", "COT": "COT", "AKST": "AKST", "ECT": "ECT", "NZDT": "NZDT", "ACWDT": "ACWDT", "CLST": "CLST", "ACST": "ACST", "HNNOMX": "HNNOMX", "HEPMX": "HEPMX", "VET": "VET", "∅∅∅": "∅∅∅", "HEEG": "HEEG", "AEST": "AEST", "AEDT": "AEDT", "HNPM": "HNPM", "HNOG": "HNOG", "EAT": "EAT", "AWDT": "AWDT", "IST": "IST", "MESZ": "MESZ", "NZST": "NZST", "GMT": "GMT", "EDT": "EDT", "LHST": "LHST", "LHDT": "LHDT", "HNPMX": "HNPMX", "CST": "CST", "SGT": "SGT", "ADT": "ADT", "BT": "BT", "UYT": "UYT", "UYST": "UYST", "SRT": "SRT", "HEOG": "HEOG", "TMT": "TMT", "ARST": "ARST", "EST": "EST", "HENOMX": "HENOMX", "HAST": "HAST", "MEZ": "MEZ", "MST": "MST", "WIT": "WIT", "ACWST": "ACWST"}, + } +} + +// Locale returns the current translators string locale +func (ewo *ewo_CM) Locale() string { + return ewo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ewo_CM' +func (ewo *ewo_CM) PluralsCardinal() []locales.PluralRule { + return ewo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ewo_CM' +func (ewo *ewo_CM) PluralsOrdinal() []locales.PluralRule { + return ewo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ewo_CM' +func (ewo *ewo_CM) PluralsRange() []locales.PluralRule { + return ewo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ewo_CM' +func (ewo *ewo_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ewo_CM' +func (ewo *ewo_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ewo_CM' +func (ewo *ewo_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ewo *ewo_CM) MonthAbbreviated(month time.Month) string { + return ewo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ewo *ewo_CM) MonthsAbbreviated() []string { + return ewo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ewo *ewo_CM) MonthNarrow(month time.Month) string { + return ewo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ewo *ewo_CM) MonthsNarrow() []string { + return ewo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ewo *ewo_CM) MonthWide(month time.Month) string { + return ewo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ewo *ewo_CM) MonthsWide() []string { + return ewo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ewo *ewo_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return ewo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ewo *ewo_CM) WeekdaysAbbreviated() []string { + return ewo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ewo *ewo_CM) WeekdayNarrow(weekday time.Weekday) string { + return ewo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ewo *ewo_CM) WeekdaysNarrow() []string { + return ewo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ewo *ewo_CM) WeekdayShort(weekday time.Weekday) string { + return ewo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ewo *ewo_CM) WeekdaysShort() []string { + return ewo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ewo *ewo_CM) WeekdayWide(weekday time.Weekday) string { + return ewo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ewo *ewo_CM) WeekdaysWide() []string { + return ewo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ewo_CM' and handles both Whole and Real numbers based on 'v' +func (ewo *ewo_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ewo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ewo.group) - 1; j >= 0; j-- { + b = append(b, ewo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ewo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ewo_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ewo *ewo_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ewo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ewo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ewo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ewo_CM' +func (ewo *ewo_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ewo.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ewo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ewo.group) - 1; j >= 0; j-- { + b = append(b, ewo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ewo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ewo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ewo.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ewo_CM' +// in accounting notation. +func (ewo *ewo_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ewo.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ewo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ewo.group) - 1; j >= 0; j-- { + b = append(b, ewo.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ewo.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ewo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ewo.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ewo.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ewo_CM' +func (ewo *ewo_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ewo_CM' +func (ewo *ewo_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ewo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ewo_CM' +func (ewo *ewo_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ewo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ewo_CM' +func (ewo *ewo_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ewo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ewo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ewo_CM' +func (ewo *ewo_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ewo_CM' +func (ewo *ewo_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ewo_CM' +func (ewo *ewo_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ewo_CM' +func (ewo *ewo_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ewo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ewo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ewo_CM/ewo_CM_test.go b/vendor/github.com/go-playground/locales/ewo_CM/ewo_CM_test.go new file mode 100644 index 0000000000..d202e12dff --- /dev/null +++ b/vendor/github.com/go-playground/locales/ewo_CM/ewo_CM_test.go @@ -0,0 +1,1120 @@ +package ewo_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ewo_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fa/fa.go b/vendor/github.com/go-playground/locales/fa/fa.go new file mode 100644 index 0000000000..8781c13319 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fa/fa.go @@ -0,0 +1,602 @@ +package fa + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fa struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fa' locale +func New() locales.Translator { + return &fa{ + locale: "fa", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: "٫", + group: "٬", + minus: "‎−", + percent: "‎٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "؋", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "$CA", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "¥CN", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "$HK", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "ریال", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "$MX", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$NZ", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "$EC", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: "‎", + currencyNegativePrefix: "‎", + monthsAbbreviated: []string{"", "ژانویهٔ", "فوریهٔ", "مارس", "آوریل", "مهٔ", "ژوئن", "ژوئیهٔ", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"}, + monthsNarrow: []string{"", "ژ", "ف", "م", "آ", "م", "ژ", "ژ", "ا", "س", "ا", "ن", "د"}, + monthsWide: []string{"", "ژانویهٔ", "فوریهٔ", "مارس", "آوریل", "مهٔ", "ژوئن", "ژوئیهٔ", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"}, + daysAbbreviated: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + daysNarrow: []string{"ی", "د", "س", "چ", "پ", "ج", "ش"}, + daysShort: []string{"۱ش", "۲ش", "۳ش", "۴ش", "۵ش", "ج", "ش"}, + daysWide: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + periodsAbbreviated: []string{"ق.ظ.", "ب.ظ."}, + periodsNarrow: []string{"ق", "ب"}, + periodsWide: []string{"قبل\u200cازظهر", "بعدازظهر"}, + erasAbbreviated: []string{"ق.م.", "م."}, + erasNarrow: []string{"ق", "م"}, + erasWide: []string{"قبل از میلاد", "میلادی"}, + timezones: map[string]string{"EAT": "وقت شرق افریقا", "AWST": "وقت عادی غرب استرالیا", "CAT": "وقت مرکز افریقا", "ADT": "وقت تابستانی آتلانتیک", "HKST": "وقت تابستانی هنگ\u200cکنگ", "NZST": "وقت عادی زلاند نو", "EDT": "وقت تابستانی شرق امریکا", "AKST": "وقت عادی آلاسکا", "SRT": "وقت سورینام", "JST": "وقت عادی ژاپن", "HNPMX": "وقت عادی شرق مکزیک", "HECU": "وقت تابستانی کوبا", "NZDT": "وقت تابستانی زلاند نو", "AEST": "وقت عادی شرق استرالیا", "MEZ": "وقت عادی مرکز اروپا", "VET": "وقت ونزوئلا", "AST": "وقت عادی آتلانتیک", "HNEG": "وقت عادی شرق گرینلند", "HNPM": "وقت عادی سنت\u200cپیر و میکلون", "PDT": "وقت تابستانی غرب امریکا", "IST": "وقت هند", "HEEG": "وقت تابستانی شرق گرینلند", "AKDT": "وقت تابستانی آلاسکا", "UYST": "وقت تابستانی اروگوئه", "HNT": "وقت عادی نیوفاندلند", "∅∅∅": "وقت تابستانی آزور", "LHDT": "وقت تابستانی لردهو", "MYT": "وقت مالزی", "WART": "وقت عادی غرب آرژانتین", "WEZ": "وقت عادی غرب اروپا", "WESZ": "وقت تابستانی غرب اروپا", "ART": "وقت عادی آرژانتین", "HEPM": "وقت تابستانی سنت\u200cپیر و میکلون", "CHAST": "وقت عادی چت\u200cهام", "SGT": "وقت سنگاپور", "MESZ": "وقت تابستانی مرکز اروپا", "ARST": "وقت تابستانی آرژانتین", "GFT": "وقت گویان فرانسه", "HAST": "وقت عادی هاوایی‐الوشن", "WARST": "وقت تابستانی غرب آرژانتین", "CLST": "وقت تابستانی شیلی", "EST": "وقت عادی شرق امریکا", "BT": "وقت بوتان", "HNOG": "وقت عادی غرب گرینلند", "GMT": "وقت گرینویچ", "BOT": "وقت بولیوی", "ACWST": "وقت عادی مرکز-غرب استرالیا", "ChST": "وقت عادی چامورو", "CLT": "وقت عادی شیلی", "GYT": "وقت گویان", "WIB": "وقت غرب اندونزی", "CDT": "وقت تابستانی مرکز امریکا", "AWDT": "وقت تابستانی غرب استرالیا", "PST": "وقت عادی غرب امریکا", "ACWDT": "وقت تابستانی مرکز-غرب استرالیا", "JDT": "وقت تابستانی ژاپن", "MDT": "وقت تابستانی ماکائو", "HNNOMX": "وقت عادی شمال غرب مکزیک", "HENOMX": "وقت تابستانی شمال غرب مکزیک", "UYT": "وقت عادی اروگوئه", "CST": "وقت عادی مرکز امریکا", "TMT": "وقت عادی ترکمنستان", "WAT": "وقت عادی غرب افریقا", "ACDT": "وقت تابستانی مرکز استرالیا", "HAT": "وقت تابستانی نیوفاندلند", "MST": "وقت عادی ماکائو", "HKT": "وقت عادی هنگ\u200cکنگ", "COST": "وقت تابستانی کلمبیا", "WITA": "وقت مرکز اندونزی", "TMST": "وقت تابستانی ترکمنستان", "SAST": "وقت عادی جنوب افریقا", "LHST": "وقت عادی لردهو", "HEPMX": "وقت تابستانی شرق مکزیک", "WIT": "وقت شرق اندونزی", "CHADT": "وقت تابستانی چت\u200cهام", "OEZ": "وقت عادی شرق اروپا", "OESZ": "وقت تابستانی شرق اروپا", "WAST": "وقت تابستانی غرب افریقا", "ACST": "وقت عادی مرکز استرالیا", "AEDT": "وقت تابستانی شرق استرالیا", "HNCU": "وقت عادی کوبا", "ECT": "وقت اکوادور", "HADT": "وقت تابستانی هاوایی‐الوشن", "HEOG": "وقت تابستانی غرب گرینلند", "COT": "وقت عادی کلمبیا"}, + } +} + +// Locale returns the current translators string locale +func (fa *fa) Locale() string { + return fa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fa' +func (fa *fa) PluralsCardinal() []locales.PluralRule { + return fa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fa' +func (fa *fa) PluralsOrdinal() []locales.PluralRule { + return fa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fa' +func (fa *fa) PluralsRange() []locales.PluralRule { + return fa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fa' +func (fa *fa) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fa' +func (fa *fa) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fa' +func (fa *fa) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fa *fa) MonthAbbreviated(month time.Month) string { + return fa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fa *fa) MonthsAbbreviated() []string { + return fa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fa *fa) MonthNarrow(month time.Month) string { + return fa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fa *fa) MonthsNarrow() []string { + return fa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fa *fa) MonthWide(month time.Month) string { + return fa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fa *fa) MonthsWide() []string { + return fa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fa *fa) WeekdayAbbreviated(weekday time.Weekday) string { + return fa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fa *fa) WeekdaysAbbreviated() []string { + return fa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fa *fa) WeekdayNarrow(weekday time.Weekday) string { + return fa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fa *fa) WeekdaysNarrow() []string { + return fa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fa *fa) WeekdayShort(weekday time.Weekday) string { + return fa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fa *fa) WeekdaysShort() []string { + return fa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fa *fa) WeekdayWide(weekday time.Weekday) string { + return fa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fa *fa) WeekdaysWide() []string { + return fa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fa' and handles both Whole and Real numbers based on 'v' +func (fa *fa) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 8 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fa' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fa *fa) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 13 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fa.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fa' +func (fa *fa) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fa.currencies[currency] + l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fa' +// in accounting notation. +func (fa *fa) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fa.currencies[currency] + l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyNegativePrefix[j]) + } + + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fa' +func (fa *fa) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fa' +func (fa *fa) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fa' +func (fa *fa) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fa' +func (fa *fa) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fa' +func (fa *fa) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fa' +func (fa *fa) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fa' +func (fa *fa) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fa' +func (fa *fa) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := fa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fa/fa_test.go b/vendor/github.com/go-playground/locales/fa/fa_test.go new file mode 100644 index 0000000000..6131628ea0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fa/fa_test.go @@ -0,0 +1,1120 @@ +package fa + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fa" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fa_AF/fa_AF.go b/vendor/github.com/go-playground/locales/fa_AF/fa_AF.go new file mode 100644 index 0000000000..3c5ccc58c8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fa_AF/fa_AF.go @@ -0,0 +1,602 @@ +package fa_AF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fa_AF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fa_AF' locale +func New() locales.Translator { + return &fa_AF{ + locale: "fa_AF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: "٫", + group: "٬", + minus: "‎−", + percent: "‎٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "جنو", "فبروری", "مارچ", "اپریل", "می", "جون", "جول", "اگست", "سپتمبر", "اکتوبر", "نومبر", "دسم"}, + monthsNarrow: []string{"", "ج", "ف", "م", "ا", "م", "ج", "ج", "ا", "س", "ا", "ن", "د"}, + monthsWide: []string{"", "جنوری", "فبروری", "مارچ", "اپریل", "می", "جون", "جولای", "اگست", "سپتمبر", "اکتوبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + daysNarrow: []string{"ی", "د", "س", "چ", "پ", "ج", "ش"}, + daysShort: []string{"۱ش", "۲ش", "۳ش", "۴ش", "۵ش", "ج", "ش"}, + daysWide: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + periodsAbbreviated: []string{"", ""}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"", ""}, + erasAbbreviated: []string{"ق.م.", "م."}, + erasNarrow: []string{"ق", "م"}, + erasWide: []string{"قبل از میلاد", "میلادی"}, + timezones: map[string]string{"NZDT": "وقت تابستانی زلاند نو", "OESZ": "وقت تابستانی شرق اروپا", "GMT": "وقت گرینویچ", "EST": "وقت عادی شرق امریکا", "PST": "وقت عادی غرب امریکا", "HNOG": "وقت عادی غرب گرینلند", "UYT": "وقت عادی اروگوئه", "UYST": "وقت تابستانی اروگوئه", "HEPM": "وقت تابستانی سنت\u200cپیر و میکلون", "HECU": "وقت تابستانی کوبا", "MDT": "وقت تابستانی ماکائو", "EDT": "وقت تابستانی شرق امریکا", "HNNOMX": "وقت عادی شمال غرب مکزیک", "BT": "وقت بوتان", "WESZ": "وقت تابستانی غرب اروپا", "HENOMX": "وقت تابستانی شمال غرب مکزیک", "AEST": "وقت عادی شرق استرالیا", "AEDT": "وقت تابستانی شرق استرالیا", "SAST": "وقت عادی جنوب افریقا", "BOT": "وقت بولیوی", "HAST": "وقت عادی هاوایی‐الوشن", "HADT": "وقت تابستانی هاوایی‐الوشن", "TMT": "وقت عادی ترکمنستان", "HKT": "وقت عادی هنگ\u200cکنگ", "COT": "وقت عادی کلمبیا", "IST": "وقت هند", "CLST": "وقت تابستانی شیلی", "COST": "وقت تابستانی کلمبیا", "GFT": "وقت گویان فرانسه", "WITA": "وقت مرکز اندونزی", "∅∅∅": "وقت تابستانی آمازون", "MST": "وقت عادی ماکائو", "HNPM": "وقت عادی سنت\u200cپیر و میکلون", "CHAST": "وقت عادی چت\u200cهام", "MYT": "وقت مالزی", "TMST": "وقت تابستانی ترکمنستان", "HNCU": "وقت عادی کوبا", "OEZ": "وقت عادی شرق اروپا", "WARST": "وقت تابستانی غرب آرژانتین", "HNEG": "وقت عادی شرق گرینلند", "HNPMX": "وقت عادی شرق مکزیک", "EAT": "وقت شرق افریقا", "AWST": "وقت عادی غرب استرالیا", "HEEG": "وقت تابستانی شرق گرینلند", "CHADT": "وقت تابستانی چت\u200cهام", "NZST": "وقت عادی زلاند نو", "MEZ": "وقت عادی مرکز اروپا", "JDT": "وقت تابستانی ژاپن", "AST": "وقت عادی آتلانتیک", "ADT": "وقت تابستانی آتلانتیک", "WAT": "وقت عادی غرب افریقا", "JST": "وقت عادی ژاپن", "WART": "وقت عادی غرب آرژانتین", "AWDT": "وقت تابستانی غرب استرالیا", "ACDT": "وقت تابستانی مرکز استرالیا", "AKST": "وقت عادی آلاسکا", "ACWST": "وقت عادی مرکز-غرب استرالیا", "MESZ": "وقت تابستانی مرکز اروپا", "CLT": "وقت عادی شیلی", "ART": "وقت عادی آرژانتین", "ARST": "وقت تابستانی آرژانتین", "WAST": "وقت تابستانی غرب افریقا", "AKDT": "وقت تابستانی آلاسکا", "CST": "وقت عادی مرکز امریکا", "PDT": "وقت تابستانی غرب امریکا", "ECT": "وقت اکوادور", "CAT": "وقت مرکز افریقا", "LHST": "وقت عادی لردهو", "HEPMX": "وقت تابستانی شرق مکزیک", "CDT": "وقت تابستانی مرکز امریکا", "WIT": "وقت شرق اندونزی", "VET": "وقت ونزوئلا", "WEZ": "وقت عادی غرب اروپا", "HKST": "وقت تابستانی هنگ\u200cکنگ", "SRT": "وقت سورینام", "GYT": "وقت گویان", "WIB": "وقت غرب اندونزی", "LHDT": "وقت تابستانی لردهو", "SGT": "وقت سنگاپور", "ACWDT": "وقت تابستانی مرکز-غرب استرالیا", "HEOG": "وقت تابستانی غرب گرینلند", "ACST": "وقت عادی مرکز استرالیا", "HNT": "وقت عادی نیوفاندلند", "HAT": "وقت تابستانی نیوفاندلند", "ChST": "وقت عادی چامورو"}, + } +} + +// Locale returns the current translators string locale +func (fa *fa_AF) Locale() string { + return fa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fa_AF' +func (fa *fa_AF) PluralsCardinal() []locales.PluralRule { + return fa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fa_AF' +func (fa *fa_AF) PluralsOrdinal() []locales.PluralRule { + return fa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fa_AF' +func (fa *fa_AF) PluralsRange() []locales.PluralRule { + return fa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fa_AF' +func (fa *fa_AF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fa_AF' +func (fa *fa_AF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fa_AF' +func (fa *fa_AF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fa *fa_AF) MonthAbbreviated(month time.Month) string { + return fa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fa *fa_AF) MonthsAbbreviated() []string { + return fa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fa *fa_AF) MonthNarrow(month time.Month) string { + return fa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fa *fa_AF) MonthsNarrow() []string { + return fa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fa *fa_AF) MonthWide(month time.Month) string { + return fa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fa *fa_AF) MonthsWide() []string { + return fa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fa *fa_AF) WeekdayAbbreviated(weekday time.Weekday) string { + return fa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fa *fa_AF) WeekdaysAbbreviated() []string { + return fa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fa *fa_AF) WeekdayNarrow(weekday time.Weekday) string { + return fa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fa *fa_AF) WeekdaysNarrow() []string { + return fa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fa *fa_AF) WeekdayShort(weekday time.Weekday) string { + return fa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fa *fa_AF) WeekdaysShort() []string { + return fa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fa *fa_AF) WeekdayWide(weekday time.Weekday) string { + return fa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fa *fa_AF) WeekdaysWide() []string { + return fa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fa_AF' and handles both Whole and Real numbers based on 'v' +func (fa *fa_AF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 8 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fa_AF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fa *fa_AF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 13 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fa.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fa_AF' +func (fa *fa_AF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fa.currencies[currency] + l := len(s) + len(symbol) + 10 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fa_AF' +// in accounting notation. +func (fa *fa_AF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fa.currencies[currency] + l := len(s) + len(symbol) + 10 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyNegativePrefix[j]) + } + + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fa_AF' +func (fa *fa_AF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fa_AF' +func (fa *fa_AF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fa_AF' +func (fa *fa_AF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fa_AF' +func (fa *fa_AF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fa_AF' +func (fa *fa_AF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fa_AF' +func (fa *fa_AF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fa_AF' +func (fa *fa_AF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fa_AF' +func (fa *fa_AF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := fa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fa_AF/fa_AF_test.go b/vendor/github.com/go-playground/locales/fa_AF/fa_AF_test.go new file mode 100644 index 0000000000..5f5e2473dd --- /dev/null +++ b/vendor/github.com/go-playground/locales/fa_AF/fa_AF_test.go @@ -0,0 +1,1120 @@ +package fa_AF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fa_AF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fa_IR/fa_IR.go b/vendor/github.com/go-playground/locales/fa_IR/fa_IR.go new file mode 100644 index 0000000000..8d5cad2967 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fa_IR/fa_IR.go @@ -0,0 +1,602 @@ +package fa_IR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fa_IR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fa_IR' locale +func New() locales.Translator { + return &fa_IR{ + locale: "fa_IR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: "٫", + group: "٬", + minus: "‎−", + percent: "‎٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: "‎", + currencyNegativePrefix: "‎", + monthsAbbreviated: []string{"", "ژانویهٔ", "فوریهٔ", "مارس", "آوریل", "مهٔ", "ژوئن", "ژوئیهٔ", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"}, + monthsNarrow: []string{"", "ژ", "ف", "م", "آ", "م", "ژ", "ژ", "ا", "س", "ا", "ن", "د"}, + monthsWide: []string{"", "ژانویهٔ", "فوریهٔ", "مارس", "آوریل", "مهٔ", "ژوئن", "ژوئیهٔ", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"}, + daysAbbreviated: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + daysNarrow: []string{"ی", "د", "س", "چ", "پ", "ج", "ش"}, + daysShort: []string{"۱ش", "۲ش", "۳ش", "۴ش", "۵ش", "ج", "ش"}, + daysWide: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + periodsAbbreviated: []string{"ق.ظ.", "ب.ظ."}, + periodsNarrow: []string{"ق", "ب"}, + periodsWide: []string{"قبل\u200cازظهر", "بعدازظهر"}, + erasAbbreviated: []string{"ق.م.", "م."}, + erasNarrow: []string{"ق", "م"}, + erasWide: []string{"قبل از میلاد", "میلادی"}, + timezones: map[string]string{"LHDT": "وقت تابستانی لردهو", "HNPMX": "وقت عادی شرق مکزیک", "WIB": "وقت غرب اندونزی", "CHAST": "وقت عادی چت\u200cهام", "WAT": "وقت عادی غرب افریقا", "AKDT": "وقت تابستانی آلاسکا", "LHST": "وقت عادی لردهو", "HAST": "وقت عادی هاوایی‐الوشن", "HKST": "وقت تابستانی هنگ\u200cکنگ", "AEST": "وقت عادی شرق استرالیا", "UYST": "وقت تابستانی اروگوئه", "ACDT": "وقت تابستانی مرکز استرالیا", "HAT": "وقت تابستانی نیوفاندلند", "HADT": "وقت تابستانی هاوایی‐الوشن", "WESZ": "وقت تابستانی غرب اروپا", "MST": "وقت عادی ماکائو", "ACST": "وقت عادی مرکز استرالیا", "ART": "وقت عادی آرژانتین", "HEPMX": "وقت تابستانی شرق مکزیک", "HNCU": "وقت عادی کوبا", "HEOG": "وقت تابستانی غرب گرینلند", "AST": "وقت عادی آتلانتیک", "ADT": "وقت تابستانی آتلانتیک", "ECT": "وقت اکوادور", "CLT": "وقت عادی شیلی", "OESZ": "وقت تابستانی شرق اروپا", "ChST": "وقت عادی چامورو", "AWDT": "وقت تابستانی غرب استرالیا", "CHADT": "وقت تابستانی چت\u200cهام", "HNPM": "وقت عادی سنت\u200cپیر و میکلون", "OEZ": "وقت عادی شرق اروپا", "GMT": "وقت گرینویچ", "COST": "وقت تابستانی کلمبیا", "HNNOMX": "وقت عادی شمال غرب مکزیک", "MEZ": "وقت عادی مرکز اروپا", "GFT": "وقت گویان فرانسه", "AEDT": "وقت تابستانی شرق استرالیا", "AKST": "وقت عادی آلاسکا", "GYT": "وقت گویان", "BOT": "وقت بولیوی", "PDT": "وقت تابستانی غرب امریکا", "WEZ": "وقت عادی غرب اروپا", "HNT": "وقت عادی نیوفاندلند", "COT": "وقت عادی کلمبیا", "WIT": "وقت شرق اندونزی", "ACWDT": "وقت تابستانی مرکز-غرب استرالیا", "MYT": "وقت مالزی", "WAST": "وقت تابستانی غرب افریقا", "HNOG": "وقت عادی غرب گرینلند", "WITA": "وقت مرکز اندونزی", "UYT": "وقت عادی اروگوئه", "TMT": "وقت عادی ترکمنستان", "BT": "وقت بوتان", "HNEG": "وقت عادی شرق گرینلند", "CDT": "وقت تابستانی مرکز امریکا", "∅∅∅": "وقت تابستانی برازیلیا", "JST": "وقت عادی ژاپن", "CLST": "وقت تابستانی شیلی", "HKT": "وقت عادی هنگ\u200cکنگ", "HENOMX": "وقت تابستانی شمال غرب مکزیک", "SRT": "وقت سورینام", "CST": "وقت عادی مرکز امریکا", "CAT": "وقت مرکز افریقا", "IST": "وقت هند", "ARST": "وقت تابستانی آرژانتین", "ACWST": "وقت عادی مرکز-غرب استرالیا", "EST": "وقت عادی شرق امریکا", "HEEG": "وقت تابستانی شرق گرینلند", "HEPM": "وقت تابستانی سنت\u200cپیر و میکلون", "WART": "وقت عادی غرب آرژانتین", "WARST": "وقت تابستانی غرب آرژانتین", "TMST": "وقت تابستانی ترکمنستان", "EDT": "وقت تابستانی شرق امریکا", "EAT": "وقت شرق افریقا", "SGT": "وقت سنگاپور", "VET": "وقت ونزوئلا", "JDT": "وقت تابستانی ژاپن", "NZDT": "وقت تابستانی زلاند نو", "MESZ": "وقت تابستانی مرکز اروپا", "MDT": "وقت تابستانی ماکائو", "SAST": "وقت عادی جنوب افریقا", "HECU": "وقت تابستانی کوبا", "AWST": "وقت عادی غرب استرالیا", "PST": "وقت عادی غرب امریکا", "NZST": "وقت عادی زلاند نو"}, + } +} + +// Locale returns the current translators string locale +func (fa *fa_IR) Locale() string { + return fa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fa_IR' +func (fa *fa_IR) PluralsCardinal() []locales.PluralRule { + return fa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fa_IR' +func (fa *fa_IR) PluralsOrdinal() []locales.PluralRule { + return fa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fa_IR' +func (fa *fa_IR) PluralsRange() []locales.PluralRule { + return fa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fa_IR' +func (fa *fa_IR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fa_IR' +func (fa *fa_IR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fa_IR' +func (fa *fa_IR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fa *fa_IR) MonthAbbreviated(month time.Month) string { + return fa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fa *fa_IR) MonthsAbbreviated() []string { + return fa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fa *fa_IR) MonthNarrow(month time.Month) string { + return fa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fa *fa_IR) MonthsNarrow() []string { + return fa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fa *fa_IR) MonthWide(month time.Month) string { + return fa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fa *fa_IR) MonthsWide() []string { + return fa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fa *fa_IR) WeekdayAbbreviated(weekday time.Weekday) string { + return fa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fa *fa_IR) WeekdaysAbbreviated() []string { + return fa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fa *fa_IR) WeekdayNarrow(weekday time.Weekday) string { + return fa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fa *fa_IR) WeekdaysNarrow() []string { + return fa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fa *fa_IR) WeekdayShort(weekday time.Weekday) string { + return fa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fa *fa_IR) WeekdaysShort() []string { + return fa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fa *fa_IR) WeekdayWide(weekday time.Weekday) string { + return fa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fa *fa_IR) WeekdaysWide() []string { + return fa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fa_IR' and handles both Whole and Real numbers based on 'v' +func (fa *fa_IR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 8 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fa_IR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fa *fa_IR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 13 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fa.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fa_IR' +func (fa *fa_IR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fa.currencies[currency] + l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fa_IR' +// in accounting notation. +func (fa *fa_IR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fa.currencies[currency] + l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(fa.decimal) - 1; j >= 0; j-- { + b = append(b, fa.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fa.group) - 1; j >= 0; j-- { + b = append(b, fa.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyNegativePrefix[j]) + } + + for j := len(fa.minus) - 1; j >= 0; j-- { + b = append(b, fa.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fa.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fa.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fa_IR' +func (fa *fa_IR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fa_IR' +func (fa *fa_IR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fa_IR' +func (fa *fa_IR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fa_IR' +func (fa *fa_IR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fa_IR' +func (fa *fa_IR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fa_IR' +func (fa *fa_IR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fa_IR' +func (fa *fa_IR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fa_IR' +func (fa *fa_IR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := fa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fa_IR/fa_IR_test.go b/vendor/github.com/go-playground/locales/fa_IR/fa_IR_test.go new file mode 100644 index 0000000000..1c47dff511 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fa_IR/fa_IR_test.go @@ -0,0 +1,1120 @@ +package fa_IR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fa_IR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ff/ff.go b/vendor/github.com/go-playground/locales/ff/ff.go new file mode 100644 index 0000000000..09e8e07291 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff/ff.go @@ -0,0 +1,517 @@ +package ff + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ff struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ff' locale +func New() locales.Translator { + return &ff{ + locale: "ff", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "sii", "col", "mbo", "see", "duu", "kor", "mor", "juk", "slt", "yar", "jol", "bow"}, + monthsNarrow: []string{"", "s", "c", "m", "s", "d", "k", "m", "j", "s", "y", "j", "b"}, + monthsWide: []string{"", "siilo", "colte", "mbooy", "seeɗto", "duujal", "korse", "morso", "juko", "siilto", "yarkomaa", "jolal", "bowte"}, + daysAbbreviated: []string{"dew", "aaɓ", "maw", "nje", "naa", "mwd", "hbi"}, + daysNarrow: []string{"d", "a", "m", "n", "n", "m", "h"}, + daysWide: []string{"dewo", "aaɓnde", "mawbaare", "njeslaare", "naasaande", "mawnde", "hoore-biir"}, + periodsAbbreviated: []string{"subaka", "kikiiɗe"}, + periodsWide: []string{"subaka", "kikiiɗe"}, + erasAbbreviated: []string{"H-I", "C-I"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Hade Iisa", "Caggal Iisa"}, + timezones: map[string]string{"AST": "AST", "HKT": "HKT", "HENOMX": "HENOMX", "HNEG": "HNEG", "WIB": "WIB", "ACWST": "ACWST", "JST": "JST", "LHDT": "LHDT", "HNCU": "HNCU", "OESZ": "OESZ", "HNT": "HNT", "CLST": "CLST", "HEOG": "HEOG", "HKST": "HKST", "ACDT": "ACDT", "HEEG": "HEEG", "GYT": "GYT", "HADT": "HADT", "MEZ": "MEZ", "CST": "CST", "EAT": "EAT", "HECU": "HECU", "ART": "ART", "EST": "EST", "AWST": "AWST", "CHAST": "CHAST", "MESZ": "MESZ", "OEZ": "OEZ", "WESZ": "WESZ", "WAT": "WAT", "BT": "BT", "AKST": "AKST", "AWDT": "AWDT", "ECT": "ECT", "VET": "VET", "IST": "IST", "ACWDT": "ACWDT", "GMT": "GMT", "MDT": "MDT", "UYST": "UYST", "HEPM": "HEPM", "CHADT": "CHADT", "PDT": "PDT", "HNPM": "HNPM", "ADT": "ADT", "TMST": "TMST", "GFT": "GFT", "WITA": "WITA", "AEST": "AEST", "HEPMX": "HEPMX", "SRT": "SRT", "BOT": "BOT", "CAT": "CAT", "MST": "MST", "ARST": "ARST", "COST": "COST", "SAST": "SAST", "SGT": "SGT", "TMT": "TMT", "EDT": "EDT", "∅∅∅": "∅∅∅", "CLT": "CLT", "AKDT": "AKDT", "UYT": "UYT", "LHST": "LHST", "HNPMX": "HNPMX", "WIT": "WIT", "WART": "WART", "HAT": "HAT", "ChST": "ChST", "CDT": "CDT", "NZDT": "NZDT", "HNOG": "HNOG", "WARST": "WARST", "WEZ": "WEZ", "ACST": "ACST", "COT": "COT", "PST": "PST", "HAST": "HAST", "WAST": "WAST", "HNNOMX": "HNNOMX", "NZST": "NZST", "MYT": "MYT", "JDT": "JDT", "AEDT": "AEDT"}, + } +} + +// Locale returns the current translators string locale +func (ff *ff) Locale() string { + return ff.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ff' +func (ff *ff) PluralsCardinal() []locales.PluralRule { + return ff.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ff' +func (ff *ff) PluralsOrdinal() []locales.PluralRule { + return ff.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ff' +func (ff *ff) PluralsRange() []locales.PluralRule { + return ff.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ff' +func (ff *ff) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ff' +func (ff *ff) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ff' +func (ff *ff) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ff *ff) MonthAbbreviated(month time.Month) string { + return ff.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ff *ff) MonthsAbbreviated() []string { + return ff.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ff *ff) MonthNarrow(month time.Month) string { + return ff.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ff *ff) MonthsNarrow() []string { + return ff.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ff *ff) MonthWide(month time.Month) string { + return ff.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ff *ff) MonthsWide() []string { + return ff.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ff *ff) WeekdayAbbreviated(weekday time.Weekday) string { + return ff.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ff *ff) WeekdaysAbbreviated() []string { + return ff.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ff *ff) WeekdayNarrow(weekday time.Weekday) string { + return ff.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ff *ff) WeekdaysNarrow() []string { + return ff.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ff *ff) WeekdayShort(weekday time.Weekday) string { + return ff.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ff *ff) WeekdaysShort() []string { + return ff.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ff *ff) WeekdayWide(weekday time.Weekday) string { + return ff.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ff *ff) WeekdaysWide() []string { + return ff.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ff' and handles both Whole and Real numbers based on 'v' +func (ff *ff) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ff' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ff *ff) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ff' +func (ff *ff) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ff.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ff.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ff' +// in accounting notation. +func (ff *ff) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ff.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ff.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ff.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ff' +func (ff *ff) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ff' +func (ff *ff) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ff' +func (ff *ff) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ff' +func (ff *ff) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ff.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ff' +func (ff *ff) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ff' +func (ff *ff) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ff' +func (ff *ff) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ff' +func (ff *ff) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ff.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ff/ff_test.go b/vendor/github.com/go-playground/locales/ff/ff_test.go new file mode 100644 index 0000000000..a05e8fef48 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff/ff_test.go @@ -0,0 +1,1120 @@ +package ff + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ff" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ff_CM/ff_CM.go b/vendor/github.com/go-playground/locales/ff_CM/ff_CM.go new file mode 100644 index 0000000000..d7d71cc41d --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff_CM/ff_CM.go @@ -0,0 +1,517 @@ +package ff_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ff_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ff_CM' locale +func New() locales.Translator { + return &ff_CM{ + locale: "ff_CM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "sii", "col", "mbo", "see", "duu", "kor", "mor", "juk", "slt", "yar", "jol", "bow"}, + monthsNarrow: []string{"", "s", "c", "m", "s", "d", "k", "m", "j", "s", "y", "j", "b"}, + monthsWide: []string{"", "siilo", "colte", "mbooy", "seeɗto", "duujal", "korse", "morso", "juko", "siilto", "yarkomaa", "jolal", "bowte"}, + daysAbbreviated: []string{"dew", "aaɓ", "maw", "nje", "naa", "mwd", "hbi"}, + daysNarrow: []string{"d", "a", "m", "n", "n", "m", "h"}, + daysWide: []string{"dewo", "aaɓnde", "mawbaare", "njeslaare", "naasaande", "mawnde", "hoore-biir"}, + periodsAbbreviated: []string{"subaka", "kikiiɗe"}, + periodsWide: []string{"subaka", "kikiiɗe"}, + erasAbbreviated: []string{"H-I", "C-I"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Hade Iisa", "Caggal Iisa"}, + timezones: map[string]string{"EAT": "EAT", "PST": "PST", "IST": "IST", "WAT": "WAT", "EST": "EST", "UYT": "UYT", "SRT": "SRT", "WART": "WART", "JDT": "JDT", "EDT": "EDT", "COT": "COT", "GFT": "GFT", "GYT": "GYT", "CST": "CST", "AWST": "AWST", "CLT": "CLT", "WESZ": "WESZ", "MYT": "MYT", "MEZ": "MEZ", "JST": "JST", "CLST": "CLST", "AKDT": "AKDT", "HEPM": "HEPM", "HECU": "HECU", "WIT": "WIT", "HADT": "HADT", "WEZ": "WEZ", "TMT": "TMT", "TMST": "TMST", "AST": "AST", "ADT": "ADT", "ACDT": "ACDT", "LHDT": "LHDT", "PDT": "PDT", "NZST": "NZST", "VET": "VET", "BT": "BT", "HEPMX": "HEPMX", "CAT": "CAT", "NZDT": "NZDT", "OESZ": "OESZ", "ART": "ART", "HNNOMX": "HNNOMX", "HAT": "HAT", "SAST": "SAST", "ECT": "ECT", "HNOG": "HNOG", "GMT": "GMT", "MST": "MST", "HKT": "HKT", "ACST": "ACST", "AEST": "AEST", "HAST": "HAST", "HNCU": "HNCU", "AWDT": "AWDT", "OEZ": "OEZ", "HNEG": "HNEG", "AEDT": "AEDT", "SGT": "SGT", "MESZ": "MESZ", "ACWDT": "ACWDT", "ARST": "ARST", "COST": "COST", "HNPM": "HNPM", "CHAST": "CHAST", "BOT": "BOT", "WAST": "WAST", "HKST": "HKST", "HENOMX": "HENOMX", "WITA": "WITA", "UYST": "UYST", "∅∅∅": "∅∅∅", "HNPMX": "HNPMX", "HEOG": "HEOG", "WARST": "WARST", "ACWST": "ACWST", "HNT": "HNT", "HEEG": "HEEG", "AKST": "AKST", "WIB": "WIB", "CHADT": "CHADT", "MDT": "MDT", "ChST": "ChST", "LHST": "LHST", "CDT": "CDT"}, + } +} + +// Locale returns the current translators string locale +func (ff *ff_CM) Locale() string { + return ff.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ff_CM' +func (ff *ff_CM) PluralsCardinal() []locales.PluralRule { + return ff.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ff_CM' +func (ff *ff_CM) PluralsOrdinal() []locales.PluralRule { + return ff.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ff_CM' +func (ff *ff_CM) PluralsRange() []locales.PluralRule { + return ff.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ff_CM' +func (ff *ff_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ff_CM' +func (ff *ff_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ff_CM' +func (ff *ff_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ff *ff_CM) MonthAbbreviated(month time.Month) string { + return ff.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ff *ff_CM) MonthsAbbreviated() []string { + return ff.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ff *ff_CM) MonthNarrow(month time.Month) string { + return ff.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ff *ff_CM) MonthsNarrow() []string { + return ff.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ff *ff_CM) MonthWide(month time.Month) string { + return ff.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ff *ff_CM) MonthsWide() []string { + return ff.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ff *ff_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return ff.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ff *ff_CM) WeekdaysAbbreviated() []string { + return ff.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ff *ff_CM) WeekdayNarrow(weekday time.Weekday) string { + return ff.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ff *ff_CM) WeekdaysNarrow() []string { + return ff.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ff *ff_CM) WeekdayShort(weekday time.Weekday) string { + return ff.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ff *ff_CM) WeekdaysShort() []string { + return ff.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ff *ff_CM) WeekdayWide(weekday time.Weekday) string { + return ff.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ff *ff_CM) WeekdaysWide() []string { + return ff.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ff_CM' and handles both Whole and Real numbers based on 'v' +func (ff *ff_CM) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ff_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ff *ff_CM) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ff_CM' +func (ff *ff_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ff.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ff.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ff_CM' +// in accounting notation. +func (ff *ff_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ff.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ff.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ff.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ff_CM' +func (ff *ff_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ff_CM' +func (ff *ff_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ff_CM' +func (ff *ff_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ff_CM' +func (ff *ff_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ff.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ff_CM' +func (ff *ff_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ff_CM' +func (ff *ff_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ff_CM' +func (ff *ff_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ff_CM' +func (ff *ff_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ff.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ff_CM/ff_CM_test.go b/vendor/github.com/go-playground/locales/ff_CM/ff_CM_test.go new file mode 100644 index 0000000000..59965b0432 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff_CM/ff_CM_test.go @@ -0,0 +1,1120 @@ +package ff_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ff_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ff_GN/ff_GN.go b/vendor/github.com/go-playground/locales/ff_GN/ff_GN.go new file mode 100644 index 0000000000..5475ad6689 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff_GN/ff_GN.go @@ -0,0 +1,517 @@ +package ff_GN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ff_GN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ff_GN' locale +func New() locales.Translator { + return &ff_GN{ + locale: "ff_GN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "FG", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "sii", "col", "mbo", "see", "duu", "kor", "mor", "juk", "slt", "yar", "jol", "bow"}, + monthsNarrow: []string{"", "s", "c", "m", "s", "d", "k", "m", "j", "s", "y", "j", "b"}, + monthsWide: []string{"", "siilo", "colte", "mbooy", "seeɗto", "duujal", "korse", "morso", "juko", "siilto", "yarkomaa", "jolal", "bowte"}, + daysAbbreviated: []string{"dew", "aaɓ", "maw", "nje", "naa", "mwd", "hbi"}, + daysNarrow: []string{"d", "a", "m", "n", "n", "m", "h"}, + daysWide: []string{"dewo", "aaɓnde", "mawbaare", "njeslaare", "naasaande", "mawnde", "hoore-biir"}, + periodsAbbreviated: []string{"subaka", "kikiiɗe"}, + periodsWide: []string{"subaka", "kikiiɗe"}, + erasAbbreviated: []string{"H-I", "C-I"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Hade Iisa", "Caggal Iisa"}, + timezones: map[string]string{"ADT": "ADT", "WEZ": "WEZ", "HNOG": "HNOG", "TMT": "TMT", "HNEG": "HNEG", "HNPM": "HNPM", "WIB": "WIB", "WAT": "WAT", "EDT": "EDT", "BT": "BT", "HAT": "HAT", "AKST": "AKST", "AEST": "AEST", "HEPMX": "HEPMX", "CLST": "CLST", "WAST": "WAST", "CHADT": "CHADT", "CAT": "CAT", "IST": "IST", "HKT": "HKT", "PDT": "PDT", "ACWDT": "ACWDT", "CLT": "CLT", "HEOG": "HEOG", "∅∅∅": "∅∅∅", "UYST": "UYST", "EAT": "EAT", "CHAST": "CHAST", "ACWST": "ACWST", "ChST": "ChST", "LHST": "LHST", "CDT": "CDT", "HADT": "HADT", "NZST": "NZST", "VET": "VET", "AST": "AST", "WART": "WART", "HKST": "HKST", "SAST": "SAST", "LHDT": "LHDT", "PST": "PST", "MEZ": "MEZ", "OEZ": "OEZ", "WESZ": "WESZ", "HNCU": "HNCU", "CST": "CST", "HENOMX": "HENOMX", "HNT": "HNT", "WITA": "WITA", "UYT": "UYT", "ECT": "ECT", "MYT": "MYT", "ART": "ART", "EST": "EST", "AKDT": "AKDT", "GFT": "GFT", "GYT": "GYT", "BOT": "BOT", "MDT": "MDT", "ACST": "ACST", "COT": "COT", "HEPM": "HEPM", "SRT": "SRT", "WIT": "WIT", "HAST": "HAST", "ACDT": "ACDT", "HEEG": "HEEG", "AEDT": "AEDT", "AWST": "AWST", "JST": "JST", "TMST": "TMST", "AWDT": "AWDT", "GMT": "GMT", "MST": "MST", "ARST": "ARST", "HNNOMX": "HNNOMX", "NZDT": "NZDT", "JDT": "JDT", "HNPMX": "HNPMX", "HECU": "HECU", "SGT": "SGT", "MESZ": "MESZ", "OESZ": "OESZ", "WARST": "WARST", "COST": "COST"}, + } +} + +// Locale returns the current translators string locale +func (ff *ff_GN) Locale() string { + return ff.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ff_GN' +func (ff *ff_GN) PluralsCardinal() []locales.PluralRule { + return ff.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ff_GN' +func (ff *ff_GN) PluralsOrdinal() []locales.PluralRule { + return ff.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ff_GN' +func (ff *ff_GN) PluralsRange() []locales.PluralRule { + return ff.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ff_GN' +func (ff *ff_GN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ff_GN' +func (ff *ff_GN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ff_GN' +func (ff *ff_GN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ff *ff_GN) MonthAbbreviated(month time.Month) string { + return ff.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ff *ff_GN) MonthsAbbreviated() []string { + return ff.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ff *ff_GN) MonthNarrow(month time.Month) string { + return ff.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ff *ff_GN) MonthsNarrow() []string { + return ff.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ff *ff_GN) MonthWide(month time.Month) string { + return ff.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ff *ff_GN) MonthsWide() []string { + return ff.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ff *ff_GN) WeekdayAbbreviated(weekday time.Weekday) string { + return ff.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ff *ff_GN) WeekdaysAbbreviated() []string { + return ff.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ff *ff_GN) WeekdayNarrow(weekday time.Weekday) string { + return ff.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ff *ff_GN) WeekdaysNarrow() []string { + return ff.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ff *ff_GN) WeekdayShort(weekday time.Weekday) string { + return ff.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ff *ff_GN) WeekdaysShort() []string { + return ff.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ff *ff_GN) WeekdayWide(weekday time.Weekday) string { + return ff.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ff *ff_GN) WeekdaysWide() []string { + return ff.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ff_GN' and handles both Whole and Real numbers based on 'v' +func (ff *ff_GN) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ff_GN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ff *ff_GN) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ff_GN' +func (ff *ff_GN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ff.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ff.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ff_GN' +// in accounting notation. +func (ff *ff_GN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ff.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ff.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ff.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ff_GN' +func (ff *ff_GN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ff_GN' +func (ff *ff_GN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ff_GN' +func (ff *ff_GN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ff_GN' +func (ff *ff_GN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ff.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ff_GN' +func (ff *ff_GN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ff_GN' +func (ff *ff_GN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ff_GN' +func (ff *ff_GN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ff_GN' +func (ff *ff_GN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ff.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ff_GN/ff_GN_test.go b/vendor/github.com/go-playground/locales/ff_GN/ff_GN_test.go new file mode 100644 index 0000000000..88c318c7ed --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff_GN/ff_GN_test.go @@ -0,0 +1,1120 @@ +package ff_GN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ff_GN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ff_MR/ff_MR.go b/vendor/github.com/go-playground/locales/ff_MR/ff_MR.go new file mode 100644 index 0000000000..6752d82024 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff_MR/ff_MR.go @@ -0,0 +1,555 @@ +package ff_MR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ff_MR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ff_MR' locale +func New() locales.Translator { + return &ff_MR{ + locale: "ff_MR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "UM", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "sii", "col", "mbo", "see", "duu", "kor", "mor", "juk", "slt", "yar", "jol", "bow"}, + monthsNarrow: []string{"", "s", "c", "m", "s", "d", "k", "m", "j", "s", "y", "j", "b"}, + monthsWide: []string{"", "siilo", "colte", "mbooy", "seeɗto", "duujal", "korse", "morso", "juko", "siilto", "yarkomaa", "jolal", "bowte"}, + daysAbbreviated: []string{"dew", "aaɓ", "maw", "nje", "naa", "mwd", "hbi"}, + daysNarrow: []string{"d", "a", "m", "n", "n", "m", "h"}, + daysWide: []string{"dewo", "aaɓnde", "mawbaare", "njeslaare", "naasaande", "mawnde", "hoore-biir"}, + periodsAbbreviated: []string{"subaka", "kikiiɗe"}, + periodsWide: []string{"subaka", "kikiiɗe"}, + erasAbbreviated: []string{"H-I", "C-I"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Hade Iisa", "Caggal Iisa"}, + timezones: map[string]string{"TMT": "TMT", "ART": "ART", "MEZ": "MEZ", "JST": "JST", "JDT": "JDT", "WART": "WART", "HEOG": "HEOG", "OEZ": "OEZ", "COT": "COT", "HAT": "HAT", "WIB": "WIB", "ACWDT": "ACWDT", "VET": "VET", "HENOMX": "HENOMX", "HNPMX": "HNPMX", "CHAST": "CHAST", "BOT": "BOT", "NZDT": "NZDT", "WAST": "WAST", "CHADT": "CHADT", "∅∅∅": "∅∅∅", "CLST": "CLST", "WAT": "WAT", "HNNOMX": "HNNOMX", "HNEG": "HNEG", "LHDT": "LHDT", "CAT": "CAT", "ADT": "ADT", "EST": "EST", "HKT": "HKT", "MST": "MST", "HNT": "HNT", "WIT": "WIT", "AWDT": "AWDT", "HADT": "HADT", "WARST": "WARST", "WEZ": "WEZ", "TMST": "TMST", "AKST": "AKST", "HEPM": "HEPM", "IST": "IST", "MESZ": "MESZ", "MDT": "MDT", "SRT": "SRT", "CDT": "CDT", "HAST": "HAST", "MYT": "MYT", "AST": "AST", "OESZ": "OESZ", "ACST": "ACST", "HECU": "HECU", "ECT": "ECT", "BT": "BT", "HEPMX": "HEPMX", "SGT": "SGT", "PST": "PST", "NZST": "NZST", "WESZ": "WESZ", "AEDT": "AEDT", "CST": "CST", "AWST": "AWST", "EAT": "EAT", "GMT": "GMT", "HNOG": "HNOG", "EDT": "EDT", "HEEG": "HEEG", "GFT": "GFT", "UYST": "UYST", "SAST": "SAST", "PDT": "PDT", "ARST": "ARST", "HKST": "HKST", "ACDT": "ACDT", "AEST": "AEST", "ChST": "ChST", "ACWST": "ACWST", "COST": "COST", "AKDT": "AKDT", "UYT": "UYT", "HNPM": "HNPM", "LHST": "LHST", "CLT": "CLT", "WITA": "WITA", "GYT": "GYT", "HNCU": "HNCU"}, + } +} + +// Locale returns the current translators string locale +func (ff *ff_MR) Locale() string { + return ff.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ff_MR' +func (ff *ff_MR) PluralsCardinal() []locales.PluralRule { + return ff.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ff_MR' +func (ff *ff_MR) PluralsOrdinal() []locales.PluralRule { + return ff.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ff_MR' +func (ff *ff_MR) PluralsRange() []locales.PluralRule { + return ff.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ff_MR' +func (ff *ff_MR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ff_MR' +func (ff *ff_MR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ff_MR' +func (ff *ff_MR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ff *ff_MR) MonthAbbreviated(month time.Month) string { + return ff.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ff *ff_MR) MonthsAbbreviated() []string { + return ff.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ff *ff_MR) MonthNarrow(month time.Month) string { + return ff.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ff *ff_MR) MonthsNarrow() []string { + return ff.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ff *ff_MR) MonthWide(month time.Month) string { + return ff.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ff *ff_MR) MonthsWide() []string { + return ff.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ff *ff_MR) WeekdayAbbreviated(weekday time.Weekday) string { + return ff.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ff *ff_MR) WeekdaysAbbreviated() []string { + return ff.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ff *ff_MR) WeekdayNarrow(weekday time.Weekday) string { + return ff.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ff *ff_MR) WeekdaysNarrow() []string { + return ff.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ff *ff_MR) WeekdayShort(weekday time.Weekday) string { + return ff.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ff *ff_MR) WeekdaysShort() []string { + return ff.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ff *ff_MR) WeekdayWide(weekday time.Weekday) string { + return ff.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ff *ff_MR) WeekdaysWide() []string { + return ff.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ff_MR' and handles both Whole and Real numbers based on 'v' +func (ff *ff_MR) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ff_MR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ff *ff_MR) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ff_MR' +func (ff *ff_MR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ff.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ff.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ff_MR' +// in accounting notation. +func (ff *ff_MR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ff.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ff.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ff.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ff_MR' +func (ff *ff_MR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ff_MR' +func (ff *ff_MR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ff_MR' +func (ff *ff_MR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ff_MR' +func (ff *ff_MR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ff.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ff_MR' +func (ff *ff_MR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ff.periodsAbbreviated[0]...) + } else { + b = append(b, ff.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ff_MR' +func (ff *ff_MR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ff.periodsAbbreviated[0]...) + } else { + b = append(b, ff.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ff_MR' +func (ff *ff_MR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ff.periodsAbbreviated[0]...) + } else { + b = append(b, ff.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ff_MR' +func (ff *ff_MR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ff.periodsAbbreviated[0]...) + } else { + b = append(b, ff.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ff.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ff_MR/ff_MR_test.go b/vendor/github.com/go-playground/locales/ff_MR/ff_MR_test.go new file mode 100644 index 0000000000..38661427ef --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff_MR/ff_MR_test.go @@ -0,0 +1,1120 @@ +package ff_MR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ff_MR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ff_SN/ff_SN.go b/vendor/github.com/go-playground/locales/ff_SN/ff_SN.go new file mode 100644 index 0000000000..5779c77410 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff_SN/ff_SN.go @@ -0,0 +1,517 @@ +package ff_SN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ff_SN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ff_SN' locale +func New() locales.Translator { + return &ff_SN{ + locale: "ff_SN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "sii", "col", "mbo", "see", "duu", "kor", "mor", "juk", "slt", "yar", "jol", "bow"}, + monthsNarrow: []string{"", "s", "c", "m", "s", "d", "k", "m", "j", "s", "y", "j", "b"}, + monthsWide: []string{"", "siilo", "colte", "mbooy", "seeɗto", "duujal", "korse", "morso", "juko", "siilto", "yarkomaa", "jolal", "bowte"}, + daysAbbreviated: []string{"dew", "aaɓ", "maw", "nje", "naa", "mwd", "hbi"}, + daysNarrow: []string{"d", "a", "m", "n", "n", "m", "h"}, + daysWide: []string{"dewo", "aaɓnde", "mawbaare", "njeslaare", "naasaande", "mawnde", "hoore-biir"}, + periodsAbbreviated: []string{"subaka", "kikiiɗe"}, + periodsWide: []string{"subaka", "kikiiɗe"}, + erasAbbreviated: []string{"H-I", "C-I"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Hade Iisa", "Caggal Iisa"}, + timezones: map[string]string{"AWDT": "AWDT", "WESZ": "WESZ", "CLST": "CLST", "TMST": "TMST", "EDT": "EDT", "HEPMX": "HEPMX", "VET": "VET", "HNOG": "HNOG", "NZDT": "NZDT", "JST": "JST", "GMT": "GMT", "HENOMX": "HENOMX", "SRT": "SRT", "WIT": "WIT", "WEZ": "WEZ", "MST": "MST", "HNT": "HNT", "WIB": "WIB", "BOT": "BOT", "IST": "IST", "CLT": "CLT", "EST": "EST", "HAT": "HAT", "AEDT": "AEDT", "GFT": "GFT", "JDT": "JDT", "MDT": "MDT", "HKT": "HKT", "HNNOMX": "HNNOMX", "AKDT": "AKDT", "LHDT": "LHDT", "CDT": "CDT", "AWST": "AWST", "PST": "PST", "ADT": "ADT", "ART": "ART", "WAST": "WAST", "AKST": "AKST", "HNPM": "HNPM", "HEPM": "HEPM", "NZST": "NZST", "MEZ": "MEZ", "OESZ": "OESZ", "ARST": "ARST", "GYT": "GYT", "HECU": "HECU", "HADT": "HADT", "ACWDT": "ACWDT", "AST": "AST", "BT": "BT", "EAT": "EAT", "CHADT": "CHADT", "PDT": "PDT", "WART": "WART", "HNEG": "HNEG", "WITA": "WITA", "SAST": "SAST", "WAT": "WAT", "ACDT": "ACDT", "HNPMX": "HNPMX", "OEZ": "OEZ", "HNCU": "HNCU", "CST": "CST", "ECT": "ECT", "ACST": "ACST", "UYST": "UYST", "CAT": "CAT", "∅∅∅": "∅∅∅", "HEOG": "HEOG", "WARST": "WARST", "TMT": "TMT", "COST": "COST", "AEST": "AEST", "UYT": "UYT", "LHST": "LHST", "SGT": "SGT", "ACWST": "ACWST", "CHAST": "CHAST", "HAST": "HAST", "MESZ": "MESZ", "MYT": "MYT", "HKST": "HKST", "COT": "COT", "HEEG": "HEEG", "ChST": "ChST"}, + } +} + +// Locale returns the current translators string locale +func (ff *ff_SN) Locale() string { + return ff.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ff_SN' +func (ff *ff_SN) PluralsCardinal() []locales.PluralRule { + return ff.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ff_SN' +func (ff *ff_SN) PluralsOrdinal() []locales.PluralRule { + return ff.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ff_SN' +func (ff *ff_SN) PluralsRange() []locales.PluralRule { + return ff.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ff_SN' +func (ff *ff_SN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ff_SN' +func (ff *ff_SN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ff_SN' +func (ff *ff_SN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ff *ff_SN) MonthAbbreviated(month time.Month) string { + return ff.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ff *ff_SN) MonthsAbbreviated() []string { + return ff.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ff *ff_SN) MonthNarrow(month time.Month) string { + return ff.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ff *ff_SN) MonthsNarrow() []string { + return ff.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ff *ff_SN) MonthWide(month time.Month) string { + return ff.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ff *ff_SN) MonthsWide() []string { + return ff.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ff *ff_SN) WeekdayAbbreviated(weekday time.Weekday) string { + return ff.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ff *ff_SN) WeekdaysAbbreviated() []string { + return ff.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ff *ff_SN) WeekdayNarrow(weekday time.Weekday) string { + return ff.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ff *ff_SN) WeekdaysNarrow() []string { + return ff.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ff *ff_SN) WeekdayShort(weekday time.Weekday) string { + return ff.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ff *ff_SN) WeekdaysShort() []string { + return ff.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ff *ff_SN) WeekdayWide(weekday time.Weekday) string { + return ff.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ff *ff_SN) WeekdaysWide() []string { + return ff.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ff_SN' and handles both Whole and Real numbers based on 'v' +func (ff *ff_SN) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ff_SN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ff *ff_SN) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ff_SN' +func (ff *ff_SN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ff.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ff.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ff_SN' +// in accounting notation. +func (ff *ff_SN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ff.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ff.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ff.group) - 1; j >= 0; j-- { + b = append(b, ff.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ff.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ff.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ff.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ff.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ff_SN' +func (ff *ff_SN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ff_SN' +func (ff *ff_SN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ff_SN' +func (ff *ff_SN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ff_SN' +func (ff *ff_SN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ff.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ff.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ff_SN' +func (ff *ff_SN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ff_SN' +func (ff *ff_SN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ff_SN' +func (ff *ff_SN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ff_SN' +func (ff *ff_SN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ff.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ff.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ff.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ff_SN/ff_SN_test.go b/vendor/github.com/go-playground/locales/ff_SN/ff_SN_test.go new file mode 100644 index 0000000000..a935b03602 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ff_SN/ff_SN_test.go @@ -0,0 +1,1120 @@ +package ff_SN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ff_SN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fi/fi.go b/vendor/github.com/go-playground/locales/fi/fi.go new file mode 100644 index 0000000000..4beb64de6a --- /dev/null +++ b/vendor/github.com/go-playground/locales/fi/fi.go @@ -0,0 +1,580 @@ +package fi + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fi struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fi' locale +func New() locales.Translator { + return &fi{ + locale: "fi", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "mk", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "tammik.", "helmik.", "maalisk.", "huhtik.", "toukok.", "kesäk.", "heinäk.", "elok.", "syysk.", "lokak.", "marrask.", "jouluk."}, + monthsNarrow: []string{"", "T", "H", "M", "H", "T", "K", "H", "E", "S", "L", "M", "J"}, + monthsWide: []string{"", "tammikuuta", "helmikuuta", "maaliskuuta", "huhtikuuta", "toukokuuta", "kesäkuuta", "heinäkuuta", "elokuuta", "syyskuuta", "lokakuuta", "marraskuuta", "joulukuuta"}, + daysAbbreviated: []string{"su", "ma", "ti", "ke", "to", "pe", "la"}, + daysNarrow: []string{"S", "M", "T", "K", "T", "P", "L"}, + daysShort: []string{"su", "ma", "ti", "ke", "to", "pe", "la"}, + daysWide: []string{"sunnuntaina", "maanantaina", "tiistaina", "keskiviikkona", "torstaina", "perjantaina", "lauantaina"}, + periodsAbbreviated: []string{"ap.", "ip."}, + periodsNarrow: []string{"ap.", "ip."}, + periodsWide: []string{"ap.", "ip."}, + erasAbbreviated: []string{"eKr.", "jKr."}, + erasNarrow: []string{"eKr", "jKr"}, + erasWide: []string{"ennen Kristuksen syntymää", "jälkeen Kristuksen syntymän"}, + timezones: map[string]string{"WAST": "Länsi-Afrikan kesäaika", "SRT": "Surinamen aika", "ACWST": "Läntisen Keski-Australian normaaliaika", "HKST": "Hongkongin kesäaika", "BT": "Bhutanin aika", "CHAST": "Chathamin normaaliaika", "WAT": "Länsi-Afrikan normaaliaika", "CST": "Yhdysvaltain keskinen normaaliaika", "CAT": "Keski-Afrikan aika", "AST": "Kanadan Atlantin normaaliaika", "OESZ": "Itä-Euroopan kesäaika", "WESZ": "Länsi-Euroopan kesäaika", "MDT": "Macaon kesäaika", "COST": "Kolumbian kesäaika", "HNT": "Newfoundlandin normaaliaika", "PDT": "Yhdysvaltain Tyynenmeren kesäaika", "GYT": "Guyanan aika", "HENOMX": "Luoteis-Meksikon kesäaika", "HNEG": "Itä-Grönlannin normaaliaika", "∅∅∅": "Acren kesäaika", "AKST": "Alaskan normaaliaika", "AKDT": "Alaskan kesäaika", "UYT": "Uruguayn normaaliaika", "LHDT": "Lord Howen kesäaika", "BOT": "Bolivian aika", "IST": "Intian aika", "MEZ": "Keski-Euroopan normaaliaika", "MST": "Macaon normaaliaika", "ACDT": "Keski-Australian kesäaika", "EAT": "Itä-Afrikan aika", "WIB": "Länsi-Indonesian aika", "AWDT": "Länsi-Australian kesäaika", "SGT": "Singaporen aika", "PST": "Yhdysvaltain Tyynenmeren normaaliaika", "GMT": "Greenwichin normaaliaika", "COT": "Kolumbian normaaliaika", "MYT": "Malesian aika", "WARST": "Länsi-Argentiinan kesäaika", "ACWDT": "Läntisen Keski-Australian kesäaika", "CLT": "Chilen normaaliaika", "ARST": "Argentiinan kesäaika", "HKT": "Hongkongin normaaliaika", "HNNOMX": "Luoteis-Meksikon normaaliaika", "AEDT": "Itä-Australian kesäaika", "LHST": "Lord Howen normaaliaika", "CDT": "Yhdysvaltain keskinen kesäaika", "OEZ": "Itä-Euroopan normaaliaika", "WART": "Länsi-Argentiinan normaaliaika", "ART": "Argentiinan normaaliaika", "AEST": "Itä-Australian normaaliaika", "AWST": "Länsi-Australian normaaliaika", "CLST": "Chilen kesäaika", "ACST": "Keski-Australian normaaliaika", "HEEG": "Itä-Grönlannin kesäaika", "ChST": "Tšamorron aika", "HNCU": "Kuuban normaaliaika", "VET": "Venezuelan aika", "HEOG": "Länsi-Grönlannin kesäaika", "EST": "Yhdysvaltain itäinen normaaliaika", "HNPM": "Saint-Pierren ja Miquelonin normaaliaika", "HEPMX": "Meksikon Tyynenmeren kesäaika", "HECU": "Kuuban kesäaika", "HAST": "Havaijin-Aleuttien normaaliaika", "MESZ": "Keski-Euroopan kesäaika", "JDT": "Japanin kesäaika", "HNOG": "Länsi-Grönlannin normaaliaika", "TMT": "Turkmenistanin normaaliaika", "TMST": "Turkmenistanin kesäaika", "WITA": "Keski-Indonesian aika", "ECT": "Ecuadorin aika", "WEZ": "Länsi-Euroopan normaaliaika", "EDT": "Yhdysvaltain itäinen kesäaika", "GFT": "Ranskan Guayanan aika", "HEPM": "Saint-Pierren ja Miquelonin kesäaika", "NZDT": "Uuden-Seelannin kesäaika", "UYST": "Uruguayn kesäaika", "SAST": "Etelä-Afrikan aika", "HNPMX": "Meksikon Tyynenmeren normaaliaika", "CHADT": "Chathamin kesäaika", "HADT": "Havaijin-Aleuttien kesäaika", "NZST": "Uuden-Seelannin normaaliaika", "JST": "Japanin normaaliaika", "ADT": "Kanadan Atlantin kesäaika", "HAT": "Newfoundlandin kesäaika", "WIT": "Itä-Indonesian aika"}, + } +} + +// Locale returns the current translators string locale +func (fi *fi) Locale() string { + return fi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fi' +func (fi *fi) PluralsCardinal() []locales.PluralRule { + return fi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fi' +func (fi *fi) PluralsOrdinal() []locales.PluralRule { + return fi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fi' +func (fi *fi) PluralsRange() []locales.PluralRule { + return fi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fi' +func (fi *fi) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fi' +func (fi *fi) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fi' +func (fi *fi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fi *fi) MonthAbbreviated(month time.Month) string { + return fi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fi *fi) MonthsAbbreviated() []string { + return fi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fi *fi) MonthNarrow(month time.Month) string { + return fi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fi *fi) MonthsNarrow() []string { + return fi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fi *fi) MonthWide(month time.Month) string { + return fi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fi *fi) MonthsWide() []string { + return fi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fi *fi) WeekdayAbbreviated(weekday time.Weekday) string { + return fi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fi *fi) WeekdaysAbbreviated() []string { + return fi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fi *fi) WeekdayNarrow(weekday time.Weekday) string { + return fi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fi *fi) WeekdaysNarrow() []string { + return fi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fi *fi) WeekdayShort(weekday time.Weekday) string { + return fi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fi *fi) WeekdaysShort() []string { + return fi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fi *fi) WeekdayWide(weekday time.Weekday) string { + return fi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fi *fi) WeekdaysWide() []string { + return fi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fi' and handles both Whole and Real numbers based on 'v' +func (fi *fi) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fi.group) - 1; j >= 0; j-- { + b = append(b, fi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fi.minus) - 1; j >= 0; j-- { + b = append(b, fi.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fi' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fi *fi) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fi.minus) - 1; j >= 0; j-- { + b = append(b, fi.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fi.percentSuffix...) + + b = append(b, fi.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fi' +func (fi *fi) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fi.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fi.group) - 1; j >= 0; j-- { + b = append(b, fi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fi.minus) - 1; j >= 0; j-- { + b = append(b, fi.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fi.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fi' +// in accounting notation. +func (fi *fi) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fi.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fi.group) - 1; j >= 0; j-- { + b = append(b, fi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(fi.minus) - 1; j >= 0; j-- { + b = append(b, fi.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fi.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fi.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fi' +func (fi *fi) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fi' +func (fi *fi) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fi' +func (fi *fi) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fi' +func (fi *fi) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x63, 0x63, 0x63, 0x63, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fi' +func (fi *fi) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fi' +func (fi *fi) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fi' +func (fi *fi) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fi' +func (fi *fi) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fi.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fi/fi_test.go b/vendor/github.com/go-playground/locales/fi/fi_test.go new file mode 100644 index 0000000000..5176a0f3c9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fi/fi_test.go @@ -0,0 +1,1120 @@ +package fi + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fi" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fi_FI/fi_FI.go b/vendor/github.com/go-playground/locales/fi_FI/fi_FI.go new file mode 100644 index 0000000000..b0e074941a --- /dev/null +++ b/vendor/github.com/go-playground/locales/fi_FI/fi_FI.go @@ -0,0 +1,580 @@ +package fi_FI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fi_FI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fi_FI' locale +func New() locales.Translator { + return &fi_FI{ + locale: "fi_FI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "tammik.", "helmik.", "maalisk.", "huhtik.", "toukok.", "kesäk.", "heinäk.", "elok.", "syysk.", "lokak.", "marrask.", "jouluk."}, + monthsNarrow: []string{"", "T", "H", "M", "H", "T", "K", "H", "E", "S", "L", "M", "J"}, + monthsWide: []string{"", "tammikuuta", "helmikuuta", "maaliskuuta", "huhtikuuta", "toukokuuta", "kesäkuuta", "heinäkuuta", "elokuuta", "syyskuuta", "lokakuuta", "marraskuuta", "joulukuuta"}, + daysAbbreviated: []string{"su", "ma", "ti", "ke", "to", "pe", "la"}, + daysNarrow: []string{"S", "M", "T", "K", "T", "P", "L"}, + daysShort: []string{"su", "ma", "ti", "ke", "to", "pe", "la"}, + daysWide: []string{"sunnuntaina", "maanantaina", "tiistaina", "keskiviikkona", "torstaina", "perjantaina", "lauantaina"}, + periodsAbbreviated: []string{"ap.", "ip."}, + periodsNarrow: []string{"ap.", "ip."}, + periodsWide: []string{"ap.", "ip."}, + erasAbbreviated: []string{"eKr.", "jKr."}, + erasNarrow: []string{"eKr", "jKr"}, + erasWide: []string{"ennen Kristuksen syntymää", "jälkeen Kristuksen syntymän"}, + timezones: map[string]string{"ACST": "Keski-Australian normaaliaika", "AKDT": "Alaskan kesäaika", "UYT": "Uruguayn normaaliaika", "SAST": "Etelä-Afrikan aika", "OEZ": "Itä-Euroopan normaaliaika", "WIT": "Itä-Indonesian aika", "BOT": "Bolivian aika", "WAST": "Länsi-Afrikan kesäaika", "HKST": "Hongkongin kesäaika", "HEEG": "Itä-Grönlannin kesäaika", "UYST": "Uruguayn kesäaika", "CST": "Yhdysvaltain keskinen normaaliaika", "ACWDT": "Läntisen Keski-Australian kesäaika", "COST": "Kolumbian kesäaika", "HENOMX": "Luoteis-Meksikon kesäaika", "WITA": "Keski-Indonesian aika", "HNCU": "Kuuban normaaliaika", "HECU": "Kuuban kesäaika", "ACDT": "Keski-Australian kesäaika", "HNOG": "Länsi-Grönlannin normaaliaika", "WEZ": "Länsi-Euroopan normaaliaika", "GMT": "Greenwichin normaaliaika", "∅∅∅": "Perun kesäaika", "AEST": "Itä-Australian normaaliaika", "WIB": "Länsi-Indonesian aika", "HAST": "Havaijin-Aleuttien normaaliaika", "MESZ": "Keski-Euroopan kesäaika", "HEPM": "Saint-Pierren ja Miquelonin kesäaika", "AWST": "Länsi-Australian normaaliaika", "VET": "Venezuelan aika", "MDT": "Macaon kesäaika", "WAT": "Länsi-Afrikan normaaliaika", "ChST": "Tšamorron aika", "LHDT": "Lord Howen kesäaika", "HNPMX": "Meksikon Tyynenmeren normaaliaika", "HAT": "Newfoundlandin kesäaika", "HEPMX": "Meksikon Tyynenmeren kesäaika", "EAT": "Itä-Afrikan aika", "CDT": "Yhdysvaltain keskinen kesäaika", "EDT": "Yhdysvaltain itäinen kesäaika", "AWDT": "Länsi-Australian kesäaika", "WART": "Länsi-Argentiinan normaaliaika", "MYT": "Malesian aika", "IST": "Intian aika", "ACWST": "Läntisen Keski-Australian normaaliaika", "ARST": "Argentiinan kesäaika", "GFT": "Ranskan Guayanan aika", "SRT": "Surinamen aika", "CHADT": "Chathamin kesäaika", "PST": "Yhdysvaltain Tyynenmeren normaaliaika", "CLT": "Chilen normaaliaika", "BT": "Bhutanin aika", "LHST": "Lord Howen normaaliaika", "PDT": "Yhdysvaltain Tyynenmeren kesäaika", "CAT": "Keski-Afrikan aika", "WARST": "Länsi-Argentiinan kesäaika", "AEDT": "Itä-Australian kesäaika", "ECT": "Ecuadorin aika", "NZST": "Uuden-Seelannin normaaliaika", "MEZ": "Keski-Euroopan normaaliaika", "JST": "Japanin normaaliaika", "EST": "Yhdysvaltain itäinen normaaliaika", "HNT": "Newfoundlandin normaaliaika", "GYT": "Guyanan aika", "CLST": "Chilen kesäaika", "ADT": "Kanadan Atlantin kesäaika", "WESZ": "Länsi-Euroopan kesäaika", "TMT": "Turkmenistanin normaaliaika", "TMST": "Turkmenistanin kesäaika", "MST": "Macaon normaaliaika", "COT": "Kolumbian normaaliaika", "AKST": "Alaskan normaaliaika", "HNPM": "Saint-Pierren ja Miquelonin normaaliaika", "CHAST": "Chathamin normaaliaika", "JDT": "Japanin kesäaika", "HEOG": "Länsi-Grönlannin kesäaika", "AST": "Kanadan Atlantin normaaliaika", "HKT": "Hongkongin normaaliaika", "HNNOMX": "Luoteis-Meksikon normaaliaika", "HNEG": "Itä-Grönlannin normaaliaika", "HADT": "Havaijin-Aleuttien kesäaika", "NZDT": "Uuden-Seelannin kesäaika", "ART": "Argentiinan normaaliaika", "SGT": "Singaporen aika", "OESZ": "Itä-Euroopan kesäaika"}, + } +} + +// Locale returns the current translators string locale +func (fi *fi_FI) Locale() string { + return fi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fi_FI' +func (fi *fi_FI) PluralsCardinal() []locales.PluralRule { + return fi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fi_FI' +func (fi *fi_FI) PluralsOrdinal() []locales.PluralRule { + return fi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fi_FI' +func (fi *fi_FI) PluralsRange() []locales.PluralRule { + return fi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fi_FI' +func (fi *fi_FI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fi_FI' +func (fi *fi_FI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fi_FI' +func (fi *fi_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fi *fi_FI) MonthAbbreviated(month time.Month) string { + return fi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fi *fi_FI) MonthsAbbreviated() []string { + return fi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fi *fi_FI) MonthNarrow(month time.Month) string { + return fi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fi *fi_FI) MonthsNarrow() []string { + return fi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fi *fi_FI) MonthWide(month time.Month) string { + return fi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fi *fi_FI) MonthsWide() []string { + return fi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fi *fi_FI) WeekdayAbbreviated(weekday time.Weekday) string { + return fi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fi *fi_FI) WeekdaysAbbreviated() []string { + return fi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fi *fi_FI) WeekdayNarrow(weekday time.Weekday) string { + return fi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fi *fi_FI) WeekdaysNarrow() []string { + return fi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fi *fi_FI) WeekdayShort(weekday time.Weekday) string { + return fi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fi *fi_FI) WeekdaysShort() []string { + return fi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fi *fi_FI) WeekdayWide(weekday time.Weekday) string { + return fi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fi *fi_FI) WeekdaysWide() []string { + return fi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fi_FI' and handles both Whole and Real numbers based on 'v' +func (fi *fi_FI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fi.group) - 1; j >= 0; j-- { + b = append(b, fi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fi.minus) - 1; j >= 0; j-- { + b = append(b, fi.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fi_FI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fi *fi_FI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fi.minus) - 1; j >= 0; j-- { + b = append(b, fi.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fi.percentSuffix...) + + b = append(b, fi.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fi_FI' +func (fi *fi_FI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fi.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fi.group) - 1; j >= 0; j-- { + b = append(b, fi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fi.minus) - 1; j >= 0; j-- { + b = append(b, fi.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fi.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fi_FI' +// in accounting notation. +func (fi *fi_FI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fi.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fi.group) - 1; j >= 0; j-- { + b = append(b, fi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(fi.minus) - 1; j >= 0; j-- { + b = append(b, fi.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fi.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fi.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fi_FI' +func (fi *fi_FI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fi_FI' +func (fi *fi_FI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fi_FI' +func (fi *fi_FI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fi_FI' +func (fi *fi_FI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x63, 0x63, 0x63, 0x63, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fi_FI' +func (fi *fi_FI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fi_FI' +func (fi *fi_FI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fi_FI' +func (fi *fi_FI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fi_FI' +func (fi *fi_FI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fi.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fi_FI/fi_FI_test.go b/vendor/github.com/go-playground/locales/fi_FI/fi_FI_test.go new file mode 100644 index 0000000000..7117b6d398 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fi_FI/fi_FI_test.go @@ -0,0 +1,1120 @@ +package fi_FI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fi_FI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fil/fil.go b/vendor/github.com/go-playground/locales/fil/fil.go new file mode 100644 index 0000000000..a829c5ec70 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fil/fil.go @@ -0,0 +1,645 @@ +package fil + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fil struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fil' locale +func New() locales.Translator { + return &fil{ + locale: "fil", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "₱", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ene", "Peb", "Mar", "Abr", "May", "Hun", "Hul", "Ago", "Set", "Okt", "Nob", "Dis"}, + monthsNarrow: []string{"", "Ene", "Peb", "Mar", "Abr", "May", "Hun", "Hul", "Ago", "Set", "Okt", "Nob", "Dis"}, + monthsWide: []string{"", "Enero", "Pebrero", "Marso", "Abril", "Mayo", "Hunyo", "Hulyo", "Agosto", "Setyembre", "Oktubre", "Nobyembre", "Disyembre"}, + daysAbbreviated: []string{"Lin", "Lun", "Mar", "Miy", "Huw", "Biy", "Sab"}, + daysNarrow: []string{"Lin", "Lun", "Mar", "Miy", "Huw", "Biy", "Sab"}, + daysShort: []string{"Li", "Lu", "Ma", "Mi", "Hu", "Bi", "Sa"}, + daysWide: []string{"Linggo", "Lunes", "Martes", "Miyerkules", "Huwebes", "Biyernes", "Sabado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"BC", "AD"}, + timezones: map[string]string{"HENOMX": "Daylight Time sa Hilagang-kanlurang Mexico", "ACDT": "Daylight Time ng Gitnang Australya", "∅∅∅": "∅∅∅", "JDT": "Daylight Time sa Japan", "MST": "MST", "HKT": "Standard na Oras sa Hong Kong", "EDT": "Eastern Daylight Time", "AKST": "Standard na Oras sa Alaska", "CLT": "Standard na Oras sa Chile", "TMST": "Oras sa Tag-init ng Turkmenistan", "WIB": "Oras ng Kanlurang Indonesiya", "MESZ": "Oras sa Tag-init ng Gitnang Europe", "ART": "Standard na Oras sa Argentina", "BT": "Oras sa Bhutan", "HNT": "Standard na Oras sa Newfoundland", "LHDT": "Daylight Time sa Lorde Howe", "HKST": "Oras sa Tag-init ng Hong Kong", "EST": "Eastern na Standard na Oras", "HEEG": "Oras sa Tag-init ng Silangang Greenland", "PST": "Standard na Oras sa Pasipiko", "HNPM": "Standard na Oras sa Saint Pierre and Miquelon", "EAT": "Oras sa Silangang Africa", "CHADT": "Daylight Time sa Chatham", "ADT": "Daylight Time sa Atlantiko", "WAT": "Standard na Oras sa Kanlurang Africa", "AEST": "Standard Time ng Silangang Australya", "HNOG": "Standard na Oras sa Kanlurang Greenland", "TMT": "Standard na Oras sa Turkmenistan", "WAST": "Oras sa Tag-init ng Kanlurang Africa", "HAT": "Daylight Time sa Newfoundland", "HNCU": "Standard na Oras sa Cuba", "UYT": "Standard na Oras sa Uruguay", "CST": "Sentral na Karaniwang Oras", "NZDT": "Daylight Time sa New Zealand", "IST": "Standard na Oras sa Bhutan", "JST": "Standard na Oras sa Japan", "MDT": "MDT", "ACST": "Standard Time ng Gitnang Australya", "AKDT": "Daylight Time sa Alaska", "BOT": "Oras sa Bolivia", "HAST": "Standard na Oras sa Hawaii-Aleutian", "GMT": "Greenwich Mean Time", "WART": "Standard na Oras sa Kanlurang Argentina", "AST": "Standard na Oras sa Atlantiko", "SRT": "Oras sa Suriname", "GYT": "Oras sa Guyana", "AWST": "Standard Time ng Kanlurang Australya", "HADT": "Oras sa Tag-init ng Hawaii-Aleutian", "HNNOMX": "Standard na Oras sa Hilagang-kanlurang Mexico", "HNPMX": "Standard na Oras sa Pasipiko ng Mexico", "SGT": "Standard na Oras sa Singapore", "GFT": "Oras sa French Guiana", "WITA": "Oras ng Gitnang Indonesiya", "NZST": "Standard na Oras sa New Zealand", "ARST": "Oras sa Tag-init ng Argentina", "COST": "Oras sa Tag-init ng Colombia", "HNEG": "Standard na Oras sa Silangang Greenland", "ACWDT": "Daylight Time ng Gitnang Kanluran ng Australya", "CLST": "Oras sa Tag-init ng Chile", "HEOG": "Oras sa Tag-init ng Kanlurang Greenland", "HECU": "Daylight Time sa Cuba", "CDT": "Sentral na Daylight Time", "ECT": "Oras sa Ecuador", "LHST": "Standard na Oras sa Lord Howe", "PDT": "Daylight Time sa Pasipiko", "MEZ": "Standard na Oras sa Gitnang Europe", "WEZ": "Standard na Oras sa Kanlurang Europe", "MYT": "Oras ng Malaysia", "COT": "Standard na Oras sa Colombia", "AEDT": "Daylight Time ng Silangang Australya", "HEPMX": "Daylight Time sa Pasipiko ng Mexico", "WARST": "Oras sa Tag-init ng Kanlurang Argentina", "AWDT": "Daylight Time sa Kanlurang Australya", "OESZ": "Oras sa Tag-init ng Silangang Europe", "CAT": "Oras sa Gitnang Africa", "VET": "Oras sa Venezuela", "WESZ": "Oras sa Tag-init ng Kanlurang Europe", "HEPM": "Daylight Time sa Saint Pierre and Miquelon", "CHAST": "Standard na Oras sa Chatham", "ACWST": "Standard Time ng Gitnang Kanluran ng Australya", "WIT": "Oras ng Silangang Indonesiya", "OEZ": "Standard na Oras sa Silangang Europe", "ChST": "Standard na Oras sa Chamorro", "UYST": "Oras sa Tag-init ng Uruguay", "SAST": "Oras sa Timog Africa"}, + } +} + +// Locale returns the current translators string locale +func (fil *fil) Locale() string { + return fil.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fil' +func (fil *fil) PluralsCardinal() []locales.PluralRule { + return fil.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fil' +func (fil *fil) PluralsOrdinal() []locales.PluralRule { + return fil.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fil' +func (fil *fil) PluralsRange() []locales.PluralRule { + return fil.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fil' +func (fil *fil) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + fMod10 := f % 10 + + if (v == 0 && (i == 1 || i == 2 || i == 3)) || (v == 0 && (iMod10 != 4 && iMod10 != 6 && iMod10 != 9)) || (v != 0 && (fMod10 != 4 && fMod10 != 6 && fMod10 != 9)) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fil' +func (fil *fil) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fil' +func (fil *fil) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fil.CardinalPluralRule(num1, v1) + end := fil.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fil *fil) MonthAbbreviated(month time.Month) string { + return fil.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fil *fil) MonthsAbbreviated() []string { + return fil.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fil *fil) MonthNarrow(month time.Month) string { + return fil.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fil *fil) MonthsNarrow() []string { + return fil.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fil *fil) MonthWide(month time.Month) string { + return fil.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fil *fil) MonthsWide() []string { + return fil.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fil *fil) WeekdayAbbreviated(weekday time.Weekday) string { + return fil.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fil *fil) WeekdaysAbbreviated() []string { + return fil.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fil *fil) WeekdayNarrow(weekday time.Weekday) string { + return fil.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fil *fil) WeekdaysNarrow() []string { + return fil.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fil *fil) WeekdayShort(weekday time.Weekday) string { + return fil.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fil *fil) WeekdaysShort() []string { + return fil.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fil *fil) WeekdayWide(weekday time.Weekday) string { + return fil.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fil *fil) WeekdaysWide() []string { + return fil.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fil' and handles both Whole and Real numbers based on 'v' +func (fil *fil) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fil.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fil.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fil.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fil' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fil *fil) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fil.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fil.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fil.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fil' +func (fil *fil) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fil.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fil.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fil.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, fil.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fil.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fil' +// in accounting notation. +func (fil *fil) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fil.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fil.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fil.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, fil.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fil.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fil.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fil' +func (fil *fil) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fil' +func (fil *fil) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fil.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fil' +func (fil *fil) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fil.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fil' +func (fil *fil) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fil.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, fil.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fil' +func (fil *fil) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fil.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fil.periodsAbbreviated[0]...) + } else { + b = append(b, fil.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fil' +func (fil *fil) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fil.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fil.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fil.periodsAbbreviated[0]...) + } else { + b = append(b, fil.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fil' +func (fil *fil) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fil.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fil.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fil.periodsAbbreviated[0]...) + } else { + b = append(b, fil.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fil' +func (fil *fil) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fil.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fil.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fil.periodsAbbreviated[0]...) + } else { + b = append(b, fil.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fil.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fil/fil_test.go b/vendor/github.com/go-playground/locales/fil/fil_test.go new file mode 100644 index 0000000000..93b8513061 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fil/fil_test.go @@ -0,0 +1,1120 @@ +package fil + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fil" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fil_PH/fil_PH.go b/vendor/github.com/go-playground/locales/fil_PH/fil_PH.go new file mode 100644 index 0000000000..7401284dc3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fil_PH/fil_PH.go @@ -0,0 +1,645 @@ +package fil_PH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fil_PH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fil_PH' locale +func New() locales.Translator { + return &fil_PH{ + locale: "fil_PH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ene", "Peb", "Mar", "Abr", "May", "Hun", "Hul", "Ago", "Set", "Okt", "Nob", "Dis"}, + monthsNarrow: []string{"", "Ene", "Peb", "Mar", "Abr", "May", "Hun", "Hul", "Ago", "Set", "Okt", "Nob", "Dis"}, + monthsWide: []string{"", "Enero", "Pebrero", "Marso", "Abril", "Mayo", "Hunyo", "Hulyo", "Agosto", "Setyembre", "Oktubre", "Nobyembre", "Disyembre"}, + daysAbbreviated: []string{"Lin", "Lun", "Mar", "Miy", "Huw", "Biy", "Sab"}, + daysNarrow: []string{"Lin", "Lun", "Mar", "Miy", "Huw", "Biy", "Sab"}, + daysShort: []string{"Li", "Lu", "Ma", "Mi", "Hu", "Bi", "Sa"}, + daysWide: []string{"Linggo", "Lunes", "Martes", "Miyerkules", "Huwebes", "Biyernes", "Sabado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"BC", "AD"}, + timezones: map[string]string{"COST": "Oras sa Tag-init ng Colombia", "BT": "Oras sa Bhutan", "HNT": "Standard na Oras sa Newfoundland", "AKDT": "Daylight Time sa Alaska", "AWST": "Standard Time ng Kanlurang Australya", "WAST": "Oras sa Tag-init ng Kanlurang Africa", "EDT": "Eastern Daylight Time", "HKT": "Standard na Oras sa Hong Kong", "WARST": "Oras sa Tag-init ng Kanlurang Argentina", "HEOG": "Oras sa Tag-init ng Kanlurang Greenland", "HKST": "Oras sa Tag-init ng Hong Kong", "AKST": "Standard na Oras sa Alaska", "SGT": "Standard na Oras sa Singapore", "IST": "Standard na Oras sa Bhutan", "GMT": "Greenwich Mean Time", "MST": "MST", "MDT": "MDT", "SAST": "Oras sa Timog Africa", "TMT": "Standard na Oras sa Turkmenistan", "TMST": "Oras sa Tag-init ng Turkmenistan", "ART": "Standard na Oras sa Argentina", "HNNOMX": "Standard na Oras sa Hilagang-kanlurang Mexico", "ACWST": "Standard Time ng Gitnang Kanluran ng Australya", "WART": "Standard na Oras sa Kanlurang Argentina", "HNOG": "Standard na Oras sa Kanlurang Greenland", "OEZ": "Standard na Oras sa Silangang Europe", "ACST": "Standard Time ng Gitnang Australya", "GFT": "Oras sa French Guiana", "HNPMX": "Standard na Oras sa Pasipiko ng Mexico", "ADT": "Daylight Time sa Atlantiko", "OESZ": "Oras sa Tag-init ng Silangang Europe", "HEPMX": "Daylight Time sa Pasipiko ng Mexico", "BOT": "Oras sa Bolivia", "HAST": "Standard na Oras sa Hawaii-Aleutian", "HECU": "Daylight Time sa Cuba", "CHAST": "Standard na Oras sa Chatham", "CHADT": "Daylight Time sa Chatham", "NZST": "Standard na Oras sa New Zealand", "JST": "Standard na Oras sa Japan", "WAT": "Standard na Oras sa Kanlurang Africa", "EST": "Eastern na Standard na Oras", "∅∅∅": "Oras sa Tag-init ng Peru", "WIT": "Oras ng Silangang Indonesiya", "MYT": "Oras ng Malaysia", "COT": "Standard na Oras sa Colombia", "LHST": "Standard na Oras sa Lord Howe", "CDT": "Sentral na Daylight Time", "WESZ": "Oras sa Tag-init ng Kanlurang Europe", "CST": "Sentral na Karaniwang Oras", "HADT": "Oras sa Tag-init ng Hawaii-Aleutian", "CAT": "Oras sa Gitnang Africa", "VET": "Oras sa Venezuela", "UYT": "Standard na Oras sa Uruguay", "EAT": "Oras sa Silangang Africa", "ECT": "Oras sa Ecuador", "HNEG": "Standard na Oras sa Silangang Greenland", "WITA": "Oras ng Gitnang Indonesiya", "HNCU": "Standard na Oras sa Cuba", "AST": "Standard na Oras sa Atlantiko", "AEST": "Standard Time ng Silangang Australya", "UYST": "Oras sa Tag-init ng Uruguay", "JDT": "Daylight Time sa Japan", "HEEG": "Oras sa Tag-init ng Silangang Greenland", "MEZ": "Standard na Oras sa Gitnang Europe", "GYT": "Oras sa Guyana", "ACWDT": "Daylight Time ng Gitnang Kanluran ng Australya", "MESZ": "Oras sa Tag-init ng Gitnang Europe", "AEDT": "Daylight Time ng Silangang Australya", "HNPM": "Standard na Oras sa Saint Pierre and Miquelon", "HEPM": "Daylight Time sa Saint Pierre and Miquelon", "PST": "Standard na Oras sa Pasipiko", "PDT": "Daylight Time sa Pasipiko", "CLST": "Oras sa Tag-init ng Chile", "WEZ": "Standard na Oras sa Kanlurang Europe", "ACDT": "Daylight Time ng Gitnang Australya", "HAT": "Daylight Time sa Newfoundland", "AWDT": "Daylight Time sa Kanlurang Australya", "LHDT": "Daylight Time sa Lorde Howe", "SRT": "Oras sa Suriname", "WIB": "Oras ng Kanlurang Indonesiya", "NZDT": "Daylight Time sa New Zealand", "CLT": "Standard na Oras sa Chile", "ARST": "Oras sa Tag-init ng Argentina", "HENOMX": "Daylight Time sa Hilagang-kanlurang Mexico", "ChST": "Standard na Oras sa Chamorro"}, + } +} + +// Locale returns the current translators string locale +func (fil *fil_PH) Locale() string { + return fil.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fil_PH' +func (fil *fil_PH) PluralsCardinal() []locales.PluralRule { + return fil.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fil_PH' +func (fil *fil_PH) PluralsOrdinal() []locales.PluralRule { + return fil.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fil_PH' +func (fil *fil_PH) PluralsRange() []locales.PluralRule { + return fil.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fil_PH' +func (fil *fil_PH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + fMod10 := f % 10 + + if (v == 0 && (i == 1 || i == 2 || i == 3)) || (v == 0 && (iMod10 != 4 && iMod10 != 6 && iMod10 != 9)) || (v != 0 && (fMod10 != 4 && fMod10 != 6 && fMod10 != 9)) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fil_PH' +func (fil *fil_PH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fil_PH' +func (fil *fil_PH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fil.CardinalPluralRule(num1, v1) + end := fil.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fil *fil_PH) MonthAbbreviated(month time.Month) string { + return fil.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fil *fil_PH) MonthsAbbreviated() []string { + return fil.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fil *fil_PH) MonthNarrow(month time.Month) string { + return fil.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fil *fil_PH) MonthsNarrow() []string { + return fil.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fil *fil_PH) MonthWide(month time.Month) string { + return fil.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fil *fil_PH) MonthsWide() []string { + return fil.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fil *fil_PH) WeekdayAbbreviated(weekday time.Weekday) string { + return fil.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fil *fil_PH) WeekdaysAbbreviated() []string { + return fil.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fil *fil_PH) WeekdayNarrow(weekday time.Weekday) string { + return fil.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fil *fil_PH) WeekdaysNarrow() []string { + return fil.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fil *fil_PH) WeekdayShort(weekday time.Weekday) string { + return fil.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fil *fil_PH) WeekdaysShort() []string { + return fil.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fil *fil_PH) WeekdayWide(weekday time.Weekday) string { + return fil.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fil *fil_PH) WeekdaysWide() []string { + return fil.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fil_PH' and handles both Whole and Real numbers based on 'v' +func (fil *fil_PH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fil.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fil.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fil.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fil_PH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fil *fil_PH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fil.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fil.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fil.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fil_PH' +func (fil *fil_PH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fil.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fil.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fil.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, fil.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fil.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fil_PH' +// in accounting notation. +func (fil *fil_PH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fil.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fil.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fil.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, fil.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fil.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fil.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fil_PH' +func (fil *fil_PH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fil_PH' +func (fil *fil_PH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fil.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fil_PH' +func (fil *fil_PH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fil.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fil_PH' +func (fil *fil_PH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fil.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, fil.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fil_PH' +func (fil *fil_PH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fil.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fil.periodsAbbreviated[0]...) + } else { + b = append(b, fil.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fil_PH' +func (fil *fil_PH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fil.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fil.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fil.periodsAbbreviated[0]...) + } else { + b = append(b, fil.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fil_PH' +func (fil *fil_PH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fil.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fil.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fil.periodsAbbreviated[0]...) + } else { + b = append(b, fil.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fil_PH' +func (fil *fil_PH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fil.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fil.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fil.periodsAbbreviated[0]...) + } else { + b = append(b, fil.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fil.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fil_PH/fil_PH_test.go b/vendor/github.com/go-playground/locales/fil_PH/fil_PH_test.go new file mode 100644 index 0000000000..8770486170 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fil_PH/fil_PH_test.go @@ -0,0 +1,1120 @@ +package fil_PH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fil_PH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fo/fo.go b/vendor/github.com/go-playground/locales/fo/fo.go new file mode 100644 index 0000000000..c360f4046c --- /dev/null +++ b/vendor/github.com/go-playground/locales/fo/fo.go @@ -0,0 +1,610 @@ +package fo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fo' locale +func New() locales.Translator { + return &fo{ + locale: "fo", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "kr", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "mars", "apríl", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"}, + daysAbbreviated: []string{"sun.", "mán.", "týs.", "mik.", "hós.", "frí.", "ley."}, + daysNarrow: []string{"S", "M", "T", "M", "H", "F", "L"}, + daysShort: []string{"su.", "má.", "tý.", "mi.", "hó.", "fr.", "le."}, + daysWide: []string{"sunnudagur", "mánadagur", "týsdagur", "mikudagur", "hósdagur", "fríggjadagur", "leygardagur"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"fKr", "eKr"}, + erasWide: []string{"fyri Krist", "eftir Krist"}, + timezones: map[string]string{"TMT": "Turkmenistan vanlig tíð", "HNEG": "Eystur grønlendsk vanlig tíð", "AKDT": "Alaska summartíð", "AEDT": "eystur Avstralia summartíð", "MST": "Mountain vanlig tíð", "HNCU": "Cuba vanlig tíð", "IST": "India tíð", "VET": "Venesuela tíð", "EST": "Eastern vanlig tíð", "WARST": "Vestur Argentina summartíð", "COST": "Kolombia summartíð", "LHST": "Lord Howe vanlig tíð", "HADT": "Hawaii-Aleutian summartíð", "NZDT": "Nýsæland summartíð", "ADT": "Atlantic summartíð", "OESZ": "Eysturevropa summartíð", "WESZ": "Vesturevropa summartíð", "ART": "Argentina vanlig tíð", "AKST": "Alaska vanlig tíð", "ChST": "Chamorro vanlig tíð", "EAT": "Eysturafrika tíð", "CDT": "Central summartíð", "HAST": "Hawaii-Aleutian vanlig tíð", "CAT": "Miðafrika tíð", "ACDT": "mið Avstralia summartíð", "GYT": "Gujana tíð", "HECU": "Cuba summartíð", "PST": "Pacific vanlig tíð", "JDT": "Japan summartíð", "HEOG": "Vestur grønlendsk summartíð", "ARST": "Argentina summartíð", "LHDT": "Lord Howe summartíð", "ECT": "Ekvador tíð", "OEZ": "Eysturevropa vanlig tíð", "TMST": "Turkmenistan summartíð", "HKT": "Hong Kong vanlig tíð", "ACST": "mið Avstralia vanlig tíð", "MYT": "Malaisia tíð", "HNOG": "Vestur grønlendsk vanlig tíð", "HNNOMX": "Northwest Mexico vanlig tíð", "WAT": "Vesturafrika vanlig tíð", "AEST": "eystur Avstralia vanlig tíð", "ACWST": "miðvestur Avstralia vanlig tíð", "ACWDT": "miðvestur Avstralia summartíð", "WAST": "Vesturafrika summartíð", "BT": "Butan tíð", "UYST": "Uruguai summartíð", "SAST": "Suðurafrika vanlig tíð", "AWDT": "vestur Avstralia summartíð", "WART": "Vestur Argentina vanlig tíð", "MDT": "Mountain summartíð", "UYT": "Uruguai vanlig tíð", "WEZ": "Vesturevropa vanlig tíð", "EDT": "Eastern summartíð", "HNT": "Newfoundland vanlig tíð", "HNPMX": "Mexican Pacific vanlig tíð", "SRT": "Surinam tíð", "SGT": "Singapor tíð", "MEZ": "Miðevropa vanlig tíð", "CLT": "Kili vanlig tíð", "WITA": "Mið Indonesia tíð", "HNPM": "St. Pierre & Miquelon vanlig tíð", "HEPMX": "Mexican Pacific summartíð", "WIB": "Vestur Indonesia tíð", "HKST": "Hong Kong summartíð", "HENOMX": "Northwest Mexico summartíð", "GMT": "Greenwich Mean tíð", "COT": "Kolombia vanlig tíð", "∅∅∅": "∅∅∅", "HEPM": "St. Pierre & Miquelon summartíð", "WIT": "Eystur Indonesia tíð", "CHADT": "Chatham summartíð", "NZST": "Nýsæland vanlig tíð", "MESZ": "Miðevropa summartíð", "HAT": "Newfoundland summartíð", "AWST": "vestur Avstralia vanlig tíð", "BOT": "Bolivia tíð", "PDT": "Pacific summartíð", "JST": "Japan vanlig tíð", "AST": "Atlantic vanlig tíð", "HEEG": "Eystur grønlendsk summartíð", "GFT": "Franska Gujana tíð", "CST": "Central vanlig tíð", "CHAST": "Chatham vanlig tíð", "CLST": "Kili summartíð"}, + } +} + +// Locale returns the current translators string locale +func (fo *fo) Locale() string { + return fo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fo' +func (fo *fo) PluralsCardinal() []locales.PluralRule { + return fo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fo' +func (fo *fo) PluralsOrdinal() []locales.PluralRule { + return fo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fo' +func (fo *fo) PluralsRange() []locales.PluralRule { + return fo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fo' +func (fo *fo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fo' +func (fo *fo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fo' +func (fo *fo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fo *fo) MonthAbbreviated(month time.Month) string { + return fo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fo *fo) MonthsAbbreviated() []string { + return fo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fo *fo) MonthNarrow(month time.Month) string { + return fo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fo *fo) MonthsNarrow() []string { + return fo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fo *fo) MonthWide(month time.Month) string { + return fo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fo *fo) MonthsWide() []string { + return fo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fo *fo) WeekdayAbbreviated(weekday time.Weekday) string { + return fo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fo *fo) WeekdaysAbbreviated() []string { + return fo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fo *fo) WeekdayNarrow(weekday time.Weekday) string { + return fo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fo *fo) WeekdaysNarrow() []string { + return fo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fo *fo) WeekdayShort(weekday time.Weekday) string { + return fo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fo *fo) WeekdaysShort() []string { + return fo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fo *fo) WeekdayWide(weekday time.Weekday) string { + return fo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fo *fo) WeekdaysWide() []string { + return fo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fo' and handles both Whole and Real numbers based on 'v' +func (fo *fo) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fo *fo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fo.percentSuffix...) + + b = append(b, fo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fo' +func (fo *fo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fo.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fo.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fo' +// in accounting notation. +func (fo *fo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fo.currencies[currency] + l := len(s) + len(symbol) + 8 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fo.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fo.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fo.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fo' +func (fo *fo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fo' +func (fo *fo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fo' +func (fo *fo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fo' +func (fo *fo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fo' +func (fo *fo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fo' +func (fo *fo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fo' +func (fo *fo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fo' +func (fo *fo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fo/fo_test.go b/vendor/github.com/go-playground/locales/fo/fo_test.go new file mode 100644 index 0000000000..705d6e95bf --- /dev/null +++ b/vendor/github.com/go-playground/locales/fo/fo_test.go @@ -0,0 +1,1120 @@ +package fo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fo_DK/fo_DK.go b/vendor/github.com/go-playground/locales/fo_DK/fo_DK.go new file mode 100644 index 0000000000..47f35632a1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fo_DK/fo_DK.go @@ -0,0 +1,610 @@ +package fo_DK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fo_DK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fo_DK' locale +func New() locales.Translator { + return &fo_DK{ + locale: "fo_DK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "kr.", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "mars", "apríl", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"}, + daysAbbreviated: []string{"sun.", "mán.", "týs.", "mik.", "hós.", "frí.", "ley."}, + daysNarrow: []string{"S", "M", "T", "M", "H", "F", "L"}, + daysShort: []string{"su.", "má.", "tý.", "mi.", "hó.", "fr.", "le."}, + daysWide: []string{"sunnudagur", "mánadagur", "týsdagur", "mikudagur", "hósdagur", "fríggjadagur", "leygardagur"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"fKr", "eKr"}, + erasWide: []string{"fyri Krist", "eftir Krist"}, + timezones: map[string]string{"CHADT": "Chatham summartíð", "PDT": "Pacific summartíð", "ACWST": "miðvestur Avstralia vanlig tíð", "OEZ": "Eysturevropa vanlig tíð", "TMST": "Turkmenistan summartíð", "HNEG": "Eystur grønlendsk vanlig tíð", "WITA": "Mið Indonesia tíð", "AEST": "eystur Avstralia vanlig tíð", "SAST": "Suðurafrika vanlig tíð", "MEZ": "Miðevropa vanlig tíð", "HNNOMX": "Northwest Mexico vanlig tíð", "PST": "Pacific vanlig tíð", "HAST": "Hawaii-Aleutian vanlig tíð", "WART": "Vestur Argentina vanlig tíð", "CLT": "Kili vanlig tíð", "EDT": "Eastern summartíð", "LHST": "Lord Howe vanlig tíð", "CLST": "Kili summartíð", "WEZ": "Vesturevropa vanlig tíð", "WAST": "Vesturafrika summartíð", "COT": "Kolombia vanlig tíð", "IST": "India tíð", "ACWDT": "miðvestur Avstralia summartíð", "NZST": "Nýsæland vanlig tíð", "AST": "Atlantic vanlig tíð", "BT": "Butan tíð", "UYST": "Uruguai summartíð", "CDT": "Central summartíð", "CHAST": "Chatham vanlig tíð", "HNOG": "Vestur grønlendsk vanlig tíð", "ART": "Argentina vanlig tíð", "HAT": "Newfoundland summartíð", "AKDT": "Alaska summartíð", "ChST": "Chamorro vanlig tíð", "LHDT": "Lord Howe summartíð", "SRT": "Surinam tíð", "HNCU": "Cuba vanlig tíð", "SGT": "Singapor tíð", "ECT": "Ekvador tíð", "JST": "Japan vanlig tíð", "ACDT": "mið Avstralia summartíð", "MST": "MST", "MDT": "MDT", "HKT": "Hong Kong vanlig tíð", "COST": "Kolombia summartíð", "GYT": "Gujana tíð", "CST": "Central vanlig tíð", "BOT": "Bolivia tíð", "AKST": "Alaska vanlig tíð", "HEPMX": "Mexican Pacific summartíð", "ARST": "Argentina summartíð", "WAT": "Vesturafrika vanlig tíð", "HADT": "Hawaii-Aleutian summartíð", "∅∅∅": "Amasona summartíð", "NZDT": "Nýsæland summartíð", "VET": "Venesuela tíð", "ADT": "Atlantic summartíð", "HNT": "Newfoundland vanlig tíð", "HEEG": "Eystur grønlendsk summartíð", "AEDT": "eystur Avstralia summartíð", "AWST": "vestur Avstralia vanlig tíð", "CAT": "Miðafrika tíð", "MESZ": "Miðevropa summartíð", "GMT": "Greenwich Mean tíð", "TMT": "Turkmenistan vanlig tíð", "HKST": "Hong Kong summartíð", "JDT": "Japan summartíð", "ACST": "mið Avstralia vanlig tíð", "HEPM": "St. Pierre & Miquelon summartíð", "EAT": "Eysturafrika tíð", "MYT": "Malaisia tíð", "HNPM": "St. Pierre & Miquelon vanlig tíð", "HNPMX": "Mexican Pacific vanlig tíð", "WIT": "Eystur Indonesia tíð", "WARST": "Vestur Argentina summartíð", "HECU": "Cuba summartíð", "HEOG": "Vestur grønlendsk summartíð", "OESZ": "Eysturevropa summartíð", "WESZ": "Vesturevropa summartíð", "EST": "Eastern vanlig tíð", "HENOMX": "Northwest Mexico summartíð", "GFT": "Franska Gujana tíð", "UYT": "Uruguai vanlig tíð", "WIB": "Vestur Indonesia tíð", "AWDT": "vestur Avstralia summartíð"}, + } +} + +// Locale returns the current translators string locale +func (fo *fo_DK) Locale() string { + return fo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fo_DK' +func (fo *fo_DK) PluralsCardinal() []locales.PluralRule { + return fo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fo_DK' +func (fo *fo_DK) PluralsOrdinal() []locales.PluralRule { + return fo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fo_DK' +func (fo *fo_DK) PluralsRange() []locales.PluralRule { + return fo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fo_DK' +func (fo *fo_DK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fo_DK' +func (fo *fo_DK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fo_DK' +func (fo *fo_DK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fo *fo_DK) MonthAbbreviated(month time.Month) string { + return fo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fo *fo_DK) MonthsAbbreviated() []string { + return fo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fo *fo_DK) MonthNarrow(month time.Month) string { + return fo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fo *fo_DK) MonthsNarrow() []string { + return fo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fo *fo_DK) MonthWide(month time.Month) string { + return fo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fo *fo_DK) MonthsWide() []string { + return fo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fo *fo_DK) WeekdayAbbreviated(weekday time.Weekday) string { + return fo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fo *fo_DK) WeekdaysAbbreviated() []string { + return fo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fo *fo_DK) WeekdayNarrow(weekday time.Weekday) string { + return fo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fo *fo_DK) WeekdaysNarrow() []string { + return fo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fo *fo_DK) WeekdayShort(weekday time.Weekday) string { + return fo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fo *fo_DK) WeekdaysShort() []string { + return fo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fo *fo_DK) WeekdayWide(weekday time.Weekday) string { + return fo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fo *fo_DK) WeekdaysWide() []string { + return fo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fo_DK' and handles both Whole and Real numbers based on 'v' +func (fo *fo_DK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fo_DK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fo *fo_DK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fo.percentSuffix...) + + b = append(b, fo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fo_DK' +func (fo *fo_DK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fo.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fo.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fo_DK' +// in accounting notation. +func (fo *fo_DK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fo.currencies[currency] + l := len(s) + len(symbol) + 8 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fo.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fo.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fo.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fo_DK' +func (fo *fo_DK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fo_DK' +func (fo *fo_DK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fo_DK' +func (fo *fo_DK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fo_DK' +func (fo *fo_DK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fo_DK' +func (fo *fo_DK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fo_DK' +func (fo *fo_DK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fo_DK' +func (fo *fo_DK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fo_DK' +func (fo *fo_DK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fo_DK/fo_DK_test.go b/vendor/github.com/go-playground/locales/fo_DK/fo_DK_test.go new file mode 100644 index 0000000000..51fa3ae2bc --- /dev/null +++ b/vendor/github.com/go-playground/locales/fo_DK/fo_DK_test.go @@ -0,0 +1,1120 @@ +package fo_DK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fo_DK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fo_FO/fo_FO.go b/vendor/github.com/go-playground/locales/fo_FO/fo_FO.go new file mode 100644 index 0000000000..3bbe345fb3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fo_FO/fo_FO.go @@ -0,0 +1,610 @@ +package fo_FO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fo_FO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fo_FO' locale +func New() locales.Translator { + return &fo_FO{ + locale: "fo_FO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "mars", "apríl", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"}, + daysAbbreviated: []string{"sun.", "mán.", "týs.", "mik.", "hós.", "frí.", "ley."}, + daysNarrow: []string{"S", "M", "T", "M", "H", "F", "L"}, + daysShort: []string{"su.", "má.", "tý.", "mi.", "hó.", "fr.", "le."}, + daysWide: []string{"sunnudagur", "mánadagur", "týsdagur", "mikudagur", "hósdagur", "fríggjadagur", "leygardagur"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"fKr", "eKr"}, + erasWide: []string{"fyri Krist", "eftir Krist"}, + timezones: map[string]string{"NZDT": "Nýsæland summartíð", "CAT": "Miðafrika tíð", "MST": "MST", "HNNOMX": "Northwest Mexico vanlig tíð", "HAT": "Newfoundland summartíð", "AWST": "vestur Avstralia vanlig tíð", "ART": "Argentina vanlig tíð", "SGT": "Singapor tíð", "HAST": "Hawaii-Aleutian vanlig tíð", "NZST": "Nýsæland vanlig tíð", "JST": "Japan vanlig tíð", "OEZ": "Eysturevropa vanlig tíð", "EDT": "Eastern summartíð", "ACDT": "mið Avstralia summartíð", "UYT": "Uruguai vanlig tíð", "HEPMX": "Mexican Pacific summartíð", "HECU": "Cuba summartíð", "VET": "Venesuela tíð", "GMT": "Greenwich Mean tíð", "UYST": "Uruguai summartíð", "HNPMX": "Mexican Pacific vanlig tíð", "SAST": "Suðurafrika vanlig tíð", "CDT": "Central summartíð", "ACWST": "miðvestur Avstralia vanlig tíð", "HKT": "Hong Kong vanlig tíð", "BT": "Butan tíð", "TMT": "Turkmenistan vanlig tíð", "WAT": "Vesturafrika vanlig tíð", "HNCU": "Cuba vanlig tíð", "BOT": "Bolivia tíð", "WART": "Vestur Argentina vanlig tíð", "HEOG": "Vestur grønlendsk summartíð", "HKST": "Hong Kong summartíð", "HEEG": "Eystur grønlendsk summartíð", "ECT": "Ekvador tíð", "WESZ": "Vesturevropa summartíð", "HEPM": "St. Pierre & Miquelon summartíð", "ChST": "Chamorro vanlig tíð", "LHDT": "Lord Howe summartíð", "AWDT": "vestur Avstralia summartíð", "TMST": "Turkmenistan summartíð", "LHST": "Lord Howe vanlig tíð", "WIB": "Vestur Indonesia tíð", "ADT": "Atlantic summartíð", "ACST": "mið Avstralia vanlig tíð", "HNEG": "Eystur grønlendsk vanlig tíð", "HNT": "Newfoundland vanlig tíð", "AKST": "Alaska vanlig tíð", "SRT": "Surinam tíð", "OESZ": "Eysturevropa summartíð", "WAST": "Vesturafrika summartíð", "GFT": "Franska Gujana tíð", "PDT": "Pacific summartíð", "WARST": "Vestur Argentina summartíð", "EAT": "Eysturafrika tíð", "CST": "Central vanlig tíð", "ACWDT": "miðvestur Avstralia summartíð", "EST": "Eastern vanlig tíð", "HENOMX": "Northwest Mexico summartíð", "WITA": "Mið Indonesia tíð", "AKDT": "Alaska summartíð", "GYT": "Gujana tíð", "IST": "India tíð", "WEZ": "Vesturevropa vanlig tíð", "MYT": "Malaisia tíð", "MESZ": "Miðevropa summartíð", "CLT": "Kili vanlig tíð", "AST": "Atlantic vanlig tíð", "∅∅∅": "∅∅∅", "AEST": "eystur Avstralia vanlig tíð", "HNPM": "St. Pierre & Miquelon vanlig tíð", "CHAST": "Chatham vanlig tíð", "HADT": "Hawaii-Aleutian summartíð", "WIT": "Eystur Indonesia tíð", "CHADT": "Chatham summartíð", "JDT": "Japan summartíð", "ARST": "Argentina summartíð", "COST": "Kolombia summartíð", "MEZ": "Miðevropa vanlig tíð", "HNOG": "Vestur grønlendsk vanlig tíð", "MDT": "MDT", "COT": "Kolombia vanlig tíð", "AEDT": "eystur Avstralia summartíð", "PST": "Pacific vanlig tíð", "CLST": "Kili summartíð"}, + } +} + +// Locale returns the current translators string locale +func (fo *fo_FO) Locale() string { + return fo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fo_FO' +func (fo *fo_FO) PluralsCardinal() []locales.PluralRule { + return fo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fo_FO' +func (fo *fo_FO) PluralsOrdinal() []locales.PluralRule { + return fo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fo_FO' +func (fo *fo_FO) PluralsRange() []locales.PluralRule { + return fo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fo_FO' +func (fo *fo_FO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fo_FO' +func (fo *fo_FO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fo_FO' +func (fo *fo_FO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fo *fo_FO) MonthAbbreviated(month time.Month) string { + return fo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fo *fo_FO) MonthsAbbreviated() []string { + return fo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fo *fo_FO) MonthNarrow(month time.Month) string { + return fo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fo *fo_FO) MonthsNarrow() []string { + return fo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fo *fo_FO) MonthWide(month time.Month) string { + return fo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fo *fo_FO) MonthsWide() []string { + return fo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fo *fo_FO) WeekdayAbbreviated(weekday time.Weekday) string { + return fo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fo *fo_FO) WeekdaysAbbreviated() []string { + return fo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fo *fo_FO) WeekdayNarrow(weekday time.Weekday) string { + return fo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fo *fo_FO) WeekdaysNarrow() []string { + return fo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fo *fo_FO) WeekdayShort(weekday time.Weekday) string { + return fo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fo *fo_FO) WeekdaysShort() []string { + return fo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fo *fo_FO) WeekdayWide(weekday time.Weekday) string { + return fo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fo *fo_FO) WeekdaysWide() []string { + return fo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fo_FO' and handles both Whole and Real numbers based on 'v' +func (fo *fo_FO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fo_FO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fo *fo_FO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fo.percentSuffix...) + + b = append(b, fo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fo_FO' +func (fo *fo_FO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fo.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(fo.minus) - 1; j >= 0; j-- { + b = append(b, fo.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fo.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fo_FO' +// in accounting notation. +func (fo *fo_FO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fo.currencies[currency] + l := len(s) + len(symbol) + 8 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fo.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fo.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fo.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fo_FO' +func (fo *fo_FO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fo_FO' +func (fo *fo_FO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fo_FO' +func (fo *fo_FO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fo_FO' +func (fo *fo_FO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, fo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fo_FO' +func (fo *fo_FO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fo_FO' +func (fo *fo_FO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fo_FO' +func (fo *fo_FO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fo_FO' +func (fo *fo_FO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fo_FO/fo_FO_test.go b/vendor/github.com/go-playground/locales/fo_FO/fo_FO_test.go new file mode 100644 index 0000000000..fea5ed9af5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fo_FO/fo_FO_test.go @@ -0,0 +1,1120 @@ +package fo_FO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fo_FO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr/fr.go b/vendor/github.com/go-playground/locales/fr/fr.go new file mode 100644 index 0000000000..1e3aa5c4f4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr/fr.go @@ -0,0 +1,619 @@ +package fr + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr' locale +func New() locales.Translator { + return &fr{ + locale: "fr", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "$AR", "ATS", "$AU", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "FB", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "$BM", "$BN", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "$BS", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "$BZ", "$CA", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "$CL", "CNX", "CNY", "$CO", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "£CY", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "$FJ", "£FK", "F", "£GB", "GEK", "GEL", "GHC", "GHS", "£GI", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "£IE", "£IL", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "₤IT", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "£LB", "LKR", "LRD", "lLS", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "fMA", "MCF", "MDC", "MDL", "MGA", "Fmg", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "£MT", "MUR", "MVP", "MVR", "MWK", "$MX", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "$NA", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "$NZ", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "$RH", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "$SB", "SCR", "SDD", "SDG", "SDP", "SEK", "$SG", "SHP", "SIT", "SKK", "SLL", "SOS", "$SR", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "$TT", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$US", "USN", "USS", "UYI", "UYP", "$UY", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WS$", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "DTS", "XEU", "XFO", "XFU", "CFA", "XPD", "FCFP", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"JDT": "heure d’été du Japon", "COST": "heure d’été de Colombie", "AEST": "heure normale de l’Est de l’Australie", "GFT": "heure de la Guyane française", "UYST": "heure d’été de l’Uruguay", "LHST": "heure normale de Lord Howe", "SGT": "heure de Singapour", "JST": "heure normale du Japon", "WESZ": "heure d’été d’Europe de l’Ouest", "COT": "heure normale de Colombie", "ChST": "heure des Chamorro", "MST": "heure normale des Rocheuses", "SRT": "heure du Suriname", "HNCU": "heure normale de Cuba", "ACWDT": "heure d’été du centre-ouest de l’Australie", "VET": "heure du Venezuela", "ADT": "heure d’été de l’Atlantique", "HNT": "heure normale de Terre-Neuve", "∅∅∅": "heure d’été de l’Acre", "PDT": "heure d’été du Pacifique", "MYT": "heure de la Malaisie", "ART": "heure normale d’Argentine", "OESZ": "heure d’été d’Europe de l’Est", "WART": "heure normale de l’Ouest argentin", "WARST": "heure d’été de l’Ouest argentin", "CLT": "heure normale du Chili", "TMST": "heure d’été du Turkménistan", "TMT": "heure normale du Turkménistan", "WAST": "heure d’été d’Afrique de l’Ouest", "HNEG": "heure normale de l’Est du Groenland", "SAST": "heure normale d’Afrique méridionale", "CAT": "heure normale d’Afrique centrale", "ACWST": "heure normale du centre-ouest de l’Australie", "NZST": "heure normale de la Nouvelle-Zélande", "AST": "heure normale de l’Atlantique", "ACST": "heure normale du centre de l’Australie", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "LHDT": "heure d’été de Lord Howe", "WEZ": "heure normale d’Europe de l’Ouest", "EDT": "heure d’été de l’Est", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "GYT": "heure du Guyana", "HECU": "heure d’été de Cuba", "BOT": "heure de Bolivie", "EST": "heure normale de l’Est nord-américain", "HKT": "heure normale de Hong Kong", "HKST": "heure d’été de Hong Kong", "AKST": "heure normale de l’Alaska", "MESZ": "heure d’été d’Europe centrale", "HNOG": "heure normale de l’Ouest du Groenland", "ARST": "heure d’été de l’Argentine", "AEDT": "heure d’été de l’Est de l’Australie", "ECT": "heure de l’Équateur", "NZDT": "heure d’été de la Nouvelle-Zélande", "GMT": "heure moyenne de Greenwich", "UYT": "heure normale de l’Uruguay", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HNPMX": "heure normale du Pacifique mexicain", "HEPMX": "heure d’été du Pacifique mexicain", "WIT": "heure de l’Est indonésien", "MEZ": "heure normale d’Europe centrale", "OEZ": "heure normale d’Europe de l’Est", "HEEG": "heure d’été de l’Est du Groenland", "WITA": "heure du Centre indonésien", "EAT": "heure normale d’Afrique de l’Est", "AWST": "heure normale de l’Ouest de l’Australie", "AWDT": "heure d’été de l’Ouest de l’Australie", "HAST": "heure normale d’Hawaii - Aléoutiennes", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "HAT": "heure d’été de Terre-Neuve", "AKDT": "heure d’été de l’Alaska", "PST": "heure normale du Pacifique nord-américain", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "BT": "heure du Bhoutan", "WIB": "heure de l’Ouest indonésien", "HEOG": "heure d’été de l’Ouest du Groenland", "CLST": "heure d’été du Chili", "WAT": "heure normale d’Afrique de l’Ouest", "ACDT": "heure d’été du centre de l’Australie", "MDT": "heure d’été des Rocheuses", "CDT": "heure d’été du Centre", "IST": "heure de l’Inde", "CST": "heure normale du centre nord-américain", "CHAST": "heure normale des îles Chatham", "CHADT": "heure d’été des îles Chatham"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr' +func (fr *fr) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr' +func (fr *fr) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr' +func (fr *fr) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr' +func (fr *fr) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr' +func (fr *fr) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr' +func (fr *fr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr' and handles both Whole and Real numbers based on 'v' +func (fr *fr) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr' +func (fr *fr) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr' +// in accounting notation. +func (fr *fr) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr' +func (fr *fr) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr' +func (fr *fr) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr' +func (fr *fr) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr' +func (fr *fr) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr' +func (fr *fr) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr' +func (fr *fr) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr' +func (fr *fr) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr' +func (fr *fr) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr/fr_test.go b/vendor/github.com/go-playground/locales/fr/fr_test.go new file mode 100644 index 0000000000..4454d17fd4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr/fr_test.go @@ -0,0 +1,1120 @@ +package fr + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_BE/fr_BE.go b/vendor/github.com/go-playground/locales/fr_BE/fr_BE.go new file mode 100644 index 0000000000..04074c01a4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BE/fr_BE.go @@ -0,0 +1,614 @@ +package fr_BE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_BE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_BE' locale +func New() locales.Translator { + return &fr_BE{ + locale: "fr_BE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"PDT": "heure d’été du Pacifique", "SAST": "heure normale d’Afrique méridionale", "CST": "heure normale du centre nord-américain", "NZDT": "heure d’été de la Nouvelle-Zélande", "WART": "heure normale de l’Ouest argentin", "OESZ": "heure d’été d’Europe de l’Est", "MST": "heure normale de Macao", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HAT": "heure d’été de Terre-Neuve", "AEDT": "heure d’été de l’Est de l’Australie", "SRT": "heure du Suriname", "HNCU": "heure normale de Cuba", "AWDT": "heure d’été de l’Ouest de l’Australie", "COT": "heure normale de Colombie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "HECU": "heure d’été de Cuba", "NZST": "heure normale de la Nouvelle-Zélande", "MEZ": "heure normale d’Europe centrale", "JDT": "heure d’été du Japon", "CLT": "heure normale du Chili", "TMT": "heure normale du Turkménistan", "HKST": "heure d’été de Hong Kong", "HNEG": "heure normale de l’Est du Groenland", "GFT": "heure de la Guyane française", "AKDT": "heure d’été de l’Alaska", "MESZ": "heure d’été d’Europe centrale", "TMST": "heure d’été du Turkménistan", "UYT": "heure normale de l’Uruguay", "CAT": "heure normale d’Afrique centrale", "MYT": "heure de la Malaisie", "WARST": "heure d’été de l’Ouest argentin", "WESZ": "heure d’été d’Europe de l’Ouest", "WAT": "heure normale d’Afrique de l’Ouest", "EST": "heure normale de l’Est nord-américain", "AWST": "heure normale de l’Ouest de l’Australie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "VET": "heure du Venezuela", "GMT": "heure moyenne de Greenwich", "BT": "heure du Bhoutan", "AKST": "heure normale de l’Alaska", "HEPMX": "heure d’été du Pacifique mexicain", "GYT": "heure du Guyana", "SGT": "heure de Singapour", "ACWDT": "heure d’été du centre-ouest de l’Australie", "JST": "heure normale du Japon", "CLST": "heure d’été du Chili", "EDT": "heure d’été de l’Est", "HEEG": "heure d’été de l’Est du Groenland", "LHDT": "heure d’été de Lord Howe", "HKT": "heure normale de Hong Kong", "HNT": "heure normale de Terre-Neuve", "BOT": "heure de Bolivie", "PST": "heure normale du Pacifique nord-américain", "WAST": "heure d’été d’Afrique de l’Ouest", "UYST": "heure d’été de l’Uruguay", "ACWST": "heure normale du centre-ouest de l’Australie", "ARST": "heure d’été de l’Argentine", "WITA": "heure du Centre indonésien", "EAT": "heure normale d’Afrique de l’Est", "CHADT": "heure d’été des îles Chatham", "ECT": "heure de l’Équateur", "HAST": "heure normale d’Hawaii - Aléoutiennes", "AST": "heure normale de l’Atlantique", "ART": "heure normale d’Argentine", "AEST": "heure normale de l’Est de l’Australie", "ChST": "heure des Chamorro", "CHAST": "heure normale des îles Chatham", "HNOG": "heure normale de l’Ouest du Groenland", "HEOG": "heure d’été de l’Ouest du Groenland", "ADT": "heure d’été de l’Atlantique", "MDT": "heure d’été de Macao", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "LHST": "heure normale de Lord Howe", "HNPMX": "heure normale du Pacifique mexicain", "CDT": "heure d’été du Centre", "WIT": "heure de l’Est indonésien", "ACST": "heure normale du centre de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "COST": "heure d’été de Colombie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "∅∅∅": "heure d’été de l’Amazonie", "IST": "heure de l’Inde", "OEZ": "heure normale d’Europe de l’Est", "WEZ": "heure normale d’Europe de l’Ouest", "WIB": "heure de l’Ouest indonésien"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_BE) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_BE' +func (fr *fr_BE) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_BE' +func (fr *fr_BE) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_BE' +func (fr *fr_BE) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BE' +func (fr *fr_BE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BE' +func (fr *fr_BE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_BE' +func (fr *fr_BE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_BE) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_BE) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_BE) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_BE) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_BE) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_BE) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_BE) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_BE) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_BE) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_BE) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_BE) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_BE) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_BE) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_BE) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_BE' and handles both Whole and Real numbers based on 'v' +func (fr *fr_BE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_BE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_BE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BE' +func (fr *fr_BE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BE' +// in accounting notation. +func (fr *fr_BE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_BE' +func (fr *fr_BE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_BE' +func (fr *fr_BE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_BE' +func (fr *fr_BE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_BE' +func (fr *fr_BE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_BE' +func (fr *fr_BE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_BE' +func (fr *fr_BE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_BE' +func (fr *fr_BE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_BE' +func (fr *fr_BE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0x68}...) + b = append(b, []byte{0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0x6d, 0x69, 0x6e}...) + b = append(b, []byte{0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x73}...) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_BE/fr_BE_test.go b/vendor/github.com/go-playground/locales/fr_BE/fr_BE_test.go new file mode 100644 index 0000000000..1fa66bb8ad --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BE/fr_BE_test.go @@ -0,0 +1,1120 @@ +package fr_BE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_BE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_BF/fr_BF.go b/vendor/github.com/go-playground/locales/fr_BF/fr_BF.go new file mode 100644 index 0000000000..e81fc927d9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BF/fr_BF.go @@ -0,0 +1,619 @@ +package fr_BF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_BF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_BF' locale +func New() locales.Translator { + return &fr_BF{ + locale: "fr_BF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"HEEG": "heure d’été de l’Est du Groenland", "ACST": "heure normale du centre de l’Australie", "COST": "heure d’été de Colombie", "OESZ": "heure d’été d’Europe de l’Est", "HAT": "heure d’été de Terre-Neuve", "SRT": "heure du Suriname", "PDT": "heure d’été du Pacifique", "VET": "heure du Venezuela", "CLST": "heure d’été du Chili", "WAT": "heure normale d’Afrique de l’Ouest", "HEPMX": "heure d’été du Pacifique mexicain", "GYT": "heure du Guyana", "BOT": "heure de Bolivie", "NZDT": "heure d’été de la Nouvelle-Zélande", "CLT": "heure normale du Chili", "HNOG": "heure normale de l’Ouest du Groenland", "WEZ": "heure normale d’Europe de l’Ouest", "UYST": "heure d’été de l’Uruguay", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "CAT": "heure normale d’Afrique centrale", "HKST": "heure d’été de Hong Kong", "COT": "heure normale de Colombie", "BT": "heure du Bhoutan", "HECU": "heure d’été de Cuba", "NZST": "heure normale de la Nouvelle-Zélande", "ACWST": "heure normale du centre-ouest de l’Australie", "WART": "heure normale de l’Ouest argentin", "HKT": "heure normale de Hong Kong", "WIB": "heure de l’Ouest indonésien", "ECT": "heure de l’Équateur", "TMT": "heure normale du Turkménistan", "ART": "heure normale d’Argentine", "ACDT": "heure d’été du centre de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "EAT": "heure normale d’Afrique de l’Est", "JST": "heure normale du Japon", "AWDT": "heure d’été de l’Ouest de l’Australie", "CHADT": "heure d’été des îles Chatham", "ACWDT": "heure d’été du centre-ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "AEDT": "heure d’été de l’Est de l’Australie", "HNCU": "heure normale de Cuba", "CST": "heure normale du centre nord-américain", "MYT": "heure de la Malaisie", "MST": "heure normale de Macao", "JDT": "heure d’été du Japon", "WESZ": "heure d’été d’Europe de l’Ouest", "GMT": "heure moyenne de Greenwich", "GFT": "heure de la Guyane française", "LHDT": "heure d’été de Lord Howe", "∅∅∅": "heure d’été de Brasilia", "ADT": "heure d’été de l’Atlantique", "PST": "heure normale du Pacifique nord-américain", "AST": "heure normale de l’Atlantique", "TMST": "heure d’été du Turkménistan", "AKST": "heure normale de l’Alaska", "LHST": "heure normale de Lord Howe", "WIT": "heure de l’Est indonésien", "CHAST": "heure normale des îles Chatham", "OEZ": "heure normale d’Europe de l’Est", "MDT": "heure d’été de Macao", "UYT": "heure normale de l’Uruguay", "SAST": "heure normale d’Afrique méridionale", "CDT": "heure d’été du Centre", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ARST": "heure d’été de l’Argentine", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HNT": "heure normale de Terre-Neuve", "AEST": "heure normale de l’Est de l’Australie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "SGT": "heure de Singapour", "IST": "heure de l’Inde", "WAST": "heure d’été d’Afrique de l’Ouest", "EST": "heure normale de l’Est nord-américain", "EDT": "heure d’été de l’Est", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HNEG": "heure normale de l’Est du Groenland", "AKDT": "heure d’été de l’Alaska", "MESZ": "heure d’été d’Europe centrale", "HEOG": "heure d’été de l’Ouest du Groenland", "ChST": "heure des Chamorro", "WITA": "heure du Centre indonésien", "HNPMX": "heure normale du Pacifique mexicain", "AWST": "heure normale de l’Ouest de l’Australie", "WARST": "heure d’été de l’Ouest argentin"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_BF) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_BF' +func (fr *fr_BF) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_BF' +func (fr *fr_BF) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_BF' +func (fr *fr_BF) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BF' +func (fr *fr_BF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BF' +func (fr *fr_BF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_BF' +func (fr *fr_BF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_BF) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_BF) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_BF) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_BF) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_BF) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_BF) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_BF) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_BF) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_BF) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_BF) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_BF) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_BF) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_BF) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_BF) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_BF' and handles both Whole and Real numbers based on 'v' +func (fr *fr_BF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_BF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_BF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BF' +func (fr *fr_BF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BF' +// in accounting notation. +func (fr *fr_BF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_BF' +func (fr *fr_BF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_BF' +func (fr *fr_BF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_BF' +func (fr *fr_BF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_BF' +func (fr *fr_BF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_BF' +func (fr *fr_BF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_BF' +func (fr *fr_BF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_BF' +func (fr *fr_BF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_BF' +func (fr *fr_BF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_BF/fr_BF_test.go b/vendor/github.com/go-playground/locales/fr_BF/fr_BF_test.go new file mode 100644 index 0000000000..48971885c5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BF/fr_BF_test.go @@ -0,0 +1,1120 @@ +package fr_BF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_BF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_BI/fr_BI.go b/vendor/github.com/go-playground/locales/fr_BI/fr_BI.go new file mode 100644 index 0000000000..26a8074d67 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BI/fr_BI.go @@ -0,0 +1,619 @@ +package fr_BI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_BI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_BI' locale +func New() locales.Translator { + return &fr_BI{ + locale: "fr_BI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "FBu", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"HAST": "heure normale d’Hawaii - Aléoutiennes", "MEZ": "heure normale d’Europe centrale", "MESZ": "heure d’été d’Europe centrale", "ACST": "heure normale du centre de l’Australie", "AEST": "heure normale de l’Est de l’Australie", "HNCU": "heure normale de Cuba", "WARST": "heure d’été de l’Ouest argentin", "AST": "heure normale de l’Atlantique", "ADT": "heure d’été de l’Atlantique", "WAT": "heure normale d’Afrique de l’Ouest", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "TMST": "heure d’été du Turkménistan", "ART": "heure normale d’Argentine", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HEEG": "heure d’été de l’Est du Groenland", "WESZ": "heure d’été d’Europe de l’Ouest", "UYST": "heure d’été de l’Uruguay", "LHDT": "heure d’été de Lord Howe", "MYT": "heure de la Malaisie", "WAST": "heure d’été d’Afrique de l’Ouest", "MST": "heure normale des Rocheuses", "AKDT": "heure d’été de l’Alaska", "SAST": "heure normale d’Afrique méridionale", "CST": "heure normale du centre nord-américain", "ECT": "heure de l’Équateur", "ARST": "heure d’été de l’Argentine", "AKST": "heure normale de l’Alaska", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "LHST": "heure normale de Lord Howe", "TMT": "heure normale du Turkménistan", "GFT": "heure de la Guyane française", "EAT": "heure normale d’Afrique de l’Est", "JDT": "heure d’été du Japon", "SGT": "heure de Singapour", "CHAST": "heure normale des îles Chatham", "IST": "heure de l’Inde", "CAT": "heure normale d’Afrique centrale", "HKST": "heure d’été de Hong Kong", "HNT": "heure normale de Terre-Neuve", "SRT": "heure du Suriname", "MDT": "heure d’été des Rocheuses", "HNPMX": "heure normale du Pacifique mexicain", "ACWST": "heure normale du centre-ouest de l’Australie", "CLT": "heure normale du Chili", "EST": "heure normale de l’Est nord-américain", "COT": "heure normale de Colombie", "HAT": "heure d’été de Terre-Neuve", "UYT": "heure normale de l’Uruguay", "HECU": "heure d’été de Cuba", "AWST": "heure normale de l’Ouest de l’Australie", "PST": "heure normale du Pacifique nord-américain", "EDT": "heure d’été de l’Est", "COST": "heure d’été de Colombie", "AEDT": "heure d’été de l’Est de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "WART": "heure normale de l’Ouest argentin", "GMT": "heure moyenne de Greenwich", "HKT": "heure normale de Hong Kong", "BOT": "heure de Bolivie", "JST": "heure normale du Japon", "OESZ": "heure d’été d’Europe de l’Est", "HEOG": "heure d’été de l’Ouest du Groenland", "WITA": "heure du Centre indonésien", "GYT": "heure du Guyana", "OEZ": "heure normale d’Europe de l’Est", "CDT": "heure d’été du Centre", "CHADT": "heure d’été des îles Chatham", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "CLST": "heure d’été du Chili", "∅∅∅": "heure d’été de l’Acre", "BT": "heure du Bhoutan", "WIB": "heure de l’Ouest indonésien", "ChST": "heure des Chamorro", "WIT": "heure de l’Est indonésien", "PDT": "heure d’été du Pacifique", "ACWDT": "heure d’été du centre-ouest de l’Australie", "NZST": "heure normale de la Nouvelle-Zélande", "NZDT": "heure d’été de la Nouvelle-Zélande", "VET": "heure du Venezuela", "WEZ": "heure normale d’Europe de l’Ouest", "HNEG": "heure normale de l’Est du Groenland", "HEPMX": "heure d’été du Pacifique mexicain", "AWDT": "heure d’été de l’Ouest de l’Australie", "HNOG": "heure normale de l’Ouest du Groenland"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_BI) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_BI' +func (fr *fr_BI) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_BI' +func (fr *fr_BI) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_BI' +func (fr *fr_BI) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BI' +func (fr *fr_BI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BI' +func (fr *fr_BI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_BI' +func (fr *fr_BI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_BI) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_BI) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_BI) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_BI) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_BI) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_BI) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_BI) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_BI) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_BI) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_BI) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_BI) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_BI) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_BI) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_BI) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_BI' and handles both Whole and Real numbers based on 'v' +func (fr *fr_BI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_BI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_BI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BI' +func (fr *fr_BI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BI' +// in accounting notation. +func (fr *fr_BI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_BI' +func (fr *fr_BI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_BI' +func (fr *fr_BI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_BI' +func (fr *fr_BI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_BI' +func (fr *fr_BI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_BI' +func (fr *fr_BI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_BI' +func (fr *fr_BI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_BI' +func (fr *fr_BI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_BI' +func (fr *fr_BI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_BI/fr_BI_test.go b/vendor/github.com/go-playground/locales/fr_BI/fr_BI_test.go new file mode 100644 index 0000000000..30666b8a2a --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BI/fr_BI_test.go @@ -0,0 +1,1120 @@ +package fr_BI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_BI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_BJ/fr_BJ.go b/vendor/github.com/go-playground/locales/fr_BJ/fr_BJ.go new file mode 100644 index 0000000000..810ba65ec1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BJ/fr_BJ.go @@ -0,0 +1,619 @@ +package fr_BJ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_BJ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_BJ' locale +func New() locales.Translator { + return &fr_BJ{ + locale: "fr_BJ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"SGT": "heure de Singapour", "IST": "heure de l’Inde", "HNOG": "heure normale de l’Ouest du Groenland", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "AKDT": "heure d’été de l’Alaska", "AWST": "heure normale de l’Ouest de l’Australie", "MDT": "heure d’été de Macao", "WAST": "heure d’été d’Afrique de l’Ouest", "LHST": "heure normale de Lord Howe", "CDT": "heure d’été du Centre", "PST": "heure normale du Pacifique nord-américain", "HAST": "heure normale d’Hawaii - Aléoutiennes", "WESZ": "heure d’été d’Europe de l’Ouest", "COST": "heure d’été de Colombie", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "CHADT": "heure d’été des îles Chatham", "CLT": "heure normale du Chili", "CLST": "heure d’été du Chili", "EDT": "heure d’été de l’Est", "BT": "heure du Bhoutan", "WIT": "heure de l’Est indonésien", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "ECT": "heure de l’Équateur", "WEZ": "heure normale d’Europe de l’Ouest", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "GYT": "heure du Guyana", "HNCU": "heure normale de Cuba", "AWDT": "heure d’été de l’Ouest de l’Australie", "NZDT": "heure d’été de la Nouvelle-Zélande", "ARST": "heure d’été de l’Argentine", "HNT": "heure normale de Terre-Neuve", "UYT": "heure normale de l’Uruguay", "JDT": "heure d’été du Japon", "AST": "heure normale de l’Atlantique", "HEOG": "heure d’été de l’Ouest du Groenland", "TMT": "heure normale du Turkménistan", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "CST": "heure normale du centre nord-américain", "MYT": "heure de la Malaisie", "HNEG": "heure normale de l’Est du Groenland", "AKST": "heure normale de l’Alaska", "SRT": "heure du Suriname", "WIB": "heure de l’Ouest indonésien", "OEZ": "heure normale d’Europe de l’Est", "HEEG": "heure d’été de l’Est du Groenland", "AEST": "heure normale de l’Est de l’Australie", "LHDT": "heure d’été de Lord Howe", "CHAST": "heure normale des îles Chatham", "TMST": "heure d’été du Turkménistan", "WAT": "heure normale d’Afrique de l’Ouest", "GFT": "heure de la Guyane française", "PDT": "heure d’été du Pacifique", "MESZ": "heure d’été d’Europe centrale", "ADT": "heure d’été de l’Atlantique", "OESZ": "heure d’été d’Europe de l’Est", "ACDT": "heure d’été du centre de l’Australie", "UYST": "heure d’été de l’Uruguay", "ACWST": "heure normale du centre-ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "VET": "heure du Venezuela", "WART": "heure normale de l’Ouest argentin", "ART": "heure normale d’Argentine", "COT": "heure normale de Colombie", "NZST": "heure normale de la Nouvelle-Zélande", "ChST": "heure des Chamorro", "SAST": "heure normale d’Afrique méridionale", "HEPMX": "heure d’été du Pacifique mexicain", "HAT": "heure d’été de Terre-Neuve", "BOT": "heure de Bolivie", "CAT": "heure normale d’Afrique centrale", "JST": "heure normale du Japon", "GMT": "heure moyenne de Greenwich", "MST": "heure normale de Macao", "HKT": "heure normale de Hong Kong", "HKST": "heure d’été de Hong Kong", "ACST": "heure normale du centre de l’Australie", "AEDT": "heure d’été de l’Est de l’Australie", "WITA": "heure du Centre indonésien", "EAT": "heure normale d’Afrique de l’Est", "ACWDT": "heure d’été du centre-ouest de l’Australie", "∅∅∅": "heure d’été de l’Amazonie", "WARST": "heure d’été de l’Ouest argentin", "EST": "heure normale de l’Est nord-américain", "HNPMX": "heure normale du Pacifique mexicain", "HECU": "heure d’été de Cuba"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_BJ) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_BJ' +func (fr *fr_BJ) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_BJ' +func (fr *fr_BJ) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_BJ' +func (fr *fr_BJ) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BJ' +func (fr *fr_BJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BJ' +func (fr *fr_BJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_BJ' +func (fr *fr_BJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_BJ) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_BJ) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_BJ) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_BJ) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_BJ) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_BJ) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_BJ) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_BJ) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_BJ) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_BJ) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_BJ) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_BJ) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_BJ) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_BJ) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_BJ' and handles both Whole and Real numbers based on 'v' +func (fr *fr_BJ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_BJ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_BJ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BJ' +func (fr *fr_BJ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BJ' +// in accounting notation. +func (fr *fr_BJ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_BJ' +func (fr *fr_BJ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_BJ' +func (fr *fr_BJ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_BJ' +func (fr *fr_BJ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_BJ' +func (fr *fr_BJ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_BJ' +func (fr *fr_BJ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_BJ' +func (fr *fr_BJ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_BJ' +func (fr *fr_BJ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_BJ' +func (fr *fr_BJ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_BJ/fr_BJ_test.go b/vendor/github.com/go-playground/locales/fr_BJ/fr_BJ_test.go new file mode 100644 index 0000000000..c4ebc88409 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BJ/fr_BJ_test.go @@ -0,0 +1,1120 @@ +package fr_BJ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_BJ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_BL/fr_BL.go b/vendor/github.com/go-playground/locales/fr_BL/fr_BL.go new file mode 100644 index 0000000000..1ce1559282 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BL/fr_BL.go @@ -0,0 +1,619 @@ +package fr_BL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_BL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_BL' locale +func New() locales.Translator { + return &fr_BL{ + locale: "fr_BL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"JST": "heure normale du Japon", "TMST": "heure d’été du Turkménistan", "MDT": "heure d’été de Macao", "HKST": "heure d’été de Hong Kong", "BT": "heure du Bhoutan", "ECT": "heure de l’Équateur", "IST": "heure de l’Inde", "GFT": "heure de la Guyane française", "AEST": "heure normale de l’Est de l’Australie", "JDT": "heure d’été du Japon", "GMT": "heure moyenne de Greenwich", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "MESZ": "heure d’été d’Europe centrale", "WEZ": "heure normale d’Europe de l’Ouest", "ChST": "heure des Chamorro", "PST": "heure normale du Pacifique nord-américain", "HAST": "heure normale d’Hawaii - Aléoutiennes", "HNOG": "heure normale de l’Ouest du Groenland", "MST": "heure normale de Macao", "WITA": "heure du Centre indonésien", "WIT": "heure de l’Est indonésien", "CAT": "heure normale d’Afrique centrale", "WARST": "heure d’été de l’Ouest argentin", "NZST": "heure normale de la Nouvelle-Zélande", "CLST": "heure d’été du Chili", "OESZ": "heure d’été d’Europe de l’Est", "∅∅∅": "heure d’été de l’Amazonie", "ACWDT": "heure d’été du centre-ouest de l’Australie", "HNPMX": "heure normale du Pacifique mexicain", "HEPMX": "heure d’été du Pacifique mexicain", "GYT": "heure du Guyana", "WAST": "heure d’été d’Afrique de l’Ouest", "COST": "heure d’été de Colombie", "WESZ": "heure d’été d’Europe de l’Ouest", "TMT": "heure normale du Turkménistan", "EDT": "heure d’été de l’Est", "UYT": "heure normale de l’Uruguay", "LHDT": "heure d’été de Lord Howe", "SGT": "heure de Singapour", "VET": "heure du Venezuela", "CHADT": "heure d’été des îles Chatham", "HEOG": "heure d’été de l’Ouest du Groenland", "HNCU": "heure normale de Cuba", "CDT": "heure d’été du Centre", "ACWST": "heure normale du centre-ouest de l’Australie", "ARST": "heure d’été de l’Argentine", "ART": "heure normale d’Argentine", "ACST": "heure normale du centre de l’Australie", "HAT": "heure d’été de Terre-Neuve", "HNEG": "heure normale de l’Est du Groenland", "HEEG": "heure d’été de l’Est du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "CHAST": "heure normale des îles Chatham", "WART": "heure normale de l’Ouest argentin", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "AKST": "heure normale de l’Alaska", "AKDT": "heure d’été de l’Alaska", "CST": "heure normale du centre nord-américain", "ADT": "heure d’été de l’Atlantique", "HKT": "heure normale de Hong Kong", "ACDT": "heure d’été du centre de l’Australie", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "SAST": "heure normale d’Afrique méridionale", "SRT": "heure du Suriname", "EAT": "heure normale d’Afrique de l’Est", "BOT": "heure de Bolivie", "OEZ": "heure normale d’Europe de l’Est", "WIB": "heure de l’Ouest indonésien", "HECU": "heure d’été de Cuba", "AST": "heure normale de l’Atlantique", "COT": "heure normale de Colombie", "CLT": "heure normale du Chili", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HNT": "heure normale de Terre-Neuve", "PDT": "heure d’été du Pacifique", "MEZ": "heure normale d’Europe centrale", "MYT": "heure de la Malaisie", "WAT": "heure normale d’Afrique de l’Ouest", "EST": "heure normale de l’Est nord-américain", "LHST": "heure normale de Lord Howe", "AWST": "heure normale de l’Ouest de l’Australie", "AWDT": "heure d’été de l’Ouest de l’Australie", "NZDT": "heure d’été de la Nouvelle-Zélande", "UYST": "heure d’été de l’Uruguay"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_BL) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_BL' +func (fr *fr_BL) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_BL' +func (fr *fr_BL) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_BL' +func (fr *fr_BL) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BL' +func (fr *fr_BL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_BL' +func (fr *fr_BL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_BL' +func (fr *fr_BL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_BL) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_BL) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_BL) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_BL) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_BL) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_BL) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_BL) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_BL) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_BL) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_BL) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_BL) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_BL) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_BL) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_BL) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_BL' and handles both Whole and Real numbers based on 'v' +func (fr *fr_BL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_BL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_BL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BL' +func (fr *fr_BL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_BL' +// in accounting notation. +func (fr *fr_BL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_BL' +func (fr *fr_BL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_BL' +func (fr *fr_BL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_BL' +func (fr *fr_BL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_BL' +func (fr *fr_BL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_BL' +func (fr *fr_BL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_BL' +func (fr *fr_BL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_BL' +func (fr *fr_BL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_BL' +func (fr *fr_BL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_BL/fr_BL_test.go b/vendor/github.com/go-playground/locales/fr_BL/fr_BL_test.go new file mode 100644 index 0000000000..1dcfc4951a --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_BL/fr_BL_test.go @@ -0,0 +1,1120 @@ +package fr_BL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_BL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_CA/fr_CA.go b/vendor/github.com/go-playground/locales/fr_CA/fr_CA.go new file mode 100644 index 0000000000..3785aadad2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CA/fr_CA.go @@ -0,0 +1,571 @@ +package fr_CA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_CA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_CA' locale +func New() locales.Translator { + return &fr_CA{ + locale: "fr_CA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$\u00a0AU", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "$\u00a0HK", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "CF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "C$", "NLG", "NOK", "NPR", "$\u00a0NZ", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "$\u00a0SG", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TL", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$\u00a0US", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZK", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " mn ", + currencyNegativeSuffix: " mn ", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juill.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"avant l’ère chrétienne", "de l’ère chrétienne"}, + timezones: map[string]string{"JDT": "heure avancée du Japon", "HNEG": "heure normale de l’Est du Groenland", "AEDT": "heure avancée de l’Est de l’Australie", "CDT": "heure avancée du Centre", "HEOG": "heure avancée de l’Ouest du Groenland", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "AKDT": "heure avancée de l’Alaska", "GYT": "heure du Guyana", "HECU": "heure avancée de Cuba", "CST": "heure normale du Centre", "AWST": "heure normale de l’Ouest de l’Australie", "WAST": "heure avancée d’Afrique de l’Ouest", "ChST": "heure des Chamorro", "HNCU": "heure normale de Cuba", "BOT": "heure de Bolivie", "CHAST": "heure normale des Îles Chatham", "CHADT": "heure avancée des Îles Chatham", "MEZ": "heure normale d’Europe centrale", "WESZ": "heure avancée d’Europe de l’Ouest", "EST": "heure normale de l’Est", "COT": "heure normale de Colombie", "WIT": "heure de l’Est indonésien", "GMT": "heure moyenne de Greenwich", "MYT": "heure de la Malaisie", "CLT": "heure normale du Chili", "HENOMX": "heure avancée du Nord-Ouest du Mexique", "HEEG": "heure avancée de l’Est du Groenland", "AEST": "heure normale de l’Est de l’Australie", "HAST": "heure normale d’Hawaï-Aléoutiennes", "HADT": "heure avancée d’Hawaï-Aléoutiennes", "ECT": "heure de l’Équateur", "PST": "heure normale du Pacifique", "PDT": "heure avancée du Pacifique", "MDT": "heure avancée de Macao", "ARST": "heure avancée de l’Argentine", "WIB": "heure de l’Ouest indonésien", "ACWDT": "heure avancée du centre-ouest de l’Australie", "WEZ": "heure normale d’Europe de l’Ouest", "CLST": "heure avancée du Chili", "UYT": "heure normale de l’Uruguay", "WART": "heure normale de l’Ouest argentin", "EDT": "heure avancée de l’Est", "HNT": "heure normale de Terre-Neuve", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "EAT": "Heure d’Afrique orientale", "NZDT": "heure avancée de la Nouvelle-Zélande", "ADT": "heure avancée de l’Atlantique", "COST": "heure avancée de Colombie", "HNPMX": "heure normale du Pacifique mexicain", "SRT": "heure du Suriname", "HNOG": "heure normale de l’Ouest du Groenland", "MST": "heure normale de Macao", "ACST": "heure normale du centre de l’Australie", "∅∅∅": "heure avancée de l’Acre", "UYST": "heure avancée de l’Uruguay", "SGT": "heure de Singapour", "NZST": "heure normale de la Nouvelle-Zélande", "CAT": "heure d’Afrique centrale", "WARST": "heure avancée de l’Ouest argentin", "WAT": "heure normale d’Afrique de l’Ouest", "GFT": "heure de Guyane française", "HEPM": "heure avancée de Saint-Pierre-et-Miquelon", "IST": "heure de l’Inde", "MESZ": "heure avancée d’Europe centrale", "AST": "heure normale de l’Atlantique", "OEZ": "heure normale d’Europe de l’Est", "WITA": "heure du Centre indonésien", "AKST": "heure normale de l’Alaska", "HEPMX": "heure avancée du Pacifique mexicain", "VET": "heure du Venezuela", "HKST": "heure avancée de Hong Kong", "BT": "heure du Bhoutan", "JST": "heure normale du Japon", "LHDT": "heure avancée de Lord Howe", "OESZ": "heure avancée d’Europe de l’Est", "TMT": "heure normale du Turkménistan", "ACDT": "heure avancée du centre de l’Australie", "SAST": "heure normale d’Afrique du Sud", "LHST": "heure normale de Lord Howe", "AWDT": "heure avancée de l’Ouest de l’Australie", "ACWST": "heure normale du centre-ouest de l’Australie", "TMST": "heure avancée du Turkménistan", "ART": "heure normale d’Argentine", "HKT": "heure normale de Hong Kong", "HAT": "heure avancée de Terre-Neuve"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_CA) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_CA' +func (fr *fr_CA) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_CA' +func (fr *fr_CA) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_CA' +func (fr *fr_CA) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CA' +func (fr *fr_CA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CA' +func (fr *fr_CA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_CA' +func (fr *fr_CA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_CA) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_CA) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_CA) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_CA) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_CA) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_CA) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_CA) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_CA) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_CA) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_CA) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_CA) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_CA) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_CA) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_CA) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CA' and handles both Whole and Real numbers based on 'v' +func (fr *fr_CA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_CA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CA' +func (fr *fr_CA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 8 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CA' +// in accounting notation. +func (fr *fr_CA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 8 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_CA' +func (fr *fr_CA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_CA' +func (fr *fr_CA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_CA' +func (fr *fr_CA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_CA' +func (fr *fr_CA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_CA' +func (fr *fr_CA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0x68}...) + b = append(b, []byte{0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_CA' +func (fr *fr_CA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_CA' +func (fr *fr_CA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_CA' +func (fr *fr_CA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_CA/fr_CA_test.go b/vendor/github.com/go-playground/locales/fr_CA/fr_CA_test.go new file mode 100644 index 0000000000..8e9f0fa336 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CA/fr_CA_test.go @@ -0,0 +1,1120 @@ +package fr_CA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_CA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_CD/fr_CD.go b/vendor/github.com/go-playground/locales/fr_CD/fr_CD.go new file mode 100644 index 0000000000..5aa0a4da69 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CD/fr_CD.go @@ -0,0 +1,619 @@ +package fr_CD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_CD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_CD' locale +func New() locales.Translator { + return &fr_CD{ + locale: "fr_CD", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "FC", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"CHADT": "heure d’été des îles Chatham", "AKDT": "heure d’été de l’Alaska", "UYT": "heure normale de l’Uruguay", "LHST": "heure normale de Lord Howe", "HEPMX": "heure d’été du Pacifique mexicain", "WIT": "heure de l’Est indonésien", "GFT": "heure de la Guyane française", "MYT": "heure de la Malaisie", "TMST": "heure d’été du Turkménistan", "HKT": "heure normale de Hong Kong", "HECU": "heure d’été de Cuba", "WAST": "heure d’été d’Afrique de l’Ouest", "LHDT": "heure d’été de Lord Howe", "ACWST": "heure normale du centre-ouest de l’Australie", "MESZ": "heure d’été d’Europe centrale", "ARST": "heure d’été de l’Argentine", "HNT": "heure normale de Terre-Neuve", "AEDT": "heure d’été de l’Est de l’Australie", "JST": "heure normale du Japon", "TMT": "heure normale du Turkménistan", "HNCU": "heure normale de Cuba", "AWST": "heure normale de l’Ouest de l’Australie", "BOT": "heure de Bolivie", "ECT": "heure de l’Équateur", "MEZ": "heure normale d’Europe centrale", "EST": "heure normale de l’Est nord-américain", "WAT": "heure normale d’Afrique de l’Ouest", "MST": "heure normale des Rocheuses", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "VET": "heure du Venezuela", "HNOG": "heure normale de l’Ouest du Groenland", "ADT": "heure d’été de l’Atlantique", "CDT": "heure d’été du Centre", "AWDT": "heure d’été de l’Ouest de l’Australie", "HKST": "heure d’été de Hong Kong", "COST": "heure d’été de Colombie", "UYST": "heure d’été de l’Uruguay", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "WEZ": "heure normale d’Europe de l’Ouest", "HAT": "heure d’été de Terre-Neuve", "HEEG": "heure d’été de l’Est du Groenland", "CLST": "heure d’été du Chili", "AST": "heure normale de l’Atlantique", "ACST": "heure normale du centre de l’Australie", "MDT": "heure d’été des Rocheuses", "HNPMX": "heure normale du Pacifique mexicain", "SGT": "heure de Singapour", "JDT": "heure d’été du Japon", "GMT": "heure moyenne de Greenwich", "HNEG": "heure normale de l’Est du Groenland", "SRT": "heure du Suriname", "∅∅∅": "heure d’été des Açores", "CAT": "heure normale d’Afrique centrale", "OEZ": "heure normale d’Europe de l’Est", "EDT": "heure d’été de l’Est", "BT": "heure du Bhoutan", "WITA": "heure du Centre indonésien", "CST": "heure normale du centre nord-américain", "PST": "heure normale du Pacifique nord-américain", "NZST": "heure normale de la Nouvelle-Zélande", "WART": "heure normale de l’Ouest argentin", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "AEST": "heure normale de l’Est de l’Australie", "GYT": "heure du Guyana", "EAT": "heure normale d’Afrique de l’Est", "NZDT": "heure d’été de la Nouvelle-Zélande", "WESZ": "heure d’été d’Europe de l’Ouest", "HEOG": "heure d’été de l’Ouest du Groenland", "ART": "heure normale d’Argentine", "ChST": "heure des Chamorro", "WIB": "heure de l’Ouest indonésien", "HAST": "heure normale d’Hawaii - Aléoutiennes", "OESZ": "heure d’été d’Europe de l’Est", "CLT": "heure normale du Chili", "AKST": "heure normale de l’Alaska", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "WARST": "heure d’été de l’Ouest argentin", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "ACDT": "heure d’été du centre de l’Australie", "COT": "heure normale de Colombie", "SAST": "heure normale d’Afrique méridionale", "CHAST": "heure normale des îles Chatham", "PDT": "heure d’été du Pacifique", "IST": "heure de l’Inde", "ACWDT": "heure d’été du centre-ouest de l’Australie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_CD) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_CD' +func (fr *fr_CD) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_CD' +func (fr *fr_CD) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_CD' +func (fr *fr_CD) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CD' +func (fr *fr_CD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CD' +func (fr *fr_CD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_CD' +func (fr *fr_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_CD) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_CD) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_CD) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_CD) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_CD) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_CD) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_CD) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_CD) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_CD) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_CD) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_CD) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_CD) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_CD) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_CD) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CD' and handles both Whole and Real numbers based on 'v' +func (fr *fr_CD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_CD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CD' +func (fr *fr_CD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CD' +// in accounting notation. +func (fr *fr_CD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_CD' +func (fr *fr_CD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_CD' +func (fr *fr_CD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_CD' +func (fr *fr_CD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_CD' +func (fr *fr_CD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_CD' +func (fr *fr_CD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_CD' +func (fr *fr_CD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_CD' +func (fr *fr_CD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_CD' +func (fr *fr_CD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_CD/fr_CD_test.go b/vendor/github.com/go-playground/locales/fr_CD/fr_CD_test.go new file mode 100644 index 0000000000..2cf58704fe --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CD/fr_CD_test.go @@ -0,0 +1,1120 @@ +package fr_CD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_CD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_CF/fr_CF.go b/vendor/github.com/go-playground/locales/fr_CF/fr_CF.go new file mode 100644 index 0000000000..b5fb9a4326 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CF/fr_CF.go @@ -0,0 +1,619 @@ +package fr_CF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_CF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_CF' locale +func New() locales.Translator { + return &fr_CF{ + locale: "fr_CF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"AEDT": "heure d’été de l’Est de l’Australie", "LHDT": "heure d’été de Lord Howe", "JST": "heure normale du Japon", "WEZ": "heure normale d’Europe de l’Ouest", "TMT": "heure normale du Turkménistan", "GFT": "heure de la Guyane française", "COST": "heure d’été de Colombie", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HNT": "heure normale de Terre-Neuve", "LHST": "heure normale de Lord Howe", "AWDT": "heure d’été de l’Ouest de l’Australie", "CHAST": "heure normale des îles Chatham", "SGT": "heure de Singapour", "BOT": "heure de Bolivie", "HNPMX": "heure normale du Pacifique mexicain", "UYT": "heure normale de l’Uruguay", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "MEZ": "heure normale d’Europe centrale", "ARST": "heure d’été de l’Argentine", "WAST": "heure d’été d’Afrique de l’Ouest", "HAT": "heure d’été de Terre-Neuve", "AKDT": "heure d’été de l’Alaska", "HAST": "heure normale d’Hawaii - Aléoutiennes", "VET": "heure du Venezuela", "ADT": "heure d’été de l’Atlantique", "WESZ": "heure d’été d’Europe de l’Ouest", "ACST": "heure normale du centre de l’Australie", "COT": "heure normale de Colombie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "SAST": "heure normale d’Afrique méridionale", "CHADT": "heure d’été des îles Chatham", "WART": "heure normale de l’Ouest argentin", "AST": "heure normale de l’Atlantique", "MST": "heure normale de Macao", "BT": "heure du Bhoutan", "AEST": "heure normale de l’Est de l’Australie", "HECU": "heure d’été de Cuba", "WIB": "heure de l’Ouest indonésien", "AWST": "heure normale de l’Ouest de l’Australie", "CLST": "heure d’été du Chili", "TMST": "heure d’été du Turkménistan", "HKST": "heure d’été de Hong Kong", "HKT": "heure normale de Hong Kong", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HEPMX": "heure d’été du Pacifique mexicain", "CDT": "heure d’été du Centre", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "CLT": "heure normale du Chili", "GMT": "heure moyenne de Greenwich", "CST": "heure normale du centre nord-américain", "EDT": "heure d’été de l’Est", "AKST": "heure normale de l’Alaska", "ACWST": "heure normale du centre-ouest de l’Australie", "UYST": "heure d’été de l’Uruguay", "HNCU": "heure normale de Cuba", "HNEG": "heure normale de l’Est du Groenland", "SRT": "heure du Suriname", "MESZ": "heure d’été d’Europe centrale", "ACDT": "heure d’été du centre de l’Australie", "NZST": "heure normale de la Nouvelle-Zélande", "EAT": "heure normale d’Afrique de l’Est", "WIT": "heure de l’Est indonésien", "∅∅∅": "heure d’été de Brasilia", "PST": "heure normale du Pacifique nord-américain", "CAT": "heure normale d’Afrique centrale", "ACWDT": "heure d’été du centre-ouest de l’Australie", "WARST": "heure d’été de l’Ouest argentin", "ART": "heure normale d’Argentine", "OEZ": "heure normale d’Europe de l’Est", "EST": "heure normale de l’Est nord-américain", "HEEG": "heure d’été de l’Est du Groenland", "ECT": "heure de l’Équateur", "NZDT": "heure d’été de la Nouvelle-Zélande", "JDT": "heure d’été du Japon", "HNOG": "heure normale de l’Ouest du Groenland", "MDT": "heure d’été de Macao", "WITA": "heure du Centre indonésien", "ChST": "heure des Chamorro", "GYT": "heure du Guyana", "PDT": "heure d’été du Pacifique", "HEOG": "heure d’été de l’Ouest du Groenland", "OESZ": "heure d’été d’Europe de l’Est", "MYT": "heure de la Malaisie", "IST": "heure de l’Inde", "WAT": "heure normale d’Afrique de l’Ouest"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_CF) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_CF' +func (fr *fr_CF) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_CF' +func (fr *fr_CF) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_CF' +func (fr *fr_CF) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CF' +func (fr *fr_CF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CF' +func (fr *fr_CF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_CF' +func (fr *fr_CF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_CF) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_CF) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_CF) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_CF) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_CF) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_CF) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_CF) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_CF) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_CF) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_CF) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_CF) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_CF) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_CF) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_CF) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CF' and handles both Whole and Real numbers based on 'v' +func (fr *fr_CF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_CF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CF' +func (fr *fr_CF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CF' +// in accounting notation. +func (fr *fr_CF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_CF' +func (fr *fr_CF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_CF' +func (fr *fr_CF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_CF' +func (fr *fr_CF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_CF' +func (fr *fr_CF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_CF' +func (fr *fr_CF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_CF' +func (fr *fr_CF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_CF' +func (fr *fr_CF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_CF' +func (fr *fr_CF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_CF/fr_CF_test.go b/vendor/github.com/go-playground/locales/fr_CF/fr_CF_test.go new file mode 100644 index 0000000000..c56b0d4fb4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CF/fr_CF_test.go @@ -0,0 +1,1120 @@ +package fr_CF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_CF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_CG/fr_CG.go b/vendor/github.com/go-playground/locales/fr_CG/fr_CG.go new file mode 100644 index 0000000000..ae60097dbb --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CG/fr_CG.go @@ -0,0 +1,619 @@ +package fr_CG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_CG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_CG' locale +func New() locales.Translator { + return &fr_CG{ + locale: "fr_CG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"HAT": "heure d’été de Terre-Neuve", "AKST": "heure normale de l’Alaska", "WIB": "heure de l’Ouest indonésien", "NZDT": "heure d’été de la Nouvelle-Zélande", "PDT": "heure d’été du Pacifique", "ACWDT": "heure d’été du centre-ouest de l’Australie", "JDT": "heure d’été du Japon", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HECU": "heure d’été de Cuba", "AWST": "heure normale de l’Ouest de l’Australie", "CHADT": "heure d’été des îles Chatham", "PST": "heure normale du Pacifique nord-américain", "HNOG": "heure normale de l’Ouest du Groenland", "WAT": "heure normale d’Afrique de l’Ouest", "HNCU": "heure normale de Cuba", "CDT": "heure d’été du Centre", "CLT": "heure normale du Chili", "HNT": "heure normale de Terre-Neuve", "UYT": "heure normale de l’Uruguay", "LHST": "heure normale de Lord Howe", "VET": "heure du Venezuela", "HAST": "heure normale d’Hawaii - Aléoutiennes", "NZST": "heure normale de la Nouvelle-Zélande", "MEZ": "heure normale d’Europe centrale", "MDT": "heure d’été de Macao", "ARST": "heure d’été de l’Argentine", "HKT": "heure normale de Hong Kong", "WITA": "heure du Centre indonésien", "AKDT": "heure d’été de l’Alaska", "MESZ": "heure d’été d’Europe centrale", "ChST": "heure des Chamorro", "CHAST": "heure normale des îles Chatham", "CLST": "heure d’été du Chili", "ADT": "heure d’été de l’Atlantique", "TMT": "heure normale du Turkménistan", "JST": "heure normale du Japon", "WESZ": "heure d’été d’Europe de l’Ouest", "WART": "heure normale de l’Ouest argentin", "ACDT": "heure d’été du centre de l’Australie", "AEDT": "heure d’été de l’Est de l’Australie", "EAT": "heure normale d’Afrique de l’Est", "BOT": "heure de Bolivie", "SGT": "heure de Singapour", "COST": "heure d’été de Colombie", "ACWST": "heure normale du centre-ouest de l’Australie", "CAT": "heure normale d’Afrique centrale", "MYT": "heure de la Malaisie", "OESZ": "heure d’été d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "WARST": "heure d’été de l’Ouest argentin", "OEZ": "heure normale d’Europe de l’Est", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "∅∅∅": "heure d’été de l’Acre", "LHDT": "heure d’été de Lord Howe", "CST": "heure normale du centre nord-américain", "WEZ": "heure normale d’Europe de l’Ouest", "HKST": "heure d’été de Hong Kong", "EST": "heure normale de l’Est nord-américain", "ACST": "heure normale du centre de l’Australie", "TMST": "heure d’été du Turkménistan", "HEEG": "heure d’été de l’Est du Groenland", "GFT": "heure de la Guyane française", "HEOG": "heure d’été de l’Ouest du Groenland", "AWDT": "heure d’été de l’Ouest de l’Australie", "ECT": "heure de l’Équateur", "IST": "heure de l’Inde", "GYT": "heure du Guyana", "ART": "heure normale d’Argentine", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "COT": "heure normale de Colombie", "UYST": "heure d’été de l’Uruguay", "SRT": "heure du Suriname", "AEST": "heure normale de l’Est de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "HNPMX": "heure normale du Pacifique mexicain", "AST": "heure normale de l’Atlantique", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "WAST": "heure d’été d’Afrique de l’Ouest", "HNEG": "heure normale de l’Est du Groenland", "HEPMX": "heure d’été du Pacifique mexicain", "SAST": "heure normale d’Afrique méridionale", "WIT": "heure de l’Est indonésien", "MST": "heure normale de Macao", "EDT": "heure d’été de l’Est", "BT": "heure du Bhoutan"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_CG) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_CG' +func (fr *fr_CG) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_CG' +func (fr *fr_CG) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_CG' +func (fr *fr_CG) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CG' +func (fr *fr_CG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CG' +func (fr *fr_CG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_CG' +func (fr *fr_CG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_CG) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_CG) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_CG) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_CG) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_CG) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_CG) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_CG) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_CG) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_CG) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_CG) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_CG) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_CG) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_CG) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_CG) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CG' and handles both Whole and Real numbers based on 'v' +func (fr *fr_CG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_CG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CG' +func (fr *fr_CG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CG' +// in accounting notation. +func (fr *fr_CG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_CG' +func (fr *fr_CG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_CG' +func (fr *fr_CG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_CG' +func (fr *fr_CG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_CG' +func (fr *fr_CG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_CG' +func (fr *fr_CG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_CG' +func (fr *fr_CG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_CG' +func (fr *fr_CG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_CG' +func (fr *fr_CG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_CG/fr_CG_test.go b/vendor/github.com/go-playground/locales/fr_CG/fr_CG_test.go new file mode 100644 index 0000000000..a2106c405e --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CG/fr_CG_test.go @@ -0,0 +1,1120 @@ +package fr_CG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_CG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_CH/fr_CH.go b/vendor/github.com/go-playground/locales/fr_CH/fr_CH.go new file mode 100644 index 0000000000..9f997ade0d --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CH/fr_CH.go @@ -0,0 +1,627 @@ +package fr_CH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_CH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_CH' locale +func New() locales.Translator { + return &fr_CH{ + locale: "fr_CH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"", ""}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"", ""}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"GMT": "heure moyenne de Greenwich", "ACST": "heure normale du centre de l’Australie", "TMT": "heure normale du Turkménistan", "GFT": "heure de la Guyane française", "AKST": "heure normale de l’Alaska", "IST": "heure de l’Inde", "WESZ": "heure d’été d’Europe de l’Ouest", "HEOG": "heure d’été de l’Ouest du Groenland", "NZDT": "heure d’été de la Nouvelle-Zélande", "GYT": "heure du Guyana", "EAT": "heure normale d’Afrique de l’Est", "PST": "heure normale du Pacifique nord-américain", "NZST": "heure normale de la Nouvelle-Zélande", "OESZ": "heure d’été d’Europe de l’Est", "TMST": "heure d’été du Turkménistan", "WAST": "heure d’été d’Afrique de l’Ouest", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "UYST": "heure d’été de l’Uruguay", "ACWST": "heure normale du centre-ouest de l’Australie", "ACWDT": "heure d’été du centre-ouest de l’Australie", "HNEG": "heure normale de l’Est du Groenland", "HAT": "heure d’été de Terre-Neuve", "ACDT": "heure d’été du centre de l’Australie", "COT": "heure normale de Colombie", "COST": "heure d’été de Colombie", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "BT": "heure du Bhoutan", "AST": "heure normale de l’Atlantique", "ADT": "heure d’été de l’Atlantique", "MST": "heure normale de Macao", "CDT": "heure d’été du Centre", "CLST": "heure d’été du Chili", "HNT": "heure normale de Terre-Neuve", "WITA": "heure du Centre indonésien", "SRT": "heure du Suriname", "WIT": "heure de l’Est indonésien", "ECT": "heure de l’Équateur", "ARST": "heure d’été de l’Argentine", "∅∅∅": "heure d’été des Açores", "CST": "heure normale du centre nord-américain", "PDT": "heure d’été du Pacifique", "MYT": "heure de la Malaisie", "HKT": "heure normale de Hong Kong", "WAT": "heure normale d’Afrique de l’Ouest", "AEST": "heure normale de l’Est de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "CHADT": "heure d’été des îles Chatham", "HAST": "heure normale d’Hawaii - Aléoutiennes", "EST": "heure normale de l’Est nord-américain", "EDT": "heure d’été de l’Est", "UYT": "heure normale de l’Uruguay", "SGT": "heure de Singapour", "HKST": "heure d’été de Hong Kong", "WARST": "heure d’été de l’Ouest argentin", "OEZ": "heure normale d’Europe de l’Est", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "VET": "heure du Venezuela", "WEZ": "heure normale d’Europe de l’Ouest", "CAT": "heure normale d’Afrique centrale", "JST": "heure normale du Japon", "MDT": "heure d’été de Macao", "HEPMX": "heure d’été du Pacifique mexicain", "WIB": "heure de l’Ouest indonésien", "HNCU": "heure normale de Cuba", "ART": "heure normale d’Argentine", "AWDT": "heure d’été de l’Ouest de l’Australie", "JDT": "heure d’été du Japon", "CLT": "heure normale du Chili", "CHAST": "heure normale des îles Chatham", "WART": "heure normale de l’Ouest argentin", "HEEG": "heure d’été de l’Est du Groenland", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "ChST": "heure des Chamorro", "HNPMX": "heure normale du Pacifique mexicain", "MEZ": "heure normale d’Europe centrale", "SAST": "heure normale d’Afrique méridionale", "HECU": "heure d’été de Cuba", "BOT": "heure de Bolivie", "MESZ": "heure d’été d’Europe centrale", "HNOG": "heure normale de l’Ouest du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "AKDT": "heure d’été de l’Alaska", "LHST": "heure normale de Lord Howe", "LHDT": "heure d’été de Lord Howe", "AWST": "heure normale de l’Ouest de l’Australie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_CH) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_CH' +func (fr *fr_CH) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_CH' +func (fr *fr_CH) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_CH' +func (fr *fr_CH) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CH' +func (fr *fr_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CH' +func (fr *fr_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_CH' +func (fr *fr_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_CH) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_CH) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_CH) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_CH) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_CH) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_CH) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_CH) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_CH) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_CH) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_CH) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_CH) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_CH) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_CH) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_CH) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CH' and handles both Whole and Real numbers based on 'v' +func (fr *fr_CH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_CH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CH' +func (fr *fr_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fr.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fr.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CH' +// in accounting notation. +func (fr *fr_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fr.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, fr.currencyNegativePrefix[j]) + } + + b = append(b, fr.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fr.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fr.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_CH' +func (fr *fr_CH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_CH' +func (fr *fr_CH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_CH' +func (fr *fr_CH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_CH' +func (fr *fr_CH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_CH' +func (fr *fr_CH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_CH' +func (fr *fr_CH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_CH' +func (fr *fr_CH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_CH' +func (fr *fr_CH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x68}...) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_CH/fr_CH_test.go b/vendor/github.com/go-playground/locales/fr_CH/fr_CH_test.go new file mode 100644 index 0000000000..17006548c4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CH/fr_CH_test.go @@ -0,0 +1,1120 @@ +package fr_CH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_CH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_CI/fr_CI.go b/vendor/github.com/go-playground/locales/fr_CI/fr_CI.go new file mode 100644 index 0000000000..0855eb3e63 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CI/fr_CI.go @@ -0,0 +1,619 @@ +package fr_CI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_CI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_CI' locale +func New() locales.Translator { + return &fr_CI{ + locale: "fr_CI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"WEZ": "heure normale d’Europe de l’Ouest", "ART": "heure normale d’Argentine", "UYT": "heure normale de l’Uruguay", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "ACWST": "heure normale du centre-ouest de l’Australie", "NZST": "heure normale de la Nouvelle-Zélande", "CLT": "heure normale du Chili", "JDT": "heure d’été du Japon", "MEZ": "heure normale d’Europe centrale", "ARST": "heure d’été de l’Argentine", "MDT": "heure d’été de Macao", "COST": "heure d’été de Colombie", "HEEG": "heure d’été de l’Est du Groenland", "SAST": "heure normale d’Afrique méridionale", "NZDT": "heure d’été de la Nouvelle-Zélande", "CAT": "heure normale d’Afrique centrale", "WAST": "heure d’été d’Afrique de l’Ouest", "WITA": "heure du Centre indonésien", "LHST": "heure normale de Lord Howe", "SRT": "heure du Suriname", "BOT": "heure de Bolivie", "HKT": "heure normale de Hong Kong", "UYST": "heure d’été de l’Uruguay", "LHDT": "heure d’été de Lord Howe", "MESZ": "heure d’été d’Europe centrale", "OEZ": "heure normale d’Europe de l’Est", "WARST": "heure d’été de l’Ouest argentin", "BT": "heure du Bhoutan", "AKDT": "heure d’été de l’Alaska", "HNCU": "heure normale de Cuba", "∅∅∅": "heure d’été de Brasilia", "IST": "heure de l’Inde", "EDT": "heure d’été de l’Est", "AEDT": "heure d’été de l’Est de l’Australie", "ChST": "heure des Chamorro", "CDT": "heure d’été du Centre", "CLST": "heure d’été du Chili", "WART": "heure normale de l’Ouest argentin", "HKST": "heure d’été de Hong Kong", "ACDT": "heure d’été du centre de l’Australie", "GFT": "heure de la Guyane française", "HEPMX": "heure d’été du Pacifique mexicain", "VET": "heure du Venezuela", "WESZ": "heure d’été d’Europe de l’Ouest", "COT": "heure normale de Colombie", "HNEG": "heure normale de l’Est du Groenland", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HECU": "heure d’été de Cuba", "HAST": "heure normale d’Hawaii - Aléoutiennes", "MST": "heure normale de Macao", "CHAST": "heure normale des îles Chatham", "HEOG": "heure d’été de l’Ouest du Groenland", "CST": "heure normale du centre nord-américain", "SGT": "heure de Singapour", "ACWDT": "heure d’été du centre-ouest de l’Australie", "GMT": "heure moyenne de Greenwich", "EST": "heure normale de l’Est nord-américain", "ACST": "heure normale du centre de l’Australie", "EAT": "heure normale d’Afrique de l’Est", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "ECT": "heure de l’Équateur", "AST": "heure normale de l’Atlantique", "WAT": "heure normale d’Afrique de l’Ouest", "WIB": "heure de l’Ouest indonésien", "PST": "heure normale du Pacifique nord-américain", "MYT": "heure de la Malaisie", "ADT": "heure d’été de l’Atlantique", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "AEST": "heure normale de l’Est de l’Australie", "AKST": "heure normale de l’Alaska", "AWDT": "heure d’été de l’Ouest de l’Australie", "PDT": "heure d’été du Pacifique", "HAT": "heure d’été de Terre-Neuve", "HNPMX": "heure normale du Pacifique mexicain", "OESZ": "heure d’été d’Europe de l’Est", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "JST": "heure normale du Japon", "HNT": "heure normale de Terre-Neuve", "WIT": "heure de l’Est indonésien", "AWST": "heure normale de l’Ouest de l’Australie", "TMT": "heure normale du Turkménistan", "TMST": "heure d’été du Turkménistan", "GYT": "heure du Guyana", "CHADT": "heure d’été des îles Chatham", "HNOG": "heure normale de l’Ouest du Groenland"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_CI) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_CI' +func (fr *fr_CI) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_CI' +func (fr *fr_CI) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_CI' +func (fr *fr_CI) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CI' +func (fr *fr_CI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CI' +func (fr *fr_CI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_CI' +func (fr *fr_CI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_CI) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_CI) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_CI) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_CI) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_CI) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_CI) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_CI) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_CI) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_CI) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_CI) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_CI) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_CI) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_CI) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_CI) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CI' and handles both Whole and Real numbers based on 'v' +func (fr *fr_CI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_CI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CI' +func (fr *fr_CI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CI' +// in accounting notation. +func (fr *fr_CI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_CI' +func (fr *fr_CI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_CI' +func (fr *fr_CI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_CI' +func (fr *fr_CI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_CI' +func (fr *fr_CI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_CI' +func (fr *fr_CI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_CI' +func (fr *fr_CI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_CI' +func (fr *fr_CI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_CI' +func (fr *fr_CI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_CI/fr_CI_test.go b/vendor/github.com/go-playground/locales/fr_CI/fr_CI_test.go new file mode 100644 index 0000000000..c9fc12f4aa --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CI/fr_CI_test.go @@ -0,0 +1,1120 @@ +package fr_CI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_CI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_CM/fr_CM.go b/vendor/github.com/go-playground/locales/fr_CM/fr_CM.go new file mode 100644 index 0000000000..172c99cb46 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CM/fr_CM.go @@ -0,0 +1,619 @@ +package fr_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_CM' locale +func New() locales.Translator { + return &fr_CM{ + locale: "fr_CM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"mat.", "soir"}, + periodsNarrow: []string{"mat.", "soir"}, + periodsWide: []string{"matin", "soir"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"EDT": "heure d’été de l’Est", "HKST": "heure d’été de Hong Kong", "SGT": "heure de Singapour", "WART": "heure normale de l’Ouest argentin", "MST": "heure normale de Macao", "MDT": "heure d’été de Macao", "COT": "heure normale de Colombie", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "UYT": "heure normale de l’Uruguay", "ECT": "heure de l’Équateur", "ACST": "heure normale du centre de l’Australie", "COST": "heure d’été de Colombie", "GYT": "heure du Guyana", "HNCU": "heure normale de Cuba", "AWST": "heure normale de l’Ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "JST": "heure normale du Japon", "CLT": "heure normale du Chili", "HNEG": "heure normale de l’Est du Groenland", "WITA": "heure du Centre indonésien", "AWDT": "heure d’été de l’Ouest de l’Australie", "IST": "heure de l’Inde", "ACWST": "heure normale du centre-ouest de l’Australie", "ACWDT": "heure d’été du centre-ouest de l’Australie", "HEOG": "heure d’été de l’Ouest du Groenland", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "MESZ": "heure d’été d’Europe centrale", "WAT": "heure normale d’Afrique de l’Ouest", "AEST": "heure normale de l’Est de l’Australie", "UYST": "heure d’été de l’Uruguay", "LHDT": "heure d’été de Lord Howe", "WIT": "heure de l’Est indonésien", "CHADT": "heure d’été des îles Chatham", "AST": "heure normale de l’Atlantique", "OEZ": "heure normale d’Europe de l’Est", "GFT": "heure de la Guyane française", "WIB": "heure de l’Ouest indonésien", "∅∅∅": "heure d’été de Brasilia", "MYT": "heure de la Malaisie", "HEEG": "heure d’été de l’Est du Groenland", "SRT": "heure du Suriname", "WARST": "heure d’été de l’Ouest argentin", "OESZ": "heure d’été d’Europe de l’Est", "ART": "heure normale d’Argentine", "WAST": "heure d’été d’Afrique de l’Ouest", "ACDT": "heure d’été du centre de l’Australie", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "AKST": "heure normale de l’Alaska", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "CDT": "heure d’été du Centre", "CAT": "heure normale d’Afrique centrale", "NZDT": "heure d’été de la Nouvelle-Zélande", "HNT": "heure normale de Terre-Neuve", "PST": "heure normale du Pacifique nord-américain", "NZST": "heure normale de la Nouvelle-Zélande", "GMT": "heure moyenne de Greenwich", "AEDT": "heure d’été de l’Est de l’Australie", "LHST": "heure normale de Lord Howe", "HNPMX": "heure normale du Pacifique mexicain", "HEPMX": "heure d’été du Pacifique mexicain", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "HNOG": "heure normale de l’Ouest du Groenland", "AKDT": "heure d’été de l’Alaska", "SAST": "heure normale d’Afrique méridionale", "BOT": "heure de Bolivie", "PDT": "heure d’été du Pacifique", "VET": "heure du Venezuela", "ARST": "heure d’été de l’Argentine", "EAT": "heure normale d’Afrique de l’Est", "JDT": "heure d’été du Japon", "BT": "heure du Bhoutan", "HECU": "heure d’été de Cuba", "HAST": "heure normale d’Hawaii - Aléoutiennes", "TMT": "heure normale du Turkménistan", "TMST": "heure d’été du Turkménistan", "EST": "heure normale de l’Est nord-américain", "CST": "heure normale du centre nord-américain", "CHAST": "heure normale des îles Chatham", "CLST": "heure d’été du Chili", "ADT": "heure d’été de l’Atlantique", "WEZ": "heure normale d’Europe de l’Ouest", "WESZ": "heure d’été d’Europe de l’Ouest", "HKT": "heure normale de Hong Kong", "HAT": "heure d’été de Terre-Neuve", "ChST": "heure des Chamorro"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_CM) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_CM' +func (fr *fr_CM) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_CM' +func (fr *fr_CM) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_CM' +func (fr *fr_CM) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CM' +func (fr *fr_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_CM' +func (fr *fr_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_CM' +func (fr *fr_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_CM) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_CM) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_CM) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_CM) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_CM) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_CM) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_CM) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_CM) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_CM) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_CM) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_CM) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_CM) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_CM) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_CM' and handles both Whole and Real numbers based on 'v' +func (fr *fr_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CM' +func (fr *fr_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_CM' +// in accounting notation. +func (fr *fr_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_CM' +func (fr *fr_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_CM' +func (fr *fr_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_CM' +func (fr *fr_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_CM' +func (fr *fr_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_CM' +func (fr *fr_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_CM' +func (fr *fr_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_CM' +func (fr *fr_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_CM' +func (fr *fr_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_CM/fr_CM_test.go b/vendor/github.com/go-playground/locales/fr_CM/fr_CM_test.go new file mode 100644 index 0000000000..3ced232599 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_CM/fr_CM_test.go @@ -0,0 +1,1120 @@ +package fr_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_DJ/fr_DJ.go b/vendor/github.com/go-playground/locales/fr_DJ/fr_DJ.go new file mode 100644 index 0000000000..78cab96734 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_DJ/fr_DJ.go @@ -0,0 +1,657 @@ +package fr_DJ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_DJ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_DJ' locale +func New() locales.Translator { + return &fr_DJ{ + locale: "fr_DJ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "Fdj", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"UYT": "heure normale de l’Uruguay", "LHST": "heure normale de Lord Howe", "ARST": "heure d’été de l’Argentine", "HNT": "heure normale de Terre-Neuve", "AEST": "heure normale de l’Est de l’Australie", "UYST": "heure d’été de l’Uruguay", "EAT": "heure normale d’Afrique de l’Est", "HNCU": "heure normale de Cuba", "HAT": "heure d’été de Terre-Neuve", "LHDT": "heure d’été de Lord Howe", "ECT": "heure de l’Équateur", "HKT": "heure normale de Hong Kong", "ACDT": "heure d’été du centre de l’Australie", "ADT": "heure d’été de l’Atlantique", "BT": "heure du Bhoutan", "GFT": "heure de la Guyane française", "ChST": "heure des Chamorro", "HECU": "heure d’été de Cuba", "CST": "heure normale du centre nord-américain", "WIT": "heure de l’Est indonésien", "MESZ": "heure d’été d’Europe centrale", "WEZ": "heure normale d’Europe de l’Ouest", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "AWDT": "heure d’été de l’Ouest de l’Australie", "JDT": "heure d’été du Japon", "COT": "heure normale de Colombie", "AKST": "heure normale de l’Alaska", "SAST": "heure normale d’Afrique méridionale", "HNPMX": "heure normale du Pacifique mexicain", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "WIB": "heure de l’Ouest indonésien", "MYT": "heure de la Malaisie", "OEZ": "heure normale d’Europe de l’Est", "EDT": "heure d’été de l’Est", "HNEG": "heure normale de l’Est du Groenland", "IST": "heure de l’Inde", "OESZ": "heure d’été d’Europe de l’Est", "ART": "heure normale d’Argentine", "EST": "heure normale de l’Est nord-américain", "COST": "heure d’été de Colombie", "SRT": "heure du Suriname", "MEZ": "heure normale d’Europe centrale", "TMST": "heure d’été du Turkménistan", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "ACWST": "heure normale du centre-ouest de l’Australie", "JST": "heure normale du Japon", "GMT": "heure moyenne de Greenwich", "ACST": "heure normale du centre de l’Australie", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "MST": "heure normale des Rocheuses", "PST": "heure normale du Pacifique nord-américain", "HAST": "heure normale d’Hawaii - Aléoutiennes", "MDT": "heure d’été des Rocheuses", "BOT": "heure de Bolivie", "WART": "heure normale de l’Ouest argentin", "WARST": "heure d’été de l’Ouest argentin", "CLT": "heure normale du Chili", "HNOG": "heure normale de l’Ouest du Groenland", "HEOG": "heure d’été de l’Ouest du Groenland", "HEEG": "heure d’été de l’Est du Groenland", "GYT": "heure du Guyana", "CHAST": "heure normale des îles Chatham", "CAT": "heure normale d’Afrique centrale", "CLST": "heure d’été du Chili", "AKDT": "heure d’été de l’Alaska", "HEPMX": "heure d’été du Pacifique mexicain", "SGT": "heure de Singapour", "PDT": "heure d’été du Pacifique", "WESZ": "heure d’été d’Europe de l’Ouest", "TMT": "heure normale du Turkménistan", "AWST": "heure normale de l’Ouest de l’Australie", "CHADT": "heure d’été des îles Chatham", "ACWDT": "heure d’été du centre-ouest de l’Australie", "AST": "heure normale de l’Atlantique", "WAST": "heure d’été d’Afrique de l’Ouest", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "WAT": "heure normale d’Afrique de l’Ouest", "∅∅∅": "heure d’été de l’Acre", "WITA": "heure du Centre indonésien", "AEDT": "heure d’été de l’Est de l’Australie", "CDT": "heure d’été du Centre", "NZST": "heure normale de la Nouvelle-Zélande", "NZDT": "heure d’été de la Nouvelle-Zélande", "VET": "heure du Venezuela", "HKST": "heure d’été de Hong Kong"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_DJ) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_DJ' +func (fr *fr_DJ) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_DJ' +func (fr *fr_DJ) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_DJ' +func (fr *fr_DJ) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_DJ' +func (fr *fr_DJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_DJ' +func (fr *fr_DJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_DJ' +func (fr *fr_DJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_DJ) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_DJ) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_DJ) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_DJ) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_DJ) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_DJ) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_DJ) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_DJ) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_DJ) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_DJ) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_DJ) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_DJ) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_DJ) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_DJ) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_DJ' and handles both Whole and Real numbers based on 'v' +func (fr *fr_DJ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_DJ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_DJ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_DJ' +func (fr *fr_DJ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_DJ' +// in accounting notation. +func (fr *fr_DJ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_DJ' +func (fr *fr_DJ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_DJ' +func (fr *fr_DJ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_DJ' +func (fr *fr_DJ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_DJ' +func (fr *fr_DJ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_DJ' +func (fr *fr_DJ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_DJ' +func (fr *fr_DJ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_DJ' +func (fr *fr_DJ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_DJ' +func (fr *fr_DJ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_DJ/fr_DJ_test.go b/vendor/github.com/go-playground/locales/fr_DJ/fr_DJ_test.go new file mode 100644 index 0000000000..3344b79c0a --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_DJ/fr_DJ_test.go @@ -0,0 +1,1120 @@ +package fr_DJ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_DJ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_DZ/fr_DZ.go b/vendor/github.com/go-playground/locales/fr_DZ/fr_DZ.go new file mode 100644 index 0000000000..02b2c2c621 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_DZ/fr_DZ.go @@ -0,0 +1,657 @@ +package fr_DZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_DZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_DZ' locale +func New() locales.Translator { + return &fr_DZ{ + locale: "fr_DZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DA", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"MESZ": "heure d’été d’Europe centrale", "HNOG": "heure normale de l’Ouest du Groenland", "TMST": "heure d’été du Turkménistan", "HAT": "heure d’été de Terre-Neuve", "HNPMX": "heure normale du Pacifique mexicain", "LHST": "heure normale de Lord Howe", "ChST": "heure des Chamorro", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "ACST": "heure normale du centre de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "ECT": "heure de l’Équateur", "EST": "heure normale de l’Est nord-américain", "CAT": "heure normale d’Afrique centrale", "HKST": "heure d’été de Hong Kong", "HNEG": "heure normale de l’Est du Groenland", "CST": "heure normale du centre nord-américain", "BOT": "heure de Bolivie", "WAST": "heure d’été d’Afrique de l’Ouest", "COT": "heure normale de Colombie", "BT": "heure du Bhoutan", "WART": "heure normale de l’Ouest argentin", "OEZ": "heure normale d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "CLT": "heure normale du Chili", "AST": "heure normale de l’Atlantique", "OESZ": "heure d’été d’Europe de l’Est", "ART": "heure normale d’Argentine", "WIT": "heure de l’Est indonésien", "IST": "heure de l’Inde", "MEZ": "heure normale d’Europe centrale", "ACWDT": "heure d’été du centre-ouest de l’Australie", "COST": "heure d’été de Colombie", "MDT": "heure d’été des Rocheuses", "SAST": "heure normale d’Afrique méridionale", "GYT": "heure du Guyana", "ACWST": "heure normale du centre-ouest de l’Australie", "JST": "heure normale du Japon", "WESZ": "heure d’été d’Europe de l’Ouest", "ACDT": "heure d’été du centre de l’Australie", "WITA": "heure du Centre indonésien", "PST": "heure normale du Pacifique nord-américain", "PDT": "heure d’été du Pacifique", "HEEG": "heure d’été de l’Est du Groenland", "AKST": "heure normale de l’Alaska", "HECU": "heure d’été de Cuba", "WARST": "heure d’été de l’Ouest argentin", "HEOG": "heure d’été de l’Ouest du Groenland", "LHDT": "heure d’été de Lord Howe", "WIB": "heure de l’Ouest indonésien", "SGT": "heure de Singapour", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "NZST": "heure normale de la Nouvelle-Zélande", "MYT": "heure de la Malaisie", "UYT": "heure normale de l’Uruguay", "HEPMX": "heure d’été du Pacifique mexicain", "AWST": "heure normale de l’Ouest de l’Australie", "HKT": "heure normale de Hong Kong", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "∅∅∅": "heure d’été de l’Acre", "HAST": "heure normale d’Hawaii - Aléoutiennes", "NZDT": "heure d’été de la Nouvelle-Zélande", "WEZ": "heure normale d’Europe de l’Ouest", "ADT": "heure d’été de l’Atlantique", "TMT": "heure normale du Turkménistan", "WAT": "heure normale d’Afrique de l’Ouest", "CDT": "heure d’été du Centre", "CHAST": "heure normale des îles Chatham", "VET": "heure du Venezuela", "ARST": "heure d’été de l’Argentine", "AEST": "heure normale de l’Est de l’Australie", "UYST": "heure d’été de l’Uruguay", "EAT": "heure normale d’Afrique de l’Est", "SRT": "heure du Suriname", "HNCU": "heure normale de Cuba", "JDT": "heure d’été du Japon", "CLST": "heure d’été du Chili", "HNT": "heure normale de Terre-Neuve", "AEDT": "heure d’été de l’Est de l’Australie", "GFT": "heure de la Guyane française", "AWDT": "heure d’été de l’Ouest de l’Australie", "CHADT": "heure d’été des îles Chatham", "EDT": "heure d’été de l’Est", "MST": "heure normale des Rocheuses", "AKDT": "heure d’été de l’Alaska", "HNPM": "heure normale de Saint-Pierre-et-Miquelon"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_DZ) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_DZ' +func (fr *fr_DZ) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_DZ' +func (fr *fr_DZ) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_DZ' +func (fr *fr_DZ) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_DZ' +func (fr *fr_DZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_DZ' +func (fr *fr_DZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_DZ' +func (fr *fr_DZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_DZ) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_DZ) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_DZ) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_DZ) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_DZ) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_DZ) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_DZ) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_DZ) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_DZ) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_DZ) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_DZ) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_DZ) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_DZ) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_DZ) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_DZ' and handles both Whole and Real numbers based on 'v' +func (fr *fr_DZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_DZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_DZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_DZ' +func (fr *fr_DZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_DZ' +// in accounting notation. +func (fr *fr_DZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_DZ' +func (fr *fr_DZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_DZ' +func (fr *fr_DZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_DZ' +func (fr *fr_DZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_DZ' +func (fr *fr_DZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_DZ' +func (fr *fr_DZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_DZ' +func (fr *fr_DZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_DZ' +func (fr *fr_DZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_DZ' +func (fr *fr_DZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_DZ/fr_DZ_test.go b/vendor/github.com/go-playground/locales/fr_DZ/fr_DZ_test.go new file mode 100644 index 0000000000..41a75064ad --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_DZ/fr_DZ_test.go @@ -0,0 +1,1120 @@ +package fr_DZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_DZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_FR/fr_FR.go b/vendor/github.com/go-playground/locales/fr_FR/fr_FR.go new file mode 100644 index 0000000000..60cc1a3022 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_FR/fr_FR.go @@ -0,0 +1,619 @@ +package fr_FR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_FR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_FR' locale +func New() locales.Translator { + return &fr_FR{ + locale: "fr_FR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"UYST": "heure d’été de l’Uruguay", "HKST": "heure d’été de Hong Kong", "PST": "heure normale du Pacifique nord-américain", "HAST": "heure normale d’Hawaii - Aléoutiennes", "OEZ": "heure normale d’Europe de l’Est", "ART": "heure normale d’Argentine", "EST": "heure normale de l’Est nord-américain", "HNEG": "heure normale de l’Est du Groenland", "GFT": "heure de la Guyane française", "WIB": "heure de l’Ouest indonésien", "LHST": "heure normale de Lord Howe", "HNCU": "heure normale de Cuba", "SGT": "heure de Singapour", "ACWST": "heure normale du centre-ouest de l’Australie", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "∅∅∅": "heure d’été des Açores", "CHADT": "heure d’été des îles Chatham", "MYT": "heure de la Malaisie", "WESZ": "heure d’été d’Europe de l’Ouest", "GMT": "heure moyenne de Greenwich", "MST": "heure normale de Macao", "COT": "heure normale de Colombie", "GYT": "heure du Guyana", "JST": "heure normale du Japon", "HEOG": "heure d’été de l’Ouest du Groenland", "ACDT": "heure d’été du centre de l’Australie", "HEPMX": "heure d’été du Pacifique mexicain", "CST": "heure normale du centre nord-américain", "IST": "heure de l’Inde", "MEZ": "heure normale d’Europe centrale", "VET": "heure du Venezuela", "OESZ": "heure d’été d’Europe de l’Est", "WAST": "heure d’été d’Afrique de l’Ouest", "HECU": "heure d’été de Cuba", "EAT": "heure normale d’Afrique de l’Est", "CDT": "heure d’été du Centre", "TMST": "heure d’été du Turkménistan", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "SRT": "heure du Suriname", "HNOG": "heure normale de l’Ouest du Groenland", "TMT": "heure normale du Turkménistan", "WAT": "heure normale d’Afrique de l’Ouest", "HEEG": "heure d’été de l’Est du Groenland", "ChST": "heure des Chamorro", "JDT": "heure d’été du Japon", "WEZ": "heure normale d’Europe de l’Ouest", "WITA": "heure du Centre indonésien", "AKST": "heure normale de l’Alaska", "AEST": "heure normale de l’Est de l’Australie", "CAT": "heure normale d’Afrique centrale", "AWST": "heure normale de l’Ouest de l’Australie", "ECT": "heure de l’Équateur", "ARST": "heure d’été de l’Argentine", "HNPMX": "heure normale du Pacifique mexicain", "WART": "heure normale de l’Ouest argentin", "AST": "heure normale de l’Atlantique", "EDT": "heure d’été de l’Est", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "NZST": "heure normale de la Nouvelle-Zélande", "WIT": "heure de l’Est indonésien", "ADT": "heure d’été de l’Atlantique", "HNT": "heure normale de Terre-Neuve", "AKDT": "heure d’été de l’Alaska", "LHDT": "heure d’été de Lord Howe", "UYT": "heure normale de l’Uruguay", "CHAST": "heure normale des îles Chatham", "MESZ": "heure d’été d’Europe centrale", "HKT": "heure normale de Hong Kong", "COST": "heure d’été de Colombie", "AEDT": "heure d’été de l’Est de l’Australie", "AWDT": "heure d’été de l’Ouest de l’Australie", "BOT": "heure de Bolivie", "PDT": "heure d’été du Pacifique", "ACWDT": "heure d’été du centre-ouest de l’Australie", "CLST": "heure d’été du Chili", "ACST": "heure normale du centre de l’Australie", "HAT": "heure d’été de Terre-Neuve", "SAST": "heure normale d’Afrique méridionale", "NZDT": "heure d’été de la Nouvelle-Zélande", "WARST": "heure d’été de l’Ouest argentin", "CLT": "heure normale du Chili", "MDT": "heure d’été de Macao", "BT": "heure du Bhoutan", "HADT": "heure d’été d’Hawaii - Aléoutiennes"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_FR) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_FR' +func (fr *fr_FR) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_FR' +func (fr *fr_FR) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_FR' +func (fr *fr_FR) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_FR' +func (fr *fr_FR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_FR' +func (fr *fr_FR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_FR' +func (fr *fr_FR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_FR) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_FR) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_FR) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_FR) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_FR) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_FR) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_FR) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_FR) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_FR) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_FR) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_FR) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_FR) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_FR) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_FR) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_FR' and handles both Whole and Real numbers based on 'v' +func (fr *fr_FR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_FR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_FR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_FR' +func (fr *fr_FR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_FR' +// in accounting notation. +func (fr *fr_FR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_FR' +func (fr *fr_FR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_FR' +func (fr *fr_FR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_FR' +func (fr *fr_FR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_FR' +func (fr *fr_FR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_FR' +func (fr *fr_FR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_FR' +func (fr *fr_FR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_FR' +func (fr *fr_FR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_FR' +func (fr *fr_FR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_FR/fr_FR_test.go b/vendor/github.com/go-playground/locales/fr_FR/fr_FR_test.go new file mode 100644 index 0000000000..5bf4dbbb0c --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_FR/fr_FR_test.go @@ -0,0 +1,1120 @@ +package fr_FR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_FR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_GA/fr_GA.go b/vendor/github.com/go-playground/locales/fr_GA/fr_GA.go new file mode 100644 index 0000000000..a1602bcd38 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GA/fr_GA.go @@ -0,0 +1,619 @@ +package fr_GA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_GA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_GA' locale +func New() locales.Translator { + return &fr_GA{ + locale: "fr_GA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"CDT": "heure d’été du Centre", "WART": "heure normale de l’Ouest argentin", "WAST": "heure d’été d’Afrique de l’Ouest", "BT": "heure du Bhoutan", "WIB": "heure de l’Ouest indonésien", "AWST": "heure normale de l’Ouest de l’Australie", "CHADT": "heure d’été des îles Chatham", "NZST": "heure normale de la Nouvelle-Zélande", "CLT": "heure normale du Chili", "HNT": "heure normale de Terre-Neuve", "AEST": "heure normale de l’Est de l’Australie", "HNCU": "heure normale de Cuba", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "ECT": "heure de l’Équateur", "EST": "heure normale de l’Est nord-américain", "HEEG": "heure d’été de l’Est du Groenland", "AKST": "heure normale de l’Alaska", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "OESZ": "heure d’été d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "HNOG": "heure normale de l’Ouest du Groenland", "EDT": "heure d’été de l’Est", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "WITA": "heure du Centre indonésien", "CHAST": "heure normale des îles Chatham", "OEZ": "heure normale d’Europe de l’Est", "AST": "heure normale de l’Atlantique", "MST": "heure normale de Macao", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "LHDT": "heure d’été de Lord Howe", "ChST": "heure des Chamorro", "JST": "heure normale du Japon", "IST": "heure de l’Inde", "WESZ": "heure d’été d’Europe de l’Ouest", "HAT": "heure d’été de Terre-Neuve", "CST": "heure normale du centre nord-américain", "PST": "heure normale du Pacifique nord-américain", "BOT": "heure de Bolivie", "JDT": "heure d’été du Japon", "CLST": "heure d’été du Chili", "ADT": "heure d’été de l’Atlantique", "MDT": "heure d’été de Macao", "COT": "heure normale de Colombie", "SAST": "heure normale d’Afrique méridionale", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ACWST": "heure normale du centre-ouest de l’Australie", "HKST": "heure d’été de Hong Kong", "HEPMX": "heure d’été du Pacifique mexicain", "SRT": "heure du Suriname", "UYT": "heure normale de l’Uruguay", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "ACWDT": "heure d’été du centre-ouest de l’Australie", "WEZ": "heure normale d’Europe de l’Ouest", "ACDT": "heure d’été du centre de l’Australie", "GFT": "heure de la Guyane française", "AKDT": "heure d’été de l’Alaska", "EAT": "heure normale d’Afrique de l’Est", "NZDT": "heure d’été de la Nouvelle-Zélande", "MYT": "heure de la Malaisie", "ARST": "heure d’été de l’Argentine", "UYST": "heure d’été de l’Uruguay", "GYT": "heure du Guyana", "PDT": "heure d’été du Pacifique", "CAT": "heure normale d’Afrique centrale", "MEZ": "heure normale d’Europe centrale", "HNEG": "heure normale de l’Est du Groenland", "HECU": "heure d’été de Cuba", "WIT": "heure de l’Est indonésien", "AEDT": "heure d’été de l’Est de l’Australie", "SGT": "heure de Singapour", "MESZ": "heure d’été d’Europe centrale", "AWDT": "heure d’été de l’Ouest de l’Australie", "VET": "heure du Venezuela", "WARST": "heure d’été de l’Ouest argentin", "TMST": "heure d’été du Turkménistan", "ART": "heure normale d’Argentine", "WAT": "heure normale d’Afrique de l’Ouest", "ACST": "heure normale du centre de l’Australie", "TMT": "heure normale du Turkménistan", "COST": "heure d’été de Colombie", "∅∅∅": "heure d’été de l’Acre", "HEOG": "heure d’été de l’Ouest du Groenland", "HKT": "heure normale de Hong Kong", "LHST": "heure normale de Lord Howe", "HNPMX": "heure normale du Pacifique mexicain"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_GA) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_GA' +func (fr *fr_GA) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_GA' +func (fr *fr_GA) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_GA' +func (fr *fr_GA) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GA' +func (fr *fr_GA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GA' +func (fr *fr_GA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_GA' +func (fr *fr_GA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_GA) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_GA) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_GA) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_GA) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_GA) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_GA) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_GA) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_GA) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_GA) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_GA) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_GA) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_GA) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_GA) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_GA) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_GA' and handles both Whole and Real numbers based on 'v' +func (fr *fr_GA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_GA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_GA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GA' +func (fr *fr_GA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GA' +// in accounting notation. +func (fr *fr_GA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_GA' +func (fr *fr_GA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_GA' +func (fr *fr_GA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_GA' +func (fr *fr_GA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_GA' +func (fr *fr_GA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_GA' +func (fr *fr_GA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_GA' +func (fr *fr_GA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_GA' +func (fr *fr_GA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_GA' +func (fr *fr_GA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_GA/fr_GA_test.go b/vendor/github.com/go-playground/locales/fr_GA/fr_GA_test.go new file mode 100644 index 0000000000..4d1414554a --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GA/fr_GA_test.go @@ -0,0 +1,1120 @@ +package fr_GA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_GA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_GF/fr_GF.go b/vendor/github.com/go-playground/locales/fr_GF/fr_GF.go new file mode 100644 index 0000000000..ca8393e067 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GF/fr_GF.go @@ -0,0 +1,619 @@ +package fr_GF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_GF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_GF' locale +func New() locales.Translator { + return &fr_GF{ + locale: "fr_GF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"MST": "heure normale de Macao", "ARST": "heure d’été de l’Argentine", "GFT": "heure de la Guyane française", "ChST": "heure des Chamorro", "PST": "heure normale du Pacifique nord-américain", "∅∅∅": "heure d’été de l’Acre", "UYST": "heure d’été de l’Uruguay", "HAST": "heure normale d’Hawaii - Aléoutiennes", "WART": "heure normale de l’Ouest argentin", "WEZ": "heure normale d’Europe de l’Ouest", "ACDT": "heure d’été du centre de l’Australie", "SAST": "heure normale d’Afrique méridionale", "PDT": "heure d’été du Pacifique", "WARST": "heure d’été de l’Ouest argentin", "AST": "heure normale de l’Atlantique", "OEZ": "heure normale d’Europe de l’Est", "ART": "heure normale d’Argentine", "AEDT": "heure d’été de l’Est de l’Australie", "CAT": "heure normale d’Afrique centrale", "GMT": "heure moyenne de Greenwich", "CLT": "heure normale du Chili", "CLST": "heure d’été du Chili", "HNOG": "heure normale de l’Ouest du Groenland", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "GYT": "heure du Guyana", "EST": "heure normale de l’Est nord-américain", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "ACST": "heure normale du centre de l’Australie", "UYT": "heure normale de l’Uruguay", "IST": "heure de l’Inde", "MYT": "heure de la Malaisie", "WESZ": "heure d’été d’Europe de l’Ouest", "WAT": "heure normale d’Afrique de l’Ouest", "HKT": "heure normale de Hong Kong", "COST": "heure d’été de Colombie", "WIB": "heure de l’Ouest indonésien", "ADT": "heure d’été de l’Atlantique", "AKDT": "heure d’été de l’Alaska", "HNCU": "heure normale de Cuba", "NZST": "heure normale de la Nouvelle-Zélande", "HEOG": "heure d’été de l’Ouest du Groenland", "OESZ": "heure d’été d’Europe de l’Est", "COT": "heure normale de Colombie", "HNT": "heure normale de Terre-Neuve", "HNEG": "heure normale de l’Est du Groenland", "AEST": "heure normale de l’Est de l’Australie", "LHDT": "heure d’été de Lord Howe", "HECU": "heure d’été de Cuba", "VET": "heure du Venezuela", "EDT": "heure d’été de l’Est", "WITA": "heure du Centre indonésien", "AKST": "heure normale de l’Alaska", "LHST": "heure normale de Lord Howe", "WIT": "heure de l’Est indonésien", "CHAST": "heure normale des îles Chatham", "MESZ": "heure d’été d’Europe centrale", "JST": "heure normale du Japon", "TMST": "heure d’été du Turkménistan", "SRT": "heure du Suriname", "AWST": "heure normale de l’Ouest de l’Australie", "ECT": "heure de l’Équateur", "WAST": "heure d’été d’Afrique de l’Ouest", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HNPMX": "heure normale du Pacifique mexicain", "CST": "heure normale du centre nord-américain", "BOT": "heure de Bolivie", "TMT": "heure normale du Turkménistan", "HKST": "heure d’été de Hong Kong", "BT": "heure du Bhoutan", "AWDT": "heure d’été de l’Ouest de l’Australie", "CHADT": "heure d’été des îles Chatham", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "ACWST": "heure normale du centre-ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "EAT": "heure normale d’Afrique de l’Est", "SGT": "heure de Singapour", "ACWDT": "heure d’été du centre-ouest de l’Australie", "JDT": "heure d’été du Japon", "MDT": "heure d’été de Macao", "HAT": "heure d’été de Terre-Neuve", "HEEG": "heure d’été de l’Est du Groenland", "HEPMX": "heure d’été du Pacifique mexicain", "CDT": "heure d’été du Centre", "NZDT": "heure d’été de la Nouvelle-Zélande"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_GF) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_GF' +func (fr *fr_GF) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_GF' +func (fr *fr_GF) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_GF' +func (fr *fr_GF) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GF' +func (fr *fr_GF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GF' +func (fr *fr_GF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_GF' +func (fr *fr_GF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_GF) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_GF) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_GF) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_GF) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_GF) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_GF) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_GF) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_GF) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_GF) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_GF) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_GF) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_GF) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_GF) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_GF) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_GF' and handles both Whole and Real numbers based on 'v' +func (fr *fr_GF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_GF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_GF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GF' +func (fr *fr_GF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GF' +// in accounting notation. +func (fr *fr_GF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_GF' +func (fr *fr_GF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_GF' +func (fr *fr_GF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_GF' +func (fr *fr_GF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_GF' +func (fr *fr_GF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_GF' +func (fr *fr_GF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_GF' +func (fr *fr_GF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_GF' +func (fr *fr_GF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_GF' +func (fr *fr_GF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_GF/fr_GF_test.go b/vendor/github.com/go-playground/locales/fr_GF/fr_GF_test.go new file mode 100644 index 0000000000..b7f207b811 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GF/fr_GF_test.go @@ -0,0 +1,1120 @@ +package fr_GF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_GF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_GN/fr_GN.go b/vendor/github.com/go-playground/locales/fr_GN/fr_GN.go new file mode 100644 index 0000000000..acf12679b9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GN/fr_GN.go @@ -0,0 +1,619 @@ +package fr_GN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_GN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_GN' locale +func New() locales.Translator { + return &fr_GN{ + locale: "fr_GN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "FG", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"CDT": "heure d’été du Centre", "MST": "heure normale de Macao", "WAT": "heure normale d’Afrique de l’Ouest", "ACST": "heure normale du centre de l’Australie", "HNPMX": "heure normale du Pacifique mexicain", "SAST": "heure normale d’Afrique méridionale", "MEZ": "heure normale d’Europe centrale", "OESZ": "heure d’été d’Europe de l’Est", "WAST": "heure d’été d’Afrique de l’Ouest", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HNEG": "heure normale de l’Est du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "HNCU": "heure normale de Cuba", "AWDT": "heure d’été de l’Ouest de l’Australie", "ECT": "heure de l’Équateur", "JST": "heure normale du Japon", "ADT": "heure d’été de l’Atlantique", "AEST": "heure normale de l’Est de l’Australie", "WITA": "heure du Centre indonésien", "HECU": "heure d’été de Cuba", "AWST": "heure normale de l’Ouest de l’Australie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "HKST": "heure d’été de Hong Kong", "BT": "heure du Bhoutan", "ACDT": "heure d’été du centre de l’Australie", "GFT": "heure de la Guyane française", "∅∅∅": "heure d’été de Brasilia", "WEZ": "heure normale d’Europe de l’Ouest", "EDT": "heure d’été de l’Est", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "GYT": "heure du Guyana", "CHADT": "heure d’été des îles Chatham", "HKT": "heure normale de Hong Kong", "EST": "heure normale de l’Est nord-américain", "HEEG": "heure d’été de l’Est du Groenland", "HNOG": "heure normale de l’Ouest du Groenland", "HAST": "heure normale d’Hawaii - Aléoutiennes", "CAT": "heure normale d’Afrique centrale", "VET": "heure du Venezuela", "CLT": "heure normale du Chili", "WIB": "heure de l’Ouest indonésien", "CHAST": "heure normale des îles Chatham", "JDT": "heure d’été du Japon", "AST": "heure normale de l’Atlantique", "HAT": "heure d’été de Terre-Neuve", "SRT": "heure du Suriname", "ACWDT": "heure d’été du centre-ouest de l’Australie", "NZST": "heure normale de la Nouvelle-Zélande", "MESZ": "heure d’été d’Europe centrale", "ARST": "heure d’été de l’Argentine", "LHDT": "heure d’été de Lord Howe", "IST": "heure de l’Inde", "COST": "heure d’été de Colombie", "ChST": "heure des Chamorro", "UYST": "heure d’été de l’Uruguay", "HNT": "heure normale de Terre-Neuve", "AKST": "heure normale de l’Alaska", "EAT": "heure normale d’Afrique de l’Est", "CLST": "heure d’été du Chili", "TMT": "heure normale du Turkménistan", "ART": "heure normale d’Argentine", "COT": "heure normale de Colombie", "UYT": "heure normale de l’Uruguay", "BOT": "heure de Bolivie", "ACWST": "heure normale du centre-ouest de l’Australie", "MYT": "heure de la Malaisie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "AKDT": "heure d’été de l’Alaska", "LHST": "heure normale de Lord Howe", "PDT": "heure d’été du Pacifique", "WESZ": "heure d’été d’Europe de l’Ouest", "OEZ": "heure normale d’Europe de l’Est", "MDT": "heure d’été de Macao", "CST": "heure normale du centre nord-américain", "GMT": "heure moyenne de Greenwich", "WART": "heure normale de l’Ouest argentin", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "NZDT": "heure d’été de la Nouvelle-Zélande", "WARST": "heure d’été de l’Ouest argentin", "HEOG": "heure d’été de l’Ouest du Groenland", "TMST": "heure d’été du Turkménistan", "WIT": "heure de l’Est indonésien", "SGT": "heure de Singapour", "PST": "heure normale du Pacifique nord-américain", "HEPMX": "heure d’été du Pacifique mexicain"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_GN) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_GN' +func (fr *fr_GN) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_GN' +func (fr *fr_GN) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_GN' +func (fr *fr_GN) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GN' +func (fr *fr_GN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GN' +func (fr *fr_GN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_GN' +func (fr *fr_GN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_GN) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_GN) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_GN) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_GN) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_GN) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_GN) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_GN) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_GN) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_GN) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_GN) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_GN) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_GN) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_GN) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_GN) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_GN' and handles both Whole and Real numbers based on 'v' +func (fr *fr_GN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_GN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_GN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GN' +func (fr *fr_GN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GN' +// in accounting notation. +func (fr *fr_GN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_GN' +func (fr *fr_GN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_GN' +func (fr *fr_GN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_GN' +func (fr *fr_GN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_GN' +func (fr *fr_GN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_GN' +func (fr *fr_GN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_GN' +func (fr *fr_GN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_GN' +func (fr *fr_GN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_GN' +func (fr *fr_GN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_GN/fr_GN_test.go b/vendor/github.com/go-playground/locales/fr_GN/fr_GN_test.go new file mode 100644 index 0000000000..e3373bd65f --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GN/fr_GN_test.go @@ -0,0 +1,1120 @@ +package fr_GN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_GN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_GP/fr_GP.go b/vendor/github.com/go-playground/locales/fr_GP/fr_GP.go new file mode 100644 index 0000000000..32120f05f2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GP/fr_GP.go @@ -0,0 +1,619 @@ +package fr_GP + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_GP struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_GP' locale +func New() locales.Translator { + return &fr_GP{ + locale: "fr_GP", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"ACWST": "heure normale du centre-ouest de l’Australie", "GYT": "heure du Guyana", "EAT": "heure normale d’Afrique de l’Est", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "UYST": "heure d’été de l’Uruguay", "CST": "heure normale du centre nord-américain", "WIT": "heure de l’Est indonésien", "ART": "heure normale d’Argentine", "AKDT": "heure d’été de l’Alaska", "HNT": "heure normale de Terre-Neuve", "BOT": "heure de Bolivie", "ADT": "heure d’été de l’Atlantique", "MDT": "heure d’été de Macao", "CDT": "heure d’été du Centre", "AWST": "heure normale de l’Ouest de l’Australie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "CAT": "heure normale d’Afrique centrale", "LHST": "heure normale de Lord Howe", "HNCU": "heure normale de Cuba", "ChST": "heure des Chamorro", "CHADT": "heure d’été des îles Chatham", "ACWDT": "heure d’été du centre-ouest de l’Australie", "WAT": "heure normale d’Afrique de l’Ouest", "BT": "heure du Bhoutan", "OEZ": "heure normale d’Europe de l’Est", "MST": "heure normale de Macao", "UYT": "heure normale de l’Uruguay", "CHAST": "heure normale des îles Chatham", "HAST": "heure normale d’Hawaii - Aléoutiennes", "WARST": "heure d’été de l’Ouest argentin", "HNOG": "heure normale de l’Ouest du Groenland", "HEPMX": "heure d’été du Pacifique mexicain", "SRT": "heure du Suriname", "NZDT": "heure d’été de la Nouvelle-Zélande", "IST": "heure de l’Inde", "GMT": "heure moyenne de Greenwich", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "CLST": "heure d’été du Chili", "HKST": "heure d’été de Hong Kong", "AKST": "heure normale de l’Alaska", "ECT": "heure de l’Équateur", "JST": "heure normale du Japon", "WART": "heure normale de l’Ouest argentin", "WESZ": "heure d’été d’Europe de l’Ouest", "MYT": "heure de la Malaisie", "CLT": "heure normale du Chili", "ARST": "heure d’été de l’Argentine", "HEEG": "heure d’été de l’Est du Groenland", "∅∅∅": "heure d’été de l’Acre", "MESZ": "heure d’été d’Europe centrale", "WEZ": "heure normale d’Europe de l’Ouest", "SGT": "heure de Singapour", "PST": "heure normale du Pacifique nord-américain", "GFT": "heure de la Guyane française", "HECU": "heure d’été de Cuba", "SAST": "heure normale d’Afrique méridionale", "AWDT": "heure d’été de l’Ouest de l’Australie", "HNEG": "heure normale de l’Est du Groenland", "HAT": "heure d’été de Terre-Neuve", "EST": "heure normale de l’Est nord-américain", "ACST": "heure normale du centre de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "AEDT": "heure d’été de l’Est de l’Australie", "WITA": "heure du Centre indonésien", "MEZ": "heure normale d’Europe centrale", "HKT": "heure normale de Hong Kong", "WAST": "heure d’été d’Afrique de l’Ouest", "EDT": "heure d’été de l’Est", "LHDT": "heure d’été de Lord Howe", "WIB": "heure de l’Ouest indonésien", "AST": "heure normale de l’Atlantique", "OESZ": "heure d’été d’Europe de l’Est", "HEOG": "heure d’été de l’Ouest du Groenland", "AEST": "heure normale de l’Est de l’Australie", "PDT": "heure d’été du Pacifique", "JDT": "heure d’été du Japon", "VET": "heure du Venezuela", "HNPMX": "heure normale du Pacifique mexicain", "TMST": "heure d’été du Turkménistan", "COT": "heure normale de Colombie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "NZST": "heure normale de la Nouvelle-Zélande", "TMT": "heure normale du Turkménistan", "COST": "heure d’été de Colombie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_GP) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_GP' +func (fr *fr_GP) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_GP' +func (fr *fr_GP) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_GP' +func (fr *fr_GP) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GP' +func (fr *fr_GP) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GP' +func (fr *fr_GP) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_GP' +func (fr *fr_GP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_GP) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_GP) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_GP) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_GP) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_GP) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_GP) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_GP) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_GP) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_GP) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_GP) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_GP) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_GP) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_GP) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_GP) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_GP' and handles both Whole and Real numbers based on 'v' +func (fr *fr_GP) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_GP' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_GP) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GP' +func (fr *fr_GP) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GP' +// in accounting notation. +func (fr *fr_GP) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_GP' +func (fr *fr_GP) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_GP' +func (fr *fr_GP) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_GP' +func (fr *fr_GP) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_GP' +func (fr *fr_GP) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_GP' +func (fr *fr_GP) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_GP' +func (fr *fr_GP) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_GP' +func (fr *fr_GP) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_GP' +func (fr *fr_GP) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_GP/fr_GP_test.go b/vendor/github.com/go-playground/locales/fr_GP/fr_GP_test.go new file mode 100644 index 0000000000..d39501da0e --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GP/fr_GP_test.go @@ -0,0 +1,1120 @@ +package fr_GP + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_GP" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_GQ/fr_GQ.go b/vendor/github.com/go-playground/locales/fr_GQ/fr_GQ.go new file mode 100644 index 0000000000..1d1c7ab578 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GQ/fr_GQ.go @@ -0,0 +1,619 @@ +package fr_GQ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_GQ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_GQ' locale +func New() locales.Translator { + return &fr_GQ{ + locale: "fr_GQ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"UYST": "heure d’été de l’Uruguay", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "AWDT": "heure d’été de l’Ouest de l’Australie", "IST": "heure de l’Inde", "ACDT": "heure d’été du centre de l’Australie", "COT": "heure normale de Colombie", "HAT": "heure d’été de Terre-Neuve", "EST": "heure normale de l’Est nord-américain", "ACST": "heure normale du centre de l’Australie", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HNEG": "heure normale de l’Est du Groenland", "SGT": "heure de Singapour", "VET": "heure du Venezuela", "WEZ": "heure normale d’Europe de l’Ouest", "ART": "heure normale d’Argentine", "GFT": "heure de la Guyane française", "SAST": "heure normale d’Afrique méridionale", "LHST": "heure normale de Lord Howe", "GYT": "heure du Guyana", "GMT": "heure moyenne de Greenwich", "HKT": "heure normale de Hong Kong", "MEZ": "heure normale d’Europe centrale", "OESZ": "heure d’été d’Europe de l’Est", "MDT": "heure d’été de Macao", "AEST": "heure normale de l’Est de l’Australie", "MST": "heure normale de Macao", "CHADT": "heure d’été des îles Chatham", "PDT": "heure d’été du Pacifique", "ACWST": "heure normale du centre-ouest de l’Australie", "WARST": "heure d’été de l’Ouest argentin", "BOT": "heure de Bolivie", "WESZ": "heure d’été d’Europe de l’Ouest", "WAT": "heure normale d’Afrique de l’Ouest", "HNT": "heure normale de Terre-Neuve", "AKST": "heure normale de l’Alaska", "ChST": "heure des Chamorro", "WIT": "heure de l’Est indonésien", "CAT": "heure normale d’Afrique centrale", "CLT": "heure normale du Chili", "MYT": "heure de la Malaisie", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "HEOG": "heure d’été de l’Ouest du Groenland", "SRT": "heure du Suriname", "WIB": "heure de l’Ouest indonésien", "ARST": "heure d’été de l’Argentine", "WITA": "heure du Centre indonésien", "LHDT": "heure d’été de Lord Howe", "HECU": "heure d’été de Cuba", "HKST": "heure d’été de Hong Kong", "HEEG": "heure d’été de l’Est du Groenland", "AKDT": "heure d’été de l’Alaska", "HNCU": "heure normale de Cuba", "CLST": "heure d’été du Chili", "HNOG": "heure normale de l’Ouest du Groenland", "TMT": "heure normale du Turkménistan", "TMST": "heure d’été du Turkménistan", "AST": "heure normale de l’Atlantique", "ADT": "heure d’été de l’Atlantique", "WAST": "heure d’été d’Afrique de l’Ouest", "BT": "heure du Bhoutan", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ECT": "heure de l’Équateur", "∅∅∅": "heure d’été de l’Amazonie", "MESZ": "heure d’été d’Europe centrale", "WART": "heure normale de l’Ouest argentin", "COST": "heure d’été de Colombie", "UYT": "heure normale de l’Uruguay", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HNPMX": "heure normale du Pacifique mexicain", "CST": "heure normale du centre nord-américain", "PST": "heure normale du Pacifique nord-américain", "JST": "heure normale du Japon", "OEZ": "heure normale d’Europe de l’Est", "EDT": "heure d’été de l’Est", "CHAST": "heure normale des îles Chatham", "EAT": "heure normale d’Afrique de l’Est", "CDT": "heure d’été du Centre", "NZST": "heure normale de la Nouvelle-Zélande", "NZDT": "heure d’été de la Nouvelle-Zélande", "JDT": "heure d’été du Japon", "ACWDT": "heure d’été du centre-ouest de l’Australie", "AEDT": "heure d’été de l’Est de l’Australie", "HEPMX": "heure d’été du Pacifique mexicain", "AWST": "heure normale de l’Ouest de l’Australie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_GQ) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_GQ' +func (fr *fr_GQ) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_GQ' +func (fr *fr_GQ) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_GQ' +func (fr *fr_GQ) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GQ' +func (fr *fr_GQ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_GQ' +func (fr *fr_GQ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_GQ' +func (fr *fr_GQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_GQ) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_GQ) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_GQ) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_GQ) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_GQ) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_GQ) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_GQ) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_GQ) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_GQ) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_GQ) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_GQ) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_GQ) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_GQ) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_GQ) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_GQ' and handles both Whole and Real numbers based on 'v' +func (fr *fr_GQ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_GQ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_GQ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GQ' +func (fr *fr_GQ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_GQ' +// in accounting notation. +func (fr *fr_GQ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_GQ' +func (fr *fr_GQ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_GQ' +func (fr *fr_GQ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_GQ' +func (fr *fr_GQ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_GQ' +func (fr *fr_GQ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_GQ' +func (fr *fr_GQ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_GQ' +func (fr *fr_GQ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_GQ' +func (fr *fr_GQ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_GQ' +func (fr *fr_GQ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_GQ/fr_GQ_test.go b/vendor/github.com/go-playground/locales/fr_GQ/fr_GQ_test.go new file mode 100644 index 0000000000..985fc8e650 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_GQ/fr_GQ_test.go @@ -0,0 +1,1120 @@ +package fr_GQ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_GQ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_HT/fr_HT.go b/vendor/github.com/go-playground/locales/fr_HT/fr_HT.go new file mode 100644 index 0000000000..8c6d68ebff --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_HT/fr_HT.go @@ -0,0 +1,619 @@ +package fr_HT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_HT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_HT' locale +func New() locales.Translator { + return &fr_HT{ + locale: "fr_HT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "G", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"", ""}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"MESZ": "heure d’été d’Europe centrale", "ACST": "heure normale du centre de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "HNCU": "heure normale de Cuba", "AKST": "heure normale de l’Alaska", "SAST": "heure normale d’Afrique méridionale", "AWST": "heure normale de l’Ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "VET": "heure du Venezuela", "WART": "heure normale de l’Ouest argentin", "AKDT": "heure d’été de l’Alaska", "HNPMX": "heure normale du Pacifique mexicain", "WARST": "heure d’été de l’Ouest argentin", "SRT": "heure du Suriname", "CST": "heure normale du centre nord-américain", "ECT": "heure de l’Équateur", "HNOG": "heure normale de l’Ouest du Groenland", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HNEG": "heure normale de l’Est du Groenland", "AEST": "heure normale de l’Est de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "CHAST": "heure normale des îles Chatham", "WEZ": "heure normale d’Europe de l’Ouest", "ARST": "heure d’été de l’Argentine", "LHST": "heure normale de Lord Howe", "CDT": "heure d’été du Centre", "CHADT": "heure d’été des îles Chatham", "GYT": "heure du Guyana", "EAT": "heure normale d’Afrique de l’Est", "AWDT": "heure d’été de l’Ouest de l’Australie", "HAST": "heure normale d’Hawaii - Aléoutiennes", "CAT": "heure normale d’Afrique centrale", "ACWDT": "heure d’été du centre-ouest de l’Australie", "CLST": "heure d’été du Chili", "TMT": "heure normale du Turkménistan", "WAT": "heure normale d’Afrique de l’Ouest", "ChST": "heure des Chamorro", "PDT": "heure d’été du Pacifique", "ACWST": "heure normale du centre-ouest de l’Australie", "HEOG": "heure d’été de l’Ouest du Groenland", "ADT": "heure d’été de l’Atlantique", "MYT": "heure de la Malaisie", "MDT": "heure d’été de Macao", "WAST": "heure d’été d’Afrique de l’Ouest", "WIT": "heure de l’Est indonésien", "∅∅∅": "heure d’été de l’Amazonie", "JDT": "heure d’été du Japon", "OEZ": "heure normale d’Europe de l’Est", "COT": "heure normale de Colombie", "UYT": "heure normale de l’Uruguay", "SGT": "heure de Singapour", "EDT": "heure d’été de l’Est", "HKST": "heure d’été de Hong Kong", "COST": "heure d’été de Colombie", "HNT": "heure normale de Terre-Neuve", "HEPMX": "heure d’été du Pacifique mexicain", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "EST": "heure normale de l’Est nord-américain", "BT": "heure du Bhoutan", "HAT": "heure d’été de Terre-Neuve", "GFT": "heure de la Guyane française", "IST": "heure de l’Inde", "NZDT": "heure d’été de la Nouvelle-Zélande", "AST": "heure normale de l’Atlantique", "ART": "heure normale d’Argentine", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "UYST": "heure d’été de l’Uruguay", "LHDT": "heure d’été de Lord Howe", "WIB": "heure de l’Ouest indonésien", "BOT": "heure de Bolivie", "JST": "heure normale du Japon", "WESZ": "heure d’été d’Europe de l’Ouest", "TMST": "heure d’été du Turkménistan", "HEEG": "heure d’été de l’Est du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "NZST": "heure normale de la Nouvelle-Zélande", "GMT": "heure moyenne de Greenwich", "HKT": "heure normale de Hong Kong", "PST": "heure normale du Pacifique nord-américain", "OESZ": "heure d’été d’Europe de l’Est", "CLT": "heure normale du Chili", "MST": "heure normale de Macao", "WITA": "heure du Centre indonésien", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HECU": "heure d’été de Cuba"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_HT) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_HT' +func (fr *fr_HT) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_HT' +func (fr *fr_HT) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_HT' +func (fr *fr_HT) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_HT' +func (fr *fr_HT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_HT' +func (fr *fr_HT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_HT' +func (fr *fr_HT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_HT) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_HT) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_HT) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_HT) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_HT) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_HT) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_HT) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_HT) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_HT) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_HT) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_HT) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_HT) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_HT) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_HT) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_HT' and handles both Whole and Real numbers based on 'v' +func (fr *fr_HT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_HT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_HT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_HT' +func (fr *fr_HT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_HT' +// in accounting notation. +func (fr *fr_HT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_HT' +func (fr *fr_HT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_HT' +func (fr *fr_HT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_HT' +func (fr *fr_HT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_HT' +func (fr *fr_HT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_HT' +func (fr *fr_HT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_HT' +func (fr *fr_HT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_HT' +func (fr *fr_HT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_HT' +func (fr *fr_HT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_HT/fr_HT_test.go b/vendor/github.com/go-playground/locales/fr_HT/fr_HT_test.go new file mode 100644 index 0000000000..2afcf84c6a --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_HT/fr_HT_test.go @@ -0,0 +1,1120 @@ +package fr_HT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_HT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_KM/fr_KM.go b/vendor/github.com/go-playground/locales/fr_KM/fr_KM.go new file mode 100644 index 0000000000..633c3ccd3f --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_KM/fr_KM.go @@ -0,0 +1,619 @@ +package fr_KM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_KM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_KM' locale +func New() locales.Translator { + return &fr_KM{ + locale: "fr_KM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "CF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"AST": "heure normale de l’Atlantique", "TMST": "heure d’été du Turkménistan", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "PDT": "heure d’été du Pacifique", "MEZ": "heure normale d’Europe centrale", "MYT": "heure de la Malaisie", "WAST": "heure d’été d’Afrique de l’Ouest", "HNEG": "heure normale de l’Est du Groenland", "AWDT": "heure d’été de l’Ouest de l’Australie", "JDT": "heure d’été du Japon", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "CAT": "heure normale d’Afrique centrale", "CLST": "heure d’été du Chili", "EST": "heure normale de l’Est nord-américain", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "WIB": "heure de l’Ouest indonésien", "EAT": "heure normale d’Afrique de l’Est", "WEZ": "heure normale d’Europe de l’Ouest", "ACST": "heure normale du centre de l’Australie", "HEEG": "heure d’été de l’Est du Groenland", "UYST": "heure d’été de l’Uruguay", "SAST": "heure normale d’Afrique méridionale", "WART": "heure normale de l’Ouest argentin", "MDT": "heure d’été de Macao", "AEDT": "heure d’été de l’Est de l’Australie", "AKDT": "heure d’été de l’Alaska", "HNPMX": "heure normale du Pacifique mexicain", "WARST": "heure d’été de l’Ouest argentin", "EDT": "heure d’été de l’Est", "WIT": "heure de l’Est indonésien", "HNCU": "heure normale de Cuba", "ADT": "heure d’été de l’Atlantique", "ART": "heure normale d’Argentine", "HKST": "heure d’été de Hong Kong", "∅∅∅": "heure d’été de l’Acre", "WITA": "heure du Centre indonésien", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "VET": "heure du Venezuela", "WAT": "heure normale d’Afrique de l’Ouest", "AKST": "heure normale de l’Alaska", "ACWDT": "heure d’été du centre-ouest de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "HAT": "heure d’été de Terre-Neuve", "AEST": "heure normale de l’Est de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "HAST": "heure normale d’Hawaii - Aléoutiennes", "IST": "heure de l’Inde", "ACWST": "heure normale du centre-ouest de l’Australie", "OESZ": "heure d’été d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "HNOG": "heure normale de l’Ouest du Groenland", "HKT": "heure normale de Hong Kong", "GYT": "heure du Guyana", "NZDT": "heure d’été de la Nouvelle-Zélande", "CLT": "heure normale du Chili", "HEOG": "heure d’été de l’Ouest du Groenland", "TMT": "heure normale du Turkménistan", "SRT": "heure du Suriname", "NZST": "heure normale de la Nouvelle-Zélande", "CDT": "heure d’été du Centre", "CHADT": "heure d’été des îles Chatham", "OEZ": "heure normale d’Europe de l’Est", "ARST": "heure d’été de l’Argentine", "COST": "heure d’été de Colombie", "ChST": "heure des Chamorro", "LHST": "heure normale de Lord Howe", "PST": "heure normale du Pacifique nord-américain", "COT": "heure normale de Colombie", "GFT": "heure de la Guyane française", "SGT": "heure de Singapour", "BOT": "heure de Bolivie", "CHAST": "heure normale des îles Chatham", "ECT": "heure de l’Équateur", "BT": "heure du Bhoutan", "HEPMX": "heure d’été du Pacifique mexicain", "HECU": "heure d’été de Cuba", "CST": "heure normale du centre nord-américain", "AWST": "heure normale de l’Ouest de l’Australie", "JST": "heure normale du Japon", "MESZ": "heure d’été d’Europe centrale", "WESZ": "heure d’été d’Europe de l’Ouest", "MST": "heure normale de Macao", "HNT": "heure normale de Terre-Neuve", "UYT": "heure normale de l’Uruguay", "LHDT": "heure d’été de Lord Howe"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_KM) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_KM' +func (fr *fr_KM) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_KM' +func (fr *fr_KM) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_KM' +func (fr *fr_KM) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_KM' +func (fr *fr_KM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_KM' +func (fr *fr_KM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_KM' +func (fr *fr_KM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_KM) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_KM) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_KM) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_KM) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_KM) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_KM) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_KM) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_KM) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_KM) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_KM) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_KM) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_KM) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_KM) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_KM) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_KM' and handles both Whole and Real numbers based on 'v' +func (fr *fr_KM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_KM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_KM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_KM' +func (fr *fr_KM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_KM' +// in accounting notation. +func (fr *fr_KM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_KM' +func (fr *fr_KM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_KM' +func (fr *fr_KM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_KM' +func (fr *fr_KM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_KM' +func (fr *fr_KM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_KM' +func (fr *fr_KM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_KM' +func (fr *fr_KM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_KM' +func (fr *fr_KM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_KM' +func (fr *fr_KM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_KM/fr_KM_test.go b/vendor/github.com/go-playground/locales/fr_KM/fr_KM_test.go new file mode 100644 index 0000000000..9249ac4b98 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_KM/fr_KM_test.go @@ -0,0 +1,1120 @@ +package fr_KM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_KM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_LU/fr_LU.go b/vendor/github.com/go-playground/locales/fr_LU/fr_LU.go new file mode 100644 index 0000000000..d962c21bcf --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_LU/fr_LU.go @@ -0,0 +1,613 @@ +package fr_LU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_LU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_LU' locale +func New() locales.Translator { + return &fr_LU{ + locale: "fr_LU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "F", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"COT": "heure normale de Colombie", "GFT": "heure de la Guyane française", "JDT": "heure d’été du Japon", "WART": "heure normale de l’Ouest argentin", "CLST": "heure d’été du Chili", "HEEG": "heure d’été de l’Est du Groenland", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "AWST": "heure normale de l’Ouest de l’Australie", "GMT": "heure moyenne de Greenwich", "MYT": "heure de la Malaisie", "CHAST": "heure normale des îles Chatham", "MEZ": "heure normale d’Europe centrale", "MESZ": "heure d’été d’Europe centrale", "EST": "heure normale de l’Est nord-américain", "HKT": "heure normale de Hong Kong", "ACST": "heure normale du centre de l’Australie", "HAT": "heure d’été de Terre-Neuve", "AKST": "heure normale de l’Alaska", "WEZ": "heure normale d’Europe de l’Ouest", "BT": "heure du Bhoutan", "UYST": "heure d’été de l’Uruguay", "AWDT": "heure d’été de l’Ouest de l’Australie", "OEZ": "heure normale d’Europe de l’Est", "IST": "heure de l’Inde", "AEST": "heure normale de l’Est de l’Australie", "UYT": "heure normale de l’Uruguay", "HECU": "heure d’été de Cuba", "PDT": "heure d’été du Pacifique", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "MDT": "heure d’été des Rocheuses", "SRT": "heure du Suriname", "WIB": "heure de l’Ouest indonésien", "PST": "heure normale du Pacifique nord-américain", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "LHDT": "heure d’été de Lord Howe", "SAST": "heure normale d’Afrique méridionale", "ECT": "heure de l’Équateur", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "CDT": "heure d’été du Centre", "CAT": "heure normale d’Afrique centrale", "AST": "heure normale de l’Atlantique", "HKST": "heure d’été de Hong Kong", "SGT": "heure de Singapour", "OESZ": "heure d’été d’Europe de l’Est", "TMT": "heure normale du Turkménistan", "ACWST": "heure normale du centre-ouest de l’Australie", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "ACDT": "heure d’été du centre de l’Australie", "∅∅∅": "heure d’été de l’Acre", "MST": "heure normale des Rocheuses", "HEPMX": "heure d’été du Pacifique mexicain", "HNCU": "heure normale de Cuba", "ARST": "heure d’été de l’Argentine", "NZDT": "heure d’été de la Nouvelle-Zélande", "WARST": "heure d’été de l’Ouest argentin", "HEOG": "heure d’été de l’Ouest du Groenland", "EDT": "heure d’été de l’Est", "COST": "heure d’été de Colombie", "WITA": "heure du Centre indonésien", "WIT": "heure de l’Est indonésien", "CHADT": "heure d’été des îles Chatham", "ADT": "heure d’été de l’Atlantique", "ART": "heure normale d’Argentine", "WAT": "heure normale d’Afrique de l’Ouest", "LHST": "heure normale de Lord Howe", "HNPMX": "heure normale du Pacifique mexicain", "VET": "heure du Venezuela", "HNOG": "heure normale de l’Ouest du Groenland", "WESZ": "heure d’été d’Europe de l’Ouest", "TMST": "heure d’été du Turkménistan", "HNT": "heure normale de Terre-Neuve", "ChST": "heure des Chamorro", "EAT": "heure normale d’Afrique de l’Est", "BOT": "heure de Bolivie", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ACWDT": "heure d’été du centre-ouest de l’Australie", "NZST": "heure normale de la Nouvelle-Zélande", "JST": "heure normale du Japon", "WAST": "heure d’été d’Afrique de l’Ouest", "HNEG": "heure normale de l’Est du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "AKDT": "heure d’été de l’Alaska", "GYT": "heure du Guyana", "CST": "heure normale du centre nord-américain", "CLT": "heure normale du Chili"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_LU) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_LU' +func (fr *fr_LU) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_LU' +func (fr *fr_LU) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_LU' +func (fr *fr_LU) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_LU' +func (fr *fr_LU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_LU' +func (fr *fr_LU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_LU' +func (fr *fr_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_LU) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_LU) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_LU) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_LU) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_LU) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_LU) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_LU) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_LU) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_LU) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_LU) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_LU) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_LU) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_LU) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_LU) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_LU' and handles both Whole and Real numbers based on 'v' +func (fr *fr_LU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_LU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_LU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_LU' +func (fr *fr_LU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_LU' +// in accounting notation. +func (fr *fr_LU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_LU' +func (fr *fr_LU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_LU' +func (fr *fr_LU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_LU' +func (fr *fr_LU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_LU' +func (fr *fr_LU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_LU' +func (fr *fr_LU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_LU' +func (fr *fr_LU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_LU' +func (fr *fr_LU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_LU' +func (fr *fr_LU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_LU/fr_LU_test.go b/vendor/github.com/go-playground/locales/fr_LU/fr_LU_test.go new file mode 100644 index 0000000000..207eb86cf5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_LU/fr_LU_test.go @@ -0,0 +1,1120 @@ +package fr_LU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_LU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_MA/fr_MA.go b/vendor/github.com/go-playground/locales/fr_MA/fr_MA.go new file mode 100644 index 0000000000..157b8321aa --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MA/fr_MA.go @@ -0,0 +1,613 @@ +package fr_MA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_MA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_MA' locale +func New() locales.Translator { + return &fr_MA{ + locale: "fr_MA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "fév.", "mar.", "avr.", "mai", "jui.", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"SAST": "heure normale d’Afrique méridionale", "EST": "heure normale de l’Est nord-américain", "EDT": "heure d’été de l’Est", "WITA": "heure du Centre indonésien", "UYST": "heure d’été de l’Uruguay", "GFT": "heure de la Guyane française", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HECU": "heure d’été de Cuba", "CAT": "heure normale d’Afrique centrale", "ACWST": "heure normale du centre-ouest de l’Australie", "WARST": "heure d’été de l’Ouest argentin", "WAT": "heure normale d’Afrique de l’Ouest", "TMST": "heure d’été du Turkménistan", "AEDT": "heure d’été de l’Est de l’Australie", "EAT": "heure normale d’Afrique de l’Est", "TMT": "heure normale du Turkménistan", "HKT": "heure normale de Hong Kong", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "NZST": "heure normale de la Nouvelle-Zélande", "HNOG": "heure normale de l’Ouest du Groenland", "OESZ": "heure d’été d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "HNPMX": "heure normale du Pacifique mexicain", "HEPMX": "heure d’été du Pacifique mexicain", "∅∅∅": "heure d’été de l’Amazonie", "CLST": "heure d’été du Chili", "HKST": "heure d’été de Hong Kong", "LHST": "heure normale de Lord Howe", "HNEG": "heure normale de l’Est du Groenland", "CDT": "heure d’été du Centre", "AWST": "heure normale de l’Ouest de l’Australie", "CHADT": "heure d’été des îles Chatham", "ACWDT": "heure d’été du centre-ouest de l’Australie", "JDT": "heure d’été du Japon", "WESZ": "heure d’été d’Europe de l’Ouest", "ARST": "heure d’été de l’Argentine", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ECT": "heure de l’Équateur", "JST": "heure normale du Japon", "HAT": "heure d’été de Terre-Neuve", "HEEG": "heure d’été de l’Est du Groenland", "CST": "heure normale du centre nord-américain", "AST": "heure normale de l’Atlantique", "ART": "heure normale d’Argentine", "HNT": "heure normale de Terre-Neuve", "LHDT": "heure d’été de Lord Howe", "AKDT": "heure d’été de l’Alaska", "IST": "heure de l’Inde", "MYT": "heure de la Malaisie", "ACST": "heure normale du centre de l’Australie", "BT": "heure du Bhoutan", "ACDT": "heure d’été du centre de l’Australie", "SRT": "heure du Suriname", "SGT": "heure de Singapour", "VET": "heure du Venezuela", "HEOG": "heure d’été de l’Ouest du Groenland", "MDT": "heure d’été de Macao", "WAST": "heure d’été d’Afrique de l’Ouest", "CLT": "heure normale du Chili", "AKST": "heure normale de l’Alaska", "PST": "heure normale du Pacifique nord-américain", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "BOT": "heure de Bolivie", "PDT": "heure d’été du Pacifique", "WART": "heure normale de l’Ouest argentin", "COT": "heure normale de Colombie", "COST": "heure d’été de Colombie", "WIT": "heure de l’Est indonésien", "ChST": "heure des Chamorro", "HNCU": "heure normale de Cuba", "WIB": "heure de l’Ouest indonésien", "NZDT": "heure d’été de la Nouvelle-Zélande", "WEZ": "heure normale d’Europe de l’Ouest", "MST": "heure normale de Macao", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "CHAST": "heure normale des îles Chatham", "MESZ": "heure d’été d’Europe centrale", "ADT": "heure d’été de l’Atlantique", "OEZ": "heure normale d’Europe de l’Est", "UYT": "heure normale de l’Uruguay", "AWDT": "heure d’été de l’Ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "AEST": "heure normale de l’Est de l’Australie", "GYT": "heure du Guyana"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_MA) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_MA' +func (fr *fr_MA) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_MA' +func (fr *fr_MA) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_MA' +func (fr *fr_MA) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MA' +func (fr *fr_MA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MA' +func (fr *fr_MA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_MA' +func (fr *fr_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_MA) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_MA) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_MA) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_MA) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_MA) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_MA) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_MA) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_MA) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_MA) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_MA) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_MA) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_MA) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_MA) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_MA) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_MA' and handles both Whole and Real numbers based on 'v' +func (fr *fr_MA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_MA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_MA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MA' +func (fr *fr_MA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MA' +// in accounting notation. +func (fr *fr_MA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_MA' +func (fr *fr_MA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_MA' +func (fr *fr_MA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_MA' +func (fr *fr_MA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_MA' +func (fr *fr_MA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_MA' +func (fr *fr_MA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_MA' +func (fr *fr_MA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_MA' +func (fr *fr_MA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_MA' +func (fr *fr_MA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_MA/fr_MA_test.go b/vendor/github.com/go-playground/locales/fr_MA/fr_MA_test.go new file mode 100644 index 0000000000..4ac696b9e0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MA/fr_MA_test.go @@ -0,0 +1,1120 @@ +package fr_MA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_MA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_MC/fr_MC.go b/vendor/github.com/go-playground/locales/fr_MC/fr_MC.go new file mode 100644 index 0000000000..06f68c0dc9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MC/fr_MC.go @@ -0,0 +1,619 @@ +package fr_MC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_MC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_MC' locale +func New() locales.Translator { + return &fr_MC{ + locale: "fr_MC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"AEDT": "heure d’été de l’Est de l’Australie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "ACWST": "heure normale du centre-ouest de l’Australie", "ACWDT": "heure d’été du centre-ouest de l’Australie", "CLST": "heure d’été du Chili", "HKT": "heure normale de Hong Kong", "HKST": "heure d’été de Hong Kong", "HNT": "heure normale de Terre-Neuve", "UYST": "heure d’été de l’Uruguay", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "EAT": "heure normale d’Afrique de l’Est", "OEZ": "heure normale d’Europe de l’Est", "WESZ": "heure d’été d’Europe de l’Ouest", "COST": "heure d’été de Colombie", "HAT": "heure d’été de Terre-Neuve", "AWST": "heure normale de l’Ouest de l’Australie", "SGT": "heure de Singapour", "PST": "heure normale du Pacifique nord-américain", "CAT": "heure normale d’Afrique centrale", "TMT": "heure normale du Turkménistan", "HNEG": "heure normale de l’Est du Groenland", "CHAST": "heure normale des îles Chatham", "ChST": "heure des Chamorro", "HEPMX": "heure d’été du Pacifique mexicain", "CST": "heure normale du centre nord-américain", "JDT": "heure d’été du Japon", "ARST": "heure d’été de l’Argentine", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "UYT": "heure normale de l’Uruguay", "LHDT": "heure d’été de Lord Howe", "BOT": "heure de Bolivie", "PDT": "heure d’été du Pacifique", "HAST": "heure normale d’Hawaii - Aléoutiennes", "SAST": "heure normale d’Afrique méridionale", "SRT": "heure du Suriname", "HECU": "heure d’été de Cuba", "CLT": "heure normale du Chili", "HNOG": "heure normale de l’Ouest du Groenland", "WEZ": "heure normale d’Europe de l’Ouest", "WAST": "heure d’été d’Afrique de l’Ouest", "CHADT": "heure d’été des îles Chatham", "ECT": "heure de l’Équateur", "VET": "heure du Venezuela", "MYT": "heure de la Malaisie", "ADT": "heure d’été de l’Atlantique", "MST": "heure normale de Macao", "BT": "heure du Bhoutan", "ACDT": "heure d’été du centre de l’Australie", "∅∅∅": "heure d’été des Açores", "GYT": "heure du Guyana", "HNCU": "heure normale de Cuba", "WIB": "heure de l’Ouest indonésien", "AWDT": "heure d’été de l’Ouest de l’Australie", "WARST": "heure d’été de l’Ouest argentin", "WAT": "heure normale d’Afrique de l’Ouest", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "MEZ": "heure normale d’Europe centrale", "COT": "heure normale de Colombie", "AEST": "heure normale de l’Est de l’Australie", "LHST": "heure normale de Lord Howe", "WART": "heure normale de l’Ouest argentin", "GMT": "heure moyenne de Greenwich", "TMST": "heure d’été du Turkménistan", "HEEG": "heure d’été de l’Est du Groenland", "GFT": "heure de la Guyane française", "AKST": "heure normale de l’Alaska", "MESZ": "heure d’été d’Europe centrale", "JST": "heure normale du Japon", "ART": "heure normale d’Argentine", "EDT": "heure d’été de l’Est", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HNPMX": "heure normale du Pacifique mexicain", "NZST": "heure normale de la Nouvelle-Zélande", "HEOG": "heure d’été de l’Ouest du Groenland", "MDT": "heure d’été de Macao", "AKDT": "heure d’été de l’Alaska", "CDT": "heure d’été du Centre", "WIT": "heure de l’Est indonésien", "NZDT": "heure d’été de la Nouvelle-Zélande", "OESZ": "heure d’été d’Europe de l’Est", "EST": "heure normale de l’Est nord-américain", "WITA": "heure du Centre indonésien", "IST": "heure de l’Inde", "AST": "heure normale de l’Atlantique", "ACST": "heure normale du centre de l’Australie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_MC) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_MC' +func (fr *fr_MC) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_MC' +func (fr *fr_MC) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_MC' +func (fr *fr_MC) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MC' +func (fr *fr_MC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MC' +func (fr *fr_MC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_MC' +func (fr *fr_MC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_MC) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_MC) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_MC) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_MC) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_MC) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_MC) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_MC) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_MC) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_MC) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_MC) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_MC) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_MC) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_MC) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_MC) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_MC' and handles both Whole and Real numbers based on 'v' +func (fr *fr_MC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_MC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_MC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MC' +func (fr *fr_MC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MC' +// in accounting notation. +func (fr *fr_MC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_MC' +func (fr *fr_MC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_MC' +func (fr *fr_MC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_MC' +func (fr *fr_MC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_MC' +func (fr *fr_MC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_MC' +func (fr *fr_MC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_MC' +func (fr *fr_MC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_MC' +func (fr *fr_MC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_MC' +func (fr *fr_MC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_MC/fr_MC_test.go b/vendor/github.com/go-playground/locales/fr_MC/fr_MC_test.go new file mode 100644 index 0000000000..d45fd8d6b4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MC/fr_MC_test.go @@ -0,0 +1,1120 @@ +package fr_MC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_MC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_MF/fr_MF.go b/vendor/github.com/go-playground/locales/fr_MF/fr_MF.go new file mode 100644 index 0000000000..5a38c7d7b2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MF/fr_MF.go @@ -0,0 +1,619 @@ +package fr_MF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_MF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_MF' locale +func New() locales.Translator { + return &fr_MF{ + locale: "fr_MF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"GFT": "heure de la Guyane française", "CHAST": "heure normale des îles Chatham", "CAT": "heure normale d’Afrique centrale", "WARST": "heure d’été de l’Ouest argentin", "HKST": "heure d’été de Hong Kong", "HNT": "heure normale de Terre-Neuve", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "VET": "heure du Venezuela", "AST": "heure normale de l’Atlantique", "TMT": "heure normale du Turkménistan", "SGT": "heure de Singapour", "MESZ": "heure d’été d’Europe centrale", "WEZ": "heure normale d’Europe de l’Ouest", "COST": "heure d’été de Colombie", "UYST": "heure d’été de l’Uruguay", "HEPMX": "heure d’été du Pacifique mexicain", "WIB": "heure de l’Ouest indonésien", "AWST": "heure normale de l’Ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "HEOG": "heure d’été de l’Ouest du Groenland", "EST": "heure normale de l’Est nord-américain", "AKDT": "heure d’été de l’Alaska", "AEST": "heure normale de l’Est de l’Australie", "LHST": "heure normale de Lord Howe", "AWDT": "heure d’été de l’Ouest de l’Australie", "ECT": "heure de l’Équateur", "ARST": "heure d’été de l’Argentine", "CHADT": "heure d’été des îles Chatham", "NZDT": "heure d’été de la Nouvelle-Zélande", "JDT": "heure d’été du Japon", "CLT": "heure normale du Chili", "HNOG": "heure normale de l’Ouest du Groenland", "OEZ": "heure normale d’Europe de l’Est", "WESZ": "heure d’été d’Europe de l’Ouest", "COT": "heure normale de Colombie", "HNPMX": "heure normale du Pacifique mexicain", "HECU": "heure d’été de Cuba", "ACWDT": "heure d’été du centre-ouest de l’Australie", "WITA": "heure du Centre indonésien", "ACST": "heure normale du centre de l’Australie", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "AEDT": "heure d’été de l’Est de l’Australie", "∅∅∅": "heure d’été des Açores", "GYT": "heure du Guyana", "ACWST": "heure normale du centre-ouest de l’Australie", "WAT": "heure normale d’Afrique de l’Ouest", "ACDT": "heure d’été du centre de l’Australie", "IST": "heure de l’Inde", "CLST": "heure d’été du Chili", "MYT": "heure de la Malaisie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HNCU": "heure normale de Cuba", "CST": "heure normale du centre nord-américain", "CDT": "heure d’été du Centre", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ADT": "heure d’été de l’Atlantique", "TMST": "heure d’été du Turkménistan", "ART": "heure normale d’Argentine", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "LHDT": "heure d’été de Lord Howe", "PST": "heure normale du Pacifique nord-américain", "PDT": "heure d’été du Pacifique", "HNEG": "heure normale de l’Est du Groenland", "EDT": "heure d’été de l’Est", "ChST": "heure des Chamorro", "EAT": "heure normale d’Afrique de l’Est", "WART": "heure normale de l’Ouest argentin", "MST": "heure normale de Macao", "AKST": "heure normale de l’Alaska", "WIT": "heure de l’Est indonésien", "WAST": "heure d’été d’Afrique de l’Ouest", "BT": "heure du Bhoutan", "UYT": "heure normale de l’Uruguay", "SRT": "heure du Suriname", "BOT": "heure de Bolivie", "OESZ": "heure d’été d’Europe de l’Est", "MDT": "heure d’été de Macao", "HAT": "heure d’été de Terre-Neuve", "NZST": "heure normale de la Nouvelle-Zélande", "JST": "heure normale du Japon", "GMT": "heure moyenne de Greenwich", "HEEG": "heure d’été de l’Est du Groenland", "SAST": "heure normale d’Afrique méridionale", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "HKT": "heure normale de Hong Kong"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_MF) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_MF' +func (fr *fr_MF) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_MF' +func (fr *fr_MF) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_MF' +func (fr *fr_MF) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MF' +func (fr *fr_MF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MF' +func (fr *fr_MF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_MF' +func (fr *fr_MF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_MF) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_MF) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_MF) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_MF) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_MF) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_MF) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_MF) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_MF) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_MF) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_MF) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_MF) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_MF) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_MF) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_MF) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_MF' and handles both Whole and Real numbers based on 'v' +func (fr *fr_MF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_MF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_MF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MF' +func (fr *fr_MF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MF' +// in accounting notation. +func (fr *fr_MF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_MF' +func (fr *fr_MF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_MF' +func (fr *fr_MF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_MF' +func (fr *fr_MF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_MF' +func (fr *fr_MF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_MF' +func (fr *fr_MF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_MF' +func (fr *fr_MF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_MF' +func (fr *fr_MF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_MF' +func (fr *fr_MF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_MF/fr_MF_test.go b/vendor/github.com/go-playground/locales/fr_MF/fr_MF_test.go new file mode 100644 index 0000000000..f902b21571 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MF/fr_MF_test.go @@ -0,0 +1,1120 @@ +package fr_MF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_MF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_MG/fr_MG.go b/vendor/github.com/go-playground/locales/fr_MG/fr_MG.go new file mode 100644 index 0000000000..8a9bd628aa --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MG/fr_MG.go @@ -0,0 +1,619 @@ +package fr_MG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_MG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_MG' locale +func New() locales.Translator { + return &fr_MG{ + locale: "fr_MG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "Ar", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"HADT": "heure d’été d’Hawaii - Aléoutiennes", "VET": "heure du Venezuela", "HNOG": "heure normale de l’Ouest du Groenland", "WARST": "heure d’été de l’Ouest argentin", "TMST": "heure d’été du Turkménistan", "HNT": "heure normale de Terre-Neuve", "UYT": "heure normale de l’Uruguay", "CHAST": "heure normale des îles Chatham", "NZST": "heure normale de la Nouvelle-Zélande", "WEZ": "heure normale d’Europe de l’Ouest", "GMT": "heure moyenne de Greenwich", "AEST": "heure normale de l’Est de l’Australie", "ChST": "heure des Chamorro", "JDT": "heure d’été du Japon", "AST": "heure normale de l’Atlantique", "HKT": "heure normale de Hong Kong", "ACST": "heure normale du centre de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "HAT": "heure d’été de Terre-Neuve", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "CAT": "heure normale d’Afrique centrale", "NZDT": "heure d’été de la Nouvelle-Zélande", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "SRT": "heure du Suriname", "AWST": "heure normale de l’Ouest de l’Australie", "PST": "heure normale du Pacifique nord-américain", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HNEG": "heure normale de l’Est du Groenland", "AKST": "heure normale de l’Alaska", "EAT": "heure normale d’Afrique de l’Est", "CHADT": "heure d’été des îles Chatham", "WESZ": "heure d’été d’Europe de l’Ouest", "BOT": "heure de Bolivie", "ARST": "heure d’été de l’Argentine", "HKST": "heure d’été de Hong Kong", "BT": "heure du Bhoutan", "LHDT": "heure d’été de Lord Howe", "WIB": "heure de l’Ouest indonésien", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ART": "heure normale d’Argentine", "COT": "heure normale de Colombie", "AKDT": "heure d’été de l’Alaska", "CST": "heure normale du centre nord-américain", "WIT": "heure de l’Est indonésien", "SGT": "heure de Singapour", "MEZ": "heure normale d’Europe centrale", "HEOG": "heure d’été de l’Ouest du Groenland", "WAT": "heure normale d’Afrique de l’Ouest", "WITA": "heure du Centre indonésien", "GFT": "heure de la Guyane française", "LHST": "heure normale de Lord Howe", "HEPMX": "heure d’été du Pacifique mexicain", "∅∅∅": "heure d’été des Açores", "CDT": "heure d’été du Centre", "ACWST": "heure normale du centre-ouest de l’Australie", "JST": "heure normale du Japon", "WAST": "heure d’été d’Afrique de l’Ouest", "TMT": "heure normale du Turkménistan", "UYST": "heure d’été de l’Uruguay", "SAST": "heure normale d’Afrique méridionale", "GYT": "heure du Guyana", "IST": "heure de l’Inde", "ACWDT": "heure d’été du centre-ouest de l’Australie", "MESZ": "heure d’été d’Europe centrale", "OESZ": "heure d’été d’Europe de l’Est", "AEDT": "heure d’été de l’Est de l’Australie", "HECU": "heure d’été de Cuba", "PDT": "heure d’été du Pacifique", "OEZ": "heure normale d’Europe de l’Est", "EDT": "heure d’été de l’Est", "COST": "heure d’été de Colombie", "HEEG": "heure d’été de l’Est du Groenland", "HNCU": "heure normale de Cuba", "AWDT": "heure d’été de l’Ouest de l’Australie", "ECT": "heure de l’Équateur", "CLST": "heure d’été du Chili", "MDT": "heure d’été de Macao", "EST": "heure normale de l’Est nord-américain", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HNPMX": "heure normale du Pacifique mexicain", "ADT": "heure d’été de l’Atlantique", "MYT": "heure de la Malaisie", "WART": "heure normale de l’Ouest argentin", "MST": "heure normale de Macao", "CLT": "heure normale du Chili"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_MG) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_MG' +func (fr *fr_MG) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_MG' +func (fr *fr_MG) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_MG' +func (fr *fr_MG) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MG' +func (fr *fr_MG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MG' +func (fr *fr_MG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_MG' +func (fr *fr_MG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_MG) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_MG) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_MG) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_MG) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_MG) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_MG) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_MG) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_MG) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_MG) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_MG) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_MG) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_MG) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_MG) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_MG) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_MG' and handles both Whole and Real numbers based on 'v' +func (fr *fr_MG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_MG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_MG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MG' +func (fr *fr_MG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MG' +// in accounting notation. +func (fr *fr_MG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_MG' +func (fr *fr_MG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_MG' +func (fr *fr_MG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_MG' +func (fr *fr_MG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_MG' +func (fr *fr_MG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_MG' +func (fr *fr_MG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_MG' +func (fr *fr_MG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_MG' +func (fr *fr_MG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_MG' +func (fr *fr_MG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_MG/fr_MG_test.go b/vendor/github.com/go-playground/locales/fr_MG/fr_MG_test.go new file mode 100644 index 0000000000..d9083d0133 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MG/fr_MG_test.go @@ -0,0 +1,1120 @@ +package fr_MG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_MG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_ML/fr_ML.go b/vendor/github.com/go-playground/locales/fr_ML/fr_ML.go new file mode 100644 index 0000000000..74e6fa8969 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_ML/fr_ML.go @@ -0,0 +1,619 @@ +package fr_ML + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_ML struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_ML' locale +func New() locales.Translator { + return &fr_ML{ + locale: "fr_ML", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"AKDT": "heure d’été de l’Alaska", "ChST": "heure des Chamorro", "SAST": "heure normale d’Afrique méridionale", "ECT": "heure de l’Équateur", "NZST": "heure normale de la Nouvelle-Zélande", "TMT": "heure normale du Turkménistan", "WITA": "heure du Centre indonésien", "COT": "heure normale de Colombie", "HNPMX": "heure normale du Pacifique mexicain", "HAST": "heure normale d’Hawaii - Aléoutiennes", "JDT": "heure d’été du Japon", "WEZ": "heure normale d’Europe de l’Ouest", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "AEDT": "heure d’été de l’Est de l’Australie", "UYT": "heure normale de l’Uruguay", "LHDT": "heure d’été de Lord Howe", "GYT": "heure du Guyana", "WIB": "heure de l’Ouest indonésien", "WAST": "heure d’été d’Afrique de l’Ouest", "ACST": "heure normale du centre de l’Australie", "CST": "heure normale du centre nord-américain", "CDT": "heure d’été du Centre", "AEST": "heure normale de l’Est de l’Australie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "AWST": "heure normale de l’Ouest de l’Australie", "HEOG": "heure d’été de l’Ouest du Groenland", "WARST": "heure d’été de l’Ouest argentin", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "HEPMX": "heure d’été du Pacifique mexicain", "WART": "heure normale de l’Ouest argentin", "HKST": "heure d’été de Hong Kong", "OEZ": "heure normale d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "MDT": "heure d’été de Macao", "COST": "heure d’été de Colombie", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "VET": "heure du Venezuela", "AST": "heure normale de l’Atlantique", "AKST": "heure normale de l’Alaska", "SRT": "heure du Suriname", "PDT": "heure d’été du Pacifique", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "ACWST": "heure normale du centre-ouest de l’Australie", "WESZ": "heure d’été d’Europe de l’Ouest", "HKT": "heure normale de Hong Kong", "TMST": "heure d’été du Turkménistan", "PST": "heure normale du Pacifique nord-américain", "IST": "heure de l’Inde", "CLT": "heure normale du Chili", "HNOG": "heure normale de l’Ouest du Groenland", "WAT": "heure normale d’Afrique de l’Ouest", "BT": "heure du Bhoutan", "HECU": "heure d’été de Cuba", "AWDT": "heure d’été de l’Ouest de l’Australie", "ACWDT": "heure d’été du centre-ouest de l’Australie", "JST": "heure normale du Japon", "ARST": "heure d’été de l’Argentine", "MST": "heure normale de Macao", "EST": "heure normale de l’Est nord-américain", "ACDT": "heure d’été du centre de l’Australie", "CHADT": "heure d’été des îles Chatham", "NZDT": "heure d’été de la Nouvelle-Zélande", "OESZ": "heure d’été d’Europe de l’Est", "MYT": "heure de la Malaisie", "WIT": "heure de l’Est indonésien", "CHAST": "heure normale des îles Chatham", "∅∅∅": "heure d’été de l’Acre", "UYST": "heure d’été de l’Uruguay", "MESZ": "heure d’été d’Europe centrale", "EDT": "heure d’été de l’Est", "BOT": "heure de Bolivie", "CAT": "heure normale d’Afrique centrale", "CLST": "heure d’été du Chili", "ART": "heure normale d’Argentine", "EAT": "heure normale d’Afrique de l’Est", "HNCU": "heure normale de Cuba", "HNEG": "heure normale de l’Est du Groenland", "LHST": "heure normale de Lord Howe", "ADT": "heure d’été de l’Atlantique", "HAT": "heure d’été de Terre-Neuve", "HEEG": "heure d’été de l’Est du Groenland", "GFT": "heure de la Guyane française", "SGT": "heure de Singapour", "MEZ": "heure normale d’Europe centrale", "HNT": "heure normale de Terre-Neuve"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_ML) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_ML' +func (fr *fr_ML) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_ML' +func (fr *fr_ML) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_ML' +func (fr *fr_ML) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_ML' +func (fr *fr_ML) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_ML' +func (fr *fr_ML) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_ML' +func (fr *fr_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_ML) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_ML) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_ML) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_ML) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_ML) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_ML) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_ML) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_ML) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_ML) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_ML) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_ML) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_ML) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_ML) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_ML) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_ML' and handles both Whole and Real numbers based on 'v' +func (fr *fr_ML) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_ML' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_ML) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_ML' +func (fr *fr_ML) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_ML' +// in accounting notation. +func (fr *fr_ML) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_ML' +func (fr *fr_ML) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_ML' +func (fr *fr_ML) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_ML' +func (fr *fr_ML) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_ML' +func (fr *fr_ML) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_ML' +func (fr *fr_ML) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_ML' +func (fr *fr_ML) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_ML' +func (fr *fr_ML) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_ML' +func (fr *fr_ML) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_ML/fr_ML_test.go b/vendor/github.com/go-playground/locales/fr_ML/fr_ML_test.go new file mode 100644 index 0000000000..b7a1c31f08 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_ML/fr_ML_test.go @@ -0,0 +1,1120 @@ +package fr_ML + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_ML" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_MQ/fr_MQ.go b/vendor/github.com/go-playground/locales/fr_MQ/fr_MQ.go new file mode 100644 index 0000000000..90ff0a1388 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MQ/fr_MQ.go @@ -0,0 +1,619 @@ +package fr_MQ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_MQ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_MQ' locale +func New() locales.Translator { + return &fr_MQ{ + locale: "fr_MQ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "SRT": "heure du Suriname", "HECU": "heure d’été de Cuba", "CHADT": "heure d’été des îles Chatham", "BOT": "heure de Bolivie", "CLT": "heure normale du Chili", "HNT": "heure normale de Terre-Neuve", "ARST": "heure d’été de l’Argentine", "BT": "heure du Bhoutan", "HNEG": "heure normale de l’Est du Groenland", "WITA": "heure du Centre indonésien", "SAST": "heure normale d’Afrique méridionale", "HEPMX": "heure d’été du Pacifique mexicain", "OESZ": "heure d’été d’Europe de l’Est", "WESZ": "heure d’été d’Europe de l’Ouest", "CAT": "heure normale d’Afrique centrale", "WIT": "heure de l’Est indonésien", "PDT": "heure d’été du Pacifique", "ADT": "heure d’été de l’Atlantique", "MYT": "heure de la Malaisie", "MST": "heure normale de Macao", "HEEG": "heure d’été de l’Est du Groenland", "UYST": "heure d’été de l’Uruguay", "MESZ": "heure d’été d’Europe centrale", "CLST": "heure d’été du Chili", "HAT": "heure d’été de Terre-Neuve", "∅∅∅": "heure d’été de l’Acre", "EAT": "heure normale d’Afrique de l’Est", "VET": "heure du Venezuela", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HNCU": "heure normale de Cuba", "WEZ": "heure normale d’Europe de l’Ouest", "AEST": "heure normale de l’Est de l’Australie", "ChST": "heure des Chamorro", "UYT": "heure normale de l’Uruguay", "ART": "heure normale d’Argentine", "ACST": "heure normale du centre de l’Australie", "AST": "heure normale de l’Atlantique", "EDT": "heure d’été de l’Est", "AKST": "heure normale de l’Alaska", "MEZ": "heure normale d’Europe centrale", "HEOG": "heure d’été de l’Ouest du Groenland", "CHAST": "heure normale des îles Chatham", "HAST": "heure normale d’Hawaii - Aléoutiennes", "MDT": "heure d’été de Macao", "LHDT": "heure d’été de Lord Howe", "HNPMX": "heure normale du Pacifique mexicain", "IST": "heure de l’Inde", "NZDT": "heure d’été de la Nouvelle-Zélande", "WART": "heure normale de l’Ouest argentin", "TMST": "heure d’été du Turkménistan", "COST": "heure d’été de Colombie", "GYT": "heure du Guyana", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "ACWDT": "heure d’été du centre-ouest de l’Australie", "GMT": "heure moyenne de Greenwich", "WAT": "heure normale d’Afrique de l’Ouest", "CST": "heure normale du centre nord-américain", "CDT": "heure d’été du Centre", "ACDT": "heure d’été du centre de l’Australie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "COT": "heure normale de Colombie", "LHST": "heure normale de Lord Howe", "AWST": "heure normale de l’Ouest de l’Australie", "SGT": "heure de Singapour", "PST": "heure normale du Pacifique nord-américain", "WAST": "heure d’été d’Afrique de l’Ouest", "EST": "heure normale de l’Est nord-américain", "ACWST": "heure normale du centre-ouest de l’Australie", "HKST": "heure d’été de Hong Kong", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "ECT": "heure de l’Équateur", "HNOG": "heure normale de l’Ouest du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "AKDT": "heure d’été de l’Alaska", "HKT": "heure normale de Hong Kong", "GFT": "heure de la Guyane française", "OEZ": "heure normale d’Europe de l’Est", "WARST": "heure d’été de l’Ouest argentin", "TMT": "heure normale du Turkménistan", "WIB": "heure de l’Ouest indonésien", "AWDT": "heure d’été de l’Ouest de l’Australie", "NZST": "heure normale de la Nouvelle-Zélande", "JST": "heure normale du Japon", "JDT": "heure d’été du Japon"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_MQ) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_MQ' +func (fr *fr_MQ) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_MQ' +func (fr *fr_MQ) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_MQ' +func (fr *fr_MQ) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MQ' +func (fr *fr_MQ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MQ' +func (fr *fr_MQ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_MQ' +func (fr *fr_MQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_MQ) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_MQ) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_MQ) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_MQ) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_MQ) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_MQ) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_MQ) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_MQ) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_MQ) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_MQ) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_MQ) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_MQ) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_MQ) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_MQ) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_MQ' and handles both Whole and Real numbers based on 'v' +func (fr *fr_MQ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_MQ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_MQ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MQ' +func (fr *fr_MQ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MQ' +// in accounting notation. +func (fr *fr_MQ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_MQ' +func (fr *fr_MQ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_MQ' +func (fr *fr_MQ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_MQ' +func (fr *fr_MQ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_MQ' +func (fr *fr_MQ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_MQ' +func (fr *fr_MQ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_MQ' +func (fr *fr_MQ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_MQ' +func (fr *fr_MQ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_MQ' +func (fr *fr_MQ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_MQ/fr_MQ_test.go b/vendor/github.com/go-playground/locales/fr_MQ/fr_MQ_test.go new file mode 100644 index 0000000000..8f2fa4ae50 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MQ/fr_MQ_test.go @@ -0,0 +1,1120 @@ +package fr_MQ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_MQ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_MR/fr_MR.go b/vendor/github.com/go-playground/locales/fr_MR/fr_MR.go new file mode 100644 index 0000000000..482d918dea --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MR/fr_MR.go @@ -0,0 +1,657 @@ +package fr_MR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_MR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_MR' locale +func New() locales.Translator { + return &fr_MR{ + locale: "fr_MR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "UM", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"ECT": "heure de l’Équateur", "WART": "heure normale de l’Ouest argentin", "OESZ": "heure d’été d’Europe de l’Est", "ACST": "heure normale du centre de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "HEPMX": "heure d’été du Pacifique mexicain", "CHADT": "heure d’été des îles Chatham", "CAT": "heure normale d’Afrique centrale", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "LHDT": "heure d’été de Lord Howe", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "NZST": "heure normale de la Nouvelle-Zélande", "JST": "heure normale du Japon", "HKT": "heure normale de Hong Kong", "HNCU": "heure normale de Cuba", "SRT": "heure du Suriname", "HNPMX": "heure normale du Pacifique mexicain", "CDT": "heure d’été du Centre", "WIT": "heure de l’Est indonésien", "OEZ": "heure normale d’Europe de l’Est", "WESZ": "heure d’été d’Europe de l’Ouest", "MST": "heure normale de Macao", "WITA": "heure du Centre indonésien", "TMT": "heure normale du Turkménistan", "ACWDT": "heure d’été du centre-ouest de l’Australie", "HNOG": "heure normale de l’Ouest du Groenland", "AKST": "heure normale de l’Alaska", "CST": "heure normale du centre nord-américain", "ACWST": "heure normale du centre-ouest de l’Australie", "CLT": "heure normale du Chili", "HAT": "heure d’été de Terre-Neuve", "HECU": "heure d’été de Cuba", "BOT": "heure de Bolivie", "WARST": "heure d’été de l’Ouest argentin", "AST": "heure normale de l’Atlantique", "BT": "heure du Bhoutan", "UYST": "heure d’été de l’Uruguay", "LHST": "heure normale de Lord Howe", "ART": "heure normale d’Argentine", "UYT": "heure normale de l’Uruguay", "PST": "heure normale du Pacifique nord-américain", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "GFT": "heure de la Guyane française", "AWST": "heure normale de l’Ouest de l’Australie", "SGT": "heure de Singapour", "PDT": "heure d’été du Pacifique", "JDT": "heure d’été du Japon", "GMT": "heure moyenne de Greenwich", "WAT": "heure normale d’Afrique de l’Ouest", "HNEG": "heure normale de l’Est du Groenland", "COT": "heure normale de Colombie", "∅∅∅": "heure d’été de l’Acre", "HEEG": "heure d’été de l’Est du Groenland", "NZDT": "heure d’été de la Nouvelle-Zélande", "MYT": "heure de la Malaisie", "WEZ": "heure normale d’Europe de l’Ouest", "ARST": "heure d’été de l’Argentine", "EST": "heure normale de l’Est nord-américain", "SAST": "heure normale d’Afrique méridionale", "VET": "heure du Venezuela", "HKST": "heure d’été de Hong Kong", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "AKDT": "heure d’été de l’Alaska", "CHAST": "heure normale des îles Chatham", "IST": "heure de l’Inde", "WAST": "heure d’été d’Afrique de l’Ouest", "COST": "heure d’été de Colombie", "HAST": "heure normale d’Hawaii - Aléoutiennes", "MEZ": "heure normale d’Europe centrale", "MESZ": "heure d’été d’Europe centrale", "CLST": "heure d’été du Chili", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "GYT": "heure du Guyana", "HNT": "heure normale de Terre-Neuve", "WIB": "heure de l’Ouest indonésien", "AWDT": "heure d’été de l’Ouest de l’Australie", "TMST": "heure d’été du Turkménistan", "MDT": "heure d’été de Macao", "EDT": "heure d’été de l’Est", "ChST": "heure des Chamorro", "EAT": "heure normale d’Afrique de l’Est", "HEOG": "heure d’été de l’Ouest du Groenland", "ADT": "heure d’été de l’Atlantique", "AEST": "heure normale de l’Est de l’Australie", "AEDT": "heure d’été de l’Est de l’Australie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_MR) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_MR' +func (fr *fr_MR) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_MR' +func (fr *fr_MR) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_MR' +func (fr *fr_MR) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MR' +func (fr *fr_MR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MR' +func (fr *fr_MR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_MR' +func (fr *fr_MR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_MR) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_MR) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_MR) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_MR) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_MR) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_MR) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_MR) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_MR) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_MR) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_MR) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_MR) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_MR) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_MR) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_MR) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_MR' and handles both Whole and Real numbers based on 'v' +func (fr *fr_MR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_MR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_MR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MR' +func (fr *fr_MR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MR' +// in accounting notation. +func (fr *fr_MR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_MR' +func (fr *fr_MR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_MR' +func (fr *fr_MR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_MR' +func (fr *fr_MR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_MR' +func (fr *fr_MR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_MR' +func (fr *fr_MR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_MR' +func (fr *fr_MR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_MR' +func (fr *fr_MR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_MR' +func (fr *fr_MR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_MR/fr_MR_test.go b/vendor/github.com/go-playground/locales/fr_MR/fr_MR_test.go new file mode 100644 index 0000000000..aaf8a9c26d --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MR/fr_MR_test.go @@ -0,0 +1,1120 @@ +package fr_MR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_MR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_MU/fr_MU.go b/vendor/github.com/go-playground/locales/fr_MU/fr_MU.go new file mode 100644 index 0000000000..97c8354fdf --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MU/fr_MU.go @@ -0,0 +1,619 @@ +package fr_MU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_MU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_MU' locale +func New() locales.Translator { + return &fr_MU{ + locale: "fr_MU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "Rs", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"MDT": "heure d’été des Rocheuses", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "SRT": "heure du Suriname", "GYT": "heure du Guyana", "HEOG": "heure d’été de l’Ouest du Groenland", "HKST": "heure d’été de Hong Kong", "ACDT": "heure d’été du centre de l’Australie", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "CHAST": "heure normale des îles Chatham", "TMST": "heure d’été du Turkménistan", "COST": "heure d’été de Colombie", "BT": "heure du Bhoutan", "WIT": "heure de l’Est indonésien", "HAST": "heure normale d’Hawaii - Aléoutiennes", "NZST": "heure normale de la Nouvelle-Zélande", "MYT": "heure de la Malaisie", "WARST": "heure d’été de l’Ouest argentin", "HNT": "heure normale de Terre-Neuve", "CST": "heure normale du centre nord-américain", "SGT": "heure de Singapour", "WIB": "heure de l’Ouest indonésien", "BOT": "heure de Bolivie", "CAT": "heure normale d’Afrique centrale", "MESZ": "heure d’été d’Europe centrale", "OEZ": "heure normale d’Europe de l’Est", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HAT": "heure d’été de Terre-Neuve", "WITA": "heure du Centre indonésien", "OESZ": "heure d’été d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "TMT": "heure normale du Turkménistan", "SAST": "heure normale d’Afrique méridionale", "LHDT": "heure d’été de Lord Howe", "ECT": "heure de l’Équateur", "EDT": "heure d’été de l’Est", "AKDT": "heure d’été de l’Alaska", "ChST": "heure des Chamorro", "WAT": "heure normale d’Afrique de l’Ouest", "JDT": "heure d’été du Japon", "ARST": "heure d’été de l’Argentine", "AEDT": "heure d’été de l’Est de l’Australie", "HEPMX": "heure d’été du Pacifique mexicain", "EAT": "heure normale d’Afrique de l’Est", "HECU": "heure d’été de Cuba", "AWDT": "heure d’été de l’Ouest de l’Australie", "ACST": "heure normale du centre de l’Australie", "GFT": "heure de la Guyane française", "AEST": "heure normale de l’Est de l’Australie", "NZDT": "heure d’été de la Nouvelle-Zélande", "ADT": "heure d’été de l’Atlantique", "ART": "heure normale d’Argentine", "AWST": "heure normale de l’Ouest de l’Australie", "ACWST": "heure normale du centre-ouest de l’Australie", "VET": "heure du Venezuela", "AST": "heure normale de l’Atlantique", "WEZ": "heure normale d’Europe de l’Ouest", "WESZ": "heure d’été d’Europe de l’Ouest", "EST": "heure normale de l’Est nord-américain", "HNEG": "heure normale de l’Est du Groenland", "HNCU": "heure normale de Cuba", "WART": "heure normale de l’Ouest argentin", "ACWDT": "heure d’été du centre-ouest de l’Australie", "JST": "heure normale du Japon", "CLT": "heure normale du Chili", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "HNPMX": "heure normale du Pacifique mexicain", "CHADT": "heure d’été des îles Chatham", "PST": "heure normale du Pacifique nord-américain", "CLST": "heure d’été du Chili", "WAST": "heure d’été d’Afrique de l’Ouest", "HKT": "heure normale de Hong Kong", "UYT": "heure normale de l’Uruguay", "HNOG": "heure normale de l’Ouest du Groenland", "AKST": "heure normale de l’Alaska", "IST": "heure de l’Inde", "MST": "heure normale des Rocheuses", "CDT": "heure d’été du Centre", "PDT": "heure d’été du Pacifique", "∅∅∅": "heure d’été de l’Acre", "MEZ": "heure normale d’Europe centrale", "COT": "heure normale de Colombie", "LHST": "heure normale de Lord Howe", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "HEEG": "heure d’été de l’Est du Groenland", "UYST": "heure d’été de l’Uruguay"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_MU) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_MU' +func (fr *fr_MU) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_MU' +func (fr *fr_MU) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_MU' +func (fr *fr_MU) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MU' +func (fr *fr_MU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_MU' +func (fr *fr_MU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_MU' +func (fr *fr_MU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_MU) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_MU) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_MU) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_MU) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_MU) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_MU) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_MU) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_MU) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_MU) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_MU) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_MU) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_MU) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_MU) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_MU) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_MU' and handles both Whole and Real numbers based on 'v' +func (fr *fr_MU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_MU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_MU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MU' +func (fr *fr_MU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_MU' +// in accounting notation. +func (fr *fr_MU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_MU' +func (fr *fr_MU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_MU' +func (fr *fr_MU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_MU' +func (fr *fr_MU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_MU' +func (fr *fr_MU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_MU' +func (fr *fr_MU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_MU' +func (fr *fr_MU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_MU' +func (fr *fr_MU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_MU' +func (fr *fr_MU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_MU/fr_MU_test.go b/vendor/github.com/go-playground/locales/fr_MU/fr_MU_test.go new file mode 100644 index 0000000000..dbcb95349b --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_MU/fr_MU_test.go @@ -0,0 +1,1120 @@ +package fr_MU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_MU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_NC/fr_NC.go b/vendor/github.com/go-playground/locales/fr_NC/fr_NC.go new file mode 100644 index 0000000000..e1a6ccbd11 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_NC/fr_NC.go @@ -0,0 +1,619 @@ +package fr_NC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_NC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_NC' locale +func New() locales.Translator { + return &fr_NC{ + locale: "fr_NC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"WIB": "heure de l’Ouest indonésien", "WITA": "heure du Centre indonésien", "HNT": "heure normale de Terre-Neuve", "AKST": "heure normale de l’Alaska", "HNPMX": "heure normale du Pacifique mexicain", "PDT": "heure d’été du Pacifique", "CLST": "heure d’été du Chili", "HEOG": "heure d’été de l’Ouest du Groenland", "HKST": "heure d’été de Hong Kong", "WIT": "heure de l’Est indonésien", "CHADT": "heure d’été des îles Chatham", "IST": "heure de l’Inde", "GYT": "heure du Guyana", "MESZ": "heure d’été d’Europe centrale", "WEZ": "heure normale d’Europe de l’Ouest", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HEEG": "heure d’été de l’Est du Groenland", "AKDT": "heure d’été de l’Alaska", "VET": "heure du Venezuela", "GMT": "heure moyenne de Greenwich", "AST": "heure normale de l’Atlantique", "WAT": "heure normale d’Afrique de l’Ouest", "HAT": "heure d’été de Terre-Neuve", "UYT": "heure normale de l’Uruguay", "SAST": "heure normale d’Afrique méridionale", "AWST": "heure normale de l’Ouest de l’Australie", "ACWST": "heure normale du centre-ouest de l’Australie", "TMST": "heure d’été du Turkménistan", "HKT": "heure normale de Hong Kong", "CLT": "heure normale du Chili", "OESZ": "heure d’été d’Europe de l’Est", "∅∅∅": "heure d’été de Brasilia", "SGT": "heure de Singapour", "PST": "heure normale du Pacifique nord-américain", "WESZ": "heure d’été d’Europe de l’Ouest", "HEPMX": "heure d’été du Pacifique mexicain", "HECU": "heure d’été de Cuba", "HNOG": "heure normale de l’Ouest du Groenland", "ARST": "heure d’été de l’Argentine", "ACDT": "heure d’été du centre de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "UYST": "heure d’été de l’Uruguay", "CHAST": "heure normale des îles Chatham", "ACWDT": "heure d’été du centre-ouest de l’Australie", "OEZ": "heure normale d’Europe de l’Est", "HNEG": "heure normale de l’Est du Groenland", "NZST": "heure normale de la Nouvelle-Zélande", "MEZ": "heure normale d’Europe centrale", "ADT": "heure d’été de l’Atlantique", "COT": "heure normale de Colombie", "WAST": "heure d’été d’Afrique de l’Ouest", "EST": "heure normale de l’Est nord-américain", "AEST": "heure normale de l’Est de l’Australie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HNCU": "heure normale de Cuba", "ECT": "heure de l’Équateur", "JST": "heure normale du Japon", "ART": "heure normale d’Argentine", "LHST": "heure normale de Lord Howe", "LHDT": "heure d’été de Lord Howe", "WARST": "heure d’été de l’Ouest argentin", "MDT": "heure d’été de Macao", "EDT": "heure d’été de l’Est", "BT": "heure du Bhoutan", "ACST": "heure normale du centre de l’Australie", "AEDT": "heure d’été de l’Est de l’Australie", "ChST": "heure des Chamorro", "CST": "heure normale du centre nord-américain", "AWDT": "heure d’été de l’Ouest de l’Australie", "NZDT": "heure d’été de la Nouvelle-Zélande", "MYT": "heure de la Malaisie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "CAT": "heure normale d’Afrique centrale", "JDT": "heure d’été du Japon", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "GFT": "heure de la Guyane française", "EAT": "heure normale d’Afrique de l’Est", "CDT": "heure d’été du Centre", "BOT": "heure de Bolivie", "WART": "heure normale de l’Ouest argentin", "SRT": "heure du Suriname", "HAST": "heure normale d’Hawaii - Aléoutiennes", "TMT": "heure normale du Turkménistan", "MST": "heure normale de Macao", "COST": "heure d’été de Colombie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_NC) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_NC' +func (fr *fr_NC) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_NC' +func (fr *fr_NC) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_NC' +func (fr *fr_NC) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_NC' +func (fr *fr_NC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_NC' +func (fr *fr_NC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_NC' +func (fr *fr_NC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_NC) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_NC) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_NC) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_NC) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_NC) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_NC) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_NC) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_NC) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_NC) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_NC) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_NC) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_NC) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_NC) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_NC) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_NC' and handles both Whole and Real numbers based on 'v' +func (fr *fr_NC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_NC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_NC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_NC' +func (fr *fr_NC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_NC' +// in accounting notation. +func (fr *fr_NC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_NC' +func (fr *fr_NC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_NC' +func (fr *fr_NC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_NC' +func (fr *fr_NC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_NC' +func (fr *fr_NC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_NC' +func (fr *fr_NC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_NC' +func (fr *fr_NC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_NC' +func (fr *fr_NC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_NC' +func (fr *fr_NC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_NC/fr_NC_test.go b/vendor/github.com/go-playground/locales/fr_NC/fr_NC_test.go new file mode 100644 index 0000000000..64fa4a3f9b --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_NC/fr_NC_test.go @@ -0,0 +1,1120 @@ +package fr_NC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_NC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_NE/fr_NE.go b/vendor/github.com/go-playground/locales/fr_NE/fr_NE.go new file mode 100644 index 0000000000..956c0e975e --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_NE/fr_NE.go @@ -0,0 +1,619 @@ +package fr_NE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_NE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_NE' locale +func New() locales.Translator { + return &fr_NE{ + locale: "fr_NE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"SAST": "heure normale d’Afrique méridionale", "HEPMX": "heure d’été du Pacifique mexicain", "CLT": "heure normale du Chili", "MYT": "heure de la Malaisie", "HNEG": "heure normale de l’Est du Groenland", "HNCU": "heure normale de Cuba", "CHADT": "heure d’été des îles Chatham", "ECT": "heure de l’Équateur", "JDT": "heure d’été du Japon", "ART": "heure normale d’Argentine", "ACST": "heure normale du centre de l’Australie", "AKST": "heure normale de l’Alaska", "AKDT": "heure d’été de l’Alaska", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "ADT": "heure d’été de l’Atlantique", "HKT": "heure normale de Hong Kong", "HEEG": "heure d’été de l’Est du Groenland", "WARST": "heure d’été de l’Ouest argentin", "HNT": "heure normale de Terre-Neuve", "HAT": "heure d’été de Terre-Neuve", "ARST": "heure d’été de l’Argentine", "COST": "heure d’été de Colombie", "HNPMX": "heure normale du Pacifique mexicain", "CST": "heure normale du centre nord-américain", "PST": "heure normale du Pacifique nord-américain", "CLST": "heure d’été du Chili", "HNOG": "heure normale de l’Ouest du Groenland", "WESZ": "heure d’été d’Europe de l’Ouest", "SRT": "heure du Suriname", "BOT": "heure de Bolivie", "WEZ": "heure normale d’Europe de l’Ouest", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "AWDT": "heure d’été de l’Ouest de l’Australie", "VET": "heure du Venezuela", "HKST": "heure d’été de Hong Kong", "LHDT": "heure d’été de Lord Howe", "EAT": "heure normale d’Afrique de l’Est", "WIT": "heure de l’Est indonésien", "IST": "heure de l’Inde", "NZST": "heure normale de la Nouvelle-Zélande", "GMT": "heure moyenne de Greenwich", "COT": "heure normale de Colombie", "∅∅∅": "heure d’été de l’Acre", "SGT": "heure de Singapour", "ACWST": "heure normale du centre-ouest de l’Australie", "ACWDT": "heure d’été du centre-ouest de l’Australie", "MESZ": "heure d’été d’Europe centrale", "HEOG": "heure d’été de l’Ouest du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "UYST": "heure d’été de l’Uruguay", "MEZ": "heure normale d’Europe centrale", "AEST": "heure normale de l’Est de l’Australie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "AST": "heure normale de l’Atlantique", "HAST": "heure normale d’Hawaii - Aléoutiennes", "TMT": "heure normale du Turkménistan", "CAT": "heure normale d’Afrique centrale", "EST": "heure normale de l’Est nord-américain", "ChST": "heure des Chamorro", "CHAST": "heure normale des îles Chatham", "GFT": "heure de la Guyane française", "GYT": "heure du Guyana", "WIB": "heure de l’Ouest indonésien", "CDT": "heure d’été du Centre", "JST": "heure normale du Japon", "OESZ": "heure d’été d’Europe de l’Est", "WART": "heure normale de l’Ouest argentin", "EDT": "heure d’été de l’Est", "WITA": "heure du Centre indonésien", "UYT": "heure normale de l’Uruguay", "AWST": "heure normale de l’Ouest de l’Australie", "PDT": "heure d’été du Pacifique", "WAST": "heure d’été d’Afrique de l’Ouest", "ACDT": "heure d’été du centre de l’Australie", "BT": "heure du Bhoutan", "MDT": "heure d’été de Macao", "WAT": "heure normale d’Afrique de l’Ouest", "LHST": "heure normale de Lord Howe", "HECU": "heure d’été de Cuba", "NZDT": "heure d’été de la Nouvelle-Zélande", "OEZ": "heure normale d’Europe de l’Est", "TMST": "heure d’été du Turkménistan", "MST": "heure normale de Macao"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_NE) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_NE' +func (fr *fr_NE) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_NE' +func (fr *fr_NE) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_NE' +func (fr *fr_NE) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_NE' +func (fr *fr_NE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_NE' +func (fr *fr_NE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_NE' +func (fr *fr_NE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_NE) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_NE) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_NE) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_NE) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_NE) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_NE) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_NE) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_NE) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_NE) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_NE) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_NE) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_NE) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_NE) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_NE) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_NE' and handles both Whole and Real numbers based on 'v' +func (fr *fr_NE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_NE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_NE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_NE' +func (fr *fr_NE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_NE' +// in accounting notation. +func (fr *fr_NE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_NE' +func (fr *fr_NE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_NE' +func (fr *fr_NE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_NE' +func (fr *fr_NE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_NE' +func (fr *fr_NE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_NE' +func (fr *fr_NE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_NE' +func (fr *fr_NE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_NE' +func (fr *fr_NE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_NE' +func (fr *fr_NE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_NE/fr_NE_test.go b/vendor/github.com/go-playground/locales/fr_NE/fr_NE_test.go new file mode 100644 index 0000000000..88926a8370 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_NE/fr_NE_test.go @@ -0,0 +1,1120 @@ +package fr_NE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_NE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_PF/fr_PF.go b/vendor/github.com/go-playground/locales/fr_PF/fr_PF.go new file mode 100644 index 0000000000..b3b51c0071 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_PF/fr_PF.go @@ -0,0 +1,619 @@ +package fr_PF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_PF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_PF' locale +func New() locales.Translator { + return &fr_PF{ + locale: "fr_PF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"AST": "heure normale de l’Atlantique", "COT": "heure normale de Colombie", "AKDT": "heure d’été de l’Alaska", "HEPMX": "heure d’été du Pacifique mexicain", "ART": "heure normale d’Argentine", "AKST": "heure normale de l’Alaska", "EST": "heure normale de l’Est nord-américain", "EAT": "heure normale d’Afrique de l’Est", "SGT": "heure de Singapour", "BOT": "heure de Bolivie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "JDT": "heure d’été du Japon", "WARST": "heure d’été de l’Ouest argentin", "HEOG": "heure d’été de l’Ouest du Groenland", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "ChST": "heure des Chamorro", "SAST": "heure normale d’Afrique méridionale", "HNCU": "heure normale de Cuba", "ACWDT": "heure d’été du centre-ouest de l’Australie", "ADT": "heure d’été de l’Atlantique", "TMT": "heure normale du Turkménistan", "MST": "heure normale de Macao", "HNEG": "heure normale de l’Est du Groenland", "AWDT": "heure d’été de l’Ouest de l’Australie", "CHAST": "heure normale des îles Chatham", "NZDT": "heure d’été de la Nouvelle-Zélande", "MESZ": "heure d’été d’Europe centrale", "ACST": "heure normale du centre de l’Australie", "COST": "heure d’été de Colombie", "UYT": "heure normale de l’Uruguay", "CDT": "heure d’été du Centre", "PST": "heure normale du Pacifique nord-américain", "NZST": "heure normale de la Nouvelle-Zélande", "MEZ": "heure normale d’Europe centrale", "MYT": "heure de la Malaisie", "TMST": "heure d’été du Turkménistan", "EDT": "heure d’été de l’Est", "CHADT": "heure d’été des îles Chatham", "JST": "heure normale du Japon", "MDT": "heure d’été de Macao", "SRT": "heure du Suriname", "CST": "heure normale du centre nord-américain", "WIT": "heure de l’Est indonésien", "GMT": "heure moyenne de Greenwich", "BT": "heure du Bhoutan", "HAT": "heure d’été de Terre-Neuve", "HNPMX": "heure normale du Pacifique mexicain", "VET": "heure du Venezuela", "CLT": "heure normale du Chili", "WAT": "heure normale d’Afrique de l’Ouest", "HKST": "heure d’été de Hong Kong", "WITA": "heure du Centre indonésien", "AEDT": "heure d’été de l’Est de l’Australie", "LHDT": "heure d’été de Lord Howe", "PDT": "heure d’été du Pacifique", "HAST": "heure normale d’Hawaii - Aléoutiennes", "CAT": "heure normale d’Afrique centrale", "ARST": "heure d’été de l’Argentine", "HEEG": "heure d’été de l’Est du Groenland", "GFT": "heure de la Guyane française", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "GYT": "heure du Guyana", "CLST": "heure d’été du Chili", "OESZ": "heure d’été d’Europe de l’Est", "HKT": "heure normale de Hong Kong", "UYST": "heure d’été de l’Uruguay", "HECU": "heure d’été de Cuba", "WIB": "heure de l’Ouest indonésien", "AWST": "heure normale de l’Ouest de l’Australie", "ACWST": "heure normale du centre-ouest de l’Australie", "WEZ": "heure normale d’Europe de l’Ouest", "WESZ": "heure d’été d’Europe de l’Ouest", "ACDT": "heure d’été du centre de l’Australie", "∅∅∅": "heure d’été des Açores", "WART": "heure normale de l’Ouest argentin", "OEZ": "heure normale d’Europe de l’Est", "WAST": "heure d’été d’Afrique de l’Ouest", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HNT": "heure normale de Terre-Neuve", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "LHST": "heure normale de Lord Howe", "ECT": "heure de l’Équateur", "IST": "heure de l’Inde", "HNOG": "heure normale de l’Ouest du Groenland", "AEST": "heure normale de l’Est de l’Australie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_PF) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_PF' +func (fr *fr_PF) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_PF' +func (fr *fr_PF) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_PF' +func (fr *fr_PF) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_PF' +func (fr *fr_PF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_PF' +func (fr *fr_PF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_PF' +func (fr *fr_PF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_PF) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_PF) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_PF) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_PF) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_PF) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_PF) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_PF) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_PF) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_PF) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_PF) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_PF) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_PF) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_PF) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_PF) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_PF' and handles both Whole and Real numbers based on 'v' +func (fr *fr_PF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_PF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_PF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_PF' +func (fr *fr_PF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_PF' +// in accounting notation. +func (fr *fr_PF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_PF' +func (fr *fr_PF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_PF' +func (fr *fr_PF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_PF' +func (fr *fr_PF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_PF' +func (fr *fr_PF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_PF' +func (fr *fr_PF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_PF' +func (fr *fr_PF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_PF' +func (fr *fr_PF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_PF' +func (fr *fr_PF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_PF/fr_PF_test.go b/vendor/github.com/go-playground/locales/fr_PF/fr_PF_test.go new file mode 100644 index 0000000000..d6586f3c97 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_PF/fr_PF_test.go @@ -0,0 +1,1120 @@ +package fr_PF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_PF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_PM/fr_PM.go b/vendor/github.com/go-playground/locales/fr_PM/fr_PM.go new file mode 100644 index 0000000000..41531e0a6c --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_PM/fr_PM.go @@ -0,0 +1,619 @@ +package fr_PM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_PM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_PM' locale +func New() locales.Translator { + return &fr_PM{ + locale: "fr_PM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"HADT": "heure d’été d’Hawaii - Aléoutiennes", "VET": "heure du Venezuela", "ART": "heure normale d’Argentine", "WITA": "heure du Centre indonésien", "HECU": "heure d’été de Cuba", "CDT": "heure d’été du Centre", "CLST": "heure d’été du Chili", "AEDT": "heure d’été de l’Est de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "NZDT": "heure d’été de la Nouvelle-Zélande", "MESZ": "heure d’été d’Europe centrale", "EDT": "heure d’été de l’Est", "UYST": "heure d’été de l’Uruguay", "TMST": "heure d’été du Turkménistan", "MDT": "heure d’été de Macao", "HEEG": "heure d’été de l’Est du Groenland", "HNCU": "heure normale de Cuba", "WIB": "heure de l’Ouest indonésien", "JST": "heure normale du Japon", "WART": "heure normale de l’Ouest argentin", "AST": "heure normale de l’Atlantique", "ChST": "heure des Chamorro", "AKDT": "heure d’été de l’Alaska", "PDT": "heure d’été du Pacifique", "WARST": "heure d’été de l’Ouest argentin", "ARST": "heure d’été de l’Argentine", "HNT": "heure normale de Terre-Neuve", "HNEG": "heure normale de l’Est du Groenland", "WIT": "heure de l’Est indonésien", "CHAST": "heure normale des îles Chatham", "WEZ": "heure normale d’Europe de l’Ouest", "UYT": "heure normale de l’Uruguay", "SAST": "heure normale d’Afrique méridionale", "SGT": "heure de Singapour", "HAST": "heure normale d’Hawaii - Aléoutiennes", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HKST": "heure d’été de Hong Kong", "WAST": "heure d’été d’Afrique de l’Ouest", "HNPMX": "heure normale du Pacifique mexicain", "SRT": "heure du Suriname", "CHADT": "heure d’été des îles Chatham", "CAT": "heure normale d’Afrique centrale", "ADT": "heure d’été de l’Atlantique", "HKT": "heure normale de Hong Kong", "COST": "heure d’été de Colombie", "ACST": "heure normale du centre de l’Australie", "ECT": "heure de l’Équateur", "ACWDT": "heure d’été du centre-ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "WESZ": "heure d’été d’Europe de l’Ouest", "EST": "heure normale de l’Est nord-américain", "GYT": "heure du Guyana", "BOT": "heure de Bolivie", "JDT": "heure d’été du Japon", "HEOG": "heure d’été de l’Ouest du Groenland", "TMT": "heure normale du Turkménistan", "LHDT": "heure d’été de Lord Howe", "CST": "heure normale du centre nord-américain", "MYT": "heure de la Malaisie", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "AWDT": "heure d’été de l’Ouest de l’Australie", "IST": "heure de l’Inde", "OESZ": "heure d’été d’Europe de l’Est", "HNOG": "heure normale de l’Ouest du Groenland", "WAT": "heure normale d’Afrique de l’Ouest", "COT": "heure normale de Colombie", "HAT": "heure d’été de Terre-Neuve", "GFT": "heure de la Guyane française", "HEPMX": "heure d’été du Pacifique mexicain", "∅∅∅": "heure d’été des Açores", "AWST": "heure normale de l’Ouest de l’Australie", "GMT": "heure moyenne de Greenwich", "MST": "heure normale de Macao", "EAT": "heure normale d’Afrique de l’Est", "ACWST": "heure normale du centre-ouest de l’Australie", "OEZ": "heure normale d’Europe de l’Est", "ACDT": "heure d’été du centre de l’Australie", "BT": "heure du Bhoutan", "AEST": "heure normale de l’Est de l’Australie", "AKST": "heure normale de l’Alaska", "LHST": "heure normale de Lord Howe", "PST": "heure normale du Pacifique nord-américain", "NZST": "heure normale de la Nouvelle-Zélande", "CLT": "heure normale du Chili", "HENOMX": "heure d’été du Nord-Ouest du Mexique"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_PM) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_PM' +func (fr *fr_PM) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_PM' +func (fr *fr_PM) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_PM' +func (fr *fr_PM) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_PM' +func (fr *fr_PM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_PM' +func (fr *fr_PM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_PM' +func (fr *fr_PM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_PM) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_PM) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_PM) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_PM) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_PM) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_PM) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_PM) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_PM) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_PM) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_PM) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_PM) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_PM) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_PM) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_PM) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_PM' and handles both Whole and Real numbers based on 'v' +func (fr *fr_PM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_PM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_PM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_PM' +func (fr *fr_PM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_PM' +// in accounting notation. +func (fr *fr_PM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_PM' +func (fr *fr_PM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_PM' +func (fr *fr_PM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_PM' +func (fr *fr_PM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_PM' +func (fr *fr_PM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_PM' +func (fr *fr_PM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_PM' +func (fr *fr_PM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_PM' +func (fr *fr_PM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_PM' +func (fr *fr_PM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_PM/fr_PM_test.go b/vendor/github.com/go-playground/locales/fr_PM/fr_PM_test.go new file mode 100644 index 0000000000..e648a10247 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_PM/fr_PM_test.go @@ -0,0 +1,1120 @@ +package fr_PM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_PM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_RE/fr_RE.go b/vendor/github.com/go-playground/locales/fr_RE/fr_RE.go new file mode 100644 index 0000000000..fd380491d7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_RE/fr_RE.go @@ -0,0 +1,619 @@ +package fr_RE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_RE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_RE' locale +func New() locales.Translator { + return &fr_RE{ + locale: "fr_RE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"", ""}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"WIB": "heure de l’Ouest indonésien", "WIT": "heure de l’Est indonésien", "BOT": "heure de Bolivie", "CHADT": "heure d’été des îles Chatham", "HAST": "heure normale d’Hawaii - Aléoutiennes", "HEEG": "heure d’été de l’Est du Groenland", "AEST": "heure normale de l’Est de l’Australie", "MDT": "heure d’été des Rocheuses", "AST": "heure normale de l’Atlantique", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "JDT": "heure d’été du Japon", "ACDT": "heure d’été du centre de l’Australie", "LHST": "heure normale de Lord Howe", "CDT": "heure d’été du Centre", "AWDT": "heure d’été de l’Ouest de l’Australie", "VET": "heure du Venezuela", "CLST": "heure d’été du Chili", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "BT": "heure du Bhoutan", "EAT": "heure normale d’Afrique de l’Est", "CHAST": "heure normale des îles Chatham", "CST": "heure normale du centre nord-américain", "PST": "heure normale du Pacifique nord-américain", "NZST": "heure normale de la Nouvelle-Zélande", "CLT": "heure normale du Chili", "HKT": "heure normale de Hong Kong", "AKDT": "heure d’été de l’Alaska", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "SRT": "heure du Suriname", "COT": "heure normale de Colombie", "TMT": "heure normale du Turkménistan", "ARST": "heure d’été de l’Argentine", "WAT": "heure normale d’Afrique de l’Ouest", "HAT": "heure d’été de Terre-Neuve", "IST": "heure de l’Inde", "HEOG": "heure d’été de l’Ouest du Groenland", "HEPMX": "heure d’été du Pacifique mexicain", "HECU": "heure d’été de Cuba", "PDT": "heure d’été du Pacifique", "ACWST": "heure normale du centre-ouest de l’Australie", "WITA": "heure du Centre indonésien", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "UYT": "heure normale de l’Uruguay", "ART": "heure normale d’Argentine", "HKST": "heure d’été de Hong Kong", "ChST": "heure des Chamorro", "WESZ": "heure d’été d’Europe de l’Ouest", "HNOG": "heure normale de l’Ouest du Groenland", "WEZ": "heure normale d’Europe de l’Ouest", "ACST": "heure normale du centre de l’Australie", "SGT": "heure de Singapour", "EST": "heure normale de l’Est nord-américain", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "JST": "heure normale du Japon", "TMST": "heure d’été du Turkménistan", "WAST": "heure d’été d’Afrique de l’Ouest", "OEZ": "heure normale d’Europe de l’Est", "COST": "heure d’été de Colombie", "AEDT": "heure d’été de l’Est de l’Australie", "ECT": "heure de l’Équateur", "MEZ": "heure normale d’Europe centrale", "CAT": "heure normale d’Afrique centrale", "AKST": "heure normale de l’Alaska", "LHDT": "heure d’été de Lord Howe", "ACWDT": "heure d’été du centre-ouest de l’Australie", "GYT": "heure du Guyana", "MYT": "heure de la Malaisie", "WART": "heure normale de l’Ouest argentin", "HNT": "heure normale de Terre-Neuve", "MST": "heure normale des Rocheuses", "UYST": "heure d’été de l’Uruguay", "AWST": "heure normale de l’Ouest de l’Australie", "MESZ": "heure d’été d’Europe centrale", "GMT": "heure moyenne de Greenwich", "GFT": "heure de la Guyane française", "HNPMX": "heure normale du Pacifique mexicain", "SAST": "heure normale d’Afrique méridionale", "∅∅∅": "heure d’été de l’Acre", "WARST": "heure d’été de l’Ouest argentin", "ADT": "heure d’été de l’Atlantique", "OESZ": "heure d’été d’Europe de l’Est", "EDT": "heure d’été de l’Est", "HNEG": "heure normale de l’Est du Groenland", "HNCU": "heure normale de Cuba", "NZDT": "heure d’été de la Nouvelle-Zélande"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_RE) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_RE' +func (fr *fr_RE) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_RE' +func (fr *fr_RE) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_RE' +func (fr *fr_RE) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_RE' +func (fr *fr_RE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_RE' +func (fr *fr_RE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_RE' +func (fr *fr_RE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_RE) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_RE) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_RE) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_RE) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_RE) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_RE) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_RE) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_RE) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_RE) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_RE) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_RE) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_RE) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_RE) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_RE) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_RE' and handles both Whole and Real numbers based on 'v' +func (fr *fr_RE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_RE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_RE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_RE' +func (fr *fr_RE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_RE' +// in accounting notation. +func (fr *fr_RE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_RE' +func (fr *fr_RE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_RE' +func (fr *fr_RE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_RE' +func (fr *fr_RE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_RE' +func (fr *fr_RE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_RE' +func (fr *fr_RE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_RE' +func (fr *fr_RE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_RE' +func (fr *fr_RE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_RE' +func (fr *fr_RE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_RE/fr_RE_test.go b/vendor/github.com/go-playground/locales/fr_RE/fr_RE_test.go new file mode 100644 index 0000000000..9fdccdcafd --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_RE/fr_RE_test.go @@ -0,0 +1,1120 @@ +package fr_RE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_RE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_RW/fr_RW.go b/vendor/github.com/go-playground/locales/fr_RW/fr_RW.go new file mode 100644 index 0000000000..55d55bad7e --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_RW/fr_RW.go @@ -0,0 +1,619 @@ +package fr_RW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_RW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_RW' locale +func New() locales.Translator { + return &fr_RW{ + locale: "fr_RW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"TMST": "heure d’été du Turkménistan", "ACST": "heure normale du centre de l’Australie", "MESZ": "heure d’été d’Europe centrale", "OESZ": "heure d’été d’Europe de l’Est", "HECU": "heure d’été de Cuba", "ECT": "heure de l’Équateur", "NZDT": "heure d’été de la Nouvelle-Zélande", "VET": "heure du Venezuela", "CLT": "heure normale du Chili", "COT": "heure normale de Colombie", "UYST": "heure d’été de l’Uruguay", "GYT": "heure du Guyana", "CLST": "heure d’été du Chili", "NZST": "heure normale de la Nouvelle-Zélande", "HNOG": "heure normale de l’Ouest du Groenland", "AST": "heure normale de l’Atlantique", "WAST": "heure d’été d’Afrique de l’Ouest", "WIT": "heure de l’Est indonésien", "CST": "heure normale du centre nord-américain", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HNT": "heure normale de Terre-Neuve", "SGT": "heure de Singapour", "EAT": "heure normale d’Afrique de l’Est", "CHAST": "heure normale des îles Chatham", "PST": "heure normale du Pacifique nord-américain", "CAT": "heure normale d’Afrique centrale", "WAT": "heure normale d’Afrique de l’Ouest", "BT": "heure du Bhoutan", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "UYT": "heure normale de l’Uruguay", "MEZ": "heure normale d’Europe centrale", "ARST": "heure d’été de l’Argentine", "HKT": "heure normale de Hong Kong", "MDT": "heure d’été des Rocheuses", "AKDT": "heure d’été de l’Alaska", "HAST": "heure normale d’Hawaii - Aléoutiennes", "HKST": "heure d’été de Hong Kong", "HEEG": "heure d’été de l’Est du Groenland", "LHST": "heure normale de Lord Howe", "ADT": "heure d’été de l’Atlantique", "TMT": "heure normale du Turkménistan", "HNPMX": "heure normale du Pacifique mexicain", "SRT": "heure du Suriname", "HNCU": "heure normale de Cuba", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "WART": "heure normale de l’Ouest argentin", "ACDT": "heure d’été du centre de l’Australie", "ChST": "heure des Chamorro", "PDT": "heure d’été du Pacifique", "GFT": "heure de la Guyane française", "WITA": "heure du Centre indonésien", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "BOT": "heure de Bolivie", "IST": "heure de l’Inde", "JST": "heure normale du Japon", "HEOG": "heure d’été de l’Ouest du Groenland", "COST": "heure d’été de Colombie", "AKST": "heure normale de l’Alaska", "WIB": "heure de l’Ouest indonésien", "HEPMX": "heure d’été du Pacifique mexicain", "AWST": "heure normale de l’Ouest de l’Australie", "AWDT": "heure d’été de l’Ouest de l’Australie", "ACWST": "heure normale du centre-ouest de l’Australie", "MYT": "heure de la Malaisie", "EST": "heure normale de l’Est nord-américain", "∅∅∅": "heure d’été de l’Acre", "MST": "heure normale des Rocheuses", "WARST": "heure d’été de l’Ouest argentin", "LHDT": "heure d’été de Lord Howe", "JDT": "heure d’été du Japon", "WESZ": "heure d’été d’Europe de l’Ouest", "GMT": "heure moyenne de Greenwich", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HAT": "heure d’été de Terre-Neuve", "AEST": "heure normale de l’Est de l’Australie", "ART": "heure normale d’Argentine", "EDT": "heure d’été de l’Est", "HNEG": "heure normale de l’Est du Groenland", "ACWDT": "heure d’été du centre-ouest de l’Australie", "SAST": "heure normale d’Afrique méridionale", "WEZ": "heure normale d’Europe de l’Ouest", "OEZ": "heure normale d’Europe de l’Est", "AEDT": "heure d’été de l’Est de l’Australie", "CDT": "heure d’été du Centre", "CHADT": "heure d’été des îles Chatham"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_RW) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_RW' +func (fr *fr_RW) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_RW' +func (fr *fr_RW) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_RW' +func (fr *fr_RW) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_RW' +func (fr *fr_RW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_RW' +func (fr *fr_RW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_RW' +func (fr *fr_RW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_RW) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_RW) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_RW) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_RW) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_RW) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_RW) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_RW) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_RW) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_RW) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_RW) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_RW) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_RW) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_RW) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_RW) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_RW' and handles both Whole and Real numbers based on 'v' +func (fr *fr_RW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_RW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_RW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_RW' +func (fr *fr_RW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_RW' +// in accounting notation. +func (fr *fr_RW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_RW' +func (fr *fr_RW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_RW' +func (fr *fr_RW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_RW' +func (fr *fr_RW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_RW' +func (fr *fr_RW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_RW' +func (fr *fr_RW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_RW' +func (fr *fr_RW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_RW' +func (fr *fr_RW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_RW' +func (fr *fr_RW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_RW/fr_RW_test.go b/vendor/github.com/go-playground/locales/fr_RW/fr_RW_test.go new file mode 100644 index 0000000000..e50d9f6def --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_RW/fr_RW_test.go @@ -0,0 +1,1120 @@ +package fr_RW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_RW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_SC/fr_SC.go b/vendor/github.com/go-playground/locales/fr_SC/fr_SC.go new file mode 100644 index 0000000000..0d1fcb17c5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_SC/fr_SC.go @@ -0,0 +1,619 @@ +package fr_SC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_SC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_SC' locale +func New() locales.Translator { + return &fr_SC{ + locale: "fr_SC", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"MYT": "heure de la Malaisie", "TMST": "heure d’été du Turkménistan", "UYST": "heure d’été de l’Uruguay", "AWST": "heure normale de l’Ouest de l’Australie", "AWDT": "heure d’été de l’Ouest de l’Australie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "MEZ": "heure normale d’Europe centrale", "EST": "heure normale de l’Est nord-américain", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "WIB": "heure de l’Ouest indonésien", "CST": "heure normale du centre nord-américain", "WART": "heure normale de l’Ouest argentin", "CLT": "heure normale du Chili", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "GFT": "heure de la Guyane française", "HNPMX": "heure normale du Pacifique mexicain", "HNCU": "heure normale de Cuba", "ECT": "heure de l’Équateur", "HNOG": "heure normale de l’Ouest du Groenland", "ACST": "heure normale du centre de l’Australie", "AKST": "heure normale de l’Alaska", "EAT": "heure normale d’Afrique de l’Est", "ACWDT": "heure d’été du centre-ouest de l’Australie", "CLST": "heure d’été du Chili", "GYT": "heure du Guyana", "GMT": "heure moyenne de Greenwich", "WAT": "heure normale d’Afrique de l’Ouest", "HEPMX": "heure d’été du Pacifique mexicain", "EDT": "heure d’été de l’Est", "HNT": "heure normale de Terre-Neuve", "ART": "heure normale d’Argentine", "AKDT": "heure d’été de l’Alaska", "WIT": "heure de l’Est indonésien", "WEZ": "heure normale d’Europe de l’Ouest", "WARST": "heure d’été de l’Ouest argentin", "IST": "heure de l’Inde", "HKT": "heure normale de Hong Kong", "ACWST": "heure normale du centre-ouest de l’Australie", "CAT": "heure normale d’Afrique centrale", "VET": "heure du Venezuela", "OEZ": "heure normale d’Europe de l’Est", "ChST": "heure des Chamorro", "∅∅∅": "heure d’été de l’Amazonie", "JDT": "heure d’été du Japon", "CDT": "heure d’été du Centre", "CHAST": "heure normale des îles Chatham", "MESZ": "heure d’été d’Europe centrale", "HAT": "heure d’été de Terre-Neuve", "AEDT": "heure d’été de l’Est de l’Australie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "OESZ": "heure d’été d’Europe de l’Est", "TMT": "heure normale du Turkménistan", "ADT": "heure d’été de l’Atlantique", "MDT": "heure d’été de Macao", "WAST": "heure d’été d’Afrique de l’Ouest", "HNEG": "heure normale de l’Est du Groenland", "HEEG": "heure d’été de l’Est du Groenland", "BT": "heure du Bhoutan", "JST": "heure normale du Japon", "AST": "heure normale de l’Atlantique", "PDT": "heure d’été du Pacifique", "ARST": "heure d’été de l’Argentine", "HKST": "heure d’été de Hong Kong", "ACDT": "heure d’été du centre de l’Australie", "COT": "heure normale de Colombie", "AEST": "heure normale de l’Est de l’Australie", "HAST": "heure normale d’Hawaii - Aléoutiennes", "PST": "heure normale du Pacifique nord-américain", "SRT": "heure du Suriname", "LHST": "heure normale de Lord Howe", "LHDT": "heure d’été de Lord Howe", "HECU": "heure d’été de Cuba", "CHADT": "heure d’été des îles Chatham", "UYT": "heure normale de l’Uruguay", "HEOG": "heure d’été de l’Ouest du Groenland", "COST": "heure d’été de Colombie", "SGT": "heure de Singapour", "NZDT": "heure d’été de la Nouvelle-Zélande", "WESZ": "heure d’été d’Europe de l’Ouest", "MST": "heure normale de Macao", "WITA": "heure du Centre indonésien", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "SAST": "heure normale d’Afrique méridionale", "BOT": "heure de Bolivie", "NZST": "heure normale de la Nouvelle-Zélande"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_SC) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_SC' +func (fr *fr_SC) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_SC' +func (fr *fr_SC) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_SC' +func (fr *fr_SC) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_SC' +func (fr *fr_SC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_SC' +func (fr *fr_SC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_SC' +func (fr *fr_SC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_SC) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_SC) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_SC) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_SC) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_SC) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_SC) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_SC) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_SC) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_SC) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_SC) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_SC) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_SC) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_SC) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_SC) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_SC' and handles both Whole and Real numbers based on 'v' +func (fr *fr_SC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_SC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_SC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_SC' +func (fr *fr_SC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_SC' +// in accounting notation. +func (fr *fr_SC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_SC' +func (fr *fr_SC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_SC' +func (fr *fr_SC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_SC' +func (fr *fr_SC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_SC' +func (fr *fr_SC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_SC' +func (fr *fr_SC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_SC' +func (fr *fr_SC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_SC' +func (fr *fr_SC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_SC' +func (fr *fr_SC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_SC/fr_SC_test.go b/vendor/github.com/go-playground/locales/fr_SC/fr_SC_test.go new file mode 100644 index 0000000000..31d9d87c85 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_SC/fr_SC_test.go @@ -0,0 +1,1120 @@ +package fr_SC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_SC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_SN/fr_SN.go b/vendor/github.com/go-playground/locales/fr_SN/fr_SN.go new file mode 100644 index 0000000000..f11c39ebc9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_SN/fr_SN.go @@ -0,0 +1,619 @@ +package fr_SN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_SN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_SN' locale +func New() locales.Translator { + return &fr_SN{ + locale: "fr_SN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"", ""}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"BT": "heure du Bhoutan", "GFT": "heure de la Guyane française", "WITA": "heure du Centre indonésien", "AKDT": "heure d’été de l’Alaska", "AWDT": "heure d’été de l’Ouest de l’Australie", "JST": "heure normale du Japon", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ART": "heure normale d’Argentine", "ARST": "heure d’été de l’Argentine", "WAST": "heure d’été d’Afrique de l’Ouest", "HNPMX": "heure normale du Pacifique mexicain", "WIT": "heure de l’Est indonésien", "HNOG": "heure normale de l’Ouest du Groenland", "LHST": "heure normale de Lord Howe", "CLST": "heure d’été du Chili", "HNT": "heure normale de Terre-Neuve", "CLT": "heure normale du Chili", "ADT": "heure d’été de l’Atlantique", "MDT": "heure d’été de Macao", "COST": "heure d’été de Colombie", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "∅∅∅": "heure d’été de Brasilia", "ECT": "heure de l’Équateur", "MST": "heure normale de Macao", "ACDT": "heure d’été du centre de l’Australie", "SRT": "heure du Suriname", "GYT": "heure du Guyana", "WEZ": "heure normale d’Europe de l’Ouest", "COT": "heure normale de Colombie", "HAT": "heure d’été de Terre-Neuve", "AEST": "heure normale de l’Est de l’Australie", "EAT": "heure normale d’Afrique de l’Est", "AST": "heure normale de l’Atlantique", "HEOG": "heure d’été de l’Ouest du Groenland", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "AEDT": "heure d’été de l’Est de l’Australie", "ChST": "heure des Chamorro", "AWST": "heure normale de l’Ouest de l’Australie", "PST": "heure normale du Pacifique nord-américain", "TMST": "heure d’été du Turkménistan", "HEPMX": "heure d’été du Pacifique mexicain", "SGT": "heure de Singapour", "OESZ": "heure d’été d’Europe de l’Est", "ACWST": "heure normale du centre-ouest de l’Australie", "NZDT": "heure d’été de la Nouvelle-Zélande", "MYT": "heure de la Malaisie", "EST": "heure normale de l’Est nord-américain", "EDT": "heure d’été de l’Est", "AKST": "heure normale de l’Alaska", "WIB": "heure de l’Ouest indonésien", "CHADT": "heure d’été des îles Chatham", "LHDT": "heure d’été de Lord Howe", "UYT": "heure normale de l’Uruguay", "UYST": "heure d’été de l’Uruguay", "WESZ": "heure d’été d’Europe de l’Ouest", "WAT": "heure normale d’Afrique de l’Ouest", "SAST": "heure normale d’Afrique méridionale", "CAT": "heure normale d’Afrique centrale", "JDT": "heure d’été du Japon", "MEZ": "heure normale d’Europe centrale", "OEZ": "heure normale d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "CDT": "heure d’été du Centre", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "WART": "heure normale de l’Ouest argentin", "WARST": "heure d’été de l’Ouest argentin", "HKST": "heure d’été de Hong Kong", "ACST": "heure normale du centre de l’Australie", "CHAST": "heure normale des îles Chatham", "NZST": "heure normale de la Nouvelle-Zélande", "ACWDT": "heure d’été du centre-ouest de l’Australie", "MESZ": "heure d’été d’Europe centrale", "TMT": "heure normale du Turkménistan", "HKT": "heure normale de Hong Kong", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HECU": "heure d’été de Cuba", "PDT": "heure d’été du Pacifique", "BOT": "heure de Bolivie", "IST": "heure de l’Inde", "VET": "heure du Venezuela", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HNEG": "heure normale de l’Est du Groenland", "HEEG": "heure d’été de l’Est du Groenland", "HNCU": "heure normale de Cuba", "CST": "heure normale du centre nord-américain"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_SN) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_SN' +func (fr *fr_SN) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_SN' +func (fr *fr_SN) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_SN' +func (fr *fr_SN) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_SN' +func (fr *fr_SN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_SN' +func (fr *fr_SN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_SN' +func (fr *fr_SN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_SN) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_SN) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_SN) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_SN) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_SN) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_SN) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_SN) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_SN) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_SN) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_SN) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_SN) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_SN) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_SN) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_SN) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_SN' and handles both Whole and Real numbers based on 'v' +func (fr *fr_SN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_SN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_SN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_SN' +func (fr *fr_SN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_SN' +// in accounting notation. +func (fr *fr_SN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_SN' +func (fr *fr_SN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_SN' +func (fr *fr_SN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_SN' +func (fr *fr_SN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_SN' +func (fr *fr_SN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_SN' +func (fr *fr_SN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_SN' +func (fr *fr_SN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_SN' +func (fr *fr_SN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_SN' +func (fr *fr_SN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_SN/fr_SN_test.go b/vendor/github.com/go-playground/locales/fr_SN/fr_SN_test.go new file mode 100644 index 0000000000..db4ba948f1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_SN/fr_SN_test.go @@ -0,0 +1,1120 @@ +package fr_SN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_SN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_SY/fr_SY.go b/vendor/github.com/go-playground/locales/fr_SY/fr_SY.go new file mode 100644 index 0000000000..2399bf2360 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_SY/fr_SY.go @@ -0,0 +1,657 @@ +package fr_SY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_SY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_SY' locale +func New() locales.Translator { + return &fr_SY{ + locale: "fr_SY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "LS", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"SRT": "heure du Suriname", "HNCU": "heure normale de Cuba", "CHADT": "heure d’été des îles Chatham", "WEZ": "heure normale d’Europe de l’Ouest", "HKT": "heure normale de Hong Kong", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HNPMX": "heure normale du Pacifique mexicain", "ACWDT": "heure d’été du centre-ouest de l’Australie", "CAT": "heure normale d’Afrique centrale", "WART": "heure normale de l’Ouest argentin", "TMST": "heure d’été du Turkménistan", "BOT": "heure de Bolivie", "UYST": "heure d’été de l’Uruguay", "CDT": "heure d’été du Centre", "SGT": "heure de Singapour", "PST": "heure normale du Pacifique nord-américain", "MYT": "heure de la Malaisie", "HNOG": "heure normale de l’Ouest du Groenland", "AST": "heure normale de l’Atlantique", "HNEG": "heure normale de l’Est du Groenland", "SAST": "heure normale d’Afrique méridionale", "ECT": "heure de l’Équateur", "PDT": "heure d’été du Pacifique", "OESZ": "heure d’été d’Europe de l’Est", "ARST": "heure d’été de l’Argentine", "AWDT": "heure d’été de l’Ouest de l’Australie", "HAST": "heure normale d’Hawaii - Aléoutiennes", "COST": "heure d’été de Colombie", "HEEG": "heure d’été de l’Est du Groenland", "HEPMX": "heure d’été du Pacifique mexicain", "WAT": "heure normale d’Afrique de l’Ouest", "∅∅∅": "heure d’été de l’Amazonie", "WESZ": "heure d’été d’Europe de l’Ouest", "WARST": "heure d’été de l’Ouest argentin", "MDT": "heure d’été de Macao", "EAT": "heure normale d’Afrique de l’Est", "MEZ": "heure normale d’Europe centrale", "ACST": "heure normale du centre de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "AEDT": "heure d’été de l’Est de l’Australie", "BT": "heure du Bhoutan", "WIB": "heure de l’Ouest indonésien", "HECU": "heure d’été de Cuba", "UYT": "heure normale de l’Uruguay", "LHDT": "heure d’été de Lord Howe", "HEOG": "heure d’été de l’Ouest du Groenland", "ADT": "heure d’été de l’Atlantique", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HNT": "heure normale de Terre-Neuve", "CST": "heure normale du centre nord-américain", "JDT": "heure d’été du Japon", "MESZ": "heure d’été d’Europe centrale", "ChST": "heure des Chamorro", "GYT": "heure du Guyana", "LHST": "heure normale de Lord Howe", "AWST": "heure normale de l’Ouest de l’Australie", "JST": "heure normale du Japon", "CLT": "heure normale du Chili", "HKST": "heure d’été de Hong Kong", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "ACWST": "heure normale du centre-ouest de l’Australie", "NZDT": "heure d’été de la Nouvelle-Zélande", "GFT": "heure de la Guyane française", "WITA": "heure du Centre indonésien", "AKDT": "heure d’été de l’Alaska", "GMT": "heure moyenne de Greenwich", "OEZ": "heure normale d’Europe de l’Est", "MST": "heure normale de Macao", "WAST": "heure d’été d’Afrique de l’Ouest", "HAT": "heure d’été de Terre-Neuve", "AEST": "heure normale de l’Est de l’Australie", "CHAST": "heure normale des îles Chatham", "IST": "heure de l’Inde", "VET": "heure du Venezuela", "ART": "heure normale d’Argentine", "COT": "heure normale de Colombie", "EST": "heure normale de l’Est nord-américain", "EDT": "heure d’été de l’Est", "AKST": "heure normale de l’Alaska", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "NZST": "heure normale de la Nouvelle-Zélande", "CLST": "heure d’été du Chili", "TMT": "heure normale du Turkménistan", "WIT": "heure de l’Est indonésien"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_SY) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_SY' +func (fr *fr_SY) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_SY' +func (fr *fr_SY) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_SY' +func (fr *fr_SY) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_SY' +func (fr *fr_SY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_SY' +func (fr *fr_SY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_SY' +func (fr *fr_SY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_SY) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_SY) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_SY) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_SY) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_SY) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_SY) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_SY) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_SY) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_SY) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_SY) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_SY) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_SY) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_SY) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_SY) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_SY' and handles both Whole and Real numbers based on 'v' +func (fr *fr_SY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_SY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_SY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_SY' +func (fr *fr_SY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_SY' +// in accounting notation. +func (fr *fr_SY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_SY' +func (fr *fr_SY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_SY' +func (fr *fr_SY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_SY' +func (fr *fr_SY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_SY' +func (fr *fr_SY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_SY' +func (fr *fr_SY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_SY' +func (fr *fr_SY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_SY' +func (fr *fr_SY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_SY' +func (fr *fr_SY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_SY/fr_SY_test.go b/vendor/github.com/go-playground/locales/fr_SY/fr_SY_test.go new file mode 100644 index 0000000000..d5bfcd5bb6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_SY/fr_SY_test.go @@ -0,0 +1,1120 @@ +package fr_SY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_SY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_TD/fr_TD.go b/vendor/github.com/go-playground/locales/fr_TD/fr_TD.go new file mode 100644 index 0000000000..530cd88fd3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_TD/fr_TD.go @@ -0,0 +1,657 @@ +package fr_TD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_TD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_TD' locale +func New() locales.Translator { + return &fr_TD{ + locale: "fr_TD", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"NZDT": "heure d’été de la Nouvelle-Zélande", "MESZ": "heure d’été d’Europe centrale", "JDT": "heure d’été du Japon", "HNT": "heure normale de Terre-Neuve", "AWDT": "heure d’été de l’Ouest de l’Australie", "BT": "heure du Bhoutan", "UYST": "heure d’été de l’Uruguay", "EAT": "heure normale d’Afrique de l’Est", "PST": "heure normale du Pacifique nord-américain", "ECT": "heure de l’Équateur", "GMT": "heure moyenne de Greenwich", "OESZ": "heure d’été d’Europe de l’Est", "COT": "heure normale de Colombie", "AEST": "heure normale de l’Est de l’Australie", "UYT": "heure normale de l’Uruguay", "WIT": "heure de l’Est indonésien", "AWST": "heure normale de l’Ouest de l’Australie", "PDT": "heure d’été du Pacifique", "WARST": "heure d’été de l’Ouest argentin", "∅∅∅": "heure d’été de l’Acre", "AKST": "heure normale de l’Alaska", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "GYT": "heure du Guyana", "HNCU": "heure normale de Cuba", "OEZ": "heure normale d’Europe de l’Est", "MYT": "heure de la Malaisie", "WAT": "heure normale d’Afrique de l’Ouest", "HEEG": "heure d’été de l’Est du Groenland", "GFT": "heure de la Guyane française", "COST": "heure d’été de Colombie", "MST": "heure normale des Rocheuses", "SAST": "heure normale d’Afrique méridionale", "CDT": "heure d’été du Centre", "CHAST": "heure normale des îles Chatham", "CLST": "heure d’été du Chili", "TMT": "heure normale du Turkménistan", "TMST": "heure d’été du Turkménistan", "IST": "heure de l’Inde", "AST": "heure normale de l’Atlantique", "ACWST": "heure normale du centre-ouest de l’Australie", "HNEG": "heure normale de l’Est du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "MDT": "heure d’été des Rocheuses", "LHDT": "heure d’été de Lord Howe", "HNPMX": "heure normale du Pacifique mexicain", "HEPMX": "heure d’été du Pacifique mexicain", "HECU": "heure d’été de Cuba", "ACST": "heure normale du centre de l’Australie", "AKDT": "heure d’été de l’Alaska", "BOT": "heure de Bolivie", "WAST": "heure d’été d’Afrique de l’Ouest", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HKST": "heure d’été de Hong Kong", "CHADT": "heure d’été des îles Chatham", "ACWDT": "heure d’été du centre-ouest de l’Australie", "ADT": "heure d’été de l’Atlantique", "WEZ": "heure normale d’Europe de l’Ouest", "WESZ": "heure d’été d’Europe de l’Ouest", "HNOG": "heure normale de l’Ouest du Groenland", "ARST": "heure d’été de l’Argentine", "ChST": "heure des Chamorro", "SRT": "heure du Suriname", "WIB": "heure de l’Ouest indonésien", "EDT": "heure d’été de l’Est", "HKT": "heure normale de Hong Kong", "ACDT": "heure d’été du centre de l’Australie", "HAT": "heure d’été de Terre-Neuve", "WITA": "heure du Centre indonésien", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "CST": "heure normale du centre nord-américain", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "MEZ": "heure normale d’Europe centrale", "CLT": "heure normale du Chili", "LHST": "heure normale de Lord Howe", "HAST": "heure normale d’Hawaii - Aléoutiennes", "VET": "heure du Venezuela", "HEOG": "heure d’été de l’Ouest du Groenland", "ART": "heure normale d’Argentine", "EST": "heure normale de l’Est nord-américain", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "SGT": "heure de Singapour", "CAT": "heure normale d’Afrique centrale", "NZST": "heure normale de la Nouvelle-Zélande", "JST": "heure normale du Japon", "WART": "heure normale de l’Ouest argentin"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_TD) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_TD' +func (fr *fr_TD) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_TD' +func (fr *fr_TD) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_TD' +func (fr *fr_TD) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_TD' +func (fr *fr_TD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_TD' +func (fr *fr_TD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_TD' +func (fr *fr_TD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_TD) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_TD) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_TD) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_TD) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_TD) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_TD) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_TD) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_TD) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_TD) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_TD) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_TD) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_TD) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_TD) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_TD) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_TD' and handles both Whole and Real numbers based on 'v' +func (fr *fr_TD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_TD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_TD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_TD' +func (fr *fr_TD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_TD' +// in accounting notation. +func (fr *fr_TD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_TD' +func (fr *fr_TD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_TD' +func (fr *fr_TD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_TD' +func (fr *fr_TD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_TD' +func (fr *fr_TD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_TD' +func (fr *fr_TD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_TD' +func (fr *fr_TD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_TD' +func (fr *fr_TD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_TD' +func (fr *fr_TD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_TD/fr_TD_test.go b/vendor/github.com/go-playground/locales/fr_TD/fr_TD_test.go new file mode 100644 index 0000000000..b1f06543b2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_TD/fr_TD_test.go @@ -0,0 +1,1120 @@ +package fr_TD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_TD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_TG/fr_TG.go b/vendor/github.com/go-playground/locales/fr_TG/fr_TG.go new file mode 100644 index 0000000000..08ab312c1f --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_TG/fr_TG.go @@ -0,0 +1,619 @@ +package fr_TG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_TG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_TG' locale +func New() locales.Translator { + return &fr_TG{ + locale: "fr_TG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"∅∅∅": "heure d’été de Brasilia", "AWDT": "heure d’été de l’Ouest de l’Australie", "CHAST": "heure normale des îles Chatham", "MESZ": "heure d’été d’Europe centrale", "WAST": "heure d’été d’Afrique de l’Ouest", "BT": "heure du Bhoutan", "UYST": "heure d’été de l’Uruguay", "LHST": "heure normale de Lord Howe", "HEPMX": "heure d’été du Pacifique mexicain", "CDT": "heure d’été du Centre", "SGT": "heure de Singapour", "VET": "heure du Venezuela", "HKST": "heure d’été de Hong Kong", "PDT": "heure d’été du Pacifique", "AEST": "heure normale de l’Est de l’Australie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "HNPMX": "heure normale du Pacifique mexicain", "ACST": "heure normale du centre de l’Australie", "HNCU": "heure normale de Cuba", "JST": "heure normale du Japon", "GMT": "heure moyenne de Greenwich", "ChST": "heure des Chamorro", "CHADT": "heure d’été des îles Chatham", "ACWDT": "heure d’été du centre-ouest de l’Australie", "HEOG": "heure d’été de l’Ouest du Groenland", "OESZ": "heure d’été d’Europe de l’Est", "WART": "heure normale de l’Ouest argentin", "TMT": "heure normale du Turkménistan", "HAT": "heure d’été de Terre-Neuve", "WITA": "heure du Centre indonésien", "UYT": "heure normale de l’Uruguay", "GYT": "heure du Guyana", "HAST": "heure normale d’Hawaii - Aléoutiennes", "NZDT": "heure d’été de la Nouvelle-Zélande", "HNOG": "heure normale de l’Ouest du Groenland", "ARST": "heure d’été de l’Argentine", "IST": "heure de l’Inde", "CLT": "heure normale du Chili", "MST": "heure normale de Macao", "ACDT": "heure d’été du centre de l’Australie", "HNEG": "heure normale de l’Est du Groenland", "AKST": "heure normale de l’Alaska", "HECU": "heure d’été de Cuba", "PST": "heure normale du Pacifique nord-américain", "CLST": "heure d’été du Chili", "TMST": "heure d’été du Turkménistan", "WIT": "heure de l’Est indonésien", "AWST": "heure normale de l’Ouest de l’Australie", "BOT": "heure de Bolivie", "CAT": "heure normale d’Afrique centrale", "COT": "heure normale de Colombie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "JDT": "heure d’été du Japon", "WAT": "heure normale d’Afrique de l’Ouest", "EST": "heure normale de l’Est nord-américain", "HKT": "heure normale de Hong Kong", "COST": "heure d’été de Colombie", "SAST": "heure normale d’Afrique méridionale", "ECT": "heure de l’Équateur", "NZST": "heure normale de la Nouvelle-Zélande", "ADT": "heure d’été de l’Atlantique", "WESZ": "heure d’été d’Europe de l’Ouest", "MYT": "heure de la Malaisie", "ART": "heure normale d’Argentine", "EAT": "heure normale d’Afrique de l’Est", "CST": "heure normale du centre nord-américain", "AST": "heure normale de l’Atlantique", "EDT": "heure d’été de l’Est", "HNT": "heure normale de Terre-Neuve", "SRT": "heure du Suriname", "AKDT": "heure d’été de l’Alaska", "AEDT": "heure d’été de l’Est de l’Australie", "OEZ": "heure normale d’Europe de l’Est", "WARST": "heure d’été de l’Ouest argentin", "GFT": "heure de la Guyane française", "LHDT": "heure d’été de Lord Howe", "ACWST": "heure normale du centre-ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "WEZ": "heure normale d’Europe de l’Ouest", "MDT": "heure d’été de Macao", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HEEG": "heure d’été de l’Est du Groenland", "WIB": "heure de l’Ouest indonésien"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_TG) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_TG' +func (fr *fr_TG) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_TG' +func (fr *fr_TG) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_TG' +func (fr *fr_TG) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_TG' +func (fr *fr_TG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_TG' +func (fr *fr_TG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_TG' +func (fr *fr_TG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_TG) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_TG) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_TG) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_TG) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_TG) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_TG) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_TG) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_TG) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_TG) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_TG) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_TG) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_TG) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_TG) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_TG) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_TG' and handles both Whole and Real numbers based on 'v' +func (fr *fr_TG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_TG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_TG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_TG' +func (fr *fr_TG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_TG' +// in accounting notation. +func (fr *fr_TG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_TG' +func (fr *fr_TG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_TG' +func (fr *fr_TG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_TG' +func (fr *fr_TG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_TG' +func (fr *fr_TG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_TG' +func (fr *fr_TG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_TG' +func (fr *fr_TG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_TG' +func (fr *fr_TG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_TG' +func (fr *fr_TG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_TG/fr_TG_test.go b/vendor/github.com/go-playground/locales/fr_TG/fr_TG_test.go new file mode 100644 index 0000000000..3a4776a5a7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_TG/fr_TG_test.go @@ -0,0 +1,1120 @@ +package fr_TG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_TG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_TN/fr_TN.go b/vendor/github.com/go-playground/locales/fr_TN/fr_TN.go new file mode 100644 index 0000000000..c669e8e217 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_TN/fr_TN.go @@ -0,0 +1,657 @@ +package fr_TN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_TN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_TN' locale +func New() locales.Translator { + return &fr_TN{ + locale: "fr_TN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "DT", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"SGT": "heure de Singapour", "GMT": "heure moyenne de Greenwich", "WAT": "heure normale d’Afrique de l’Ouest", "COT": "heure normale de Colombie", "AEST": "heure normale de l’Est de l’Australie", "UYST": "heure d’été de l’Uruguay", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HEPMX": "heure d’été du Pacifique mexicain", "OESZ": "heure d’été d’Europe de l’Est", "COST": "heure d’été de Colombie", "WITA": "heure du Centre indonésien", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "LHDT": "heure d’été de Lord Howe", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "HKT": "heure normale de Hong Kong", "ACDT": "heure d’été du centre de l’Australie", "MDT": "heure d’été des Rocheuses", "AKDT": "heure d’été de l’Alaska", "LHST": "heure normale de Lord Howe", "HEOG": "heure d’été de l’Ouest du Groenland", "ADT": "heure d’été de l’Atlantique", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "UYT": "heure normale de l’Uruguay", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ACWST": "heure normale du centre-ouest de l’Australie", "VET": "heure du Venezuela", "WARST": "heure d’été de l’Ouest argentin", "BOT": "heure de Bolivie", "MEZ": "heure normale d’Europe centrale", "MYT": "heure de la Malaisie", "EST": "heure normale de l’Est nord-américain", "WAST": "heure d’été d’Afrique de l’Ouest", "HNPMX": "heure normale du Pacifique mexicain", "GYT": "heure du Guyana", "ACWDT": "heure d’été du centre-ouest de l’Australie", "CLST": "heure d’été du Chili", "HKST": "heure d’été de Hong Kong", "EAT": "heure normale d’Afrique de l’Est", "CHADT": "heure d’été des îles Chatham", "JDT": "heure d’été du Japon", "TMST": "heure d’été du Turkménistan", "HNT": "heure normale de Terre-Neuve", "AKST": "heure normale de l’Alaska", "OEZ": "heure normale d’Europe de l’Est", "CLT": "heure normale du Chili", "EDT": "heure d’été de l’Est", "ACST": "heure normale du centre de l’Australie", "AEDT": "heure d’été de l’Est de l’Australie", "GFT": "heure de la Guyane française", "AWST": "heure normale de l’Ouest de l’Australie", "HAT": "heure d’été de Terre-Neuve", "HEEG": "heure d’été de l’Est du Groenland", "CHAST": "heure normale des îles Chatham", "IST": "heure de l’Inde", "ARST": "heure d’été de l’Argentine", "BT": "heure du Bhoutan", "ECT": "heure de l’Équateur", "NZST": "heure normale de la Nouvelle-Zélande", "MESZ": "heure d’été d’Europe centrale", "MST": "heure normale des Rocheuses", "ChST": "heure des Chamorro", "WIT": "heure de l’Est indonésien", "PST": "heure normale du Pacifique nord-américain", "PDT": "heure d’été du Pacifique", "WEZ": "heure normale d’Europe de l’Ouest", "ART": "heure normale d’Argentine", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "TMT": "heure normale du Turkménistan", "WIB": "heure de l’Ouest indonésien", "NZDT": "heure d’été de la Nouvelle-Zélande", "CAT": "heure normale d’Afrique centrale", "WART": "heure normale de l’Ouest argentin", "HNOG": "heure normale de l’Ouest du Groenland", "SRT": "heure du Suriname", "AWDT": "heure d’été de l’Ouest de l’Australie", "JST": "heure normale du Japon", "CDT": "heure d’été du Centre", "WESZ": "heure d’été d’Europe de l’Ouest", "AST": "heure normale de l’Atlantique", "∅∅∅": "heure d’été des Açores", "SAST": "heure normale d’Afrique méridionale", "HNCU": "heure normale de Cuba", "HECU": "heure d’été de Cuba", "CST": "heure normale du centre nord-américain", "HNEG": "heure normale de l’Est du Groenland"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_TN) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_TN' +func (fr *fr_TN) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_TN' +func (fr *fr_TN) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_TN' +func (fr *fr_TN) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_TN' +func (fr *fr_TN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_TN' +func (fr *fr_TN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_TN' +func (fr *fr_TN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_TN) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_TN) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_TN) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_TN) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_TN) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_TN) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_TN) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_TN) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_TN) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_TN) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_TN) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_TN) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_TN) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_TN) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_TN' and handles both Whole and Real numbers based on 'v' +func (fr *fr_TN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_TN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_TN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_TN' +func (fr *fr_TN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_TN' +// in accounting notation. +func (fr *fr_TN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_TN' +func (fr *fr_TN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_TN' +func (fr *fr_TN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_TN' +func (fr *fr_TN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_TN' +func (fr *fr_TN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_TN' +func (fr *fr_TN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_TN' +func (fr *fr_TN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_TN' +func (fr *fr_TN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_TN' +func (fr *fr_TN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_TN/fr_TN_test.go b/vendor/github.com/go-playground/locales/fr_TN/fr_TN_test.go new file mode 100644 index 0000000000..ab21a788d2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_TN/fr_TN_test.go @@ -0,0 +1,1120 @@ +package fr_TN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_TN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_VU/fr_VU.go b/vendor/github.com/go-playground/locales/fr_VU/fr_VU.go new file mode 100644 index 0000000000..f5edc9eca5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_VU/fr_VU.go @@ -0,0 +1,657 @@ +package fr_VU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_VU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_VU' locale +func New() locales.Translator { + return &fr_VU{ + locale: "fr_VU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VT", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"MESZ": "heure d’été d’Europe centrale", "ChST": "heure des Chamorro", "WIB": "heure de l’Ouest indonésien", "CLT": "heure normale du Chili", "CLST": "heure d’été du Chili", "ART": "heure normale d’Argentine", "HNT": "heure normale de Terre-Neuve", "GFT": "heure de la Guyane française", "CDT": "heure d’été du Centre", "CHAST": "heure normale des îles Chatham", "IST": "heure de l’Inde", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "HAT": "heure d’été de Terre-Neuve", "ACWDT": "heure d’été du centre-ouest de l’Australie", "TMST": "heure d’été du Turkménistan", "MST": "heure normale de Macao", "OESZ": "heure d’été d’Europe de l’Est", "AWDT": "heure d’été de l’Ouest de l’Australie", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "ECT": "heure de l’Équateur", "CAT": "heure normale d’Afrique centrale", "MEZ": "heure normale d’Europe centrale", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "NZDT": "heure d’été de la Nouvelle-Zélande", "JDT": "heure d’été du Japon", "GMT": "heure moyenne de Greenwich", "EDT": "heure d’été de l’Est", "MDT": "heure d’été de Macao", "AEST": "heure normale de l’Est de l’Australie", "AKST": "heure normale de l’Alaska", "LHDT": "heure d’été de Lord Howe", "BOT": "heure de Bolivie", "CHADT": "heure d’été des îles Chatham", "WART": "heure normale de l’Ouest argentin", "HNOG": "heure normale de l’Ouest du Groenland", "UYT": "heure normale de l’Uruguay", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "WIT": "heure de l’Est indonésien", "WESZ": "heure d’été d’Europe de l’Ouest", "HEOG": "heure d’été de l’Ouest du Groenland", "ACST": "heure normale du centre de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "SGT": "heure de Singapour", "HAST": "heure normale d’Hawaii - Aléoutiennes", "AST": "heure normale de l’Atlantique", "HKT": "heure normale de Hong Kong", "WAST": "heure d’été d’Afrique de l’Ouest", "AKDT": "heure d’été de l’Alaska", "LHST": "heure normale de Lord Howe", "PST": "heure normale du Pacifique nord-américain", "NZST": "heure normale de la Nouvelle-Zélande", "ADT": "heure d’été de l’Atlantique", "TMT": "heure normale du Turkménistan", "HNCU": "heure normale de Cuba", "AWST": "heure normale de l’Ouest de l’Australie", "JST": "heure normale du Japon", "OEZ": "heure normale d’Europe de l’Est", "WEZ": "heure normale d’Europe de l’Ouest", "UYST": "heure d’été de l’Uruguay", "ARST": "heure d’été de l’Argentine", "AEDT": "heure d’été de l’Est de l’Australie", "SAST": "heure normale d’Afrique méridionale", "HECU": "heure d’été de Cuba", "∅∅∅": "heure d’été de l’Amazonie", "VET": "heure du Venezuela", "WARST": "heure d’été de l’Ouest argentin", "SRT": "heure du Suriname", "WITA": "heure du Centre indonésien", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "EAT": "heure normale d’Afrique de l’Est", "MYT": "heure de la Malaisie", "COST": "heure d’été de Colombie", "HNEG": "heure normale de l’Est du Groenland", "HEEG": "heure d’été de l’Est du Groenland", "ACWST": "heure normale du centre-ouest de l’Australie", "WAT": "heure normale d’Afrique de l’Ouest", "HNPMX": "heure normale du Pacifique mexicain", "BT": "heure du Bhoutan", "HEPMX": "heure d’été du Pacifique mexicain", "GYT": "heure du Guyana", "CST": "heure normale du centre nord-américain", "PDT": "heure d’été du Pacifique", "EST": "heure normale de l’Est nord-américain", "HKST": "heure d’été de Hong Kong", "COT": "heure normale de Colombie"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_VU) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_VU' +func (fr *fr_VU) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_VU' +func (fr *fr_VU) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_VU' +func (fr *fr_VU) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_VU' +func (fr *fr_VU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_VU' +func (fr *fr_VU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_VU' +func (fr *fr_VU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_VU) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_VU) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_VU) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_VU) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_VU) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_VU) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_VU) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_VU) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_VU) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_VU) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_VU) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_VU) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_VU) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_VU) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_VU' and handles both Whole and Real numbers based on 'v' +func (fr *fr_VU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_VU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_VU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_VU' +func (fr *fr_VU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_VU' +// in accounting notation. +func (fr *fr_VU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_VU' +func (fr *fr_VU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_VU' +func (fr *fr_VU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_VU' +func (fr *fr_VU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_VU' +func (fr *fr_VU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_VU' +func (fr *fr_VU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_VU' +func (fr *fr_VU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_VU' +func (fr *fr_VU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_VU' +func (fr *fr_VU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, fr.periodsAbbreviated[0]...) + } else { + b = append(b, fr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_VU/fr_VU_test.go b/vendor/github.com/go-playground/locales/fr_VU/fr_VU_test.go new file mode 100644 index 0000000000..214c5be753 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_VU/fr_VU_test.go @@ -0,0 +1,1120 @@ +package fr_VU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_VU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_WF/fr_WF.go b/vendor/github.com/go-playground/locales/fr_WF/fr_WF.go new file mode 100644 index 0000000000..6b4a04fa6f --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_WF/fr_WF.go @@ -0,0 +1,619 @@ +package fr_WF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_WF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_WF' locale +func New() locales.Translator { + return &fr_WF{ + locale: "fr_WF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"HAT": "heure d’été de Terre-Neuve", "AEST": "heure normale de l’Est de l’Australie", "AKST": "heure normale de l’Alaska", "CHADT": "heure d’été des îles Chatham", "HNOG": "heure normale de l’Ouest du Groenland", "COT": "heure normale de Colombie", "UYT": "heure normale de l’Uruguay", "SGT": "heure de Singapour", "WAT": "heure normale d’Afrique de l’Ouest", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "ACWST": "heure normale du centre-ouest de l’Australie", "MYT": "heure de la Malaisie", "TMST": "heure d’été du Turkménistan", "MST": "heure normale de Macao", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "CST": "heure normale du centre nord-américain", "CHAST": "heure normale des îles Chatham", "LHST": "heure normale de Lord Howe", "SRT": "heure du Suriname", "CAT": "heure normale d’Afrique centrale", "OEZ": "heure normale d’Europe de l’Est", "WARST": "heure d’été de l’Ouest argentin", "ARST": "heure d’été de l’Argentine", "HKT": "heure normale de Hong Kong", "WIB": "heure de l’Ouest indonésien", "AWDT": "heure d’été de l’Ouest de l’Australie", "IST": "heure de l’Inde", "MEZ": "heure normale d’Europe centrale", "HKST": "heure d’été de Hong Kong", "HAST": "heure normale d’Hawaii - Aléoutiennes", "ECT": "heure de l’Équateur", "NZST": "heure normale de la Nouvelle-Zélande", "OESZ": "heure d’été d’Europe de l’Est", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "HNPMX": "heure normale du Pacifique mexicain", "BOT": "heure de Bolivie", "PST": "heure normale du Pacifique nord-américain", "COST": "heure d’été de Colombie", "EAT": "heure normale d’Afrique de l’Est", "TMT": "heure normale du Turkménistan", "VET": "heure du Venezuela", "CLT": "heure normale du Chili", "MDT": "heure d’été de Macao", "HNEG": "heure normale de l’Est du Groenland", "GYT": "heure du Guyana", "AWST": "heure normale de l’Ouest de l’Australie", "PDT": "heure d’été du Pacifique", "ART": "heure normale d’Argentine", "HNT": "heure normale de Terre-Neuve", "WEZ": "heure normale d’Europe de l’Ouest", "GMT": "heure moyenne de Greenwich", "CLST": "heure d’été du Chili", "LHDT": "heure d’été de Lord Howe", "ACWDT": "heure d’été du centre-ouest de l’Australie", "JST": "heure normale du Japon", "NZDT": "heure d’été de la Nouvelle-Zélande", "BT": "heure du Bhoutan", "WITA": "heure du Centre indonésien", "HECU": "heure d’été de Cuba", "WIT": "heure de l’Est indonésien", "MESZ": "heure d’été d’Europe centrale", "HEOG": "heure d’été de l’Ouest du Groenland", "ADT": "heure d’été de l’Atlantique", "ACST": "heure normale du centre de l’Australie", "ACDT": "heure d’été du centre de l’Australie", "HNCU": "heure normale de Cuba", "CDT": "heure d’été du Centre", "SAST": "heure normale d’Afrique méridionale", "∅∅∅": "heure d’été de Brasilia", "HEPMX": "heure d’été du Pacifique mexicain", "UYST": "heure d’été de l’Uruguay", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "ChST": "heure des Chamorro", "AST": "heure normale de l’Atlantique", "EST": "heure normale de l’Est nord-américain", "EDT": "heure d’été de l’Est", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "WART": "heure normale de l’Ouest argentin", "WAST": "heure d’été d’Afrique de l’Ouest", "HEEG": "heure d’été de l’Est du Groenland", "AEDT": "heure d’été de l’Est de l’Australie", "GFT": "heure de la Guyane française", "AKDT": "heure d’été de l’Alaska", "JDT": "heure d’été du Japon", "WESZ": "heure d’été d’Europe de l’Ouest"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_WF) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_WF' +func (fr *fr_WF) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_WF' +func (fr *fr_WF) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_WF' +func (fr *fr_WF) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_WF' +func (fr *fr_WF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_WF' +func (fr *fr_WF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_WF' +func (fr *fr_WF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_WF) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_WF) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_WF) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_WF) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_WF) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_WF) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_WF) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_WF) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_WF) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_WF) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_WF) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_WF) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_WF) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_WF) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_WF' and handles both Whole and Real numbers based on 'v' +func (fr *fr_WF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_WF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_WF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_WF' +func (fr *fr_WF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_WF' +// in accounting notation. +func (fr *fr_WF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_WF' +func (fr *fr_WF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_WF' +func (fr *fr_WF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_WF' +func (fr *fr_WF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_WF' +func (fr *fr_WF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_WF' +func (fr *fr_WF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_WF' +func (fr *fr_WF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_WF' +func (fr *fr_WF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_WF' +func (fr *fr_WF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_WF/fr_WF_test.go b/vendor/github.com/go-playground/locales/fr_WF/fr_WF_test.go new file mode 100644 index 0000000000..ba6b0c9104 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_WF/fr_WF_test.go @@ -0,0 +1,1120 @@ +package fr_WF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_WF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fr_YT/fr_YT.go b/vendor/github.com/go-playground/locales/fr_YT/fr_YT.go new file mode 100644 index 0000000000..ef1f622832 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_YT/fr_YT.go @@ -0,0 +1,619 @@ +package fr_YT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fr_YT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fr_YT' locale +func New() locales.Translator { + return &fr_YT{ + locale: "fr_YT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"}, + daysAbbreviated: []string{"dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"di", "lu", "ma", "me", "je", "ve", "sa"}, + daysWide: []string{"dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. J.-C.", "ap. J.-C."}, + erasNarrow: []string{"av. J.-C.", "ap. J.-C."}, + erasWide: []string{"avant Jésus-Christ", "après Jésus-Christ"}, + timezones: map[string]string{"ACST": "heure normale du centre de l’Australie", "COT": "heure normale de Colombie", "AEDT": "heure d’été de l’Est de l’Australie", "VET": "heure du Venezuela", "WESZ": "heure d’été d’Europe de l’Ouest", "HNT": "heure normale de Terre-Neuve", "LHST": "heure normale de Lord Howe", "HECU": "heure d’été de Cuba", "OESZ": "heure d’été d’Europe de l’Est", "EST": "heure normale de l’Est nord-américain", "AST": "heure normale de l’Atlantique", "AKST": "heure normale de l’Alaska", "CHAST": "heure normale des îles Chatham", "SGT": "heure de Singapour", "WART": "heure normale de l’Ouest argentin", "HEOG": "heure d’été de l’Ouest du Groenland", "BT": "heure du Bhoutan", "UYST": "heure d’été de l’Uruguay", "ACWST": "heure normale du centre-ouest de l’Australie", "ACWDT": "heure d’été du centre-ouest de l’Australie", "MEZ": "heure normale d’Europe centrale", "HNOG": "heure normale de l’Ouest du Groenland", "MYT": "heure de la Malaisie", "ACDT": "heure d’été du centre de l’Australie", "GFT": "heure de la Guyane française", "MDT": "heure d’été des Rocheuses", "UYT": "heure normale de l’Uruguay", "HADT": "heure d’été d’Hawaii - Aléoutiennes", "TMT": "heure normale du Turkménistan", "ART": "heure normale d’Argentine", "WAST": "heure d’été d’Afrique de l’Ouest", "ADT": "heure d’été de l’Atlantique", "HNEG": "heure normale de l’Est du Groenland", "CDT": "heure d’été du Centre", "CHADT": "heure d’été des îles Chatham", "CAT": "heure normale d’Afrique centrale", "NZST": "heure normale de la Nouvelle-Zélande", "HEPMX": "heure d’été du Pacifique mexicain", "AWDT": "heure d’été de l’Ouest de l’Australie", "HAST": "heure normale d’Hawaii - Aléoutiennes", "TMST": "heure d’été du Turkménistan", "WARST": "heure d’été de l’Ouest argentin", "HENOMX": "heure d’été du Nord-Ouest du Mexique", "SRT": "heure du Suriname", "EAT": "heure normale d’Afrique de l’Est", "PDT": "heure d’été du Pacifique", "NZDT": "heure d’été de la Nouvelle-Zélande", "EDT": "heure d’été de l’Est", "∅∅∅": "heure d’été du Pérou", "AKDT": "heure d’été de l’Alaska", "MST": "heure normale des Rocheuses", "HEPM": "heure d’été de Saint-Pierre-et-Miquelon", "CLT": "heure normale du Chili", "HAT": "heure d’été de Terre-Neuve", "HEEG": "heure d’été de l’Est du Groenland", "WITA": "heure du Centre indonésien", "HNCU": "heure normale de Cuba", "WEZ": "heure normale d’Europe de l’Ouest", "WAT": "heure normale d’Afrique de l’Ouest", "SAST": "heure normale d’Afrique méridionale", "WIT": "heure de l’Est indonésien", "PST": "heure normale du Pacifique nord-américain", "JST": "heure normale du Japon", "CLST": "heure d’été du Chili", "HNNOMX": "heure normale du Nord-Ouest du Mexique", "AEST": "heure normale de l’Est de l’Australie", "HKT": "heure normale de Hong Kong", "ChST": "heure des Chamorro", "AWST": "heure normale de l’Ouest de l’Australie", "BOT": "heure de Bolivie", "ECT": "heure de l’Équateur", "MESZ": "heure d’été d’Europe centrale", "LHDT": "heure d’été de Lord Howe", "JDT": "heure d’été du Japon", "HNPMX": "heure normale du Pacifique mexicain", "WIB": "heure de l’Ouest indonésien", "OEZ": "heure normale d’Europe de l’Est", "GMT": "heure moyenne de Greenwich", "HKST": "heure d’été de Hong Kong", "ARST": "heure d’été de l’Argentine", "COST": "heure d’été de Colombie", "HNPM": "heure normale de Saint-Pierre-et-Miquelon", "GYT": "heure du Guyana", "CST": "heure normale du centre nord-américain", "IST": "heure de l’Inde"}, + } +} + +// Locale returns the current translators string locale +func (fr *fr_YT) Locale() string { + return fr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fr_YT' +func (fr *fr_YT) PluralsCardinal() []locales.PluralRule { + return fr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fr_YT' +func (fr *fr_YT) PluralsOrdinal() []locales.PluralRule { + return fr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fr_YT' +func (fr *fr_YT) PluralsRange() []locales.PluralRule { + return fr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fr_YT' +func (fr *fr_YT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fr_YT' +func (fr *fr_YT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fr_YT' +func (fr *fr_YT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := fr.CardinalPluralRule(num1, v1) + end := fr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fr *fr_YT) MonthAbbreviated(month time.Month) string { + return fr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fr *fr_YT) MonthsAbbreviated() []string { + return fr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fr *fr_YT) MonthNarrow(month time.Month) string { + return fr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fr *fr_YT) MonthsNarrow() []string { + return fr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fr *fr_YT) MonthWide(month time.Month) string { + return fr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fr *fr_YT) MonthsWide() []string { + return fr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fr *fr_YT) WeekdayAbbreviated(weekday time.Weekday) string { + return fr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fr *fr_YT) WeekdaysAbbreviated() []string { + return fr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fr *fr_YT) WeekdayNarrow(weekday time.Weekday) string { + return fr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fr *fr_YT) WeekdaysNarrow() []string { + return fr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fr *fr_YT) WeekdayShort(weekday time.Weekday) string { + return fr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fr *fr_YT) WeekdaysShort() []string { + return fr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fr *fr_YT) WeekdayWide(weekday time.Weekday) string { + return fr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fr *fr_YT) WeekdaysWide() []string { + return fr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fr_YT' and handles both Whole and Real numbers based on 'v' +func (fr *fr_YT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fr_YT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fr *fr_YT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fr.percentSuffix...) + + b = append(b, fr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fr_YT' +func (fr *fr_YT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, fr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fr_YT' +// in accounting notation. +func (fr *fr_YT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fr.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(fr.group) - 1; j >= 0; j-- { + b = append(b, fr.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, fr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, fr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fr_YT' +func (fr *fr_YT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fr_YT' +func (fr *fr_YT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fr_YT' +func (fr *fr_YT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fr_YT' +func (fr *fr_YT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fr_YT' +func (fr *fr_YT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fr_YT' +func (fr *fr_YT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fr_YT' +func (fr *fr_YT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fr_YT' +func (fr *fr_YT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fr_YT/fr_YT_test.go b/vendor/github.com/go-playground/locales/fr_YT/fr_YT_test.go new file mode 100644 index 0000000000..1a4aeaa18c --- /dev/null +++ b/vendor/github.com/go-playground/locales/fr_YT/fr_YT_test.go @@ -0,0 +1,1120 @@ +package fr_YT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fr_YT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fur/fur.go b/vendor/github.com/go-playground/locales/fur/fur.go new file mode 100644 index 0000000000..36bf6edd3b --- /dev/null +++ b/vendor/github.com/go-playground/locales/fur/fur.go @@ -0,0 +1,613 @@ +package fur + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fur struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fur' locale +func New() locales.Translator { + return &fur{ + locale: "fur", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Zen", "Fev", "Mar", "Avr", "Mai", "Jug", "Lui", "Avo", "Set", "Otu", "Nov", "Dic"}, + monthsNarrow: []string{"", "Z", "F", "M", "A", "M", "J", "L", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Zenâr", "Fevrâr", "Març", "Avrîl", "Mai", "Jugn", "Lui", "Avost", "Setembar", "Otubar", "Novembar", "Dicembar"}, + daysAbbreviated: []string{"dom", "lun", "mar", "mie", "joi", "vin", "sab"}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysWide: []string{"domenie", "lunis", "martars", "miercus", "joibe", "vinars", "sabide"}, + periodsAbbreviated: []string{"a.", "p."}, + periodsWide: []string{"a.", "p."}, + erasAbbreviated: []string{"pdC", "ddC"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ARST": "ARST", "HNPM": "HNPM", "EAT": "EAT", "CDT": "CDT", "AWST": "AWST", "PST": "PST", "GMT": "GMT", "WAST": "WAST", "HNNOMX": "HNNOMX", "HEPM": "HEPM", "CHAST": "CHAST", "ACWDT": "ACWDT", "HNOG": "HNOG", "CLT": "CLT", "TMST": "TMST", "BT": "BT", "HNT": "HNT", "HAT": "HAT", "ECT": "ECT", "NZDT": "NZDT", "MST": "MST", "HNPMX": "HNPMX", "SGT": "SGT", "HEOG": "HEOG", "HKT": "HKT", "LHDT": "LHDT", "MEZ": "Ore standard de Europe centrâl", "ACST": "ACST", "GFT": "GFT", "AEDT": "AEDT", "WIT": "WIT", "HADT": "HADT", "OESZ": "Ore estive de Europe orientâl", "WART": "WART", "CLST": "CLST", "WITA": "WITA", "∅∅∅": "∅∅∅", "CHADT": "CHADT", "JST": "JST", "WEZ": "Ore standard de Europe ocidentâl", "AKDT": "AKDT", "GYT": "GYT", "AWDT": "AWDT", "BOT": "BOT", "PDT": "PDT", "MESZ": "Ore estive de Europe centrâl", "EDT": "EDT", "UYST": "UYST", "HNCU": "HNCU", "TMT": "TMT", "MDT": "MDT", "COST": "COST", "AKST": "AKST", "ChST": "ChST", "UYT": "UYT", "SAST": "SAST", "LHST": "LHST", "HEPMX": "HEPMX", "VET": "VET", "AEST": "AEST", "ART": "ART", "HKST": "HKST", "HEEG": "HEEG", "WAT": "WAT", "ACDT": "ACDT", "HECU": "HECU", "CST": "CST", "CAT": "CAT", "NZST": "NZST", "WESZ": "Ore estive de Europe ocidentâl", "MYT": "MYT", "HENOMX": "HENOMX", "HAST": "HAST", "IST": "IST", "AST": "AST", "OEZ": "Ore standard de Europe orientâl", "WARST": "WARST", "EST": "EST", "SRT": "SRT", "WIB": "WIB", "ACWST": "ACWST", "JDT": "JDT", "ADT": "ADT", "COT": "COT", "HNEG": "HNEG"}, + } +} + +// Locale returns the current translators string locale +func (fur *fur) Locale() string { + return fur.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fur' +func (fur *fur) PluralsCardinal() []locales.PluralRule { + return fur.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fur' +func (fur *fur) PluralsOrdinal() []locales.PluralRule { + return fur.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fur' +func (fur *fur) PluralsRange() []locales.PluralRule { + return fur.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fur' +func (fur *fur) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fur' +func (fur *fur) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fur' +func (fur *fur) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fur *fur) MonthAbbreviated(month time.Month) string { + return fur.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fur *fur) MonthsAbbreviated() []string { + return fur.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fur *fur) MonthNarrow(month time.Month) string { + return fur.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fur *fur) MonthsNarrow() []string { + return fur.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fur *fur) MonthWide(month time.Month) string { + return fur.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fur *fur) MonthsWide() []string { + return fur.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fur *fur) WeekdayAbbreviated(weekday time.Weekday) string { + return fur.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fur *fur) WeekdaysAbbreviated() []string { + return fur.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fur *fur) WeekdayNarrow(weekday time.Weekday) string { + return fur.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fur *fur) WeekdaysNarrow() []string { + return fur.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fur *fur) WeekdayShort(weekday time.Weekday) string { + return fur.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fur *fur) WeekdaysShort() []string { + return fur.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fur *fur) WeekdayWide(weekday time.Weekday) string { + return fur.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fur *fur) WeekdaysWide() []string { + return fur.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fur' and handles both Whole and Real numbers based on 'v' +func (fur *fur) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fur.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fur' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fur *fur) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fur.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fur.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fur.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fur' +func (fur *fur) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fur.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fur.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fur.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, fur.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fur' +// in accounting notation. +func (fur *fur) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fur.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fur.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, fur.currencyNegativePrefix[j]) + } + + b = append(b, fur.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fur.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fur.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fur' +func (fur *fur) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fur' +func (fur *fur) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fur' +func (fur *fur) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + b = append(b, fur.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x61, 0x6c}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fur' +func (fur *fur) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fur.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + b = append(b, fur.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x61, 0x6c}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fur' +func (fur *fur) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fur' +func (fur *fur) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fur' +func (fur *fur) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fur' +func (fur *fur) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fur.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fur/fur_test.go b/vendor/github.com/go-playground/locales/fur/fur_test.go new file mode 100644 index 0000000000..c7f73cadee --- /dev/null +++ b/vendor/github.com/go-playground/locales/fur/fur_test.go @@ -0,0 +1,1120 @@ +package fur + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fur" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fur_IT/fur_IT.go b/vendor/github.com/go-playground/locales/fur_IT/fur_IT.go new file mode 100644 index 0000000000..b9b39983a5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fur_IT/fur_IT.go @@ -0,0 +1,613 @@ +package fur_IT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fur_IT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fur_IT' locale +func New() locales.Translator { + return &fur_IT{ + locale: "fur_IT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Zen", "Fev", "Mar", "Avr", "Mai", "Jug", "Lui", "Avo", "Set", "Otu", "Nov", "Dic"}, + monthsNarrow: []string{"", "Z", "F", "M", "A", "M", "J", "L", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Zenâr", "Fevrâr", "Març", "Avrîl", "Mai", "Jugn", "Lui", "Avost", "Setembar", "Otubar", "Novembar", "Dicembar"}, + daysAbbreviated: []string{"dom", "lun", "mar", "mie", "joi", "vin", "sab"}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysWide: []string{"domenie", "lunis", "martars", "miercus", "joibe", "vinars", "sabide"}, + periodsAbbreviated: []string{"a.", "p."}, + periodsWide: []string{"a.", "p."}, + erasAbbreviated: []string{"pdC", "ddC"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"LHDT": "LHDT", "HECU": "HECU", "BOT": "BOT", "HNNOMX": "HNNOMX", "WITA": "WITA", "HEPM": "HEPM", "ChST": "ChST", "WIT": "WIT", "HAT": "HAT", "BT": "BT", "HNPM": "HNPM", "HEPMX": "HEPMX", "SRT": "SRT", "AWDT": "AWDT", "HAST": "HAST", "CLST": "CLST", "COST": "COST", "∅∅∅": "∅∅∅", "HNPMX": "HNPMX", "HNOG": "HNOG", "MEZ": "Ore standard de Europe centrâl", "UYST": "UYST", "CST": "CST", "NZDT": "NZDT", "WESZ": "Ore estive de Europe ocidentâl", "WARST": "WARST", "COT": "COT", "ACST": "ACST", "HNEG": "HNEG", "OESZ": "Ore estive de Europe orientâl", "EST": "EST", "HKST": "HKST", "AEDT": "AEDT", "SAST": "SAST", "PST": "PST", "CDT": "CDT", "CAT": "CAT", "ART": "ART", "ACDT": "ACDT", "MDT": "MDT", "UYT": "UYT", "TMT": "TMT", "PDT": "PDT", "WEZ": "Ore standard de Europe ocidentâl", "ADT": "ADT", "OEZ": "Ore standard de Europe orientâl", "TMST": "TMST", "AKDT": "AKDT", "VET": "VET", "JDT": "JDT", "NZST": "NZST", "MESZ": "Ore estive de Europe centrâl", "HEOG": "HEOG", "HENOMX": "HENOMX", "HEEG": "HEEG", "WAT": "WAT", "MYT": "MYT", "CLT": "CLT", "EDT": "EDT", "LHST": "LHST", "HNCU": "HNCU", "HADT": "HADT", "CHAST": "CHAST", "ACWST": "ACWST", "ACWDT": "ACWDT", "HKT": "HKT", "WAST": "WAST", "GFT": "GFT", "AKST": "AKST", "WIB": "WIB", "EAT": "EAT", "CHADT": "CHADT", "WART": "WART", "AWST": "AWST", "SGT": "SGT", "ECT": "ECT", "JST": "JST", "AST": "AST", "HNT": "HNT", "AEST": "AEST", "MST": "MST", "ARST": "ARST", "GYT": "GYT", "IST": "IST", "GMT": "GMT"}, + } +} + +// Locale returns the current translators string locale +func (fur *fur_IT) Locale() string { + return fur.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fur_IT' +func (fur *fur_IT) PluralsCardinal() []locales.PluralRule { + return fur.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fur_IT' +func (fur *fur_IT) PluralsOrdinal() []locales.PluralRule { + return fur.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fur_IT' +func (fur *fur_IT) PluralsRange() []locales.PluralRule { + return fur.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fur_IT' +func (fur *fur_IT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fur_IT' +func (fur *fur_IT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fur_IT' +func (fur *fur_IT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fur *fur_IT) MonthAbbreviated(month time.Month) string { + return fur.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fur *fur_IT) MonthsAbbreviated() []string { + return fur.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fur *fur_IT) MonthNarrow(month time.Month) string { + return fur.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fur *fur_IT) MonthsNarrow() []string { + return fur.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fur *fur_IT) MonthWide(month time.Month) string { + return fur.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fur *fur_IT) MonthsWide() []string { + return fur.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fur *fur_IT) WeekdayAbbreviated(weekday time.Weekday) string { + return fur.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fur *fur_IT) WeekdaysAbbreviated() []string { + return fur.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fur *fur_IT) WeekdayNarrow(weekday time.Weekday) string { + return fur.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fur *fur_IT) WeekdaysNarrow() []string { + return fur.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fur *fur_IT) WeekdayShort(weekday time.Weekday) string { + return fur.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fur *fur_IT) WeekdaysShort() []string { + return fur.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fur *fur_IT) WeekdayWide(weekday time.Weekday) string { + return fur.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fur *fur_IT) WeekdaysWide() []string { + return fur.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fur_IT' and handles both Whole and Real numbers based on 'v' +func (fur *fur_IT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fur.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fur_IT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fur *fur_IT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fur.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fur.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fur.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fur_IT' +func (fur *fur_IT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fur.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fur.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fur.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, fur.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fur_IT' +// in accounting notation. +func (fur *fur_IT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fur.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fur.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, fur.currencyNegativePrefix[j]) + } + + b = append(b, fur.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fur.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fur.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fur_IT' +func (fur *fur_IT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fur_IT' +func (fur *fur_IT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fur_IT' +func (fur *fur_IT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + b = append(b, fur.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x61, 0x6c}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fur_IT' +func (fur *fur_IT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fur.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + b = append(b, fur.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x61, 0x6c}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fur_IT' +func (fur *fur_IT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fur_IT' +func (fur *fur_IT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fur_IT' +func (fur *fur_IT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fur_IT' +func (fur *fur_IT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fur.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fur_IT/fur_IT_test.go b/vendor/github.com/go-playground/locales/fur_IT/fur_IT_test.go new file mode 100644 index 0000000000..331976e6d1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fur_IT/fur_IT_test.go @@ -0,0 +1,1120 @@ +package fur_IT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fur_IT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fy/fy.go b/vendor/github.com/go-playground/locales/fy/fy.go new file mode 100644 index 0000000000..80a6bc7440 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fy/fy.go @@ -0,0 +1,606 @@ +package fy + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fy struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fy' locale +func New() locales.Translator { + return &fy{ + locale: "fy", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "C$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJ$", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SI$", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: "( ", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mrt", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Jannewaris", "Febrewaris", "Maart", "April", "Maaie", "Juny", "July", "Augustus", "Septimber", "Oktober", "Novimber", "Desimber"}, + daysAbbreviated: []string{"si", "mo", "ti", "wo", "to", "fr", "so"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"si", "mo", "ti", "wo", "to", "fr", "so"}, + daysWide: []string{"snein", "moandei", "tiisdei", "woansdei", "tongersdei", "freed", "sneon"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"f.Kr.", "n.Kr."}, + erasNarrow: []string{"f.K.", "n.K."}, + erasWide: []string{"Foar Kristus", "nei Kristus"}, + timezones: map[string]string{"HKST": "Hongkongse simmertiid", "AKST": "Alaska-standerttiid", "UYST": "Uruguayaanske simmertiid", "WIT": "East-Yndonezyske tiid", "TMT": "Turkmeense standerttiid", "HNT": "Newfoundlânske-standerttiid", "PDT": "Pasifik-simmertiid", "ACWST": "Midden-Australyske westelijke standerttiid", "WEZ": "West-Europeeske standerttiid", "SRT": "Surinaamske tiid", "ADT": "Atlantic-simmertiid", "ACDT": "Midden-Australyske simmertiid", "GFT": "Frâns-Guyaanske tiid", "OEZ": "East-Europeeske standerttiid", "HEEG": "East-Groenlânske simmertiid", "BOT": "Boliviaanske tiid", "NZST": "Nij-Seelânske standerttiid", "AST": "Atlantic-standerttiid", "WART": "West-Argentynske standerttiid", "WAST": "West-Afrikaanske simmertiid", "GYT": "Guyaanske tiid", "EAT": "East-Afrikaanske tiid", "WIB": "West-Yndonezyske tiid", "MEZ": "Midden-Europeeske standerttiid", "MYT": "Maleisyske tiid", "WARST": "West-Argentynske simmertiid", "ARST": "Argentynske simmertiid", "HEPM": "Saint Pierre en Miquelon-simmertiid", "LHST": "Lord Howe-eilânske standerttiid", "HNCU": "Kubaanske standerttiid", "HNNOMX": "HNNOMX", "BT": "Bhutaanske tiid", "∅∅∅": "Azoren-simmertiid", "CAT": "Sintraal-Afrikaanske tiid", "HKT": "Hongkongse standerttiid", "OESZ": "East-Europeeske simmertiid", "WAT": "West-Afrikaanske standerttiid", "SGT": "Singaporese standerttiid", "CLST": "Sileenske simmertiid", "HNOG": "West-Groenlânske standerttiid", "EST": "Eastern-standerttiid", "HENOMX": "HENOMX", "AKDT": "Alaska-simmertiid", "HNPM": "Saint Pierre en Miquelon-standerttiid", "HEPMX": "HEPMX", "CDT": "Central-simmertiid", "JST": "Japanske standerttiid", "CLT": "Sileenske standerttiid", "COT": "Kolombiaanske standerttiid", "HNEG": "East-Groenlânske standerttiid", "MST": "Mountain-standerttiid", "SAST": "Sûd-Afrikaanske tiid", "HNPMX": "HNPMX", "ECT": "Ecuadoraanske tiid", "NZDT": "Nij-Seelânske simmertiid", "COST": "Kolombiaanske simmertiid", "WITA": "Sintraal-Yndonezyske tiid", "MDT": "Mountain-simmertiid", "AWDT": "West-Australyske simmertiid", "ACWDT": "Midden-Australyske westelijke simmertiid", "HAT": "Newfoundlânske-simmertiid", "HECU": "Kubaanske simmertiid", "AEST": "East-Australyske standerttiid", "ChST": "Chamorro-tiid", "UYT": "Uruguayaanske standerttiid", "ART": "Argentynske standerttiid", "EDT": "Eastern-simmertiid", "AEDT": "East-Australyske simmertiid", "IST": "Yndiaaske tiid", "HEOG": "West-Groenlânske simmertiid", "CHAST": "Chatham standerttiid", "CHADT": "Chatham simmertiid", "HAST": "Hawaii-Aleoetyske standerttiid", "WESZ": "West-Europeeske simmertiid", "LHDT": "Lord Howe-eilânske simmertiid", "CST": "Central-standerttiid", "AWST": "West-Australyske standerttiid", "VET": "Fenezolaanske tiid", "JDT": "Japanske simmertiid", "GMT": "Greenwich Mean Time", "TMST": "Turkmeense simmertiid", "ACST": "Midden-Australyske standerttiid", "PST": "Pasifik-standerttiid", "HADT": "Hawaii-Aleoetyske simmertiid", "MESZ": "Midden-Europeeske simmertiid"}, + } +} + +// Locale returns the current translators string locale +func (fy *fy) Locale() string { + return fy.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fy' +func (fy *fy) PluralsCardinal() []locales.PluralRule { + return fy.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fy' +func (fy *fy) PluralsOrdinal() []locales.PluralRule { + return fy.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fy' +func (fy *fy) PluralsRange() []locales.PluralRule { + return fy.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fy' +func (fy *fy) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fy' +func (fy *fy) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fy' +func (fy *fy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fy *fy) MonthAbbreviated(month time.Month) string { + return fy.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fy *fy) MonthsAbbreviated() []string { + return fy.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fy *fy) MonthNarrow(month time.Month) string { + return fy.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fy *fy) MonthsNarrow() []string { + return fy.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fy *fy) MonthWide(month time.Month) string { + return fy.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fy *fy) MonthsWide() []string { + return fy.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fy *fy) WeekdayAbbreviated(weekday time.Weekday) string { + return fy.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fy *fy) WeekdaysAbbreviated() []string { + return fy.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fy *fy) WeekdayNarrow(weekday time.Weekday) string { + return fy.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fy *fy) WeekdaysNarrow() []string { + return fy.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fy *fy) WeekdayShort(weekday time.Weekday) string { + return fy.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fy *fy) WeekdaysShort() []string { + return fy.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fy *fy) WeekdayWide(weekday time.Weekday) string { + return fy.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fy *fy) WeekdaysWide() []string { + return fy.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fy' and handles both Whole and Real numbers based on 'v' +func (fy *fy) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fy' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fy *fy) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fy.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fy.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fy' +func (fy *fy) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fy.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fy.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fy.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, fy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fy' +// in accounting notation. +func (fy *fy) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fy.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fy.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, fy.currencyNegativePrefix[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fy.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fy.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fy.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fy' +func (fy *fy) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fy' +func (fy *fy) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fy.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fy' +func (fy *fy) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fy' +func (fy *fy) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fy.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fy' +func (fy *fy) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fy' +func (fy *fy) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fy' +func (fy *fy) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fy' +func (fy *fy) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fy.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fy/fy_test.go b/vendor/github.com/go-playground/locales/fy/fy_test.go new file mode 100644 index 0000000000..281921850e --- /dev/null +++ b/vendor/github.com/go-playground/locales/fy/fy_test.go @@ -0,0 +1,1120 @@ +package fy + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fy" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/fy_NL/fy_NL.go b/vendor/github.com/go-playground/locales/fy_NL/fy_NL.go new file mode 100644 index 0000000000..1306eed30e --- /dev/null +++ b/vendor/github.com/go-playground/locales/fy_NL/fy_NL.go @@ -0,0 +1,606 @@ +package fy_NL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type fy_NL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'fy_NL' locale +func New() locales.Translator { + return &fy_NL{ + locale: "fy_NL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: "( ", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mrt", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Jannewaris", "Febrewaris", "Maart", "April", "Maaie", "Juny", "July", "Augustus", "Septimber", "Oktober", "Novimber", "Desimber"}, + daysAbbreviated: []string{"si", "mo", "ti", "wo", "to", "fr", "so"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"si", "mo", "ti", "wo", "to", "fr", "so"}, + daysWide: []string{"snein", "moandei", "tiisdei", "woansdei", "tongersdei", "freed", "sneon"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"f.Kr.", "n.Kr."}, + erasNarrow: []string{"f.K.", "n.K."}, + erasWide: []string{"Foar Kristus", "nei Kristus"}, + timezones: map[string]string{"HEPMX": "HEPMX", "LHDT": "Lord Howe-eilânske simmertiid", "WAT": "West-Afrikaanske standerttiid", "UYST": "Uruguayaanske simmertiid", "WESZ": "West-Europeeske simmertiid", "MYT": "Maleisyske tiid", "HEOG": "West-Groenlânske simmertiid", "MDT": "Macause simmertiid", "HEPM": "Saint Pierre en Miquelon-simmertiid", "UYT": "Uruguayaanske standerttiid", "BOT": "Boliviaanske tiid", "SGT": "Singaporese standerttiid", "ACWDT": "Midden-Australyske westelijke simmertiid", "IST": "Yndiaaske tiid", "CLT": "Sileenske standerttiid", "CLST": "Sileenske simmertiid", "ART": "Argentynske standerttiid", "AKST": "Alaska-standerttiid", "HNCU": "Kubaanske standerttiid", "∅∅∅": "Brazyljaanske simmertiid", "HNOG": "West-Groenlânske standerttiid", "ARST": "Argentynske simmertiid", "HKST": "Hongkongse simmertiid", "HENOMX": "HENOMX", "AEDT": "East-Australyske simmertiid", "ECT": "Ecuadoraanske tiid", "MESZ": "Midden-Europeeske simmertiid", "HEEG": "East-Groenlânske simmertiid", "GFT": "Frâns-Guyaanske tiid", "GYT": "Guyaanske tiid", "HADT": "Hawaii-Aleoetyske simmertiid", "EST": "Eastern-standerttiid", "JDT": "Japanske simmertiid", "WARST": "West-Argentynske simmertiid", "ACDT": "Midden-Australyske simmertiid", "WITA": "Sintraal-Yndonezyske tiid", "CHADT": "Chatham simmertiid", "ACWST": "Midden-Australyske westelijke standerttiid", "TMT": "Turkmeense standerttiid", "HNT": "Newfoundlânske-standerttiid", "GMT": "Greenwich Mean Time", "ADT": "Atlantic-simmertiid", "VET": "Fenezolaanske tiid", "EDT": "Eastern-simmertiid", "CDT": "Central-simmertiid", "AWST": "West-Australyske standerttiid", "MST": "Macause standerttiid", "EAT": "East-Afrikaanske tiid", "NZDT": "Nij-Seelânske simmertiid", "OEZ": "East-Europeeske standerttiid", "BT": "Bhutaanske tiid", "HNPMX": "HNPMX", "WEZ": "West-Europeeske standerttiid", "AST": "Atlantic-standerttiid", "HNPM": "Saint Pierre en Miquelon-standerttiid", "CST": "Central-standerttiid", "WART": "West-Argentynske standerttiid", "NZST": "Nij-Seelânske standerttiid", "CAT": "Sintraal-Afrikaanske tiid", "WAST": "West-Afrikaanske simmertiid", "ACST": "Midden-Australyske standerttiid", "AEST": "East-Australyske standerttiid", "SAST": "Sûd-Afrikaanske tiid", "WIB": "West-Yndonezyske tiid", "WIT": "East-Yndonezyske tiid", "LHST": "Lord Howe-eilânske standerttiid", "OESZ": "East-Europeeske simmertiid", "HNNOMX": "HNNOMX", "COST": "Kolombiaanske simmertiid", "HNEG": "East-Groenlânske standerttiid", "SRT": "Surinaamske tiid", "AWDT": "West-Australyske simmertiid", "JST": "Japanske standerttiid", "PDT": "Pasifik-simmertiid", "COT": "Kolombiaanske standerttiid", "MEZ": "Midden-Europeeske standerttiid", "HKT": "Hongkongse standerttiid", "AKDT": "Alaska-simmertiid", "CHAST": "Chatham standerttiid", "PST": "Pasifik-standerttiid", "TMST": "Turkmeense simmertiid", "HAT": "Newfoundlânske-simmertiid", "ChST": "Chamorro-tiid", "HECU": "Kubaanske simmertiid", "HAST": "Hawaii-Aleoetyske standerttiid"}, + } +} + +// Locale returns the current translators string locale +func (fy *fy_NL) Locale() string { + return fy.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'fy_NL' +func (fy *fy_NL) PluralsCardinal() []locales.PluralRule { + return fy.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'fy_NL' +func (fy *fy_NL) PluralsOrdinal() []locales.PluralRule { + return fy.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'fy_NL' +func (fy *fy_NL) PluralsRange() []locales.PluralRule { + return fy.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'fy_NL' +func (fy *fy_NL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'fy_NL' +func (fy *fy_NL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'fy_NL' +func (fy *fy_NL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (fy *fy_NL) MonthAbbreviated(month time.Month) string { + return fy.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (fy *fy_NL) MonthsAbbreviated() []string { + return fy.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (fy *fy_NL) MonthNarrow(month time.Month) string { + return fy.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (fy *fy_NL) MonthsNarrow() []string { + return fy.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (fy *fy_NL) MonthWide(month time.Month) string { + return fy.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (fy *fy_NL) MonthsWide() []string { + return fy.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (fy *fy_NL) WeekdayAbbreviated(weekday time.Weekday) string { + return fy.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (fy *fy_NL) WeekdaysAbbreviated() []string { + return fy.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (fy *fy_NL) WeekdayNarrow(weekday time.Weekday) string { + return fy.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (fy *fy_NL) WeekdaysNarrow() []string { + return fy.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (fy *fy_NL) WeekdayShort(weekday time.Weekday) string { + return fy.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (fy *fy_NL) WeekdaysShort() []string { + return fy.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (fy *fy_NL) WeekdayWide(weekday time.Weekday) string { + return fy.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (fy *fy_NL) WeekdaysWide() []string { + return fy.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'fy_NL' and handles both Whole and Real numbers based on 'v' +func (fy *fy_NL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'fy_NL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (fy *fy_NL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fy.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, fy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, fy.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'fy_NL' +func (fy *fy_NL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fy.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fy.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fy.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, fy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'fy_NL' +// in accounting notation. +func (fy *fy_NL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := fy.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, fy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, fy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fy.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, fy.currencyNegativePrefix[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(fy.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, fy.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, fy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, fy.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'fy_NL' +func (fy *fy_NL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'fy_NL' +func (fy *fy_NL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fy.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'fy_NL' +func (fy *fy_NL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'fy_NL' +func (fy *fy_NL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, fy.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, fy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'fy_NL' +func (fy *fy_NL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'fy_NL' +func (fy *fy_NL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'fy_NL' +func (fy *fy_NL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'fy_NL' +func (fy *fy_NL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, fy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, fy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := fy.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/fy_NL/fy_NL_test.go b/vendor/github.com/go-playground/locales/fy_NL/fy_NL_test.go new file mode 100644 index 0000000000..82a0c768e7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/fy_NL/fy_NL_test.go @@ -0,0 +1,1120 @@ +package fy_NL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "fy_NL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ga/ga.go b/vendor/github.com/go-playground/locales/ga/ga.go new file mode 100644 index 0000000000..8cf684608f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ga/ga.go @@ -0,0 +1,645 @@ +package ga + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ga struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ga' locale +func New() locales.Translator { + return &ga{ + locale: "ga", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ean", "Feabh", "Márta", "Aib", "Beal", "Meith", "Iúil", "Lún", "MFómh", "DFómh", "Samh", "Noll"}, + monthsNarrow: []string{"", "E", "F", "M", "A", "B", "M", "I", "L", "M", "D", "S", "N"}, + monthsWide: []string{"", "Eanáir", "Feabhra", "Márta", "Aibreán", "Bealtaine", "Meitheamh", "Iúil", "Lúnasa", "Meán Fómhair", "Deireadh Fómhair", "Samhain", "Nollaig"}, + daysAbbreviated: []string{"Domh", "Luan", "Máirt", "Céad", "Déar", "Aoine", "Sath"}, + daysNarrow: []string{"D", "L", "M", "C", "D", "A", "S"}, + daysShort: []string{"Do", "Lu", "Má", "Cé", "Dé", "Ao", "Sa"}, + daysWide: []string{"Dé Domhnaigh", "Dé Luain", "Dé Máirt", "Dé Céadaoin", "Déardaoin", "Dé hAoine", "Dé Sathairn"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"RC", "AD"}, + erasNarrow: []string{"RC", "AD"}, + erasWide: []string{"Roimh Chríost", "Anno Domini"}, + timezones: map[string]string{"CHAST": "Am Caighdeánach Chatham", "SRT": "Am Shuranam", "CDT": "Am Samhraidh Lárnach", "SGT": "Am Caighdeánach Shingeapór", "HADT": "Am Samhraidh Haváí-Ailiúit", "CAT": "Am Lár na hAfraice", "MESZ": "Am Samhraidh Lár na hEorpa", "ACST": "Am Caighdeánach Lár na hAstráile", "ACDT": "Am Samhraidh Lár na hAstráile", "NZST": "Am Caighdeánach na Nua-Shéalainne", "VET": "Am Veiniséala", "CLT": "Am Caighdeánach na Sile", "EST": "Am Caighdeánach an Oirthir", "GFT": "Am Ghuáin na Fraince", "LHST": "Am Caighdeánach Lord Howe", "HNPMX": "Am Caighdeánach Meicsiceach an Aigéin Chiúin", "JDT": "Am Samhraidh na Seapáine", "HEEG": "Am Samhraidh Oirthear na Graonlainne", "HEPM": "Am Samhraidh Saint-Pierre-et-Miquelon", "WART": "Am Caighdeánach Iarthar na hAirgintíne", "ACWDT": "Am Samhraidh Mheániarthar na hAstráile", "TMST": "Am Samhraidh na Tuircméanastáine", "COST": "Am Samhraidh na Colóime", "UYST": "Am Samhraidh Uragua", "CHADT": "Am Samhraidh Chatham", "WEZ": "Am Caighdeánach Iarthar na hEorpa", "TMT": "Am Caighdeánach na Tuircméanastáine", "HNEG": "Am Caighdeánach Oirthear na Graonlainne", "AEDT": "Am Samhraidh Oirthear na hAstráile", "WAT": "Am Caighdeánach Iarthar na hAfraice", "EDT": "Am Samhraidh an Oirthir", "HENOMX": "Am Samhraidh Iarthuaisceart Mheicsiceo", "AWDT": "Am Samhraidh Iarthar na hAstráile", "MEZ": "Am Caighdeánach Lár na hEorpa", "JST": "Am Caighdeánach na Seapáine", "AST": "Am Caighdeánach an Atlantaigh", "MYT": "Am na Malaeisia", "AKDT": "Am Samhraidh Alasca", "PDT": "Am Samhraidh an Aigéin Chiúin", "HNNOMX": "Am Caighdeánach Iarthuaisceart Mheicsiceo", "ART": "Am Caighdeánach na hAirgintíne", "COT": "Am Caighdeánach na Colóime", "AEST": "Am Caighdeánach Oirthear na hAstráile", "ChST": "Am Caighdeánach Seamórach", "LHDT": "Am Samhraidh Lord Howe", "CST": "Am Caighdeánach Lárnach", "AWST": "Am Caighdeánach Iarthar na hAstráile", "HAST": "Am Caighdeánach Haváí-Ailiúit", "HKST": "Am Samhraidh Hong Cong", "WIT": "Am Oirthear na hIndinéise", "PST": "Am Caighdeánach an Aigéin Chiúin", "ACWST": "Am Caighdeánach Mheániarthar na hAstráile", "ADT": "Am Samhraidh an Atlantaigh", "WESZ": "Am Samhraidh Iarthar na hEorpa", "GMT": "Meán-Am Greenwich", "HNOG": "Am Caighdeánach Iarthar na Graonlainne", "HEOG": "Am Samhraidh Iarthar na Graonlainne", "ARST": "Am Samhraidh na hAirgintíne", "HNT": "Am Caighdeánach Thalamh an Éisc", "AKST": "Am Caighdeánach Alasca", "HNPM": "Am Caighdeánach Saint-Pierre-et-Miquelon", "GYT": "Am na Guáine", "EAT": "Am Oirthear na hAfraice", "ECT": "Am Eacuadór", "∅∅∅": "Am Samhraidh na hAmasóine", "MST": "Am Caighdeánach Mhacao", "WAST": "Am Samhraidh Iarthar na hAfraice", "HKT": "Am Caighdeánach Hong Cong", "WITA": "Am Lár na hIndinéise", "WIB": "Am Iarthar na hIndinéise", "BOT": "Am na Bolaive", "NZDT": "Am Samhraidh na Nua-Shéalainne", "WARST": "Am Samhraidh Iarthar na hAirgintíne", "CLST": "Am Samhraidh na Sile", "MDT": "Am Samhraidh Mhacao", "HAT": "Am Samhraidh Thalamh an Éisc", "SAST": "Am Caighdeánach na hAfraice Theas", "HNCU": "Am Caighdeánach Chúba", "HECU": "Am Samhraidh Chúba", "IST": "Am Caighdeánach na hIndia", "OEZ": "Am Caighdeánach Oirthear na hEorpa", "OESZ": "Am Samhraidh Oirthear na hEorpa", "BT": "Am na Bútáine", "UYT": "Am Caighdeánach Uragua", "HEPMX": "Am Samhraidh Meicsiceach an Aigéin Chiúin"}, + } +} + +// Locale returns the current translators string locale +func (ga *ga) Locale() string { + return ga.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ga' +func (ga *ga) PluralsCardinal() []locales.PluralRule { + return ga.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ga' +func (ga *ga) PluralsOrdinal() []locales.PluralRule { + return ga.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ga' +func (ga *ga) PluralsRange() []locales.PluralRule { + return ga.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ga' +func (ga *ga) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n >= 3 && n <= 6 { + return locales.PluralRuleFew + } else if n >= 7 && n <= 10 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ga' +func (ga *ga) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ga' +func (ga *ga) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ga.CardinalPluralRule(num1, v1) + end := ga.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ga *ga) MonthAbbreviated(month time.Month) string { + return ga.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ga *ga) MonthsAbbreviated() []string { + return ga.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ga *ga) MonthNarrow(month time.Month) string { + return ga.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ga *ga) MonthsNarrow() []string { + return ga.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ga *ga) MonthWide(month time.Month) string { + return ga.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ga *ga) MonthsWide() []string { + return ga.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ga *ga) WeekdayAbbreviated(weekday time.Weekday) string { + return ga.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ga *ga) WeekdaysAbbreviated() []string { + return ga.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ga *ga) WeekdayNarrow(weekday time.Weekday) string { + return ga.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ga *ga) WeekdaysNarrow() []string { + return ga.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ga *ga) WeekdayShort(weekday time.Weekday) string { + return ga.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ga *ga) WeekdaysShort() []string { + return ga.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ga *ga) WeekdayWide(weekday time.Weekday) string { + return ga.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ga *ga) WeekdaysWide() []string { + return ga.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ga' and handles both Whole and Real numbers based on 'v' +func (ga *ga) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ga.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ga.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ga.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ga' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ga *ga) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ga.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ga.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ga.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ga' +func (ga *ga) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ga.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ga.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ga.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ga.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ga.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ga' +// in accounting notation. +func (ga *ga) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ga.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ga.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ga.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ga.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ga.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ga.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ga' +func (ga *ga) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ga' +func (ga *ga) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ga.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ga' +func (ga *ga) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ga.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ga' +func (ga *ga) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ga.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ga.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ga' +func (ga *ga) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ga.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ga' +func (ga *ga) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ga.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ga.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ga' +func (ga *ga) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ga.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ga.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ga' +func (ga *ga) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ga.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ga.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ga.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ga/ga_test.go b/vendor/github.com/go-playground/locales/ga/ga_test.go new file mode 100644 index 0000000000..dbef821787 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ga/ga_test.go @@ -0,0 +1,1120 @@ +package ga + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ga" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ga_IE/ga_IE.go b/vendor/github.com/go-playground/locales/ga_IE/ga_IE.go new file mode 100644 index 0000000000..29b00c8328 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ga_IE/ga_IE.go @@ -0,0 +1,645 @@ +package ga_IE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ga_IE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ga_IE' locale +func New() locales.Translator { + return &ga_IE{ + locale: "ga_IE", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 3, 4, 5, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ean", "Feabh", "Márta", "Aib", "Beal", "Meith", "Iúil", "Lún", "MFómh", "DFómh", "Samh", "Noll"}, + monthsNarrow: []string{"", "E", "F", "M", "A", "B", "M", "I", "L", "M", "D", "S", "N"}, + monthsWide: []string{"", "Eanáir", "Feabhra", "Márta", "Aibreán", "Bealtaine", "Meitheamh", "Iúil", "Lúnasa", "Meán Fómhair", "Deireadh Fómhair", "Samhain", "Nollaig"}, + daysAbbreviated: []string{"Domh", "Luan", "Máirt", "Céad", "Déar", "Aoine", "Sath"}, + daysNarrow: []string{"D", "L", "M", "C", "D", "A", "S"}, + daysShort: []string{"Do", "Lu", "Má", "Cé", "Dé", "Ao", "Sa"}, + daysWide: []string{"Dé Domhnaigh", "Dé Luain", "Dé Máirt", "Dé Céadaoin", "Déardaoin", "Dé hAoine", "Dé Sathairn"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"RC", "AD"}, + erasNarrow: []string{"RC", "AD"}, + erasWide: []string{"Roimh Chríost", "Anno Domini"}, + timezones: map[string]string{"VET": "Am Veiniséala", "ADT": "Am Samhraidh an Atlantaigh", "GMT": "Meán-Am Greenwich", "ART": "Am Caighdeánach na hAirgintíne", "ACWDT": "Am Samhraidh Mheániarthar na hAstráile", "MEZ": "Am Caighdeánach Lár na hEorpa", "WARST": "Am Samhraidh Iarthar na hAirgintíne", "WAT": "Am Caighdeánach Iarthar na hAfraice", "EDT": "Am Samhraidh an Oirthir", "HNEG": "Am Caighdeánach Oirthear na Graonlainne", "HNPMX": "Am Caighdeánach Meicsiceach an Aigéin Chiúin", "EAT": "Am Oirthear na hAfraice", "CST": "Am Caighdeánach Lárnach", "NZST": "Am Caighdeánach na Nua-Shéalainne", "TMST": "Am Samhraidh na Tuircméanastáine", "LHST": "Am Caighdeánach Lord Howe", "CLT": "Am Caighdeánach na Sile", "ChST": "Am Caighdeánach Seamórach", "ACDT": "Am Samhraidh Lár na hAstráile", "HENOMX": "Am Samhraidh Iarthuaisceart Mheicsiceo", "AKDT": "Am Samhraidh Alasca", "HEPM": "Am Samhraidh Saint-Pierre-et-Miquelon", "LHDT": "Am Samhraidh Lord Howe", "GYT": "Am na Guáine", "CHAST": "Am Caighdeánach Chatham", "CHADT": "Am Samhraidh Chatham", "SRT": "Am Shuranam", "HNCU": "Am Caighdeánach Chúba", "JST": "Am Caighdeánach na Seapáine", "HNOG": "Am Caighdeánach Iarthar na Graonlainne", "CAT": "Am Lár na hAfraice", "HEOG": "Am Samhraidh Iarthar na Graonlainne", "OEZ": "Am Caighdeánach Oirthear na hEorpa", "ARST": "Am Samhraidh na hAirgintíne", "HAST": "Am Caighdeánach Haváí-Ailiúit", "HADT": "Am Samhraidh Haváí-Ailiúit", "AST": "Am Caighdeánach an Atlantaigh", "COST": "Am Samhraidh na Colóime", "AKST": "Am Caighdeánach Alasca", "AEDT": "Am Samhraidh Oirthear na hAstráile", "ECT": "Am Eacuadór", "IST": "Am Caighdeánach na hIndia", "BT": "Am na Bútáine", "AEST": "Am Caighdeánach Oirthear na hAstráile", "CDT": "Am Samhraidh Lárnach", "PDT": "Am Samhraidh an Aigéin Chiúin", "HNNOMX": "Am Caighdeánach Iarthuaisceart Mheicsiceo", "NZDT": "Am Samhraidh na Nua-Shéalainne", "JDT": "Am Samhraidh na Seapáine", "WEZ": "Am Caighdeánach Iarthar na hEorpa", "WART": "Am Caighdeánach Iarthar na hAirgintíne", "TMT": "Am Caighdeánach na Tuircméanastáine", "HKST": "Am Samhraidh Hong Cong", "AWST": "Am Caighdeánach Iarthar na hAstráile", "PST": "Am Caighdeánach an Aigéin Chiúin", "WIB": "Am Iarthar na hIndinéise", "COT": "Am Caighdeánach na Colóime", "UYST": "Am Samhraidh Uragua", "MYT": "Am na Malaeisia", "BOT": "Am na Bolaive", "∅∅∅": "Am Samhraidh na hAmasóine", "HNPM": "Am Caighdeánach Saint-Pierre-et-Miquelon", "SAST": "Am Caighdeánach na hAfraice Theas", "HEPMX": "Am Samhraidh Meicsiceach an Aigéin Chiúin", "GFT": "Am Ghuáin na Fraince", "WITA": "Am Lár na hIndinéise", "EST": "Am Caighdeánach an Oirthir", "HKT": "Am Caighdeánach Hong Cong", "ACST": "Am Caighdeánach Lár na hAstráile", "UYT": "Am Caighdeánach Uragua", "CLST": "Am Samhraidh na Sile", "MST": "Am Caighdeánach Mhacao", "MESZ": "Am Samhraidh Lár na hEorpa", "HAT": "Am Samhraidh Thalamh an Éisc", "AWDT": "Am Samhraidh Iarthar na hAstráile", "SGT": "Am Caighdeánach Shingeapór", "WESZ": "Am Samhraidh Iarthar na hEorpa", "WAST": "Am Samhraidh Iarthar na hAfraice", "HEEG": "Am Samhraidh Oirthear na Graonlainne", "HECU": "Am Samhraidh Chúba", "ACWST": "Am Caighdeánach Mheániarthar na hAstráile", "OESZ": "Am Samhraidh Oirthear na hEorpa", "WIT": "Am Oirthear na hIndinéise", "MDT": "Am Samhraidh Mhacao", "HNT": "Am Caighdeánach Thalamh an Éisc"}, + } +} + +// Locale returns the current translators string locale +func (ga *ga_IE) Locale() string { + return ga.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ga_IE' +func (ga *ga_IE) PluralsCardinal() []locales.PluralRule { + return ga.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ga_IE' +func (ga *ga_IE) PluralsOrdinal() []locales.PluralRule { + return ga.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ga_IE' +func (ga *ga_IE) PluralsRange() []locales.PluralRule { + return ga.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ga_IE' +func (ga *ga_IE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } else if n >= 3 && n <= 6 { + return locales.PluralRuleFew + } else if n >= 7 && n <= 10 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ga_IE' +func (ga *ga_IE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ga_IE' +func (ga *ga_IE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ga.CardinalPluralRule(num1, v1) + end := ga.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ga *ga_IE) MonthAbbreviated(month time.Month) string { + return ga.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ga *ga_IE) MonthsAbbreviated() []string { + return ga.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ga *ga_IE) MonthNarrow(month time.Month) string { + return ga.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ga *ga_IE) MonthsNarrow() []string { + return ga.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ga *ga_IE) MonthWide(month time.Month) string { + return ga.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ga *ga_IE) MonthsWide() []string { + return ga.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ga *ga_IE) WeekdayAbbreviated(weekday time.Weekday) string { + return ga.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ga *ga_IE) WeekdaysAbbreviated() []string { + return ga.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ga *ga_IE) WeekdayNarrow(weekday time.Weekday) string { + return ga.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ga *ga_IE) WeekdaysNarrow() []string { + return ga.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ga *ga_IE) WeekdayShort(weekday time.Weekday) string { + return ga.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ga *ga_IE) WeekdaysShort() []string { + return ga.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ga *ga_IE) WeekdayWide(weekday time.Weekday) string { + return ga.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ga *ga_IE) WeekdaysWide() []string { + return ga.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ga_IE' and handles both Whole and Real numbers based on 'v' +func (ga *ga_IE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ga.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ga.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ga.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ga_IE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ga *ga_IE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ga.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ga.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ga.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ga_IE' +func (ga *ga_IE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ga.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ga.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ga.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ga.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ga.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ga_IE' +// in accounting notation. +func (ga *ga_IE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ga.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ga.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ga.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ga.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ga.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ga.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ga_IE' +func (ga *ga_IE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ga_IE' +func (ga *ga_IE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ga.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ga_IE' +func (ga *ga_IE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ga.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ga_IE' +func (ga *ga_IE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ga.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ga.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ga_IE' +func (ga *ga_IE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ga.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ga_IE' +func (ga *ga_IE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ga.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ga.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ga_IE' +func (ga *ga_IE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ga.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ga.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ga_IE' +func (ga *ga_IE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ga.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ga.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ga.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ga_IE/ga_IE_test.go b/vendor/github.com/go-playground/locales/ga_IE/ga_IE_test.go new file mode 100644 index 0000000000..3d16331125 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ga_IE/ga_IE_test.go @@ -0,0 +1,1120 @@ +package ga_IE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ga_IE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gd/gd.go b/vendor/github.com/go-playground/locales/gd/gd.go new file mode 100644 index 0000000000..d3582a0e88 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gd/gd.go @@ -0,0 +1,599 @@ +package gd + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gd struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gd' locale +func New() locales.Translator { + return &gd{ + locale: "gd", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Faoi", "Gearr", "Màrt", "Gibl", "Cèit", "Ògmh", "Iuch", "Lùna", "Sult", "Dàmh", "Samh", "Dùbh"}, + monthsNarrow: []string{"", "F", "G", "M", "G", "C", "Ò", "I", "L", "S", "D", "S", "D"}, + monthsWide: []string{"", "dhen Fhaoilleach", "dhen Ghearran", "dhen Mhàrt", "dhen Ghiblean", "dhen Chèitean", "dhen Ògmhios", "dhen Iuchar", "dhen Lùnastal", "dhen t-Sultain", "dhen Dàmhair", "dhen t-Samhain", "dhen Dùbhlachd"}, + daysAbbreviated: []string{"DiD", "DiL", "DiM", "DiC", "Dia", "Dih", "DiS"}, + daysNarrow: []string{"D", "L", "M", "C", "A", "H", "S"}, + daysShort: []string{"Dò", "Lu", "Mà", "Ci", "Da", "hA", "Sa"}, + daysWide: []string{"DiDòmhnaich", "DiLuain", "DiMàirt", "DiCiadain", "DiarDaoin", "DihAoine", "DiSathairne"}, + periodsAbbreviated: []string{"m", "f"}, + periodsNarrow: []string{"m", "f"}, + periodsWide: []string{"m", "f"}, + erasAbbreviated: []string{"RC", "AD"}, + erasNarrow: []string{"R", "A"}, + erasWide: []string{"Ro Chrìosta", "An dèidh Chrìosta"}, + timezones: map[string]string{"HNCU": "Bun-àm Cùba", "CHAST": "Bun-àm Chatham", "HEOG": "Tìde samhraidh na Graonlainn an Iar", "MST": "Bun-àm Macàthu", "WAST": "Tìde Samhraidh Afraga an Iar", "COT": "Bun-àm Coloimbia", "LHST": "Bun-àm Lord Howe", "GYT": "Àm Guidheàna", "ACWDT": "Tìde samhraidh Meadhan Astràilia an Iar", "OESZ": "Tìde samhraidh na Roinn-Eòrpa an Ear", "HNNOMX": "Bun-àm Mheagsago an Iar-thuath", "AEDT": "Tìde samhraidh Astràilia an Ear", "AWDT": "Tìde samhraidh Astràilia an Iar", "NZDT": "Tìde samhraidh Shealainn Nuaidh", "WART": "Bun-àm na h-Argantaine Siaraich", "AEST": "Bun-àm Astràilia an Ear", "SAST": "Àm Afraga a Deas", "OEZ": "Bun-àm na Roinn-Eòrpa an Ear", "TMST": "Tìde samhraidh Turcmanastàin", "HEPM": "Tìde Samhraidh Saint Pierre agus Miquelon", "WIB": "Àm nan Innd-Innse an Iar", "WIT": "Àm nan Innd-Innse an Ear", "PDT": "Tìde samhraidh a’ Chuain Sèimh", "MEZ": "Bun-àm Meadhan na Roinn-Eòrpa", "ADT": "Tìde samhraidh a’ Chuain Siar", "WARST": "Tìde samhraidh na h-Argantaine Siaraich", "UYT": "Bun-àm Uruguaidh", "HNPM": "Bun-àm Saint Pierre agus Miquelon", "HADT": "Tìde Samhraidh nan Eileanan Hawai’i ’s Aleutach", "IST": "Àm nan Innseachan", "ACWST": "Bun-àm Meadhan Astràilia an Iar", "MDT": "Tìde samhraidh Macàthu", "EDT": "Tìde samhraidh Aimeireaga a Tuath an Ear", "ACST": "Bun-àm Meadhan Astràilia", "CLT": "Bun-àm na Sile", "ARST": "Tìde samhraidh na h-Argantaine", "EST": "Bun-àm Aimeireaga a Tuath an Ear", "HKST": "Tìde samhraidh Hong Kong", "WEZ": "Bun-àm na Roinn-Eòrpa an Iar", "HENOMX": "Tìde samhraidh Mheagsago an Iar-thuath", "HNPMX": "Bun-àm a’ Chuain Sèimh Mheagsago", "CST": "Bun-àm Meadhan Aimeireaga a Tuath", "ECT": "Àm Eacuadoir", "JST": "Bun-àm na Seapaine", "JDT": "Tìde samhraidh na Seapaine", "TMT": "Bun-àm Turcmanastàin", "AWST": "Bun-àm Astràilia an Iar", "BOT": "Àm Boilibhia", "AST": "Bun-àm a’ Chuain Siar", "GMT": "Greenwich Mean Time", "ART": "Bun-àm na h-Argantaine", "COST": "Tìde samhraidh Coloimbia", "AKST": "Bun-àm Alaska", "LHDT": "Tìde samhraidh Lord Howe", "SGT": "Àm Singeapòr", "CAT": "Àm Meadhan Afraga", "MESZ": "Tìde samhraidh Meadhan na Roinn-Eòrpa", "WAT": "Bun-àm Afraga an Iar", "WITA": "Àm Meadhan nan Innd-Innse", "SRT": "Àm Suranaim", "HECU": "Tìde samhraidh Cùba", "PST": "Bun-àm a’ Chuain Sèimh", "NZST": "Bun-àm Shealainn Nuaidh", "MYT": "Àm Mhalaidhsea", "BT": "Àm Butàin", "HNOG": "Bun-àm na Graonlainn an Iar", "GFT": "Àm Guidheàna na Frainge", "UYST": "Tìde samhraidh Uruguaidh", "CHADT": "Tìde samhraidh Chatham", "∅∅∅": "Tìde samhraidh Amasoin", "CLST": "Tìde samhraidh na Sile", "HNT": "Bun-àm Talamh an Èisg", "EAT": "Àm Afraga an Ear", "ChST": "Àm Chamorro", "HAST": "Bun-àm nan Eileanan Hawai’i ’s Aleutach", "VET": "Àm na Bheiniseala", "HKT": "Bun-àm Hong Kong", "ACDT": "Tìde samhraidh Meadhan Astràilia", "HNEG": "Bun-àm na Graonlainn an Ear", "HEEG": "Tìde samhraidh na Graonlainn an Ear", "WESZ": "Tìde samhraidh na Roinn-Eòrpa an Iar", "HAT": "Tìde samhraidh Talamh an Èisg", "AKDT": "Tìde samhraidh Alaska", "HEPMX": "Tìde samhraidh a’ Chuain Sèimh Mheagsago", "CDT": "Tìde samhraidh Meadhan Aimeireaga a Tuath"}, + } +} + +// Locale returns the current translators string locale +func (gd *gd) Locale() string { + return gd.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gd' +func (gd *gd) PluralsCardinal() []locales.PluralRule { + return gd.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gd' +func (gd *gd) PluralsOrdinal() []locales.PluralRule { + return gd.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gd' +func (gd *gd) PluralsRange() []locales.PluralRule { + return gd.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gd' +func (gd *gd) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 11 { + return locales.PluralRuleOne + } else if n == 2 || n == 12 { + return locales.PluralRuleTwo + } else if (n >= 3 && n <= 10) || (n >= 13 && n <= 19) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gd' +func (gd *gd) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gd' +func (gd *gd) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gd *gd) MonthAbbreviated(month time.Month) string { + return gd.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gd *gd) MonthsAbbreviated() []string { + return gd.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gd *gd) MonthNarrow(month time.Month) string { + return gd.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gd *gd) MonthsNarrow() []string { + return gd.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gd *gd) MonthWide(month time.Month) string { + return gd.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gd *gd) MonthsWide() []string { + return gd.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gd *gd) WeekdayAbbreviated(weekday time.Weekday) string { + return gd.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gd *gd) WeekdaysAbbreviated() []string { + return gd.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gd *gd) WeekdayNarrow(weekday time.Weekday) string { + return gd.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gd *gd) WeekdaysNarrow() []string { + return gd.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gd *gd) WeekdayShort(weekday time.Weekday) string { + return gd.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gd *gd) WeekdaysShort() []string { + return gd.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gd *gd) WeekdayWide(weekday time.Weekday) string { + return gd.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gd *gd) WeekdaysWide() []string { + return gd.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gd' and handles both Whole and Real numbers based on 'v' +func (gd *gd) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gd.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gd' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gd *gd) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gd.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gd.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gd.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gd' +func (gd *gd) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gd.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, gd.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gd.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gd' +// in accounting notation. +func (gd *gd) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gd.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, gd.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gd.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, gd.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gd' +func (gd *gd) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gd' +func (gd *gd) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gd.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gd' +func (gd *gd) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x6d, 0x68}...) + b = append(b, []byte{0x20}...) + b = append(b, gd.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gd' +func (gd *gd) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gd.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x6d, 0x68}...) + b = append(b, []byte{0x20}...) + b = append(b, gd.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gd' +func (gd *gd) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gd' +func (gd *gd) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gd' +func (gd *gd) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gd' +func (gd *gd) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gd.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gd/gd_test.go b/vendor/github.com/go-playground/locales/gd/gd_test.go new file mode 100644 index 0000000000..5613fa1fd6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gd/gd_test.go @@ -0,0 +1,1120 @@ +package gd + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gd" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gd_GB/gd_GB.go b/vendor/github.com/go-playground/locales/gd_GB/gd_GB.go new file mode 100644 index 0000000000..268f38ece3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gd_GB/gd_GB.go @@ -0,0 +1,599 @@ +package gd_GB + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gd_GB struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gd_GB' locale +func New() locales.Translator { + return &gd_GB{ + locale: "gd_GB", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Faoi", "Gearr", "Màrt", "Gibl", "Cèit", "Ògmh", "Iuch", "Lùna", "Sult", "Dàmh", "Samh", "Dùbh"}, + monthsNarrow: []string{"", "F", "G", "M", "G", "C", "Ò", "I", "L", "S", "D", "S", "D"}, + monthsWide: []string{"", "dhen Fhaoilleach", "dhen Ghearran", "dhen Mhàrt", "dhen Ghiblean", "dhen Chèitean", "dhen Ògmhios", "dhen Iuchar", "dhen Lùnastal", "dhen t-Sultain", "dhen Dàmhair", "dhen t-Samhain", "dhen Dùbhlachd"}, + daysAbbreviated: []string{"DiD", "DiL", "DiM", "DiC", "Dia", "Dih", "DiS"}, + daysNarrow: []string{"D", "L", "M", "C", "A", "H", "S"}, + daysShort: []string{"Dò", "Lu", "Mà", "Ci", "Da", "hA", "Sa"}, + daysWide: []string{"DiDòmhnaich", "DiLuain", "DiMàirt", "DiCiadain", "DiarDaoin", "DihAoine", "DiSathairne"}, + periodsAbbreviated: []string{"m", "f"}, + periodsNarrow: []string{"m", "f"}, + periodsWide: []string{"m", "f"}, + erasAbbreviated: []string{"RC", "AD"}, + erasNarrow: []string{"R", "A"}, + erasWide: []string{"Ro Chrìosta", "An dèidh Chrìosta"}, + timezones: map[string]string{"UYT": "Bun-àm Uruguaidh", "LHDT": "Tìde samhraidh Lord Howe", "HEOG": "Tìde samhraidh na Graonlainn an Iar", "GMT": "Greenwich Mean Time", "AEDT": "Tìde samhraidh Astràilia an Ear", "CDT": "Tìde samhraidh Meadhan Aimeireaga a Tuath", "HADT": "Tìde Samhraidh nan Eileanan Hawai’i ’s Aleutach", "TMST": "Tìde samhraidh Turcmanastàin", "WAT": "Bun-àm Afraga an Iar", "HNPM": "Bun-àm Saint Pierre agus Miquelon", "CHADT": "Tìde samhraidh Chatham", "ECT": "Àm Eacuadoir", "ACWDT": "Tìde samhraidh Meadhan Astràilia an Iar", "MEZ": "Bun-àm Meadhan na Roinn-Eòrpa", "CLST": "Tìde samhraidh na Sile", "HNOG": "Bun-àm na Graonlainn an Iar", "AST": "Bun-àm a’ Chuain Siar", "WAST": "Tìde Samhraidh Afraga an Iar", "EAT": "Àm Afraga an Ear", "HNCU": "Bun-àm Cùba", "OESZ": "Tìde samhraidh na Roinn-Eòrpa an Ear", "WIT": "Àm nan Innd-Innse an Ear", "∅∅∅": "Tìde samhraidh Bhrasilia", "NZDT": "Tìde samhraidh Shealainn Nuaidh", "CLT": "Bun-àm na Sile", "WEZ": "Bun-àm na Roinn-Eòrpa an Iar", "MYT": "Àm Mhalaidhsea", "ACST": "Bun-àm Meadhan Astràilia", "HEEG": "Tìde samhraidh na Graonlainn an Ear", "AWDT": "Tìde samhraidh Astràilia an Iar", "CHAST": "Bun-àm Chatham", "VET": "Àm na Bheiniseala", "COST": "Tìde samhraidh Coloimbia", "AKDT": "Tìde samhraidh Alaska", "CAT": "Àm Meadhan Afraga", "ACWST": "Bun-àm Meadhan Astràilia an Iar", "HNPMX": "Bun-àm a’ Chuain Sèimh Mheagsago", "SGT": "Àm Singeapòr", "HNNOMX": "Bun-àm Mheagsago an Iar-thuath", "ART": "Bun-àm na h-Argantaine", "ACDT": "Tìde samhraidh Meadhan Astràilia", "UYST": "Tìde samhraidh Uruguaidh", "SAST": "Àm Afraga a Deas", "HEPMX": "Tìde samhraidh a’ Chuain Sèimh Mheagsago", "HECU": "Tìde samhraidh Cùba", "MDT": "Tìde samhraidh Macàthu", "NZST": "Bun-àm Shealainn Nuaidh", "OEZ": "Bun-àm na Roinn-Eòrpa an Ear", "BT": "Àm Butàin", "AKST": "Bun-àm Alaska", "ChST": "Àm Chamorro", "GYT": "Àm Guidheàna", "HAST": "Bun-àm nan Eileanan Hawai’i ’s Aleutach", "WESZ": "Tìde samhraidh na Roinn-Eòrpa an Iar", "HKST": "Tìde samhraidh Hong Kong", "HNT": "Bun-àm Talamh an Èisg", "HAT": "Tìde samhraidh Talamh an Èisg", "PST": "Bun-àm a’ Chuain Sèimh", "PDT": "Tìde samhraidh a’ Chuain Sèimh", "MST": "Bun-àm Macàthu", "SRT": "Àm Suranaim", "JDT": "Tìde samhraidh na Seapaine", "WART": "Bun-àm na h-Argantaine Siaraich", "WARST": "Tìde samhraidh na h-Argantaine Siaraich", "COT": "Bun-àm Coloimbia", "HNEG": "Bun-àm na Graonlainn an Ear", "GFT": "Àm Guidheàna na Frainge", "IST": "Àm nan Innseachan", "MESZ": "Tìde samhraidh Meadhan na Roinn-Eòrpa", "AEST": "Bun-àm Astràilia an Ear", "BOT": "Àm Boilibhia", "EST": "Bun-àm Aimeireaga a Tuath an Ear", "EDT": "Tìde samhraidh Aimeireaga a Tuath an Ear", "HENOMX": "Tìde samhraidh Mheagsago an Iar-thuath", "WIB": "Àm nan Innd-Innse an Iar", "AWST": "Bun-àm Astràilia an Iar", "WITA": "Àm Meadhan nan Innd-Innse", "HEPM": "Tìde Samhraidh Saint Pierre agus Miquelon", "JST": "Bun-àm na Seapaine", "HKT": "Bun-àm Hong Kong", "TMT": "Bun-àm Turcmanastàin", "ARST": "Tìde samhraidh na h-Argantaine", "LHST": "Bun-àm Lord Howe", "CST": "Bun-àm Meadhan Aimeireaga a Tuath", "ADT": "Tìde samhraidh a’ Chuain Siar"}, + } +} + +// Locale returns the current translators string locale +func (gd *gd_GB) Locale() string { + return gd.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gd_GB' +func (gd *gd_GB) PluralsCardinal() []locales.PluralRule { + return gd.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gd_GB' +func (gd *gd_GB) PluralsOrdinal() []locales.PluralRule { + return gd.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gd_GB' +func (gd *gd_GB) PluralsRange() []locales.PluralRule { + return gd.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gd_GB' +func (gd *gd_GB) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 11 { + return locales.PluralRuleOne + } else if n == 2 || n == 12 { + return locales.PluralRuleTwo + } else if (n >= 3 && n <= 10) || (n >= 13 && n <= 19) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gd_GB' +func (gd *gd_GB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gd_GB' +func (gd *gd_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gd *gd_GB) MonthAbbreviated(month time.Month) string { + return gd.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gd *gd_GB) MonthsAbbreviated() []string { + return gd.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gd *gd_GB) MonthNarrow(month time.Month) string { + return gd.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gd *gd_GB) MonthsNarrow() []string { + return gd.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gd *gd_GB) MonthWide(month time.Month) string { + return gd.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gd *gd_GB) MonthsWide() []string { + return gd.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gd *gd_GB) WeekdayAbbreviated(weekday time.Weekday) string { + return gd.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gd *gd_GB) WeekdaysAbbreviated() []string { + return gd.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gd *gd_GB) WeekdayNarrow(weekday time.Weekday) string { + return gd.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gd *gd_GB) WeekdaysNarrow() []string { + return gd.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gd *gd_GB) WeekdayShort(weekday time.Weekday) string { + return gd.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gd *gd_GB) WeekdaysShort() []string { + return gd.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gd *gd_GB) WeekdayWide(weekday time.Weekday) string { + return gd.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gd *gd_GB) WeekdaysWide() []string { + return gd.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gd_GB' and handles both Whole and Real numbers based on 'v' +func (gd *gd_GB) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gd.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gd_GB' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gd *gd_GB) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gd.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gd.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gd.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gd_GB' +func (gd *gd_GB) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gd.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, gd.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gd.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gd_GB' +// in accounting notation. +func (gd *gd_GB) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gd.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, gd.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gd.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, gd.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gd_GB' +func (gd *gd_GB) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gd_GB' +func (gd *gd_GB) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gd.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gd_GB' +func (gd *gd_GB) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x6d, 0x68}...) + b = append(b, []byte{0x20}...) + b = append(b, gd.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gd_GB' +func (gd *gd_GB) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gd.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x6d, 0x68}...) + b = append(b, []byte{0x20}...) + b = append(b, gd.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gd_GB' +func (gd *gd_GB) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gd_GB' +func (gd *gd_GB) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gd_GB' +func (gd *gd_GB) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gd_GB' +func (gd *gd_GB) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gd.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gd_GB/gd_GB_test.go b/vendor/github.com/go-playground/locales/gd_GB/gd_GB_test.go new file mode 100644 index 0000000000..aff8a23b73 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gd_GB/gd_GB_test.go @@ -0,0 +1,1120 @@ +package gd_GB + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gd_GB" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gl/gl.go b/vendor/github.com/go-playground/locales/gl/gl.go new file mode 100644 index 0000000000..1d0c2a7350 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gl/gl.go @@ -0,0 +1,610 @@ +package gl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gl' locale +func New() locales.Translator { + return &gl{ + locale: "gl", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "$A", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "$R", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "$CA", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "₧", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "$MX", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "xan.", "feb.", "mar.", "abr.", "maio", "xuño", "xul.", "ago.", "set.", "out.", "nov.", "dec."}, + monthsNarrow: []string{"", "x.", "f.", "m.", "a.", "m.", "x.", "x.", "a.", "s.", "o.", "n.", "d."}, + monthsWide: []string{"", "xaneiro", "febreiro", "marzo", "abril", "maio", "xuño", "xullo", "agosto", "setembro", "outubro", "novembro", "decembro"}, + daysAbbreviated: []string{"dom.", "luns", "mar.", "mér.", "xov.", "ven.", "sáb."}, + daysNarrow: []string{"d.", "l.", "m.", "m.", "x.", "v.", "s."}, + daysShort: []string{"dom.", "luns", "mar.", "mér.", "xov.", "ven.", "sáb."}, + daysWide: []string{"domingo", "luns", "martes", "mércores", "xoves", "venres", "sábado"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "despois de Cristo"}, + timezones: map[string]string{"NZST": "Horario estándar de Nova Zelandia", "JDT": "Horario de verán do Xapón", "CLT": "Horario estándar de Chile", "WAST": "Horario de verán de África Occidental", "AEDT": "Horario de verán de Australia Oriental", "HNPM": "Horario estándar de Saint Pierre e Miquelon", "∅∅∅": "Horario de verán das Azores", "BOT": "Horario de Bolivia", "ACWST": "Horario estándar de Australia Occidental Central", "ART": "Horario estándar de Arxentina", "HNEG": "Horario estándar de Groenlandia Oriental", "HEPM": "Horario de verán de Saint Pierre e Miquelon", "WART": "Horario estándar de Arxentina Occidental", "WARST": "Horario de verán de Arxentina Occidental", "HEOG": "Horario de verán de Groenlandia Occidental", "ARST": "Horario de verán de Arxentina", "HEEG": "Horario de verán de Groenlandia Oriental", "LHST": "Horario estándar de Lord Howe", "ECT": "Horario de Ecuador", "CAT": "Horario de África Central", "MST": "MST", "HKST": "Horario de verán de Hong Kong", "COT": "Horario estándar de Colombia", "HNNOMX": "Horario estándar de México Noroeste", "GYT": "Horario da Güiana", "JST": "Horario estándar do Xapón", "TMST": "Horario de verán de Turcomenistán", "SAST": "Horario estándar de África do Sur", "CHADT": "Horario de verán de Chatham", "HNOG": "Horario estándar de Groenlandia Occidental", "EDT": "Horario de verán do leste, Norteamérica", "AWST": "Horario estándar de Australia Occidental", "EST": "Horario estándar do leste, Norteamérica", "BT": "Horario de Bután", "GFT": "Horario da Güiana Francesa", "CST": "Horario estándar central, Norteamérica", "PST": "Horario estándar do Pacífico, Norteamérica", "GMT": "Horario do meridiano de Greenwich", "WAT": "Horario estándar de África Occidental", "HNT": "Horario estándar de Terranova", "HECU": "Horario de verán de Cuba", "VET": "Horario de Venezuela", "WEZ": "Horario estándar de Europa Occidental", "MDT": "MDT", "HNCU": "Horario estándar de Cuba", "IST": "Horario estándar da India", "MESZ": "Horario de verán de Europa Central", "CLST": "Horario de verán de Chile", "HKT": "Horario estándar de Hong Kong", "ACST": "Horario estándar de Australia Central", "PDT": "Horario de verán do Pacífico, Norteamérica", "ACWDT": "Horario de verán de Australia Occidental Central", "NZDT": "Horario de verán de Nova Zelandia", "MEZ": "Horario estándar de Europa Central", "HENOMX": "Horario de verán de México Noroeste", "WIB": "Horario de Indonesia Occidental", "ADT": "Horario de verán do Atlántico", "COST": "Horario de verán de Colombia", "AKST": "Horario estándar de Alasca", "AEST": "Horario estándar de Australia Oriental", "AKDT": "Horario de verán de Alasca", "UYT": "Horario estándar de Uruguai", "HEPMX": "Horario de verán do Pacífico mexicano", "SRT": "Horario de Suriname", "WIT": "Horario de Indonesia Oriental", "AST": "Horario estándar do Atlántico", "OESZ": "Horario de verán de Europa Oriental", "WESZ": "Horario de verán de Europa Occidental", "WITA": "Horario de Indonesia Central", "EAT": "Horario de África Oriental", "HADT": "Horario de verán de Hawai-Aleutiano", "HNPMX": "Horario estándar do Pacífico mexicano", "AWDT": "Horario de verán de Australia Occidental", "CHAST": "Horario estándar de Chatham", "OEZ": "Horario estándar de Europa Oriental", "TMT": "Horario estándar de Turcomenistán", "ACDT": "Horario de verán de Australia Central", "HAT": "Horario de verán de Terranova", "ChST": "Horario estándar chamorro", "UYST": "Horario de verán de Uruguai", "LHDT": "Horario de verán de Lord Howe", "CDT": "Horario de verán central, Norteamérica", "SGT": "Horario estándar de Singapur", "HAST": "Horario estándar de Hawai-Aleutiano", "MYT": "Horario de Malaisia"}, + } +} + +// Locale returns the current translators string locale +func (gl *gl) Locale() string { + return gl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gl' +func (gl *gl) PluralsCardinal() []locales.PluralRule { + return gl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gl' +func (gl *gl) PluralsOrdinal() []locales.PluralRule { + return gl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gl' +func (gl *gl) PluralsRange() []locales.PluralRule { + return gl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gl' +func (gl *gl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gl' +func (gl *gl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gl' +func (gl *gl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := gl.CardinalPluralRule(num1, v1) + end := gl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gl *gl) MonthAbbreviated(month time.Month) string { + return gl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gl *gl) MonthsAbbreviated() []string { + return gl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gl *gl) MonthNarrow(month time.Month) string { + return gl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gl *gl) MonthsNarrow() []string { + return gl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gl *gl) MonthWide(month time.Month) string { + return gl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gl *gl) MonthsWide() []string { + return gl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gl *gl) WeekdayAbbreviated(weekday time.Weekday) string { + return gl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gl *gl) WeekdaysAbbreviated() []string { + return gl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gl *gl) WeekdayNarrow(weekday time.Weekday) string { + return gl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gl *gl) WeekdaysNarrow() []string { + return gl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gl *gl) WeekdayShort(weekday time.Weekday) string { + return gl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gl *gl) WeekdaysShort() []string { + return gl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gl *gl) WeekdayWide(weekday time.Weekday) string { + return gl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gl *gl) WeekdaysWide() []string { + return gl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gl' and handles both Whole and Real numbers based on 'v' +func (gl *gl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gl *gl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gl.percentSuffix...) + + b = append(b, gl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gl' +func (gl *gl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, gl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gl' +// in accounting notation. +func (gl *gl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, gl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, gl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, gl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gl' +func (gl *gl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gl' +func (gl *gl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, gl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gl' +func (gl *gl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, gl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gl' +func (gl *gl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, gl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gl' +func (gl *gl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gl' +func (gl *gl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gl' +func (gl *gl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gl' +func (gl *gl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gl/gl_test.go b/vendor/github.com/go-playground/locales/gl/gl_test.go new file mode 100644 index 0000000000..1918285094 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gl/gl_test.go @@ -0,0 +1,1120 @@ +package gl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gl_ES/gl_ES.go b/vendor/github.com/go-playground/locales/gl_ES/gl_ES.go new file mode 100644 index 0000000000..afc5b81610 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gl_ES/gl_ES.go @@ -0,0 +1,610 @@ +package gl_ES + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gl_ES struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gl_ES' locale +func New() locales.Translator { + return &gl_ES{ + locale: "gl_ES", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "xan.", "feb.", "mar.", "abr.", "maio", "xuño", "xul.", "ago.", "set.", "out.", "nov.", "dec."}, + monthsNarrow: []string{"", "x.", "f.", "m.", "a.", "m.", "x.", "x.", "a.", "s.", "o.", "n.", "d."}, + monthsWide: []string{"", "xaneiro", "febreiro", "marzo", "abril", "maio", "xuño", "xullo", "agosto", "setembro", "outubro", "novembro", "decembro"}, + daysAbbreviated: []string{"dom.", "luns", "mar.", "mér.", "xov.", "ven.", "sáb."}, + daysNarrow: []string{"d.", "l.", "m.", "m.", "x.", "v.", "s."}, + daysShort: []string{"dom.", "luns", "mar.", "mér.", "xov.", "ven.", "sáb."}, + daysWide: []string{"domingo", "luns", "martes", "mércores", "xoves", "venres", "sábado"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "despois de Cristo"}, + timezones: map[string]string{"PDT": "Horario de verán do Pacífico, Norteamérica", "HAST": "Horario estándar de Hawai-Aleutiano", "TMT": "Horario estándar de Turcomenistán", "BT": "Horario de Bután", "ChST": "Horario estándar chamorro", "SAST": "Horario estándar de África do Sur", "WIT": "Horario de Indonesia Oriental", "PST": "Horario estándar do Pacífico, Norteamérica", "OEZ": "Horario estándar de Europa Oriental", "WEZ": "Horario estándar de Europa Occidental", "WESZ": "Horario de verán de Europa Occidental", "HNOG": "Horario estándar de Groenlandia Occidental", "HAT": "Horario de verán de Terranova", "AEDT": "Horario de verán de Australia Oriental", "CDT": "Horario de verán central, Norteamérica", "VET": "Horario de Venezuela", "CLST": "Horario de verán de Chile", "ADT": "Horario de verán do Atlántico", "WIB": "Horario de Indonesia Occidental", "MEZ": "Horario estándar de Europa Central", "MDT": "MDT", "EDT": "Horario de verán do leste, Norteamérica", "HNEG": "Horario estándar de Groenlandia Oriental", "AEST": "Horario estándar de Australia Oriental", "HEPM": "Horario de verán de Saint Pierre e Miquelon", "EAT": "Horario de África Oriental", "MST": "MST", "COT": "Horario estándar de Colombia", "CHADT": "Horario de verán de Chatham", "WART": "Horario estándar de Arxentina Occidental", "WAST": "Horario de verán de África Occidental", "HNT": "Horario estándar de Terranova", "∅∅∅": "Horario de verán de Brasilia", "IST": "Horario estándar da India", "COST": "Horario de verán de Colombia", "GFT": "Horario da Güiana Francesa", "UYT": "Horario estándar de Uruguai", "ACWDT": "Horario de verán de Australia Occidental Central", "NZST": "Horario estándar de Nova Zelandia", "OESZ": "Horario de verán de Europa Oriental", "HNNOMX": "Horario estándar de México Noroeste", "ACST": "Horario estándar de Australia Central", "WITA": "Horario de Indonesia Central", "HEPMX": "Horario de verán do Pacífico mexicano", "SGT": "Horario estándar de Singapur", "ACWST": "Horario estándar de Australia Occidental Central", "HKT": "Horario estándar de Hong Kong", "HENOMX": "Horario de verán de México Noroeste", "ACDT": "Horario de verán de Australia Central", "HEEG": "Horario de verán de Groenlandia Oriental", "SRT": "Horario de Suriname", "ECT": "Horario de Ecuador", "NZDT": "Horario de verán de Nova Zelandia", "HKST": "Horario de verán de Hong Kong", "WAT": "Horario estándar de África Occidental", "CHAST": "Horario estándar de Chatham", "MESZ": "Horario de verán de Europa Central", "CAT": "Horario de África Central", "JDT": "Horario de verán do Xapón", "HEOG": "Horario de verán de Groenlandia Occidental", "HNPM": "Horario estándar de Saint Pierre e Miquelon", "HNPMX": "Horario estándar do Pacífico mexicano", "AWDT": "Horario de verán de Australia Occidental", "CLT": "Horario estándar de Chile", "EST": "Horario estándar do leste, Norteamérica", "WARST": "Horario de verán de Arxentina Occidental", "ART": "Horario estándar de Arxentina", "HADT": "Horario de verán de Hawai-Aleutiano", "GMT": "Horario do meridiano de Greenwich", "AWST": "Horario estándar de Australia Occidental", "BOT": "Horario de Bolivia", "MYT": "Horario de Malaisia", "ARST": "Horario de verán de Arxentina", "AKDT": "Horario de verán de Alasca", "UYST": "Horario de verán de Uruguai", "HNCU": "Horario estándar de Cuba", "CST": "Horario estándar central, Norteamérica", "LHST": "Horario estándar de Lord Howe", "GYT": "Horario da Güiana", "AST": "Horario estándar do Atlántico", "TMST": "Horario de verán de Turcomenistán", "AKST": "Horario estándar de Alasca", "LHDT": "Horario de verán de Lord Howe", "HECU": "Horario de verán de Cuba", "JST": "Horario estándar do Xapón"}, + } +} + +// Locale returns the current translators string locale +func (gl *gl_ES) Locale() string { + return gl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gl_ES' +func (gl *gl_ES) PluralsCardinal() []locales.PluralRule { + return gl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gl_ES' +func (gl *gl_ES) PluralsOrdinal() []locales.PluralRule { + return gl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gl_ES' +func (gl *gl_ES) PluralsRange() []locales.PluralRule { + return gl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gl_ES' +func (gl *gl_ES) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gl_ES' +func (gl *gl_ES) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gl_ES' +func (gl *gl_ES) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := gl.CardinalPluralRule(num1, v1) + end := gl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gl *gl_ES) MonthAbbreviated(month time.Month) string { + return gl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gl *gl_ES) MonthsAbbreviated() []string { + return gl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gl *gl_ES) MonthNarrow(month time.Month) string { + return gl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gl *gl_ES) MonthsNarrow() []string { + return gl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gl *gl_ES) MonthWide(month time.Month) string { + return gl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gl *gl_ES) MonthsWide() []string { + return gl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gl *gl_ES) WeekdayAbbreviated(weekday time.Weekday) string { + return gl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gl *gl_ES) WeekdaysAbbreviated() []string { + return gl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gl *gl_ES) WeekdayNarrow(weekday time.Weekday) string { + return gl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gl *gl_ES) WeekdaysNarrow() []string { + return gl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gl *gl_ES) WeekdayShort(weekday time.Weekday) string { + return gl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gl *gl_ES) WeekdaysShort() []string { + return gl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gl *gl_ES) WeekdayWide(weekday time.Weekday) string { + return gl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gl *gl_ES) WeekdaysWide() []string { + return gl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gl_ES' and handles both Whole and Real numbers based on 'v' +func (gl *gl_ES) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gl_ES' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gl *gl_ES) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gl.percentSuffix...) + + b = append(b, gl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gl_ES' +func (gl *gl_ES) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, gl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gl_ES' +// in accounting notation. +func (gl *gl_ES) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, gl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, gl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, gl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gl_ES' +func (gl *gl_ES) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gl_ES' +func (gl *gl_ES) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, gl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gl_ES' +func (gl *gl_ES) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, gl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gl_ES' +func (gl *gl_ES) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, gl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gl_ES' +func (gl *gl_ES) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gl_ES' +func (gl *gl_ES) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gl_ES' +func (gl *gl_ES) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gl_ES' +func (gl *gl_ES) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gl_ES/gl_ES_test.go b/vendor/github.com/go-playground/locales/gl_ES/gl_ES_test.go new file mode 100644 index 0000000000..1c9b772b81 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gl_ES/gl_ES_test.go @@ -0,0 +1,1120 @@ +package gl_ES + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gl_ES" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gsw/gsw.go b/vendor/github.com/go-playground/locales/gsw/gsw.go new file mode 100644 index 0000000000..5e6e85b866 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gsw/gsw.go @@ -0,0 +1,614 @@ +package gsw + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gsw struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gsw' locale +func New() locales.Translator { + return &gsw{ + locale: "gsw", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: "’", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "öS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "Auguscht", "Septämber", "Oktoober", "Novämber", "Dezämber"}, + daysAbbreviated: []string{"Su.", "Mä.", "Zi.", "Mi.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysWide: []string{"Sunntig", "Määntig", "Ziischtig", "Mittwuch", "Dunschtig", "Friitig", "Samschtig"}, + periodsAbbreviated: []string{"v.m.", "n.m."}, + periodsWide: []string{"vorm.", "nam."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"MYT": "MYT", "MDT": "MDT", "ARST": "ARST", "ChST": "ChST", "WIT": "WIT", "WESZ": "Weschteuropäischi Summerziit", "AKDT": "Alaska-Summerziit", "OESZ": "Oschteuropäischi Summerziit", "HKT": "HKT", "HKST": "HKST", "CLST": "CLST", "HNOG": "HNOG", "AST": "AST", "WEZ": "Weschteuropäischi Schtandardziit", "WAT": "Weschtafrikanischi Schtandardziit", "HNPMX": "HNPMX", "BOT": "BOT", "CLT": "CLT", "COST": "COST", "HNEG": "HNEG", "ACWDT": "ACWDT", "WART": "WART", "ADT": "ADT", "WAST": "Weschtafrikanischi Summerziit", "HENOMX": "HENOMX", "CHAST": "CHAST", "PST": "PST", "HAST": "HAST", "HAT": "HAT", "WITA": "WITA", "AKST": "Alaska-Schtandardziit", "OEZ": "Oschteuropäischi Schtandardziit", "COT": "COT", "BT": "BT", "JDT": "JDT", "GMT": "GMT", "ACST": "ACST", "PDT": "PDT", "IST": "IST", "NZDT": "NZDT", "MST": "MST", "HNNOMX": "HNNOMX", "HNPM": "HNPM", "WIB": "WIB", "CDT": "Amerika-Zentraal Summerziit", "AWST": "AWST", "CHADT": "CHADT", "GFT": "GFT", "LHDT": "LHDT", "HEPMX": "HEPMX", "∅∅∅": "∅∅∅", "HADT": "HADT", "HEOG": "HEOG", "ART": "ART", "AEST": "AEST", "HEPM": "HEPM", "SGT": "SGT", "ECT": "ECT", "MESZ": "Mitteleuropäischi Summerziit", "ACDT": "ACDT", "LHST": "LHST", "HECU": "HECU", "AWDT": "AWDT", "AEDT": "AEDT", "SAST": "Süüdafrikanischi ziit", "VET": "VET", "TMT": "TMT", "TMST": "TMST", "EST": "EST", "UYT": "UYT", "GYT": "GYT", "CST": "Amerika-Zentraal Schtandardziit", "EDT": "EDT", "NZST": "NZST", "WARST": "WARST", "HEEG": "HEEG", "UYST": "UYST", "EAT": "Oschtafrikanischi Ziit", "CAT": "Zentralafrikanischi Ziit", "MEZ": "Mitteleuropäischi Schtandardziit", "JST": "JST", "HNT": "HNT", "SRT": "SRT", "HNCU": "HNCU", "ACWST": "ACWST"}, + } +} + +// Locale returns the current translators string locale +func (gsw *gsw) Locale() string { + return gsw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gsw' +func (gsw *gsw) PluralsCardinal() []locales.PluralRule { + return gsw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gsw' +func (gsw *gsw) PluralsOrdinal() []locales.PluralRule { + return gsw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gsw' +func (gsw *gsw) PluralsRange() []locales.PluralRule { + return gsw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gsw' +func (gsw *gsw) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gsw' +func (gsw *gsw) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gsw' +func (gsw *gsw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gsw *gsw) MonthAbbreviated(month time.Month) string { + return gsw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gsw *gsw) MonthsAbbreviated() []string { + return gsw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gsw *gsw) MonthNarrow(month time.Month) string { + return gsw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gsw *gsw) MonthsNarrow() []string { + return gsw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gsw *gsw) MonthWide(month time.Month) string { + return gsw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gsw *gsw) MonthsWide() []string { + return gsw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gsw *gsw) WeekdayAbbreviated(weekday time.Weekday) string { + return gsw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gsw *gsw) WeekdaysAbbreviated() []string { + return gsw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gsw *gsw) WeekdayNarrow(weekday time.Weekday) string { + return gsw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gsw *gsw) WeekdaysNarrow() []string { + return gsw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gsw *gsw) WeekdayShort(weekday time.Weekday) string { + return gsw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gsw *gsw) WeekdaysShort() []string { + return gsw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gsw *gsw) WeekdayWide(weekday time.Weekday) string { + return gsw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gsw *gsw) WeekdaysWide() []string { + return gsw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gsw' and handles both Whole and Real numbers based on 'v' +func (gsw *gsw) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gsw' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gsw *gsw) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gsw.percentSuffix...) + + b = append(b, gsw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gsw' +func (gsw *gsw) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gsw.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gsw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, gsw.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gsw' +// in accounting notation. +func (gsw *gsw) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gsw.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gsw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, gsw.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, gsw.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gsw' +func (gsw *gsw) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gsw' +func (gsw *gsw) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gsw' +func (gsw *gsw) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, gsw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gsw' +func (gsw *gsw) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gsw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, gsw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gsw' +func (gsw *gsw) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gsw' +func (gsw *gsw) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gsw' +func (gsw *gsw) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gsw' +func (gsw *gsw) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gsw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gsw/gsw_test.go b/vendor/github.com/go-playground/locales/gsw/gsw_test.go new file mode 100644 index 0000000000..c67f827d62 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gsw/gsw_test.go @@ -0,0 +1,1120 @@ +package gsw + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gsw" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gsw_CH/gsw_CH.go b/vendor/github.com/go-playground/locales/gsw_CH/gsw_CH.go new file mode 100644 index 0000000000..712e21880e --- /dev/null +++ b/vendor/github.com/go-playground/locales/gsw_CH/gsw_CH.go @@ -0,0 +1,614 @@ +package gsw_CH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gsw_CH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gsw_CH' locale +func New() locales.Translator { + return &gsw_CH{ + locale: "gsw_CH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: "’", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "Auguscht", "Septämber", "Oktoober", "Novämber", "Dezämber"}, + daysAbbreviated: []string{"Su.", "Mä.", "Zi.", "Mi.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysWide: []string{"Sunntig", "Määntig", "Ziischtig", "Mittwuch", "Dunschtig", "Friitig", "Samschtig"}, + periodsAbbreviated: []string{"v.m.", "n.m."}, + periodsWide: []string{"vorm.", "nam."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"GFT": "GFT", "AKDT": "Alaska-Summerziit", "WIB": "WIB", "OESZ": "Oschteuropäischi Summerziit", "CLT": "CLT", "COST": "COST", "HEEG": "HEEG", "BOT": "BOT", "NZST": "NZST", "HAST": "HAST", "CAT": "Zentralafrikanischi Ziit", "NZDT": "NZDT", "EDT": "EDT", "AEDT": "AEDT", "SAST": "Süüdafrikanischi ziit", "HNCU": "HNCU", "CST": "Amerika-Zentraal Schtandardziit", "HEPMX": "HEPMX", "HNPM": "HNPM", "LHDT": "LHDT", "HADT": "HADT", "MEZ": "Mitteleuropäischi Schtandardziit", "JST": "JST", "HEOG": "HEOG", "AKST": "Alaska-Schtandardziit", "ChST": "ChST", "SRT": "SRT", "PDT": "PDT", "IST": "IST", "UYT": "UYT", "VET": "VET", "GMT": "GMT", "UYST": "UYST", "AWDT": "AWDT", "MESZ": "Mitteleuropäischi Summerziit", "WAT": "Weschtafrikanischi Schtandardziit", "HEPM": "HEPM", "TMST": "TMST", "ART": "ART", "WEZ": "Weschteuropäischi Schtandardziit", "WESZ": "Weschteuropäischi Summerziit", "MST": "MST", "MDT": "MDT", "HNT": "HNT", "PST": "PST", "ACWST": "ACWST", "HKT": "HKT", "HNEG": "HNEG", "∅∅∅": "∅∅∅", "OEZ": "Oschteuropäischi Schtandardziit", "WAST": "Weschtafrikanischi Summerziit", "COT": "COT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "AEST": "AEST", "LHST": "LHST", "WIT": "WIT", "CLST": "CLST", "ACWDT": "ACWDT", "WARST": "WARST", "HNOG": "HNOG", "AST": "AST", "TMT": "TMT", "GYT": "GYT", "ECT": "ECT", "CDT": "Amerika-Zentraal Summerziit", "CHADT": "CHADT", "SGT": "SGT", "JDT": "JDT", "ARST": "ARST", "EST": "EST", "EAT": "Oschtafrikanischi Ziit", "HECU": "HECU", "BT": "BT", "ACST": "ACST", "AWST": "AWST", "ADT": "ADT", "HAT": "HAT", "WITA": "WITA", "CHAST": "CHAST", "HKST": "HKST", "ACDT": "ACDT", "HNPMX": "HNPMX", "WART": "WART", "MYT": "MYT"}, + } +} + +// Locale returns the current translators string locale +func (gsw *gsw_CH) Locale() string { + return gsw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gsw_CH' +func (gsw *gsw_CH) PluralsCardinal() []locales.PluralRule { + return gsw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gsw_CH' +func (gsw *gsw_CH) PluralsOrdinal() []locales.PluralRule { + return gsw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gsw_CH' +func (gsw *gsw_CH) PluralsRange() []locales.PluralRule { + return gsw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gsw_CH' +func (gsw *gsw_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gsw_CH' +func (gsw *gsw_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gsw_CH' +func (gsw *gsw_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gsw *gsw_CH) MonthAbbreviated(month time.Month) string { + return gsw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gsw *gsw_CH) MonthsAbbreviated() []string { + return gsw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gsw *gsw_CH) MonthNarrow(month time.Month) string { + return gsw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gsw *gsw_CH) MonthsNarrow() []string { + return gsw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gsw *gsw_CH) MonthWide(month time.Month) string { + return gsw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gsw *gsw_CH) MonthsWide() []string { + return gsw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gsw *gsw_CH) WeekdayAbbreviated(weekday time.Weekday) string { + return gsw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gsw *gsw_CH) WeekdaysAbbreviated() []string { + return gsw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gsw *gsw_CH) WeekdayNarrow(weekday time.Weekday) string { + return gsw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gsw *gsw_CH) WeekdaysNarrow() []string { + return gsw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gsw *gsw_CH) WeekdayShort(weekday time.Weekday) string { + return gsw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gsw *gsw_CH) WeekdaysShort() []string { + return gsw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gsw *gsw_CH) WeekdayWide(weekday time.Weekday) string { + return gsw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gsw *gsw_CH) WeekdaysWide() []string { + return gsw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gsw_CH' and handles both Whole and Real numbers based on 'v' +func (gsw *gsw_CH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gsw_CH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gsw *gsw_CH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gsw.percentSuffix...) + + b = append(b, gsw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gsw_CH' +func (gsw *gsw_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gsw.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gsw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, gsw.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gsw_CH' +// in accounting notation. +func (gsw *gsw_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gsw.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gsw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, gsw.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, gsw.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gsw_CH' +func (gsw *gsw_CH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gsw_CH' +func (gsw *gsw_CH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gsw_CH' +func (gsw *gsw_CH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, gsw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gsw_CH' +func (gsw *gsw_CH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gsw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, gsw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gsw_CH' +func (gsw *gsw_CH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gsw_CH' +func (gsw *gsw_CH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gsw_CH' +func (gsw *gsw_CH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gsw_CH' +func (gsw *gsw_CH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gsw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gsw_CH/gsw_CH_test.go b/vendor/github.com/go-playground/locales/gsw_CH/gsw_CH_test.go new file mode 100644 index 0000000000..98632cdb25 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gsw_CH/gsw_CH_test.go @@ -0,0 +1,1120 @@ +package gsw_CH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gsw_CH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gsw_FR/gsw_FR.go b/vendor/github.com/go-playground/locales/gsw_FR/gsw_FR.go new file mode 100644 index 0000000000..ea5158b143 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gsw_FR/gsw_FR.go @@ -0,0 +1,614 @@ +package gsw_FR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gsw_FR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gsw_FR' locale +func New() locales.Translator { + return &gsw_FR{ + locale: "gsw_FR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: "’", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "Auguscht", "Septämber", "Oktoober", "Novämber", "Dezämber"}, + daysAbbreviated: []string{"Su.", "Mä.", "Zi.", "Mi.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysWide: []string{"Sunntig", "Määntig", "Ziischtig", "Mittwuch", "Dunschtig", "Friitig", "Samschtig"}, + periodsAbbreviated: []string{"v.m.", "n.m."}, + periodsWide: []string{"vorm.", "nam."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"PST": "PST", "MYT": "MYT", "CLST": "CLST", "SRT": "SRT", "EAT": "Oschtafrikanischi Ziit", "ACWDT": "ACWDT", "WARST": "WARST", "AST": "AST", "WESZ": "Weschteuropäischi Summerziit", "HNT": "HNT", "CST": "Amerika-Zentraal Schtandardziit", "HAST": "HAST", "EST": "EST", "HNCU": "HNCU", "CHAST": "CHAST", "SGT": "SGT", "AKDT": "Alaska-Summerziit", "WIB": "WIB", "ADT": "ADT", "MST": "MST", "MDT": "MDT", "EDT": "EDT", "HKT": "HKT", "HENOMX": "HENOMX", "CDT": "Amerika-Zentraal Summerziit", "HADT": "HADT", "HNOG": "HNOG", "HEOG": "HEOG", "HAT": "HAT", "AKST": "Alaska-Schtandardziit", "UYT": "UYT", "VET": "VET", "JDT": "JDT", "ACST": "ACST", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "HECU": "HECU", "WIT": "WIT", "ACWST": "ACWST", "MEZ": "Mitteleuropäischi Schtandardziit", "AEST": "AEST", "NZDT": "NZDT", "HEPM": "HEPM", "JST": "JST", "HKST": "HKST", "SAST": "Süüdafrikanischi ziit", "BOT": "BOT", "NZST": "NZST", "MESZ": "Mitteleuropäischi Summerziit", "COT": "COT", "AWDT": "AWDT", "CAT": "Zentralafrikanischi Ziit", "ART": "ART", "CHADT": "CHADT", "IST": "IST", "OESZ": "Oschteuropäischi Summerziit", "HNPM": "HNPM", "HNPMX": "HNPMX", "AWST": "AWST", "PDT": "PDT", "WART": "WART", "WEZ": "Weschteuropäischi Schtandardziit", "WAT": "Weschtafrikanischi Schtandardziit", "AEDT": "AEDT", "∅∅∅": "Amazonas-Summerziit", "OEZ": "Oschteuropäischi Schtandardziit", "TMT": "TMT", "TMST": "TMST", "ARST": "ARST", "WAST": "Weschtafrikanischi Summerziit", "BT": "BT", "HNEG": "HNEG", "HEEG": "HEEG", "GFT": "GFT", "WITA": "WITA", "UYST": "UYST", "LHST": "LHST", "LHDT": "LHDT", "ECT": "ECT", "GMT": "GMT", "CLT": "CLT", "COST": "COST", "ChST": "ChST", "HEPMX": "HEPMX", "GYT": "GYT"}, + } +} + +// Locale returns the current translators string locale +func (gsw *gsw_FR) Locale() string { + return gsw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gsw_FR' +func (gsw *gsw_FR) PluralsCardinal() []locales.PluralRule { + return gsw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gsw_FR' +func (gsw *gsw_FR) PluralsOrdinal() []locales.PluralRule { + return gsw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gsw_FR' +func (gsw *gsw_FR) PluralsRange() []locales.PluralRule { + return gsw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gsw_FR' +func (gsw *gsw_FR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gsw_FR' +func (gsw *gsw_FR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gsw_FR' +func (gsw *gsw_FR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gsw *gsw_FR) MonthAbbreviated(month time.Month) string { + return gsw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gsw *gsw_FR) MonthsAbbreviated() []string { + return gsw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gsw *gsw_FR) MonthNarrow(month time.Month) string { + return gsw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gsw *gsw_FR) MonthsNarrow() []string { + return gsw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gsw *gsw_FR) MonthWide(month time.Month) string { + return gsw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gsw *gsw_FR) MonthsWide() []string { + return gsw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gsw *gsw_FR) WeekdayAbbreviated(weekday time.Weekday) string { + return gsw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gsw *gsw_FR) WeekdaysAbbreviated() []string { + return gsw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gsw *gsw_FR) WeekdayNarrow(weekday time.Weekday) string { + return gsw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gsw *gsw_FR) WeekdaysNarrow() []string { + return gsw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gsw *gsw_FR) WeekdayShort(weekday time.Weekday) string { + return gsw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gsw *gsw_FR) WeekdaysShort() []string { + return gsw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gsw *gsw_FR) WeekdayWide(weekday time.Weekday) string { + return gsw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gsw *gsw_FR) WeekdaysWide() []string { + return gsw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gsw_FR' and handles both Whole and Real numbers based on 'v' +func (gsw *gsw_FR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gsw_FR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gsw *gsw_FR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gsw.percentSuffix...) + + b = append(b, gsw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gsw_FR' +func (gsw *gsw_FR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gsw.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gsw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, gsw.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gsw_FR' +// in accounting notation. +func (gsw *gsw_FR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gsw.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gsw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, gsw.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, gsw.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gsw_FR' +func (gsw *gsw_FR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gsw_FR' +func (gsw *gsw_FR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gsw_FR' +func (gsw *gsw_FR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, gsw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gsw_FR' +func (gsw *gsw_FR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gsw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, gsw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gsw_FR' +func (gsw *gsw_FR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gsw_FR' +func (gsw *gsw_FR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gsw_FR' +func (gsw *gsw_FR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gsw_FR' +func (gsw *gsw_FR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gsw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gsw_FR/gsw_FR_test.go b/vendor/github.com/go-playground/locales/gsw_FR/gsw_FR_test.go new file mode 100644 index 0000000000..77a4bcd0e3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gsw_FR/gsw_FR_test.go @@ -0,0 +1,1120 @@ +package gsw_FR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gsw_FR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gsw_LI/gsw_LI.go b/vendor/github.com/go-playground/locales/gsw_LI/gsw_LI.go new file mode 100644 index 0000000000..d63c9c64e4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gsw_LI/gsw_LI.go @@ -0,0 +1,614 @@ +package gsw_LI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gsw_LI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gsw_LI' locale +func New() locales.Translator { + return &gsw_LI{ + locale: "gsw_LI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: "’", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "Auguscht", "Septämber", "Oktoober", "Novämber", "Dezämber"}, + daysAbbreviated: []string{"Su.", "Mä.", "Zi.", "Mi.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysWide: []string{"Sunntig", "Määntig", "Ziischtig", "Mittwuch", "Dunschtig", "Friitig", "Samschtig"}, + periodsAbbreviated: []string{"v.m.", "n.m."}, + periodsWide: []string{"vorm.", "nam."}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"v. Chr.", "n. Chr."}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"BOT": "BOT", "PDT": "PDT", "ACDT": "ACDT", "WIB": "WIB", "WESZ": "Weschteuropäischi Summerziit", "ARST": "ARST", "COST": "COST", "HNPM": "HNPM", "WIT": "WIT", "CHADT": "CHADT", "MEZ": "Mitteleuropäischi Schtandardziit", "WEZ": "Weschteuropäischi Schtandardziit", "WART": "WART", "HKT": "HKT", "EST": "EST", "EDT": "EDT", "JDT": "JDT", "VET": "VET", "ART": "ART", "HKST": "HKST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "AKDT": "Alaska-Summerziit", "CDT": "Amerika-Zentraal Summerziit", "GMT": "GMT", "WARST": "WARST", "AWST": "AWST", "HADT": "HADT", "WAT": "Weschtafrikanischi Schtandardziit", "HEEG": "HEEG", "HAT": "HAT", "SAST": "Süüdafrikanischi ziit", "LHDT": "LHDT", "AWDT": "AWDT", "MST": "MST", "MDT": "MDT", "BT": "BT", "GFT": "GFT", "UYST": "UYST", "HEPMX": "HEPMX", "PST": "PST", "IST": "IST", "MYT": "MYT", "CLST": "CLST", "SGT": "SGT", "OESZ": "Oschteuropäischi Summerziit", "WAST": "Weschtafrikanischi Summerziit", "CST": "Amerika-Zentraal Schtandardziit", "HEPM": "HEPM", "ChST": "ChST", "HNEG": "HNEG", "AEST": "AEST", "AKST": "Alaska-Schtandardziit", "EAT": "Oschtafrikanischi Ziit", "CHAST": "CHAST", "ACWDT": "ACWDT", "JST": "JST", "OEZ": "Oschteuropäischi Schtandardziit", "∅∅∅": "Acre-Summerziit", "HECU": "HECU", "NZDT": "NZDT", "AST": "AST", "TMT": "TMT", "ACWST": "ACWST", "ADT": "ADT", "LHST": "LHST", "HNCU": "HNCU", "HNOG": "HNOG", "TMST": "TMST", "GYT": "GYT", "AEDT": "AEDT", "SRT": "SRT", "HNT": "HNT", "ACST": "ACST", "COT": "COT", "WITA": "WITA", "CAT": "Zentralafrikanischi Ziit", "HEOG": "HEOG", "UYT": "UYT", "HNPMX": "HNPMX", "HAST": "HAST", "ECT": "ECT", "NZST": "NZST", "MESZ": "Mitteleuropäischi Summerziit", "CLT": "CLT"}, + } +} + +// Locale returns the current translators string locale +func (gsw *gsw_LI) Locale() string { + return gsw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gsw_LI' +func (gsw *gsw_LI) PluralsCardinal() []locales.PluralRule { + return gsw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gsw_LI' +func (gsw *gsw_LI) PluralsOrdinal() []locales.PluralRule { + return gsw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gsw_LI' +func (gsw *gsw_LI) PluralsRange() []locales.PluralRule { + return gsw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gsw_LI' +func (gsw *gsw_LI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gsw_LI' +func (gsw *gsw_LI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gsw_LI' +func (gsw *gsw_LI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gsw *gsw_LI) MonthAbbreviated(month time.Month) string { + return gsw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gsw *gsw_LI) MonthsAbbreviated() []string { + return gsw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gsw *gsw_LI) MonthNarrow(month time.Month) string { + return gsw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gsw *gsw_LI) MonthsNarrow() []string { + return gsw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gsw *gsw_LI) MonthWide(month time.Month) string { + return gsw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gsw *gsw_LI) MonthsWide() []string { + return gsw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gsw *gsw_LI) WeekdayAbbreviated(weekday time.Weekday) string { + return gsw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gsw *gsw_LI) WeekdaysAbbreviated() []string { + return gsw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gsw *gsw_LI) WeekdayNarrow(weekday time.Weekday) string { + return gsw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gsw *gsw_LI) WeekdaysNarrow() []string { + return gsw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gsw *gsw_LI) WeekdayShort(weekday time.Weekday) string { + return gsw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gsw *gsw_LI) WeekdaysShort() []string { + return gsw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gsw *gsw_LI) WeekdayWide(weekday time.Weekday) string { + return gsw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gsw *gsw_LI) WeekdaysWide() []string { + return gsw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gsw_LI' and handles both Whole and Real numbers based on 'v' +func (gsw *gsw_LI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gsw_LI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gsw *gsw_LI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gsw.percentSuffix...) + + b = append(b, gsw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gsw_LI' +func (gsw *gsw_LI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gsw.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gsw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, gsw.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gsw_LI' +// in accounting notation. +func (gsw *gsw_LI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gsw.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gsw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(gsw.group) - 1; j >= 0; j-- { + b = append(b, gsw.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(gsw.minus) - 1; j >= 0; j-- { + b = append(b, gsw.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gsw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, gsw.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, gsw.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gsw_LI' +func (gsw *gsw_LI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gsw_LI' +func (gsw *gsw_LI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gsw_LI' +func (gsw *gsw_LI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, gsw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gsw_LI' +func (gsw *gsw_LI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gsw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, gsw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gsw_LI' +func (gsw *gsw_LI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gsw_LI' +func (gsw *gsw_LI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gsw_LI' +func (gsw *gsw_LI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gsw_LI' +func (gsw *gsw_LI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gsw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gsw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gsw_LI/gsw_LI_test.go b/vendor/github.com/go-playground/locales/gsw_LI/gsw_LI_test.go new file mode 100644 index 0000000000..13dd35286d --- /dev/null +++ b/vendor/github.com/go-playground/locales/gsw_LI/gsw_LI_test.go @@ -0,0 +1,1120 @@ +package gsw_LI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gsw_LI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gu/gu.go b/vendor/github.com/go-playground/locales/gu/gu.go new file mode 100644 index 0000000000..e67782070b --- /dev/null +++ b/vendor/github.com/go-playground/locales/gu/gu.go @@ -0,0 +1,663 @@ +package gu + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gu struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gu' locale +func New() locales.Translator { + return &gu{ + locale: "gu", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "જાન્યુ", "ફેબ્રુ", "માર્ચ", "એપ્રિલ", "મે", "જૂન", "જુલાઈ", "ઑગસ્ટ", "સપ્ટે", "ઑક્ટો", "નવે", "ડિસે"}, + monthsNarrow: []string{"", "જા", "ફે", "મા", "એ", "મે", "જૂ", "જુ", "ઑ", "સ", "ઑ", "ન", "ડિ"}, + monthsWide: []string{"", "જાન્યુઆરી", "ફેબ્રુઆરી", "માર્ચ", "એપ્રિલ", "મે", "જૂન", "જુલાઈ", "ઑગસ્ટ", "સપ્ટેમ્બર", "ઑક્ટોબર", "નવેમ્બર", "ડિસેમ્બર"}, + daysAbbreviated: []string{"રવિ", "સોમ", "મંગળ", "બુધ", "ગુરુ", "શુક્ર", "શનિ"}, + daysNarrow: []string{"ર", "સો", "મં", "બુ", "ગુ", "શુ", "શ"}, + daysShort: []string{"ર", "સો", "મં", "બુ", "ગુ", "શુ", "શ"}, + daysWide: []string{"રવિવાર", "સોમવાર", "મંગળવાર", "બુધવાર", "ગુરુવાર", "શુક્રવાર", "શનિવાર"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"ઈ.સ.પૂર્વે", "ઈ.સ."}, + erasNarrow: []string{"ઇ સ પુ", "ઇસ"}, + erasWide: []string{"ઈસવીસન પૂર્વે", "ઇસવીસન"}, + timezones: map[string]string{"EDT": "ઉત્તર અમેરિકન પૂર્વી દિવસ સમય", "HNPM": "સેંટ પીએરે એન્ડ મિકીલોન માનક સમય", "EAT": "પૂર્વ આફ્રિકા સમય", "NZDT": "ન્યુઝીલેન્ડ દિવસ સમય", "MYT": "મલેશિયા સમય", "OESZ": "પૂર્વી યુરોપીયન ગ્રીષ્મ સમય", "VET": "વેનેઝુએલા સમય", "HNPMX": "મેક્સીકન પેસિફિક માનક સમય", "ARST": "આર્જેન્ટીના ગ્રીષ્મ સમય", "COT": "કોલંબિયા માનક સમય", "AEDT": "ઓસ્ટ્રેલિયન પૂર્વીય દિવસ સમય", "HEPMX": "મેક્સીકન પેસિફિક દિવસ સમય", "HNCU": "ક્યૂબા માનક સમય", "WIT": "પૂર્વીય ઇન્ડોનેશિયા સમય", "WARST": "પશ્ચિમી અર્જેન્ટીના ગ્રીષ્મ સમય", "CLT": "ચિલી માનક સમય", "SAST": "દક્ષિણ આફ્રિકા માનક સમય", "ACWDT": "ઓસ્ટ્રેલિયન મધ્ય પશ્ચિમી દિવસ સમય", "HEOG": "પશ્ચિમ ગ્રીનલેન્ડ ગ્રીષ્મ સમય", "MDT": "મકાઉ ગ્રીષ્મ સમય", "BT": "ભૂટાન સમય", "AEST": "ઓસ્ટ્રેલિયન પૂર્વીય પ્રમાણભૂત સમય", "WITA": "મધ્ય ઇન્ડોનેશિયા સમય", "UYST": "ઉરૂગ્વે ગ્રીષ્મ સમય", "WIB": "પશ્ચિમી ઇન્ડોનેશિયા સમય", "CST": "ઉત્તર અમેરિકન કેન્દ્રિય પ્રમાણભૂત સમય", "HNOG": "પશ્ચિમ ગ્રીનલેન્ડ માનક સમય", "HENOMX": "ઉત્તરપશ્ચિમ મેક્સિકો દિવસ સમય", "UYT": "ઉરૂગ્વે માનક સમય", "WEZ": "પશ્ચિમી યુરોપિયન માનક સમય", "GFT": "ફ્રેન્ચ ગયાના સમય", "ART": "અર્જેન્ટીના માનક સમય", "HKST": "હોંગ કોંગ ગ્રીષ્મ સમય", "WAST": "પશ્ચિમ આફ્રિકા ગ્રીષ્મ સમય", "AWST": "ઓસ્ટ્રેલિયન પશ્ચિમી પ્રમાણભૂત સમય", "CHAST": "ચેતહામ માનક સમય", "CHADT": "ચેતહામ દિવસ સમય", "JST": "જાપાન માનક સમય", "MEZ": "મધ્ય યુરોપિયન માનક સમય", "HNNOMX": "ઉત્તરપશ્ચિમ મેક્સિકો માનક સમય", "HEEG": "પૂર્વ ગ્રીનલેન્ડ ગ્રીષ્મ સમય", "AKST": "અલાસ્કા પ્રમાણભૂત સમય", "EST": "ઉત્તર અમેરિકન પૂર્વી પ્રમાણભૂત સમય", "HEPM": "સેંટ પીએરે એન્ડ મિકીલોન દિવસ સમય", "CDT": "ઉત્તર અમેરિકન મધ્ય દિવસ સમય", "AWDT": "ઓસ્ટ્રેલિયન પશ્ચિમી દિવસ સમય", "ACWST": "ઓસ્ટ્રેલિયન મધ્ય પશ્ચિમી પ્રમાણભૂત સમય", "HKT": "હોંગ કોંગ માનક સમય", "ACST": "ઓસ્ટ્રેલિયન મધ્ય પ્રમાણભૂત સમય", "SRT": "સૂરીનામ સમય", "GYT": "ગયાના સમય", "SGT": "સિંગાપુર માનક સમય", "JDT": "જાપાન દિવસ સમય", "TMST": "તુર્કમેનિસ્તાન ગ્રીષ્મ સમય", "CLST": "ચિલી ગ્રીષ્મ સમય", "ADT": "અટલાન્ટિક દિવસ સમય", "HAST": "હવાઇ-એલ્યુશિઅન માનક સમય", "HADT": "હવાઇ-એલ્યુશિઅન દિવસ સમય", "PDT": "ઉત્તર અમેરિકન પેસિફિક દિવસ સમય", "CAT": "મધ્ય આફ્રિકા સમય", "IST": "ભારતીય માનક સમય", "NZST": "ન્યુઝીલેન્ડ માનક સમય", "MST": "મકાઉ પ્રમાણભૂત સમય", "WAT": "પશ્ચિમ આફ્રિકા માનક સમય", "ACDT": "ઓસ્ટ્રેલિયન મધ્ય દિવસ સમય", "LHDT": "લોર્ડ હોવ દિવસ સમય", "PST": "ઉત્તર અમેરિકન પેસિફિક પ્રમાણભૂત સમય", "WART": "પશ્ચિમી અર્જેન્ટીના માનક સમય", "COST": "કોલંબિયા ગ્રીષ્મ સમય", "HNT": "ન્યૂફાઉન્ડલેન્ડ પ્રમાણભૂત સમય", "HAT": "ન્યૂફાઉન્ડલેન્ડ દિવસ સમય", "ChST": "કેમોરો માનક સમય", "WESZ": "પશ્ચિમી યુરોપિયન ગ્રીષ્મ સમય", "GMT": "ગ્રીનવિચ મધ્યમ સમય", "AST": "અટલાન્ટિક પ્રમાણભૂત સમય", "TMT": "તુર્કમેનિસ્તાન માનક સમય", "HNEG": "પૂર્વ ગ્રીનલેન્ડ માનક સમય", "AKDT": "અલાસ્કા દિવસ સમય", "LHST": "લોર્ડ હોવ પ્રમાણભૂત સમય", "HECU": "ક્યૂબા દિવસ સમય", "ECT": "એક્વાડોર સમય", "MESZ": "મધ્ય યુરોપિયન ગ્રીષ્મ સમય", "OEZ": "પૂર્વી યુરોપિયન માનક સમય", "∅∅∅": "એઝોર્સ ગ્રીષ્મ સમય", "BOT": "બોલિવિયા સમય"}, + } +} + +// Locale returns the current translators string locale +func (gu *gu) Locale() string { + return gu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gu' +func (gu *gu) PluralsCardinal() []locales.PluralRule { + return gu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gu' +func (gu *gu) PluralsOrdinal() []locales.PluralRule { + return gu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gu' +func (gu *gu) PluralsRange() []locales.PluralRule { + return gu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gu' +func (gu *gu) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gu' +func (gu *gu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gu' +func (gu *gu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := gu.CardinalPluralRule(num1, v1) + end := gu.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gu *gu) MonthAbbreviated(month time.Month) string { + return gu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gu *gu) MonthsAbbreviated() []string { + return gu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gu *gu) MonthNarrow(month time.Month) string { + return gu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gu *gu) MonthsNarrow() []string { + return gu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gu *gu) MonthWide(month time.Month) string { + return gu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gu *gu) MonthsWide() []string { + return gu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gu *gu) WeekdayAbbreviated(weekday time.Weekday) string { + return gu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gu *gu) WeekdaysAbbreviated() []string { + return gu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gu *gu) WeekdayNarrow(weekday time.Weekday) string { + return gu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gu *gu) WeekdaysNarrow() []string { + return gu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gu *gu) WeekdayShort(weekday time.Weekday) string { + return gu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gu *gu) WeekdaysShort() []string { + return gu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gu *gu) WeekdayWide(weekday time.Weekday) string { + return gu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gu *gu) WeekdaysWide() []string { + return gu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gu' and handles both Whole and Real numbers based on 'v' +func (gu *gu) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, gu.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gu' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gu *gu) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gu' +func (gu *gu) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gu.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, gu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gu' +// in accounting notation. +func (gu *gu) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gu.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, gu.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gu' +func (gu *gu) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gu' +func (gu *gu) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gu' +func (gu *gu) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gu.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gu' +func (gu *gu) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gu.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gu' +func (gu *gu) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, gu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, gu.periodsAbbreviated[0]...) + } else { + b = append(b, gu.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gu' +func (gu *gu) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, gu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, gu.periodsAbbreviated[0]...) + } else { + b = append(b, gu.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gu' +func (gu *gu) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, gu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, gu.periodsAbbreviated[0]...) + } else { + b = append(b, gu.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gu' +func (gu *gu) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, gu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, gu.periodsAbbreviated[0]...) + } else { + b = append(b, gu.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gu/gu_test.go b/vendor/github.com/go-playground/locales/gu/gu_test.go new file mode 100644 index 0000000000..ecb09ebba2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gu/gu_test.go @@ -0,0 +1,1120 @@ +package gu + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gu" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gu_IN/gu_IN.go b/vendor/github.com/go-playground/locales/gu_IN/gu_IN.go new file mode 100644 index 0000000000..ca0cd15890 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gu_IN/gu_IN.go @@ -0,0 +1,663 @@ +package gu_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gu_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gu_IN' locale +func New() locales.Translator { + return &gu_IN{ + locale: "gu_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "જાન્યુ", "ફેબ્રુ", "માર્ચ", "એપ્રિલ", "મે", "જૂન", "જુલાઈ", "ઑગસ્ટ", "સપ્ટે", "ઑક્ટો", "નવે", "ડિસે"}, + monthsNarrow: []string{"", "જા", "ફે", "મા", "એ", "મે", "જૂ", "જુ", "ઑ", "સ", "ઑ", "ન", "ડિ"}, + monthsWide: []string{"", "જાન્યુઆરી", "ફેબ્રુઆરી", "માર્ચ", "એપ્રિલ", "મે", "જૂન", "જુલાઈ", "ઑગસ્ટ", "સપ્ટેમ્બર", "ઑક્ટોબર", "નવેમ્બર", "ડિસેમ્બર"}, + daysAbbreviated: []string{"રવિ", "સોમ", "મંગળ", "બુધ", "ગુરુ", "શુક્ર", "શનિ"}, + daysNarrow: []string{"ર", "સો", "મં", "બુ", "ગુ", "શુ", "શ"}, + daysShort: []string{"ર", "સો", "મં", "બુ", "ગુ", "શુ", "શ"}, + daysWide: []string{"રવિવાર", "સોમવાર", "મંગળવાર", "બુધવાર", "ગુરુવાર", "શુક્રવાર", "શનિવાર"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"ઈ.સ.પૂર્વે", "ઈ.સ."}, + erasNarrow: []string{"ઇ સ પુ", "ઇસ"}, + erasWide: []string{"ઈસવીસન પૂર્વે", "ઇસવીસન"}, + timezones: map[string]string{"SRT": "સૂરીનામ સમય", "TMST": "તુર્કમેનિસ્તાન ગ્રીષ્મ સમય", "MST": "મકાઉ પ્રમાણભૂત સમય", "ACDT": "ઓસ્ટ્રેલિયન મધ્ય દિવસ સમય", "BT": "ભૂટાન સમય", "UYST": "ઉરૂગ્વે ગ્રીષ્મ સમય", "HNPMX": "મેક્સીકન પેસિફિક માનક સમય", "ACWST": "ઓસ્ટ્રેલિયન મધ્ય પશ્ચિમી પ્રમાણભૂત સમય", "JST": "જાપાન માનક સમય", "WAST": "પશ્ચિમ આફ્રિકા ગ્રીષ્મ સમય", "HNT": "ન્યૂફાઉન્ડલેન્ડ પ્રમાણભૂત સમય", "GYT": "ગયાના સમય", "SAST": "દક્ષિણ આફ્રિકા માનક સમય", "CLT": "ચિલી માનક સમય", "GMT": "ગ્રીનવિચ મધ્યમ સમય", "COT": "કોલંબિયા માનક સમય", "HNEG": "પૂર્વ ગ્રીનલેન્ડ માનક સમય", "AEST": "ઓસ્ટ્રેલિયન પૂર્વીય પ્રમાણભૂત સમય", "UYT": "ઉરૂગ્વે માનક સમય", "AKST": "અલાસ્કા પ્રમાણભૂત સમય", "LHDT": "લોર્ડ હોવ દિવસ સમય", "HNCU": "ક્યૂબા માનક સમય", "WIT": "પૂર્વીય ઇન્ડોનેશિયા સમય", "HAST": "હવાઇ-એલ્યુશિઅન માનક સમય", "NZDT": "ન્યુઝીલેન્ડ દિવસ સમય", "MYT": "મલેશિયા સમય", "WART": "પશ્ચિમી અર્જેન્ટીના માનક સમય", "AST": "અટલાન્ટિક પ્રમાણભૂત સમય", "HEPMX": "મેક્સીકન પેસિફિક દિવસ સમય", "∅∅∅": "એમેઝોન ગ્રીષ્મ સમય", "ACWDT": "ઓસ્ટ્રેલિયન મધ્ય પશ્ચિમી દિવસ સમય", "MESZ": "મધ્ય યુરોપિયન ગ્રીષ્મ સમય", "WARST": "પશ્ચિમી અર્જેન્ટીના ગ્રીષ્મ સમય", "HEOG": "પશ્ચિમ ગ્રીનલેન્ડ ગ્રીષ્મ સમય", "AKDT": "અલાસ્કા દિવસ સમય", "WIB": "પશ્ચિમી ઇન્ડોનેશિયા સમય", "SGT": "સિંગાપુર માનક સમય", "CAT": "મધ્ય આફ્રિકા સમય", "OEZ": "પૂર્વી યુરોપિયન માનક સમય", "ARST": "આર્જેન્ટીના ગ્રીષ્મ સમય", "EST": "ઉત્તર અમેરિકન પૂર્વી પ્રમાણભૂત સમય", "HAT": "ન્યૂફાઉન્ડલેન્ડ દિવસ સમય", "HADT": "હવાઇ-એલ્યુશિઅન દિવસ સમય", "WAT": "પશ્ચિમ આફ્રિકા માનક સમય", "COST": "કોલંબિયા ગ્રીષ્મ સમય", "AEDT": "ઓસ્ટ્રેલિયન પૂર્વીય દિવસ સમય", "ChST": "કેમોરો માનક સમય", "HEPM": "સેંટ પીએરે એન્ડ મિકીલોન દિવસ સમય", "CHAST": "ચેતહામ માનક સમય", "ECT": "એક્વાડોર સમય", "MEZ": "મધ્ય યુરોપિયન માનક સમય", "JDT": "જાપાન દિવસ સમય", "HNOG": "પશ્ચિમ ગ્રીનલેન્ડ માનક સમય", "WEZ": "પશ્ચિમી યુરોપિયન માનક સમય", "LHST": "લોર્ડ હોવ પ્રમાણભૂત સમય", "CHADT": "ચેતહામ દિવસ સમય", "CLST": "ચિલી ગ્રીષ્મ સમય", "HENOMX": "ઉત્તરપશ્ચિમ મેક્સિકો દિવસ સમય", "PST": "ઉત્તર અમેરિકન પેસિફિક પ્રમાણભૂત સમય", "PDT": "ઉત્તર અમેરિકન પેસિફિક દિવસ સમય", "MDT": "મકાઉ ગ્રીષ્મ સમય", "HNPM": "સેંટ પીએરે એન્ડ મિકીલોન માનક સમય", "TMT": "તુર્કમેનિસ્તાન માનક સમય", "HKT": "હોંગ કોંગ માનક સમય", "HNNOMX": "ઉત્તરપશ્ચિમ મેક્સિકો માનક સમય", "WESZ": "પશ્ચિમી યુરોપિયન ગ્રીષ્મ સમય", "ACST": "ઓસ્ટ્રેલિયન મધ્ય પ્રમાણભૂત સમય", "HEEG": "પૂર્વ ગ્રીનલેન્ડ ગ્રીષ્મ સમય", "HECU": "ક્યૂબા દિવસ સમય", "IST": "ભારતીય માનક સમય", "EDT": "ઉત્તર અમેરિકન પૂર્વી દિવસ સમય", "GFT": "ફ્રેન્ચ ગયાના સમય", "WITA": "મધ્ય ઇન્ડોનેશિયા સમય", "CDT": "ઉત્તર અમેરિકન મધ્ય દિવસ સમય", "NZST": "ન્યુઝીલેન્ડ માનક સમય", "ADT": "અટલાન્ટિક દિવસ સમય", "OESZ": "પૂર્વી યુરોપીયન ગ્રીષ્મ સમય", "HKST": "હોંગ કોંગ ગ્રીષ્મ સમય", "EAT": "પૂર્વ આફ્રિકા સમય", "CST": "ઉત્તર અમેરિકન કેન્દ્રિય પ્રમાણભૂત સમય", "BOT": "બોલિવિયા સમય", "VET": "વેનેઝુએલા સમય", "ART": "અર્જેન્ટીના માનક સમય", "AWST": "ઓસ્ટ્રેલિયન પશ્ચિમી પ્રમાણભૂત સમય", "AWDT": "ઓસ્ટ્રેલિયન પશ્ચિમી દિવસ સમય"}, + } +} + +// Locale returns the current translators string locale +func (gu *gu_IN) Locale() string { + return gu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gu_IN' +func (gu *gu_IN) PluralsCardinal() []locales.PluralRule { + return gu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gu_IN' +func (gu *gu_IN) PluralsOrdinal() []locales.PluralRule { + return gu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gu_IN' +func (gu *gu_IN) PluralsRange() []locales.PluralRule { + return gu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gu_IN' +func (gu *gu_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gu_IN' +func (gu *gu_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gu_IN' +func (gu *gu_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := gu.CardinalPluralRule(num1, v1) + end := gu.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gu *gu_IN) MonthAbbreviated(month time.Month) string { + return gu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gu *gu_IN) MonthsAbbreviated() []string { + return gu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gu *gu_IN) MonthNarrow(month time.Month) string { + return gu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gu *gu_IN) MonthsNarrow() []string { + return gu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gu *gu_IN) MonthWide(month time.Month) string { + return gu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gu *gu_IN) MonthsWide() []string { + return gu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gu *gu_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return gu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gu *gu_IN) WeekdaysAbbreviated() []string { + return gu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gu *gu_IN) WeekdayNarrow(weekday time.Weekday) string { + return gu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gu *gu_IN) WeekdaysNarrow() []string { + return gu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gu *gu_IN) WeekdayShort(weekday time.Weekday) string { + return gu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gu *gu_IN) WeekdaysShort() []string { + return gu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gu *gu_IN) WeekdayWide(weekday time.Weekday) string { + return gu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gu *gu_IN) WeekdaysWide() []string { + return gu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gu_IN' and handles both Whole and Real numbers based on 'v' +func (gu *gu_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, gu.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gu_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gu *gu_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, gu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, gu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gu_IN' +func (gu *gu_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gu.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, gu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gu_IN' +// in accounting notation. +func (gu *gu_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gu.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, gu.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gu_IN' +func (gu *gu_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gu_IN' +func (gu *gu_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gu_IN' +func (gu *gu_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gu.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gu_IN' +func (gu *gu_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gu.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gu_IN' +func (gu *gu_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, gu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, gu.periodsAbbreviated[0]...) + } else { + b = append(b, gu.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gu_IN' +func (gu *gu_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, gu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, gu.periodsAbbreviated[0]...) + } else { + b = append(b, gu.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gu_IN' +func (gu *gu_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, gu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, gu.periodsAbbreviated[0]...) + } else { + b = append(b, gu.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gu_IN' +func (gu *gu_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, gu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, gu.periodsAbbreviated[0]...) + } else { + b = append(b, gu.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gu_IN/gu_IN_test.go b/vendor/github.com/go-playground/locales/gu_IN/gu_IN_test.go new file mode 100644 index 0000000000..7d2fdcba19 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gu_IN/gu_IN_test.go @@ -0,0 +1,1120 @@ +package gu_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gu_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/guz/guz.go b/vendor/github.com/go-playground/locales/guz/guz.go new file mode 100644 index 0000000000..4784baf011 --- /dev/null +++ b/vendor/github.com/go-playground/locales/guz/guz.go @@ -0,0 +1,518 @@ +package guz + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type guz struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'guz' locale +func New() locales.Translator { + return &guz{ + locale: "guz", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Can", "Feb", "Mac", "Apr", "Mei", "Jun", "Cul", "Agt", "Sep", "Okt", "Nob", "Dis"}, + monthsNarrow: []string{"", "C", "F", "M", "A", "M", "J", "C", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Chanuari", "Feburari", "Machi", "Apiriri", "Mei", "Juni", "Chulai", "Agosti", "Septemba", "Okitoba", "Nobemba", "Disemba"}, + daysAbbreviated: []string{"Cpr", "Ctt", "Cmn", "Cmt", "Ars", "Icm", "Est"}, + daysNarrow: []string{"C", "C", "C", "C", "A", "I", "E"}, + daysWide: []string{"Chumapiri", "Chumatato", "Chumaine", "Chumatano", "Aramisi", "Ichuma", "Esabato"}, + periodsAbbreviated: []string{"Ma", "Mo"}, + periodsWide: []string{"Mambia", "Mog"}, + erasAbbreviated: []string{"YA", "YK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Yeso ataiborwa", "Yeso kaiboirwe"}, + timezones: map[string]string{"HAT": "HAT", "∅∅∅": "∅∅∅", "ACDT": "ACDT", "WAT": "WAT", "UYT": "UYT", "HECU": "HECU", "HAST": "HAST", "ECT": "ECT", "ADT": "ADT", "ART": "ART", "WARST": "WARST", "WIB": "WIB", "HNNOMX": "HNNOMX", "AEST": "AEST", "UYST": "UYST", "WIT": "WIT", "PST": "PST", "WEZ": "WEZ", "TMST": "TMST", "AKDT": "AKDT", "EAT": "EAT", "CHAST": "CHAST", "COT": "COT", "HEEG": "HEEG", "EDT": "EDT", "COST": "COST", "AKST": "AKST", "HEPM": "HEPM", "HEPMX": "HEPMX", "AWDT": "AWDT", "CLST": "CLST", "MDT": "MDT", "SGT": "SGT", "LHST": "LHST", "GYT": "GYT", "CST": "CST", "MST": "MST", "WAST": "WAST", "OEZ": "OEZ", "CLT": "CLT", "HNOG": "HNOG", "HNPMX": "HNPMX", "NZDT": "NZDT", "JDT": "JDT", "AST": "AST", "ARST": "ARST", "HNPM": "HNPM", "ChST": "ChST", "SAST": "SAST", "MESZ": "MESZ", "OESZ": "OESZ", "ACWDT": "ACWDT", "VET": "VET", "GMT": "GMT", "MYT": "MYT", "HNEG": "HNEG", "HADT": "HADT", "IST": "IST", "ACWST": "ACWST", "BOT": "BOT", "PDT": "PDT", "WART": "WART", "GFT": "GFT", "HEOG": "HEOG", "TMT": "TMT", "HKST": "HKST", "BT": "BT", "AEDT": "AEDT", "CAT": "CAT", "JST": "JST", "HENOMX": "HENOMX", "HNT": "HNT", "LHDT": "LHDT", "CDT": "CDT", "CHADT": "CHADT", "EST": "EST", "HKT": "HKT", "WITA": "WITA", "SRT": "SRT", "MEZ": "MEZ", "ACST": "ACST", "HNCU": "HNCU", "AWST": "AWST", "NZST": "NZST", "WESZ": "WESZ"}, + } +} + +// Locale returns the current translators string locale +func (guz *guz) Locale() string { + return guz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'guz' +func (guz *guz) PluralsCardinal() []locales.PluralRule { + return guz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'guz' +func (guz *guz) PluralsOrdinal() []locales.PluralRule { + return guz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'guz' +func (guz *guz) PluralsRange() []locales.PluralRule { + return guz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'guz' +func (guz *guz) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'guz' +func (guz *guz) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'guz' +func (guz *guz) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (guz *guz) MonthAbbreviated(month time.Month) string { + return guz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (guz *guz) MonthsAbbreviated() []string { + return guz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (guz *guz) MonthNarrow(month time.Month) string { + return guz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (guz *guz) MonthsNarrow() []string { + return guz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (guz *guz) MonthWide(month time.Month) string { + return guz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (guz *guz) MonthsWide() []string { + return guz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (guz *guz) WeekdayAbbreviated(weekday time.Weekday) string { + return guz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (guz *guz) WeekdaysAbbreviated() []string { + return guz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (guz *guz) WeekdayNarrow(weekday time.Weekday) string { + return guz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (guz *guz) WeekdaysNarrow() []string { + return guz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (guz *guz) WeekdayShort(weekday time.Weekday) string { + return guz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (guz *guz) WeekdaysShort() []string { + return guz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (guz *guz) WeekdayWide(weekday time.Weekday) string { + return guz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (guz *guz) WeekdaysWide() []string { + return guz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'guz' and handles both Whole and Real numbers based on 'v' +func (guz *guz) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'guz' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (guz *guz) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'guz' +func (guz *guz) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := guz.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, guz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, guz.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, guz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, guz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'guz' +// in accounting notation. +func (guz *guz) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := guz.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, guz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, guz.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, guz.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, guz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, guz.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'guz' +func (guz *guz) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'guz' +func (guz *guz) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, guz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'guz' +func (guz *guz) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, guz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'guz' +func (guz *guz) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, guz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, guz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'guz' +func (guz *guz) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, guz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'guz' +func (guz *guz) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, guz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, guz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'guz' +func (guz *guz) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, guz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, guz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'guz' +func (guz *guz) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, guz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, guz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := guz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/guz/guz_test.go b/vendor/github.com/go-playground/locales/guz/guz_test.go new file mode 100644 index 0000000000..186751ef0f --- /dev/null +++ b/vendor/github.com/go-playground/locales/guz/guz_test.go @@ -0,0 +1,1120 @@ +package guz + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "guz" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/guz_KE/guz_KE.go b/vendor/github.com/go-playground/locales/guz_KE/guz_KE.go new file mode 100644 index 0000000000..ec8c550030 --- /dev/null +++ b/vendor/github.com/go-playground/locales/guz_KE/guz_KE.go @@ -0,0 +1,518 @@ +package guz_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type guz_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'guz_KE' locale +func New() locales.Translator { + return &guz_KE{ + locale: "guz_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Can", "Feb", "Mac", "Apr", "Mei", "Jun", "Cul", "Agt", "Sep", "Okt", "Nob", "Dis"}, + monthsNarrow: []string{"", "C", "F", "M", "A", "M", "J", "C", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Chanuari", "Feburari", "Machi", "Apiriri", "Mei", "Juni", "Chulai", "Agosti", "Septemba", "Okitoba", "Nobemba", "Disemba"}, + daysAbbreviated: []string{"Cpr", "Ctt", "Cmn", "Cmt", "Ars", "Icm", "Est"}, + daysNarrow: []string{"C", "C", "C", "C", "A", "I", "E"}, + daysWide: []string{"Chumapiri", "Chumatato", "Chumaine", "Chumatano", "Aramisi", "Ichuma", "Esabato"}, + periodsAbbreviated: []string{"Ma", "Mo"}, + periodsWide: []string{"Mambia", "Mog"}, + erasAbbreviated: []string{"YA", "YK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Yeso ataiborwa", "Yeso kaiboirwe"}, + timezones: map[string]string{"HNOG": "HNOG", "COT": "COT", "BT": "BT", "ChST": "ChST", "NZDT": "NZDT", "WIB": "WIB", "VET": "VET", "WARST": "WARST", "ACDT": "ACDT", "AKST": "AKST", "UYST": "UYST", "HEPM": "HEPM", "CST": "CST", "HKT": "HKT", "HNEG": "HNEG", "AKDT": "AKDT", "GFT": "GFT", "UYT": "UYT", "SRT": "SRT", "AST": "AST", "WEZ": "WEZ", "AEDT": "AEDT", "HNPMX": "HNPMX", "AWDT": "AWDT", "HENOMX": "HENOMX", "LHST": "LHST", "WIT": "WIT", "NZST": "NZST", "WESZ": "WESZ", "TMT": "TMT", "WAT": "WAT", "PDT": "PDT", "GMT": "GMT", "WAST": "WAST", "HAT": "HAT", "SAST": "SAST", "CHADT": "CHADT", "CAT": "CAT", "ACWDT": "ACWDT", "MEZ": "MEZ", "JDT": "JDT", "OEZ": "OEZ", "OESZ": "OESZ", "MYT": "MYT", "MST": "MST", "AWST": "AWST", "ART": "ART", "COST": "COST", "HEEG": "HEEG", "∅∅∅": "∅∅∅", "EAT": "EAT", "CDT": "CDT", "CLT": "CLT", "HNCU": "HNCU", "BOT": "BOT", "IST": "IST", "HADT": "HADT", "ARST": "ARST", "EST": "EST", "EDT": "EDT", "HNT": "HNT", "LHDT": "LHDT", "HAST": "HAST", "MDT": "MDT", "AEST": "AEST", "PST": "PST", "ADT": "ADT", "ACST": "ACST", "HECU": "HECU", "TMST": "TMST", "GYT": "GYT", "CHAST": "CHAST", "SGT": "SGT", "ACWST": "ACWST", "JST": "JST", "WART": "WART", "CLST": "CLST", "HNNOMX": "HNNOMX", "ECT": "ECT", "MESZ": "MESZ", "HEOG": "HEOG", "HKST": "HKST", "WITA": "WITA", "HNPM": "HNPM", "HEPMX": "HEPMX"}, + } +} + +// Locale returns the current translators string locale +func (guz *guz_KE) Locale() string { + return guz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'guz_KE' +func (guz *guz_KE) PluralsCardinal() []locales.PluralRule { + return guz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'guz_KE' +func (guz *guz_KE) PluralsOrdinal() []locales.PluralRule { + return guz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'guz_KE' +func (guz *guz_KE) PluralsRange() []locales.PluralRule { + return guz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'guz_KE' +func (guz *guz_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'guz_KE' +func (guz *guz_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'guz_KE' +func (guz *guz_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (guz *guz_KE) MonthAbbreviated(month time.Month) string { + return guz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (guz *guz_KE) MonthsAbbreviated() []string { + return guz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (guz *guz_KE) MonthNarrow(month time.Month) string { + return guz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (guz *guz_KE) MonthsNarrow() []string { + return guz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (guz *guz_KE) MonthWide(month time.Month) string { + return guz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (guz *guz_KE) MonthsWide() []string { + return guz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (guz *guz_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return guz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (guz *guz_KE) WeekdaysAbbreviated() []string { + return guz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (guz *guz_KE) WeekdayNarrow(weekday time.Weekday) string { + return guz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (guz *guz_KE) WeekdaysNarrow() []string { + return guz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (guz *guz_KE) WeekdayShort(weekday time.Weekday) string { + return guz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (guz *guz_KE) WeekdaysShort() []string { + return guz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (guz *guz_KE) WeekdayWide(weekday time.Weekday) string { + return guz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (guz *guz_KE) WeekdaysWide() []string { + return guz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'guz_KE' and handles both Whole and Real numbers based on 'v' +func (guz *guz_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'guz_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (guz *guz_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'guz_KE' +func (guz *guz_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := guz.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, guz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, guz.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, guz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, guz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'guz_KE' +// in accounting notation. +func (guz *guz_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := guz.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, guz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, guz.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, guz.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, guz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, guz.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'guz_KE' +func (guz *guz_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'guz_KE' +func (guz *guz_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, guz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'guz_KE' +func (guz *guz_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, guz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'guz_KE' +func (guz *guz_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, guz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, guz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'guz_KE' +func (guz *guz_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, guz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'guz_KE' +func (guz *guz_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, guz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, guz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'guz_KE' +func (guz *guz_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, guz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, guz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'guz_KE' +func (guz *guz_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, guz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, guz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := guz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/guz_KE/guz_KE_test.go b/vendor/github.com/go-playground/locales/guz_KE/guz_KE_test.go new file mode 100644 index 0000000000..d9c78aec1e --- /dev/null +++ b/vendor/github.com/go-playground/locales/guz_KE/guz_KE_test.go @@ -0,0 +1,1120 @@ +package guz_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "guz_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gv/gv.go b/vendor/github.com/go-playground/locales/gv/gv.go new file mode 100644 index 0000000000..e797068907 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gv/gv.go @@ -0,0 +1,538 @@ +package gv + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gv struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gv' locale +func New() locales.Translator { + return &gv{ + locale: "gv", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "J-guer", "T-arree", "Mayrnt", "Avrril", "Boaldyn", "M-souree", "J-souree", "Luanistyn", "M-fouyir", "J-fouyir", "M-Houney", "M-Nollick"}, + monthsWide: []string{"", "Jerrey-geuree", "Toshiaght-arree", "Mayrnt", "Averil", "Boaldyn", "Mean-souree", "Jerrey-souree", "Luanistyn", "Mean-fouyir", "Jerrey-fouyir", "Mee Houney", "Mee ny Nollick"}, + daysAbbreviated: []string{"Jed", "Jel", "Jem", "Jerc", "Jerd", "Jeh", "Jes"}, + daysWide: []string{"Jedoonee", "Jelhein", "Jemayrt", "Jercean", "Jerdein", "Jeheiney", "Jesarn"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"RC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HADT": "HADT", "ADT": "ADT", "GMT": "GMT", "CLT": "CLT", "HENOMX": "HENOMX", "HAST": "HAST", "WARST": "WARST", "AEST": "AEST", "SRT": "SRT", "GYT": "GYT", "HNCU": "HNCU", "CST": "CST", "WIT": "WIT", "AWDT": "AWDT", "ART": "ART", "ACST": "ACST", "BT": "BT", "HNT": "HNT", "HNEG": "HNEG", "AKDT": "AKDT", "UYT": "UYT", "CDT": "CDT", "BOT": "BOT", "IST": "IST", "EST": "EST", "WITA": "WITA", "HEPM": "HEPM", "OEZ": "OEZ", "WAST": "WAST", "EDT": "EDT", "HAT": "HAT", "WIB": "WIB", "PST": "PST", "HEOG": "HEOG", "WART": "WART", "ARST": "ARST", "COST": "COST", "HNPMX": "HNPMX", "ECT": "ECT", "JST": "JST", "AEDT": "AEDT", "ACWDT": "ACWDT", "MESZ": "MESZ", "AKST": "AKST", "HNPM": "HNPM", "SAST": "SAST", "CHADT": "CHADT", "ACWST": "ACWST", "MEZ": "MEZ", "WESZ": "WESZ", "CLST": "CLST", "HKST": "HKST", "UYST": "UYST", "EAT": "EAT", "CHAST": "CHAST", "CAT": "CAT", "VET": "VET", "HNOG": "HNOG", "TMT": "TMT", "COT": "COT", "LHDT": "LHDT", "WAT": "WAT", "ACDT": "ACDT", "HEPMX": "HEPMX", "HECU": "HECU", "MYT": "MYT", "GFT": "GFT", "SGT": "SGT", "PDT": "PDT", "NZST": "NZST", "AST": "AST", "OESZ": "OESZ", "ChST": "ChST", "NZDT": "NZDT", "∅∅∅": "∅∅∅", "WEZ": "WEZ", "TMST": "TMST", "MST": "MST", "HEEG": "HEEG", "LHST": "LHST", "AWST": "AWST", "JDT": "JDT", "MDT": "MDT", "HKT": "HKT", "HNNOMX": "HNNOMX"}, + } +} + +// Locale returns the current translators string locale +func (gv *gv) Locale() string { + return gv.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gv' +func (gv *gv) PluralsCardinal() []locales.PluralRule { + return gv.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gv' +func (gv *gv) PluralsOrdinal() []locales.PluralRule { + return gv.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gv' +func (gv *gv) PluralsRange() []locales.PluralRule { + return gv.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gv' +func (gv *gv) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + iMod10 := i % 10 + + if v == 0 && iMod10 == 1 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 == 2 { + return locales.PluralRuleTwo + } else if v == 0 && (iMod100 == 0 || iMod100 == 20 || iMod100 == 40 || iMod100 == 60 || iMod100 == 80) { + return locales.PluralRuleFew + } else if v != 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gv' +func (gv *gv) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gv' +func (gv *gv) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gv *gv) MonthAbbreviated(month time.Month) string { + return gv.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gv *gv) MonthsAbbreviated() []string { + return gv.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gv *gv) MonthNarrow(month time.Month) string { + return gv.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gv *gv) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gv *gv) MonthWide(month time.Month) string { + return gv.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gv *gv) MonthsWide() []string { + return gv.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gv *gv) WeekdayAbbreviated(weekday time.Weekday) string { + return gv.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gv *gv) WeekdaysAbbreviated() []string { + return gv.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gv *gv) WeekdayNarrow(weekday time.Weekday) string { + return gv.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gv *gv) WeekdaysNarrow() []string { + return gv.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gv *gv) WeekdayShort(weekday time.Weekday) string { + return gv.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gv *gv) WeekdaysShort() []string { + return gv.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gv *gv) WeekdayWide(weekday time.Weekday) string { + return gv.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gv *gv) WeekdaysWide() []string { + return gv.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gv' and handles both Whole and Real numbers based on 'v' +func (gv *gv) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gv' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gv *gv) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gv' +func (gv *gv) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gv.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gv.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, gv.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gv' +// in accounting notation. +func (gv *gv) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gv.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gv.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, gv.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gv' +func (gv *gv) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gv' +func (gv *gv) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gv.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gv' +func (gv *gv) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gv' +func (gv *gv) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gv.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gv' +func (gv *gv) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gv' +func (gv *gv) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gv' +func (gv *gv) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gv' +func (gv *gv) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gv.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gv/gv_test.go b/vendor/github.com/go-playground/locales/gv/gv_test.go new file mode 100644 index 0000000000..02f110bdd7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gv/gv_test.go @@ -0,0 +1,1120 @@ +package gv + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gv" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/gv_IM/gv_IM.go b/vendor/github.com/go-playground/locales/gv_IM/gv_IM.go new file mode 100644 index 0000000000..68d94ba0f5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/gv_IM/gv_IM.go @@ -0,0 +1,538 @@ +package gv_IM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type gv_IM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'gv_IM' locale +func New() locales.Translator { + return &gv_IM{ + locale: "gv_IM", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "J-guer", "T-arree", "Mayrnt", "Avrril", "Boaldyn", "M-souree", "J-souree", "Luanistyn", "M-fouyir", "J-fouyir", "M-Houney", "M-Nollick"}, + monthsWide: []string{"", "Jerrey-geuree", "Toshiaght-arree", "Mayrnt", "Averil", "Boaldyn", "Mean-souree", "Jerrey-souree", "Luanistyn", "Mean-fouyir", "Jerrey-fouyir", "Mee Houney", "Mee ny Nollick"}, + daysAbbreviated: []string{"Jed", "Jel", "Jem", "Jerc", "Jerd", "Jeh", "Jes"}, + daysWide: []string{"Jedoonee", "Jelhein", "Jemayrt", "Jercean", "Jerdein", "Jeheiney", "Jesarn"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"RC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"CDT": "CDT", "SGT": "SGT", "CST": "CST", "HADT": "HADT", "AKDT": "AKDT", "HNPM": "HNPM", "UYT": "UYT", "HNCU": "HNCU", "UYST": "UYST", "HECU": "HECU", "ACWST": "ACWST", "JST": "JST", "MST": "MST", "ACDT": "ACDT", "HAT": "HAT", "GFT": "GFT", "LHDT": "LHDT", "MEZ": "MEZ", "AKST": "AKST", "PDT": "PDT", "HNEG": "HNEG", "PST": "PST", "ACWDT": "ACWDT", "WESZ": "WESZ", "TMT": "TMT", "EST": "EST", "COST": "COST", "NZDT": "NZDT", "IST": "IST", "MESZ": "MESZ", "OEZ": "OEZ", "MDT": "MDT", "CHADT": "CHADT", "AEDT": "AEDT", "WITA": "WITA", "EAT": "EAT", "ADT": "ADT", "ART": "ART", "WAT": "WAT", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "HEPM": "HEPM", "JDT": "JDT", "CLST": "CLST", "TMST": "TMST", "HEEG": "HEEG", "COT": "COT", "HEPMX": "HEPMX", "CHAST": "CHAST", "CAT": "CAT", "ChST": "ChST", "SRT": "SRT", "WIT": "WIT", "WEZ": "WEZ", "OESZ": "OESZ", "ARST": "ARST", "BT": "BT", "ECT": "ECT", "MYT": "MYT", "HKT": "HKT", "HNPMX": "HNPMX", "HAST": "HAST", "AWST": "AWST", "WAST": "WAST", "HNNOMX": "HNNOMX", "AEST": "AEST", "WIB": "WIB", "LHST": "LHST", "GYT": "GYT", "WART": "WART", "WARST": "WARST", "CLT": "CLT", "ACST": "ACST", "BOT": "BOT", "VET": "VET", "AST": "AST", "HKST": "HKST", "SAST": "SAST", "HNT": "HNT", "AWDT": "AWDT", "NZST": "NZST", "GMT": "GMT", "HNOG": "HNOG", "HEOG": "HEOG", "EDT": "EDT"}, + } +} + +// Locale returns the current translators string locale +func (gv *gv_IM) Locale() string { + return gv.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'gv_IM' +func (gv *gv_IM) PluralsCardinal() []locales.PluralRule { + return gv.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'gv_IM' +func (gv *gv_IM) PluralsOrdinal() []locales.PluralRule { + return gv.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'gv_IM' +func (gv *gv_IM) PluralsRange() []locales.PluralRule { + return gv.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gv_IM' +func (gv *gv_IM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if v == 0 && iMod10 == 1 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 == 2 { + return locales.PluralRuleTwo + } else if v == 0 && (iMod100 == 0 || iMod100 == 20 || iMod100 == 40 || iMod100 == 60 || iMod100 == 80) { + return locales.PluralRuleFew + } else if v != 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gv_IM' +func (gv *gv_IM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gv_IM' +func (gv *gv_IM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (gv *gv_IM) MonthAbbreviated(month time.Month) string { + return gv.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (gv *gv_IM) MonthsAbbreviated() []string { + return gv.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (gv *gv_IM) MonthNarrow(month time.Month) string { + return gv.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (gv *gv_IM) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (gv *gv_IM) MonthWide(month time.Month) string { + return gv.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (gv *gv_IM) MonthsWide() []string { + return gv.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (gv *gv_IM) WeekdayAbbreviated(weekday time.Weekday) string { + return gv.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (gv *gv_IM) WeekdaysAbbreviated() []string { + return gv.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (gv *gv_IM) WeekdayNarrow(weekday time.Weekday) string { + return gv.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (gv *gv_IM) WeekdaysNarrow() []string { + return gv.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (gv *gv_IM) WeekdayShort(weekday time.Weekday) string { + return gv.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (gv *gv_IM) WeekdaysShort() []string { + return gv.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (gv *gv_IM) WeekdayWide(weekday time.Weekday) string { + return gv.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (gv *gv_IM) WeekdaysWide() []string { + return gv.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'gv_IM' and handles both Whole and Real numbers based on 'v' +func (gv *gv_IM) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'gv_IM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (gv *gv_IM) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gv_IM' +func (gv *gv_IM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gv.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gv.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, gv.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gv_IM' +// in accounting notation. +func (gv *gv_IM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := gv.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, gv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, gv.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, gv.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, gv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'gv_IM' +func (gv *gv_IM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'gv_IM' +func (gv *gv_IM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gv.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'gv_IM' +func (gv *gv_IM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'gv_IM' +func (gv *gv_IM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, gv.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, gv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'gv_IM' +func (gv *gv_IM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'gv_IM' +func (gv *gv_IM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'gv_IM' +func (gv *gv_IM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'gv_IM' +func (gv *gv_IM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, gv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, gv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := gv.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/gv_IM/gv_IM_test.go b/vendor/github.com/go-playground/locales/gv_IM/gv_IM_test.go new file mode 100644 index 0000000000..6653d6b3fc --- /dev/null +++ b/vendor/github.com/go-playground/locales/gv_IM/gv_IM_test.go @@ -0,0 +1,1120 @@ +package gv_IM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "gv_IM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ha/ha.go b/vendor/github.com/go-playground/locales/ha/ha.go new file mode 100644 index 0000000000..0922b69179 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ha/ha.go @@ -0,0 +1,587 @@ +package ha + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ha struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ha' locale +func New() locales.Translator { + return &ha{ + locale: "ha", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "₦", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan", "Fab", "Mar", "Afi", "May", "Yun", "Yul", "Agu", "Sat", "Okt", "Nuw", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Y", "Y", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janairu", "Faburairu", "Maris", "Afirilu", "Mayu", "Yuni", "Yuli", "Agusta", "Satumba", "Oktoba", "Nuwamba", "Disamba"}, + daysAbbreviated: []string{"Lah", "Lit", "Tal", "Lar", "Alh", "Jum", "Asa"}, + daysNarrow: []string{"L", "L", "T", "L", "A", "J", "A"}, + daysShort: []string{"Lh", "Li", "Ta", "Lr", "Al", "Ju", "As"}, + daysWide: []string{"Lahadi", "Litinin", "Talata", "Laraba", "Alhamis", "Jummaʼa", "Asabar"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"KHAI", "BHAI"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kafin haihuwar annab", "Bayan haihuwar annab"}, + timezones: map[string]string{"CHAST": "CHAST", "ACST": "ACST", "AEST": "AEST", "WIB": "WIB", "HKT": "HKT", "HNNOMX": "HNNOMX", "HECU": "HECU", "SGT": "SGT", "ACWST": "ACWST", "CLT": "CLT", "OESZ": "OESZ", "BOT": "BOT", "CAT": "CAT", "WEZ": "WEZ", "HNCU": "HNCU", "HNPM": "HNPM", "PST": "PST", "IST": "IST", "CLST": "CLST", "WESZ": "WESZ", "HAT": "HAT", "ADT": "ADT", "ART": "ART", "HKST": "HKST", "COST": "COST", "WARST": "WARST", "MDT": "MDT", "WITA": "WITA", "AEDT": "AEDT", "HNPMX": "HNPMX", "AWDT": "AWDT", "PDT": "PDT", "TMT": "TMT", "GFT": "GFT", "MESZ": "MESZ", "MST": "MST", "UYST": "UYST", "WAT": "WAT", "ACDT": "ACDT", "BT": "BT", "ChST": "ChST", "HAST": "HAST", "∅∅∅": "∅∅∅", "NZDT": "NZDT", "HNOG": "HNOG", "LHDT": "LHDT", "CDT": "CDT", "JST": "JST", "WART": "WART", "WAST": "WAST", "HNEG": "HNEG", "GMT": "GMT", "TMST": "TMST", "HEEG": "HEEG", "AKDT": "AKDT", "AWST": "AWST", "CHADT": "CHADT", "NZST": "NZST", "HEOG": "HEOG", "GYT": "GYT", "CST": "CST", "MYT": "MYT", "HENOMX": "HENOMX", "LHST": "LHST", "SRT": "SRT", "HNT": "HNT", "AKST": "AKST", "WIT": "WIT", "ACWDT": "ACWDT", "AST": "AST", "OEZ": "OEZ", "COT": "COT", "HEPMX": "HEPMX", "MEZ": "MEZ", "VET": "VET", "HEPM": "HEPM", "SAST": "SAST", "ARST": "ARST", "EST": "EST", "UYT": "UYT", "EAT": "EAT", "ECT": "ECT", "HADT": "HADT", "JDT": "JDT", "EDT": "EDT"}, + } +} + +// Locale returns the current translators string locale +func (ha *ha) Locale() string { + return ha.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ha' +func (ha *ha) PluralsCardinal() []locales.PluralRule { + return ha.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ha' +func (ha *ha) PluralsOrdinal() []locales.PluralRule { + return ha.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ha' +func (ha *ha) PluralsRange() []locales.PluralRule { + return ha.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ha' +func (ha *ha) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ha' +func (ha *ha) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ha' +func (ha *ha) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ha *ha) MonthAbbreviated(month time.Month) string { + return ha.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ha *ha) MonthsAbbreviated() []string { + return ha.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ha *ha) MonthNarrow(month time.Month) string { + return ha.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ha *ha) MonthsNarrow() []string { + return ha.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ha *ha) MonthWide(month time.Month) string { + return ha.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ha *ha) MonthsWide() []string { + return ha.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ha *ha) WeekdayAbbreviated(weekday time.Weekday) string { + return ha.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ha *ha) WeekdaysAbbreviated() []string { + return ha.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ha *ha) WeekdayNarrow(weekday time.Weekday) string { + return ha.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ha *ha) WeekdaysNarrow() []string { + return ha.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ha *ha) WeekdayShort(weekday time.Weekday) string { + return ha.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ha *ha) WeekdaysShort() []string { + return ha.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ha *ha) WeekdayWide(weekday time.Weekday) string { + return ha.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ha *ha) WeekdaysWide() []string { + return ha.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ha' and handles both Whole and Real numbers based on 'v' +func (ha *ha) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ha' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ha *ha) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ha.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ha' +func (ha *ha) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ha.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ha.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ha' +// in accounting notation. +func (ha *ha) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ha.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyNegativePrefix[j]) + } + + b = append(b, ha.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ha.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ha' +func (ha *ha) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ha' +func (ha *ha) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ha' +func (ha *ha) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ha' +func (ha *ha) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ha.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ha' +func (ha *ha) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ha' +func (ha *ha) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ha' +func (ha *ha) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ha' +func (ha *ha) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ha.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ha/ha_test.go b/vendor/github.com/go-playground/locales/ha/ha_test.go new file mode 100644 index 0000000000..0e956a9cbb --- /dev/null +++ b/vendor/github.com/go-playground/locales/ha/ha_test.go @@ -0,0 +1,1120 @@ +package ha + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ha" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ha_GH/ha_GH.go b/vendor/github.com/go-playground/locales/ha_GH/ha_GH.go new file mode 100644 index 0000000000..eb8cbedaf4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ha_GH/ha_GH.go @@ -0,0 +1,587 @@ +package ha_GH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ha_GH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ha_GH' locale +func New() locales.Translator { + return &ha_GH{ + locale: "ha_GH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GH₵", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan", "Fab", "Mar", "Afi", "May", "Yun", "Yul", "Agu", "Sat", "Okt", "Nuw", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Y", "Y", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janairu", "Faburairu", "Maris", "Afirilu", "Mayu", "Yuni", "Yuli", "Agusta", "Satumba", "Oktoba", "Nuwamba", "Disamba"}, + daysAbbreviated: []string{"Lah", "Lit", "Tal", "Lar", "Alh", "Jum", "Asa"}, + daysNarrow: []string{"L", "L", "T", "L", "A", "J", "A"}, + daysShort: []string{"Lh", "Li", "Ta", "Lr", "Al", "Ju", "As"}, + daysWide: []string{"Lahadi", "Litinin", "Talata", "Laraba", "Alhamis", "Jummaʼa", "Asabar"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"KHAI", "BHAI"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kafin haihuwar annab", "Bayan haihuwar annab"}, + timezones: map[string]string{"CHAST": "CHAST", "TMT": "TMT", "GMT": "GMT", "AKST": "AKST", "CST": "CST", "PST": "PST", "MEZ": "MEZ", "MDT": "MDT", "CHADT": "CHADT", "ECT": "ECT", "HKT": "HKT", "COST": "COST", "HNNOMX": "HNNOMX", "BT": "BT", "LHST": "LHST", "WIB": "WIB", "ART": "ART", "GFT": "GFT", "EST": "EST", "AEST": "AEST", "WAT": "WAT", "HNT": "HNT", "CLT": "CLT", "UYT": "UYT", "UYST": "UYST", "IST": "IST", "MESZ": "MESZ", "CLST": "CLST", "MST": "MST", "EDT": "EDT", "∅∅∅": "∅∅∅", "NZST": "NZST", "WESZ": "WESZ", "ADT": "ADT", "WITA": "WITA", "HEPM": "HEPM", "EAT": "EAT", "WEZ": "WEZ", "WART": "WART", "AST": "AST", "WAST": "WAST", "HENOMX": "HENOMX", "SGT": "SGT", "PDT": "PDT", "NZDT": "NZDT", "COT": "COT", "ACDT": "ACDT", "HNPM": "HNPM", "ChST": "ChST", "LHDT": "LHDT", "CDT": "CDT", "ACWDT": "ACWDT", "HNPMX": "HNPMX", "HEOG": "HEOG", "ARST": "ARST", "HKST": "HKST", "HNEG": "HNEG", "GYT": "GYT", "BOT": "BOT", "ACWST": "ACWST", "JDT": "JDT", "OEZ": "OEZ", "MYT": "MYT", "TMST": "TMST", "ACST": "ACST", "HAT": "HAT", "WIT": "WIT", "VET": "VET", "AEDT": "AEDT", "AKDT": "AKDT", "HADT": "HADT", "JST": "JST", "HNOG": "HNOG", "HEPMX": "HEPMX", "SRT": "SRT", "AWST": "AWST", "HAST": "HAST", "CAT": "CAT", "HEEG": "HEEG", "AWDT": "AWDT", "OESZ": "OESZ", "WARST": "WARST", "SAST": "SAST", "HNCU": "HNCU", "HECU": "HECU"}, + } +} + +// Locale returns the current translators string locale +func (ha *ha_GH) Locale() string { + return ha.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ha_GH' +func (ha *ha_GH) PluralsCardinal() []locales.PluralRule { + return ha.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ha_GH' +func (ha *ha_GH) PluralsOrdinal() []locales.PluralRule { + return ha.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ha_GH' +func (ha *ha_GH) PluralsRange() []locales.PluralRule { + return ha.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ha_GH' +func (ha *ha_GH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ha_GH' +func (ha *ha_GH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ha_GH' +func (ha *ha_GH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ha *ha_GH) MonthAbbreviated(month time.Month) string { + return ha.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ha *ha_GH) MonthsAbbreviated() []string { + return ha.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ha *ha_GH) MonthNarrow(month time.Month) string { + return ha.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ha *ha_GH) MonthsNarrow() []string { + return ha.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ha *ha_GH) MonthWide(month time.Month) string { + return ha.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ha *ha_GH) MonthsWide() []string { + return ha.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ha *ha_GH) WeekdayAbbreviated(weekday time.Weekday) string { + return ha.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ha *ha_GH) WeekdaysAbbreviated() []string { + return ha.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ha *ha_GH) WeekdayNarrow(weekday time.Weekday) string { + return ha.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ha *ha_GH) WeekdaysNarrow() []string { + return ha.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ha *ha_GH) WeekdayShort(weekday time.Weekday) string { + return ha.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ha *ha_GH) WeekdaysShort() []string { + return ha.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ha *ha_GH) WeekdayWide(weekday time.Weekday) string { + return ha.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ha *ha_GH) WeekdaysWide() []string { + return ha.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ha_GH' and handles both Whole and Real numbers based on 'v' +func (ha *ha_GH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ha_GH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ha *ha_GH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ha.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ha_GH' +func (ha *ha_GH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ha.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ha.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ha_GH' +// in accounting notation. +func (ha *ha_GH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ha.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyNegativePrefix[j]) + } + + b = append(b, ha.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ha.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ha_GH' +func (ha *ha_GH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ha_GH' +func (ha *ha_GH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ha_GH' +func (ha *ha_GH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ha_GH' +func (ha *ha_GH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ha.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ha_GH' +func (ha *ha_GH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ha_GH' +func (ha *ha_GH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ha_GH' +func (ha *ha_GH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ha_GH' +func (ha *ha_GH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ha.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ha_GH/ha_GH_test.go b/vendor/github.com/go-playground/locales/ha_GH/ha_GH_test.go new file mode 100644 index 0000000000..8b02c4df5c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ha_GH/ha_GH_test.go @@ -0,0 +1,1120 @@ +package ha_GH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ha_GH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ha_NE/ha_NE.go b/vendor/github.com/go-playground/locales/ha_NE/ha_NE.go new file mode 100644 index 0000000000..8efb6a6da1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ha_NE/ha_NE.go @@ -0,0 +1,587 @@ +package ha_NE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ha_NE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ha_NE' locale +func New() locales.Translator { + return &ha_NE{ + locale: "ha_NE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan", "Fab", "Mar", "Afi", "May", "Yun", "Yul", "Agu", "Sat", "Okt", "Nuw", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Y", "Y", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janairu", "Faburairu", "Maris", "Afirilu", "Mayu", "Yuni", "Yuli", "Agusta", "Satumba", "Oktoba", "Nuwamba", "Disamba"}, + daysAbbreviated: []string{"Lah", "Lit", "Tal", "Lar", "Alh", "Jum", "Asa"}, + daysNarrow: []string{"L", "L", "T", "L", "A", "J", "A"}, + daysShort: []string{"Lh", "Li", "Ta", "Lr", "Al", "Ju", "As"}, + daysWide: []string{"Lahadi", "Litinin", "Talata", "Laraba", "Alhamis", "Jummaʼa", "Asabar"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"KHAI", "BHAI"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kafin haihuwar annab", "Bayan haihuwar annab"}, + timezones: map[string]string{"HECU": "HECU", "WIB": "WIB", "WIT": "WIT", "HEOG": "HEOG", "HNNOMX": "HNNOMX", "CAT": "CAT", "TMST": "TMST", "ACST": "ACST", "HNPM": "HNPM", "UYT": "UYT", "UYST": "UYST", "CST": "CST", "ECT": "ECT", "OEZ": "OEZ", "MDT": "MDT", "EST": "EST", "HNEG": "HNEG", "SRT": "SRT", "EAT": "EAT", "JDT": "JDT", "HKT": "HKT", "PST": "PST", "JST": "JST", "HEEG": "HEEG", "GFT": "GFT", "WESZ": "WESZ", "ARST": "ARST", "SAST": "SAST", "AWDT": "AWDT", "MESZ": "MESZ", "WART": "WART", "TMT": "TMT", "AEDT": "AEDT", "HEPM": "HEPM", "AWST": "AWST", "CHAST": "CHAST", "IST": "IST", "ACDT": "ACDT", "HEPMX": "HEPMX", "HAST": "HAST", "ADT": "ADT", "EDT": "EDT", "SGT": "SGT", "NZST": "NZST", "VET": "VET", "ART": "ART", "ChST": "ChST", "LHDT": "LHDT", "HAT": "HAT", "HNPMX": "HNPMX", "CHADT": "CHADT", "BOT": "BOT", "ACWDT": "ACWDT", "OESZ": "OESZ", "MYT": "MYT", "WAST": "WAST", "AKDT": "AKDT", "WITA": "WITA", "HNCU": "HNCU", "WEZ": "WEZ", "GMT": "GMT", "CLT": "CLT", "CLST": "CLST", "HENOMX": "HENOMX", "PDT": "PDT", "ACWST": "ACWST", "NZDT": "NZDT", "WAT": "WAT", "WARST": "WARST", "HNOG": "HNOG", "HKST": "HKST", "AEST": "AEST", "GYT": "GYT", "MEZ": "MEZ", "MST": "MST", "BT": "BT", "HNT": "HNT", "AKST": "AKST", "LHST": "LHST", "CDT": "CDT", "∅∅∅": "∅∅∅", "HADT": "HADT", "AST": "AST", "COT": "COT", "COST": "COST"}, + } +} + +// Locale returns the current translators string locale +func (ha *ha_NE) Locale() string { + return ha.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ha_NE' +func (ha *ha_NE) PluralsCardinal() []locales.PluralRule { + return ha.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ha_NE' +func (ha *ha_NE) PluralsOrdinal() []locales.PluralRule { + return ha.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ha_NE' +func (ha *ha_NE) PluralsRange() []locales.PluralRule { + return ha.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ha_NE' +func (ha *ha_NE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ha_NE' +func (ha *ha_NE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ha_NE' +func (ha *ha_NE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ha *ha_NE) MonthAbbreviated(month time.Month) string { + return ha.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ha *ha_NE) MonthsAbbreviated() []string { + return ha.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ha *ha_NE) MonthNarrow(month time.Month) string { + return ha.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ha *ha_NE) MonthsNarrow() []string { + return ha.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ha *ha_NE) MonthWide(month time.Month) string { + return ha.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ha *ha_NE) MonthsWide() []string { + return ha.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ha *ha_NE) WeekdayAbbreviated(weekday time.Weekday) string { + return ha.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ha *ha_NE) WeekdaysAbbreviated() []string { + return ha.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ha *ha_NE) WeekdayNarrow(weekday time.Weekday) string { + return ha.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ha *ha_NE) WeekdaysNarrow() []string { + return ha.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ha *ha_NE) WeekdayShort(weekday time.Weekday) string { + return ha.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ha *ha_NE) WeekdaysShort() []string { + return ha.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ha *ha_NE) WeekdayWide(weekday time.Weekday) string { + return ha.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ha *ha_NE) WeekdaysWide() []string { + return ha.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ha_NE' and handles both Whole and Real numbers based on 'v' +func (ha *ha_NE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ha_NE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ha *ha_NE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ha.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ha_NE' +func (ha *ha_NE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ha.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ha.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ha_NE' +// in accounting notation. +func (ha *ha_NE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ha.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyNegativePrefix[j]) + } + + b = append(b, ha.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ha.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ha_NE' +func (ha *ha_NE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ha_NE' +func (ha *ha_NE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ha_NE' +func (ha *ha_NE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ha_NE' +func (ha *ha_NE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ha.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ha_NE' +func (ha *ha_NE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ha_NE' +func (ha *ha_NE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ha_NE' +func (ha *ha_NE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ha_NE' +func (ha *ha_NE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ha.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ha_NE/ha_NE_test.go b/vendor/github.com/go-playground/locales/ha_NE/ha_NE_test.go new file mode 100644 index 0000000000..c7d01a9b0e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ha_NE/ha_NE_test.go @@ -0,0 +1,1120 @@ +package ha_NE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ha_NE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ha_NG/ha_NG.go b/vendor/github.com/go-playground/locales/ha_NG/ha_NG.go new file mode 100644 index 0000000000..52a230c1cd --- /dev/null +++ b/vendor/github.com/go-playground/locales/ha_NG/ha_NG.go @@ -0,0 +1,587 @@ +package ha_NG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ha_NG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ha_NG' locale +func New() locales.Translator { + return &ha_NG{ + locale: "ha_NG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan", "Fab", "Mar", "Afi", "May", "Yun", "Yul", "Agu", "Sat", "Okt", "Nuw", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Y", "Y", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janairu", "Faburairu", "Maris", "Afirilu", "Mayu", "Yuni", "Yuli", "Agusta", "Satumba", "Oktoba", "Nuwamba", "Disamba"}, + daysAbbreviated: []string{"Lah", "Lit", "Tal", "Lar", "Alh", "Jum", "Asa"}, + daysNarrow: []string{"L", "L", "T", "L", "A", "J", "A"}, + daysShort: []string{"Lh", "Li", "Ta", "Lr", "Al", "Ju", "As"}, + daysWide: []string{"Lahadi", "Litinin", "Talata", "Laraba", "Alhamis", "Jummaʼa", "Asabar"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"KHAI", "BHAI"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kafin haihuwar annab", "Bayan haihuwar annab"}, + timezones: map[string]string{"OESZ": "OESZ", "HNCU": "HNCU", "HAST": "HAST", "NZDT": "NZDT", "MYT": "MYT", "BOT": "BOT", "LHDT": "LHDT", "CHADT": "CHADT", "PDT": "PDT", "CAT": "CAT", "MEZ": "MEZ", "WARST": "WARST", "AKDT": "AKDT", "UYST": "UYST", "NZST": "NZST", "ACWST": "ACWST", "ADT": "ADT", "HKST": "HKST", "BT": "BT", "HADT": "HADT", "UYT": "UYT", "SAST": "SAST", "HECU": "HECU", "ART": "ART", "MST": "MST", "HNEG": "HNEG", "AKST": "AKST", "ECT": "ECT", "IST": "IST", "WEZ": "WEZ", "WESZ": "WESZ", "EDT": "EDT", "HAT": "HAT", "CDT": "CDT", "PST": "PST", "GMT": "GMT", "WART": "WART", "AST": "AST", "AEDT": "AEDT", "HEEG": "HEEG", "HNPMX": "HNPMX", "JDT": "JDT", "TMST": "TMST", "∅∅∅": "∅∅∅", "HNT": "HNT", "SRT": "SRT", "LHST": "LHST", "GYT": "GYT", "WIT": "WIT", "AWDT": "AWDT", "CLST": "CLST", "COST": "COST", "WAST": "WAST", "ARST": "ARST", "EAT": "EAT", "AWST": "AWST", "SGT": "SGT", "EST": "EST", "AEST": "AEST", "WIB": "WIB", "WITA": "WITA", "GFT": "GFT", "CST": "CST", "CHAST": "CHAST", "ACWDT": "ACWDT", "MESZ": "MESZ", "JST": "JST", "CLT": "CLT", "MDT": "MDT", "WAT": "WAT", "HKT": "HKT", "HNOG": "HNOG", "HNNOMX": "HNNOMX", "COT": "COT", "ChST": "ChST", "HNPM": "HNPM", "VET": "VET", "HEOG": "HEOG", "ACST": "ACST", "HENOMX": "HENOMX", "HEPM": "HEPM", "HEPMX": "HEPMX", "OEZ": "OEZ", "TMT": "TMT", "ACDT": "ACDT"}, + } +} + +// Locale returns the current translators string locale +func (ha *ha_NG) Locale() string { + return ha.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ha_NG' +func (ha *ha_NG) PluralsCardinal() []locales.PluralRule { + return ha.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ha_NG' +func (ha *ha_NG) PluralsOrdinal() []locales.PluralRule { + return ha.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ha_NG' +func (ha *ha_NG) PluralsRange() []locales.PluralRule { + return ha.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ha_NG' +func (ha *ha_NG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ha_NG' +func (ha *ha_NG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ha_NG' +func (ha *ha_NG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ha *ha_NG) MonthAbbreviated(month time.Month) string { + return ha.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ha *ha_NG) MonthsAbbreviated() []string { + return ha.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ha *ha_NG) MonthNarrow(month time.Month) string { + return ha.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ha *ha_NG) MonthsNarrow() []string { + return ha.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ha *ha_NG) MonthWide(month time.Month) string { + return ha.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ha *ha_NG) MonthsWide() []string { + return ha.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ha *ha_NG) WeekdayAbbreviated(weekday time.Weekday) string { + return ha.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ha *ha_NG) WeekdaysAbbreviated() []string { + return ha.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ha *ha_NG) WeekdayNarrow(weekday time.Weekday) string { + return ha.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ha *ha_NG) WeekdaysNarrow() []string { + return ha.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ha *ha_NG) WeekdayShort(weekday time.Weekday) string { + return ha.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ha *ha_NG) WeekdaysShort() []string { + return ha.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ha *ha_NG) WeekdayWide(weekday time.Weekday) string { + return ha.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ha *ha_NG) WeekdaysWide() []string { + return ha.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ha_NG' and handles both Whole and Real numbers based on 'v' +func (ha *ha_NG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ha_NG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ha *ha_NG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ha.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ha_NG' +func (ha *ha_NG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ha.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ha.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ha.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ha_NG' +// in accounting notation. +func (ha *ha_NG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ha.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ha.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ha.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyNegativePrefix[j]) + } + + b = append(b, ha.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ha.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ha.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ha.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ha_NG' +func (ha *ha_NG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ha_NG' +func (ha *ha_NG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ha_NG' +func (ha *ha_NG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ha_NG' +func (ha *ha_NG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ha.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ha.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ha_NG' +func (ha *ha_NG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ha_NG' +func (ha *ha_NG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ha_NG' +func (ha *ha_NG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ha_NG' +func (ha *ha_NG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ha.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ha.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ha.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ha_NG/ha_NG_test.go b/vendor/github.com/go-playground/locales/ha_NG/ha_NG_test.go new file mode 100644 index 0000000000..bbed7794c5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ha_NG/ha_NG_test.go @@ -0,0 +1,1120 @@ +package ha_NG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ha_NG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/haw/haw.go b/vendor/github.com/go-playground/locales/haw/haw.go new file mode 100644 index 0000000000..eba60314bc --- /dev/null +++ b/vendor/github.com/go-playground/locales/haw/haw.go @@ -0,0 +1,621 @@ +package haw + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type haw struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'haw' locale +func New() locales.Translator { + return &haw{ + locale: "haw", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ian.", "Pep.", "Mal.", "ʻAp.", "Mei", "Iun.", "Iul.", "ʻAu.", "Kep.", "ʻOk.", "Now.", "Kek."}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Ianuali", "Pepeluali", "Malaki", "ʻApelila", "Mei", "Iune", "Iulai", "ʻAukake", "Kepakemapa", "ʻOkakopa", "Nowemapa", "Kekemapa"}, + daysAbbreviated: []string{"LP", "P1", "P2", "P3", "P4", "P5", "P6"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"LP", "P1", "P2", "P3", "P4", "P5", "P6"}, + daysWide: []string{"Lāpule", "Poʻakahi", "Poʻalua", "Poʻakolu", "Poʻahā", "Poʻalima", "Poʻaono"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"BCE", "CE"}, + timezones: map[string]string{"VET": "VET", "EDT": "EDT", "HNT": "HNT", "MDT": "MDT", "HENOMX": "HENOMX", "UYST": "UYST", "ECT": "ECT", "NZDT": "NZDT", "MEZ": "MEZ", "HNOG": "HNOG", "AKST": "AKST", "AWST": "AWST", "AWDT": "AWDT", "BOT": "BOT", "NZST": "NZST", "GMT": "GMT", "MST": "MST", "COST": "COST", "HKT": "HKT", "ACST": "ACST", "HEEG": "HEEG", "HEPMX": "HEPMX", "HEOG": "HEOG", "TMST": "TMST", "WAST": "WAST", "COT": "COT", "CAT": "CAT", "OEZ": "OEZ", "OESZ": "OESZ", "WESZ": "WESZ", "ChST": "ChST", "SAST": "SAST", "AEST": "AEST", "AKDT": "AKDT", "HNPM": "HNPM", "HEPM": "HEPM", "HNEG": "HNEG", "WIB": "WIB", "WIT": "WIT", "CHADT": "CHADT", "PDT": "PDT", "HAST": "HAST", "ACWDT": "ACWDT", "ARST": "ARST", "BT": "BT", "LHDT": "LHDT", "AEDT": "AEDT", "WITA": "WITA", "HNCU": "HNCU", "PST": "PST", "HADT": "HADT", "IST": "IST", "WARST": "WARST", "SRT": "SRT", "GYT": "GYT", "ACWST": "ACWST", "JDT": "JDT", "GFT": "GFT", "LHST": "LHST", "EAT": "EAT", "∅∅∅": "∅∅∅", "JST": "JST", "ACDT": "ACDT", "UYT": "UYT", "CDT": "CDT", "ADT": "ADT", "HKST": "HKST", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "WEZ": "WEZ", "CLST": "CLST", "TMT": "TMT", "WAT": "WAT", "CST": "CST", "MYT": "MYT", "WART": "WART", "CLT": "CLT", "HECU": "HECU", "MESZ": "MESZ", "SGT": "SGT", "CHAST": "CHAST", "AST": "AST", "ART": "ART", "EST": "EST", "HAT": "HAT"}, + } +} + +// Locale returns the current translators string locale +func (haw *haw) Locale() string { + return haw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'haw' +func (haw *haw) PluralsCardinal() []locales.PluralRule { + return haw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'haw' +func (haw *haw) PluralsOrdinal() []locales.PluralRule { + return haw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'haw' +func (haw *haw) PluralsRange() []locales.PluralRule { + return haw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'haw' +func (haw *haw) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'haw' +func (haw *haw) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'haw' +func (haw *haw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (haw *haw) MonthAbbreviated(month time.Month) string { + return haw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (haw *haw) MonthsAbbreviated() []string { + return haw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (haw *haw) MonthNarrow(month time.Month) string { + return haw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (haw *haw) MonthsNarrow() []string { + return haw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (haw *haw) MonthWide(month time.Month) string { + return haw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (haw *haw) MonthsWide() []string { + return haw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (haw *haw) WeekdayAbbreviated(weekday time.Weekday) string { + return haw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (haw *haw) WeekdaysAbbreviated() []string { + return haw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (haw *haw) WeekdayNarrow(weekday time.Weekday) string { + return haw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (haw *haw) WeekdaysNarrow() []string { + return haw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (haw *haw) WeekdayShort(weekday time.Weekday) string { + return haw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (haw *haw) WeekdaysShort() []string { + return haw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (haw *haw) WeekdayWide(weekday time.Weekday) string { + return haw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (haw *haw) WeekdaysWide() []string { + return haw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'haw' and handles both Whole and Real numbers based on 'v' +func (haw *haw) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, haw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, haw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, haw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'haw' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (haw *haw) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, haw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, haw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, haw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'haw' +func (haw *haw) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := haw.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, haw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, haw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, haw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, haw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'haw' +// in accounting notation. +func (haw *haw) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := haw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, haw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, haw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, haw.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, haw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, haw.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'haw' +func (haw *haw) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'haw' +func (haw *haw) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, haw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'haw' +func (haw *haw) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, haw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'haw' +func (haw *haw) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, haw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, haw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'haw' +func (haw *haw) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, haw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, haw.periodsAbbreviated[0]...) + } else { + b = append(b, haw.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'haw' +func (haw *haw) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, haw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, haw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, haw.periodsAbbreviated[0]...) + } else { + b = append(b, haw.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'haw' +func (haw *haw) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, haw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, haw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, haw.periodsAbbreviated[0]...) + } else { + b = append(b, haw.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'haw' +func (haw *haw) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, haw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, haw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, haw.periodsAbbreviated[0]...) + } else { + b = append(b, haw.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := haw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/haw/haw_test.go b/vendor/github.com/go-playground/locales/haw/haw_test.go new file mode 100644 index 0000000000..61048ac58b --- /dev/null +++ b/vendor/github.com/go-playground/locales/haw/haw_test.go @@ -0,0 +1,1120 @@ +package haw + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "haw" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/haw_US/haw_US.go b/vendor/github.com/go-playground/locales/haw_US/haw_US.go new file mode 100644 index 0000000000..e0bcd95b1a --- /dev/null +++ b/vendor/github.com/go-playground/locales/haw_US/haw_US.go @@ -0,0 +1,621 @@ +package haw_US + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type haw_US struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'haw_US' locale +func New() locales.Translator { + return &haw_US{ + locale: "haw_US", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ian.", "Pep.", "Mal.", "ʻAp.", "Mei", "Iun.", "Iul.", "ʻAu.", "Kep.", "ʻOk.", "Now.", "Kek."}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Ianuali", "Pepeluali", "Malaki", "ʻApelila", "Mei", "Iune", "Iulai", "ʻAukake", "Kepakemapa", "ʻOkakopa", "Nowemapa", "Kekemapa"}, + daysAbbreviated: []string{"LP", "P1", "P2", "P3", "P4", "P5", "P6"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"LP", "P1", "P2", "P3", "P4", "P5", "P6"}, + daysWide: []string{"Lāpule", "Poʻakahi", "Poʻalua", "Poʻakolu", "Poʻahā", "Poʻalima", "Poʻaono"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"BCE", "CE"}, + timezones: map[string]string{"TMST": "TMST", "EST": "EST", "CDT": "CDT", "NZST": "NZST", "MESZ": "MESZ", "HEPMX": "HEPMX", "WIB": "WIB", "MDT": "MDT", "SAST": "SAST", "LHST": "LHST", "AWST": "AWST", "CLT": "CLT", "ADT": "ADT", "MST": "MST", "HEPM": "HEPM", "HNPMX": "HNPMX", "COT": "COT", "GYT": "GYT", "CHAST": "CHAST", "AKST": "AKST", "ChST": "ChST", "CHADT": "CHADT", "JDT": "JDT", "GMT": "GMT", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "WITA": "WITA", "WESZ": "WESZ", "MYT": "MYT", "HEEG": "HEEG", "PDT": "PDT", "HADT": "HADT", "VET": "VET", "HEOG": "HEOG", "GFT": "GFT", "HECU": "HECU", "ACWST": "ACWST", "JST": "JST", "UYST": "UYST", "HNPM": "HNPM", "OESZ": "OESZ", "WIT": "WIT", "CAT": "CAT", "NZDT": "NZDT", "HNT": "HNT", "AEST": "AEST", "UYT": "UYT", "ART": "ART", "PST": "PST", "OEZ": "OEZ", "WEZ": "WEZ", "AWDT": "AWDT", "IST": "IST", "AST": "AST", "EDT": "EDT", "HKT": "HKT", "ACST": "ACST", "HAT": "HAT", "SRT": "SRT", "MEZ": "MEZ", "HNOG": "HNOG", "HNEG": "HNEG", "HAST": "HAST", "ECT": "ECT", "HKST": "HKST", "EAT": "EAT", "HNCU": "HNCU", "BOT": "BOT", "CLST": "CLST", "WARST": "WARST", "BT": "BT", "LHDT": "LHDT", "ACWDT": "ACWDT", "AKDT": "AKDT", "AEDT": "AEDT", "CST": "CST", "SGT": "SGT", "WART": "WART", "COST": "COST", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "WAST": "WAST", "TMT": "TMT", "ARST": "ARST", "WAT": "WAT"}, + } +} + +// Locale returns the current translators string locale +func (haw *haw_US) Locale() string { + return haw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'haw_US' +func (haw *haw_US) PluralsCardinal() []locales.PluralRule { + return haw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'haw_US' +func (haw *haw_US) PluralsOrdinal() []locales.PluralRule { + return haw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'haw_US' +func (haw *haw_US) PluralsRange() []locales.PluralRule { + return haw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'haw_US' +func (haw *haw_US) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'haw_US' +func (haw *haw_US) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'haw_US' +func (haw *haw_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (haw *haw_US) MonthAbbreviated(month time.Month) string { + return haw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (haw *haw_US) MonthsAbbreviated() []string { + return haw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (haw *haw_US) MonthNarrow(month time.Month) string { + return haw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (haw *haw_US) MonthsNarrow() []string { + return haw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (haw *haw_US) MonthWide(month time.Month) string { + return haw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (haw *haw_US) MonthsWide() []string { + return haw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (haw *haw_US) WeekdayAbbreviated(weekday time.Weekday) string { + return haw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (haw *haw_US) WeekdaysAbbreviated() []string { + return haw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (haw *haw_US) WeekdayNarrow(weekday time.Weekday) string { + return haw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (haw *haw_US) WeekdaysNarrow() []string { + return haw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (haw *haw_US) WeekdayShort(weekday time.Weekday) string { + return haw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (haw *haw_US) WeekdaysShort() []string { + return haw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (haw *haw_US) WeekdayWide(weekday time.Weekday) string { + return haw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (haw *haw_US) WeekdaysWide() []string { + return haw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'haw_US' and handles both Whole and Real numbers based on 'v' +func (haw *haw_US) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, haw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, haw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, haw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'haw_US' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (haw *haw_US) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, haw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, haw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, haw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'haw_US' +func (haw *haw_US) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := haw.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, haw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, haw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, haw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, haw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'haw_US' +// in accounting notation. +func (haw *haw_US) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := haw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, haw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, haw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, haw.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, haw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, haw.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'haw_US' +func (haw *haw_US) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'haw_US' +func (haw *haw_US) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, haw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'haw_US' +func (haw *haw_US) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, haw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'haw_US' +func (haw *haw_US) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, haw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, haw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'haw_US' +func (haw *haw_US) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, haw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, haw.periodsAbbreviated[0]...) + } else { + b = append(b, haw.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'haw_US' +func (haw *haw_US) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, haw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, haw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, haw.periodsAbbreviated[0]...) + } else { + b = append(b, haw.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'haw_US' +func (haw *haw_US) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, haw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, haw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, haw.periodsAbbreviated[0]...) + } else { + b = append(b, haw.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'haw_US' +func (haw *haw_US) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, haw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, haw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, haw.periodsAbbreviated[0]...) + } else { + b = append(b, haw.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := haw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/haw_US/haw_US_test.go b/vendor/github.com/go-playground/locales/haw_US/haw_US_test.go new file mode 100644 index 0000000000..e6c5f2a8e0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/haw_US/haw_US_test.go @@ -0,0 +1,1120 @@ +package haw_US + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "haw_US" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/he/he.go b/vendor/github.com/go-playground/locales/he/he.go new file mode 100644 index 0000000000..c31c30e4a8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/he/he.go @@ -0,0 +1,603 @@ +package he + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type he struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'he' locale +func New() locales.Translator { + return &he{ + locale: "he", + pluralsCardinal: []locales.PluralRule{2, 3, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{5, 6}, + decimal: ".", + group: ",", + minus: "‎-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "\u200eCN¥\u200e", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ל״י", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ינו׳", "פבר׳", "מרץ", "אפר׳", "מאי", "יוני", "יולי", "אוג׳", "ספט׳", "אוק׳", "נוב׳", "דצמ׳"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"}, + daysAbbreviated: []string{"יום א׳", "יום ב׳", "יום ג׳", "יום ד׳", "יום ה׳", "יום ו׳", "שבת"}, + daysNarrow: []string{"א׳", "ב׳", "ג׳", "ד׳", "ה׳", "ו׳", "ש׳"}, + daysShort: []string{"א׳", "ב׳", "ג׳", "ד׳", "ה׳", "ו׳", "ש׳"}, + daysWide: []string{"יום ראשון", "יום שני", "יום שלישי", "יום רביעי", "יום חמישי", "יום שישי", "יום שבת"}, + periodsAbbreviated: []string{"לפנה״צ", "אחה״צ"}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"לפנה״צ", "אחה״צ"}, + erasAbbreviated: []string{"לפנה״ס", "לספירה"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"∅∅∅": "שעון אמזונס (קיץ)", "EST": "שעון החוף המזרחי (חורף)", "GFT": "שעון גיאנה הצרפתית", "AWDT": "שעון מערב אוסטרליה (קיץ)", "SGT": "שעון סינגפור", "NZST": "שעון ניו זילנד (חורף)", "TMST": "שעון טורקמניסטן (קיץ)", "HKST": "שעון הונג קונג (קיץ)", "HEPM": "שעון סנט פייר ומיקלון (קיץ)", "PDT": "שעון מערב ארה״ב (קיץ)", "HNOG": "שעון מערב גרינלנד (חורף)", "CLT": "שעון צ׳ילה (חורף)", "CLST": "שעון צ׳ילה (קיץ)", "WEZ": "שעון מערב אירופה (חורף)", "MDT": "שעון קיץ מקאו", "AEST": "שעון מזרח אוסטרליה (חורף)", "ChST": "שעון צ׳אמורו", "CAT": "שעון מרכז אפריקה", "ACWDT": "שעון מרכז-מערב אוסטרליה (קיץ)", "TMT": "שעון טורקמניסטן (חורף)", "AKDT": "שעון אלסקה (קיץ)", "HNCU": "שעון קובה (חורף)", "WIB": "שעון מערב אינדונזיה", "CHAST": "שעון צ׳טהאם (חורף)", "OEZ": "שעון מזרח אירופה (חורף)", "LHST": "שעון אי הלורד האו (חורף)", "EAT": "שעון מזרח אפריקה", "ACST": "שעון מרכז אוסטרליה (חורף)", "HAT": "שעון ניופאונדלנד (קיץ)", "WARST": "שעון מערב ארגנטינה (קיץ)", "WAT": "שעון מערב אפריקה (חורף)", "HNEG": "שעון מזרח גרינלנד (חורף)", "WIT": "שעון מזרח אינדונזיה", "CHADT": "שעון צ׳טהאם (קיץ)", "ADT": "שעון האוקיינוס האטלנטי (קיץ)", "COT": "שעון קולומביה (חורף)", "UYT": "שעון אורוגוואי (חורף)", "ACWST": "שעון מרכז-מערב אוסטרליה (חורף)", "VET": "שעון ונצואלה", "AWST": "שעון מערב אוסטרליה (חורף)", "ART": "שעון ארגנטינה (חורף)", "UYST": "שעון אורוגוואי (קיץ)", "WART": "שעון מערב ארגנטינה (חורף)", "ARST": "שעון ארגנטינה (קיץ)", "EDT": "שעון החוף המזרחי (קיץ)", "ACDT": "שעון מרכז אוסטרליה (קיץ)", "HNNOMX": "שעון צפון-מערב מקסיקו (חורף)", "SAST": "שעון דרום אפריקה", "NZDT": "שעון ניו זילנד (קיץ)", "AST": "שעון האוקיינוס האטלנטי (חורף)", "MST": "שעון חורף מקאו", "SRT": "שעון סורינאם", "GYT": "שעון גיאנה", "CST": "שעון מרכז ארה״ב (חורף)", "CDT": "שעון מרכז ארה״ב (קיץ)", "ECT": "שעון אקוודור", "IST": "שעון הודו", "OESZ": "שעון מזרח אירופה (קיץ)", "HNT": "שעון ניופאונדלנד (חורף)", "HEEG": "שעון מזרח גרינלנד (קיץ)", "MEZ": "שעון מרכז אירופה (חורף)", "JDT": "שעון יפן (קיץ)", "HKT": "שעון הונג קונג (חורף)", "MESZ": "שעון מרכז אירופה (קיץ)", "JST": "שעון יפן (חורף)", "HENOMX": "שעון צפון-מערב מקסיקו (קיץ)", "HNPM": "שעון סנט פייר ומיקלון (חורף)", "HEPMX": "שעון מערב מקסיקו (קיץ)", "HEOG": "שעון מערב גרינלנד (קיץ)", "MYT": "שעון מלזיה", "WITA": "שעון מרכז אינדונזיה", "COST": "שעון קולומביה (קיץ)", "BT": "שעון בהוטן", "AEDT": "שעון מזרח אוסטרליה (קיץ)", "HADT": "שעון האיים האלאוטיים הוואי (קיץ)", "GMT": "שעון גריניץ׳\u200f", "HAST": "שעון האיים האלאוטיים הוואי (חורף)", "WESZ": "שעון מערב אירופה (קיץ)", "WAST": "שעון מערב אפריקה (קיץ)", "AKST": "שעון אלסקה (חורף)", "LHDT": "שעון אי הלורד האו (קיץ)", "HNPMX": "שעון מערב מקסיקו (חורף)", "BOT": "שעון בוליביה", "PST": "שעון מערב ארה״ב (חורף)", "HECU": "שעון קובה (קיץ)"}, + } +} + +// Locale returns the current translators string locale +func (he *he) Locale() string { + return he.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'he' +func (he *he) PluralsCardinal() []locales.PluralRule { + return he.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'he' +func (he *he) PluralsOrdinal() []locales.PluralRule { + return he.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'he' +func (he *he) PluralsRange() []locales.PluralRule { + return he.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'he' +func (he *he) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + nMod10 := math.Mod(n, 10) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if i == 2 && v == 0 { + return locales.PluralRuleTwo + } else if v == 0 && (n < 0 || n > 10) && nMod10 == 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'he' +func (he *he) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'he' +func (he *he) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := he.CardinalPluralRule(num1, v1) + end := he.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (he *he) MonthAbbreviated(month time.Month) string { + return he.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (he *he) MonthsAbbreviated() []string { + return he.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (he *he) MonthNarrow(month time.Month) string { + return he.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (he *he) MonthsNarrow() []string { + return he.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (he *he) MonthWide(month time.Month) string { + return he.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (he *he) MonthsWide() []string { + return he.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (he *he) WeekdayAbbreviated(weekday time.Weekday) string { + return he.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (he *he) WeekdaysAbbreviated() []string { + return he.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (he *he) WeekdayNarrow(weekday time.Weekday) string { + return he.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (he *he) WeekdaysNarrow() []string { + return he.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (he *he) WeekdayShort(weekday time.Weekday) string { + return he.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (he *he) WeekdaysShort() []string { + return he.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (he *he) WeekdayWide(weekday time.Weekday) string { + return he.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (he *he) WeekdaysWide() []string { + return he.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'he' and handles both Whole and Real numbers based on 'v' +func (he *he) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, he.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, he.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(he.minus) - 1; j >= 0; j-- { + b = append(b, he.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'he' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (he *he) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, he.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(he.minus) - 1; j >= 0; j-- { + b = append(b, he.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, he.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'he' +func (he *he) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := he.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, he.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, he.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(he.minus) - 1; j >= 0; j-- { + b = append(b, he.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, he.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, he.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'he' +// in accounting notation. +func (he *he) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := he.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, he.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, he.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(he.minus) - 1; j >= 0; j-- { + b = append(b, he.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, he.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, he.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, he.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'he' +func (he *he) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'he' +func (he *he) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd7, 0x91}...) + b = append(b, he.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'he' +func (he *he) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd7, 0x91}...) + b = append(b, he.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'he' +func (he *he) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, he.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd7, 0x91}...) + b = append(b, he.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'he' +func (he *he) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, he.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'he' +func (he *he) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, he.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, he.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'he' +func (he *he) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, he.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, he.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'he' +func (he *he) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, he.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, he.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := he.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/he/he_test.go b/vendor/github.com/go-playground/locales/he/he_test.go new file mode 100644 index 0000000000..2aaf828461 --- /dev/null +++ b/vendor/github.com/go-playground/locales/he/he_test.go @@ -0,0 +1,1120 @@ +package he + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "he" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/he_IL/he_IL.go b/vendor/github.com/go-playground/locales/he_IL/he_IL.go new file mode 100644 index 0000000000..0a4ff0e286 --- /dev/null +++ b/vendor/github.com/go-playground/locales/he_IL/he_IL.go @@ -0,0 +1,603 @@ +package he_IL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type he_IL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'he_IL' locale +func New() locales.Translator { + return &he_IL{ + locale: "he_IL", + pluralsCardinal: []locales.PluralRule{2, 3, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{5, 6}, + decimal: ".", + group: ",", + minus: "‎-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ינו׳", "פבר׳", "מרץ", "אפר׳", "מאי", "יוני", "יולי", "אוג׳", "ספט׳", "אוק׳", "נוב׳", "דצמ׳"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"}, + daysAbbreviated: []string{"יום א׳", "יום ב׳", "יום ג׳", "יום ד׳", "יום ה׳", "יום ו׳", "שבת"}, + daysNarrow: []string{"א׳", "ב׳", "ג׳", "ד׳", "ה׳", "ו׳", "ש׳"}, + daysShort: []string{"א׳", "ב׳", "ג׳", "ד׳", "ה׳", "ו׳", "ש׳"}, + daysWide: []string{"יום ראשון", "יום שני", "יום שלישי", "יום רביעי", "יום חמישי", "יום שישי", "יום שבת"}, + periodsAbbreviated: []string{"לפנה״צ", "אחה״צ"}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"לפנה״צ", "אחה״צ"}, + erasAbbreviated: []string{"לפנה״ס", "לספירה"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"COT": "שעון קולומביה (חורף)", "LHST": "שעון אי הלורד האו (חורף)", "PDT": "שעון מערב ארה״ב (קיץ)", "ARST": "שעון ארגנטינה (קיץ)", "WESZ": "שעון מערב אירופה (קיץ)", "OESZ": "שעון מזרח אירופה (קיץ)", "HNEG": "שעון מזרח גרינלנד (חורף)", "ChST": "שעון צ׳אמורו", "CST": "שעון מרכז ארה״ב (חורף)", "HEEG": "שעון מזרח גרינלנד (קיץ)", "WIB": "שעון מערב אינדונזיה", "ACWST": "שעון מרכז-מערב אוסטרליה (חורף)", "JST": "שעון יפן (חורף)", "WART": "שעון מערב ארגנטינה (חורף)", "OEZ": "שעון מזרח אירופה (חורף)", "HNT": "שעון ניופאונדלנד (חורף)", "HNCU": "שעון קובה (חורף)", "ECT": "שעון אקוודור", "PST": "שעון מערב ארה״ב (חורף)", "CLT": "שעון צ׳ילה (חורף)", "ADT": "שעון האוקיינוס האטלנטי (קיץ)", "ART": "שעון ארגנטינה (חורף)", "EST": "שעון החוף המזרחי (חורף)", "HNPM": "שעון סנט פייר ומיקלון (חורף)", "GYT": "שעון גיאנה", "EAT": "שעון מזרח אפריקה", "AKDT": "שעון אלסקה (קיץ)", "HEPM": "שעון סנט פייר ומיקלון (קיץ)", "WARST": "שעון מערב ארגנטינה (קיץ)", "CHAST": "שעון צ׳טהאם (חורף)", "WAT": "שעון מערב אפריקה (חורף)", "HENOMX": "שעון צפון-מערב מקסיקו (קיץ)", "ACDT": "שעון מרכז אוסטרליה (קיץ)", "BT": "שעון בהוטן", "AEST": "שעון מזרח אוסטרליה (חורף)", "AKST": "שעון אלסקה (חורף)", "UYT": "שעון אורוגוואי (חורף)", "MEZ": "שעון מרכז אירופה (חורף)", "MESZ": "שעון מרכז אירופה (קיץ)", "WEZ": "שעון מערב אירופה (חורף)", "HNOG": "שעון מערב גרינלנד (חורף)", "AST": "שעון האוקיינוס האטלנטי (חורף)", "COST": "שעון קולומביה (קיץ)", "MDT": "שעון אזור ההרים בארה״ב (קיץ)", "WITA": "שעון מרכז אינדונזיה", "SRT": "שעון סורינאם", "SGT": "שעון סינגפור", "JDT": "שעון יפן (קיץ)", "TMST": "שעון טורקמניסטן (קיץ)", "WAST": "שעון מערב אפריקה (קיץ)", "EDT": "שעון החוף המזרחי (קיץ)", "HAT": "שעון ניופאונדלנד (קיץ)", "LHDT": "שעון אי הלורד האו (קיץ)", "CDT": "שעון מרכז ארה״ב (קיץ)", "HNNOMX": "שעון צפון-מערב מקסיקו (חורף)", "HKST": "שעון הונג קונג (קיץ)", "MST": "שעון אזור ההרים בארה״ב (חורף)", "HADT": "שעון האיים האלאוטיים הוואי (קיץ)", "TMT": "שעון טורקמניסטן (חורף)", "ACST": "שעון מרכז אוסטרליה (חורף)", "AWDT": "שעון מערב אוסטרליה (קיץ)", "BOT": "שעון בוליביה", "GMT": "שעון גריניץ׳\u200f", "SAST": "שעון דרום אפריקה", "CAT": "שעון מרכז אפריקה", "HKT": "שעון הונג קונג (חורף)", "HECU": "שעון קובה (קיץ)", "WIT": "שעון מזרח אינדונזיה", "AWST": "שעון מערב אוסטרליה (חורף)", "CHADT": "שעון צ׳טהאם (קיץ)", "HAST": "שעון האיים האלאוטיים הוואי (חורף)", "∅∅∅": "∅∅∅", "GFT": "שעון גיאנה הצרפתית", "HEPMX": "שעון מערב מקסיקו (קיץ)", "HEOG": "שעון מערב גרינלנד (קיץ)", "IST": "שעון הודו", "VET": "שעון ונצואלה", "CLST": "שעון צ׳ילה (קיץ)", "UYST": "שעון אורוגוואי (קיץ)", "HNPMX": "שעון מערב מקסיקו (חורף)", "NZDT": "שעון ניו זילנד (קיץ)", "MYT": "שעון מלזיה", "AEDT": "שעון מזרח אוסטרליה (קיץ)", "ACWDT": "שעון מרכז-מערב אוסטרליה (קיץ)", "NZST": "שעון ניו זילנד (חורף)"}, + } +} + +// Locale returns the current translators string locale +func (he *he_IL) Locale() string { + return he.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'he_IL' +func (he *he_IL) PluralsCardinal() []locales.PluralRule { + return he.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'he_IL' +func (he *he_IL) PluralsOrdinal() []locales.PluralRule { + return he.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'he_IL' +func (he *he_IL) PluralsRange() []locales.PluralRule { + return he.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'he_IL' +func (he *he_IL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + nMod10 := math.Mod(n, 10) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if i == 2 && v == 0 { + return locales.PluralRuleTwo + } else if v == 0 && (n < 0 || n > 10) && nMod10 == 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'he_IL' +func (he *he_IL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'he_IL' +func (he *he_IL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := he.CardinalPluralRule(num1, v1) + end := he.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleMany { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (he *he_IL) MonthAbbreviated(month time.Month) string { + return he.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (he *he_IL) MonthsAbbreviated() []string { + return he.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (he *he_IL) MonthNarrow(month time.Month) string { + return he.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (he *he_IL) MonthsNarrow() []string { + return he.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (he *he_IL) MonthWide(month time.Month) string { + return he.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (he *he_IL) MonthsWide() []string { + return he.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (he *he_IL) WeekdayAbbreviated(weekday time.Weekday) string { + return he.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (he *he_IL) WeekdaysAbbreviated() []string { + return he.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (he *he_IL) WeekdayNarrow(weekday time.Weekday) string { + return he.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (he *he_IL) WeekdaysNarrow() []string { + return he.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (he *he_IL) WeekdayShort(weekday time.Weekday) string { + return he.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (he *he_IL) WeekdaysShort() []string { + return he.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (he *he_IL) WeekdayWide(weekday time.Weekday) string { + return he.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (he *he_IL) WeekdaysWide() []string { + return he.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'he_IL' and handles both Whole and Real numbers based on 'v' +func (he *he_IL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, he.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, he.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(he.minus) - 1; j >= 0; j-- { + b = append(b, he.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'he_IL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (he *he_IL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, he.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(he.minus) - 1; j >= 0; j-- { + b = append(b, he.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, he.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'he_IL' +func (he *he_IL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := he.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, he.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, he.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(he.minus) - 1; j >= 0; j-- { + b = append(b, he.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, he.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, he.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'he_IL' +// in accounting notation. +func (he *he_IL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := he.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, he.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, he.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(he.minus) - 1; j >= 0; j-- { + b = append(b, he.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, he.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, he.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, he.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'he_IL' +func (he *he_IL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'he_IL' +func (he *he_IL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd7, 0x91}...) + b = append(b, he.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'he_IL' +func (he *he_IL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd7, 0x91}...) + b = append(b, he.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'he_IL' +func (he *he_IL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, he.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd7, 0x91}...) + b = append(b, he.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'he_IL' +func (he *he_IL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, he.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'he_IL' +func (he *he_IL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, he.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, he.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'he_IL' +func (he *he_IL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, he.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, he.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'he_IL' +func (he *he_IL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, he.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, he.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := he.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/he_IL/he_IL_test.go b/vendor/github.com/go-playground/locales/he_IL/he_IL_test.go new file mode 100644 index 0000000000..3c21e6077c --- /dev/null +++ b/vendor/github.com/go-playground/locales/he_IL/he_IL_test.go @@ -0,0 +1,1120 @@ +package he_IL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "he_IL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hi/hi.go b/vendor/github.com/go-playground/locales/hi/hi.go new file mode 100644 index 0000000000..818824028c --- /dev/null +++ b/vendor/github.com/go-playground/locales/hi/hi.go @@ -0,0 +1,675 @@ +package hi + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hi struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hi' locale +func New() locales.Translator { + return &hi{ + locale: "hi", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "जन॰", "फ़र॰", "मार्च", "अप्रैल", "मई", "जून", "जुल॰", "अग॰", "सित॰", "अक्तू॰", "नव॰", "दिस॰"}, + monthsNarrow: []string{"", "ज", "फ़", "मा", "अ", "म", "जू", "जु", "अ", "सि", "अ", "न", "दि"}, + monthsWide: []string{"", "जनवरी", "फ़रवरी", "मार्च", "अप्रैल", "मई", "जून", "जुलाई", "अगस्त", "सितंबर", "अक्तूबर", "नवंबर", "दिसंबर"}, + daysAbbreviated: []string{"रवि", "सोम", "मंगल", "बुध", "गुरु", "शुक्र", "शनि"}, + daysNarrow: []string{"र", "सो", "मं", "बु", "गु", "शु", "श"}, + daysShort: []string{"र", "सो", "मं", "बु", "गु", "शु", "श"}, + daysWide: []string{"रविवार", "सोमवार", "मंगलवार", "बुधवार", "गुरुवार", "शुक्रवार", "शनिवार"}, + periodsAbbreviated: []string{"पूर्वाह्न", "अपराह्न"}, + periodsNarrow: []string{"पू", "अ"}, + periodsWide: []string{"पूर्वाह्न", "अपराह्न"}, + erasAbbreviated: []string{"ईसा-पूर्व", "ईस्वी"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ईसा-पूर्व", "ईसवी सन"}, + timezones: map[string]string{"ECT": "इक्वाडोर समय", "HAST": "हवाई–आल्यूशन मानक समय", "WART": "पश्चिमी अर्जेंटीना मानक समय", "HEPMX": "मेक्सिकन प्रशांत डेलाइट समय", "AWDT": "ऑस्ट्रेलियाई पश्चिमी डेलाइट समय", "BOT": "बोलीविया समय", "TMST": "तुर्कमेनिस्तान ग्रीष्मकालीन समय", "AEDT": "ऑस्\u200dट्रेलियाई पूर्वी डेलाइट समय", "UYST": "उरुग्वे ग्रीष्मकालीन समय", "CLT": "चिली मानक समय", "TMT": "तुर्कमेनिस्तान मानक समय", "ACST": "ऑस्\u200dट्रेलियाई केंद्रीय मानक समय", "HNEG": "पूर्वी ग्रीनलैंड मानक समय", "EAT": "पूर्वी अफ़्रीका समय", "WIT": "पूर्वी इंडोनेशिया समय", "MDT": "MDT", "EST": "उत्तरी अमेरिकी पूर्वी मानक समय", "AST": "अटलांटिक मानक समय", "ART": "अर्जेंटीना मानक समय", "BT": "भूटान समय", "LHST": "लॉर्ड होवे मानक समय", "JST": "जापान मानक समय", "HEOG": "पश्चिमी ग्रीनलैंड ग्रीष्मकालीन समय", "AKST": "अलास्\u200dका मानक समय", "ChST": "चामोरो मानक समय", "GYT": "गुयाना समय", "HADT": "हवाई–आल्यूशन डेलाइट समय", "OESZ": "पूर्वी यूरोपीय ग्रीष्मकालीन समय", "HENOMX": "उत्तर पश्चिमी मेक्सिको डेलाइट समय", "GFT": "फ़्रेंच गुयाना समय", "WIB": "पश्चिमी इंडोनेशिया समय", "CAT": "मध्य अफ़्रीका समय", "WAT": "पश्चिम अफ़्रीका मानक समय", "IST": "भारतीय मानक समय", "ACWST": "ऑस्\u200dट्रेलियाई केंद्रीय पश्चिमी मानक समय", "JDT": "जापान डेलाइट समय", "ARST": "अर्जेंटीना ग्रीष्मकालीन समय", "AWST": "ऑस्ट्रेलियाई पश्चिमी मानक समय", "∅∅∅": "अमेज़न ग्रीष्मकालीन समय", "HNT": "न्यूफ़ाउंडलैंड मानक समय", "AKDT": "अलास्\u200dका डेलाइट समय", "HEPM": "सेंट पियरे और मिकेलान डेलाइट समय", "MESZ": "मध्\u200dय यूरोपीय ग्रीष्\u200dमकालीन समय", "OEZ": "पूर्वी यूरोपीय मानक समय", "GMT": "ग्रीनविच मीन टाइम", "HKT": "हाँग काँग मानक समय", "WITA": "मध्य इंडोनेशिया समय", "HNPM": "सेंट पियरे और मिकेलान मानक समय", "CHAST": "चैथम मानक समय", "WEZ": "पश्चिमी यूरोपीय मानक समय", "ADT": "अटलांटिक डेलाइट समय", "EDT": "उत्तरी अमेरिकी पूर्वी डेलाइट समय", "CST": "उत्तरी अमेरिकी केंद्रीय मानक समय", "NZST": "न्यूज़ीलैंड मानक समय", "NZDT": "न्यूज़ीलैंड डेलाइट समय", "WAST": "पश्चिम अफ़्रीका ग्रीष्मकालीन समय", "ACDT": "ऑस्\u200dट्रेलियाई केंद्रीय डेलाइट समय", "HAT": "न्यूफ़ाउंडलैंड डेलाइट समय", "HEEG": "पूर्वी ग्रीनलैंड ग्रीष्मकालीन समय", "SGT": "सिंगापुर समय", "PDT": "उत्तरी अमेरिकी प्रशांत डेलाइट समय", "AEST": "ऑस्\u200dट्रेलियाई पूर्वी मानक समय", "LHDT": "लॉर्ड होवे डेलाइट समय", "ACWDT": "ऑस्\u200dट्रेलियाई केंद्रीय पश्चिमी डेलाइट समय", "WESZ": "पश्चिमी यूरोपीय ग्रीष्\u200dमकालीन समय", "COT": "कोलंबिया मानक समय", "HNCU": "क्यूबा मानक समय", "CLST": "चिली ग्रीष्मकालीन समय", "MST": "MST", "WARST": "पश्चिमी अर्जेंटीना ग्रीष्मकालीन समय", "MYT": "मलेशिया समय", "HNNOMX": "उत्तर पश्चिमी मेक्सिको मानक समय", "UYT": "उरुग्वे मानक समय", "HECU": "क्यूबा डेलाइट समय", "CHADT": "चैथम डेलाइट समय", "MEZ": "मध्य यूरोपीय मानक समय", "COST": "कोलंबिया ग्रीष्मकालीन समय", "SAST": "दक्षिण अफ़्रीका समय", "SRT": "सूरीनाम समय", "PST": "उत्तरी अमेरिकी प्रशांत मानक समय", "HNOG": "पश्चिमी ग्रीनलैंड मानक समय", "HNPMX": "मेक्सिकन प्रशांत मानक समय", "CDT": "उत्तरी अमेरिकी केंद्रीय डेलाइट समय", "VET": "वेनेज़ुएला समय", "HKST": "हाँग काँग ग्रीष्मकालीन समय"}, + } +} + +// Locale returns the current translators string locale +func (hi *hi) Locale() string { + return hi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hi' +func (hi *hi) PluralsCardinal() []locales.PluralRule { + return hi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hi' +func (hi *hi) PluralsOrdinal() []locales.PluralRule { + return hi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hi' +func (hi *hi) PluralsRange() []locales.PluralRule { + return hi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hi' +func (hi *hi) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hi' +func (hi *hi) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hi' +func (hi *hi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hi.CardinalPluralRule(num1, v1) + end := hi.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hi *hi) MonthAbbreviated(month time.Month) string { + return hi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hi *hi) MonthsAbbreviated() []string { + return hi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hi *hi) MonthNarrow(month time.Month) string { + return hi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hi *hi) MonthsNarrow() []string { + return hi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hi *hi) MonthWide(month time.Month) string { + return hi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hi *hi) MonthsWide() []string { + return hi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hi *hi) WeekdayAbbreviated(weekday time.Weekday) string { + return hi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hi *hi) WeekdaysAbbreviated() []string { + return hi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hi *hi) WeekdayNarrow(weekday time.Weekday) string { + return hi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hi *hi) WeekdaysNarrow() []string { + return hi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hi *hi) WeekdayShort(weekday time.Weekday) string { + return hi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hi *hi) WeekdaysShort() []string { + return hi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hi *hi) WeekdayWide(weekday time.Weekday) string { + return hi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hi *hi) WeekdaysWide() []string { + return hi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hi' and handles both Whole and Real numbers based on 'v' +func (hi *hi) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, hi.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hi' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hi *hi) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hi.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hi' +func (hi *hi) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hi.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, hi.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, hi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hi' +// in accounting notation. +func (hi *hi) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hi.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, hi.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, hi.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hi' +func (hi *hi) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hi' +func (hi *hi) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hi' +func (hi *hi) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, hi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hi' +func (hi *hi) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, hi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, hi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hi' +func (hi *hi) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, hi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, hi.periodsAbbreviated[0]...) + } else { + b = append(b, hi.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hi' +func (hi *hi) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, hi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, hi.periodsAbbreviated[0]...) + } else { + b = append(b, hi.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hi' +func (hi *hi) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, hi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, hi.periodsAbbreviated[0]...) + } else { + b = append(b, hi.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hi' +func (hi *hi) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, hi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, hi.periodsAbbreviated[0]...) + } else { + b = append(b, hi.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := hi.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hi/hi_test.go b/vendor/github.com/go-playground/locales/hi/hi_test.go new file mode 100644 index 0000000000..ad02c2dfc3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hi/hi_test.go @@ -0,0 +1,1120 @@ +package hi + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hi" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hi_IN/hi_IN.go b/vendor/github.com/go-playground/locales/hi_IN/hi_IN.go new file mode 100644 index 0000000000..6815f83f3d --- /dev/null +++ b/vendor/github.com/go-playground/locales/hi_IN/hi_IN.go @@ -0,0 +1,675 @@ +package hi_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hi_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hi_IN' locale +func New() locales.Translator { + return &hi_IN{ + locale: "hi_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "जन॰", "फ़र॰", "मार्च", "अप्रैल", "मई", "जून", "जुल॰", "अग॰", "सित॰", "अक्तू॰", "नव॰", "दिस॰"}, + monthsNarrow: []string{"", "ज", "फ़", "मा", "अ", "म", "जू", "जु", "अ", "सि", "अ", "न", "दि"}, + monthsWide: []string{"", "जनवरी", "फ़रवरी", "मार्च", "अप्रैल", "मई", "जून", "जुलाई", "अगस्त", "सितंबर", "अक्तूबर", "नवंबर", "दिसंबर"}, + daysAbbreviated: []string{"रवि", "सोम", "मंगल", "बुध", "गुरु", "शुक्र", "शनि"}, + daysNarrow: []string{"र", "सो", "मं", "बु", "गु", "शु", "श"}, + daysShort: []string{"र", "सो", "मं", "बु", "गु", "शु", "श"}, + daysWide: []string{"रविवार", "सोमवार", "मंगलवार", "बुधवार", "गुरुवार", "शुक्रवार", "शनिवार"}, + periodsAbbreviated: []string{"पूर्वाह्न", "अपराह्न"}, + periodsNarrow: []string{"पू", "अ"}, + periodsWide: []string{"पूर्वाह्न", "अपराह्न"}, + erasAbbreviated: []string{"ईसा-पूर्व", "ईस्वी"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ईसा-पूर्व", "ईसवी सन"}, + timezones: map[string]string{"HNCU": "क्यूबा मानक समय", "AWST": "ऑस्ट्रेलियाई पश्चिमी मानक समय", "TMT": "तुर्कमेनिस्तान मानक समय", "ACST": "ऑस्\u200dट्रेलियाई केंद्रीय मानक समय", "COST": "कोलंबिया ग्रीष्मकालीन समय", "HEPMX": "मेक्सिकन प्रशांत डेलाइट समय", "HECU": "क्यूबा डेलाइट समय", "AWDT": "ऑस्ट्रेलियाई पश्चिमी डेलाइट समय", "PDT": "उत्तरी अमेरिकी प्रशांत डेलाइट समय", "MDT": "MDT", "AEDT": "ऑस्\u200dट्रेलियाई पूर्वी डेलाइट समय", "LHST": "लॉर्ड होवे मानक समय", "JDT": "जापान डेलाइट समय", "WAT": "पश्चिम अफ़्रीका मानक समय", "HENOMX": "उत्तर पश्चिमी मेक्सिको डेलाइट समय", "HEPM": "सेंट पियरे और मिकेलान डेलाइट समय", "CLT": "चिली मानक समय", "OESZ": "पूर्वी यूरोपीय ग्रीष्मकालीन समय", "TMST": "तुर्कमेनिस्तान ग्रीष्मकालीन समय", "HNNOMX": "उत्तर पश्चिमी मेक्सिको मानक समय", "EDT": "उत्तरी अमेरिकी पूर्वी डेलाइट समय", "GFT": "फ़्रेंच गुयाना समय", "SRT": "सूरीनाम समय", "EAT": "पूर्वी अफ़्रीका समय", "VET": "वेनेज़ुएला समय", "WARST": "पश्चिमी अर्जेंटीना ग्रीष्मकालीन समय", "CLST": "चिली ग्रीष्मकालीन समय", "MST": "MST", "SGT": "सिंगापुर समय", "CAT": "मध्य अफ़्रीका समय", "WEZ": "पश्चिमी यूरोपीय मानक समय", "HKT": "हाँग काँग मानक समय", "BOT": "बोलीविया समय", "AKDT": "अलास्\u200dका डेलाइट समय", "UYST": "उरुग्वे ग्रीष्मकालीन समय", "ACDT": "ऑस्\u200dट्रेलियाई केंद्रीय डेलाइट समय", "HEEG": "पूर्वी ग्रीनलैंड ग्रीष्मकालीन समय", "HNT": "न्यूफ़ाउंडलैंड मानक समय", "AKST": "अलास्\u200dका मानक समय", "COT": "कोलंबिया मानक समय", "MESZ": "मध्\u200dय यूरोपीय ग्रीष्\u200dमकालीन समय", "WESZ": "पश्चिमी यूरोपीय ग्रीष्\u200dमकालीन समय", "OEZ": "पूर्वी यूरोपीय मानक समय", "EST": "उत्तरी अमेरिकी पूर्वी मानक समय", "CST": "उत्तरी अमेरिकी केंद्रीय मानक समय", "WIT": "पूर्वी इंडोनेशिया समय", "PST": "उत्तरी अमेरिकी प्रशांत मानक समय", "∅∅∅": "अमेज़न ग्रीष्मकालीन समय", "HNPM": "सेंट पियरे और मिकेलान मानक समय", "LHDT": "लॉर्ड होवे डेलाइट समय", "JST": "जापान मानक समय", "WART": "पश्चिमी अर्जेंटीना मानक समय", "HNOG": "पश्चिमी ग्रीनलैंड मानक समय", "HNEG": "पूर्वी ग्रीनलैंड मानक समय", "ChST": "चामोरो मानक समय", "WIB": "पश्चिमी इंडोनेशिया समय", "CHADT": "चैथम डेलाइट समय", "HADT": "हवाई–आल्यूशन डेलाइट समय", "NZDT": "न्यूज़ीलैंड डेलाइट समय", "GMT": "ग्रीनविच मीन टाइम", "MYT": "मलेशिया समय", "WITA": "मध्य इंडोनेशिया समय", "HAST": "हवाई–आल्यूशन मानक समय", "NZST": "न्यूज़ीलैंड मानक समय", "IST": "भारतीय मानक समय", "AST": "अटलांटिक मानक समय", "ECT": "इक्वाडोर समय", "MEZ": "मध्य यूरोपीय मानक समय", "WAST": "पश्चिम अफ़्रीका ग्रीष्मकालीन समय", "HNPMX": "मेक्सिकन प्रशांत मानक समय", "HAT": "न्यूफ़ाउंडलैंड डेलाइट समय", "SAST": "दक्षिण अफ़्रीका समय", "GYT": "गुयाना समय", "ART": "अर्जेंटीना मानक समय", "ARST": "अर्जेंटीना ग्रीष्मकालीन समय", "HKST": "हाँग काँग ग्रीष्मकालीन समय", "BT": "भूटान समय", "ACWDT": "ऑस्\u200dट्रेलियाई केंद्रीय पश्चिमी डेलाइट समय", "ADT": "अटलांटिक डेलाइट समय", "AEST": "ऑस्\u200dट्रेलियाई पूर्वी मानक समय", "CDT": "उत्तरी अमेरिकी केंद्रीय डेलाइट समय", "ACWST": "ऑस्\u200dट्रेलियाई केंद्रीय पश्चिमी मानक समय", "HEOG": "पश्चिमी ग्रीनलैंड ग्रीष्मकालीन समय", "UYT": "उरुग्वे मानक समय", "CHAST": "चैथम मानक समय"}, + } +} + +// Locale returns the current translators string locale +func (hi *hi_IN) Locale() string { + return hi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hi_IN' +func (hi *hi_IN) PluralsCardinal() []locales.PluralRule { + return hi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hi_IN' +func (hi *hi_IN) PluralsOrdinal() []locales.PluralRule { + return hi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hi_IN' +func (hi *hi_IN) PluralsRange() []locales.PluralRule { + return hi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hi_IN' +func (hi *hi_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hi_IN' +func (hi *hi_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } else if n == 6 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hi_IN' +func (hi *hi_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hi.CardinalPluralRule(num1, v1) + end := hi.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hi *hi_IN) MonthAbbreviated(month time.Month) string { + return hi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hi *hi_IN) MonthsAbbreviated() []string { + return hi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hi *hi_IN) MonthNarrow(month time.Month) string { + return hi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hi *hi_IN) MonthsNarrow() []string { + return hi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hi *hi_IN) MonthWide(month time.Month) string { + return hi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hi *hi_IN) MonthsWide() []string { + return hi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hi *hi_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return hi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hi *hi_IN) WeekdaysAbbreviated() []string { + return hi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hi *hi_IN) WeekdayNarrow(weekday time.Weekday) string { + return hi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hi *hi_IN) WeekdaysNarrow() []string { + return hi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hi *hi_IN) WeekdayShort(weekday time.Weekday) string { + return hi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hi *hi_IN) WeekdaysShort() []string { + return hi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hi *hi_IN) WeekdayWide(weekday time.Weekday) string { + return hi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hi *hi_IN) WeekdaysWide() []string { + return hi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hi_IN' and handles both Whole and Real numbers based on 'v' +func (hi *hi_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, hi.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hi_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hi *hi_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hi.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hi_IN' +func (hi *hi_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hi.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, hi.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, hi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hi_IN' +// in accounting notation. +func (hi *hi_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hi.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, hi.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, hi.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hi_IN' +func (hi *hi_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hi_IN' +func (hi *hi_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hi_IN' +func (hi *hi_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, hi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hi_IN' +func (hi *hi_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, hi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, hi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hi_IN' +func (hi *hi_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, hi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, hi.periodsAbbreviated[0]...) + } else { + b = append(b, hi.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hi_IN' +func (hi *hi_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, hi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, hi.periodsAbbreviated[0]...) + } else { + b = append(b, hi.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hi_IN' +func (hi *hi_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, hi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, hi.periodsAbbreviated[0]...) + } else { + b = append(b, hi.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hi_IN' +func (hi *hi_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, hi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, hi.periodsAbbreviated[0]...) + } else { + b = append(b, hi.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := hi.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hi_IN/hi_IN_test.go b/vendor/github.com/go-playground/locales/hi_IN/hi_IN_test.go new file mode 100644 index 0000000000..3c87f192cb --- /dev/null +++ b/vendor/github.com/go-playground/locales/hi_IN/hi_IN_test.go @@ -0,0 +1,1120 @@ +package hi_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hi_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hr/hr.go b/vendor/github.com/go-playground/locales/hr/hr.go new file mode 100644 index 0000000000..3c4cea7a1c --- /dev/null +++ b/vendor/github.com/go-playground/locales/hr/hr.go @@ -0,0 +1,629 @@ +package hr + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hr struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hr' locale +func New() locales.Translator { + return &hr{ + locale: "hr", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "sij", "velj", "ožu", "tra", "svi", "lip", "srp", "kol", "ruj", "lis", "stu", "pro"}, + monthsNarrow: []string{"", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12."}, + monthsWide: []string{"", "siječnja", "veljače", "ožujka", "travnja", "svibnja", "lipnja", "srpnja", "kolovoza", "rujna", "listopada", "studenoga", "prosinca"}, + daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"}, + daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"pr. Kr.", "po. Kr."}, + erasNarrow: []string{"pr.n.e.", "AD"}, + erasWide: []string{"prije Krista", "poslije Krista"}, + timezones: map[string]string{"AWST": "zapadnoaustralsko standardno vrijeme", "HEOG": "zapadnogrenlandsko ljetno vrijeme", "OESZ": "istočnoeuropsko ljetno vrijeme", "HKT": "hongkonško standardno vrijeme", "SAST": "južnoafričko vrijeme", "IST": "indijsko vrijeme", "HNOG": "zapadnogrenlandsko standardno vrijeme", "ARST": "argentinsko ljetno vrijeme", "JST": "japansko standardno vrijeme", "JDT": "japansko ljetno vrijeme", "ADT": "atlantsko ljetno vrijeme", "AST": "atlantsko standardno vrijeme", "WEZ": "zapadnoeuropsko standardno vrijeme", "ART": "argentinsko standardno vrijeme", "HNPMX": "meksičko pacifičko standardno vrijeme", "HAST": "havajsko-aleutsko standardno vrijeme", "MEZ": "srednjoeuropsko standardno vrijeme", "CHAST": "standardno vrijeme Chathama", "PST": "pacifičko standardno vrijeme", "HADT": "havajsko-aleutsko ljetno vrijeme", "CAT": "srednjoafričko vrijeme", "ACWDT": "australsko središnje zapadno ljetno vrijeme", "HNNOMX": "sjeverozapadno meksičko standardno vrijeme", "AKDT": "aljaško ljetno vrijeme", "AWDT": "zapadnoaustralsko ljetno vrijeme", "OEZ": "istočnoeuropsko standardno vrijeme", "TMT": "turkmenistansko standardno vrijeme", "WAT": "zapadnoafričko standardno vrijeme", "ACWST": "australsko središnje zapadno standardno vrijeme", "WAST": "zapadnoafričko ljetno vrijeme", "COST": "kolumbijsko ljetno vrijeme", "∅∅∅": "Acre ljetno vrijeme", "EAT": "istočnoafričko vrijeme", "MESZ": "srednjoeuropsko ljetno vrijeme", "EST": "istočno standardno vrijeme", "HKST": "hongkonško ljetno vrijeme", "HNEG": "istočnogrenlandsko standardno vrijeme", "HEPM": "ljetno vrijeme za Sveti Petar i Mikelon", "WIB": "zapadnoindonezijsko vrijeme", "SRT": "surinamsko vrijeme", "HECU": "kubansko ljetno vrijeme", "WIT": "istočnoindonezijsko vrijeme", "HENOMX": "sjeverozapadno meksičko ljetno vrijeme", "AEDT": "istočnoaustralsko ljetno vrijeme", "LHDT": "ljetno vrijeme otoka Lord Howe", "BOT": "bolivijsko vrijeme", "ACDT": "srednjoaustralsko ljetno vrijeme", "BT": "butansko vrijeme", "HEEG": "istočnogrenlandsko ljetno vrijeme", "WARST": "zapadno-argentinsko ljetno vrijeme", "GYT": "gvajansko vrijeme", "NZST": "novozelandsko standardno vrijeme", "GMT": "univerzalno vrijeme", "MYT": "malezijsko vrijeme", "MDT": "planinsko ljetno vrijeme", "ChST": "standardno vrijeme Chamorra", "UYT": "urugvajsko standardno vrijeme", "UYST": "urugvajsko ljetno vrijeme", "HEPMX": "meksičko pacifičko ljetno vrijeme", "COT": "kolumbijsko standardno vrijeme", "AKST": "aljaško standardno vrijeme", "MST": "planinsko standardno vrijeme", "WESZ": "zapadnoeuropsko ljetno vrijeme", "CST": "središnje standardno vrijeme", "SGT": "singapursko vrijeme", "VET": "venezuelsko vrijeme", "WART": "zapadno-argentinsko standardno vrijeme", "EDT": "istočno ljetno vrijeme", "AEST": "istočnoaustralsko standardno vrijeme", "CDT": "središnje ljetno vrijeme", "CLT": "čileansko standardno vrijeme", "CHADT": "ljetno vrijeme Chathama", "PDT": "pacifičko ljetno vrijeme", "LHST": "standardno vrijeme otoka Lord Howe", "ECT": "ekvadorsko vrijeme", "CLST": "čileansko ljetno vrijeme", "HNT": "newfoundlandsko standardno vrijeme", "HAT": "newfoundlandsko ljetno vrijeme", "WITA": "srednjoindonezijsko vrijeme", "HNCU": "kubansko standardno vrijeme", "NZDT": "novozelandsko ljetno vrijeme", "TMST": "turkmenistansko ljetno vrijeme", "ACST": "srednjoaustralsko standardno vrijeme", "GFT": "vrijeme Francuske Gvajane", "HNPM": "standardno vrijeme za Sveti Petar i Mikelon"}, + } +} + +// Locale returns the current translators string locale +func (hr *hr) Locale() string { + return hr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hr' +func (hr *hr) PluralsCardinal() []locales.PluralRule { + return hr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hr' +func (hr *hr) PluralsOrdinal() []locales.PluralRule { + return hr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hr' +func (hr *hr) PluralsRange() []locales.PluralRule { + return hr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hr' +func (hr *hr) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hr' +func (hr *hr) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hr' +func (hr *hr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hr.CardinalPluralRule(num1, v1) + end := hr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hr *hr) MonthAbbreviated(month time.Month) string { + return hr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hr *hr) MonthsAbbreviated() []string { + return hr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hr *hr) MonthNarrow(month time.Month) string { + return hr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hr *hr) MonthsNarrow() []string { + return hr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hr *hr) MonthWide(month time.Month) string { + return hr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hr *hr) MonthsWide() []string { + return hr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hr *hr) WeekdayAbbreviated(weekday time.Weekday) string { + return hr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hr *hr) WeekdaysAbbreviated() []string { + return hr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hr *hr) WeekdayNarrow(weekday time.Weekday) string { + return hr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hr *hr) WeekdaysNarrow() []string { + return hr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hr *hr) WeekdayShort(weekday time.Weekday) string { + return hr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hr *hr) WeekdaysShort() []string { + return hr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hr *hr) WeekdayWide(weekday time.Weekday) string { + return hr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hr *hr) WeekdaysWide() []string { + return hr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hr' and handles both Whole and Real numbers based on 'v' +func (hr *hr) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hr' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hr *hr) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hr' +func (hr *hr) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, hr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hr' +// in accounting notation. +func (hr *hr) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, hr.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, hr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, hr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hr' +func (hr *hr) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hr' +func (hr *hr) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hr' +func (hr *hr) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hr' +func (hr *hr) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, hr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hr' +func (hr *hr) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hr' +func (hr *hr) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hr' +func (hr *hr) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hr' +func (hr *hr) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := hr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hr/hr_test.go b/vendor/github.com/go-playground/locales/hr/hr_test.go new file mode 100644 index 0000000000..e0cd295b86 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hr/hr_test.go @@ -0,0 +1,1120 @@ +package hr + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hr" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hr_BA/hr_BA.go b/vendor/github.com/go-playground/locales/hr_BA/hr_BA.go new file mode 100644 index 0000000000..8a25ed4809 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hr_BA/hr_BA.go @@ -0,0 +1,619 @@ +package hr_BA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hr_BA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hr_BA' locale +func New() locales.Translator { + return &hr_BA{ + locale: "hr_BA", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "KM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "sij", "velj", "ožu", "tra", "svi", "lip", "srp", "kol", "ruj", "lis", "stu", "pro"}, + monthsNarrow: []string{"", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12."}, + monthsWide: []string{"", "siječnja", "veljače", "ožujka", "travnja", "svibnja", "lipnja", "srpnja", "kolovoza", "rujna", "listopada", "studenoga", "prosinca"}, + daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"}, + daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"pr. Kr.", "po. Kr."}, + erasNarrow: []string{"pr.n.e.", "AD"}, + erasWide: []string{"prije Krista", "poslije Krista"}, + timezones: map[string]string{"HAST": "havajsko-aleutsko standardno vrijeme", "IST": "indijsko vrijeme", "AST": "atlantsko standardno vrijeme", "OEZ": "istočnoeuropsko standardno vrijeme", "AEST": "istočnoaustralsko standardno vrijeme", "HEOG": "zapadnogrenlandsko ljetno vrijeme", "AEDT": "istočnoaustralsko ljetno vrijeme", "SRT": "surinamsko vrijeme", "HECU": "kubansko ljetno vrijeme", "PST": "pacifičko standardno vrijeme", "NZDT": "novozelandsko ljetno vrijeme", "HNOG": "zapadnogrenlandsko standardno vrijeme", "UYT": "urugvajsko standardno vrijeme", "EAT": "istočnoafričko vrijeme", "HADT": "havajsko-aleutsko ljetno vrijeme", "VET": "venezuelsko vrijeme", "COT": "kolumbijsko standardno vrijeme", "HENOMX": "sjeverozapadno meksičko ljetno vrijeme", "EST": "istočno standardno vrijeme", "HNT": "newfoundlandsko standardno vrijeme", "HAT": "newfoundlandsko ljetno vrijeme", "HNPMX": "meksičko pacifičko standardno vrijeme", "CHADT": "ljetno vrijeme Chathama", "ACWDT": "australsko središnje zapadno ljetno vrijeme", "MST": "standardno makaosko vrijeme", "WAT": "zapadnoafričko standardno vrijeme", "TMST": "turkmenistansko ljetno vrijeme", "HNEG": "istočnogrenlandsko standardno vrijeme", "HEPMX": "meksičko pacifičko ljetno vrijeme", "∅∅∅": "azorsko ljetno vrijeme", "ECT": "ekvadorsko vrijeme", "WESZ": "zapadnoeuropsko ljetno vrijeme", "WARST": "zapadno-argentinsko ljetno vrijeme", "HKST": "hongkonško ljetno vrijeme", "ACDT": "srednjoaustralsko ljetno vrijeme", "WITA": "srednjoindonezijsko vrijeme", "HNCU": "kubansko standardno vrijeme", "AWST": "zapadnoaustralsko standardno vrijeme", "BOT": "bolivijsko vrijeme", "ACWST": "australsko središnje zapadno standardno vrijeme", "WAST": "zapadnoafričko ljetno vrijeme", "AKST": "aljaško standardno vrijeme", "ChST": "standardno vrijeme Chamorra", "HNPM": "standardno vrijeme za Sveti Petar i Mikelon", "HEPM": "ljetno vrijeme za Sveti Petar i Mikelon", "LHST": "standardno vrijeme otoka Lord Howe", "JST": "japansko standardno vrijeme", "MYT": "malezijsko vrijeme", "ART": "argentinsko standardno vrijeme", "ACST": "srednjoaustralsko standardno vrijeme", "GYT": "gvajansko vrijeme", "WIT": "istočnoindonezijsko vrijeme", "JDT": "japansko ljetno vrijeme", "GFT": "vrijeme Francuske Gvajane", "AKDT": "aljaško ljetno vrijeme", "LHDT": "ljetno vrijeme otoka Lord Howe", "CHAST": "standardno vrijeme Chathama", "GMT": "univerzalno vrijeme", "WART": "zapadno-argentinsko standardno vrijeme", "MDT": "ljetno makaosko vrijeme", "WIB": "zapadnoindonezijsko vrijeme", "PDT": "pacifičko ljetno vrijeme", "BT": "butansko vrijeme", "WEZ": "zapadnoeuropsko standardno vrijeme", "TMT": "turkmenistansko standardno vrijeme", "HKT": "hongkonško standardno vrijeme", "HNNOMX": "sjeverozapadno meksičko standardno vrijeme", "NZST": "novozelandsko standardno vrijeme", "MEZ": "srednjoeuropsko standardno vrijeme", "CLT": "čileansko standardno vrijeme", "ARST": "argentinsko ljetno vrijeme", "UYST": "urugvajsko ljetno vrijeme", "CDT": "središnje ljetno vrijeme", "CAT": "srednjoafričko vrijeme", "CLST": "čileansko ljetno vrijeme", "ADT": "atlantsko ljetno vrijeme", "COST": "kolumbijsko ljetno vrijeme", "CST": "središnje standardno vrijeme", "AWDT": "zapadnoaustralsko ljetno vrijeme", "SGT": "singapursko vrijeme", "OESZ": "istočnoeuropsko ljetno vrijeme", "HEEG": "istočnogrenlandsko ljetno vrijeme", "SAST": "južnoafričko vrijeme", "MESZ": "srednjoeuropsko ljetno vrijeme", "EDT": "istočno ljetno vrijeme"}, + } +} + +// Locale returns the current translators string locale +func (hr *hr_BA) Locale() string { + return hr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hr_BA' +func (hr *hr_BA) PluralsCardinal() []locales.PluralRule { + return hr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hr_BA' +func (hr *hr_BA) PluralsOrdinal() []locales.PluralRule { + return hr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hr_BA' +func (hr *hr_BA) PluralsRange() []locales.PluralRule { + return hr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hr_BA' +func (hr *hr_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hr_BA' +func (hr *hr_BA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hr_BA' +func (hr *hr_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hr.CardinalPluralRule(num1, v1) + end := hr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hr *hr_BA) MonthAbbreviated(month time.Month) string { + return hr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hr *hr_BA) MonthsAbbreviated() []string { + return hr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hr *hr_BA) MonthNarrow(month time.Month) string { + return hr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hr *hr_BA) MonthsNarrow() []string { + return hr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hr *hr_BA) MonthWide(month time.Month) string { + return hr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hr *hr_BA) MonthsWide() []string { + return hr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hr *hr_BA) WeekdayAbbreviated(weekday time.Weekday) string { + return hr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hr *hr_BA) WeekdaysAbbreviated() []string { + return hr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hr *hr_BA) WeekdayNarrow(weekday time.Weekday) string { + return hr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hr *hr_BA) WeekdaysNarrow() []string { + return hr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hr *hr_BA) WeekdayShort(weekday time.Weekday) string { + return hr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hr *hr_BA) WeekdaysShort() []string { + return hr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hr *hr_BA) WeekdayWide(weekday time.Weekday) string { + return hr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hr *hr_BA) WeekdaysWide() []string { + return hr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hr_BA' and handles both Whole and Real numbers based on 'v' +func (hr *hr_BA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hr_BA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hr *hr_BA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hr_BA' +func (hr *hr_BA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, hr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hr_BA' +// in accounting notation. +func (hr *hr_BA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, hr.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, hr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, hr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hr_BA' +func (hr *hr_BA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hr_BA' +func (hr *hr_BA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hr_BA' +func (hr *hr_BA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hr_BA' +func (hr *hr_BA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, hr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hr_BA' +func (hr *hr_BA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hr_BA' +func (hr *hr_BA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hr_BA' +func (hr *hr_BA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hr_BA' +func (hr *hr_BA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := hr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hr_BA/hr_BA_test.go b/vendor/github.com/go-playground/locales/hr_BA/hr_BA_test.go new file mode 100644 index 0000000000..7f81c6d4e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hr_BA/hr_BA_test.go @@ -0,0 +1,1120 @@ +package hr_BA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hr_BA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hr_HR/hr_HR.go b/vendor/github.com/go-playground/locales/hr_HR/hr_HR.go new file mode 100644 index 0000000000..de99638e43 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hr_HR/hr_HR.go @@ -0,0 +1,629 @@ +package hr_HR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hr_HR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hr_HR' locale +func New() locales.Translator { + return &hr_HR{ + locale: "hr_HR", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "sij", "velj", "ožu", "tra", "svi", "lip", "srp", "kol", "ruj", "lis", "stu", "pro"}, + monthsNarrow: []string{"", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12."}, + monthsWide: []string{"", "siječnja", "veljače", "ožujka", "travnja", "svibnja", "lipnja", "srpnja", "kolovoza", "rujna", "listopada", "studenoga", "prosinca"}, + daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"}, + daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"}, + daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"pr. Kr.", "po. Kr."}, + erasNarrow: []string{"pr.n.e.", "AD"}, + erasWide: []string{"prije Krista", "poslije Krista"}, + timezones: map[string]string{"NZST": "novozelandsko standardno vrijeme", "NZDT": "novozelandsko ljetno vrijeme", "UYT": "urugvajsko standardno vrijeme", "MST": "standardno makaosko vrijeme", "WAST": "zapadnoafričko ljetno vrijeme", "HNT": "newfoundlandsko standardno vrijeme", "AEST": "istočnoaustralsko standardno vrijeme", "SGT": "singapursko vrijeme", "PDT": "pacifičko ljetno vrijeme", "HEOG": "zapadnogrenlandsko ljetno vrijeme", "TMT": "turkmenistansko standardno vrijeme", "ACWDT": "australsko središnje zapadno ljetno vrijeme", "GFT": "vrijeme Francuske Gvajane", "EAT": "istočnoafričko vrijeme", "BOT": "bolivijsko vrijeme", "∅∅∅": "amazonsko ljetno vrijeme", "HEPM": "ljetno vrijeme za Sveti Petar i Mikelon", "HEPMX": "meksičko pacifičko ljetno vrijeme", "GMT": "univerzalno vrijeme", "MDT": "ljetno makaosko vrijeme", "AKST": "aljaško standardno vrijeme", "AKDT": "aljaško ljetno vrijeme", "AWDT": "zapadnoaustralsko ljetno vrijeme", "HAST": "havajsko-aleutsko standardno vrijeme", "HADT": "havajsko-aleutsko ljetno vrijeme", "ACWST": "australsko središnje zapadno standardno vrijeme", "ChST": "standardno vrijeme Chamorra", "WIB": "zapadnoindonezijsko vrijeme", "GYT": "gvajansko vrijeme", "COST": "kolumbijsko ljetno vrijeme", "SAST": "južnoafričko vrijeme", "LHDT": "ljetno vrijeme otoka Lord Howe", "HNPMX": "meksičko pacifičko standardno vrijeme", "WARST": "zapadno-argentinsko ljetno vrijeme", "WITA": "srednjoindonezijsko vrijeme", "HNCU": "kubansko standardno vrijeme", "CHADT": "ljetno vrijeme Chathama", "JST": "japansko standardno vrijeme", "HNOG": "zapadnogrenlandsko standardno vrijeme", "AST": "atlantsko standardno vrijeme", "ACDT": "srednjoaustralsko ljetno vrijeme", "LHST": "standardno vrijeme otoka Lord Howe", "HKT": "hongkonško standardno vrijeme", "COT": "kolumbijsko standardno vrijeme", "HNNOMX": "sjeverozapadno meksičko standardno vrijeme", "BT": "butansko vrijeme", "ECT": "ekvadorsko vrijeme", "WESZ": "zapadnoeuropsko ljetno vrijeme", "TMST": "turkmenistansko ljetno vrijeme", "EDT": "istočno ljetno vrijeme", "HAT": "newfoundlandsko ljetno vrijeme", "AEDT": "istočnoaustralsko ljetno vrijeme", "CAT": "srednjoafričko vrijeme", "IST": "indijsko vrijeme", "MYT": "malezijsko vrijeme", "HECU": "kubansko ljetno vrijeme", "MEZ": "srednjoeuropsko standardno vrijeme", "MESZ": "srednjoeuropsko ljetno vrijeme", "HNEG": "istočnogrenlandsko standardno vrijeme", "SRT": "surinamsko vrijeme", "CDT": "središnje ljetno vrijeme", "JDT": "japansko ljetno vrijeme", "OESZ": "istočnoeuropsko ljetno vrijeme", "EST": "istočno standardno vrijeme", "HNPM": "standardno vrijeme za Sveti Petar i Mikelon", "ACST": "srednjoaustralsko standardno vrijeme", "AWST": "zapadnoaustralsko standardno vrijeme", "PST": "pacifičko standardno vrijeme", "OEZ": "istočnoeuropsko standardno vrijeme", "HKST": "hongkonško ljetno vrijeme", "HENOMX": "sjeverozapadno meksičko ljetno vrijeme", "UYST": "urugvajsko ljetno vrijeme", "CST": "središnje standardno vrijeme", "CLT": "čileansko standardno vrijeme", "ADT": "atlantsko ljetno vrijeme", "WEZ": "zapadnoeuropsko standardno vrijeme", "ARST": "argentinsko ljetno vrijeme", "ART": "argentinsko standardno vrijeme", "WAT": "zapadnoafričko standardno vrijeme", "HEEG": "istočnogrenlandsko ljetno vrijeme", "WIT": "istočnoindonezijsko vrijeme", "CHAST": "standardno vrijeme Chathama", "VET": "venezuelsko vrijeme", "WART": "zapadno-argentinsko standardno vrijeme", "CLST": "čileansko ljetno vrijeme"}, + } +} + +// Locale returns the current translators string locale +func (hr *hr_HR) Locale() string { + return hr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hr_HR' +func (hr *hr_HR) PluralsCardinal() []locales.PluralRule { + return hr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hr_HR' +func (hr *hr_HR) PluralsOrdinal() []locales.PluralRule { + return hr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hr_HR' +func (hr *hr_HR) PluralsRange() []locales.PluralRule { + return hr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hr_HR' +func (hr *hr_HR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + iMod10 := i % 10 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hr_HR' +func (hr *hr_HR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hr_HR' +func (hr *hr_HR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hr.CardinalPluralRule(num1, v1) + end := hr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hr *hr_HR) MonthAbbreviated(month time.Month) string { + return hr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hr *hr_HR) MonthsAbbreviated() []string { + return hr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hr *hr_HR) MonthNarrow(month time.Month) string { + return hr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hr *hr_HR) MonthsNarrow() []string { + return hr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hr *hr_HR) MonthWide(month time.Month) string { + return hr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hr *hr_HR) MonthsWide() []string { + return hr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hr *hr_HR) WeekdayAbbreviated(weekday time.Weekday) string { + return hr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hr *hr_HR) WeekdaysAbbreviated() []string { + return hr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hr *hr_HR) WeekdayNarrow(weekday time.Weekday) string { + return hr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hr *hr_HR) WeekdaysNarrow() []string { + return hr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hr *hr_HR) WeekdayShort(weekday time.Weekday) string { + return hr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hr *hr_HR) WeekdaysShort() []string { + return hr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hr *hr_HR) WeekdayWide(weekday time.Weekday) string { + return hr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hr *hr_HR) WeekdaysWide() []string { + return hr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hr_HR' and handles both Whole and Real numbers based on 'v' +func (hr *hr_HR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hr_HR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hr *hr_HR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hr_HR' +func (hr *hr_HR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, hr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hr_HR' +// in accounting notation. +func (hr *hr_HR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, hr.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, hr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, hr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hr_HR' +func (hr *hr_HR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hr_HR' +func (hr *hr_HR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hr_HR' +func (hr *hr_HR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hr_HR' +func (hr *hr_HR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, hr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hr_HR' +func (hr *hr_HR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hr_HR' +func (hr *hr_HR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hr_HR' +func (hr *hr_HR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hr_HR' +func (hr *hr_HR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := hr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hr_HR/hr_HR_test.go b/vendor/github.com/go-playground/locales/hr_HR/hr_HR_test.go new file mode 100644 index 0000000000..343214e40b --- /dev/null +++ b/vendor/github.com/go-playground/locales/hr_HR/hr_HR_test.go @@ -0,0 +1,1120 @@ +package hr_HR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hr_HR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hsb/hsb.go b/vendor/github.com/go-playground/locales/hsb/hsb.go new file mode 100644 index 0000000000..af3462f04a --- /dev/null +++ b/vendor/github.com/go-playground/locales/hsb/hsb.go @@ -0,0 +1,576 @@ +package hsb + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hsb struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hsb' locale +func New() locales.Translator { + return &hsb{ + locale: "hsb", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "zł", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "měr.", "apr.", "mej.", "jun.", "jul.", "awg.", "sep.", "okt.", "now.", "dec."}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januara", "februara", "měrca", "apryla", "meje", "junija", "julija", "awgusta", "septembra", "oktobra", "nowembra", "decembra"}, + daysAbbreviated: []string{"nje", "pón", "wut", "srj", "štw", "pja", "sob"}, + daysNarrow: []string{"n", "p", "w", "s", "š", "p", "s"}, + daysShort: []string{"nj", "pó", "wu", "sr", "št", "pj", "so"}, + daysWide: []string{"njedźela", "póndźela", "wutora", "srjeda", "štwórtk", "pjatk", "sobota"}, + periodsAbbreviated: []string{"dopołdnja", "popołdnju"}, + periodsNarrow: []string{"dop.", "pop."}, + periodsWide: []string{"dopołdnja", "popołdnju"}, + erasAbbreviated: []string{"př.Chr.n.", "po Chr.n."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"před Chrystowym narodźenjom", "po Chrystowym narodźenju"}, + timezones: map[string]string{"NZST": "nowoseelandski standardny čas", "ADT": "atlantiski lětni čas", "GFT": "francoskoguyanski čas", "GYT": "guyanski čas", "MYT": "malajziski čas", "EDT": "sewjeroameriski wuchodny lětni čas", "ACST": "srjedźoawstralski standardny čas", "LHST": "standardny čas kupy Lord-Howe", "HEPMX": "mexiski pacifiski lětni čas", "EAT": "wuchodoafriski čas", "CDT": "sewjeroameriski centralny lětni čas", "AWST": "zapadoawstralski standardny čas", "MEZ": "srjedźoeuropski standardny čas", "OESZ": "wuchodoeuropski lětni čas", "HNT": "nowofundlandski standardny čas", "HEEG": "wuchodogrönlandski lětni čas", "SAST": "južnoafriski čas", "CST": "sewjeroameriski centralny standardny čas", "MST": "MST", "SRT": "surinamski čas", "AWDT": "zapadoawstralski lětni čas", "COT": "kolumbiski standardny čas", "ChST": "chamorroski čas", "WIB": "zapadoindoneski čas", "ACWST": "srjedźozapadny awstralski standardny čas", "OEZ": "wuchodoeuropski standardny čas", "HEOG": "zapadogrönlandski lětni čas", "MDT": "MDT", "WITA": "srjedźoindoneski čas", "HEPM": "lětni čas kupow St. Pierre a Miquelon", "HADT": "hawaiisko-aleutski lětni čas", "CLST": "chilski lětni čas", "HNOG": "zapadogrönlandski standardny čas", "COST": "kolumbiski lětni čas", "WIT": "wuchodoindoneski", "PDT": "sewjeroameriski pacifiski lětni čas", "HAST": "hawaiisko-aleutski standardny čas", "HNNOMX": "mexiski sewjerozapadny standardny čas", "HAT": "nowofundlandski lětni čas", "BOT": "boliwiski čas", "CAT": "centralnoafriski čas", "MESZ": "srjedźoeuropski lětni čas", "GMT": "Greenwichski čas", "CLT": "chilski standardny čas", "ART": "argentinski standardny čas", "HENOMX": "mexiski sewjerozapadny lětni čas", "AKST": "alaskaski standardny čas", "HECU": "kubaski lětni čas", "WART": "zapadoargentinski standardny čas", "WARST": "zapadoargentinski lětni čas", "AEDT": "wuchodoawstralski lětni čas", "HNPMX": "mexiski pacifiski standardny čas", "CHAST": "chathamski standardny čas", "IST": "indiski čas", "JDT": "japanski lětni čas", "UYT": "uruguayski standardny čas", "CHADT": "chathamski lětni čas", "ACWDT": "sjedźozapadny awstralski lětni čas", "VET": "venezuelski čas", "WESZ": "zapadoeuropski lětni čas", "AEST": "wuchodoawstralski standardny čas", "LHDT": "lětni čas kupy Lord-Howe", "SGT": "Singapurski čas", "ECT": "ekwadorski čas", "NZDT": "nowoseelandski lětni čas", "HKT": "Hongkongski standardny čas", "ACDT": "srjedźoawstralski lětni čas", "HNEG": "wuchodogrönlandski standardny čas", "HNPM": "standardny čas kupow St. Pierre a Miquelon", "PST": "sewjeroameriski pacifiski standardny čas", "JST": "japanski standardny čas", "WEZ": "zapadoeuropski standardny čas", "TMT": "turkmenski standardny čas", "WAST": "zapadoafriski lětni čas", "EST": "sewjeroameriski wuchodny standardny čas", "BT": "bhutanski čas", "UYST": "uruguayski lětni čas", "AST": "atlantiski standardny čas", "HKST": "Hongkongski lětni čas", "AKDT": "alaskaski lětni čas", "∅∅∅": "Brasiliski lětni čas", "TMST": "turkmenski lětni čas", "ARST": "argentinski lětni čas", "WAT": "zapadoafriski standardny čas", "HNCU": "kubaski standardny čas"}, + } +} + +// Locale returns the current translators string locale +func (hsb *hsb) Locale() string { + return hsb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hsb' +func (hsb *hsb) PluralsCardinal() []locales.PluralRule { + return hsb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hsb' +func (hsb *hsb) PluralsOrdinal() []locales.PluralRule { + return hsb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hsb' +func (hsb *hsb) PluralsRange() []locales.PluralRule { + return hsb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hsb' +func (hsb *hsb) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + fMod100 := f % 100 + + if (v == 0 && iMod100 == 1) || (fMod100 == 1) { + return locales.PluralRuleOne + } else if (v == 0 && iMod100 == 2) || (fMod100 == 2) { + return locales.PluralRuleTwo + } else if (v == 0 && iMod100 >= 3 && iMod100 <= 4) || (fMod100 >= 3 && fMod100 <= 4) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hsb' +func (hsb *hsb) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hsb' +func (hsb *hsb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hsb *hsb) MonthAbbreviated(month time.Month) string { + return hsb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hsb *hsb) MonthsAbbreviated() []string { + return hsb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hsb *hsb) MonthNarrow(month time.Month) string { + return hsb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hsb *hsb) MonthsNarrow() []string { + return hsb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hsb *hsb) MonthWide(month time.Month) string { + return hsb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hsb *hsb) MonthsWide() []string { + return hsb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hsb *hsb) WeekdayAbbreviated(weekday time.Weekday) string { + return hsb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hsb *hsb) WeekdaysAbbreviated() []string { + return hsb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hsb *hsb) WeekdayNarrow(weekday time.Weekday) string { + return hsb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hsb *hsb) WeekdaysNarrow() []string { + return hsb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hsb *hsb) WeekdayShort(weekday time.Weekday) string { + return hsb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hsb *hsb) WeekdaysShort() []string { + return hsb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hsb *hsb) WeekdayWide(weekday time.Weekday) string { + return hsb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hsb *hsb) WeekdaysWide() []string { + return hsb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hsb' and handles both Whole and Real numbers based on 'v' +func (hsb *hsb) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hsb' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hsb *hsb) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hsb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hsb.percentSuffix...) + + b = append(b, hsb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hsb' +func (hsb *hsb) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hsb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hsb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, hsb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hsb' +// in accounting notation. +func (hsb *hsb) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hsb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, hsb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hsb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, hsb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, hsb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hsb' +func (hsb *hsb) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hsb' +func (hsb *hsb) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hsb' +func (hsb *hsb) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hsb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hsb' +func (hsb *hsb) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, hsb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hsb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hsb' +func (hsb *hsb) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0x68, 0x6f, 0x64, 0xc5, 0xba}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hsb' +func (hsb *hsb) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hsb' +func (hsb *hsb) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hsb' +func (hsb *hsb) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := hsb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hsb/hsb_test.go b/vendor/github.com/go-playground/locales/hsb/hsb_test.go new file mode 100644 index 0000000000..b9502a029d --- /dev/null +++ b/vendor/github.com/go-playground/locales/hsb/hsb_test.go @@ -0,0 +1,1120 @@ +package hsb + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hsb" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hsb_DE/hsb_DE.go b/vendor/github.com/go-playground/locales/hsb_DE/hsb_DE.go new file mode 100644 index 0000000000..73ac0c63ef --- /dev/null +++ b/vendor/github.com/go-playground/locales/hsb_DE/hsb_DE.go @@ -0,0 +1,576 @@ +package hsb_DE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hsb_DE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hsb_DE' locale +func New() locales.Translator { + return &hsb_DE{ + locale: "hsb_DE", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "měr.", "apr.", "mej.", "jun.", "jul.", "awg.", "sep.", "okt.", "now.", "dec."}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januara", "februara", "měrca", "apryla", "meje", "junija", "julija", "awgusta", "septembra", "oktobra", "nowembra", "decembra"}, + daysAbbreviated: []string{"nje", "pón", "wut", "srj", "štw", "pja", "sob"}, + daysNarrow: []string{"n", "p", "w", "s", "š", "p", "s"}, + daysShort: []string{"nj", "pó", "wu", "sr", "št", "pj", "so"}, + daysWide: []string{"njedźela", "póndźela", "wutora", "srjeda", "štwórtk", "pjatk", "sobota"}, + periodsAbbreviated: []string{"dopołdnja", "popołdnju"}, + periodsNarrow: []string{"dop.", "pop."}, + periodsWide: []string{"dopołdnja", "popołdnju"}, + erasAbbreviated: []string{"př.Chr.n.", "po Chr.n."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"před Chrystowym narodźenjom", "po Chrystowym narodźenju"}, + timezones: map[string]string{"MDT": "MDT", "AEDT": "wuchodoawstralski lětni čas", "SAST": "južnoafriski čas", "CST": "sewjeroameriski centralny standardny čas", "SGT": "Singapurski čas", "ACWST": "srjedźozapadny awstralski standardny čas", "JDT": "japanski lětni čas", "HEOG": "zapadogrönlandski lětni čas", "HEPM": "lětni čas kupow St. Pierre a Miquelon", "LHST": "standardny čas kupy Lord-Howe", "WIT": "wuchodoindoneski", "PDT": "sewjeroameriski pacifiski lětni čas", "CLST": "chilski lětni čas", "HNEG": "wuchodogrönlandski standardny čas", "OESZ": "wuchodoeuropski lětni čas", "TMT": "turkmenski standardny čas", "ART": "argentinski standardny čas", "AST": "atlantiski standardny čas", "OEZ": "wuchodoeuropski standardny čas", "HENOMX": "mexiski sewjerozapadny lětni čas", "WITA": "srjedźoindoneski čas", "PST": "sewjeroameriski pacifiski standardny čas", "ACWDT": "sjedźozapadny awstralski lětni čas", "HEEG": "wuchodogrönlandski lětni čas", "HNPMX": "mexiski pacifiski standardny čas", "ARST": "argentinski lětni čas", "WAST": "zapadoafriski lětni čas", "HEPMX": "mexiski pacifiski lětni čas", "CAT": "centralnoafriski čas", "VET": "venezuelski čas", "WART": "zapadoargentinski standardny čas", "WIB": "zapadoindoneski čas", "WARST": "zapadoargentinski lětni čas", "HAT": "nowofundlandski lětni čas", "MST": "MST", "BT": "bhutanski čas", "BOT": "boliwiski čas", "NZST": "nowoseelandski standardny čas", "JST": "japanski standardny čas", "MYT": "malajziski čas", "HKT": "Hongkongski standardny čas", "ACST": "srjedźoawstralski standardny čas", "∅∅∅": "peruski lětni čas", "AKST": "alaskaski standardny čas", "HNOG": "zapadogrönlandski standardny čas", "GMT": "Greenwichski čas", "WAT": "zapadoafriski standardny čas", "EST": "sewjeroameriski wuchodny standardny čas", "MESZ": "srjedźoeuropski lětni čas", "HNT": "nowofundlandski standardny čas", "WESZ": "zapadoeuropski lětni čas", "EDT": "sewjeroameriski wuchodny lětni čas", "GFT": "francoskoguyanski čas", "HNPM": "standardny čas kupow St. Pierre a Miquelon", "LHDT": "lětni čas kupy Lord-Howe", "CHAST": "chathamski standardny čas", "CLT": "chilski standardny čas", "ADT": "atlantiski lětni čas", "IST": "indiski čas", "HNNOMX": "mexiski sewjerozapadny standardny čas", "EAT": "wuchodoafriski čas", "HNCU": "kubaski standardny čas", "CDT": "sewjeroameriski centralny lětni čas", "AWST": "zapadoawstralski standardny čas", "ECT": "ekwadorski čas", "ACDT": "srjedźoawstralski lětni čas", "COST": "kolumbiski lětni čas", "UYT": "uruguayski standardny čas", "GYT": "guyanski čas", "HAST": "hawaiisko-aleutski standardny čas", "NZDT": "nowoseelandski lětni čas", "TMST": "turkmenski lětni čas", "COT": "kolumbiski standardny čas", "AKDT": "alaskaski lětni čas", "ChST": "chamorroski čas", "SRT": "surinamski čas", "HECU": "kubaski lětni čas", "AWDT": "zapadoawstralski lětni čas", "MEZ": "srjedźoeuropski standardny čas", "WEZ": "zapadoeuropski standardny čas", "UYST": "uruguayski lětni čas", "CHADT": "chathamski lětni čas", "HADT": "hawaiisko-aleutski lětni čas", "HKST": "Hongkongski lětni čas", "AEST": "wuchodoawstralski standardny čas"}, + } +} + +// Locale returns the current translators string locale +func (hsb *hsb_DE) Locale() string { + return hsb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hsb_DE' +func (hsb *hsb_DE) PluralsCardinal() []locales.PluralRule { + return hsb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hsb_DE' +func (hsb *hsb_DE) PluralsOrdinal() []locales.PluralRule { + return hsb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hsb_DE' +func (hsb *hsb_DE) PluralsRange() []locales.PluralRule { + return hsb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hsb_DE' +func (hsb *hsb_DE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + fMod100 := f % 100 + + if (v == 0 && iMod100 == 1) || (fMod100 == 1) { + return locales.PluralRuleOne + } else if (v == 0 && iMod100 == 2) || (fMod100 == 2) { + return locales.PluralRuleTwo + } else if (v == 0 && iMod100 >= 3 && iMod100 <= 4) || (fMod100 >= 3 && fMod100 <= 4) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hsb_DE' +func (hsb *hsb_DE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hsb_DE' +func (hsb *hsb_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hsb *hsb_DE) MonthAbbreviated(month time.Month) string { + return hsb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hsb *hsb_DE) MonthsAbbreviated() []string { + return hsb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hsb *hsb_DE) MonthNarrow(month time.Month) string { + return hsb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hsb *hsb_DE) MonthsNarrow() []string { + return hsb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hsb *hsb_DE) MonthWide(month time.Month) string { + return hsb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hsb *hsb_DE) MonthsWide() []string { + return hsb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hsb *hsb_DE) WeekdayAbbreviated(weekday time.Weekday) string { + return hsb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hsb *hsb_DE) WeekdaysAbbreviated() []string { + return hsb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hsb *hsb_DE) WeekdayNarrow(weekday time.Weekday) string { + return hsb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hsb *hsb_DE) WeekdaysNarrow() []string { + return hsb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hsb *hsb_DE) WeekdayShort(weekday time.Weekday) string { + return hsb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hsb *hsb_DE) WeekdaysShort() []string { + return hsb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hsb *hsb_DE) WeekdayWide(weekday time.Weekday) string { + return hsb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hsb *hsb_DE) WeekdaysWide() []string { + return hsb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hsb_DE' and handles both Whole and Real numbers based on 'v' +func (hsb *hsb_DE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hsb_DE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hsb *hsb_DE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hsb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hsb.percentSuffix...) + + b = append(b, hsb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hsb_DE' +func (hsb *hsb_DE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hsb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hsb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hsb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, hsb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hsb_DE' +// in accounting notation. +func (hsb *hsb_DE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hsb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hsb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, hsb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, hsb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hsb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, hsb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, hsb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hsb_DE' +func (hsb *hsb_DE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hsb_DE' +func (hsb *hsb_DE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hsb_DE' +func (hsb *hsb_DE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hsb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hsb_DE' +func (hsb *hsb_DE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, hsb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hsb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hsb_DE' +func (hsb *hsb_DE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0x68, 0x6f, 0x64, 0xc5, 0xba}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hsb_DE' +func (hsb *hsb_DE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hsb_DE' +func (hsb *hsb_DE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hsb_DE' +func (hsb *hsb_DE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hsb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := hsb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hsb_DE/hsb_DE_test.go b/vendor/github.com/go-playground/locales/hsb_DE/hsb_DE_test.go new file mode 100644 index 0000000000..3c92f27667 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hsb_DE/hsb_DE_test.go @@ -0,0 +1,1120 @@ +package hsb_DE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hsb_DE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hu/hu.go b/vendor/github.com/go-playground/locales/hu/hu.go new file mode 100644 index 0000000000..e4c7b50b6b --- /dev/null +++ b/vendor/github.com/go-playground/locales/hu/hu.go @@ -0,0 +1,600 @@ +package hu + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hu struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hu' locale +func New() locales.Translator { + return &hu{ + locale: "hu", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "Ft", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "febr.", "márc.", "ápr.", "máj.", "jún.", "júl.", "aug.", "szept.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "Á", "M", "J", "J", "A", "Sz", "O", "N", "D"}, + monthsWide: []string{"", "január", "február", "március", "április", "május", "június", "július", "augusztus", "szeptember", "október", "november", "december"}, + daysAbbreviated: []string{"V", "H", "K", "Sze", "Cs", "P", "Szo"}, + daysNarrow: []string{"V", "H", "K", "Sz", "Cs", "P", "Sz"}, + daysShort: []string{"V", "H", "K", "Sze", "Cs", "P", "Szo"}, + daysWide: []string{"vasárnap", "hétfő", "kedd", "szerda", "csütörtök", "péntek", "szombat"}, + periodsAbbreviated: []string{"de.", "du."}, + periodsNarrow: []string{"de.", "du."}, + periodsWide: []string{"de.", "du."}, + erasAbbreviated: []string{"i. e.", "i. sz."}, + erasNarrow: []string{"ie.", "isz."}, + erasWide: []string{"időszámításunk előtt", "időszámításunk szerint"}, + timezones: map[string]string{"AEDT": "kelet-ausztráliai nyári idő", "HEPM": "Saint Pierre és Miquelon-i nyári idő", "ADT": "atlanti-óceáni nyári idő", "HAST": "hawaii-aleuti téli idő", "COT": "kolumbiai téli idő", "HNNOMX": "északnyugat-mexikói zónaidő", "HNPM": "Saint Pierre és Miquelon-i zónaidő", "GYT": "guyanai téli idő", "CST": "középső államokbeli zónaidő", "CDT": "középső államokbeli nyári idő", "PDT": "csendes-óceáni nyári idő", "MESZ": "közép-európai nyári idő", "OESZ": "kelet-európai nyári idő", "EST": "keleti államokbeli zónaidő", "MST": "hegyvidéki zónaidő", "WIT": "kelet-indonéziai idő", "HEOG": "nyugat-grönlandi nyári idő", "WART": "nyugat-argentínai téli idő", "ART": "argentínai téli idő", "WAST": "nyugat-afrikai nyári idő", "ECT": "ecuadori téli idő", "MEZ": "közép-európai téli idő", "VET": "venezuelai idő", "HNOG": "nyugat-grönlandi téli idő", "CLST": "chilei nyári idő", "ACST": "közép-ausztráliai téli idő", "HEEG": "kelet-grönlandi nyári idő", "AKST": "alaszkai zónaidő", "ACWDT": "közép-nyugat-ausztráliai nyári idő", "OEZ": "kelet-európai téli idő", "EDT": "keleti államokbeli nyári idő", "SAST": "dél-afrikai téli idő", "EAT": "kelet-afrikai téli idő", "PST": "csendes-óceáni zónaidő", "NZST": "új-zélandi téli idő", "GMT": "greenwichi középidő, téli idő", "MYT": "malajziai idő", "HKST": "hongkongi nyári idő", "∅∅∅": "Acre nyári idő", "GFT": "francia-guianai idő", "ChST": "chamorrói téli idő", "AWDT": "nyugat-ausztráliai nyári idő", "JDT": "japán nyári idő", "WESZ": "nyugat-európai nyári idő", "HENOMX": "északnyugat-mexikói nyári idő", "HEPMX": "mexikói csendes-óceáni nyári idő", "ACWST": "közép-nyugat-ausztráliai téli idő", "TMT": "türkmenisztáni téli idő", "HKT": "hongkongi téli idő", "WITA": "közép-indonéziai idő", "LHST": "Lord Howe-szigeti téli idő", "HADT": "hawaii-aleuti nyári idő", "CLT": "chilei téli idő", "HNEG": "kelet-grönlandi téli idő", "UYST": "uruguayi nyári idő", "AWST": "nyugat-ausztráliai téli idő", "SGT": "szingapúri téli idő", "IST": "indiai téli idő", "AST": "atlanti-óceáni zónaidő", "WEZ": "nyugat-európai téli idő", "COST": "kolumbiai nyári idő", "BT": "butáni idő", "HNT": "új-fundlandi zónaidő", "LHDT": "Lord Howe-szigeti nyári idő", "BOT": "bolíviai téli idő", "CAT": "közép-afrikai téli idő", "JST": "japán téli idő", "ACDT": "közép-ausztráliai nyári idő", "MDT": "hegyvidéki nyári idő", "WARST": "nyugat-argentínai nyári idő", "HAT": "új-fundlandi nyári idő", "AEST": "kelet-ausztráliai téli idő", "UYT": "uruguayi téli idő", "HNPMX": "mexikói csendes-óceáni zónaidő", "SRT": "szurinámi idő", "HNCU": "kubai téli idő", "HECU": "kubai nyári idő", "WIB": "nyugat-indonéziai téli idő", "CHADT": "chathami nyári idő", "WAT": "nyugat-afrikai téli idő", "AKDT": "alaszkai nyári idő", "CHAST": "chathami téli idő", "NZDT": "új-zélandi nyári idő", "TMST": "türkmenisztáni nyári idő", "ARST": "Argentínai nyári idő"}, + } +} + +// Locale returns the current translators string locale +func (hu *hu) Locale() string { + return hu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hu' +func (hu *hu) PluralsCardinal() []locales.PluralRule { + return hu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hu' +func (hu *hu) PluralsOrdinal() []locales.PluralRule { + return hu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hu' +func (hu *hu) PluralsRange() []locales.PluralRule { + return hu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hu' +func (hu *hu) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hu' +func (hu *hu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 5 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hu' +func (hu *hu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hu.CardinalPluralRule(num1, v1) + end := hu.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hu *hu) MonthAbbreviated(month time.Month) string { + return hu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hu *hu) MonthsAbbreviated() []string { + return hu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hu *hu) MonthNarrow(month time.Month) string { + return hu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hu *hu) MonthsNarrow() []string { + return hu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hu *hu) MonthWide(month time.Month) string { + return hu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hu *hu) MonthsWide() []string { + return hu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hu *hu) WeekdayAbbreviated(weekday time.Weekday) string { + return hu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hu *hu) WeekdaysAbbreviated() []string { + return hu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hu *hu) WeekdayNarrow(weekday time.Weekday) string { + return hu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hu *hu) WeekdaysNarrow() []string { + return hu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hu *hu) WeekdayShort(weekday time.Weekday) string { + return hu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hu *hu) WeekdaysShort() []string { + return hu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hu *hu) WeekdayWide(weekday time.Weekday) string { + return hu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hu *hu) WeekdaysWide() []string { + return hu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hu' and handles both Whole and Real numbers based on 'v' +func (hu *hu) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hu.group) - 1; j >= 0; j-- { + b = append(b, hu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hu' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hu *hu) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hu' +func (hu *hu) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hu.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hu.group) - 1; j >= 0; j-- { + b = append(b, hu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, hu.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hu' +// in accounting notation. +func (hu *hu) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hu.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hu.group) - 1; j >= 0; j-- { + b = append(b, hu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, hu.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, hu.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, hu.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hu' +func (hu *hu) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hu' +func (hu *hu) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hu' +func (hu *hu) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hu' +func (hu *hu) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = append(b, hu.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hu' +func (hu *hu) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hu' +func (hu *hu) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hu' +func (hu *hu) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hu' +func (hu *hu) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := hu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hu/hu_test.go b/vendor/github.com/go-playground/locales/hu/hu_test.go new file mode 100644 index 0000000000..740906742e --- /dev/null +++ b/vendor/github.com/go-playground/locales/hu/hu_test.go @@ -0,0 +1,1120 @@ +package hu + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hu" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hu_HU/hu_HU.go b/vendor/github.com/go-playground/locales/hu_HU/hu_HU.go new file mode 100644 index 0000000000..d338ba3179 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hu_HU/hu_HU.go @@ -0,0 +1,600 @@ +package hu_HU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hu_HU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hu_HU' locale +func New() locales.Translator { + return &hu_HU{ + locale: "hu_HU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "febr.", "márc.", "ápr.", "máj.", "jún.", "júl.", "aug.", "szept.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "Á", "M", "J", "J", "A", "Sz", "O", "N", "D"}, + monthsWide: []string{"", "január", "február", "március", "április", "május", "június", "július", "augusztus", "szeptember", "október", "november", "december"}, + daysAbbreviated: []string{"V", "H", "K", "Sze", "Cs", "P", "Szo"}, + daysNarrow: []string{"V", "H", "K", "Sz", "Cs", "P", "Sz"}, + daysShort: []string{"V", "H", "K", "Sze", "Cs", "P", "Szo"}, + daysWide: []string{"vasárnap", "hétfő", "kedd", "szerda", "csütörtök", "péntek", "szombat"}, + periodsAbbreviated: []string{"de.", "du."}, + periodsNarrow: []string{"de.", "du."}, + periodsWide: []string{"de.", "du."}, + erasAbbreviated: []string{"i. e.", "i. sz."}, + erasNarrow: []string{"ie.", "isz."}, + erasWide: []string{"időszámításunk előtt", "időszámításunk szerint"}, + timezones: map[string]string{"SGT": "szingapúri téli idő", "MESZ": "közép-európai nyári idő", "CHADT": "chathami nyári idő", "HNNOMX": "északnyugat-mexikói zónaidő", "AEST": "kelet-ausztráliai téli idő", "HECU": "kubai nyári idő", "HAST": "hawaii-aleuti téli idő", "ACDT": "közép-ausztráliai nyári idő", "ACST": "közép-ausztráliai téli idő", "HENOMX": "északnyugat-mexikói nyári idő", "AEDT": "kelet-ausztráliai nyári idő", "WAST": "nyugat-afrikai nyári idő", "HNT": "új-fundlandi zónaidő", "CST": "középső államokbeli zónaidő", "ACWDT": "közép-nyugat-ausztráliai nyári idő", "NZST": "új-zélandi téli idő", "MYT": "malajziai idő", "TMT": "türkmenisztáni téli idő", "HKST": "hongkongi nyári idő", "AKDT": "alaszkai nyári idő", "MST": "hegyvidéki zónaidő", "SRT": "szurinámi idő", "CAT": "közép-afrikai téli idő", "WITA": "közép-indonéziai idő", "HNCU": "kubai téli idő", "WIB": "nyugat-indonéziai téli idő", "WIT": "kelet-indonéziai idő", "AWST": "nyugat-ausztráliai téli idő", "JST": "japán téli idő", "ADT": "atlanti-óceáni nyári idő", "∅∅∅": "Acre nyári idő", "HEPMX": "mexikói csendes-óceáni nyári idő", "ECT": "ecuadori téli idő", "HKT": "hongkongi téli idő", "MDT": "hegyvidéki nyári idő", "HNPMX": "mexikói csendes-óceáni zónaidő", "CHAST": "chathami téli idő", "WEZ": "nyugat-európai téli idő", "ART": "argentínai téli idő", "EDT": "keleti államokbeli nyári idő", "ACWST": "közép-nyugat-ausztráliai téli idő", "VET": "venezuelai idő", "EST": "keleti államokbeli zónaidő", "SAST": "dél-afrikai téli idő", "GYT": "guyanai téli idő", "PST": "csendes-óceáni zónaidő", "PDT": "csendes-óceáni nyári idő", "WART": "nyugat-argentínai téli idő", "WARST": "nyugat-argentínai nyári idő", "ARST": "Argentínai nyári idő", "COST": "kolumbiai nyári idő", "HNEG": "kelet-grönlandi téli idő", "AKST": "alaszkai zónaidő", "ChST": "chamorrói téli idő", "EAT": "kelet-afrikai téli idő", "IST": "indiai téli idő", "AST": "atlanti-óceáni zónaidő", "CLST": "chilei nyári idő", "HAT": "új-fundlandi nyári idő", "AWDT": "nyugat-ausztráliai nyári idő", "HNOG": "nyugat-grönlandi téli idő", "HEOG": "nyugat-grönlandi nyári idő", "WESZ": "nyugat-európai nyári idő", "GMT": "greenwichi középidő, téli idő", "CLT": "chilei téli idő", "UYT": "uruguayi téli idő", "GFT": "francia-guianai idő", "UYST": "uruguayi nyári idő", "HEPM": "Saint Pierre és Miquelon-i nyári idő", "MEZ": "közép-európai téli idő", "OESZ": "kelet-európai nyári idő", "COT": "kolumbiai téli idő", "HNPM": "Saint Pierre és Miquelon-i zónaidő", "LHST": "Lord Howe-szigeti téli idő", "CDT": "középső államokbeli nyári idő", "HADT": "hawaii-aleuti nyári idő", "JDT": "japán nyári idő", "TMST": "türkmenisztáni nyári idő", "BT": "butáni idő", "NZDT": "új-zélandi nyári idő", "HEEG": "kelet-grönlandi nyári idő", "LHDT": "Lord Howe-szigeti nyári idő", "BOT": "bolíviai téli idő", "OEZ": "kelet-európai téli idő", "WAT": "nyugat-afrikai téli idő"}, + } +} + +// Locale returns the current translators string locale +func (hu *hu_HU) Locale() string { + return hu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hu_HU' +func (hu *hu_HU) PluralsCardinal() []locales.PluralRule { + return hu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hu_HU' +func (hu *hu_HU) PluralsOrdinal() []locales.PluralRule { + return hu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hu_HU' +func (hu *hu_HU) PluralsRange() []locales.PluralRule { + return hu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hu_HU' +func (hu *hu_HU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hu_HU' +func (hu *hu_HU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 || n == 5 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hu_HU' +func (hu *hu_HU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hu.CardinalPluralRule(num1, v1) + end := hu.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hu *hu_HU) MonthAbbreviated(month time.Month) string { + return hu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hu *hu_HU) MonthsAbbreviated() []string { + return hu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hu *hu_HU) MonthNarrow(month time.Month) string { + return hu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hu *hu_HU) MonthsNarrow() []string { + return hu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hu *hu_HU) MonthWide(month time.Month) string { + return hu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hu *hu_HU) MonthsWide() []string { + return hu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hu *hu_HU) WeekdayAbbreviated(weekday time.Weekday) string { + return hu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hu *hu_HU) WeekdaysAbbreviated() []string { + return hu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hu *hu_HU) WeekdayNarrow(weekday time.Weekday) string { + return hu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hu *hu_HU) WeekdaysNarrow() []string { + return hu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hu *hu_HU) WeekdayShort(weekday time.Weekday) string { + return hu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hu *hu_HU) WeekdaysShort() []string { + return hu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hu *hu_HU) WeekdayWide(weekday time.Weekday) string { + return hu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hu *hu_HU) WeekdaysWide() []string { + return hu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hu_HU' and handles both Whole and Real numbers based on 'v' +func (hu *hu_HU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hu.group) - 1; j >= 0; j-- { + b = append(b, hu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hu_HU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hu *hu_HU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hu_HU' +func (hu *hu_HU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hu.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hu.group) - 1; j >= 0; j-- { + b = append(b, hu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, hu.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hu_HU' +// in accounting notation. +func (hu *hu_HU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hu.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hu.group) - 1; j >= 0; j-- { + b = append(b, hu.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, hu.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, hu.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, hu.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hu_HU' +func (hu *hu_HU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hu_HU' +func (hu *hu_HU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hu_HU' +func (hu *hu_HU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hu_HU' +func (hu *hu_HU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, hu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = append(b, hu.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hu_HU' +func (hu *hu_HU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hu_HU' +func (hu *hu_HU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hu_HU' +func (hu *hu_HU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hu_HU' +func (hu *hu_HU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := hu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hu_HU/hu_HU_test.go b/vendor/github.com/go-playground/locales/hu_HU/hu_HU_test.go new file mode 100644 index 0000000000..c05d3724dc --- /dev/null +++ b/vendor/github.com/go-playground/locales/hu_HU/hu_HU_test.go @@ -0,0 +1,1120 @@ +package hu_HU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hu_HU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hy/hy.go b/vendor/github.com/go-playground/locales/hy/hy.go new file mode 100644 index 0000000000..e32beea408 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hy/hy.go @@ -0,0 +1,638 @@ +package hy + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hy struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hy' locale +func New() locales.Translator { + return &hy{ + locale: "hy", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "֏", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "հնվ", "փտվ", "մրտ", "ապր", "մյս", "հնս", "հլս", "օգս", "սեպ", "հոկ", "նոյ", "դեկ"}, + monthsNarrow: []string{"", "Հ", "Փ", "Մ", "Ա", "Մ", "Հ", "Հ", "Օ", "Ս", "Հ", "Ն", "Դ"}, + monthsWide: []string{"", "հունվարի", "փետրվարի", "մարտի", "ապրիլի", "մայիսի", "հունիսի", "հուլիսի", "օգոստոսի", "սեպտեմբերի", "հոկտեմբերի", "նոյեմբերի", "դեկտեմբերի"}, + daysAbbreviated: []string{"կիր", "երկ", "երք", "չրք", "հնգ", "ուր", "շբթ"}, + daysNarrow: []string{"Կ", "Ե", "Ե", "Չ", "Հ", "Ո", "Շ"}, + daysShort: []string{"կր", "եկ", "եք", "չք", "հգ", "ու", "շբ"}, + daysWide: []string{"կիրակի", "երկուշաբթի", "երեքշաբթի", "չորեքշաբթի", "հինգշաբթի", "ուրբաթ", "շաբաթ"}, + periodsAbbreviated: []string{"ԿԱ", "ԿՀ"}, + periodsNarrow: []string{"ա", "հ"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Քրիստոսից առաջ", "Քրիստոսից հետո"}, + timezones: map[string]string{"HKT": "Հոնկոնգի ստանդարտ ժամանակ", "ACST": "Կենտրոնական Ավստրալիայի ստանդարտ ժամանակ", "HNEG": "Արևելյան Գրենլանդիայի ստանդարտ ժամանակ", "HNPM": "Սեն Պիեռ և Միքելոնի ստանդարտ ժամանակ", "ACWST": "Կենտրոնական Ավստրալիայի արևմտյան ստանդարտ ժամանակ", "NZDT": "Նոր Զելանդիայի ամառային ժամանակ", "HNNOMX": "Հյուսիսարևմտյան Մեքսիկայի ստանդարտ ժամանակ", "HNCU": "Կուբայի ստանդարտ ժամանակ", "GMT": "Գրինվիչի ժամանակ", "COST": "Կոլումբիայի ամառային ժամանակ", "ACDT": "Կենտրոնական Ավստրալիայի ամառային ժամանակ", "HEEG": "Արևելյան Գրենլանդիայի ամառային ժամանակ", "AEDT": "Արևելյան Ավստրալիայի ամառային ժամանակ", "LHDT": "Լորդ Հաուի ամառային ժամանակ", "CAT": "Կենտրոնական Աֆրիկայի ժամանակ", "WEZ": "Արևմտյան Եվրոպայի ստանդարտ ժամանակ", "CDT": "Կենտրոնական Ամերիկայի ամառային ժամանակ", "CHAST": "Չաթեմ կղզու ստանդարտ ժամանակ", "WITA": "Կենտրոնական Ինդոնեզիայի ժամանակ", "LHST": "Լորդ Հաուի ստանդարտ ժամանակ", "AWST": "Արևմտյան Ավստրալիայի ստանդարտ ժամանակ", "AWDT": "Արևմտյան Ավստրալիայի ամառային ժամանակ", "SGT": "Սինգապուրի ժամանակ", "WESZ": "Արևմտյան Եվրոպայի ամառային ժամանակ", "MDT": "MDT", "HEPM": "Սեն Պիեռ և Միքելոնի ամառային ժամանակ", "HNPMX": "Մեքսիկայի խաղաղօվկիանոսյան ստանդարտ ժամանակ", "WIB": "Արևմտյան Ինդոնեզիայի ժամանակ", "WIT": "Արևելյան Ինդոնեզիայի ժամանակ", "HKST": "Հոնկոնգի ամառային ժամանակ", "HAT": "Նյուֆաունդլենդի ամառային ժամանակ", "MST": "MST", "IST": "Հնդկաստանի ստանդարտ ժամանակ", "HNOG": "Արևմտյան Գրենլանդիայի ստանդարտ ժամանակ", "WART": "Արևմտյան Արգենտինայի ստնադարտ ժամանակ", "CLT": "Չիլիի ստանդարտ ժամանակ", "EDT": "Արևելյան Ամերիկայի ամառային ժամանակ", "WAT": "Արևմտյան Աֆրիկայի ստանդարտ ժամանակ", "HNT": "Նյուֆաունդլենդի ստանդարտ ժամանակ", "EAT": "Արևելյան Աֆրիկայի ժամանակ", "ACWDT": "Կենտրոնական Ավստրալիայի արևմտյան ամառային ժամանակ", "MEZ": "Կենտրոնական Եվրոպայի ստանդարտ ժամանակ", "ART": "Արգենտինայի ստնադարտ ժամանակ", "ARST": "Արգենտինայի ամառային ժամանակ", "UYST": "Ուրուգվայի ամառային ժամանակ", "HECU": "Կուբայի ամառային ժամանակ", "MYT": "Մալայզիայի ժամանակ", "WARST": "Արևմտյան Արգենտինայի ամառային ժամանակ", "NZST": "Նոր Զելանդիայի ստանդարտ ժամանակ", "VET": "Վենեսուելայի ժամանակ", "SRT": "Սուրինամի ժամանակ", "CST": "Կենտրոնական Ամերիկայի ստանդարտ ժամանակ", "BOT": "Բոլիվիայի ժամանակ", "PST": "Խաղաղօվկիանոսյան ստանդարտ ժամանակ", "PDT": "Խաղաղօվկիանոսյան ամառային ժամանակ", "HEOG": "Արևմտյան Գրենլանդիայի ամառային ժամանակ", "BT": "Բութանի ժամանակ", "GFT": "Ֆրանսիական Գվիանայի ժամանակ", "GYT": "Գայանայի ժամանակ", "CHADT": "Չաթեմ կղզու ամառային ժամանակ", "HAST": "Հավայան-ալեության ստանդարտ ժամանակ", "JDT": "Ճապոնիայի ամառային ժամանակ", "HADT": "Հավայան-ալեության ամառային ժամանակ", "EST": "Արևելյան Ամերիկայի ստանդարտ ժամանակ", "CLST": "Չիլիի ամառային ժամանակ", "AST": "Ատլանտյան ստանդարտ ժամանակ", "TMT": "Թուրքմենստանի ստանդարտ ժամանակ", "COT": "Կոլումբիայի ստանդարտ ժամանակ", "HEPMX": "Մեքսիկայի խաղաղօվկիանոսյան ամառային ժամանակ", "JST": "Ճապոնիայի ստանդարտ ժամանակ", "OESZ": "Արևելյան Եվրոպայի ամառային ժամանակ", "WAST": "Արևմտյան Աֆրիկայի ամառային ժամանակ", "UYT": "Ուրուգվայի ստանդարտ ժամանակ", "ADT": "Ատլանտյան ամառային ժամանակ", "TMST": "Թուրքմենստանի ամառային ժամանակ", "MESZ": "Կենտրոնական Եվրոպայի ամառային ժամանակ", "OEZ": "Արևելյան Եվրոպայի ստանդարտ ժամանակ", "HENOMX": "Հյուսիսարևմտյան Մեքսիկայի ամառային ժամանակ", "AEST": "Արևելյան Ավստրալիայի ստանդարտ ժամանակ", "AKST": "Ալյասկայի ստանդարտ ժամանակ", "AKDT": "Ալյասկայի ամառային ժամանակ", "ECT": "Էկվադորի ժամանակ", "∅∅∅": "Ամազոնյան ամառային ժամանակ", "ChST": "Չամոռոյի ժամանակ", "SAST": "Հարավային Աֆրիկայի ժամանակ"}, + } +} + +// Locale returns the current translators string locale +func (hy *hy) Locale() string { + return hy.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hy' +func (hy *hy) PluralsCardinal() []locales.PluralRule { + return hy.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hy' +func (hy *hy) PluralsOrdinal() []locales.PluralRule { + return hy.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hy' +func (hy *hy) PluralsRange() []locales.PluralRule { + return hy.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hy' +func (hy *hy) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hy' +func (hy *hy) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hy' +func (hy *hy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hy.CardinalPluralRule(num1, v1) + end := hy.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hy *hy) MonthAbbreviated(month time.Month) string { + return hy.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hy *hy) MonthsAbbreviated() []string { + return hy.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hy *hy) MonthNarrow(month time.Month) string { + return hy.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hy *hy) MonthsNarrow() []string { + return hy.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hy *hy) MonthWide(month time.Month) string { + return hy.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hy *hy) MonthsWide() []string { + return hy.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hy *hy) WeekdayAbbreviated(weekday time.Weekday) string { + return hy.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hy *hy) WeekdaysAbbreviated() []string { + return hy.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hy *hy) WeekdayNarrow(weekday time.Weekday) string { + return hy.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hy *hy) WeekdaysNarrow() []string { + return hy.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hy *hy) WeekdayShort(weekday time.Weekday) string { + return hy.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hy *hy) WeekdaysShort() []string { + return hy.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hy *hy) WeekdayWide(weekday time.Weekday) string { + return hy.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hy *hy) WeekdaysWide() []string { + return hy.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hy' and handles both Whole and Real numbers based on 'v' +func (hy *hy) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hy.group) - 1; j >= 0; j-- { + b = append(b, hy.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hy' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hy *hy) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hy.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hy.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hy' +func (hy *hy) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hy.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hy.group) - 1; j >= 0; j-- { + b = append(b, hy.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(hy.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, hy.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, hy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hy' +// in accounting notation. +func (hy *hy) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hy.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hy.group) - 1; j >= 0; j-- { + b = append(b, hy.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(hy.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, hy.currencyNegativePrefix[j]) + } + + b = append(b, hy.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(hy.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, hy.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hy' +func (hy *hy) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hy' +func (hy *hy) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, hy.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hy' +func (hy *hy) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, hy.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hy' +func (hy *hy) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e, 0x20}...) + b = append(b, hy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, hy.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hy' +func (hy *hy) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hy' +func (hy *hy) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hy' +func (hy *hy) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hy' +func (hy *hy) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := hy.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hy/hy_test.go b/vendor/github.com/go-playground/locales/hy/hy_test.go new file mode 100644 index 0000000000..9ffe5b8558 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hy/hy_test.go @@ -0,0 +1,1120 @@ +package hy + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hy" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/hy_AM/hy_AM.go b/vendor/github.com/go-playground/locales/hy_AM/hy_AM.go new file mode 100644 index 0000000000..184b2c1a8e --- /dev/null +++ b/vendor/github.com/go-playground/locales/hy_AM/hy_AM.go @@ -0,0 +1,638 @@ +package hy_AM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type hy_AM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'hy_AM' locale +func New() locales.Translator { + return &hy_AM{ + locale: "hy_AM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "հնվ", "փտվ", "մրտ", "ապր", "մյս", "հնս", "հլս", "օգս", "սեպ", "հոկ", "նոյ", "դեկ"}, + monthsNarrow: []string{"", "Հ", "Փ", "Մ", "Ա", "Մ", "Հ", "Հ", "Օ", "Ս", "Հ", "Ն", "Դ"}, + monthsWide: []string{"", "հունվարի", "փետրվարի", "մարտի", "ապրիլի", "մայիսի", "հունիսի", "հուլիսի", "օգոստոսի", "սեպտեմբերի", "հոկտեմբերի", "նոյեմբերի", "դեկտեմբերի"}, + daysAbbreviated: []string{"կիր", "երկ", "երք", "չրք", "հնգ", "ուր", "շբթ"}, + daysNarrow: []string{"Կ", "Ե", "Ե", "Չ", "Հ", "Ո", "Շ"}, + daysShort: []string{"կր", "եկ", "եք", "չք", "հգ", "ու", "շբ"}, + daysWide: []string{"կիրակի", "երկուշաբթի", "երեքշաբթի", "չորեքշաբթի", "հինգշաբթի", "ուրբաթ", "շաբաթ"}, + periodsAbbreviated: []string{"ԿԱ", "ԿՀ"}, + periodsNarrow: []string{"ա", "հ"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Քրիստոսից առաջ", "Քրիստոսից հետո"}, + timezones: map[string]string{"AKST": "Ալյասկայի ստանդարտ ժամանակ", "LHDT": "Լորդ Հաուի ամառային ժամանակ", "CHADT": "Չաթեմ կղզու ամառային ժամանակ", "BOT": "Բոլիվիայի ժամանակ", "WAT": "Արևմտյան Աֆրիկայի ստանդարտ ժամանակ", "HKT": "Հոնկոնգի ստանդարտ ժամանակ", "GFT": "Ֆրանսիական Գվիանայի ժամանակ", "SAST": "Հարավային Աֆրիկայի ժամանակ", "HADT": "Հավայան-ալեության ամառային ժամանակ", "WART": "Արևմտյան Արգենտինայի ստնադարտ ժամանակ", "HKST": "Հոնկոնգի ամառային ժամանակ", "HNEG": "Արևելյան Գրենլանդիայի ստանդարտ ժամանակ", "HEPMX": "Մեքսիկայի խաղաղօվկիանոսյան ամառային ժամանակ", "AWST": "Արևմտյան Ավստրալիայի ստանդարտ ժամանակ", "CAT": "Կենտրոնական Աֆրիկայի ժամանակ", "MESZ": "Կենտրոնական Եվրոպայի ամառային ժամանակ", "CLT": "Չիլիի ստանդարտ ժամանակ", "WIT": "Արևելյան Ինդոնեզիայի ժամանակ", "WESZ": "Արևմտյան Եվրոպայի ամառային ժամանակ", "EST": "Արևելյան Ամերիկայի ստանդարտ ժամանակ", "HECU": "Կուբայի ամառային ժամանակ", "SGT": "Սինգապուրի ժամանակ", "NZST": "Նոր Զելանդիայի ստանդարտ ժամանակ", "EDT": "Արևելյան Ամերիկայի ամառային ժամանակ", "BT": "Բութանի ժամանակ", "AST": "Ատլանտյան ստանդարտ ժամանակ", "WEZ": "Արևմտյան Եվրոպայի ստանդարտ ժամանակ", "ART": "Արգենտինայի ստնադարտ ժամանակ", "ARST": "Արգենտինայի ամառային ժամանակ", "CST": "Կենտրոնական Ամերիկայի ստանդարտ ժամանակ", "∅∅∅": "Բրազիլիայի ամառային ժամանակ", "NZDT": "Նոր Զելանդիայի ամառային ժամանակ", "CLST": "Չիլիի ամառային ժամանակ", "HNCU": "Կուբայի ստանդարտ ժամանակ", "COT": "Կոլումբիայի ստանդարտ ժամանակ", "HAT": "Նյուֆաունդլենդի ամառային ժամանակ", "UYT": "Ուրուգվայի ստանդարտ ժամանակ", "EAT": "Արևելյան Աֆրիկայի ժամանակ", "HEPM": "Սեն Պիեռ և Միքելոնի ամառային ժամանակ", "GYT": "Գայանայի ժամանակ", "HAST": "Հավայան-ալեության ստանդարտ ժամանակ", "VET": "Վենեսուելայի ժամանակ", "WAST": "Արևմտյան Աֆրիկայի ամառային ժամանակ", "ChST": "Չամոռոյի ժամանակ", "IST": "Հնդկաստանի ստանդարտ ժամանակ", "WARST": "Արևմտյան Արգենտինայի ամառային ժամանակ", "ADT": "Ատլանտյան ամառային ժամանակ", "MYT": "Մալայզիայի ժամանակ", "HENOMX": "Հյուսիսարևմտյան Մեքսիկայի ամառային ժամանակ", "AEST": "Արևելյան Ավստրալիայի ստանդարտ ժամանակ", "ACWST": "Կենտրոնական Ավստրալիայի արևմտյան ստանդարտ ժամանակ", "HNOG": "Արևմտյան Գրենլանդիայի ստանդարտ ժամանակ", "OEZ": "Արևելյան Եվրոպայի ստանդարտ ժամանակ", "TMST": "Թուրքմենստանի ամառային ժամանակ", "MEZ": "Կենտրոնական Եվրոպայի ստանդարտ ժամանակ", "ACST": "Կենտրոնական Ավստրալիայի ստանդարտ ժամանակ", "HNT": "Նյուֆաունդլենդի ստանդարտ ժամանակ", "LHST": "Լորդ Հաուի ստանդարտ ժամանակ", "MST": "MST", "MDT": "MDT", "SRT": "Սուրինամի ժամանակ", "HNNOMX": "Հյուսիսարևմտյան Մեքսիկայի ստանդարտ ժամանակ", "AKDT": "Ալյասկայի ամառային ժամանակ", "HNPM": "Սեն Պիեռ և Միքելոնի ստանդարտ ժամանակ", "ECT": "Էկվադորի ժամանակ", "PDT": "Խաղաղօվկիանոսյան ամառային ժամանակ", "JST": "Ճապոնիայի ստանդարտ ժամանակ", "HEOG": "Արևմտյան Գրենլանդիայի ամառային ժամանակ", "UYST": "Ուրուգվայի ամառային ժամանակ", "AWDT": "Արևմտյան Ավստրալիայի ամառային ժամանակ", "CHAST": "Չաթեմ կղզու ստանդարտ ժամանակ", "HEEG": "Արևելյան Գրենլանդիայի ամառային ժամանակ", "WITA": "Կենտրոնական Ինդոնեզիայի ժամանակ", "PST": "Խաղաղօվկիանոսյան ստանդարտ ժամանակ", "OESZ": "Արևելյան Եվրոպայի ամառային ժամանակ", "TMT": "Թուրքմենստանի ստանդարտ ժամանակ", "AEDT": "Արևելյան Ավստրալիայի ամառային ժամանակ", "ACWDT": "Կենտրոնական Ավստրալիայի արևմտյան ամառային ժամանակ", "COST": "Կոլումբիայի ամառային ժամանակ", "HNPMX": "Մեքսիկայի խաղաղօվկիանոսյան ստանդարտ ժամանակ", "WIB": "Արևմտյան Ինդոնեզիայի ժամանակ", "CDT": "Կենտրոնական Ամերիկայի ամառային ժամանակ", "JDT": "Ճապոնիայի ամառային ժամանակ", "GMT": "Գրինվիչի ժամանակ", "ACDT": "Կենտրոնական Ավստրալիայի ամառային ժամանակ"}, + } +} + +// Locale returns the current translators string locale +func (hy *hy_AM) Locale() string { + return hy.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'hy_AM' +func (hy *hy_AM) PluralsCardinal() []locales.PluralRule { + return hy.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'hy_AM' +func (hy *hy_AM) PluralsOrdinal() []locales.PluralRule { + return hy.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'hy_AM' +func (hy *hy_AM) PluralsRange() []locales.PluralRule { + return hy.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hy_AM' +func (hy *hy_AM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hy_AM' +func (hy *hy_AM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hy_AM' +func (hy *hy_AM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := hy.CardinalPluralRule(num1, v1) + end := hy.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (hy *hy_AM) MonthAbbreviated(month time.Month) string { + return hy.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (hy *hy_AM) MonthsAbbreviated() []string { + return hy.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (hy *hy_AM) MonthNarrow(month time.Month) string { + return hy.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (hy *hy_AM) MonthsNarrow() []string { + return hy.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (hy *hy_AM) MonthWide(month time.Month) string { + return hy.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (hy *hy_AM) MonthsWide() []string { + return hy.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (hy *hy_AM) WeekdayAbbreviated(weekday time.Weekday) string { + return hy.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (hy *hy_AM) WeekdaysAbbreviated() []string { + return hy.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (hy *hy_AM) WeekdayNarrow(weekday time.Weekday) string { + return hy.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (hy *hy_AM) WeekdaysNarrow() []string { + return hy.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (hy *hy_AM) WeekdayShort(weekday time.Weekday) string { + return hy.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (hy *hy_AM) WeekdaysShort() []string { + return hy.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (hy *hy_AM) WeekdayWide(weekday time.Weekday) string { + return hy.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (hy *hy_AM) WeekdaysWide() []string { + return hy.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'hy_AM' and handles both Whole and Real numbers based on 'v' +func (hy *hy_AM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hy.group) - 1; j >= 0; j-- { + b = append(b, hy.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'hy_AM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (hy *hy_AM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hy.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, hy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, hy.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hy_AM' +func (hy *hy_AM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hy.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hy.group) - 1; j >= 0; j-- { + b = append(b, hy.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(hy.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, hy.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, hy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hy_AM' +// in accounting notation. +func (hy *hy_AM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := hy.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, hy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(hy.group) - 1; j >= 0; j-- { + b = append(b, hy.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(hy.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, hy.currencyNegativePrefix[j]) + } + + b = append(b, hy.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(hy.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, hy.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, hy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'hy_AM' +func (hy *hy_AM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'hy_AM' +func (hy *hy_AM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, hy.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'hy_AM' +func (hy *hy_AM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, hy.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'hy_AM' +func (hy *hy_AM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e, 0x20}...) + b = append(b, hy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, hy.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'hy_AM' +func (hy *hy_AM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'hy_AM' +func (hy *hy_AM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'hy_AM' +func (hy *hy_AM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'hy_AM' +func (hy *hy_AM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, hy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, hy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := hy.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/hy_AM/hy_AM_test.go b/vendor/github.com/go-playground/locales/hy_AM/hy_AM_test.go new file mode 100644 index 0000000000..1ac2436112 --- /dev/null +++ b/vendor/github.com/go-playground/locales/hy_AM/hy_AM_test.go @@ -0,0 +1,1120 @@ +package hy_AM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "hy_AM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/id/id.go b/vendor/github.com/go-playground/locales/id/id.go new file mode 100644 index 0000000000..a9bf9ae5f2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/id/id.go @@ -0,0 +1,583 @@ +package id + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type id struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'id' locale +func New() locales.Translator { + return &id{ + locale: "id", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "Rp", "IEP", "ILP", "ILR", "₪", "Rs", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agt", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"}, + daysAbbreviated: []string{"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"}, + daysNarrow: []string{"M", "S", "S", "R", "K", "J", "S"}, + daysShort: []string{"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"}, + daysWide: []string{"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"SM", "M"}, + erasNarrow: []string{"SM", "M"}, + erasWide: []string{"Sebelum Masehi", "Masehi"}, + timezones: map[string]string{"HKT": "Waktu Standar Hong Kong", "ACDT": "Waktu Musim Panas Tengah Australia", "AKDT": "Waktu Musim Panas Alaska", "WEZ": "Waktu Standar Eropa Barat", "EST": "Waktu Standar Timur", "LHST": "Waktu Standar Lord Howe", "AWST": "Waktu Standar Barat Australia", "ACWST": "Waktu Standar Barat Tengah Australia", "ACWDT": "Waktu Musim Panas Barat Tengah Australia", "MESZ": "Waktu Musim Panas Eropa Tengah", "CLST": "Waktu Musim Panas Cile", "AST": "Waktu Standar Atlantik", "UYT": "Waktu Standar Uruguay", "OEZ": "Waktu Standar Eropa Timur", "MYT": "Waktu Malaysia", "WIB": "Waktu Indonesia Barat", "HECU": "Waktu Musim Panas Kuba", "LHDT": "Waktu Musim Panas Lord Howe", "BT": "Waktu Bhutan", "GYT": "Waktu Guyana", "JST": "Waktu Standar Jepang", "WAST": "Waktu Musim Panas Afrika Barat", "SRT": "Waktu Suriname", "HNPMX": "Waktu Standar Pasifik Meksiko", "HADT": "Waktu Musim Panas Hawaii-Aleutian", "WART": "Waktu Standar Argentina Bagian Barat", "UYST": "Waktu Musim Panas Uruguay", "NZST": "Waktu Standar Selandia Baru", "SGT": "Waktu Standar Singapura", "ARST": "Waktu Musim Panas Argentina", "WAT": "Waktu Standar Afrika Barat", "WIT": "Waktu Indonesia Timur", "AWDT": "Waktu Musim Panas Barat Australia", "NZDT": "Waktu Musim Panas Selandia Baru", "ADT": "Waktu Musim Panas Atlantik", "WESZ": "Waktu Musim Panas Eropa Barat", "MST": "Waktu Standar Makau", "HNT": "Waktu Standar Newfoundland", "HAT": "Waktu Musim Panas Newfoundland", "AKST": "Waktu Standar Alaska", "SAST": "Waktu Standar Afrika Selatan", "CDT": "Waktu Musim Panas Tengah", "CHADT": "Waktu Musim Panas Chatham", "VET": "Waktu Venezuela", "HENOMX": "Waktu Musim Panas Meksiko Barat Laut", "HEOG": "Waktu Musim Panas Greenland Barat", "GMT": "Greenwich Mean Time", "HKST": "Waktu Musim Panas Hong Kong", "GFT": "Waktu Guyana Prancis", "ChST": "Waktu Standar Chamorro", "EAT": "Waktu Afrika Timur", "ECT": "Waktu Ekuador", "CAT": "Waktu Afrika Tengah", "CLT": "Waktu Standar Cile", "MDT": "Waktu Musim Panas Makau", "HNOG": "Waktu Standar Greenland Barat", "HNNOMX": "Waktu Standar Meksiko Barat Laut", "HEEG": "Waktu Musim Panas Greenland Timur", "AEST": "Waktu Standar Timur Australia", "AEDT": "Waktu Musim Panas Timur Australia", "HEPMX": "Waktu Musim Panas Pasifik Meksiko", "CHAST": "Waktu Standar Chatham", "HAST": "Waktu Standar Hawaii-Aleutian", "COT": "Waktu Standar Kolombia", "WARST": "Waktu Musim Panas Argentina Bagian Barat", "TMST": "Waktu Musim Panas Turkmenistan", "JDT": "Waktu Musim Panas Jepang", "HNEG": "Waktu Standar Greenland Timur", "HEPM": "Waktu Musim Panas Saint Pierre dan Miquelon", "ACST": "Waktu Standar Tengah Australia", "CST": "Waktu Standar Tengah", "BOT": "Waktu Bolivia", "PDT": "Waktu Musim Panas Pasifik", "IST": "Waktu India", "EDT": "Waktu Musim Panas Timur", "WITA": "Waktu Indonesia Tengah", "HNPM": "Waktu Standar Saint Pierre dan Miquelon", "PST": "Waktu Standar Pasifik", "OESZ": "Waktu Musim Panas Eropa Timur", "ART": "Waktu Standar Argentina", "∅∅∅": "Waktu Musim Panas Acre", "HNCU": "Waktu Standar Kuba", "MEZ": "Waktu Standar Eropa Tengah", "TMT": "Waktu Standar Turkmenistan", "COST": "Waktu Musim Panas Kolombia"}, + } +} + +// Locale returns the current translators string locale +func (id *id) Locale() string { + return id.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'id' +func (id *id) PluralsCardinal() []locales.PluralRule { + return id.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'id' +func (id *id) PluralsOrdinal() []locales.PluralRule { + return id.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'id' +func (id *id) PluralsRange() []locales.PluralRule { + return id.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'id' +func (id *id) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'id' +func (id *id) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'id' +func (id *id) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (id *id) MonthAbbreviated(month time.Month) string { + return id.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (id *id) MonthsAbbreviated() []string { + return id.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (id *id) MonthNarrow(month time.Month) string { + return id.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (id *id) MonthsNarrow() []string { + return id.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (id *id) MonthWide(month time.Month) string { + return id.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (id *id) MonthsWide() []string { + return id.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (id *id) WeekdayAbbreviated(weekday time.Weekday) string { + return id.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (id *id) WeekdaysAbbreviated() []string { + return id.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (id *id) WeekdayNarrow(weekday time.Weekday) string { + return id.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (id *id) WeekdaysNarrow() []string { + return id.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (id *id) WeekdayShort(weekday time.Weekday) string { + return id.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (id *id) WeekdaysShort() []string { + return id.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (id *id) WeekdayWide(weekday time.Weekday) string { + return id.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (id *id) WeekdaysWide() []string { + return id.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'id' and handles both Whole and Real numbers based on 'v' +func (id *id) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, id.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, id.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, id.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'id' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (id *id) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, id.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, id.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, id.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'id' +func (id *id) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := id.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, id.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, id.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, id.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, id.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'id' +// in accounting notation. +func (id *id) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := id.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, id.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, id.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, id.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, id.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'id' +func (id *id) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'id' +func (id *id) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, id.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'id' +func (id *id) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, id.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'id' +func (id *id) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, id.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, id.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'id' +func (id *id) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'id' +func (id *id) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'id' +func (id *id) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'id' +func (id *id) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := id.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/id/id_test.go b/vendor/github.com/go-playground/locales/id/id_test.go new file mode 100644 index 0000000000..97c4e4a488 --- /dev/null +++ b/vendor/github.com/go-playground/locales/id/id_test.go @@ -0,0 +1,1120 @@ +package id + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "id" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/id_ID/id_ID.go b/vendor/github.com/go-playground/locales/id_ID/id_ID.go new file mode 100644 index 0000000000..442dc97221 --- /dev/null +++ b/vendor/github.com/go-playground/locales/id_ID/id_ID.go @@ -0,0 +1,583 @@ +package id_ID + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type id_ID struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'id_ID' locale +func New() locales.Translator { + return &id_ID{ + locale: "id_ID", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agt", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"}, + daysAbbreviated: []string{"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"}, + daysNarrow: []string{"M", "S", "S", "R", "K", "J", "S"}, + daysShort: []string{"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"}, + daysWide: []string{"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"SM", "M"}, + erasNarrow: []string{"SM", "M"}, + erasWide: []string{"Sebelum Masehi", "Masehi"}, + timezones: map[string]string{"TMST": "Waktu Musim Panas Turkmenistan", "EDT": "Waktu Musim Panas Timur", "CHADT": "Waktu Musim Panas Chatham", "BOT": "Waktu Bolivia", "MESZ": "Waktu Musim Panas Eropa Tengah", "HNOG": "Waktu Standar Greenland Barat", "OEZ": "Waktu Standar Eropa Timur", "WEZ": "Waktu Standar Eropa Barat", "WAST": "Waktu Musim Panas Afrika Barat", "HKT": "Waktu Standar Hong Kong", "COT": "Waktu Standar Kolombia", "HEEG": "Waktu Musim Panas Greenland Timur", "ECT": "Waktu Ekuador", "ACWST": "Waktu Standar Barat Tengah Australia", "WART": "Waktu Standar Argentina Bagian Barat", "CLT": "Waktu Standar Cile", "CLST": "Waktu Musim Panas Cile", "HEOG": "Waktu Musim Panas Greenland Barat", "OESZ": "Waktu Musim Panas Eropa Timur", "COST": "Waktu Musim Panas Kolombia", "∅∅∅": "Waktu Musim Panas Acre", "AEDT": "Waktu Musim Panas Timur Australia", "AWST": "Waktu Standar Barat Australia", "NZST": "Waktu Standar Selandia Baru", "WESZ": "Waktu Musim Panas Eropa Barat", "GFT": "Waktu Guyana Prancis", "AKST": "Waktu Standar Alaska", "HNPM": "Waktu Standar Saint Pierre dan Miquelon", "LHDT": "Waktu Musim Panas Lord Howe", "CDT": "Waktu Musim Panas Tengah", "AEST": "Waktu Standar Timur Australia", "ChST": "Waktu Standar Chamorro", "SRT": "Waktu Suriname", "CHAST": "Waktu Standar Chatham", "VET": "Waktu Venezuela", "ACDT": "Waktu Musim Panas Tengah Australia", "HAT": "Waktu Musim Panas Newfoundland", "UYT": "Waktu Standar Uruguay", "HEPMX": "Waktu Musim Panas Pasifik Meksiko", "AWDT": "Waktu Musim Panas Barat Australia", "PDT": "Waktu Musim Panas Pasifik", "JST": "Waktu Standar Jepang", "GMT": "Greenwich Mean Time", "WAT": "Waktu Standar Afrika Barat", "HECU": "Waktu Musim Panas Kuba", "ADT": "Waktu Musim Panas Atlantik", "ARST": "Waktu Musim Panas Argentina", "EST": "Waktu Standar Timur", "HNNOMX": "Waktu Standar Meksiko Barat Laut", "WIB": "Waktu Indonesia Barat", "CST": "Waktu Standar Tengah", "WARST": "Waktu Musim Panas Argentina Bagian Barat", "AKDT": "Waktu Musim Panas Alaska", "UYST": "Waktu Musim Panas Uruguay", "HNPMX": "Waktu Standar Pasifik Meksiko", "EAT": "Waktu Afrika Timur", "ACST": "Waktu Standar Tengah Australia", "WITA": "Waktu Indonesia Tengah", "TMT": "Waktu Standar Turkmenistan", "GYT": "Waktu Guyana", "CAT": "Waktu Afrika Tengah", "MDT": "Waktu Musim Panas Makau", "ART": "Waktu Standar Argentina", "HENOMX": "Waktu Musim Panas Meksiko Barat Laut", "SAST": "Waktu Standar Afrika Selatan", "LHST": "Waktu Standar Lord Howe", "HKST": "Waktu Musim Panas Hong Kong", "BT": "Waktu Bhutan", "HNEG": "Waktu Standar Greenland Timur", "JDT": "Waktu Musim Panas Jepang", "AST": "Waktu Standar Atlantik", "HEPM": "Waktu Musim Panas Saint Pierre dan Miquelon", "HAST": "Waktu Standar Hawaii-Aleutian", "MEZ": "Waktu Standar Eropa Tengah", "MYT": "Waktu Malaysia", "MST": "Waktu Standar Makau", "HNCU": "Waktu Standar Kuba", "SGT": "Waktu Standar Singapura", "PST": "Waktu Standar Pasifik", "NZDT": "Waktu Musim Panas Selandia Baru", "HNT": "Waktu Standar Newfoundland", "WIT": "Waktu Indonesia Timur", "HADT": "Waktu Musim Panas Hawaii-Aleutian", "IST": "Waktu India", "ACWDT": "Waktu Musim Panas Barat Tengah Australia"}, + } +} + +// Locale returns the current translators string locale +func (id *id_ID) Locale() string { + return id.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'id_ID' +func (id *id_ID) PluralsCardinal() []locales.PluralRule { + return id.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'id_ID' +func (id *id_ID) PluralsOrdinal() []locales.PluralRule { + return id.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'id_ID' +func (id *id_ID) PluralsRange() []locales.PluralRule { + return id.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'id_ID' +func (id *id_ID) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'id_ID' +func (id *id_ID) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'id_ID' +func (id *id_ID) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (id *id_ID) MonthAbbreviated(month time.Month) string { + return id.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (id *id_ID) MonthsAbbreviated() []string { + return id.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (id *id_ID) MonthNarrow(month time.Month) string { + return id.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (id *id_ID) MonthsNarrow() []string { + return id.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (id *id_ID) MonthWide(month time.Month) string { + return id.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (id *id_ID) MonthsWide() []string { + return id.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (id *id_ID) WeekdayAbbreviated(weekday time.Weekday) string { + return id.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (id *id_ID) WeekdaysAbbreviated() []string { + return id.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (id *id_ID) WeekdayNarrow(weekday time.Weekday) string { + return id.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (id *id_ID) WeekdaysNarrow() []string { + return id.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (id *id_ID) WeekdayShort(weekday time.Weekday) string { + return id.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (id *id_ID) WeekdaysShort() []string { + return id.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (id *id_ID) WeekdayWide(weekday time.Weekday) string { + return id.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (id *id_ID) WeekdaysWide() []string { + return id.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'id_ID' and handles both Whole and Real numbers based on 'v' +func (id *id_ID) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, id.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, id.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, id.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'id_ID' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (id *id_ID) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, id.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, id.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, id.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'id_ID' +func (id *id_ID) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := id.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, id.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, id.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, id.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, id.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'id_ID' +// in accounting notation. +func (id *id_ID) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := id.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, id.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, id.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, id.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, id.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'id_ID' +func (id *id_ID) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'id_ID' +func (id *id_ID) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, id.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'id_ID' +func (id *id_ID) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, id.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'id_ID' +func (id *id_ID) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, id.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, id.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'id_ID' +func (id *id_ID) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'id_ID' +func (id *id_ID) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'id_ID' +func (id *id_ID) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'id_ID' +func (id *id_ID) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := id.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/id_ID/id_ID_test.go b/vendor/github.com/go-playground/locales/id_ID/id_ID_test.go new file mode 100644 index 0000000000..0d3380fc81 --- /dev/null +++ b/vendor/github.com/go-playground/locales/id_ID/id_ID_test.go @@ -0,0 +1,1120 @@ +package id_ID + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "id_ID" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ig/ig.go b/vendor/github.com/go-playground/locales/ig/ig.go new file mode 100644 index 0000000000..41ffe0670c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ig/ig.go @@ -0,0 +1,594 @@ +package ig + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ig struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ig' locale +func New() locales.Translator { + return &ig{ + locale: "ig", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: "٫", + group: "٬", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "₦", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "Jen", "Feb", "Maa", "Epr", "Mee", "Juu", "Jul", "Ọgọ", "Sep", "Ọkt", "Nov", "Dis"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Jenụwarị", "Febrụwarị", "Maachị", "Eprel", "Mee", "Juun", "Julaị", "Ọgọọst", "Septemba", "Ọktoba", "Novemba", "Disemba"}, + daysAbbreviated: []string{"Ụka", "Mọn", "Tiu", "Wen", "Tọọ", "Fraị", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Ụka", "Mọn", "Tiu", "Wen", "Tọọ", "Fraị", "Sat"}, + daysWide: []string{"Mbọsị Ụka", "Mọnde", "Tiuzdee", "Wenezdee", "Tọọzdee", "Fraịdee", "Satọdee"}, + periodsAbbreviated: []string{"A.M.", "P.M."}, + periodsNarrow: []string{"A.M.", "P.M."}, + periodsWide: []string{"A.M.", "P.M."}, + erasAbbreviated: []string{"T.K.", "A.K."}, + erasNarrow: []string{"T.K.", "A.K."}, + erasWide: []string{"Tupu Kristi", "Afọ Kristi"}, + timezones: map[string]string{"JDT": "JDT", "MYT": "MYT", "TMT": "TMT", "MST": "MST", "UYT": "UYT", "CHAST": "CHAST", "IST": "IST", "NZDT": "NZDT", "HNPM": "HNPM", "CDT": "CDT", "TMST": "TMST", "MESZ": "MESZ", "WARST": "WARST", "COST": "COST", "GFT": "GFT", "GYT": "GYT", "SGT": "SGT", "CAT": "CAT", "CLST": "CLST", "AST": "AST", "ADT": "ADT", "ACST": "ACST", "HENOMX": "HENOMX", "HEPM": "HEPM", "AWDT": "AWDT", "PDT": "PDT", "WESZ": "WESZ", "OESZ": "OESZ", "GMT": "GMT", "HKT": "HKT", "∅∅∅": "∅∅∅", "WART": "WART", "AEDT": "AEDT", "SRT": "SRT", "VET": "VET", "EDT": "EDT", "HNOG": "HNOG", "WAST": "WAST", "HNT": "HNT", "WITA": "WITA", "WIB": "WIB", "PST": "PST", "ACWST": "ACWST", "EST": "EST", "HNNOMX": "HNNOMX", "UYST": "UYST", "JST": "JST", "OEZ": "OEZ", "WAT": "WAT", "WEZ": "WEZ", "COT": "COT", "HNEG": "HNEG", "AKDT": "AKDT", "MDT": "MDT", "ECT": "ECT", "ACDT": "ACDT", "LHST": "LHST", "EAT": "EAT", "AWST": "AWST", "HADT": "HADT", "BT": "BT", "HEEG": "HEEG", "AKST": "AKST", "NZST": "NZST", "ARST": "ARST", "HNPMX": "HNPMX", "CST": "CST", "MEZ": "MEZ", "AEST": "AEST", "HEPMX": "HEPMX", "ACWDT": "ACWDT", "HEOG": "HEOG", "ART": "ART", "HKST": "HKST", "SAST": "SAST", "LHDT": "LHDT", "WIT": "WIT", "CHADT": "CHADT", "CLT": "CLT", "HAST": "HAST", "HAT": "HAT", "ChST": "ChST", "HNCU": "HNCU", "HECU": "HECU", "BOT": "BOT"}, + } +} + +// Locale returns the current translators string locale +func (ig *ig) Locale() string { + return ig.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ig' +func (ig *ig) PluralsCardinal() []locales.PluralRule { + return ig.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ig' +func (ig *ig) PluralsOrdinal() []locales.PluralRule { + return ig.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ig' +func (ig *ig) PluralsRange() []locales.PluralRule { + return ig.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ig' +func (ig *ig) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ig' +func (ig *ig) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ig' +func (ig *ig) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ig *ig) MonthAbbreviated(month time.Month) string { + return ig.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ig *ig) MonthsAbbreviated() []string { + return ig.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ig *ig) MonthNarrow(month time.Month) string { + return ig.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ig *ig) MonthsNarrow() []string { + return ig.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ig *ig) MonthWide(month time.Month) string { + return ig.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ig *ig) MonthsWide() []string { + return ig.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ig *ig) WeekdayAbbreviated(weekday time.Weekday) string { + return ig.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ig *ig) WeekdaysAbbreviated() []string { + return ig.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ig *ig) WeekdayNarrow(weekday time.Weekday) string { + return ig.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ig *ig) WeekdaysNarrow() []string { + return ig.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ig *ig) WeekdayShort(weekday time.Weekday) string { + return ig.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ig *ig) WeekdaysShort() []string { + return ig.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ig *ig) WeekdayWide(weekday time.Weekday) string { + return ig.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ig *ig) WeekdaysWide() []string { + return ig.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ig' and handles both Whole and Real numbers based on 'v' +func (ig *ig) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ig.decimal) - 1; j >= 0; j-- { + b = append(b, ig.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ig.group) - 1; j >= 0; j-- { + b = append(b, ig.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ig.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ig' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ig *ig) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ig.decimal) - 1; j >= 0; j-- { + b = append(b, ig.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ig.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ig.percentSuffix...) + + b = append(b, ig.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ig' +func (ig *ig) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ig.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ig.decimal) - 1; j >= 0; j-- { + b = append(b, ig.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ig.group) - 1; j >= 0; j-- { + b = append(b, ig.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ig.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ig.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ig' +// in accounting notation. +func (ig *ig) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ig.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ig.decimal) - 1; j >= 0; j-- { + b = append(b, ig.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ig.group) - 1; j >= 0; j-- { + b = append(b, ig.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ig.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ig.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ig' +func (ig *ig) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ig' +func (ig *ig) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ig.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ig' +func (ig *ig) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ig.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ig' +func (ig *ig) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ig.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ig.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ig' +func (ig *ig) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ig.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ig' +func (ig *ig) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ig.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ig.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ig' +func (ig *ig) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ig.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ig.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ig' +func (ig *ig) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ig.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ig.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ig.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ig/ig_test.go b/vendor/github.com/go-playground/locales/ig/ig_test.go new file mode 100644 index 0000000000..03c0d2ff68 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ig/ig_test.go @@ -0,0 +1,1120 @@ +package ig + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ig" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ig_NG/ig_NG.go b/vendor/github.com/go-playground/locales/ig_NG/ig_NG.go new file mode 100644 index 0000000000..d6b817641a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ig_NG/ig_NG.go @@ -0,0 +1,594 @@ +package ig_NG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ig_NG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ig_NG' locale +func New() locales.Translator { + return &ig_NG{ + locale: "ig_NG", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: "٫", + group: "٬", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "Jen", "Feb", "Maa", "Epr", "Mee", "Juu", "Jul", "Ọgọ", "Sep", "Ọkt", "Nov", "Dis"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Jenụwarị", "Febrụwarị", "Maachị", "Eprel", "Mee", "Juun", "Julaị", "Ọgọọst", "Septemba", "Ọktoba", "Novemba", "Disemba"}, + daysAbbreviated: []string{"Ụka", "Mọn", "Tiu", "Wen", "Tọọ", "Fraị", "Sat"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Ụka", "Mọn", "Tiu", "Wen", "Tọọ", "Fraị", "Sat"}, + daysWide: []string{"Mbọsị Ụka", "Mọnde", "Tiuzdee", "Wenezdee", "Tọọzdee", "Fraịdee", "Satọdee"}, + periodsAbbreviated: []string{"A.M.", "P.M."}, + periodsNarrow: []string{"A.M.", "P.M."}, + periodsWide: []string{"A.M.", "P.M."}, + erasAbbreviated: []string{"T.K.", "A.K."}, + erasNarrow: []string{"T.K.", "A.K."}, + erasWide: []string{"Tupu Kristi", "Afọ Kristi"}, + timezones: map[string]string{"NZST": "NZST", "JDT": "JDT", "CLST": "CLST", "HNNOMX": "HNNOMX", "IST": "IST", "HKT": "HKT", "BOT": "BOT", "ADT": "ADT", "HNT": "HNT", "SGT": "SGT", "TMST": "TMST", "HNPM": "HNPM", "LHST": "LHST", "GYT": "GYT", "HNCU": "HNCU", "∅∅∅": "∅∅∅", "MEZ": "MEZ", "MYT": "MYT", "CDT": "CDT", "HADT": "HADT", "OESZ": "OESZ", "WESZ": "WESZ", "COT": "COT", "EAT": "EAT", "WIB": "WIB", "AWST": "AWST", "CHADT": "CHADT", "PST": "PST", "HAST": "HAST", "MESZ": "MESZ", "WEZ": "WEZ", "MST": "MST", "WAST": "WAST", "ACST": "ACST", "ACDT": "ACDT", "ChST": "ChST", "SAST": "SAST", "WART": "WART", "MDT": "MDT", "EDT": "EDT", "GFT": "GFT", "CST": "CST", "CAT": "CAT", "ARST": "ARST", "HAT": "HAT", "HNEG": "HNEG", "HEEG": "HEEG", "UYT": "UYT", "WAT": "WAT", "SRT": "SRT", "HNPMX": "HNPMX", "WARST": "WARST", "ECT": "ECT", "ACWST": "ACWST", "ACWDT": "ACWDT", "CLT": "CLT", "HNOG": "HNOG", "OEZ": "OEZ", "HKST": "HKST", "COST": "COST", "UYST": "UYST", "WIT": "WIT", "VET": "VET", "JST": "JST", "GMT": "GMT", "HEOG": "HEOG", "AST": "AST", "HENOMX": "HENOMX", "LHDT": "LHDT", "WITA": "WITA", "HEPMX": "HEPMX", "HECU": "HECU", "CHAST": "CHAST", "PDT": "PDT", "AKST": "AKST", "HEPM": "HEPM", "NZDT": "NZDT", "TMT": "TMT", "ART": "ART", "EST": "EST", "BT": "BT", "AEST": "AEST", "AEDT": "AEDT", "AKDT": "AKDT", "AWDT": "AWDT"}, + } +} + +// Locale returns the current translators string locale +func (ig *ig_NG) Locale() string { + return ig.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ig_NG' +func (ig *ig_NG) PluralsCardinal() []locales.PluralRule { + return ig.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ig_NG' +func (ig *ig_NG) PluralsOrdinal() []locales.PluralRule { + return ig.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ig_NG' +func (ig *ig_NG) PluralsRange() []locales.PluralRule { + return ig.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ig_NG' +func (ig *ig_NG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ig_NG' +func (ig *ig_NG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ig_NG' +func (ig *ig_NG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ig *ig_NG) MonthAbbreviated(month time.Month) string { + return ig.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ig *ig_NG) MonthsAbbreviated() []string { + return ig.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ig *ig_NG) MonthNarrow(month time.Month) string { + return ig.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ig *ig_NG) MonthsNarrow() []string { + return ig.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ig *ig_NG) MonthWide(month time.Month) string { + return ig.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ig *ig_NG) MonthsWide() []string { + return ig.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ig *ig_NG) WeekdayAbbreviated(weekday time.Weekday) string { + return ig.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ig *ig_NG) WeekdaysAbbreviated() []string { + return ig.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ig *ig_NG) WeekdayNarrow(weekday time.Weekday) string { + return ig.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ig *ig_NG) WeekdaysNarrow() []string { + return ig.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ig *ig_NG) WeekdayShort(weekday time.Weekday) string { + return ig.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ig *ig_NG) WeekdaysShort() []string { + return ig.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ig *ig_NG) WeekdayWide(weekday time.Weekday) string { + return ig.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ig *ig_NG) WeekdaysWide() []string { + return ig.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ig_NG' and handles both Whole and Real numbers based on 'v' +func (ig *ig_NG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ig.decimal) - 1; j >= 0; j-- { + b = append(b, ig.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ig.group) - 1; j >= 0; j-- { + b = append(b, ig.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ig.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ig_NG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ig *ig_NG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ig.decimal) - 1; j >= 0; j-- { + b = append(b, ig.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ig.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ig.percentSuffix...) + + b = append(b, ig.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ig_NG' +func (ig *ig_NG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ig.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ig.decimal) - 1; j >= 0; j-- { + b = append(b, ig.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ig.group) - 1; j >= 0; j-- { + b = append(b, ig.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ig.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ig.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ig_NG' +// in accounting notation. +func (ig *ig_NG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ig.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ig.decimal) - 1; j >= 0; j-- { + b = append(b, ig.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ig.group) - 1; j >= 0; j-- { + b = append(b, ig.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ig.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ig.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ig_NG' +func (ig *ig_NG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ig_NG' +func (ig *ig_NG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ig.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ig_NG' +func (ig *ig_NG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ig.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ig_NG' +func (ig *ig_NG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ig.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ig.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ig_NG' +func (ig *ig_NG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ig.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ig_NG' +func (ig *ig_NG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ig.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ig.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ig_NG' +func (ig *ig_NG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ig.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ig.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ig_NG' +func (ig *ig_NG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ig.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ig.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ig.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ig_NG/ig_NG_test.go b/vendor/github.com/go-playground/locales/ig_NG/ig_NG_test.go new file mode 100644 index 0000000000..d7d76af8b6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ig_NG/ig_NG_test.go @@ -0,0 +1,1120 @@ +package ig_NG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ig_NG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ii/ii.go b/vendor/github.com/go-playground/locales/ii/ii.go new file mode 100644 index 0000000000..61753daa06 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ii/ii.go @@ -0,0 +1,629 @@ +package ii + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ii struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ii' locale +func New() locales.Translator { + return &ii{ + locale: "ii", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ꋍꆪ", "ꑍꆪ", "ꌕꆪ", "ꇖꆪ", "ꉬꆪ", "ꃘꆪ", "ꏃꆪ", "ꉆꆪ", "ꈬꆪ", "ꊰꆪ", "ꊰꊪꆪ", "ꊰꑋꆪ"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "ꋍꆪ", "ꑍꆪ", "ꌕꆪ", "ꇖꆪ", "ꉬꆪ", "ꃘꆪ", "ꏃꆪ", "ꉆꆪ", "ꈬꆪ", "ꊰꆪ", "ꊰꊪꆪ", "ꊰꑋꆪ"}, + daysAbbreviated: []string{"ꑭꆏ", "ꆏꋍ", "ꆏꑍ", "ꆏꌕ", "ꆏꇖ", "ꆏꉬ", "ꆏꃘ"}, + daysNarrow: []string{"ꆏ", "ꋍ", "ꑍ", "ꌕ", "ꇖ", "ꉬ", "ꃘ"}, + daysWide: []string{"ꑭꆏꑍ", "ꆏꊂꋍ", "ꆏꊂꑍ", "ꆏꊂꌕ", "ꆏꊂꇖ", "ꆏꊂꉬ", "ꆏꊂꃘ"}, + periodsAbbreviated: []string{"ꎸꄑ", "ꁯꋒ"}, + periodsWide: []string{"ꎸꄑ", "ꁯꋒ"}, + erasAbbreviated: []string{"ꃅꋊꂿ", "ꃅꋊꊂ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"BT": "BT", "GFT": "GFT", "SAST": "SAST", "HNCU": "HNCU", "HECU": "HECU", "CHAST": "CHAST", "SGT": "SGT", "PDT": "PDT", "HENOMX": "HENOMX", "TMST": "TMST", "EST": "EST", "HNPM": "HNPM", "LHST": "LHST", "WIB": "WIB", "ACWST": "ACWST", "JST": "JST", "WEZ": "WEZ", "COST": "COST", "HNNOMX": "HNNOMX", "AWST": "AWST", "BOT": "BOT", "ACWDT": "ACWDT", "CLST": "CLST", "WAST": "WAST", "ACST": "ACST", "MEZ": "MEZ", "WARST": "WARST", "WESZ": "WESZ", "MDT": "MDT", "AEDT": "AEDT", "IST": "IST", "GMT": "GMT", "CLT": "CLT", "HKT": "HKT", "HNEG": "HNEG", "UYT": "UYT", "ChST": "ChST", "LHDT": "LHDT", "EAT": "EAT", "MESZ": "MESZ", "WART": "WART", "ADT": "ADT", "ARST": "ARST", "COT": "COT", "CST": "CST", "MYT": "MYT", "OESZ": "OESZ", "WAT": "WAT", "PST": "PST", "NZST": "NZST", "ART": "ART", "AKDT": "AKDT", "HEPMX": "HEPMX", "HNPMX": "HNPMX", "ECT": "ECT", "CAT": "CAT", "MST": "MST", "EDT": "EDT", "WITA": "WITA", "AKST": "AKST", "WIT": "WIT", "ACDT": "ACDT", "HAT": "HAT", "HEEG": "HEEG", "NZDT": "NZDT", "VET": "VET", "HEOG": "HEOG", "OEZ": "OEZ", "SRT": "SRT", "CDT": "CDT", "∅∅∅": "∅∅∅", "AST": "AST", "AEST": "AEST", "UYST": "UYST", "HNOG": "HNOG", "GYT": "GYT", "AWDT": "AWDT", "CHADT": "CHADT", "HAST": "HAST", "HADT": "HADT", "JDT": "JDT", "TMT": "TMT", "HKST": "HKST", "HNT": "HNT", "HEPM": "HEPM"}, + } +} + +// Locale returns the current translators string locale +func (ii *ii) Locale() string { + return ii.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ii' +func (ii *ii) PluralsCardinal() []locales.PluralRule { + return ii.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ii' +func (ii *ii) PluralsOrdinal() []locales.PluralRule { + return ii.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ii' +func (ii *ii) PluralsRange() []locales.PluralRule { + return ii.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ii' +func (ii *ii) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ii' +func (ii *ii) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ii' +func (ii *ii) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ii *ii) MonthAbbreviated(month time.Month) string { + return ii.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ii *ii) MonthsAbbreviated() []string { + return ii.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ii *ii) MonthNarrow(month time.Month) string { + return ii.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ii *ii) MonthsNarrow() []string { + return ii.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ii *ii) MonthWide(month time.Month) string { + return ii.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ii *ii) MonthsWide() []string { + return ii.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ii *ii) WeekdayAbbreviated(weekday time.Weekday) string { + return ii.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ii *ii) WeekdaysAbbreviated() []string { + return ii.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ii *ii) WeekdayNarrow(weekday time.Weekday) string { + return ii.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ii *ii) WeekdaysNarrow() []string { + return ii.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ii *ii) WeekdayShort(weekday time.Weekday) string { + return ii.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ii *ii) WeekdaysShort() []string { + return ii.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ii *ii) WeekdayWide(weekday time.Weekday) string { + return ii.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ii *ii) WeekdaysWide() []string { + return ii.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ii' and handles both Whole and Real numbers based on 'v' +func (ii *ii) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ii.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ii.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ii.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ii' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ii *ii) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ii.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ii.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ii.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ii' +func (ii *ii) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ii.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ii.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ii.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ii.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ii.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ii.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ii.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ii' +// in accounting notation. +func (ii *ii) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ii.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ii.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ii.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ii.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ii.currencyNegativePrefix[j]) + } + + b = append(b, ii.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ii.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ii.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ii.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ii' +func (ii *ii) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ii' +func (ii *ii) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ii.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ii' +func (ii *ii) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ii.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ii' +func (ii *ii) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ii.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ii.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ii' +func (ii *ii) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ii.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ii.periodsAbbreviated[0]...) + } else { + b = append(b, ii.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ii' +func (ii *ii) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ii.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ii.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ii.periodsAbbreviated[0]...) + } else { + b = append(b, ii.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ii' +func (ii *ii) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ii.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ii.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ii.periodsAbbreviated[0]...) + } else { + b = append(b, ii.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ii' +func (ii *ii) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ii.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ii.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ii.periodsAbbreviated[0]...) + } else { + b = append(b, ii.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ii.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ii/ii_test.go b/vendor/github.com/go-playground/locales/ii/ii_test.go new file mode 100644 index 0000000000..28dac3ea06 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ii/ii_test.go @@ -0,0 +1,1120 @@ +package ii + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ii" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ii_CN/ii_CN.go b/vendor/github.com/go-playground/locales/ii_CN/ii_CN.go new file mode 100644 index 0000000000..cfcb283b72 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ii_CN/ii_CN.go @@ -0,0 +1,629 @@ +package ii_CN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ii_CN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ii_CN' locale +func New() locales.Translator { + return &ii_CN{ + locale: "ii_CN", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ꋍꆪ", "ꑍꆪ", "ꌕꆪ", "ꇖꆪ", "ꉬꆪ", "ꃘꆪ", "ꏃꆪ", "ꉆꆪ", "ꈬꆪ", "ꊰꆪ", "ꊰꊪꆪ", "ꊰꑋꆪ"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "ꋍꆪ", "ꑍꆪ", "ꌕꆪ", "ꇖꆪ", "ꉬꆪ", "ꃘꆪ", "ꏃꆪ", "ꉆꆪ", "ꈬꆪ", "ꊰꆪ", "ꊰꊪꆪ", "ꊰꑋꆪ"}, + daysAbbreviated: []string{"ꑭꆏ", "ꆏꋍ", "ꆏꑍ", "ꆏꌕ", "ꆏꇖ", "ꆏꉬ", "ꆏꃘ"}, + daysNarrow: []string{"ꆏ", "ꋍ", "ꑍ", "ꌕ", "ꇖ", "ꉬ", "ꃘ"}, + daysWide: []string{"ꑭꆏꑍ", "ꆏꊂꋍ", "ꆏꊂꑍ", "ꆏꊂꌕ", "ꆏꊂꇖ", "ꆏꊂꉬ", "ꆏꊂꃘ"}, + periodsAbbreviated: []string{"ꎸꄑ", "ꁯꋒ"}, + periodsWide: []string{"ꎸꄑ", "ꁯꋒ"}, + erasAbbreviated: []string{"ꃅꋊꂿ", "ꃅꋊꊂ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"AEST": "AEST", "NZST": "NZST", "ARST": "ARST", "ACST": "ACST", "HEEG": "HEEG", "WITA": "WITA", "WIB": "WIB", "WIT": "WIT", "WESZ": "WESZ", "ART": "ART", "WAT": "WAT", "HENOMX": "HENOMX", "HEPM": "HEPM", "LHST": "LHST", "MDT": "MDT", "BOT": "BOT", "HAST": "HAST", "MST": "MST", "OESZ": "OESZ", "WART": "WART", "SAST": "SAST", "EAT": "EAT", "HADT": "HADT", "CAT": "CAT", "JDT": "JDT", "GFT": "GFT", "AKST": "AKST", "UYST": "UYST", "HNCU": "HNCU", "HECU": "HECU", "HNOG": "HNOG", "AEDT": "AEDT", "UYT": "UYT", "LHDT": "LHDT", "HNPM": "HNPM", "IST": "IST", "ADT": "ADT", "COST": "COST", "SGT": "SGT", "MEZ": "MEZ", "VET": "VET", "CLT": "CLT", "TMST": "TMST", "∅∅∅": "∅∅∅", "CHAST": "CHAST", "PDT": "PDT", "CHADT": "CHADT", "ECT": "ECT", "WEZ": "WEZ", "WAST": "WAST", "AKDT": "AKDT", "HEPMX": "HEPMX", "AWDT": "AWDT", "HEOG": "HEOG", "AST": "AST", "EST": "EST", "EDT": "EDT", "HKT": "HKT", "CST": "CST", "ACWDT": "ACWDT", "JST": "JST", "NZDT": "NZDT", "MYT": "MYT", "WARST": "WARST", "ChST": "ChST", "HNPMX": "HNPMX", "ACWST": "ACWST", "SRT": "SRT", "GMT": "GMT", "BT": "BT", "HAT": "HAT", "HNEG": "HNEG", "CDT": "CDT", "MESZ": "MESZ", "ACDT": "ACDT", "COT": "COT", "HNNOMX": "HNNOMX", "TMT": "TMT", "GYT": "GYT", "AWST": "AWST", "OEZ": "OEZ", "HKST": "HKST", "HNT": "HNT", "PST": "PST", "CLST": "CLST"}, + } +} + +// Locale returns the current translators string locale +func (ii *ii_CN) Locale() string { + return ii.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ii_CN' +func (ii *ii_CN) PluralsCardinal() []locales.PluralRule { + return ii.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ii_CN' +func (ii *ii_CN) PluralsOrdinal() []locales.PluralRule { + return ii.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ii_CN' +func (ii *ii_CN) PluralsRange() []locales.PluralRule { + return ii.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ii_CN' +func (ii *ii_CN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ii_CN' +func (ii *ii_CN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ii_CN' +func (ii *ii_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ii *ii_CN) MonthAbbreviated(month time.Month) string { + return ii.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ii *ii_CN) MonthsAbbreviated() []string { + return ii.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ii *ii_CN) MonthNarrow(month time.Month) string { + return ii.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ii *ii_CN) MonthsNarrow() []string { + return ii.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ii *ii_CN) MonthWide(month time.Month) string { + return ii.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ii *ii_CN) MonthsWide() []string { + return ii.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ii *ii_CN) WeekdayAbbreviated(weekday time.Weekday) string { + return ii.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ii *ii_CN) WeekdaysAbbreviated() []string { + return ii.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ii *ii_CN) WeekdayNarrow(weekday time.Weekday) string { + return ii.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ii *ii_CN) WeekdaysNarrow() []string { + return ii.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ii *ii_CN) WeekdayShort(weekday time.Weekday) string { + return ii.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ii *ii_CN) WeekdaysShort() []string { + return ii.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ii *ii_CN) WeekdayWide(weekday time.Weekday) string { + return ii.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ii *ii_CN) WeekdaysWide() []string { + return ii.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ii_CN' and handles both Whole and Real numbers based on 'v' +func (ii *ii_CN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ii.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ii.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ii.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ii_CN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ii *ii_CN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ii.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ii.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ii.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ii_CN' +func (ii *ii_CN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ii.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ii.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ii.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ii.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ii.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ii.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ii.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ii_CN' +// in accounting notation. +func (ii *ii_CN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ii.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ii.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ii.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ii.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ii.currencyNegativePrefix[j]) + } + + b = append(b, ii.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ii.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ii.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ii.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ii_CN' +func (ii *ii_CN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ii_CN' +func (ii *ii_CN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ii.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ii_CN' +func (ii *ii_CN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ii.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ii_CN' +func (ii *ii_CN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ii.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ii.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ii_CN' +func (ii *ii_CN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ii.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ii.periodsAbbreviated[0]...) + } else { + b = append(b, ii.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ii_CN' +func (ii *ii_CN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ii.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ii.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ii.periodsAbbreviated[0]...) + } else { + b = append(b, ii.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ii_CN' +func (ii *ii_CN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ii.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ii.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ii.periodsAbbreviated[0]...) + } else { + b = append(b, ii.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ii_CN' +func (ii *ii_CN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ii.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ii.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ii.periodsAbbreviated[0]...) + } else { + b = append(b, ii.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ii.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ii_CN/ii_CN_test.go b/vendor/github.com/go-playground/locales/ii_CN/ii_CN_test.go new file mode 100644 index 0000000000..5abe8bf52e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ii_CN/ii_CN_test.go @@ -0,0 +1,1120 @@ +package ii_CN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ii_CN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/is/is.go b/vendor/github.com/go-playground/locales/is/is.go new file mode 100644 index 0000000000..9aa62540a6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/is/is.go @@ -0,0 +1,595 @@ +package is + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type is struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'is' locale +func New() locales.Translator { + return &is{ + locale: "is", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maí", "jún.", "júl.", "ágú.", "sep.", "okt.", "nóv.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "Á", "S", "O", "N", "D"}, + monthsWide: []string{"", "janúar", "febrúar", "mars", "apríl", "maí", "júní", "júlí", "ágúst", "september", "október", "nóvember", "desember"}, + daysAbbreviated: []string{"sun.", "mán.", "þri.", "mið.", "fim.", "fös.", "lau."}, + daysNarrow: []string{"S", "M", "Þ", "M", "F", "F", "L"}, + daysShort: []string{"su.", "má.", "þr.", "mi.", "fi.", "fö.", "la."}, + daysWide: []string{"sunnudagur", "mánudagur", "þriðjudagur", "miðvikudagur", "fimmtudagur", "föstudagur", "laugardagur"}, + periodsAbbreviated: []string{"f.h.", "e.h."}, + periodsNarrow: []string{"f.", "e."}, + periodsWide: []string{"f.h.", "e.h."}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.k.", "e.k."}, + erasWide: []string{"fyrir Krist", "eftir Krist"}, + timezones: map[string]string{"HADT": "Sumartími á Havaí og Aleúta", "AST": "Staðaltími á Atlantshafssvæðinu", "ADT": "Sumartími á Atlantshafssvæðinu", "COST": "Sumartími í Kólumbíu", "WITA": "Mið-Indónesíutími", "AKST": "Staðaltími í Alaska", "HNCU": "Staðaltími á Kúbu", "HECU": "Sumartími á Kúbu", "CLST": "Sumartími í Síle", "HKST": "Sumartími í Hong Kong", "AEDT": "Sumartími í Austur-Ástralíu", "CLT": "Staðaltími í Síle", "HNNOMX": "Staðaltími í Norðvestur-Mexíkó", "UYT": "Staðaltími í Úrúgvæ", "BOT": "Bólivíutími", "NZDT": "Sumartími á Nýja-Sjálandi", "MEZ": "Staðaltími í Mið-Evrópu", "GMT": "Greenwich-staðaltími", "ART": "Staðaltími í Argentínu", "WAST": "Sumartími í Vestur-Afríku", "ACDT": "Sumartími í Mið-Ástralíu", "HEEG": "Sumartími á Austur-Grænlandi", "HAST": "Staðaltími á Havaí og Aleúta", "∅∅∅": "Sumartími á Amasónsvæðinu", "ACWST": "Staðaltími í miðvesturhluta Ástralíu", "WART": "Staðaltími í Vestur-Argentínu", "CDT": "Sumartími í miðhluta Bandaríkjanna og Kanada", "IST": "Indlandstími", "JST": "Staðaltími í Japan", "OEZ": "Staðaltími í Austur-Evrópu", "ARST": "Sumartími í Argentínu", "BT": "Bútantími", "GFT": "Tími í Frönsku Gvæjana", "AKDT": "Sumartími í Alaska", "ChST": "Chamorro-staðaltími", "WIT": "Austur-Indónesíutími", "ECT": "Ekvadortími", "PDT": "Sumartími á Kyrrahafssvæðinu", "MYT": "Malasíutími", "HNOG": "Staðaltími á Vestur-Grænlandi", "EST": "Staðaltími í austurhluta Bandaríkjanna og Kanada", "ACST": "Staðaltími í Mið-Ástralíu", "UYST": "Sumartími í Úrúgvæ", "AWDT": "Sumartími í Vestur-Ástralíu", "VET": "Venesúelatími", "SGT": "Singapúrtími", "MDT": "MDT", "COT": "Staðaltími í Kólumbíu", "HNEG": "Staðaltími á Austur-Grænlandi", "AEST": "Staðaltími í Austur-Ástralíu", "HEPMX": "Sumartími í Mexíkó á Kyrrahafssvæðinu", "EAT": "Austur-Afríkutími", "MESZ": "Sumartími í Mið-Evrópu", "WARST": "Sumartími í Vestur-Argentínu", "MST": "MST", "HAT": "Sumartími á Nýfundnalandi", "LHST": "Staðaltími á Lord Howe-eyju", "LHDT": "Sumartími á Lord Howe-eyju", "CST": "Staðaltími í miðhluta Bandaríkjanna og Kanada", "CHADT": "Sumartími í Chatham", "OESZ": "Sumartími í Austur-Evrópu", "WEZ": "Staðaltími í Vestur-Evrópu", "WAT": "Staðaltími í Vestur-Afríku", "HNT": "Staðaltími á Nýfundnalandi", "SAST": "Suður-Afríkutími", "PST": "Staðaltími á Kyrrahafssvæðinu", "WESZ": "Sumartími í Vestur-Evrópu", "EDT": "Sumartími í austurhluta Bandaríkjanna og Kanada", "GYT": "Gvæjanatími", "HEOG": "Sumartími á Vestur-Grænlandi", "TMST": "Sumartími í Túrkmenistan", "HENOMX": "Sumartími í Norðvestur-Mexíkó", "SRT": "Súrinamtími", "AWST": "Staðaltími í Vestur-Ástralíu", "ACWDT": "Sumartími í miðvesturhluta Ástralíu", "TMT": "Staðaltími í Túrkmenistan", "HKT": "Staðaltími í Hong Kong", "HNPM": "Staðaltími á Sankti Pierre og Miquelon", "NZST": "Staðaltími á Nýja-Sjálandi", "CAT": "Mið-Afríkutími", "JDT": "Sumartími í Japan", "HEPM": "Sumartími á Sankti Pierre og Miquelon", "HNPMX": "Staðaltími í Mexíkó á Kyrrahafssvæðinu", "WIB": "Vestur-Indónesíutími", "CHAST": "Staðaltími í Chatham"}, + } +} + +// Locale returns the current translators string locale +func (is *is) Locale() string { + return is.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'is' +func (is *is) PluralsCardinal() []locales.PluralRule { + return is.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'is' +func (is *is) PluralsOrdinal() []locales.PluralRule { + return is.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'is' +func (is *is) PluralsRange() []locales.PluralRule { + return is.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'is' +func (is *is) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + + if (t == 0 && iMod10 == 1 && iMod100 != 11) || (t != 0) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'is' +func (is *is) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'is' +func (is *is) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := is.CardinalPluralRule(num1, v1) + end := is.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (is *is) MonthAbbreviated(month time.Month) string { + return is.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (is *is) MonthsAbbreviated() []string { + return is.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (is *is) MonthNarrow(month time.Month) string { + return is.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (is *is) MonthsNarrow() []string { + return is.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (is *is) MonthWide(month time.Month) string { + return is.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (is *is) MonthsWide() []string { + return is.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (is *is) WeekdayAbbreviated(weekday time.Weekday) string { + return is.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (is *is) WeekdaysAbbreviated() []string { + return is.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (is *is) WeekdayNarrow(weekday time.Weekday) string { + return is.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (is *is) WeekdaysNarrow() []string { + return is.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (is *is) WeekdayShort(weekday time.Weekday) string { + return is.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (is *is) WeekdaysShort() []string { + return is.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (is *is) WeekdayWide(weekday time.Weekday) string { + return is.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (is *is) WeekdaysWide() []string { + return is.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'is' and handles both Whole and Real numbers based on 'v' +func (is *is) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, is.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, is.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, is.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'is' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (is *is) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, is.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, is.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, is.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'is' +func (is *is) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := is.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, is.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, is.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, is.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, is.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, is.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'is' +// in accounting notation. +func (is *is) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := is.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, is.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, is.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, is.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, is.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, is.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, is.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'is' +func (is *is) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'is' +func (is *is) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, is.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'is' +func (is *is) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, is.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'is' +func (is *is) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, is.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, is.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'is' +func (is *is) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, is.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'is' +func (is *is) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, is.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, is.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'is' +func (is *is) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, is.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, is.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'is' +func (is *is) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, is.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, is.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := is.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/is/is_test.go b/vendor/github.com/go-playground/locales/is/is_test.go new file mode 100644 index 0000000000..048b27e234 --- /dev/null +++ b/vendor/github.com/go-playground/locales/is/is_test.go @@ -0,0 +1,1120 @@ +package is + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "is" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/is_IS/is_IS.go b/vendor/github.com/go-playground/locales/is_IS/is_IS.go new file mode 100644 index 0000000000..0dd2351747 --- /dev/null +++ b/vendor/github.com/go-playground/locales/is_IS/is_IS.go @@ -0,0 +1,595 @@ +package is_IS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type is_IS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'is_IS' locale +func New() locales.Translator { + return &is_IS{ + locale: "is_IS", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maí", "jún.", "júl.", "ágú.", "sep.", "okt.", "nóv.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "Á", "S", "O", "N", "D"}, + monthsWide: []string{"", "janúar", "febrúar", "mars", "apríl", "maí", "júní", "júlí", "ágúst", "september", "október", "nóvember", "desember"}, + daysAbbreviated: []string{"sun.", "mán.", "þri.", "mið.", "fim.", "fös.", "lau."}, + daysNarrow: []string{"S", "M", "Þ", "M", "F", "F", "L"}, + daysShort: []string{"su.", "má.", "þr.", "mi.", "fi.", "fö.", "la."}, + daysWide: []string{"sunnudagur", "mánudagur", "þriðjudagur", "miðvikudagur", "fimmtudagur", "föstudagur", "laugardagur"}, + periodsAbbreviated: []string{"f.h.", "e.h."}, + periodsNarrow: []string{"f.", "e."}, + periodsWide: []string{"f.h.", "e.h."}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.k.", "e.k."}, + erasWide: []string{"fyrir Krist", "eftir Krist"}, + timezones: map[string]string{"ART": "Staðaltími í Argentínu", "ARST": "Sumartími í Argentínu", "BT": "Bútantími", "ACWST": "Staðaltími í miðvesturhluta Ástralíu", "MEZ": "Staðaltími í Mið-Evrópu", "ACST": "Staðaltími í Mið-Ástralíu", "UYST": "Sumartími í Úrúgvæ", "HEPMX": "Sumartími í Mexíkó á Kyrrahafssvæðinu", "OEZ": "Staðaltími í Austur-Evrópu", "EST": "Staðaltími í austurhluta Bandaríkjanna og Kanada", "HNEG": "Staðaltími á Austur-Grænlandi", "WIT": "Austur-Indónesíutími", "CHAST": "Staðaltími í Chatham", "WAST": "Sumartími í Vestur-Afríku", "ChST": "Chamorro-staðaltími", "∅∅∅": "Sumartími í Brasilíu", "WEZ": "Staðaltími í Vestur-Evrópu", "TMT": "Staðaltími í Túrkmenistan", "HEPM": "Sumartími á Sankti Pierre og Miquelon", "SRT": "Súrinamtími", "CST": "Staðaltími í miðhluta Bandaríkjanna og Kanada", "SGT": "Singapúrtími", "NZDT": "Sumartími á Nýja-Sjálandi", "HNOG": "Staðaltími á Vestur-Grænlandi", "PDT": "Sumartími á Kyrrahafssvæðinu", "ECT": "Ekvadortími", "VET": "Venesúelatími", "HEEG": "Sumartími á Austur-Grænlandi", "AKDT": "Sumartími í Alaska", "SAST": "Suður-Afríkutími", "BOT": "Bólivíutími", "HAST": "Staðaltími á Havaí og Aleúta", "HNT": "Staðaltími á Nýfundnalandi", "LHST": "Staðaltími á Lord Howe-eyju", "AWDT": "Sumartími í Vestur-Ástralíu", "PST": "Staðaltími á Kyrrahafssvæðinu", "WESZ": "Sumartími í Vestur-Evrópu", "HAT": "Sumartími á Nýfundnalandi", "AEST": "Staðaltími í Austur-Ástralíu", "COST": "Sumartími í Kólumbíu", "HNNOMX": "Staðaltími í Norðvestur-Mexíkó", "HECU": "Sumartími á Kúbu", "AWST": "Staðaltími í Vestur-Ástralíu", "CAT": "Mið-Afríkutími", "MESZ": "Sumartími í Mið-Evrópu", "MDT": "MDT", "HKT": "Staðaltími í Hong Kong", "HENOMX": "Sumartími í Norðvestur-Mexíkó", "CDT": "Sumartími í miðhluta Bandaríkjanna og Kanada", "HEOG": "Sumartími á Vestur-Grænlandi", "ADT": "Sumartími á Atlantshafssvæðinu", "GFT": "Tími í Frönsku Gvæjana", "HNPM": "Staðaltími á Sankti Pierre og Miquelon", "WAT": "Staðaltími í Vestur-Afríku", "AKST": "Staðaltími í Alaska", "CHADT": "Sumartími í Chatham", "JST": "Staðaltími í Japan", "OESZ": "Sumartími í Austur-Evrópu", "WARST": "Sumartími í Vestur-Argentínu", "CLT": "Staðaltími í Síle", "TMST": "Sumartími í Túrkmenistan", "UYT": "Staðaltími í Úrúgvæ", "LHDT": "Sumartími á Lord Howe-eyju", "EAT": "Austur-Afríkutími", "HADT": "Sumartími á Havaí og Aleúta", "WART": "Staðaltími í Vestur-Argentínu", "WITA": "Mið-Indónesíutími", "AEDT": "Sumartími í Austur-Ástralíu", "GYT": "Gvæjanatími", "WIB": "Vestur-Indónesíutími", "NZST": "Staðaltími á Nýja-Sjálandi", "CLST": "Sumartími í Síle", "EDT": "Sumartími í austurhluta Bandaríkjanna og Kanada", "HNCU": "Staðaltími á Kúbu", "MST": "MST", "HKST": "Sumartími í Hong Kong", "IST": "Indlandstími", "ACWDT": "Sumartími í miðvesturhluta Ástralíu", "JDT": "Sumartími í Japan", "AST": "Staðaltími á Atlantshafssvæðinu", "GMT": "Greenwich-staðaltími", "MYT": "Malasíutími", "ACDT": "Sumartími í Mið-Ástralíu", "COT": "Staðaltími í Kólumbíu", "HNPMX": "Staðaltími í Mexíkó á Kyrrahafssvæðinu"}, + } +} + +// Locale returns the current translators string locale +func (is *is_IS) Locale() string { + return is.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'is_IS' +func (is *is_IS) PluralsCardinal() []locales.PluralRule { + return is.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'is_IS' +func (is *is_IS) PluralsOrdinal() []locales.PluralRule { + return is.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'is_IS' +func (is *is_IS) PluralsRange() []locales.PluralRule { + return is.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'is_IS' +func (is *is_IS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + t := locales.T(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + + if (t == 0 && iMod10 == 1 && iMod100 != 11) || (t != 0) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'is_IS' +func (is *is_IS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'is_IS' +func (is *is_IS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := is.CardinalPluralRule(num1, v1) + end := is.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (is *is_IS) MonthAbbreviated(month time.Month) string { + return is.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (is *is_IS) MonthsAbbreviated() []string { + return is.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (is *is_IS) MonthNarrow(month time.Month) string { + return is.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (is *is_IS) MonthsNarrow() []string { + return is.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (is *is_IS) MonthWide(month time.Month) string { + return is.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (is *is_IS) MonthsWide() []string { + return is.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (is *is_IS) WeekdayAbbreviated(weekday time.Weekday) string { + return is.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (is *is_IS) WeekdaysAbbreviated() []string { + return is.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (is *is_IS) WeekdayNarrow(weekday time.Weekday) string { + return is.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (is *is_IS) WeekdaysNarrow() []string { + return is.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (is *is_IS) WeekdayShort(weekday time.Weekday) string { + return is.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (is *is_IS) WeekdaysShort() []string { + return is.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (is *is_IS) WeekdayWide(weekday time.Weekday) string { + return is.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (is *is_IS) WeekdaysWide() []string { + return is.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'is_IS' and handles both Whole and Real numbers based on 'v' +func (is *is_IS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, is.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, is.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, is.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'is_IS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (is *is_IS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, is.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, is.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, is.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'is_IS' +func (is *is_IS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := is.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, is.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, is.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, is.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, is.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, is.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'is_IS' +// in accounting notation. +func (is *is_IS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := is.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, is.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, is.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, is.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, is.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, is.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, is.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'is_IS' +func (is *is_IS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'is_IS' +func (is *is_IS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, is.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'is_IS' +func (is *is_IS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, is.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'is_IS' +func (is *is_IS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, is.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, is.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'is_IS' +func (is *is_IS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, is.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'is_IS' +func (is *is_IS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, is.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, is.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'is_IS' +func (is *is_IS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, is.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, is.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'is_IS' +func (is *is_IS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, is.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, is.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := is.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/is_IS/is_IS_test.go b/vendor/github.com/go-playground/locales/is_IS/is_IS_test.go new file mode 100644 index 0000000000..31ab0c2725 --- /dev/null +++ b/vendor/github.com/go-playground/locales/is_IS/is_IS_test.go @@ -0,0 +1,1120 @@ +package is_IS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "is_IS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/it/it.go b/vendor/github.com/go-playground/locales/it/it.go new file mode 100644 index 0000000000..97138323c3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/it/it.go @@ -0,0 +1,611 @@ +package it + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type it struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'it' locale +func New() locales.Translator { + return &it{ + locale: "it", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic"}, + monthsNarrow: []string{"", "G", "F", "M", "A", "M", "G", "L", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"}, + daysAbbreviated: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"}, + daysNarrow: []string{"D", "L", "M", "M", "G", "V", "S"}, + daysShort: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"}, + daysWide: []string{"domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"m.", "p."}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"avanti Cristo", "dopo Cristo"}, + timezones: map[string]string{"AWDT": "Ora legale dell’Australia occidentale", "NZST": "Ora standard della Nuova Zelanda", "COST": "Ora legale della Colombia", "ChST": "Ora di Chamorro", "CAT": "Ora dell’Africa centrale", "WESZ": "Ora legale dell’Europa occidentale", "TMT": "Ora standard del Turkmenistan", "WAT": "Ora standard dell’Africa occidentale", "HNT": "Ora standard di Terranova", "HAT": "Ora legale di Terranova", "HNPM": "Ora standard di Saint-Pierre e Miquelon", "HNCU": "Ora standard di Cuba", "OEZ": "Ora standard dell’Europa orientale", "CLST": "Ora legale del Cile", "ARST": "Ora legale dell’Argentina", "AKST": "Ora standard dell’Alaska", "CDT": "Ora legale centrale USA", "BOT": "Ora della Bolivia", "ACWDT": "Ora legale dell’Australia centroccidentale", "JST": "Ora standard del Giappone", "WARST": "Ora legale dell’Argentina occidentale", "MDT": "MDT", "ART": "Ora standard dell’Argentina", "EST": "Ora standard orientale USA", "WIT": "Ora dell’Indonesia orientale", "CHAST": "Ora standard delle Chatham", "HAST": "Ora standard delle Isole Hawaii-Aleutine", "GMT": "Ora del meridiano di Greenwich", "BT": "Ora del Bhutan", "HNEG": "Ora standard della Groenlandia orientale", "GFT": "Ora della Guiana francese", "UYT": "Ora standard dell’Uruguay", "GYT": "Ora della Guyana", "SGT": "Ora di Singapore", "PST": "Ora standard del Pacifico USA", "ECT": "Ora dell’Ecuador", "ACWST": "Ora standard dell’Australia centroccidentale", "MST": "MST", "HENOMX": "Ora legale del Messico nord-occidentale", "∅∅∅": "Ora legale di Brasilia", "JDT": "Ora legale del Giappone", "AST": "Ora standard dell’Atlantico", "AEST": "Ora standard dell’Australia orientale", "SAST": "Ora dell’Africa meridionale", "WEZ": "Ora standard dell’Europa occidentale", "ACST": "Ora standard dell’Australia centrale", "HNNOMX": "Ora standard del Messico nord-occidentale", "HECU": "Ora legale di Cuba", "AWST": "Ora standard dell’Australia occidentale", "HADT": "Ora legale delle Isole Hawaii-Aleutine", "OESZ": "Ora legale dell’Europa orientale", "HNOG": "Ora standard della Groenlandia occidentale", "SRT": "Ora del Suriname", "NZDT": "Ora legale della Nuova Zelanda", "HEOG": "Ora legale della Groenlandia occidentale", "HEEG": "Ora legale della Groenlandia orientale", "AEDT": "Ora legale dell’Australia orientale", "LHDT": "Ora legale di Lord Howe", "EAT": "Ora dell’Africa orientale", "MEZ": "Ora standard dell’Europa centrale", "VET": "Ora del Venezuela", "LHST": "Ora standard di Lord Howe", "HNPMX": "Ora standard del Pacifico (Messico)", "IST": "Ora standard dell’India", "MESZ": "Ora legale dell’Europa centrale", "WART": "Ora standard dell’Argentina occidentale", "EDT": "Ora legale orientale USA", "AKDT": "Ora legale dell’Alaska", "MYT": "Ora della Malesia", "TMST": "Ora legale del Turkmenistan", "WAST": "Ora legale dell’Africa occidentale", "HKST": "Ora legale di Hong Kong", "ACDT": "Ora legale dell’Australia centrale", "COT": "Ora standard della Colombia", "WITA": "Ora dell’Indonesia centrale", "HEPM": "Ora legale di Saint-Pierre e Miquelon", "HEPMX": "Ora legale del Pacifico (Messico)", "UYST": "Ora legale dell’Uruguay", "WIB": "Ora dell’Indonesia occidentale", "CST": "Ora standard centrale USA", "CHADT": "Ora legale delle Chatham", "PDT": "Ora legale del Pacifico USA", "ADT": "Ora legale dell’Atlantico", "CLT": "Ora standard del Cile", "HKT": "Ora standard di Hong Kong"}, + } +} + +// Locale returns the current translators string locale +func (it *it) Locale() string { + return it.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'it' +func (it *it) PluralsCardinal() []locales.PluralRule { + return it.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'it' +func (it *it) PluralsOrdinal() []locales.PluralRule { + return it.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'it' +func (it *it) PluralsRange() []locales.PluralRule { + return it.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'it' +func (it *it) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'it' +func (it *it) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 11 || n == 8 || n == 80 || n == 800 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'it' +func (it *it) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := it.CardinalPluralRule(num1, v1) + end := it.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (it *it) MonthAbbreviated(month time.Month) string { + return it.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (it *it) MonthsAbbreviated() []string { + return it.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (it *it) MonthNarrow(month time.Month) string { + return it.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (it *it) MonthsNarrow() []string { + return it.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (it *it) MonthWide(month time.Month) string { + return it.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (it *it) MonthsWide() []string { + return it.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (it *it) WeekdayAbbreviated(weekday time.Weekday) string { + return it.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (it *it) WeekdaysAbbreviated() []string { + return it.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (it *it) WeekdayNarrow(weekday time.Weekday) string { + return it.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (it *it) WeekdaysNarrow() []string { + return it.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (it *it) WeekdayShort(weekday time.Weekday) string { + return it.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (it *it) WeekdaysShort() []string { + return it.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (it *it) WeekdayWide(weekday time.Weekday) string { + return it.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (it *it) WeekdaysWide() []string { + return it.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'it' and handles both Whole and Real numbers based on 'v' +func (it *it) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'it' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (it *it) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, it.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'it' +func (it *it) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := it.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, it.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, it.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'it' +// in accounting notation. +func (it *it) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := it.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, it.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, it.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, it.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, it.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'it' +func (it *it) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'it' +func (it *it) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'it' +func (it *it) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'it' +func (it *it) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, it.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'it' +func (it *it) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'it' +func (it *it) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'it' +func (it *it) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'it' +func (it *it) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := it.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/it/it_test.go b/vendor/github.com/go-playground/locales/it/it_test.go new file mode 100644 index 0000000000..daefa9aa79 --- /dev/null +++ b/vendor/github.com/go-playground/locales/it/it_test.go @@ -0,0 +1,1120 @@ +package it + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "it" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/it_CH/it_CH.go b/vendor/github.com/go-playground/locales/it_CH/it_CH.go new file mode 100644 index 0000000000..d73b60659c --- /dev/null +++ b/vendor/github.com/go-playground/locales/it_CH/it_CH.go @@ -0,0 +1,620 @@ +package it_CH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type it_CH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'it_CH' locale +func New() locales.Translator { + return &it_CH{ + locale: "it_CH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: "'", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic"}, + monthsNarrow: []string{"", "G", "F", "M", "A", "M", "G", "L", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"}, + daysAbbreviated: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"}, + daysNarrow: []string{"D", "L", "M", "M", "G", "V", "S"}, + daysShort: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"}, + daysWide: []string{"domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"m.", "p."}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"avanti Cristo", "dopo Cristo"}, + timezones: map[string]string{"ACDT": "Ora legale dell’Australia centrale", "ChST": "Ora di Chamorro", "MEZ": "Ora standard dell’Europa centrale", "ART": "Ora standard dell’Argentina", "HNT": "Ora standard di Terranova", "CST": "Ora standard centrale USA", "ADT": "Ora legale dell’Atlantico", "WAST": "Ora legale dell’Africa occidentale", "PST": "Ora standard del Pacifico USA", "ACWDT": "Ora legale dell’Australia centroccidentale", "JDT": "Ora legale del Giappone", "CLST": "Ora legale del Cile", "AKDT": "Ora legale dell’Alaska", "SRT": "Ora del Suriname", "MYT": "Ora della Malesia", "MST": "MST", "NZST": "Ora standard della Nuova Zelanda", "VET": "Ora del Venezuela", "GMT": "Ora del meridiano di Greenwich", "HKST": "Ora legale di Hong Kong", "AEST": "Ora standard dell’Australia orientale", "HEPM": "Ora legale di Saint-Pierre e Miquelon", "HECU": "Ora legale di Cuba", "NZDT": "Ora legale della Nuova Zelanda", "WEZ": "Ora standard dell’Europa occidentale", "EST": "Ora standard orientale USA", "AWST": "Ora standard dell’Australia occidentale", "ECT": "Ora dell’Ecuador", "PDT": "Ora legale del Pacifico USA", "ACWST": "Ora standard dell’Australia centroccidentale", "WARST": "Ora legale dell’Argentina occidentale", "MDT": "MDT", "ARST": "Ora legale dell’Argentina", "BT": "Ora del Bhutan", "HAT": "Ora legale di Terranova", "HNPM": "Ora standard di Saint-Pierre e Miquelon", "CHAST": "Ora standard delle Chatham", "JST": "Ora standard del Giappone", "WAT": "Ora standard dell’Africa occidentale", "ACST": "Ora standard dell’Australia centrale", "AKST": "Ora standard dell’Alaska", "WIB": "Ora dell’Indonesia occidentale", "CDT": "Ora legale centrale USA", "HADT": "Ora legale delle Isole Hawaii-Aleutine", "CAT": "Ora dell’Africa centrale", "WART": "Ora standard dell’Argentina occidentale", "BOT": "Ora della Bolivia", "HKT": "Ora standard di Hong Kong", "COT": "Ora standard della Colombia", "SAST": "Ora dell’Africa meridionale", "HNPMX": "Ora standard del Pacifico (Messico)", "GYT": "Ora della Guyana", "EAT": "Ora dell’Africa orientale", "CHADT": "Ora legale delle Chatham", "HNOG": "Ora standard della Groenlandia occidentale", "HENOMX": "Ora legale del Messico nord-occidentale", "CLT": "Ora standard del Cile", "HAST": "Ora standard delle Isole Hawaii-Aleutine", "MESZ": "Ora legale dell’Europa centrale", "WESZ": "Ora legale dell’Europa occidentale", "EDT": "Ora legale orientale USA", "LHDT": "Ora legale di Lord Howe", "IST": "Ora standard dell’India", "AST": "Ora standard dell’Atlantico", "TMT": "Ora standard del Turkmenistan", "TMST": "Ora legale del Turkmenistan", "COST": "Ora legale della Colombia", "∅∅∅": "∅∅∅", "WITA": "Ora dell’Indonesia centrale", "HEPMX": "Ora legale del Pacifico (Messico)", "HNCU": "Ora standard di Cuba", "SGT": "Ora di Singapore", "HNEG": "Ora standard della Groenlandia orientale", "HEEG": "Ora legale della Groenlandia orientale", "GFT": "Ora della Guiana francese", "UYT": "Ora standard dell’Uruguay", "WIT": "Ora dell’Indonesia orientale", "OESZ": "Ora legale dell’Europa orientale", "HNNOMX": "Ora standard del Messico nord-occidentale", "AEDT": "Ora legale dell’Australia orientale", "UYST": "Ora legale dell’Uruguay", "LHST": "Ora standard di Lord Howe", "AWDT": "Ora legale dell’Australia occidentale", "HEOG": "Ora legale della Groenlandia occidentale", "OEZ": "Ora standard dell’Europa orientale"}, + } +} + +// Locale returns the current translators string locale +func (it *it_CH) Locale() string { + return it.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'it_CH' +func (it *it_CH) PluralsCardinal() []locales.PluralRule { + return it.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'it_CH' +func (it *it_CH) PluralsOrdinal() []locales.PluralRule { + return it.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'it_CH' +func (it *it_CH) PluralsRange() []locales.PluralRule { + return it.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'it_CH' +func (it *it_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'it_CH' +func (it *it_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 11 || n == 8 || n == 80 || n == 800 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'it_CH' +func (it *it_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := it.CardinalPluralRule(num1, v1) + end := it.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (it *it_CH) MonthAbbreviated(month time.Month) string { + return it.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (it *it_CH) MonthsAbbreviated() []string { + return it.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (it *it_CH) MonthNarrow(month time.Month) string { + return it.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (it *it_CH) MonthsNarrow() []string { + return it.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (it *it_CH) MonthWide(month time.Month) string { + return it.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (it *it_CH) MonthsWide() []string { + return it.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (it *it_CH) WeekdayAbbreviated(weekday time.Weekday) string { + return it.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (it *it_CH) WeekdaysAbbreviated() []string { + return it.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (it *it_CH) WeekdayNarrow(weekday time.Weekday) string { + return it.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (it *it_CH) WeekdaysNarrow() []string { + return it.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (it *it_CH) WeekdayShort(weekday time.Weekday) string { + return it.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (it *it_CH) WeekdaysShort() []string { + return it.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (it *it_CH) WeekdayWide(weekday time.Weekday) string { + return it.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (it *it_CH) WeekdaysWide() []string { + return it.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'it_CH' and handles both Whole and Real numbers based on 'v' +func (it *it_CH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'it_CH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (it *it_CH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, it.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'it_CH' +func (it *it_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := it.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(it.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, it.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, it.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'it_CH' +// in accounting notation. +func (it *it_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := it.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(it.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, it.currencyNegativePrefix[j]) + } + + b = append(b, it.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(it.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, it.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, it.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'it_CH' +func (it *it_CH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'it_CH' +func (it *it_CH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'it_CH' +func (it *it_CH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'it_CH' +func (it *it_CH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, it.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'it_CH' +func (it *it_CH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'it_CH' +func (it *it_CH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'it_CH' +func (it *it_CH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'it_CH' +func (it *it_CH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := it.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/it_CH/it_CH_test.go b/vendor/github.com/go-playground/locales/it_CH/it_CH_test.go new file mode 100644 index 0000000000..2de43dc534 --- /dev/null +++ b/vendor/github.com/go-playground/locales/it_CH/it_CH_test.go @@ -0,0 +1,1120 @@ +package it_CH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "it_CH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/it_IT/it_IT.go b/vendor/github.com/go-playground/locales/it_IT/it_IT.go new file mode 100644 index 0000000000..d45ac71b21 --- /dev/null +++ b/vendor/github.com/go-playground/locales/it_IT/it_IT.go @@ -0,0 +1,611 @@ +package it_IT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type it_IT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'it_IT' locale +func New() locales.Translator { + return &it_IT{ + locale: "it_IT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic"}, + monthsNarrow: []string{"", "G", "F", "M", "A", "M", "G", "L", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"}, + daysAbbreviated: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"}, + daysNarrow: []string{"D", "L", "M", "M", "G", "V", "S"}, + daysShort: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"}, + daysWide: []string{"domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"m.", "p."}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"avanti Cristo", "dopo Cristo"}, + timezones: map[string]string{"∅∅∅": "Ora legale dell’Amazzonia", "VET": "Ora del Venezuela", "WITA": "Ora dell’Indonesia centrale", "AKDT": "Ora legale dell’Alaska", "UYT": "Ora standard dell’Uruguay", "AWST": "Ora standard dell’Australia occidentale", "ACWST": "Ora standard dell’Australia centroccidentale", "JDT": "Ora legale del Giappone", "WART": "Ora standard dell’Argentina occidentale", "AST": "Ora standard dell’Atlantico", "HNT": "Ora standard di Terranova", "UYST": "Ora legale dell’Uruguay", "AWDT": "Ora legale dell’Australia occidentale", "JST": "Ora standard del Giappone", "GMT": "Ora del meridiano di Greenwich", "TMST": "Ora legale del Turkmenistan", "COST": "Ora legale della Colombia", "ChST": "Ora di Chamorro", "CDT": "Ora legale centrale USA", "HECU": "Ora legale di Cuba", "BOT": "Ora della Bolivia", "HAST": "Ora standard delle Isole Hawaii-Aleutine", "CLST": "Ora legale del Cile", "HKST": "Ora legale di Hong Kong", "COT": "Ora standard della Colombia", "AKST": "Ora standard dell’Alaska", "HEPM": "Ora legale di Saint-Pierre e Miquelon", "WAST": "Ora legale dell’Africa occidentale", "HNNOMX": "Ora standard del Messico nord-occidentale", "GFT": "Ora della Guiana francese", "ACWDT": "Ora legale dell’Australia centroccidentale", "BT": "Ora del Bhutan", "HNPM": "Ora standard di Saint-Pierre e Miquelon", "PST": "Ora standard del Pacifico USA", "IST": "Ora standard dell’India", "ADT": "Ora legale dell’Atlantico", "OEZ": "Ora standard dell’Europa orientale", "ARST": "Ora legale dell’Argentina", "HEEG": "Ora legale della Groenlandia orientale", "ECT": "Ora dell’Ecuador", "NZDT": "Ora legale della Nuova Zelanda", "MESZ": "Ora legale dell’Europa centrale", "CLT": "Ora standard del Cile", "WESZ": "Ora legale dell’Europa occidentale", "WAT": "Ora standard dell’Africa occidentale", "HNOG": "Ora standard della Groenlandia occidentale", "OESZ": "Ora legale dell’Europa orientale", "ACST": "Ora standard dell’Australia centrale", "CHAST": "Ora standard delle Chatham", "HEOG": "Ora legale della Groenlandia occidentale", "MST": "MST", "LHST": "Ora standard di Lord Howe", "HNCU": "Ora standard di Cuba", "PDT": "Ora legale del Pacifico USA", "WARST": "Ora legale dell’Argentina occidentale", "EST": "Ora standard orientale USA", "AEST": "Ora standard dell’Australia orientale", "HNPMX": "Ora standard del Pacifico (Messico)", "HKT": "Ora standard di Hong Kong", "ACDT": "Ora legale dell’Australia centrale", "NZST": "Ora standard della Nuova Zelanda", "WEZ": "Ora standard dell’Europa occidentale", "EDT": "Ora legale orientale USA", "HEPMX": "Ora legale del Pacifico (Messico)", "CST": "Ora standard centrale USA", "GYT": "Ora della Guyana", "EAT": "Ora dell’Africa orientale", "MEZ": "Ora standard dell’Europa centrale", "ART": "Ora standard dell’Argentina", "HAT": "Ora legale di Terranova", "HNEG": "Ora standard della Groenlandia orientale", "AEDT": "Ora legale dell’Australia orientale", "SRT": "Ora del Suriname", "WIB": "Ora dell’Indonesia occidentale", "WIT": "Ora dell’Indonesia orientale", "CHADT": "Ora legale delle Chatham", "SGT": "Ora di Singapore", "SAST": "Ora dell’Africa meridionale", "LHDT": "Ora legale di Lord Howe", "HADT": "Ora legale delle Isole Hawaii-Aleutine", "CAT": "Ora dell’Africa centrale", "MYT": "Ora della Malesia", "TMT": "Ora standard del Turkmenistan", "MDT": "MDT", "HENOMX": "Ora legale del Messico nord-occidentale"}, + } +} + +// Locale returns the current translators string locale +func (it *it_IT) Locale() string { + return it.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'it_IT' +func (it *it_IT) PluralsCardinal() []locales.PluralRule { + return it.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'it_IT' +func (it *it_IT) PluralsOrdinal() []locales.PluralRule { + return it.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'it_IT' +func (it *it_IT) PluralsRange() []locales.PluralRule { + return it.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'it_IT' +func (it *it_IT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'it_IT' +func (it *it_IT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 11 || n == 8 || n == 80 || n == 800 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'it_IT' +func (it *it_IT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := it.CardinalPluralRule(num1, v1) + end := it.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (it *it_IT) MonthAbbreviated(month time.Month) string { + return it.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (it *it_IT) MonthsAbbreviated() []string { + return it.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (it *it_IT) MonthNarrow(month time.Month) string { + return it.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (it *it_IT) MonthsNarrow() []string { + return it.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (it *it_IT) MonthWide(month time.Month) string { + return it.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (it *it_IT) MonthsWide() []string { + return it.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (it *it_IT) WeekdayAbbreviated(weekday time.Weekday) string { + return it.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (it *it_IT) WeekdaysAbbreviated() []string { + return it.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (it *it_IT) WeekdayNarrow(weekday time.Weekday) string { + return it.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (it *it_IT) WeekdaysNarrow() []string { + return it.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (it *it_IT) WeekdayShort(weekday time.Weekday) string { + return it.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (it *it_IT) WeekdaysShort() []string { + return it.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (it *it_IT) WeekdayWide(weekday time.Weekday) string { + return it.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (it *it_IT) WeekdaysWide() []string { + return it.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'it_IT' and handles both Whole and Real numbers based on 'v' +func (it *it_IT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'it_IT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (it *it_IT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, it.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'it_IT' +func (it *it_IT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := it.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, it.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, it.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'it_IT' +// in accounting notation. +func (it *it_IT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := it.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, it.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, it.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, it.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, it.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'it_IT' +func (it *it_IT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'it_IT' +func (it *it_IT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'it_IT' +func (it *it_IT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'it_IT' +func (it *it_IT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, it.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'it_IT' +func (it *it_IT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'it_IT' +func (it *it_IT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'it_IT' +func (it *it_IT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'it_IT' +func (it *it_IT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := it.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/it_IT/it_IT_test.go b/vendor/github.com/go-playground/locales/it_IT/it_IT_test.go new file mode 100644 index 0000000000..f29cba3f22 --- /dev/null +++ b/vendor/github.com/go-playground/locales/it_IT/it_IT_test.go @@ -0,0 +1,1120 @@ +package it_IT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "it_IT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/it_SM/it_SM.go b/vendor/github.com/go-playground/locales/it_SM/it_SM.go new file mode 100644 index 0000000000..3c9d3b2db7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/it_SM/it_SM.go @@ -0,0 +1,611 @@ +package it_SM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type it_SM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'it_SM' locale +func New() locales.Translator { + return &it_SM{ + locale: "it_SM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "gen", "feb", "mar", "apr", "mag", "giu", "lug", "ago", "set", "ott", "nov", "dic"}, + monthsNarrow: []string{"", "G", "F", "M", "A", "M", "G", "L", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"}, + daysAbbreviated: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"}, + daysNarrow: []string{"D", "L", "M", "M", "G", "V", "S"}, + daysShort: []string{"dom", "lun", "mar", "mer", "gio", "ven", "sab"}, + daysWide: []string{"domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"m.", "p."}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"aC", "dC"}, + erasWide: []string{"avanti Cristo", "dopo Cristo"}, + timezones: map[string]string{"PST": "Ora standard del Pacifico USA", "CLT": "Ora standard del Cile", "HAT": "Ora legale di Terranova", "AKDT": "Ora legale dell’Alaska", "WIB": "Ora dell’Indonesia occidentale", "CHAST": "Ora standard delle Chatham", "HNCU": "Ora standard di Cuba", "HAST": "Ora standard delle Isole Hawaii-Aleutine", "ACWST": "Ora standard dell’Australia centroccidentale", "HNNOMX": "Ora standard del Messico nord-occidentale", "HNT": "Ora standard di Terranova", "AKST": "Ora standard dell’Alaska", "HNPMX": "Ora standard del Pacifico (Messico)", "WESZ": "Ora legale dell’Europa occidentale", "HKT": "Ora standard di Hong Kong", "HKST": "Ora legale di Hong Kong", "HECU": "Ora legale di Cuba", "WEZ": "Ora standard dell’Europa occidentale", "PDT": "Ora legale del Pacifico USA", "TMT": "Ora standard del Turkmenistan", "ACST": "Ora standard dell’Australia centrale", "AEDT": "Ora legale dell’Australia orientale", "UYST": "Ora legale dell’Uruguay", "HEPMX": "Ora legale del Pacifico (Messico)", "CLST": "Ora legale del Cile", "WAST": "Ora legale dell’Africa occidentale", "ACDT": "Ora legale dell’Australia centrale", "LHDT": "Ora legale di Lord Howe", "MESZ": "Ora legale dell’Europa centrale", "EST": "Ora standard orientale USA", "MDT": "Ora legale Montagne Rocciose USA", "GFT": "Ora della Guiana francese", "CDT": "Ora legale centrale USA", "JST": "Ora standard del Giappone", "WARST": "Ora legale dell’Argentina occidentale", "WAT": "Ora standard dell’Africa occidentale", "∅∅∅": "∅∅∅", "BT": "Ora del Bhutan", "WIT": "Ora dell’Indonesia orientale", "NZDT": "Ora legale della Nuova Zelanda", "AST": "Ora standard dell’Atlantico", "COT": "Ora standard della Colombia", "HNEG": "Ora standard della Groenlandia orientale", "SRT": "Ora del Suriname", "AWST": "Ora standard dell’Australia occidentale", "GMT": "Ora del meridiano di Greenwich", "MYT": "Ora della Malesia", "OESZ": "Ora legale dell’Europa orientale", "AEST": "Ora standard dell’Australia orientale", "HNPM": "Ora standard di Saint-Pierre e Miquelon", "LHST": "Ora standard di Lord Howe", "NZST": "Ora standard della Nuova Zelanda", "ADT": "Ora legale dell’Atlantico", "HEEG": "Ora legale della Groenlandia orientale", "SGT": "Ora di Singapore", "ACWDT": "Ora legale dell’Australia centroccidentale", "MEZ": "Ora standard dell’Europa centrale", "HADT": "Ora legale delle Isole Hawaii-Aleutine", "OEZ": "Ora standard dell’Europa orientale", "TMST": "Ora legale del Turkmenistan", "ART": "Ora standard dell’Argentina", "WITA": "Ora dell’Indonesia centrale", "UYT": "Ora standard dell’Uruguay", "EAT": "Ora dell’Africa orientale", "AWDT": "Ora legale dell’Australia occidentale", "CAT": "Ora dell’Africa centrale", "HEOG": "Ora legale della Groenlandia occidentale", "ARST": "Ora legale dell’Argentina", "CHADT": "Ora legale delle Chatham", "JDT": "Ora legale del Giappone", "VET": "Ora del Venezuela", "HNOG": "Ora standard della Groenlandia occidentale", "EDT": "Ora legale orientale USA", "COST": "Ora legale della Colombia", "MST": "Ora standard Montagne Rocciose USA", "HEPM": "Ora legale di Saint-Pierre e Miquelon", "HENOMX": "Ora legale del Messico nord-occidentale", "ECT": "Ora dell’Ecuador", "IST": "Ora standard dell’India", "WART": "Ora standard dell’Argentina occidentale", "ChST": "Ora di Chamorro", "SAST": "Ora dell’Africa meridionale", "CST": "Ora standard centrale USA", "BOT": "Ora della Bolivia", "GYT": "Ora della Guyana"}, + } +} + +// Locale returns the current translators string locale +func (it *it_SM) Locale() string { + return it.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'it_SM' +func (it *it_SM) PluralsCardinal() []locales.PluralRule { + return it.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'it_SM' +func (it *it_SM) PluralsOrdinal() []locales.PluralRule { + return it.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'it_SM' +func (it *it_SM) PluralsRange() []locales.PluralRule { + return it.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'it_SM' +func (it *it_SM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'it_SM' +func (it *it_SM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 11 || n == 8 || n == 80 || n == 800 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'it_SM' +func (it *it_SM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := it.CardinalPluralRule(num1, v1) + end := it.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (it *it_SM) MonthAbbreviated(month time.Month) string { + return it.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (it *it_SM) MonthsAbbreviated() []string { + return it.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (it *it_SM) MonthNarrow(month time.Month) string { + return it.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (it *it_SM) MonthsNarrow() []string { + return it.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (it *it_SM) MonthWide(month time.Month) string { + return it.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (it *it_SM) MonthsWide() []string { + return it.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (it *it_SM) WeekdayAbbreviated(weekday time.Weekday) string { + return it.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (it *it_SM) WeekdaysAbbreviated() []string { + return it.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (it *it_SM) WeekdayNarrow(weekday time.Weekday) string { + return it.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (it *it_SM) WeekdaysNarrow() []string { + return it.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (it *it_SM) WeekdayShort(weekday time.Weekday) string { + return it.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (it *it_SM) WeekdaysShort() []string { + return it.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (it *it_SM) WeekdayWide(weekday time.Weekday) string { + return it.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (it *it_SM) WeekdaysWide() []string { + return it.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'it_SM' and handles both Whole and Real numbers based on 'v' +func (it *it_SM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'it_SM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (it *it_SM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, it.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'it_SM' +func (it *it_SM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := it.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, it.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, it.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, it.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'it_SM' +// in accounting notation. +func (it *it_SM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := it.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, it.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, it.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, it.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, it.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, it.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, it.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'it_SM' +func (it *it_SM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'it_SM' +func (it *it_SM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'it_SM' +func (it *it_SM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'it_SM' +func (it *it_SM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, it.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, it.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'it_SM' +func (it *it_SM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'it_SM' +func (it *it_SM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'it_SM' +func (it *it_SM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'it_SM' +func (it *it_SM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, it.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, it.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := it.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/it_SM/it_SM_test.go b/vendor/github.com/go-playground/locales/it_SM/it_SM_test.go new file mode 100644 index 0000000000..daeef3b4d4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/it_SM/it_SM_test.go @@ -0,0 +1,1120 @@ +package it_SM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "it_SM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ja/ja.go b/vendor/github.com/go-playground/locales/ja/ja.go new file mode 100644 index 0000000000..a243abd5bb --- /dev/null +++ b/vendor/github.com/go-playground/locales/ja/ja.go @@ -0,0 +1,583 @@ +package ja + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ja struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ja' locale +func New() locales.Translator { + return &ja{ + locale: "ja", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "元", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + daysAbbreviated: []string{"日", "月", "火", "水", "木", "金", "土"}, + daysNarrow: []string{"日", "月", "火", "水", "木", "金", "土"}, + daysShort: []string{"日", "月", "火", "水", "木", "金", "土"}, + daysWide: []string{"日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"}, + periodsAbbreviated: []string{"午前", "午後"}, + periodsNarrow: []string{"午前", "午後"}, + periodsWide: []string{"午前", "午後"}, + erasAbbreviated: []string{"紀元前", "西暦"}, + erasNarrow: []string{"BC", "AD"}, + erasWide: []string{"紀元前", "西暦"}, + timezones: map[string]string{"MDT": "マカオ夏時間", "WAT": "西アフリカ標準時", "HEPM": "サンピエール・ミクロン夏時間", "AWST": "オーストラリア西部標準時", "SGT": "シンガポール標準時", "∅∅∅": "アマゾン夏時間", "WEZ": "西ヨーロッパ標準時", "JST": "日本標準時", "TMST": "トルクメニスタン夏時間", "AEST": "オーストラリア東部標準時", "AST": "大西洋標準時", "WIB": "インドネシア西部時間", "BOT": "ボリビア時間", "VET": "ベネズエラ時間", "OESZ": "東ヨーロッパ夏時間", "WART": "西部アルゼンチン標準時", "GMT": "グリニッジ標準時", "HEEG": "グリーンランド東部夏時間", "AKST": "アラスカ標準時", "HEPMX": "メキシコ太平洋夏時間", "AWDT": "オーストラリア西部夏時間", "COST": "コロンビア夏時間", "HNEG": "グリーンランド東部標準時", "GFT": "仏領ギアナ時間", "COT": "コロンビア標準時", "CST": "アメリカ中部標準時", "PDT": "アメリカ太平洋夏時間", "HADT": "ハワイ・アリューシャン夏時間", "CAT": "中央アフリカ時間", "EST": "アメリカ東部標準時", "ACWDT": "オーストラリア中西部夏時間", "HEOG": "グリーンランド西部夏時間", "HAT": "ニューファンドランド夏時間", "HENOMX": "メキシコ北西部夏時間", "WITA": "インドネシア中部時間", "JDT": "日本夏時間", "MYT": "マレーシア時間", "CLST": "チリ夏時間", "WAST": "西アフリカ夏時間", "HNCU": "キューバ標準時", "HECU": "キューバ夏時間", "MEZ": "中央ヨーロッパ標準時", "HNOG": "グリーンランド西部標準時", "ARST": "アルゼンチン夏時間", "LHDT": "ロードハウ夏時間", "WARST": "西部アルゼンチン夏時間", "AEDT": "オーストラリア東部夏時間", "AKDT": "アラスカ夏時間", "EAT": "東アフリカ時間", "HAST": "ハワイ・アリューシャン標準時", "WESZ": "西ヨーロッパ夏時間", "HKST": "香港夏時間", "HNNOMX": "メキシコ北西部標準時", "HNPM": "サンピエール・ミクロン標準時", "CDT": "アメリカ中部夏時間", "MESZ": "中央ヨーロッパ夏時間", "CLT": "チリ標準時", "HKT": "香港標準時", "ACST": "オーストラリア中部標準時", "HNT": "ニューファンドランド標準時", "UYST": "ウルグアイ夏時間", "ChST": "チャモロ時間", "WIT": "インドネシア東部時間", "PST": "アメリカ太平洋標準時", "IST": "インド標準時", "NZDT": "ニュージーランド夏時間", "ART": "アルゼンチン標準時", "EDT": "アメリカ東部夏時間", "SRT": "スリナム時間", "CHADT": "チャタム夏時間", "OEZ": "東ヨーロッパ標準時", "TMT": "トルクメニスタン標準時", "MST": "マカオ標準時", "UYT": "ウルグアイ標準時", "HNPMX": "メキシコ太平洋標準時", "GYT": "ガイアナ時間", "ADT": "大西洋夏時間", "ACDT": "オーストラリア中部夏時間", "BT": "ブータン時間", "LHST": "ロードハウ標準時", "CHAST": "チャタム標準時", "ECT": "エクアドル時間", "ACWST": "オーストラリア中西部標準時", "NZST": "ニュージーランド標準時", "SAST": "南アフリカ標準時"}, + } +} + +// Locale returns the current translators string locale +func (ja *ja) Locale() string { + return ja.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ja' +func (ja *ja) PluralsCardinal() []locales.PluralRule { + return ja.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ja' +func (ja *ja) PluralsOrdinal() []locales.PluralRule { + return ja.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ja' +func (ja *ja) PluralsRange() []locales.PluralRule { + return ja.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ja' +func (ja *ja) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ja' +func (ja *ja) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ja' +func (ja *ja) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ja *ja) MonthAbbreviated(month time.Month) string { + return ja.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ja *ja) MonthsAbbreviated() []string { + return ja.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ja *ja) MonthNarrow(month time.Month) string { + return ja.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ja *ja) MonthsNarrow() []string { + return ja.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ja *ja) MonthWide(month time.Month) string { + return ja.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ja *ja) MonthsWide() []string { + return ja.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ja *ja) WeekdayAbbreviated(weekday time.Weekday) string { + return ja.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ja *ja) WeekdaysAbbreviated() []string { + return ja.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ja *ja) WeekdayNarrow(weekday time.Weekday) string { + return ja.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ja *ja) WeekdaysNarrow() []string { + return ja.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ja *ja) WeekdayShort(weekday time.Weekday) string { + return ja.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ja *ja) WeekdaysShort() []string { + return ja.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ja *ja) WeekdayWide(weekday time.Weekday) string { + return ja.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ja *ja) WeekdaysWide() []string { + return ja.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ja' and handles both Whole and Real numbers based on 'v' +func (ja *ja) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ja.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ja.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ja.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ja' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ja *ja) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ja.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ja.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ja.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ja' +func (ja *ja) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ja.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ja.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ja.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ja.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ja.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ja' +// in accounting notation. +func (ja *ja) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ja.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ja.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ja.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ja.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ja.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ja.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ja' +func (ja *ja) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ja' +func (ja *ja) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ja' +func (ja *ja) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ja' +func (ja *ja) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, ja.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ja' +func (ja *ja) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ja.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ja' +func (ja *ja) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ja.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ja.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ja' +func (ja *ja) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ja.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ja.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ja' +func (ja *ja) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0xe6, 0x99, 0x82}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0xe5, 0x88, 0x86}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0xe7, 0xa7, 0x92, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ja.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ja/ja_test.go b/vendor/github.com/go-playground/locales/ja/ja_test.go new file mode 100644 index 0000000000..9b82837e93 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ja/ja_test.go @@ -0,0 +1,1120 @@ +package ja + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ja" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ja_JP/ja_JP.go b/vendor/github.com/go-playground/locales/ja_JP/ja_JP.go new file mode 100644 index 0000000000..63a02149a5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ja_JP/ja_JP.go @@ -0,0 +1,583 @@ +package ja_JP + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ja_JP struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ja_JP' locale +func New() locales.Translator { + return &ja_JP{ + locale: "ja_JP", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + daysAbbreviated: []string{"日", "月", "火", "水", "木", "金", "土"}, + daysNarrow: []string{"日", "月", "火", "水", "木", "金", "土"}, + daysShort: []string{"日", "月", "火", "水", "木", "金", "土"}, + daysWide: []string{"日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"}, + periodsAbbreviated: []string{"午前", "午後"}, + periodsNarrow: []string{"午前", "午後"}, + periodsWide: []string{"午前", "午後"}, + erasAbbreviated: []string{"紀元前", "西暦"}, + erasNarrow: []string{"BC", "AD"}, + erasWide: []string{"紀元前", "西暦"}, + timezones: map[string]string{"TMT": "トルクメニスタン標準時", "MST": "マカオ標準時", "HNEG": "グリーンランド東部標準時", "CAT": "中央アフリカ時間", "OESZ": "東ヨーロッパ夏時間", "GMT": "グリニッジ標準時", "ACST": "オーストラリア中部標準時", "COST": "コロンビア夏時間", "ECT": "エクアドル時間", "WESZ": "西ヨーロッパ夏時間", "HKST": "香港夏時間", "LHST": "ロードハウ標準時", "WAT": "西アフリカ標準時", "AKDT": "アラスカ夏時間", "HNNOMX": "メキシコ北西部標準時", "BT": "ブータン時間", "AKST": "アラスカ標準時", "HECU": "キューバ夏時間", "CST": "アメリカ中部標準時", "ADT": "大西洋夏時間", "AST": "大西洋標準時", "AEDT": "オーストラリア東部夏時間", "HNPMX": "メキシコ太平洋標準時", "EAT": "東アフリカ時間", "NZDT": "ニュージーランド夏時間", "SRT": "スリナム時間", "JST": "日本標準時", "HKT": "香港標準時", "ACWDT": "オーストラリア中西部夏時間", "CLT": "チリ標準時", "ARST": "アルゼンチン夏時間", "SGT": "シンガポール標準時", "IST": "インド標準時", "NZST": "ニュージーランド標準時", "COT": "コロンビア標準時", "HEPM": "サンピエール・ミクロン夏時間", "LHDT": "ロードハウ夏時間", "HEPMX": "メキシコ太平洋夏時間", "HNCU": "キューバ標準時", "ACWST": "オーストラリア中西部標準時", "HEOG": "グリーンランド西部夏時間", "HENOMX": "メキシコ北西部夏時間", "HAT": "ニューファンドランド夏時間", "∅∅∅": "アゾレス夏時間", "CHADT": "チャタム夏時間", "BOT": "ボリビア時間", "EDT": "アメリカ東部夏時間", "CLST": "チリ夏時間", "EST": "アメリカ東部標準時", "UYT": "ウルグアイ標準時", "HNPM": "サンピエール・ミクロン標準時", "WIB": "インドネシア西部時間", "PDT": "アメリカ太平洋夏時間", "WARST": "西部アルゼンチン夏時間", "GFT": "仏領ギアナ時間", "WITA": "インドネシア中部時間", "ChST": "チャモロ時間", "CHAST": "チャタム標準時", "HNOG": "グリーンランド西部標準時", "HNT": "ニューファンドランド標準時", "TMST": "トルクメニスタン夏時間", "GYT": "ガイアナ時間", "CDT": "アメリカ中部夏時間", "MYT": "マレーシア時間", "WEZ": "西ヨーロッパ標準時", "MDT": "マカオ夏時間", "ACDT": "オーストラリア中部夏時間", "AWST": "オーストラリア西部標準時", "HAST": "ハワイ・アリューシャン標準時", "OEZ": "東ヨーロッパ標準時", "HEEG": "グリーンランド東部夏時間", "UYST": "ウルグアイ夏時間", "PST": "アメリカ太平洋標準時", "WART": "西部アルゼンチン標準時", "WAST": "西アフリカ夏時間", "HADT": "ハワイ・アリューシャン夏時間", "MEZ": "中央ヨーロッパ標準時", "MESZ": "中央ヨーロッパ夏時間", "VET": "ベネズエラ時間", "JDT": "日本夏時間", "SAST": "南アフリカ標準時", "WIT": "インドネシア東部時間", "AWDT": "オーストラリア西部夏時間", "ART": "アルゼンチン標準時", "AEST": "オーストラリア東部標準時"}, + } +} + +// Locale returns the current translators string locale +func (ja *ja_JP) Locale() string { + return ja.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ja_JP' +func (ja *ja_JP) PluralsCardinal() []locales.PluralRule { + return ja.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ja_JP' +func (ja *ja_JP) PluralsOrdinal() []locales.PluralRule { + return ja.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ja_JP' +func (ja *ja_JP) PluralsRange() []locales.PluralRule { + return ja.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ja_JP' +func (ja *ja_JP) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ja_JP' +func (ja *ja_JP) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ja_JP' +func (ja *ja_JP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ja *ja_JP) MonthAbbreviated(month time.Month) string { + return ja.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ja *ja_JP) MonthsAbbreviated() []string { + return ja.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ja *ja_JP) MonthNarrow(month time.Month) string { + return ja.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ja *ja_JP) MonthsNarrow() []string { + return ja.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ja *ja_JP) MonthWide(month time.Month) string { + return ja.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ja *ja_JP) MonthsWide() []string { + return ja.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ja *ja_JP) WeekdayAbbreviated(weekday time.Weekday) string { + return ja.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ja *ja_JP) WeekdaysAbbreviated() []string { + return ja.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ja *ja_JP) WeekdayNarrow(weekday time.Weekday) string { + return ja.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ja *ja_JP) WeekdaysNarrow() []string { + return ja.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ja *ja_JP) WeekdayShort(weekday time.Weekday) string { + return ja.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ja *ja_JP) WeekdaysShort() []string { + return ja.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ja *ja_JP) WeekdayWide(weekday time.Weekday) string { + return ja.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ja *ja_JP) WeekdaysWide() []string { + return ja.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ja_JP' and handles both Whole and Real numbers based on 'v' +func (ja *ja_JP) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ja.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ja.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ja.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ja_JP' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ja *ja_JP) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ja.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ja.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ja.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ja_JP' +func (ja *ja_JP) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ja.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ja.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ja.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ja.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ja.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ja_JP' +// in accounting notation. +func (ja *ja_JP) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ja.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ja.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ja.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ja.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ja.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ja.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ja_JP' +func (ja *ja_JP) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ja_JP' +func (ja *ja_JP) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ja_JP' +func (ja *ja_JP) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ja_JP' +func (ja *ja_JP) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, ja.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ja_JP' +func (ja *ja_JP) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ja.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ja_JP' +func (ja *ja_JP) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ja.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ja.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ja_JP' +func (ja *ja_JP) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ja.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ja.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ja_JP' +func (ja *ja_JP) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0xe6, 0x99, 0x82}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0xe5, 0x88, 0x86}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0xe7, 0xa7, 0x92, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ja.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ja_JP/ja_JP_test.go b/vendor/github.com/go-playground/locales/ja_JP/ja_JP_test.go new file mode 100644 index 0000000000..1a94dacff6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ja_JP/ja_JP_test.go @@ -0,0 +1,1120 @@ +package ja_JP + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ja_JP" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/jgo/jgo.go b/vendor/github.com/go-playground/locales/jgo/jgo.go new file mode 100644 index 0000000000..e3d2f1f2dc --- /dev/null +++ b/vendor/github.com/go-playground/locales/jgo/jgo.go @@ -0,0 +1,606 @@ +package jgo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type jgo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'jgo' locale +func New() locales.Translator { + return &jgo{ + locale: "jgo", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Nduŋmbi Saŋ", "Pɛsaŋ Pɛ́pá", "Pɛsaŋ Pɛ́tát", "Pɛsaŋ Pɛ́nɛ́kwa", "Pɛsaŋ Pataa", "Pɛsaŋ Pɛ́nɛ́ntúkú", "Pɛsaŋ Saambá", "Pɛsaŋ Pɛ́nɛ́fɔm", "Pɛsaŋ Pɛ́nɛ́pfúꞋú", "Pɛsaŋ Nɛgɛ́m", "Pɛsaŋ Ntsɔ̌pmɔ́", "Pɛsaŋ Ntsɔ̌ppá"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Nduŋmbi Saŋ", "Pɛsaŋ Pɛ́pá", "Pɛsaŋ Pɛ́tát", "Pɛsaŋ Pɛ́nɛ́kwa", "Pɛsaŋ Pataa", "Pɛsaŋ Pɛ́nɛ́ntúkú", "Pɛsaŋ Saambá", "Pɛsaŋ Pɛ́nɛ́fɔm", "Pɛsaŋ Pɛ́nɛ́pfúꞋú", "Pɛsaŋ Nɛgɛ́m", "Pɛsaŋ Ntsɔ̌pmɔ́", "Pɛsaŋ Ntsɔ̌ppá"}, + daysAbbreviated: []string{"Sɔ́ndi", "Mɔ́ndi", "Ápta Mɔ́ndi", "Wɛ́nɛsɛdɛ", "Tɔ́sɛdɛ", "Fɛlâyɛdɛ", "Sásidɛ"}, + daysNarrow: []string{"Sɔ́", "Mɔ́", "ÁM", "Wɛ́", "Tɔ́", "Fɛ", "Sá"}, + daysWide: []string{"Sɔ́ndi", "Mɔ́ndi", "Ápta Mɔ́ndi", "Wɛ́nɛsɛdɛ", "Tɔ́sɛdɛ", "Fɛlâyɛdɛ", "Sásidɛ"}, + periodsAbbreviated: []string{"mbaꞌmbaꞌ", "ŋka mbɔ́t nji"}, + periodsWide: []string{"mbaꞌmbaꞌ", "ŋka mbɔ́t nji"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"tsɛttsɛt mɛŋguꞌ mi ɛ́ lɛɛnɛ Kɛlísɛtɔ gɔ ńɔ́", "tsɛttsɛt mɛŋguꞌ mi ɛ́ fúnɛ Kɛlísɛtɔ tɔ́ mɔ́"}, + timezones: map[string]string{"HNOG": "HNOG", "CDT": "CDT", "CLT": "CLT", "HNNOMX": "HNNOMX", "GFT": "GFT", "HNPM": "HNPM", "AWDT": "AWDT", "HEOG": "HEOG", "MST": "MST", "CAT": "CAT", "NZDT": "NZDT", "CLST": "CLST", "GMT": "GMT", "TMST": "TMST", "MDT": "MDT", "COT": "COT", "COST": "COST", "BT": "BT", "HAT": "HAT", "UYT": "UYT", "HEPMX": "HEPMX", "WIB": "WIB", "CHADT": "CHADT", "PST": "PST", "HADT": "HADT", "JDT": "JDT", "WAST": "WAST", "EDT": "EDT", "HNEG": "HNEG", "BOT": "BOT", "IST": "IST", "ACWST": "ACWST", "WEZ": "WEZ", "WAT": "WAT", "HKST": "HKST", "LHDT": "LHDT", "HECU": "HECU", "MESZ": "MESZ", "JST": "JST", "WART": "WART", "WARST": "WARST", "ART": "ART", "ARST": "ARST", "EST": "EST", "SGT": "SGT", "AEST": "AEST", "AST": "AST", "ACDT": "ACDT", "AKST": "AKST", "GYT": "GYT", "HNCU": "HNCU", "WIT": "WIT", "ACWDT": "ACWDT", "VET": "VET", "WESZ": "WESZ", "HNT": "HNT", "HNPMX": "HNPMX", "CHAST": "CHAST", "PDT": "PDT", "MEZ": "MEZ", "HEEG": "HEEG", "EAT": "EAT", "HKT": "HKT", "WITA": "WITA", "SRT": "SRT", "HAST": "HAST", "MYT": "MYT", "ADT": "ADT", "OEZ": "OEZ", "TMT": "TMT", "ACST": "ACST", "HENOMX": "HENOMX", "AKDT": "AKDT", "UYST": "UYST", "HEPM": "HEPM", "SAST": "SAST", "LHST": "LHST", "ECT": "ECT", "∅∅∅": "∅∅∅", "NZST": "NZST", "OESZ": "OESZ", "AEDT": "AEDT", "ChST": "ChST", "CST": "CST", "AWST": "AWST"}, + } +} + +// Locale returns the current translators string locale +func (jgo *jgo) Locale() string { + return jgo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'jgo' +func (jgo *jgo) PluralsCardinal() []locales.PluralRule { + return jgo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'jgo' +func (jgo *jgo) PluralsOrdinal() []locales.PluralRule { + return jgo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'jgo' +func (jgo *jgo) PluralsRange() []locales.PluralRule { + return jgo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'jgo' +func (jgo *jgo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'jgo' +func (jgo *jgo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'jgo' +func (jgo *jgo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (jgo *jgo) MonthAbbreviated(month time.Month) string { + return jgo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (jgo *jgo) MonthsAbbreviated() []string { + return jgo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (jgo *jgo) MonthNarrow(month time.Month) string { + return jgo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (jgo *jgo) MonthsNarrow() []string { + return jgo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (jgo *jgo) MonthWide(month time.Month) string { + return jgo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (jgo *jgo) MonthsWide() []string { + return jgo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (jgo *jgo) WeekdayAbbreviated(weekday time.Weekday) string { + return jgo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (jgo *jgo) WeekdaysAbbreviated() []string { + return jgo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (jgo *jgo) WeekdayNarrow(weekday time.Weekday) string { + return jgo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (jgo *jgo) WeekdaysNarrow() []string { + return jgo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (jgo *jgo) WeekdayShort(weekday time.Weekday) string { + return jgo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (jgo *jgo) WeekdaysShort() []string { + return jgo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (jgo *jgo) WeekdayWide(weekday time.Weekday) string { + return jgo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (jgo *jgo) WeekdaysWide() []string { + return jgo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'jgo' and handles both Whole and Real numbers based on 'v' +func (jgo *jgo) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, jgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'jgo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (jgo *jgo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jgo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, jgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, jgo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'jgo' +func (jgo *jgo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := jgo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(jgo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, jgo.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, jgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, jgo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'jgo' +// in accounting notation. +func (jgo *jgo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := jgo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(jgo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, jgo.currencyNegativePrefix[j]) + } + + b = append(b, jgo.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(jgo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, jgo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, jgo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'jgo' +func (jgo *jgo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'jgo' +func (jgo *jgo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, jgo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'jgo' +func (jgo *jgo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, jgo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'jgo' +func (jgo *jgo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, jgo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, jgo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'jgo' +func (jgo *jgo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'jgo' +func (jgo *jgo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'jgo' +func (jgo *jgo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'jgo' +func (jgo *jgo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := jgo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/jgo/jgo_test.go b/vendor/github.com/go-playground/locales/jgo/jgo_test.go new file mode 100644 index 0000000000..52b477e118 --- /dev/null +++ b/vendor/github.com/go-playground/locales/jgo/jgo_test.go @@ -0,0 +1,1120 @@ +package jgo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "jgo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/jgo_CM/jgo_CM.go b/vendor/github.com/go-playground/locales/jgo_CM/jgo_CM.go new file mode 100644 index 0000000000..d3e9dd30f0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/jgo_CM/jgo_CM.go @@ -0,0 +1,606 @@ +package jgo_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type jgo_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'jgo_CM' locale +func New() locales.Translator { + return &jgo_CM{ + locale: "jgo_CM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Nduŋmbi Saŋ", "Pɛsaŋ Pɛ́pá", "Pɛsaŋ Pɛ́tát", "Pɛsaŋ Pɛ́nɛ́kwa", "Pɛsaŋ Pataa", "Pɛsaŋ Pɛ́nɛ́ntúkú", "Pɛsaŋ Saambá", "Pɛsaŋ Pɛ́nɛ́fɔm", "Pɛsaŋ Pɛ́nɛ́pfúꞋú", "Pɛsaŋ Nɛgɛ́m", "Pɛsaŋ Ntsɔ̌pmɔ́", "Pɛsaŋ Ntsɔ̌ppá"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Nduŋmbi Saŋ", "Pɛsaŋ Pɛ́pá", "Pɛsaŋ Pɛ́tát", "Pɛsaŋ Pɛ́nɛ́kwa", "Pɛsaŋ Pataa", "Pɛsaŋ Pɛ́nɛ́ntúkú", "Pɛsaŋ Saambá", "Pɛsaŋ Pɛ́nɛ́fɔm", "Pɛsaŋ Pɛ́nɛ́pfúꞋú", "Pɛsaŋ Nɛgɛ́m", "Pɛsaŋ Ntsɔ̌pmɔ́", "Pɛsaŋ Ntsɔ̌ppá"}, + daysAbbreviated: []string{"Sɔ́ndi", "Mɔ́ndi", "Ápta Mɔ́ndi", "Wɛ́nɛsɛdɛ", "Tɔ́sɛdɛ", "Fɛlâyɛdɛ", "Sásidɛ"}, + daysNarrow: []string{"Sɔ́", "Mɔ́", "ÁM", "Wɛ́", "Tɔ́", "Fɛ", "Sá"}, + daysWide: []string{"Sɔ́ndi", "Mɔ́ndi", "Ápta Mɔ́ndi", "Wɛ́nɛsɛdɛ", "Tɔ́sɛdɛ", "Fɛlâyɛdɛ", "Sásidɛ"}, + periodsAbbreviated: []string{"mbaꞌmbaꞌ", "ŋka mbɔ́t nji"}, + periodsWide: []string{"mbaꞌmbaꞌ", "ŋka mbɔ́t nji"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"tsɛttsɛt mɛŋguꞌ mi ɛ́ lɛɛnɛ Kɛlísɛtɔ gɔ ńɔ́", "tsɛttsɛt mɛŋguꞌ mi ɛ́ fúnɛ Kɛlísɛtɔ tɔ́ mɔ́"}, + timezones: map[string]string{"PDT": "PDT", "NZDT": "NZDT", "CAT": "CAT", "JDT": "JDT", "TMST": "TMST", "ACST": "ACST", "JST": "JST", "ART": "ART", "GYT": "GYT", "WIT": "WIT", "LHDT": "LHDT", "MEZ": "MEZ", "HEOG": "HEOG", "HAT": "HAT", "WITA": "WITA", "UYT": "UYT", "HEPM": "HEPM", "CHADT": "CHADT", "MYT": "MYT", "WEZ": "WEZ", "MDT": "MDT", "HKST": "HKST", "BT": "BT", "HECU": "HECU", "NZST": "NZST", "ACWST": "ACWST", "MST": "MST", "HENOMX": "HENOMX", "HNCU": "HNCU", "VET": "VET", "HNOG": "HNOG", "OESZ": "OESZ", "EST": "EST", "HNPMX": "HNPMX", "AWST": "AWST", "IST": "IST", "MESZ": "MESZ", "SAST": "SAST", "CST": "CST", "CDT": "CDT", "BOT": "BOT", "WART": "WART", "ADT": "ADT", "WESZ": "WESZ", "HNT": "HNT", "ARST": "ARST", "AKST": "AKST", "LHST": "LHST", "EAT": "EAT", "AWDT": "AWDT", "TMT": "TMT", "WAT": "WAT", "EDT": "EDT", "HNNOMX": "HNNOMX", "AKDT": "AKDT", "HNPM": "HNPM", "GFT": "GFT", "PST": "PST", "HAST": "HAST", "CLST": "CLST", "ACDT": "ACDT", "HNEG": "HNEG", "AEDT": "AEDT", "ECT": "ECT", "GMT": "GMT", "SGT": "SGT", "ACWDT": "ACWDT", "WARST": "WARST", "CLT": "CLT", "HKT": "HKT", "COST": "COST", "AEST": "AEST", "HADT": "HADT", "∅∅∅": "∅∅∅", "COT": "COT", "ChST": "ChST", "HEPMX": "HEPMX", "WIB": "WIB", "HEEG": "HEEG", "AST": "AST", "OEZ": "OEZ", "WAST": "WAST", "UYST": "UYST", "SRT": "SRT", "CHAST": "CHAST"}, + } +} + +// Locale returns the current translators string locale +func (jgo *jgo_CM) Locale() string { + return jgo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'jgo_CM' +func (jgo *jgo_CM) PluralsCardinal() []locales.PluralRule { + return jgo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'jgo_CM' +func (jgo *jgo_CM) PluralsOrdinal() []locales.PluralRule { + return jgo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'jgo_CM' +func (jgo *jgo_CM) PluralsRange() []locales.PluralRule { + return jgo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'jgo_CM' +func (jgo *jgo_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'jgo_CM' +func (jgo *jgo_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'jgo_CM' +func (jgo *jgo_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (jgo *jgo_CM) MonthAbbreviated(month time.Month) string { + return jgo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (jgo *jgo_CM) MonthsAbbreviated() []string { + return jgo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (jgo *jgo_CM) MonthNarrow(month time.Month) string { + return jgo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (jgo *jgo_CM) MonthsNarrow() []string { + return jgo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (jgo *jgo_CM) MonthWide(month time.Month) string { + return jgo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (jgo *jgo_CM) MonthsWide() []string { + return jgo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (jgo *jgo_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return jgo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (jgo *jgo_CM) WeekdaysAbbreviated() []string { + return jgo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (jgo *jgo_CM) WeekdayNarrow(weekday time.Weekday) string { + return jgo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (jgo *jgo_CM) WeekdaysNarrow() []string { + return jgo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (jgo *jgo_CM) WeekdayShort(weekday time.Weekday) string { + return jgo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (jgo *jgo_CM) WeekdaysShort() []string { + return jgo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (jgo *jgo_CM) WeekdayWide(weekday time.Weekday) string { + return jgo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (jgo *jgo_CM) WeekdaysWide() []string { + return jgo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'jgo_CM' and handles both Whole and Real numbers based on 'v' +func (jgo *jgo_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, jgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'jgo_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (jgo *jgo_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jgo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, jgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, jgo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'jgo_CM' +func (jgo *jgo_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := jgo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(jgo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, jgo.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, jgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, jgo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'jgo_CM' +// in accounting notation. +func (jgo *jgo_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := jgo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(jgo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, jgo.currencyNegativePrefix[j]) + } + + b = append(b, jgo.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(jgo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, jgo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, jgo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'jgo_CM' +func (jgo *jgo_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'jgo_CM' +func (jgo *jgo_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, jgo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'jgo_CM' +func (jgo *jgo_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, jgo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'jgo_CM' +func (jgo *jgo_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, jgo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, jgo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'jgo_CM' +func (jgo *jgo_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'jgo_CM' +func (jgo *jgo_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'jgo_CM' +func (jgo *jgo_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'jgo_CM' +func (jgo *jgo_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := jgo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/jgo_CM/jgo_CM_test.go b/vendor/github.com/go-playground/locales/jgo_CM/jgo_CM_test.go new file mode 100644 index 0000000000..9882c0e936 --- /dev/null +++ b/vendor/github.com/go-playground/locales/jgo_CM/jgo_CM_test.go @@ -0,0 +1,1120 @@ +package jgo_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "jgo_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/jmc/jmc.go b/vendor/github.com/go-playground/locales/jmc/jmc.go new file mode 100644 index 0000000000..f29945b593 --- /dev/null +++ b/vendor/github.com/go-playground/locales/jmc/jmc.go @@ -0,0 +1,517 @@ +package jmc + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type jmc struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'jmc' locale +func New() locales.Translator { + return &jmc{ + locale: "jmc", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprilyi", "Mei", "Junyi", "Julyai", "Agusti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Jumapilyi", "Jumatatuu", "Jumanne", "Jumatanu", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"utuko", "kyiukonyi"}, + periodsWide: []string{"utuko", "kyiukonyi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristu", "Baada ya Kristu"}, + timezones: map[string]string{"CHAST": "CHAST", "HADT": "HADT", "ChST": "ChST", "HNPMX": "HNPMX", "VET": "VET", "OESZ": "OESZ", "ARST": "ARST", "EST": "EST", "HNNOMX": "HNNOMX", "MESZ": "MESZ", "WART": "WART", "AST": "AST", "GFT": "GFT", "AKDT": "AKDT", "SGT": "SGT", "WEZ": "WEZ", "ACST": "ACST", "HEOG": "HEOG", "GYT": "GYT", "WIT": "WIT", "NZST": "NZST", "IST": "IST", "ACWST": "ACWST", "MDT": "MDT", "ACDT": "ACDT", "LHST": "LHST", "CST": "CST", "HKT": "HKT", "WITA": "WITA", "HECU": "HECU", "TMST": "TMST", "ACWDT": "ACWDT", "CLT": "CLT", "WESZ": "WESZ", "COST": "COST", "HNEG": "HNEG", "AEST": "AEST", "SRT": "SRT", "CDT": "CDT", "BOT": "BOT", "GMT": "GMT", "OEZ": "OEZ", "∅∅∅": "∅∅∅", "PST": "PST", "HAST": "HAST", "MYT": "MYT", "TMT": "TMT", "EDT": "EDT", "COT": "COT", "AKST": "AKST", "AWDT": "AWDT", "HNCU": "HNCU", "CHADT": "CHADT", "WAT": "WAT", "HKST": "HKST", "SAST": "SAST", "AWST": "AWST", "NZDT": "NZDT", "CAT": "CAT", "UYST": "UYST", "HEPM": "HEPM", "HEPMX": "HEPMX", "ADT": "ADT", "ART": "ART", "HENOMX": "HENOMX", "AEDT": "AEDT", "JDT": "JDT", "MST": "MST", "HAT": "HAT", "MEZ": "MEZ", "EAT": "EAT", "PDT": "PDT", "WARST": "WARST", "WAST": "WAST", "LHDT": "LHDT", "ECT": "ECT", "JST": "JST", "CLST": "CLST", "HNOG": "HNOG", "BT": "BT", "HNT": "HNT", "HEEG": "HEEG", "WIB": "WIB", "HNPM": "HNPM", "UYT": "UYT"}, + } +} + +// Locale returns the current translators string locale +func (jmc *jmc) Locale() string { + return jmc.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'jmc' +func (jmc *jmc) PluralsCardinal() []locales.PluralRule { + return jmc.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'jmc' +func (jmc *jmc) PluralsOrdinal() []locales.PluralRule { + return jmc.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'jmc' +func (jmc *jmc) PluralsRange() []locales.PluralRule { + return jmc.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'jmc' +func (jmc *jmc) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'jmc' +func (jmc *jmc) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'jmc' +func (jmc *jmc) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (jmc *jmc) MonthAbbreviated(month time.Month) string { + return jmc.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (jmc *jmc) MonthsAbbreviated() []string { + return jmc.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (jmc *jmc) MonthNarrow(month time.Month) string { + return jmc.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (jmc *jmc) MonthsNarrow() []string { + return jmc.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (jmc *jmc) MonthWide(month time.Month) string { + return jmc.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (jmc *jmc) MonthsWide() []string { + return jmc.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (jmc *jmc) WeekdayAbbreviated(weekday time.Weekday) string { + return jmc.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (jmc *jmc) WeekdaysAbbreviated() []string { + return jmc.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (jmc *jmc) WeekdayNarrow(weekday time.Weekday) string { + return jmc.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (jmc *jmc) WeekdaysNarrow() []string { + return jmc.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (jmc *jmc) WeekdayShort(weekday time.Weekday) string { + return jmc.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (jmc *jmc) WeekdaysShort() []string { + return jmc.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (jmc *jmc) WeekdayWide(weekday time.Weekday) string { + return jmc.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (jmc *jmc) WeekdaysWide() []string { + return jmc.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'jmc' and handles both Whole and Real numbers based on 'v' +func (jmc *jmc) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'jmc' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (jmc *jmc) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'jmc' +func (jmc *jmc) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := jmc.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jmc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jmc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, jmc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, jmc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'jmc' +// in accounting notation. +func (jmc *jmc) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := jmc.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jmc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jmc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, jmc.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, jmc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'jmc' +func (jmc *jmc) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'jmc' +func (jmc *jmc) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, jmc.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'jmc' +func (jmc *jmc) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, jmc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'jmc' +func (jmc *jmc) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, jmc.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, jmc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'jmc' +func (jmc *jmc) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'jmc' +func (jmc *jmc) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'jmc' +func (jmc *jmc) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'jmc' +func (jmc *jmc) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := jmc.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/jmc/jmc_test.go b/vendor/github.com/go-playground/locales/jmc/jmc_test.go new file mode 100644 index 0000000000..c3341dc1b1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/jmc/jmc_test.go @@ -0,0 +1,1120 @@ +package jmc + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "jmc" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/jmc_TZ/jmc_TZ.go b/vendor/github.com/go-playground/locales/jmc_TZ/jmc_TZ.go new file mode 100644 index 0000000000..8c14a6b817 --- /dev/null +++ b/vendor/github.com/go-playground/locales/jmc_TZ/jmc_TZ.go @@ -0,0 +1,517 @@ +package jmc_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type jmc_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'jmc_TZ' locale +func New() locales.Translator { + return &jmc_TZ{ + locale: "jmc_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprilyi", "Mei", "Junyi", "Julyai", "Agusti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Jumapilyi", "Jumatatuu", "Jumanne", "Jumatanu", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"utuko", "kyiukonyi"}, + periodsWide: []string{"utuko", "kyiukonyi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristu", "Baada ya Kristu"}, + timezones: map[string]string{"CLST": "CLST", "HEOG": "HEOG", "MDT": "MDT", "ARST": "ARST", "COT": "COT", "AEST": "AEST", "CAT": "CAT", "WARST": "WARST", "HNOG": "HNOG", "OEZ": "OEZ", "HNT": "HNT", "AKST": "AKST", "AKDT": "AKDT", "SRT": "SRT", "AWST": "AWST", "CHADT": "CHADT", "WAST": "WAST", "HKT": "HKT", "AEDT": "AEDT", "HNPMX": "HNPMX", "SGT": "SGT", "ACWDT": "ACWDT", "JST": "JST", "WEZ": "WEZ", "WESZ": "WESZ", "EDT": "EDT", "WITA": "WITA", "MEZ": "MEZ", "MESZ": "MESZ", "ACWST": "ACWST", "NZDT": "NZDT", "CLT": "CLT", "COST": "COST", "AWDT": "AWDT", "PDT": "PDT", "BOT": "BOT", "HKST": "HKST", "JDT": "JDT", "MYT": "MYT", "NZST": "NZST", "WIT": "WIT", "HADT": "HADT", "ChST": "ChST", "HECU": "HECU", "HEEG": "HEEG", "CHAST": "CHAST", "WART": "WART", "ACST": "ACST", "HNEG": "HNEG", "UYST": "UYST", "LHST": "LHST", "EAT": "EAT", "CST": "CST", "ADT": "ADT", "TMST": "TMST", "EST": "EST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "HAT": "HAT", "WIB": "WIB", "IST": "IST", "HEPMX": "HEPMX", "UYT": "UYT", "SAST": "SAST", "BT": "BT", "HEPM": "HEPM", "HNCU": "HNCU", "CDT": "CDT", "ART": "ART", "WAT": "WAT", "ECT": "ECT", "GMT": "GMT", "OESZ": "OESZ", "TMT": "TMT", "∅∅∅": "∅∅∅", "HAST": "HAST", "LHDT": "LHDT", "PST": "PST", "ACDT": "ACDT", "AST": "AST", "MST": "MST", "GFT": "GFT", "HNPM": "HNPM", "GYT": "GYT", "VET": "VET"}, + } +} + +// Locale returns the current translators string locale +func (jmc *jmc_TZ) Locale() string { + return jmc.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'jmc_TZ' +func (jmc *jmc_TZ) PluralsCardinal() []locales.PluralRule { + return jmc.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'jmc_TZ' +func (jmc *jmc_TZ) PluralsOrdinal() []locales.PluralRule { + return jmc.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'jmc_TZ' +func (jmc *jmc_TZ) PluralsRange() []locales.PluralRule { + return jmc.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'jmc_TZ' +func (jmc *jmc_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'jmc_TZ' +func (jmc *jmc_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'jmc_TZ' +func (jmc *jmc_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (jmc *jmc_TZ) MonthAbbreviated(month time.Month) string { + return jmc.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (jmc *jmc_TZ) MonthsAbbreviated() []string { + return jmc.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (jmc *jmc_TZ) MonthNarrow(month time.Month) string { + return jmc.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (jmc *jmc_TZ) MonthsNarrow() []string { + return jmc.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (jmc *jmc_TZ) MonthWide(month time.Month) string { + return jmc.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (jmc *jmc_TZ) MonthsWide() []string { + return jmc.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (jmc *jmc_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return jmc.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (jmc *jmc_TZ) WeekdaysAbbreviated() []string { + return jmc.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (jmc *jmc_TZ) WeekdayNarrow(weekday time.Weekday) string { + return jmc.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (jmc *jmc_TZ) WeekdaysNarrow() []string { + return jmc.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (jmc *jmc_TZ) WeekdayShort(weekday time.Weekday) string { + return jmc.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (jmc *jmc_TZ) WeekdaysShort() []string { + return jmc.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (jmc *jmc_TZ) WeekdayWide(weekday time.Weekday) string { + return jmc.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (jmc *jmc_TZ) WeekdaysWide() []string { + return jmc.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'jmc_TZ' and handles both Whole and Real numbers based on 'v' +func (jmc *jmc_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'jmc_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (jmc *jmc_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := jmc.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jmc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jmc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, jmc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, jmc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'jmc_TZ' +// in accounting notation. +func (jmc *jmc_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := jmc.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, jmc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, jmc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, jmc.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, jmc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, jmc.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, jmc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, jmc.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, jmc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'jmc_TZ' +func (jmc *jmc_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, jmc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := jmc.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/jmc_TZ/jmc_TZ_test.go b/vendor/github.com/go-playground/locales/jmc_TZ/jmc_TZ_test.go new file mode 100644 index 0000000000..b4c33bcaa8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/jmc_TZ/jmc_TZ_test.go @@ -0,0 +1,1120 @@ +package jmc_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "jmc_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ka/ka.go b/vendor/github.com/go-playground/locales/ka/ka.go new file mode 100644 index 0000000000..c33e35b50c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ka/ka.go @@ -0,0 +1,625 @@ +package ka + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ka struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ka' locale +func New() locales.Translator { + return &ka{ + locale: "ka", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "₾", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "იან", "თებ", "მარ", "აპრ", "მაი", "ივნ", "ივლ", "აგვ", "სექ", "ოქტ", "ნოე", "დეკ"}, + monthsNarrow: []string{"", "ი", "თ", "მ", "ა", "მ", "ი", "ი", "ა", "ს", "ო", "ნ", "დ"}, + monthsWide: []string{"", "იანვარი", "თებერვალი", "მარტი", "აპრილი", "მაისი", "ივნისი", "ივლისი", "აგვისტო", "სექტემბერი", "ოქტომბერი", "ნოემბერი", "დეკემბერი"}, + daysAbbreviated: []string{"კვი", "ორშ", "სამ", "ოთხ", "ხუთ", "პარ", "შაბ"}, + daysNarrow: []string{"კ", "ო", "ს", "ო", "ხ", "პ", "შ"}, + daysShort: []string{"კვ", "ორ", "სმ", "ოთ", "ხთ", "პრ", "შბ"}, + daysWide: []string{"კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"ძვ. წ.", "ახ. წ."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ძველი წელთაღრიცხვით", "ახალი წელთაღრიცხვით"}, + timezones: map[string]string{"IST": "ინდოეთის დრო", "WEZ": "დასავლეთ ევროპის სტანდარტული დრო", "ACST": "ავსტრალიის ცენტრალური სტანდარტული დრო", "AEDT": "აღმოსავლეთ ავსტრალიის ზაფხულის დრო", "HEPMX": "მექსიკის წყნარი ოკეანის ზაფხულის დრო", "AWDT": "დასავლეთ ავსტრალიის ზაფხულის დრო", "GMT": "გრინვიჩის საშუალო დრო", "OESZ": "აღმოსავლეთ ევროპის ზაფხულის დრო", "HKST": "ჰონკონგის ზაფხულის დრო", "SAST": "სამხრეთ აფრიკის დრო", "GYT": "გაიანის დრო", "SGT": "სინგაპურის დრო", "ECT": "ეკვადორის დრო", "HADT": "ჰავაისა და ალეუტის ზაფხულის დრო", "CDT": "ჩრდილოეთ ამერიკის ცენტრალური ზაფხულის დრო", "VET": "ვენესუელის დრო", "CLST": "ჩილეს ზაფხულის დრო", "ARST": "არგენტინის ზაფხულის დრო", "EDT": "ჩრდილოეთ ამერიკის აღმოსავლეთის ზაფხულის დრო", "ACDT": "ავსტრალიის ცენტრალური ზაფხულის დრო", "HNEG": "აღმოსავლეთ გრენლანდიის სტანდარტული დრო", "HEEG": "აღმოსავლეთ გრენლანდიის ზაფხულის დრო", "NZDT": "ახალი ზელანდიის ზაფხულის დრო", "JST": "იაპონიის სტანდარტული დრო", "LHST": "ლორდ-ჰაუს სტანდარტული დრო", "CHAST": "ჩატემის სტანდარტული დრო", "WARST": "დასავლეთ არგენტინის ზაფხულის დრო", "OEZ": "აღმოსავლეთ ევროპის სტანდარტული დრო", "ART": "არგენტინის სტანდარტული დრო", "HEPM": "სენ-პიერის და მიკელონის ზაფხულის დრო", "HNPMX": "მექსიკის წყნარი ოკეანის სტანდარტული დრო", "CAT": "ცენტრალური აფრიკის დრო", "MEZ": "ცენტრალური ევროპის სტანდარტული დრო", "MESZ": "ცენტრალური ევროპის ზაფხულის დრო", "WART": "დასავლეთ არგენტინის სტანდარტული დრო", "WAST": "დასავლეთ აფრიკის ზაფხულის დრო", "EAT": "აღმოსავლეთ აფრიკის დრო", "NZST": "ახალი ზელანდიის სტანდარტული დრო", "ACWDT": "ცენტრალური და დასავლეთ ავსტრალიის ზაფხულის დრო", "HENOMX": "ჩრდილო-დასავლეთ მექსიკის ზაფხულის დრო", "GFT": "საფრანგეთის გვიანის დრო", "HNOG": "დასავლეთ გრენლანდიის სტანდარტული დრო", "TMT": "თურქმენეთის სტანდარტული დრო", "WITA": "ცენტრალური ინდონეზიის დრო", "WIB": "დასავლეთ ინდონეზიის დრო", "AWST": "დასავლეთ ავსტრალიის სტანდარტული დრო", "PDT": "ჩრდილოეთ ამერიკის წყნარი ოკეანის ზაფხულის დრო", "JDT": "იაპონიის ზაფხულის დრო", "MST": "MST", "BT": "ბუტანის დრო", "UYT": "ურუგვაის სტანდარტული დრო", "CST": "ჩრდილოეთ ამერიკის ცენტრალური სტანდარტული დრო", "CHADT": "ჩატემის ზაფხულის დრო", "HEOG": "დასავლეთ გრენლანდიის ზაფხულის დრო", "WAT": "დასავლეთ აფრიკის სტანდარტული დრო", "COT": "კოლუმბიის სტანდარტული დრო", "AKDT": "ალასკის ზაფხულის დრო", "BOT": "ბოლივიის დრო", "ADT": "ატლანტიკის ოკეანის ზაფხულის დრო", "TMST": "თურქმენეთის ზაფხულის დრო", "EST": "ჩრდილოეთ ამერიკის აღმოსავლეთის სტანდარტული დრო", "HNT": "ნიუფაუნდლენდის სტანდარტული დრო", "AEST": "აღმოსავლეთ ავსტრალიის სტანდარტული დრო", "AKST": "ალასკის სტანდარტული დრო", "WIT": "აღმოსავლეთ ინდონეზიის დრო", "HAST": "ჰავაისა და ალეუტის სტანდარტული დრო", "ACWST": "ცენტრალური და დასავლეთ ავსტრალიის სტანდარტული დრო", "WESZ": "დასავლეთ ევროპის ზაფხულის დრო", "HKT": "ჰონკონგის სტანდარტული დრო", "HAT": "ნიუფაუნდლენდის ზაფხულის დრო", "ChST": "ჩამოროს დრო", "UYST": "ურუგვაის ზაფხულის დრო", "HNCU": "კუბის სტანდარტული დრო", "HECU": "კუბის ზაფხულის დრო", "COST": "კოლუმბიის ზაფხულის დრო", "HNPM": "სენ-პიერის და მიკელონის სტანდარტული დრო", "CLT": "ჩილეს სტანდარტული დრო", "AST": "ატლანტიკის ოკეანის სტანდარტული დრო", "HNNOMX": "ჩრდილო-დასავლეთ მექსიკის დრო", "SRT": "სურინამის დრო", "PST": "ჩრდილოეთ ამერიკის წყნარი ოკეანის სტანდარტული დრო", "∅∅∅": "ამაზონიის ზაფხულის დრო", "MYT": "მალაიზიის დრო", "MDT": "MDT", "LHDT": "ლორდ-ჰაუს ზაფხულის დრო"}, + } +} + +// Locale returns the current translators string locale +func (ka *ka) Locale() string { + return ka.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ka' +func (ka *ka) PluralsCardinal() []locales.PluralRule { + return ka.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ka' +func (ka *ka) PluralsOrdinal() []locales.PluralRule { + return ka.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ka' +func (ka *ka) PluralsRange() []locales.PluralRule { + return ka.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ka' +func (ka *ka) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ka' +func (ka *ka) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + + if i == 1 { + return locales.PluralRuleOne + } else if (i == 0) || (iMod100 >= 2 && iMod100 <= 20 && (iMod100 == 40 || iMod100 == 60 || iMod100 == 80)) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ka' +func (ka *ka) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ka.CardinalPluralRule(num1, v1) + end := ka.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ka *ka) MonthAbbreviated(month time.Month) string { + return ka.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ka *ka) MonthsAbbreviated() []string { + return ka.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ka *ka) MonthNarrow(month time.Month) string { + return ka.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ka *ka) MonthsNarrow() []string { + return ka.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ka *ka) MonthWide(month time.Month) string { + return ka.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ka *ka) MonthsWide() []string { + return ka.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ka *ka) WeekdayAbbreviated(weekday time.Weekday) string { + return ka.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ka *ka) WeekdaysAbbreviated() []string { + return ka.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ka *ka) WeekdayNarrow(weekday time.Weekday) string { + return ka.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ka *ka) WeekdaysNarrow() []string { + return ka.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ka *ka) WeekdayShort(weekday time.Weekday) string { + return ka.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ka *ka) WeekdaysShort() []string { + return ka.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ka *ka) WeekdayWide(weekday time.Weekday) string { + return ka.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ka *ka) WeekdaysWide() []string { + return ka.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ka' and handles both Whole and Real numbers based on 'v' +func (ka *ka) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ka.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ka.group) - 1; j >= 0; j-- { + b = append(b, ka.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ka.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ka' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ka *ka) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ka.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ka.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ka.percentSuffix...) + + b = append(b, ka.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ka' +func (ka *ka) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ka.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ka.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ka.group) - 1; j >= 0; j-- { + b = append(b, ka.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ka.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ka.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ka.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ka' +// in accounting notation. +func (ka *ka) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ka.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ka.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ka.group) - 1; j >= 0; j-- { + b = append(b, ka.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ka.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ka.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ka.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ka.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ka' +func (ka *ka) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ka' +func (ka *ka) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ka.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ka' +func (ka *ka) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ka.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ka' +func (ka *ka) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ka.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ka.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ka' +func (ka *ka) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ka.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ka' +func (ka *ka) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ka.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ka.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ka' +func (ka *ka) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ka.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ka.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ka' +func (ka *ka) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ka.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ka.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ka.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ka/ka_test.go b/vendor/github.com/go-playground/locales/ka/ka_test.go new file mode 100644 index 0000000000..b71e25037e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ka/ka_test.go @@ -0,0 +1,1120 @@ +package ka + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ka" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ka_GE/ka_GE.go b/vendor/github.com/go-playground/locales/ka_GE/ka_GE.go new file mode 100644 index 0000000000..12c53f1c7f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ka_GE/ka_GE.go @@ -0,0 +1,625 @@ +package ka_GE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ka_GE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ka_GE' locale +func New() locales.Translator { + return &ka_GE{ + locale: "ka_GE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "იან", "თებ", "მარ", "აპრ", "მაი", "ივნ", "ივლ", "აგვ", "სექ", "ოქტ", "ნოე", "დეკ"}, + monthsNarrow: []string{"", "ი", "თ", "მ", "ა", "მ", "ი", "ი", "ა", "ს", "ო", "ნ", "დ"}, + monthsWide: []string{"", "იანვარი", "თებერვალი", "მარტი", "აპრილი", "მაისი", "ივნისი", "ივლისი", "აგვისტო", "სექტემბერი", "ოქტომბერი", "ნოემბერი", "დეკემბერი"}, + daysAbbreviated: []string{"კვი", "ორშ", "სამ", "ოთხ", "ხუთ", "პარ", "შაბ"}, + daysNarrow: []string{"კ", "ო", "ს", "ო", "ხ", "პ", "შ"}, + daysShort: []string{"კვ", "ორ", "სმ", "ოთ", "ხთ", "პრ", "შბ"}, + daysWide: []string{"კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"ძვ. წ.", "ახ. წ."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ძველი წელთაღრიცხვით", "ახალი წელთაღრიცხვით"}, + timezones: map[string]string{"HENOMX": "ჩრდილო-დასავლეთ მექსიკის ზაფხულის დრო", "ChST": "ჩამოროს დრო", "UYT": "ურუგვაის სტანდარტული დრო", "HEPMX": "მექსიკის წყნარი ოკეანის ზაფხულის დრო", "ACDT": "ავსტრალიის ცენტრალური ზაფხულის დრო", "∅∅∅": "ბრაზილიის ზაფხულის დრო", "CHADT": "ჩატემის ზაფხულის დრო", "ECT": "ეკვადორის დრო", "JST": "იაპონიის სტანდარტული დრო", "EDT": "ჩრდილოეთ ამერიკის აღმოსავლეთის ზაფხულის დრო", "ACST": "ავსტრალიის ცენტრალური სტანდარტული დრო", "VET": "ვენესუელის დრო", "COST": "კოლუმბიის ზაფხულის დრო", "BT": "ბუტანის დრო", "HNPM": "სენ-პიერის და მიკელონის სტანდარტული დრო", "AEDT": "აღმოსავლეთ ავსტრალიის ზაფხულის დრო", "LHDT": "ლორდ-ჰაუს ზაფხულის დრო", "CDT": "ჩრდილოეთ ამერიკის ცენტრალური ზაფხულის დრო", "PST": "ჩრდილოეთ ამერიკის წყნარი ოკეანის სტანდარტული დრო", "CAT": "ცენტრალური აფრიკის დრო", "OEZ": "აღმოსავლეთ ევროპის სტანდარტული დრო", "CLST": "ჩილეს ზაფხულის დრო", "HNNOMX": "ჩრდილო-დასავლეთ მექსიკის დრო", "LHST": "ლორდ-ჰაუს სტანდარტული დრო", "SRT": "სურინამის დრო", "AWST": "დასავლეთ ავსტრალიის სტანდარტული დრო", "BOT": "ბოლივიის დრო", "HAST": "ჰავაისა და ალეუტის სტანდარტული დრო", "HEOG": "დასავლეთ გრენლანდიის ზაფხულის დრო", "MYT": "მალაიზიის დრო", "COT": "კოლუმბიის სტანდარტული დრო", "ACWST": "ცენტრალური და დასავლეთ ავსტრალიის სტანდარტული დრო", "ACWDT": "ცენტრალური და დასავლეთ ავსტრალიის ზაფხულის დრო", "CLT": "ჩილეს სტანდარტული დრო", "ARST": "არგენტინის ზაფხულის დრო", "SAST": "სამხრეთ აფრიკის დრო", "WIT": "აღმოსავლეთ ინდონეზიის დრო", "WEZ": "დასავლეთ ევროპის სტანდარტული დრო", "WARST": "დასავლეთ არგენტინის ზაფხულის დრო", "WAST": "დასავლეთ აფრიკის ზაფხულის დრო", "EAT": "აღმოსავლეთ აფრიკის დრო", "CHAST": "ჩატემის სტანდარტული დრო", "HADT": "ჰავაისა და ალეუტის ზაფხულის დრო", "NZST": "ახალი ზელანდიის სტანდარტული დრო", "NZDT": "ახალი ზელანდიის ზაფხულის დრო", "HAT": "ნიუფაუნდლენდის ზაფხულის დრო", "JDT": "იაპონიის ზაფხულის დრო", "ADT": "ატლანტიკის ოკეანის ზაფხულის დრო", "MST": "MST", "AEST": "აღმოსავლეთ ავსტრალიის სტანდარტული დრო", "GYT": "გაიანის დრო", "HECU": "კუბის ზაფხულის დრო", "WESZ": "დასავლეთ ევროპის ზაფხულის დრო", "EST": "ჩრდილოეთ ამერიკის აღმოსავლეთის სტანდარტული დრო", "PDT": "ჩრდილოეთ ამერიკის წყნარი ოკეანის ზაფხულის დრო", "HNOG": "დასავლეთ გრენლანდიის სტანდარტული დრო", "HKST": "ჰონკონგის ზაფხულის დრო", "WITA": "ცენტრალური ინდონეზიის დრო", "HNPMX": "მექსიკის წყნარი ოკეანის სტანდარტული დრო", "SGT": "სინგაპურის დრო", "OESZ": "აღმოსავლეთ ევროპის ზაფხულის დრო", "HKT": "ჰონკონგის სტანდარტული დრო", "HNEG": "აღმოსავლეთ გრენლანდიის სტანდარტული დრო", "AKST": "ალასკის სტანდარტული დრო", "GFT": "საფრანგეთის გვიანის დრო", "IST": "ინდოეთის დრო", "MEZ": "ცენტრალური ევროპის სტანდარტული დრო", "MESZ": "ცენტრალური ევროპის ზაფხულის დრო", "GMT": "გრინვიჩის საშუალო დრო", "MDT": "MDT", "HNT": "ნიუფაუნდლენდის სტანდარტული დრო", "AST": "ატლანტიკის ოკეანის სტანდარტული დრო", "TMT": "თურქმენეთის სტანდარტული დრო", "HEEG": "აღმოსავლეთ გრენლანდიის ზაფხულის დრო", "AKDT": "ალასკის ზაფხულის დრო", "HEPM": "სენ-პიერის და მიკელონის ზაფხულის დრო", "TMST": "თურქმენეთის ზაფხულის დრო", "ART": "არგენტინის სტანდარტული დრო", "UYST": "ურუგვაის ზაფხულის დრო", "CST": "ჩრდილოეთ ამერიკის ცენტრალური სტანდარტული დრო", "AWDT": "დასავლეთ ავსტრალიის ზაფხულის დრო", "WART": "დასავლეთ არგენტინის სტანდარტული დრო", "WAT": "დასავლეთ აფრიკის სტანდარტული დრო", "HNCU": "კუბის სტანდარტული დრო", "WIB": "დასავლეთ ინდონეზიის დრო"}, + } +} + +// Locale returns the current translators string locale +func (ka *ka_GE) Locale() string { + return ka.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ka_GE' +func (ka *ka_GE) PluralsCardinal() []locales.PluralRule { + return ka.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ka_GE' +func (ka *ka_GE) PluralsOrdinal() []locales.PluralRule { + return ka.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ka_GE' +func (ka *ka_GE) PluralsRange() []locales.PluralRule { + return ka.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ka_GE' +func (ka *ka_GE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ka_GE' +func (ka *ka_GE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + + if i == 1 { + return locales.PluralRuleOne + } else if (i == 0) || (iMod100 >= 2 && iMod100 <= 20 && (iMod100 == 40 || iMod100 == 60 || iMod100 == 80)) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ka_GE' +func (ka *ka_GE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ka.CardinalPluralRule(num1, v1) + end := ka.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ka *ka_GE) MonthAbbreviated(month time.Month) string { + return ka.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ka *ka_GE) MonthsAbbreviated() []string { + return ka.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ka *ka_GE) MonthNarrow(month time.Month) string { + return ka.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ka *ka_GE) MonthsNarrow() []string { + return ka.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ka *ka_GE) MonthWide(month time.Month) string { + return ka.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ka *ka_GE) MonthsWide() []string { + return ka.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ka *ka_GE) WeekdayAbbreviated(weekday time.Weekday) string { + return ka.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ka *ka_GE) WeekdaysAbbreviated() []string { + return ka.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ka *ka_GE) WeekdayNarrow(weekday time.Weekday) string { + return ka.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ka *ka_GE) WeekdaysNarrow() []string { + return ka.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ka *ka_GE) WeekdayShort(weekday time.Weekday) string { + return ka.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ka *ka_GE) WeekdaysShort() []string { + return ka.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ka *ka_GE) WeekdayWide(weekday time.Weekday) string { + return ka.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ka *ka_GE) WeekdaysWide() []string { + return ka.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ka_GE' and handles both Whole and Real numbers based on 'v' +func (ka *ka_GE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ka.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ka.group) - 1; j >= 0; j-- { + b = append(b, ka.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ka.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ka_GE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ka *ka_GE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ka.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ka.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ka.percentSuffix...) + + b = append(b, ka.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ka_GE' +func (ka *ka_GE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ka.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ka.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ka.group) - 1; j >= 0; j-- { + b = append(b, ka.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ka.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ka.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ka.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ka_GE' +// in accounting notation. +func (ka *ka_GE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ka.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ka.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ka.group) - 1; j >= 0; j-- { + b = append(b, ka.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ka.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ka.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ka.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ka.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ka_GE' +func (ka *ka_GE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ka_GE' +func (ka *ka_GE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ka.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ka_GE' +func (ka *ka_GE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ka.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ka_GE' +func (ka *ka_GE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ka.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ka.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ka_GE' +func (ka *ka_GE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ka.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ka_GE' +func (ka *ka_GE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ka.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ka.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ka_GE' +func (ka *ka_GE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ka.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ka.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ka_GE' +func (ka *ka_GE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ka.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ka.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ka.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ka_GE/ka_GE_test.go b/vendor/github.com/go-playground/locales/ka_GE/ka_GE_test.go new file mode 100644 index 0000000000..7146c3b550 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ka_GE/ka_GE_test.go @@ -0,0 +1,1120 @@ +package ka_GE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ka_GE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kab/kab.go b/vendor/github.com/go-playground/locales/kab/kab.go new file mode 100644 index 0000000000..7f9a7e0e12 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kab/kab.go @@ -0,0 +1,547 @@ +package kab + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kab struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kab' locale +func New() locales.Translator { + return &kab{ + locale: "kab", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DA", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Yen", "Fur", "Meɣ", "Yeb", "May", "Yun", "Yul", "Ɣuc", "Cte", "Tub", "Nun", "Duǧ"}, + monthsNarrow: []string{"", "Y", "F", "M", "Y", "M", "Y", "Y", "Ɣ", "C", "T", "N", "D"}, + monthsWide: []string{"", "Yennayer", "Fuṛar", "Meɣres", "Yebrir", "Mayyu", "Yunyu", "Yulyu", "Ɣuct", "Ctembeṛ", "Tubeṛ", "Nunembeṛ", "Duǧembeṛ"}, + daysAbbreviated: []string{"Yan", "San", "Kraḍ", "Kuẓ", "Sam", "Sḍis", "Say"}, + daysNarrow: []string{"Y", "S", "K", "K", "S", "S", "S"}, + daysWide: []string{"Yanass", "Sanass", "Kraḍass", "Kuẓass", "Samass", "Sḍisass", "Sayass"}, + periodsAbbreviated: []string{"n tufat", "n tmeddit"}, + periodsWide: []string{"n tufat", "n tmeddit"}, + erasAbbreviated: []string{"snd. T.Ɛ", "sld. T.Ɛ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"send talalit n Ɛisa", "seld talalit n Ɛisa"}, + timezones: map[string]string{"MYT": "MYT", "AWST": "AWST", "UYST": "UYST", "VET": "VET", "OEZ": "OEZ", "EDT": "EDT", "AEDT": "AEDT", "GFT": "GFT", "AKST": "AKST", "CDT": "CDT", "ACWST": "ACWST", "JDT": "JDT", "AST": "AST", "HAT": "HAT", "WIB": "WIB", "BOT": "BOT", "HAST": "HAST", "ACWDT": "ACWDT", "NZST": "NZST", "MDT": "MDT", "CHAST": "CHAST", "CAT": "CAT", "JST": "JST", "HNOG": "HNOG", "ARST": "ARST", "HKT": "HKT", "ACDT": "ACDT", "AEST": "AEST", "HNNOMX": "HNNOMX", "ChST": "ChST", "HADT": "HADT", "IST": "IST", "MEZ": "MEZ", "OESZ": "OESZ", "GMT": "GMT", "HNEG": "HNEG", "HNPMX": "HNPMX", "EAT": "EAT", "PDT": "PDT", "HENOMX": "HENOMX", "HEEG": "HEEG", "LHST": "LHST", "CST": "CST", "CHADT": "CHADT", "WARST": "WARST", "HEOG": "HEOG", "HEPM": "HEPM", "WITA": "WITA", "UYT": "UYT", "HEPMX": "HEPMX", "HNCU": "HNCU", "TMST": "TMST", "EST": "EST", "COT": "COT", "∅∅∅": "∅∅∅", "ECT": "ECT", "CLT": "CLT", "WESZ": "WESZ", "SRT": "SRT", "AWDT": "AWDT", "WART": "WART", "HNT": "HNT", "WIT": "WIT", "TMT": "TMT", "ACST": "ACST", "MST": "MST", "COST": "COST", "PST": "PST", "NZDT": "NZDT", "HKST": "HKST", "HNPM": "HNPM", "SAST": "SAST", "GYT": "GYT", "ADT": "ADT", "ART": "ART", "AKDT": "AKDT", "LHDT": "LHDT", "HECU": "HECU", "SGT": "SGT", "MESZ": "MESZ", "CLST": "CLST", "WEZ": "WEZ", "WAT": "WAT", "BT": "BT", "WAST": "WAST"}, + } +} + +// Locale returns the current translators string locale +func (kab *kab) Locale() string { + return kab.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kab' +func (kab *kab) PluralsCardinal() []locales.PluralRule { + return kab.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kab' +func (kab *kab) PluralsOrdinal() []locales.PluralRule { + return kab.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kab' +func (kab *kab) PluralsRange() []locales.PluralRule { + return kab.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kab' +func (kab *kab) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kab' +func (kab *kab) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kab' +func (kab *kab) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kab *kab) MonthAbbreviated(month time.Month) string { + return kab.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kab *kab) MonthsAbbreviated() []string { + return kab.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kab *kab) MonthNarrow(month time.Month) string { + return kab.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kab *kab) MonthsNarrow() []string { + return kab.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kab *kab) MonthWide(month time.Month) string { + return kab.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kab *kab) MonthsWide() []string { + return kab.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kab *kab) WeekdayAbbreviated(weekday time.Weekday) string { + return kab.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kab *kab) WeekdaysAbbreviated() []string { + return kab.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kab *kab) WeekdayNarrow(weekday time.Weekday) string { + return kab.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kab *kab) WeekdaysNarrow() []string { + return kab.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kab *kab) WeekdayShort(weekday time.Weekday) string { + return kab.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kab *kab) WeekdaysShort() []string { + return kab.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kab *kab) WeekdayWide(weekday time.Weekday) string { + return kab.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kab *kab) WeekdaysWide() []string { + return kab.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kab' and handles both Whole and Real numbers based on 'v' +func (kab *kab) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kab' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kab *kab) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kab' +func (kab *kab) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kab.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kab.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kab.group) - 1; j >= 0; j-- { + b = append(b, kab.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kab.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kab.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kab' +// in accounting notation. +func (kab *kab) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kab.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kab.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kab.group) - 1; j >= 0; j-- { + b = append(b, kab.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, kab.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kab.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kab' +func (kab *kab) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kab' +func (kab *kab) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kab.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kab' +func (kab *kab) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kab.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kab' +func (kab *kab) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kab.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kab.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kab' +func (kab *kab) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kab.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kab.periodsAbbreviated[0]...) + } else { + b = append(b, kab.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kab' +func (kab *kab) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kab.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kab.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kab.periodsAbbreviated[0]...) + } else { + b = append(b, kab.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kab' +func (kab *kab) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kab.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kab.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kab.periodsAbbreviated[0]...) + } else { + b = append(b, kab.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kab' +func (kab *kab) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kab.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kab.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kab.periodsAbbreviated[0]...) + } else { + b = append(b, kab.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kab.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kab/kab_test.go b/vendor/github.com/go-playground/locales/kab/kab_test.go new file mode 100644 index 0000000000..0d2fc32a05 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kab/kab_test.go @@ -0,0 +1,1120 @@ +package kab + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kab" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kab_DZ/kab_DZ.go b/vendor/github.com/go-playground/locales/kab_DZ/kab_DZ.go new file mode 100644 index 0000000000..d1e56b8045 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kab_DZ/kab_DZ.go @@ -0,0 +1,547 @@ +package kab_DZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kab_DZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kab_DZ' locale +func New() locales.Translator { + return &kab_DZ{ + locale: "kab_DZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Yen", "Fur", "Meɣ", "Yeb", "May", "Yun", "Yul", "Ɣuc", "Cte", "Tub", "Nun", "Duǧ"}, + monthsNarrow: []string{"", "Y", "F", "M", "Y", "M", "Y", "Y", "Ɣ", "C", "T", "N", "D"}, + monthsWide: []string{"", "Yennayer", "Fuṛar", "Meɣres", "Yebrir", "Mayyu", "Yunyu", "Yulyu", "Ɣuct", "Ctembeṛ", "Tubeṛ", "Nunembeṛ", "Duǧembeṛ"}, + daysAbbreviated: []string{"Yan", "San", "Kraḍ", "Kuẓ", "Sam", "Sḍis", "Say"}, + daysNarrow: []string{"Y", "S", "K", "K", "S", "S", "S"}, + daysWide: []string{"Yanass", "Sanass", "Kraḍass", "Kuẓass", "Samass", "Sḍisass", "Sayass"}, + periodsAbbreviated: []string{"n tufat", "n tmeddit"}, + periodsWide: []string{"n tufat", "n tmeddit"}, + erasAbbreviated: []string{"snd. T.Ɛ", "sld. T.Ɛ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"send talalit n Ɛisa", "seld talalit n Ɛisa"}, + timezones: map[string]string{"CLT": "CLT", "HNPM": "HNPM", "HEOG": "HEOG", "TMT": "TMT", "CHAST": "CHAST", "ACWDT": "ACWDT", "IST": "IST", "ARST": "ARST", "ACDT": "ACDT", "HNPMX": "HNPMX", "PST": "PST", "NZDT": "NZDT", "∅∅∅": "∅∅∅", "CLST": "CLST", "HKT": "HKT", "UYST": "UYST", "WIB": "WIB", "MEZ": "MEZ", "VET": "VET", "COST": "COST", "WIT": "WIT", "HNOG": "HNOG", "ART": "ART", "AKST": "AKST", "ChST": "ChST", "HNCU": "HNCU", "WARST": "WARST", "TMST": "TMST", "COT": "COT", "HNT": "HNT", "HEPM": "HEPM", "CST": "CST", "AWST": "AWST", "MDT": "MDT", "WAST": "WAST", "HAT": "HAT", "LHST": "LHST", "LHDT": "LHDT", "GYT": "GYT", "MYT": "MYT", "EST": "EST", "AST": "AST", "ADT": "ADT", "OESZ": "OESZ", "HKST": "HKST", "BT": "BT", "SAST": "SAST", "JDT": "JDT", "WEZ": "WEZ", "HNEG": "HNEG", "AEDT": "AEDT", "GFT": "GFT", "CDT": "CDT", "BOT": "BOT", "SGT": "SGT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "EDT": "EDT", "HEEG": "HEEG", "HAST": "HAST", "MESZ": "MESZ", "GMT": "GMT", "AWDT": "AWDT", "SRT": "SRT", "EAT": "EAT", "AKDT": "AKDT", "HECU": "HECU", "HADT": "HADT", "ACWST": "ACWST", "WITA": "WITA", "HEPMX": "HEPMX", "JST": "JST", "OEZ": "OEZ", "WART": "WART", "MST": "MST", "ACST": "ACST", "AEST": "AEST", "NZST": "NZST", "CAT": "CAT", "UYT": "UYT", "CHADT": "CHADT", "ECT": "ECT", "PDT": "PDT", "WESZ": "WESZ", "WAT": "WAT"}, + } +} + +// Locale returns the current translators string locale +func (kab *kab_DZ) Locale() string { + return kab.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kab_DZ' +func (kab *kab_DZ) PluralsCardinal() []locales.PluralRule { + return kab.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kab_DZ' +func (kab *kab_DZ) PluralsOrdinal() []locales.PluralRule { + return kab.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kab_DZ' +func (kab *kab_DZ) PluralsRange() []locales.PluralRule { + return kab.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kab_DZ' +func (kab *kab_DZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 0 || i == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kab_DZ' +func (kab *kab_DZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kab_DZ' +func (kab *kab_DZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kab *kab_DZ) MonthAbbreviated(month time.Month) string { + return kab.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kab *kab_DZ) MonthsAbbreviated() []string { + return kab.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kab *kab_DZ) MonthNarrow(month time.Month) string { + return kab.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kab *kab_DZ) MonthsNarrow() []string { + return kab.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kab *kab_DZ) MonthWide(month time.Month) string { + return kab.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kab *kab_DZ) MonthsWide() []string { + return kab.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kab *kab_DZ) WeekdayAbbreviated(weekday time.Weekday) string { + return kab.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kab *kab_DZ) WeekdaysAbbreviated() []string { + return kab.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kab *kab_DZ) WeekdayNarrow(weekday time.Weekday) string { + return kab.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kab *kab_DZ) WeekdaysNarrow() []string { + return kab.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kab *kab_DZ) WeekdayShort(weekday time.Weekday) string { + return kab.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kab *kab_DZ) WeekdaysShort() []string { + return kab.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kab *kab_DZ) WeekdayWide(weekday time.Weekday) string { + return kab.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kab *kab_DZ) WeekdaysWide() []string { + return kab.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kab_DZ' and handles both Whole and Real numbers based on 'v' +func (kab *kab_DZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kab_DZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kab *kab_DZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kab_DZ' +func (kab *kab_DZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kab.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kab.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kab.group) - 1; j >= 0; j-- { + b = append(b, kab.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kab.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kab.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kab_DZ' +// in accounting notation. +func (kab *kab_DZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kab.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kab.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kab.group) - 1; j >= 0; j-- { + b = append(b, kab.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, kab.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kab.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kab_DZ' +func (kab *kab_DZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kab_DZ' +func (kab *kab_DZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kab.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kab_DZ' +func (kab *kab_DZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kab.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kab_DZ' +func (kab *kab_DZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kab.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kab.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kab_DZ' +func (kab *kab_DZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kab.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kab.periodsAbbreviated[0]...) + } else { + b = append(b, kab.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kab_DZ' +func (kab *kab_DZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kab.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kab.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kab.periodsAbbreviated[0]...) + } else { + b = append(b, kab.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kab_DZ' +func (kab *kab_DZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kab.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kab.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kab.periodsAbbreviated[0]...) + } else { + b = append(b, kab.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kab_DZ' +func (kab *kab_DZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kab.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kab.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kab.periodsAbbreviated[0]...) + } else { + b = append(b, kab.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kab.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kab_DZ/kab_DZ_test.go b/vendor/github.com/go-playground/locales/kab_DZ/kab_DZ_test.go new file mode 100644 index 0000000000..856e91e369 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kab_DZ/kab_DZ_test.go @@ -0,0 +1,1120 @@ +package kab_DZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kab_DZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kam/kam.go b/vendor/github.com/go-playground/locales/kam/kam.go new file mode 100644 index 0000000000..6b081652b0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kam/kam.go @@ -0,0 +1,518 @@ +package kam + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kam struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kam' locale +func New() locales.Translator { + return &kam{ + locale: "kam", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Mbe", "Kel", "Ktũ", "Kan", "Ktn", "Tha", "Moo", "Nya", "Knd", "Ĩku", "Ĩkm", "Ĩkl"}, + monthsNarrow: []string{"", "M", "K", "K", "K", "K", "T", "M", "N", "K", "Ĩ", "Ĩ", "Ĩ"}, + monthsWide: []string{"", "Mwai wa mbee", "Mwai wa kelĩ", "Mwai wa katatũ", "Mwai wa kana", "Mwai wa katano", "Mwai wa thanthatũ", "Mwai wa muonza", "Mwai wa nyaanya", "Mwai wa kenda", "Mwai wa ĩkumi", "Mwai wa ĩkumi na ĩmwe", "Mwai wa ĩkumi na ilĩ"}, + daysAbbreviated: []string{"Wky", "Wkw", "Wkl", "Wtũ", "Wkn", "Wtn", "Wth"}, + daysNarrow: []string{"Y", "W", "E", "A", "A", "A", "A"}, + daysWide: []string{"Wa kyumwa", "Wa kwambĩlĩlya", "Wa kelĩ", "Wa katatũ", "Wa kana", "Wa katano", "Wa thanthatũ"}, + periodsAbbreviated: []string{"Ĩyakwakya", "Ĩyawĩoo"}, + periodsWide: []string{"Ĩyakwakya", "Ĩyawĩoo"}, + erasAbbreviated: []string{"MY", "IY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbee wa Yesũ", "Ĩtina wa Yesũ"}, + timezones: map[string]string{"UYST": "UYST", "HADT": "HADT", "CLST": "CLST", "HNNOMX": "HNNOMX", "BT": "BT", "AEDT": "AEDT", "∅∅∅": "∅∅∅", "GYT": "GYT", "HAST": "HAST", "ART": "ART", "GFT": "GFT", "AEST": "AEST", "CST": "CST", "AWDT": "AWDT", "PDT": "PDT", "CAT": "CAT", "NZST": "NZST", "WART": "WART", "WAT": "WAT", "JDT": "JDT", "ADT": "ADT", "EDT": "EDT", "ACDT": "ACDT", "WITA": "WITA", "CHADT": "CHADT", "WARST": "WARST", "HEPM": "HEPM", "LHST": "LHST", "IST": "IST", "MESZ": "MESZ", "HNOG": "HNOG", "EST": "EST", "HNPMX": "HNPMX", "WIT": "WIT", "ACWST": "ACWST", "MST": "MST", "COT": "COT", "HNT": "HNT", "AKST": "AKST", "ChST": "ChST", "LHDT": "LHDT", "MEZ": "MEZ", "WEZ": "WEZ", "HEEG": "HEEG", "HNCU": "HNCU", "ACWDT": "ACWDT", "JST": "JST", "OEZ": "OEZ", "CLT": "CLT", "HAT": "HAT", "PST": "PST", "NZDT": "NZDT", "TMT": "TMT", "CHAST": "CHAST", "GMT": "GMT", "MYT": "MYT", "MDT": "MDT", "HKST": "HKST", "COST": "COST", "SAST": "SAST", "HEPMX": "HEPMX", "HECU": "HECU", "CDT": "CDT", "OESZ": "OESZ", "WESZ": "WESZ", "WAST": "WAST", "HENOMX": "HENOMX", "HNEG": "HNEG", "WIB": "WIB", "SGT": "SGT", "ECT": "ECT", "ARST": "ARST", "HKT": "HKT", "AKDT": "AKDT", "EAT": "EAT", "AST": "AST", "UYT": "UYT", "HNPM": "HNPM", "AWST": "AWST", "BOT": "BOT", "TMST": "TMST", "SRT": "SRT", "VET": "VET", "HEOG": "HEOG", "ACST": "ACST"}, + } +} + +// Locale returns the current translators string locale +func (kam *kam) Locale() string { + return kam.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kam' +func (kam *kam) PluralsCardinal() []locales.PluralRule { + return kam.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kam' +func (kam *kam) PluralsOrdinal() []locales.PluralRule { + return kam.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kam' +func (kam *kam) PluralsRange() []locales.PluralRule { + return kam.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kam' +func (kam *kam) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kam' +func (kam *kam) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kam' +func (kam *kam) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kam *kam) MonthAbbreviated(month time.Month) string { + return kam.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kam *kam) MonthsAbbreviated() []string { + return kam.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kam *kam) MonthNarrow(month time.Month) string { + return kam.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kam *kam) MonthsNarrow() []string { + return kam.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kam *kam) MonthWide(month time.Month) string { + return kam.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kam *kam) MonthsWide() []string { + return kam.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kam *kam) WeekdayAbbreviated(weekday time.Weekday) string { + return kam.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kam *kam) WeekdaysAbbreviated() []string { + return kam.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kam *kam) WeekdayNarrow(weekday time.Weekday) string { + return kam.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kam *kam) WeekdaysNarrow() []string { + return kam.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kam *kam) WeekdayShort(weekday time.Weekday) string { + return kam.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kam *kam) WeekdaysShort() []string { + return kam.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kam *kam) WeekdayWide(weekday time.Weekday) string { + return kam.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kam *kam) WeekdaysWide() []string { + return kam.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kam' and handles both Whole and Real numbers based on 'v' +func (kam *kam) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kam' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kam *kam) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kam' +func (kam *kam) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kam.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kam.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kam.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kam.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kam.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kam' +// in accounting notation. +func (kam *kam) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kam.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kam.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kam.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kam.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kam.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kam.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kam' +func (kam *kam) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kam' +func (kam *kam) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kam.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kam' +func (kam *kam) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kam.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kam' +func (kam *kam) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kam.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kam.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kam' +func (kam *kam) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kam.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kam' +func (kam *kam) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kam.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kam.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kam' +func (kam *kam) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kam.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kam.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kam' +func (kam *kam) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kam.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kam.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kam.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kam/kam_test.go b/vendor/github.com/go-playground/locales/kam/kam_test.go new file mode 100644 index 0000000000..43d5d95ea3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kam/kam_test.go @@ -0,0 +1,1120 @@ +package kam + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kam" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kam_KE/kam_KE.go b/vendor/github.com/go-playground/locales/kam_KE/kam_KE.go new file mode 100644 index 0000000000..97a720a522 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kam_KE/kam_KE.go @@ -0,0 +1,518 @@ +package kam_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kam_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kam_KE' locale +func New() locales.Translator { + return &kam_KE{ + locale: "kam_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Mbe", "Kel", "Ktũ", "Kan", "Ktn", "Tha", "Moo", "Nya", "Knd", "Ĩku", "Ĩkm", "Ĩkl"}, + monthsNarrow: []string{"", "M", "K", "K", "K", "K", "T", "M", "N", "K", "Ĩ", "Ĩ", "Ĩ"}, + monthsWide: []string{"", "Mwai wa mbee", "Mwai wa kelĩ", "Mwai wa katatũ", "Mwai wa kana", "Mwai wa katano", "Mwai wa thanthatũ", "Mwai wa muonza", "Mwai wa nyaanya", "Mwai wa kenda", "Mwai wa ĩkumi", "Mwai wa ĩkumi na ĩmwe", "Mwai wa ĩkumi na ilĩ"}, + daysAbbreviated: []string{"Wky", "Wkw", "Wkl", "Wtũ", "Wkn", "Wtn", "Wth"}, + daysNarrow: []string{"Y", "W", "E", "A", "A", "A", "A"}, + daysWide: []string{"Wa kyumwa", "Wa kwambĩlĩlya", "Wa kelĩ", "Wa katatũ", "Wa kana", "Wa katano", "Wa thanthatũ"}, + periodsAbbreviated: []string{"Ĩyakwakya", "Ĩyawĩoo"}, + periodsWide: []string{"Ĩyakwakya", "Ĩyawĩoo"}, + erasAbbreviated: []string{"MY", "IY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbee wa Yesũ", "Ĩtina wa Yesũ"}, + timezones: map[string]string{"ECT": "ECT", "MESZ": "MESZ", "JDT": "JDT", "CLST": "CLST", "OEZ": "OEZ", "LHDT": "LHDT", "WIT": "WIT", "ADT": "ADT", "GMT": "GMT", "BT": "BT", "LHST": "LHST", "SGT": "SGT", "BOT": "BOT", "NZST": "NZST", "MYT": "MYT", "COST": "COST", "CST": "CST", "HADT": "HADT", "ACWST": "ACWST", "JST": "JST", "WART": "WART", "HNCU": "HNCU", "PDT": "PDT", "CAT": "CAT", "MEZ": "MEZ", "VET": "VET", "WEZ": "WEZ", "ARST": "ARST", "ACDT": "ACDT", "AEST": "AEST", "UYT": "UYT", "CHADT": "CHADT", "HEOG": "HEOG", "WESZ": "WESZ", "MST": "MST", "HNEG": "HNEG", "HNPMX": "HNPMX", "AWDT": "AWDT", "ACWDT": "ACWDT", "NZDT": "NZDT", "TMT": "TMT", "HNNOMX": "HNNOMX", "GFT": "GFT", "HEPM": "HEPM", "SAST": "SAST", "WIB": "WIB", "CDT": "CDT", "CHAST": "CHAST", "IST": "IST", "MDT": "MDT", "COT": "COT", "AEDT": "AEDT", "∅∅∅": "∅∅∅", "AST": "AST", "HAT": "HAT", "EST": "EST", "WITA": "WITA", "UYST": "UYST", "HEPMX": "HEPMX", "WAT": "WAT", "WAST": "WAST", "HNPM": "HNPM", "HECU": "HECU", "PST": "PST", "WARST": "WARST", "HKT": "HKT", "HENOMX": "HENOMX", "TMST": "TMST", "HNT": "HNT", "CLT": "CLT", "ART": "ART", "HKST": "HKST", "AKST": "AKST", "AKDT": "AKDT", "AWST": "AWST", "HAST": "HAST", "HNOG": "HNOG", "EDT": "EDT", "HEEG": "HEEG", "SRT": "SRT", "GYT": "GYT", "OESZ": "OESZ", "ACST": "ACST", "ChST": "ChST", "EAT": "EAT"}, + } +} + +// Locale returns the current translators string locale +func (kam *kam_KE) Locale() string { + return kam.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kam_KE' +func (kam *kam_KE) PluralsCardinal() []locales.PluralRule { + return kam.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kam_KE' +func (kam *kam_KE) PluralsOrdinal() []locales.PluralRule { + return kam.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kam_KE' +func (kam *kam_KE) PluralsRange() []locales.PluralRule { + return kam.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kam_KE' +func (kam *kam_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kam_KE' +func (kam *kam_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kam_KE' +func (kam *kam_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kam *kam_KE) MonthAbbreviated(month time.Month) string { + return kam.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kam *kam_KE) MonthsAbbreviated() []string { + return kam.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kam *kam_KE) MonthNarrow(month time.Month) string { + return kam.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kam *kam_KE) MonthsNarrow() []string { + return kam.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kam *kam_KE) MonthWide(month time.Month) string { + return kam.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kam *kam_KE) MonthsWide() []string { + return kam.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kam *kam_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return kam.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kam *kam_KE) WeekdaysAbbreviated() []string { + return kam.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kam *kam_KE) WeekdayNarrow(weekday time.Weekday) string { + return kam.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kam *kam_KE) WeekdaysNarrow() []string { + return kam.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kam *kam_KE) WeekdayShort(weekday time.Weekday) string { + return kam.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kam *kam_KE) WeekdaysShort() []string { + return kam.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kam *kam_KE) WeekdayWide(weekday time.Weekday) string { + return kam.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kam *kam_KE) WeekdaysWide() []string { + return kam.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kam_KE' and handles both Whole and Real numbers based on 'v' +func (kam *kam_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kam_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kam *kam_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kam_KE' +func (kam *kam_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kam.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kam.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kam.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kam.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kam.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kam_KE' +// in accounting notation. +func (kam *kam_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kam.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kam.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kam.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kam.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kam.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kam.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kam_KE' +func (kam *kam_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kam_KE' +func (kam *kam_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kam.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kam_KE' +func (kam *kam_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kam.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kam_KE' +func (kam *kam_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kam.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kam.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kam_KE' +func (kam *kam_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kam.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kam_KE' +func (kam *kam_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kam.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kam.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kam_KE' +func (kam *kam_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kam.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kam.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kam_KE' +func (kam *kam_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kam.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kam.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kam.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kam_KE/kam_KE_test.go b/vendor/github.com/go-playground/locales/kam_KE/kam_KE_test.go new file mode 100644 index 0000000000..bf7bc46529 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kam_KE/kam_KE_test.go @@ -0,0 +1,1120 @@ +package kam_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kam_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kde/kde.go b/vendor/github.com/go-playground/locales/kde/kde.go new file mode 100644 index 0000000000..f6e9b67a33 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kde/kde.go @@ -0,0 +1,518 @@ +package kde + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kde struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kde' locale +func New() locales.Translator { + return &kde{ + locale: "kde", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Mwedi Ntandi", "Mwedi wa Pili", "Mwedi wa Tatu", "Mwedi wa Nchechi", "Mwedi wa Nnyano", "Mwedi wa Nnyano na Umo", "Mwedi wa Nnyano na Mivili", "Mwedi wa Nnyano na Mitatu", "Mwedi wa Nnyano na Nchechi", "Mwedi wa Nnyano na Nnyano", "Mwedi wa Nnyano na Nnyano na U", "Mwedi wa Nnyano na Nnyano na M"}, + daysAbbreviated: []string{"Ll2", "Ll3", "Ll4", "Ll5", "Ll6", "Ll7", "Ll1"}, + daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"}, + daysWide: []string{"Liduva lyapili", "Liduva lyatatu", "Liduva lyanchechi", "Liduva lyannyano", "Liduva lyannyano na linji", "Liduva lyannyano na mavili", "Liduva litandi"}, + periodsAbbreviated: []string{"Muhi", "Chilo"}, + periodsWide: []string{"Muhi", "Chilo"}, + erasAbbreviated: []string{"AY", "NY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Akanapawa Yesu", "Nankuida Yesu"}, + timezones: map[string]string{"AKST": "AKST", "HKT": "HKT", "WARST": "WARST", "WAT": "WAT", "EDT": "EDT", "HEPMX": "HEPMX", "WIB": "WIB", "HECU": "HECU", "CHAST": "CHAST", "VET": "VET", "∅∅∅": "∅∅∅", "CDT": "CDT", "ADT": "ADT", "WAST": "WAST", "AWST": "AWST", "ECT": "ECT", "WEZ": "WEZ", "WESZ": "WESZ", "HEEG": "HEEG", "HEOG": "HEOG", "MST": "MST", "HAST": "HAST", "PDT": "PDT", "JST": "JST", "WART": "WART", "AEDT": "AEDT", "CST": "CST", "TMST": "TMST", "HNNOMX": "HNNOMX", "HNEG": "HNEG", "ChST": "ChST", "GMT": "GMT", "AST": "AST", "OESZ": "OESZ", "EST": "EST", "SAST": "SAST", "LHST": "LHST", "MEZ": "MEZ", "HEPM": "HEPM", "WIT": "WIT", "CHADT": "CHADT", "ACWDT": "ACWDT", "MESZ": "MESZ", "MYT": "MYT", "UYT": "UYT", "SRT": "SRT", "HNCU": "HNCU", "BOT": "BOT", "SGT": "SGT", "TMT": "TMT", "ART": "ART", "HKST": "HKST", "CAT": "CAT", "ARST": "ARST", "HENOMX": "HENOMX", "HNT": "HNT", "GFT": "GFT", "HNPMX": "HNPMX", "PST": "PST", "ACWST": "ACWST", "ACDT": "ACDT", "OEZ": "OEZ", "ACST": "ACST", "COST": "COST", "WITA": "WITA", "GYT": "GYT", "AWDT": "AWDT", "CLST": "CLST", "HNOG": "HNOG", "BT": "BT", "IST": "IST", "HAT": "HAT", "HNPM": "HNPM", "UYST": "UYST", "LHDT": "LHDT", "EAT": "EAT", "HADT": "HADT", "AEST": "AEST", "AKDT": "AKDT", "NZST": "NZST", "JDT": "JDT", "MDT": "MDT", "NZDT": "NZDT", "CLT": "CLT", "COT": "COT"}, + } +} + +// Locale returns the current translators string locale +func (kde *kde) Locale() string { + return kde.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kde' +func (kde *kde) PluralsCardinal() []locales.PluralRule { + return kde.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kde' +func (kde *kde) PluralsOrdinal() []locales.PluralRule { + return kde.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kde' +func (kde *kde) PluralsRange() []locales.PluralRule { + return kde.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kde' +func (kde *kde) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kde' +func (kde *kde) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kde' +func (kde *kde) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kde *kde) MonthAbbreviated(month time.Month) string { + return kde.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kde *kde) MonthsAbbreviated() []string { + return kde.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kde *kde) MonthNarrow(month time.Month) string { + return kde.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kde *kde) MonthsNarrow() []string { + return kde.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kde *kde) MonthWide(month time.Month) string { + return kde.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kde *kde) MonthsWide() []string { + return kde.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kde *kde) WeekdayAbbreviated(weekday time.Weekday) string { + return kde.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kde *kde) WeekdaysAbbreviated() []string { + return kde.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kde *kde) WeekdayNarrow(weekday time.Weekday) string { + return kde.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kde *kde) WeekdaysNarrow() []string { + return kde.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kde *kde) WeekdayShort(weekday time.Weekday) string { + return kde.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kde *kde) WeekdaysShort() []string { + return kde.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kde *kde) WeekdayWide(weekday time.Weekday) string { + return kde.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kde *kde) WeekdaysWide() []string { + return kde.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kde' and handles both Whole and Real numbers based on 'v' +func (kde *kde) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kde' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kde *kde) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kde' +func (kde *kde) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kde.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kde.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kde.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kde.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kde.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kde' +// in accounting notation. +func (kde *kde) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kde.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kde.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kde.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kde.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kde.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kde.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kde' +func (kde *kde) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kde' +func (kde *kde) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kde.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kde' +func (kde *kde) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kde.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kde' +func (kde *kde) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kde.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kde.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kde' +func (kde *kde) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kde.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kde' +func (kde *kde) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kde.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kde.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kde' +func (kde *kde) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kde.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kde.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kde' +func (kde *kde) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kde.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kde.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kde.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kde/kde_test.go b/vendor/github.com/go-playground/locales/kde/kde_test.go new file mode 100644 index 0000000000..e10259830d --- /dev/null +++ b/vendor/github.com/go-playground/locales/kde/kde_test.go @@ -0,0 +1,1120 @@ +package kde + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kde" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kde_TZ/kde_TZ.go b/vendor/github.com/go-playground/locales/kde_TZ/kde_TZ.go new file mode 100644 index 0000000000..ddf0e3822f --- /dev/null +++ b/vendor/github.com/go-playground/locales/kde_TZ/kde_TZ.go @@ -0,0 +1,518 @@ +package kde_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kde_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kde_TZ' locale +func New() locales.Translator { + return &kde_TZ{ + locale: "kde_TZ", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Mwedi Ntandi", "Mwedi wa Pili", "Mwedi wa Tatu", "Mwedi wa Nchechi", "Mwedi wa Nnyano", "Mwedi wa Nnyano na Umo", "Mwedi wa Nnyano na Mivili", "Mwedi wa Nnyano na Mitatu", "Mwedi wa Nnyano na Nchechi", "Mwedi wa Nnyano na Nnyano", "Mwedi wa Nnyano na Nnyano na U", "Mwedi wa Nnyano na Nnyano na M"}, + daysAbbreviated: []string{"Ll2", "Ll3", "Ll4", "Ll5", "Ll6", "Ll7", "Ll1"}, + daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"}, + daysWide: []string{"Liduva lyapili", "Liduva lyatatu", "Liduva lyanchechi", "Liduva lyannyano", "Liduva lyannyano na linji", "Liduva lyannyano na mavili", "Liduva litandi"}, + periodsAbbreviated: []string{"Muhi", "Chilo"}, + periodsWide: []string{"Muhi", "Chilo"}, + erasAbbreviated: []string{"AY", "NY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Akanapawa Yesu", "Nankuida Yesu"}, + timezones: map[string]string{"HAST": "HAST", "EST": "EST", "COST": "COST", "SRT": "SRT", "HNCU": "HNCU", "WIT": "WIT", "ART": "ART", "LHDT": "LHDT", "EAT": "EAT", "NZST": "NZST", "AKDT": "AKDT", "AEST": "AEST", "LHST": "LHST", "WIB": "WIB", "CST": "CST", "NZDT": "NZDT", "WART": "WART", "HEOG": "HEOG", "MDT": "MDT", "BT": "BT", "HEEG": "HEEG", "HECU": "HECU", "ECT": "ECT", "MESZ": "MESZ", "WEZ": "WEZ", "CLT": "CLT", "UYT": "UYT", "GYT": "GYT", "CAT": "CAT", "ACWST": "ACWST", "ADT": "ADT", "HNOG": "HNOG", "MST": "MST", "ACDT": "ACDT", "CDT": "CDT", "ACST": "ACST", "HENOMX": "HENOMX", "HNPM": "HNPM", "HEPM": "HEPM", "HADT": "HADT", "OEZ": "OEZ", "ARST": "ARST", "HNNOMX": "HNNOMX", "ChST": "ChST", "PDT": "PDT", "MEZ": "MEZ", "TMST": "TMST", "EDT": "EDT", "VET": "VET", "WARST": "WARST", "COT": "COT", "HNEG": "HNEG", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "ACWDT": "ACWDT", "∅∅∅": "∅∅∅", "JST": "JST", "AST": "AST", "TMT": "TMT", "OESZ": "OESZ", "AEDT": "AEDT", "GFT": "GFT", "WITA": "WITA", "UYST": "UYST", "AWDT": "AWDT", "SAST": "SAST", "SGT": "SGT", "PST": "PST", "WESZ": "WESZ", "GMT": "GMT", "CLST": "CLST", "WAT": "WAT", "AWST": "AWST", "CHAST": "CHAST", "BOT": "BOT", "WAST": "WAST", "HNT": "HNT", "HAT": "HAT", "AKST": "AKST", "CHADT": "CHADT", "IST": "IST", "JDT": "JDT", "MYT": "MYT", "HKT": "HKT", "HKST": "HKST"}, + } +} + +// Locale returns the current translators string locale +func (kde *kde_TZ) Locale() string { + return kde.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kde_TZ' +func (kde *kde_TZ) PluralsCardinal() []locales.PluralRule { + return kde.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kde_TZ' +func (kde *kde_TZ) PluralsOrdinal() []locales.PluralRule { + return kde.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kde_TZ' +func (kde *kde_TZ) PluralsRange() []locales.PluralRule { + return kde.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kde_TZ' +func (kde *kde_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kde_TZ' +func (kde *kde_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kde_TZ' +func (kde *kde_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kde *kde_TZ) MonthAbbreviated(month time.Month) string { + return kde.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kde *kde_TZ) MonthsAbbreviated() []string { + return kde.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kde *kde_TZ) MonthNarrow(month time.Month) string { + return kde.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kde *kde_TZ) MonthsNarrow() []string { + return kde.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kde *kde_TZ) MonthWide(month time.Month) string { + return kde.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kde *kde_TZ) MonthsWide() []string { + return kde.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kde *kde_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return kde.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kde *kde_TZ) WeekdaysAbbreviated() []string { + return kde.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kde *kde_TZ) WeekdayNarrow(weekday time.Weekday) string { + return kde.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kde *kde_TZ) WeekdaysNarrow() []string { + return kde.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kde *kde_TZ) WeekdayShort(weekday time.Weekday) string { + return kde.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kde *kde_TZ) WeekdaysShort() []string { + return kde.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kde *kde_TZ) WeekdayWide(weekday time.Weekday) string { + return kde.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kde *kde_TZ) WeekdaysWide() []string { + return kde.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kde_TZ' and handles both Whole and Real numbers based on 'v' +func (kde *kde_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kde_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kde *kde_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kde_TZ' +func (kde *kde_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kde.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kde.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kde.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kde.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kde.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kde_TZ' +// in accounting notation. +func (kde *kde_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kde.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kde.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kde.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kde.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kde.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kde.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kde_TZ' +func (kde *kde_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kde_TZ' +func (kde *kde_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kde.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kde_TZ' +func (kde *kde_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kde.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kde_TZ' +func (kde *kde_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kde.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kde.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kde_TZ' +func (kde *kde_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kde.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kde_TZ' +func (kde *kde_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kde.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kde.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kde_TZ' +func (kde *kde_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kde.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kde.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kde_TZ' +func (kde *kde_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kde.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kde.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kde.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kde_TZ/kde_TZ_test.go b/vendor/github.com/go-playground/locales/kde_TZ/kde_TZ_test.go new file mode 100644 index 0000000000..c32cf8e5d3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kde_TZ/kde_TZ_test.go @@ -0,0 +1,1120 @@ +package kde_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kde_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kea/kea.go b/vendor/github.com/go-playground/locales/kea/kea.go new file mode 100644 index 0000000000..161763d01b --- /dev/null +++ b/vendor/github.com/go-playground/locales/kea/kea.go @@ -0,0 +1,583 @@ +package kea + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kea struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kea' locale +func New() locales.Translator { + return &kea{ + locale: "kea", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "৳", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "$", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "\u200b", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "$", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "៛", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "₸", "₭", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "₮", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "₱", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "$", "SCR", "SDD", "SDG", "SDP", "SEK", "$", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "₺", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Otu", "Nuv", "Diz"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janeru", "Febreru", "Marsu", "Abril", "Maiu", "Junhu", "Julhu", "Agostu", "Setenbru", "Otubru", "Nuvenbru", "Dizenbru"}, + daysAbbreviated: []string{"dum", "sig", "ter", "kua", "kin", "ses", "sab"}, + daysNarrow: []string{"D", "S", "T", "K", "K", "S", "S"}, + daysShort: []string{"du", "si", "te", "ku", "ki", "se", "sa"}, + daysWide: []string{"dumingu", "sigunda-fera", "tersa-fera", "kuarta-fera", "kinta-fera", "sesta-fera", "sabadu"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"AK", "DK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Antis di Kristu", "Dispos di Kristu"}, + timezones: map[string]string{"ECT": "ECT", "HADT": "HADT", "IST": "IST", "HNOG": "HNOG", "HNT": "HNT", "AEST": "Ora Padrãu di Australia Oriental", "SRT": "SRT", "SGT": "SGT", "OESZ": "Ora di Verãu di Europa Oriental", "GFT": "GFT", "HNPM": "HNPM", "CDT": "Ora Sentral di Verãu", "HAST": "HAST", "HKST": "HKST", "HNNOMX": "HNNOMX", "AEDT": "Ora di Verãu di Australia Oriental", "SAST": "Ora di Sul di Afrika", "ART": "ART", "UYT": "UYT", "AWDT": "Ora di Verãu di Australia Osidental", "ACWST": "Ora Padrãu di Australia Sentru-Osidental", "WARST": "WARST", "COST": "COST", "BOT": "BOT", "NZDT": "NZDT", "MESZ": "Ora di Verãu di Europa Sentral", "WAT": "Ora Padrãu di Afrika Osidental", "EST": "Ora Oriental Padrãu", "HNEG": "HNEG", "EAT": "Ora di Afrika Oriental", "CHADT": "CHADT", "CLST": "CLST", "HEOG": "HEOG", "GMT": "GMT", "TMST": "TMST", "COT": "COT", "HNPMX": "HNPMX", "WESZ": "Ora di Verãu di Europa Osidental", "MST": "MST", "HKT": "HKT", "ACST": "Ora Padrãu di Australia Sentral", "HAT": "HAT", "BT": "BT", "LHST": "LHST", "VET": "VET", "MYT": "MYT", "MDT": "MDT", "ARST": "ARST", "HEEG": "HEEG", "WIB": "WIB", "WEZ": "Ora Padrãu di Europa Osidental", "UYST": "UYST", "HEPM": "HEPM", "AWST": "Ora Padrãu di Australia Osidental", "CHAST": "CHAST", "NZST": "NZST", "OEZ": "Ora Padrãu di Europa Oriental", "TMT": "TMT", "∅∅∅": "∅∅∅", "LHDT": "LHDT", "CST": "Ora Sentral Padrãu", "PST": "Ora di Pasifiku Padrãu", "MEZ": "Ora Padrãu di Europa Sentral", "JDT": "JDT", "ACWDT": "Ora di Verãu di Australia Sentru-Osidental", "WART": "WART", "HENOMX": "HENOMX", "HNCU": "HNCU", "WIT": "WIT", "CAT": "Ora di Afrika Sentral", "PDT": "Ora di Pasifiku di Verãu", "JST": "JST", "ADT": "Ora di Verãu di Atlantiku", "ACDT": "Ora di Verãu di Australia Sentral", "AKDT": "AKDT", "ChST": "ChST", "HEPMX": "HEPMX", "AKST": "AKST", "GYT": "GYT", "HECU": "HECU", "CLT": "CLT", "AST": "Ora Padrãu di Atlantiku", "WAST": "Ora di Verão di Afrika Osidental", "EDT": "Ora Oriental di Verãu", "WITA": "WITA"}, + } +} + +// Locale returns the current translators string locale +func (kea *kea) Locale() string { + return kea.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kea' +func (kea *kea) PluralsCardinal() []locales.PluralRule { + return kea.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kea' +func (kea *kea) PluralsOrdinal() []locales.PluralRule { + return kea.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kea' +func (kea *kea) PluralsRange() []locales.PluralRule { + return kea.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kea' +func (kea *kea) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kea' +func (kea *kea) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kea' +func (kea *kea) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kea *kea) MonthAbbreviated(month time.Month) string { + return kea.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kea *kea) MonthsAbbreviated() []string { + return kea.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kea *kea) MonthNarrow(month time.Month) string { + return kea.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kea *kea) MonthsNarrow() []string { + return kea.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kea *kea) MonthWide(month time.Month) string { + return kea.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kea *kea) MonthsWide() []string { + return kea.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kea *kea) WeekdayAbbreviated(weekday time.Weekday) string { + return kea.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kea *kea) WeekdaysAbbreviated() []string { + return kea.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kea *kea) WeekdayNarrow(weekday time.Weekday) string { + return kea.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kea *kea) WeekdaysNarrow() []string { + return kea.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kea *kea) WeekdayShort(weekday time.Weekday) string { + return kea.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kea *kea) WeekdaysShort() []string { + return kea.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kea *kea) WeekdayWide(weekday time.Weekday) string { + return kea.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kea *kea) WeekdaysWide() []string { + return kea.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kea' and handles both Whole and Real numbers based on 'v' +func (kea *kea) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kea.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kea.group) - 1; j >= 0; j-- { + b = append(b, kea.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kea.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kea' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kea *kea) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kea.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kea.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kea.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kea' +func (kea *kea) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kea.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kea.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kea.group) - 1; j >= 0; j-- { + b = append(b, kea.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kea.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kea.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, kea.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kea' +// in accounting notation. +func (kea *kea) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kea.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kea.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kea.group) - 1; j >= 0; j-- { + b = append(b, kea.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, kea.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kea.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kea.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, kea.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kea' +func (kea *kea) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kea' +func (kea *kea) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kea.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kea' +func (kea *kea) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + b = append(b, kea.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kea' +func (kea *kea) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kea.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + b = append(b, kea.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kea' +func (kea *kea) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kea.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kea' +func (kea *kea) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kea.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kea.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kea' +func (kea *kea) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kea.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kea.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kea' +func (kea *kea) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kea.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kea.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kea.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kea/kea_test.go b/vendor/github.com/go-playground/locales/kea/kea_test.go new file mode 100644 index 0000000000..e64e661a66 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kea/kea_test.go @@ -0,0 +1,1120 @@ +package kea + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kea" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kea_CV/kea_CV.go b/vendor/github.com/go-playground/locales/kea_CV/kea_CV.go new file mode 100644 index 0000000000..f799c5e56d --- /dev/null +++ b/vendor/github.com/go-playground/locales/kea_CV/kea_CV.go @@ -0,0 +1,583 @@ +package kea_CV + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kea_CV struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kea_CV' locale +func New() locales.Translator { + return &kea_CV{ + locale: "kea_CV", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Otu", "Nuv", "Diz"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janeru", "Febreru", "Marsu", "Abril", "Maiu", "Junhu", "Julhu", "Agostu", "Setenbru", "Otubru", "Nuvenbru", "Dizenbru"}, + daysAbbreviated: []string{"dum", "sig", "ter", "kua", "kin", "ses", "sab"}, + daysNarrow: []string{"D", "S", "T", "K", "K", "S", "S"}, + daysShort: []string{"du", "si", "te", "ku", "ki", "se", "sa"}, + daysWide: []string{"dumingu", "sigunda-fera", "tersa-fera", "kuarta-fera", "kinta-fera", "sesta-fera", "sabadu"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"am", "pm"}, + erasAbbreviated: []string{"AK", "DK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Antis di Kristu", "Dispos di Kristu"}, + timezones: map[string]string{"SGT": "SGT", "CLT": "CLT", "HENOMX": "HENOMX", "ACST": "Ora Padrãu di Australia Sentral", "SRT": "SRT", "MDT": "Ora di Verãu di Montanha", "HKST": "HKST", "HNNOMX": "HNNOMX", "HNT": "HNT", "AEDT": "Ora di Verãu di Australia Oriental", "AWST": "Ora Padrãu di Australia Osidental", "PST": "Ora di Pasifiku Padrãu", "ACWDT": "Ora di Verãu di Australia Sentru-Osidental", "COT": "COT", "UYST": "UYST", "WIT": "WIT", "HEPMX": "HEPMX", "CDT": "Ora Sentral di Verãu", "HNEG": "HNEG", "BT": "BT", "UYT": "UYT", "PDT": "Ora di Pasifiku di Verãu", "HNOG": "HNOG", "EST": "Ora Oriental Padrãu", "HAT": "HAT", "WIB": "WIB", "CHAST": "CHAST", "JST": "JST", "HEOG": "HEOG", "WAST": "Ora di Verão di Afrika Osidental", "GYT": "GYT", "AWDT": "Ora di Verãu di Australia Osidental", "CHADT": "CHADT", "ACWST": "Ora Padrãu di Australia Sentru-Osidental", "MEZ": "Ora Padrãu di Europa Sentral", "LHDT": "LHDT", "CAT": "Ora di Afrika Sentral", "CLST": "CLST", "TMST": "TMST", "ART": "ART", "WITA": "WITA", "AKDT": "AKDT", "ChST": "ChST", "ARST": "ARST", "TMT": "TMT", "HECU": "HECU", "IST": "IST", "JDT": "JDT", "GMT": "GMT", "WAT": "Ora Padrãu di Afrika Osidental", "HEEG": "HEEG", "HNPM": "HNPM", "HEPM": "HEPM", "BOT": "BOT", "WART": "WART", "AEST": "Ora Padrãu di Australia Oriental", "HNPMX": "HNPMX", "HNCU": "HNCU", "VET": "VET", "OESZ": "Ora di Verãu di Europa Oriental", "AST": "Ora Padrãu di Atlantiku", "MST": "Ora di Montanha Padrãu", "AKST": "AKST", "CST": "Ora Sentral Padrãu", "HADT": "HADT", "OEZ": "Ora Padrãu di Europa Oriental", "WESZ": "Ora di Verãu di Europa Osidental", "ACDT": "Ora di Verãu di Australia Sentral", "LHST": "LHST", "HAST": "HAST", "∅∅∅": "∅∅∅", "MYT": "MYT", "WARST": "WARST", "WEZ": "Ora Padrãu di Europa Osidental", "EDT": "Ora Oriental di Verãu", "ECT": "ECT", "NZST": "NZST", "MESZ": "Ora di Verãu di Europa Sentral", "EAT": "Ora di Afrika Oriental", "NZDT": "NZDT", "ADT": "Ora di Verãu di Atlantiku", "HKT": "HKT", "COST": "COST", "GFT": "GFT", "SAST": "Ora di Sul di Afrika"}, + } +} + +// Locale returns the current translators string locale +func (kea *kea_CV) Locale() string { + return kea.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kea_CV' +func (kea *kea_CV) PluralsCardinal() []locales.PluralRule { + return kea.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kea_CV' +func (kea *kea_CV) PluralsOrdinal() []locales.PluralRule { + return kea.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kea_CV' +func (kea *kea_CV) PluralsRange() []locales.PluralRule { + return kea.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kea_CV' +func (kea *kea_CV) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kea_CV' +func (kea *kea_CV) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kea_CV' +func (kea *kea_CV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kea *kea_CV) MonthAbbreviated(month time.Month) string { + return kea.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kea *kea_CV) MonthsAbbreviated() []string { + return kea.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kea *kea_CV) MonthNarrow(month time.Month) string { + return kea.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kea *kea_CV) MonthsNarrow() []string { + return kea.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kea *kea_CV) MonthWide(month time.Month) string { + return kea.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kea *kea_CV) MonthsWide() []string { + return kea.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kea *kea_CV) WeekdayAbbreviated(weekday time.Weekday) string { + return kea.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kea *kea_CV) WeekdaysAbbreviated() []string { + return kea.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kea *kea_CV) WeekdayNarrow(weekday time.Weekday) string { + return kea.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kea *kea_CV) WeekdaysNarrow() []string { + return kea.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kea *kea_CV) WeekdayShort(weekday time.Weekday) string { + return kea.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kea *kea_CV) WeekdaysShort() []string { + return kea.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kea *kea_CV) WeekdayWide(weekday time.Weekday) string { + return kea.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kea *kea_CV) WeekdaysWide() []string { + return kea.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kea_CV' and handles both Whole and Real numbers based on 'v' +func (kea *kea_CV) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kea.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kea.group) - 1; j >= 0; j-- { + b = append(b, kea.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kea.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kea_CV' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kea *kea_CV) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kea.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kea.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kea.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kea_CV' +func (kea *kea_CV) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kea.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kea.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kea.group) - 1; j >= 0; j-- { + b = append(b, kea.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kea.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kea.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, kea.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kea_CV' +// in accounting notation. +func (kea *kea_CV) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kea.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kea.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kea.group) - 1; j >= 0; j-- { + b = append(b, kea.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, kea.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kea.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kea.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, kea.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kea_CV' +func (kea *kea_CV) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kea_CV' +func (kea *kea_CV) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kea.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kea_CV' +func (kea *kea_CV) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + b = append(b, kea.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kea_CV' +func (kea *kea_CV) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kea.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + b = append(b, kea.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x69}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kea_CV' +func (kea *kea_CV) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kea.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kea_CV' +func (kea *kea_CV) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kea.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kea.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kea_CV' +func (kea *kea_CV) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kea.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kea.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kea_CV' +func (kea *kea_CV) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kea.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kea.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kea.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kea_CV/kea_CV_test.go b/vendor/github.com/go-playground/locales/kea_CV/kea_CV_test.go new file mode 100644 index 0000000000..efc2a9fcd4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kea_CV/kea_CV_test.go @@ -0,0 +1,1120 @@ +package kea_CV + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kea_CV" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/khq/khq.go b/vendor/github.com/go-playground/locales/khq/khq.go new file mode 100644 index 0000000000..364a36bc49 --- /dev/null +++ b/vendor/github.com/go-playground/locales/khq/khq.go @@ -0,0 +1,500 @@ +package khq + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type khq struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'khq' locale +func New() locales.Translator { + return &khq{ + locale: "khq", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"}, + monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"}, + daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alj", "Ass"}, + daysNarrow: []string{"H", "T", "T", "L", "L", "L", "S"}, + daysWide: []string{"Alhadi", "Atini", "Atalata", "Alarba", "Alhamiisa", "Aljuma", "Assabdu"}, + periodsAbbreviated: []string{"Adduha", "Aluula"}, + periodsWide: []string{"Adduha", "Aluula"}, + erasAbbreviated: []string{"IJ", "IZ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Isaa jine", "Isaa jamanoo"}, + timezones: map[string]string{"∅∅∅": "∅∅∅", "HNPM": "HNPM", "HEOG": "HEOG", "COST": "COST", "GYT": "GYT", "CST": "CST", "VET": "VET", "MYT": "MYT", "TMST": "TMST", "UYST": "UYST", "CDT": "CDT", "HAST": "HAST", "ACWST": "ACWST", "MEZ": "MEZ", "JDT": "JDT", "GMT": "GMT", "CLT": "CLT", "BT": "BT", "LHDT": "LHDT", "HNPMX": "HNPMX", "AWST": "AWST", "ACWDT": "ACWDT", "OESZ": "OESZ", "EST": "EST", "HNEG": "HNEG", "HADT": "HADT", "NZST": "NZST", "MESZ": "MESZ", "UYT": "UYT", "AKST": "AKST", "AKDT": "AKDT", "MST": "MST", "MDT": "MDT", "ChST": "ChST", "EDT": "EDT", "HENOMX": "HENOMX", "HNNOMX": "HNNOMX", "EAT": "EAT", "HKT": "HKT", "COT": "COT", "GFT": "GFT", "WIT": "WIT", "IST": "IST", "JST": "JST", "OEZ": "OEZ", "ARST": "ARST", "AEST": "AEST", "WIB": "WIB", "PST": "PST", "AEDT": "AEDT", "HEPM": "HEPM", "LHST": "LHST", "CHAST": "CHAST", "HAT": "HAT", "HEEG": "HEEG", "HEPMX": "HEPMX", "HECU": "HECU", "AWDT": "AWDT", "BOT": "BOT", "PDT": "PDT", "ADT": "ADT", "ACST": "ACST", "SGT": "SGT", "CAT": "CAT", "WESZ": "WESZ", "HKST": "HKST", "HNCU": "HNCU", "HNT": "HNT", "WART": "WART", "ACDT": "ACDT", "CHADT": "CHADT", "AST": "AST", "WARST": "WARST", "CLST": "CLST", "SRT": "SRT", "WEZ": "WEZ", "TMT": "TMT", "NZDT": "NZDT", "SAST": "SAST", "ECT": "ECT", "HNOG": "HNOG", "ART": "ART", "WAT": "WAT", "WAST": "WAST", "WITA": "WITA"}, + } +} + +// Locale returns the current translators string locale +func (khq *khq) Locale() string { + return khq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'khq' +func (khq *khq) PluralsCardinal() []locales.PluralRule { + return khq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'khq' +func (khq *khq) PluralsOrdinal() []locales.PluralRule { + return khq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'khq' +func (khq *khq) PluralsRange() []locales.PluralRule { + return khq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'khq' +func (khq *khq) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'khq' +func (khq *khq) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'khq' +func (khq *khq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (khq *khq) MonthAbbreviated(month time.Month) string { + return khq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (khq *khq) MonthsAbbreviated() []string { + return khq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (khq *khq) MonthNarrow(month time.Month) string { + return khq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (khq *khq) MonthsNarrow() []string { + return khq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (khq *khq) MonthWide(month time.Month) string { + return khq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (khq *khq) MonthsWide() []string { + return khq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (khq *khq) WeekdayAbbreviated(weekday time.Weekday) string { + return khq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (khq *khq) WeekdaysAbbreviated() []string { + return khq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (khq *khq) WeekdayNarrow(weekday time.Weekday) string { + return khq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (khq *khq) WeekdaysNarrow() []string { + return khq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (khq *khq) WeekdayShort(weekday time.Weekday) string { + return khq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (khq *khq) WeekdaysShort() []string { + return khq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (khq *khq) WeekdayWide(weekday time.Weekday) string { + return khq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (khq *khq) WeekdaysWide() []string { + return khq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'khq' and handles both Whole and Real numbers based on 'v' +func (khq *khq) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'khq' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (khq *khq) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'khq' +func (khq *khq) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := khq.currencies[currency] + l := len(s) + len(symbol) + 0 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, khq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(khq.group) - 1; j >= 0; j-- { + b = append(b, khq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, khq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, khq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'khq' +// in accounting notation. +func (khq *khq) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := khq.currencies[currency] + l := len(s) + len(symbol) + 0 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, khq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(khq.group) - 1; j >= 0; j-- { + b = append(b, khq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, khq.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, khq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'khq' +func (khq *khq) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'khq' +func (khq *khq) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, khq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'khq' +func (khq *khq) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, khq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'khq' +func (khq *khq) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, khq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, khq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'khq' +func (khq *khq) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, khq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'khq' +func (khq *khq) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, khq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, khq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'khq' +func (khq *khq) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, khq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, khq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'khq' +func (khq *khq) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, khq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, khq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := khq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/khq/khq_test.go b/vendor/github.com/go-playground/locales/khq/khq_test.go new file mode 100644 index 0000000000..17498b3195 --- /dev/null +++ b/vendor/github.com/go-playground/locales/khq/khq_test.go @@ -0,0 +1,1120 @@ +package khq + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "khq" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/khq_ML/khq_ML.go b/vendor/github.com/go-playground/locales/khq_ML/khq_ML.go new file mode 100644 index 0000000000..a14f6cf7b0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/khq_ML/khq_ML.go @@ -0,0 +1,500 @@ +package khq_ML + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type khq_ML struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'khq_ML' locale +func New() locales.Translator { + return &khq_ML{ + locale: "khq_ML", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"}, + monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"}, + daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alj", "Ass"}, + daysNarrow: []string{"H", "T", "T", "L", "L", "L", "S"}, + daysWide: []string{"Alhadi", "Atini", "Atalata", "Alarba", "Alhamiisa", "Aljuma", "Assabdu"}, + periodsAbbreviated: []string{"Adduha", "Aluula"}, + periodsWide: []string{"Adduha", "Aluula"}, + erasAbbreviated: []string{"IJ", "IZ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Isaa jine", "Isaa jamanoo"}, + timezones: map[string]string{"SRT": "SRT", "CHADT": "CHADT", "HEOG": "HEOG", "EST": "EST", "COT": "COT", "HEEG": "HEEG", "OESZ": "OESZ", "TMST": "TMST", "MDT": "MDT", "CST": "CST", "WIB": "WIB", "HAST": "HAST", "CLT": "CLT", "HKT": "HKT", "GYT": "GYT", "LHST": "LHST", "AWST": "AWST", "BOT": "BOT", "MYT": "MYT", "WAST": "WAST", "ACST": "ACST", "UYST": "UYST", "HNNOMX": "HNNOMX", "LHDT": "LHDT", "ECT": "ECT", "NZDT": "NZDT", "WARST": "WARST", "WAT": "WAT", "EDT": "EDT", "AKDT": "AKDT", "SAST": "SAST", "CHAST": "CHAST", "MESZ": "MESZ", "OEZ": "OEZ", "BT": "BT", "WITA": "WITA", "AST": "AST", "ACDT": "ACDT", "GFT": "GFT", "HNCU": "HNCU", "CAT": "CAT", "MEZ": "MEZ", "WEZ": "WEZ", "WESZ": "WESZ", "ADT": "ADT", "HNT": "HNT", "WIT": "WIT", "HAT": "HAT", "HECU": "HECU", "EAT": "EAT", "ACWDT": "ACWDT", "JDT": "JDT", "GMT": "GMT", "MST": "MST", "ChST": "ChST", "SGT": "SGT", "HADT": "HADT", "IST": "IST", "WART": "WART", "HNPM": "HNPM", "NZST": "NZST", "VET": "VET", "HENOMX": "HENOMX", "AKST": "AKST", "AWDT": "AWDT", "PDT": "PDT", "ART": "ART", "HNEG": "HNEG", "CDT": "CDT", "TMT": "TMT", "HKST": "HKST", "AEDT": "AEDT", "UYT": "UYT", "HEPMX": "HEPMX", "JST": "JST", "CLST": "CLST", "ARST": "ARST", "HNPMX": "HNPMX", "COST": "COST", "AEST": "AEST", "HEPM": "HEPM", "PST": "PST", "ACWST": "ACWST", "∅∅∅": "∅∅∅", "HNOG": "HNOG"}, + } +} + +// Locale returns the current translators string locale +func (khq *khq_ML) Locale() string { + return khq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'khq_ML' +func (khq *khq_ML) PluralsCardinal() []locales.PluralRule { + return khq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'khq_ML' +func (khq *khq_ML) PluralsOrdinal() []locales.PluralRule { + return khq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'khq_ML' +func (khq *khq_ML) PluralsRange() []locales.PluralRule { + return khq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'khq_ML' +func (khq *khq_ML) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'khq_ML' +func (khq *khq_ML) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'khq_ML' +func (khq *khq_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (khq *khq_ML) MonthAbbreviated(month time.Month) string { + return khq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (khq *khq_ML) MonthsAbbreviated() []string { + return khq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (khq *khq_ML) MonthNarrow(month time.Month) string { + return khq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (khq *khq_ML) MonthsNarrow() []string { + return khq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (khq *khq_ML) MonthWide(month time.Month) string { + return khq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (khq *khq_ML) MonthsWide() []string { + return khq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (khq *khq_ML) WeekdayAbbreviated(weekday time.Weekday) string { + return khq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (khq *khq_ML) WeekdaysAbbreviated() []string { + return khq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (khq *khq_ML) WeekdayNarrow(weekday time.Weekday) string { + return khq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (khq *khq_ML) WeekdaysNarrow() []string { + return khq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (khq *khq_ML) WeekdayShort(weekday time.Weekday) string { + return khq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (khq *khq_ML) WeekdaysShort() []string { + return khq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (khq *khq_ML) WeekdayWide(weekday time.Weekday) string { + return khq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (khq *khq_ML) WeekdaysWide() []string { + return khq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'khq_ML' and handles both Whole and Real numbers based on 'v' +func (khq *khq_ML) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'khq_ML' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (khq *khq_ML) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'khq_ML' +func (khq *khq_ML) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := khq.currencies[currency] + l := len(s) + len(symbol) + 0 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, khq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(khq.group) - 1; j >= 0; j-- { + b = append(b, khq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, khq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, khq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'khq_ML' +// in accounting notation. +func (khq *khq_ML) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := khq.currencies[currency] + l := len(s) + len(symbol) + 0 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, khq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(khq.group) - 1; j >= 0; j-- { + b = append(b, khq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, khq.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, khq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'khq_ML' +func (khq *khq_ML) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'khq_ML' +func (khq *khq_ML) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, khq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'khq_ML' +func (khq *khq_ML) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, khq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'khq_ML' +func (khq *khq_ML) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, khq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, khq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'khq_ML' +func (khq *khq_ML) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, khq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'khq_ML' +func (khq *khq_ML) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, khq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, khq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'khq_ML' +func (khq *khq_ML) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, khq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, khq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'khq_ML' +func (khq *khq_ML) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, khq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, khq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := khq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/khq_ML/khq_ML_test.go b/vendor/github.com/go-playground/locales/khq_ML/khq_ML_test.go new file mode 100644 index 0000000000..2fcd5da5c9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/khq_ML/khq_ML_test.go @@ -0,0 +1,1120 @@ +package khq_ML + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "khq_ML" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ki/ki.go b/vendor/github.com/go-playground/locales/ki/ki.go new file mode 100644 index 0000000000..b91503f1ad --- /dev/null +++ b/vendor/github.com/go-playground/locales/ki/ki.go @@ -0,0 +1,518 @@ +package ki + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ki struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ki' locale +func New() locales.Translator { + return &ki{ + locale: "ki", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "JEN", "WKR", "WGT", "WKN", "WTN", "WTD", "WMJ", "WNN", "WKD", "WIK", "WMW", "DIT"}, + monthsNarrow: []string{"", "J", "K", "G", "K", "G", "G", "M", "K", "K", "I", "I", "D"}, + monthsWide: []string{"", "Njenuarĩ", "Mwere wa kerĩ", "Mwere wa gatatũ", "Mwere wa kana", "Mwere wa gatano", "Mwere wa gatandatũ", "Mwere wa mũgwanja", "Mwere wa kanana", "Mwere wa kenda", "Mwere wa ikũmi", "Mwere wa ikũmi na ũmwe", "Ndithemba"}, + daysAbbreviated: []string{"KMA", "NTT", "NMN", "NMT", "ART", "NMA", "NMM"}, + daysNarrow: []string{"K", "N", "N", "N", "A", "N", "N"}, + daysWide: []string{"Kiumia", "Njumatatũ", "Njumaine", "Njumatana", "Aramithi", "Njumaa", "Njumamothi"}, + periodsAbbreviated: []string{"Kiroko", "Hwaĩ-inĩ"}, + periodsWide: []string{"Kiroko", "Hwaĩ-inĩ"}, + erasAbbreviated: []string{"MK", "TK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbere ya Kristo", "Thutha wa Kristo"}, + timezones: map[string]string{"UYT": "UYT", "SAST": "SAST", "CHADT": "CHADT", "GMT": "GMT", "EST": "EST", "WAST": "WAST", "ACDT": "ACDT", "ChST": "ChST", "HECU": "HECU", "SGT": "SGT", "ECT": "ECT", "ACWDT": "ACWDT", "CLST": "CLST", "COST": "COST", "HNNOMX": "HNNOMX", "LHDT": "LHDT", "WIT": "WIT", "HEOG": "HEOG", "WITA": "WITA", "LHST": "LHST", "GYT": "GYT", "BT": "BT", "AWST": "AWST", "WARST": "WARST", "AEST": "AEST", "HEPM": "HEPM", "HADT": "HADT", "IST": "IST", "OESZ": "OESZ", "WEZ": "WEZ", "JST": "JST", "MESZ": "MESZ", "MDT": "MDT", "HNPM": "HNPM", "HAT": "HAT", "AEDT": "AEDT", "CDT": "CDT", "HNCU": "HNCU", "WIB": "WIB", "HAST": "HAST", "OEZ": "OEZ", "CLT": "CLT", "ART": "ART", "WART": "WART", "AKST": "AKST", "AKDT": "AKDT", "HEPMX": "HEPMX", "TMT": "TMT", "ARST": "ARST", "CAT": "CAT", "VET": "VET", "MYT": "MYT", "AST": "AST", "EDT": "EDT", "COT": "COT", "ACST": "ACST", "HEEG": "HEEG", "ACWST": "ACWST", "NZST": "NZST", "JDT": "JDT", "MEZ": "MEZ", "HNPMX": "HNPMX", "EAT": "EAT", "∅∅∅": "∅∅∅", "MST": "MST", "CST": "CST", "BOT": "BOT", "SRT": "SRT", "AWDT": "AWDT", "CHAST": "CHAST", "PST": "PST", "ADT": "ADT", "HKT": "HKT", "HNEG": "HNEG", "HENOMX": "HENOMX", "HNT": "HNT", "GFT": "GFT", "UYST": "UYST", "NZDT": "NZDT", "WESZ": "WESZ", "HNOG": "HNOG", "TMST": "TMST", "PDT": "PDT", "HKST": "HKST", "WAT": "WAT"}, + } +} + +// Locale returns the current translators string locale +func (ki *ki) Locale() string { + return ki.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ki' +func (ki *ki) PluralsCardinal() []locales.PluralRule { + return ki.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ki' +func (ki *ki) PluralsOrdinal() []locales.PluralRule { + return ki.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ki' +func (ki *ki) PluralsRange() []locales.PluralRule { + return ki.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ki' +func (ki *ki) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ki' +func (ki *ki) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ki' +func (ki *ki) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ki *ki) MonthAbbreviated(month time.Month) string { + return ki.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ki *ki) MonthsAbbreviated() []string { + return ki.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ki *ki) MonthNarrow(month time.Month) string { + return ki.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ki *ki) MonthsNarrow() []string { + return ki.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ki *ki) MonthWide(month time.Month) string { + return ki.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ki *ki) MonthsWide() []string { + return ki.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ki *ki) WeekdayAbbreviated(weekday time.Weekday) string { + return ki.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ki *ki) WeekdaysAbbreviated() []string { + return ki.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ki *ki) WeekdayNarrow(weekday time.Weekday) string { + return ki.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ki *ki) WeekdaysNarrow() []string { + return ki.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ki *ki) WeekdayShort(weekday time.Weekday) string { + return ki.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ki *ki) WeekdaysShort() []string { + return ki.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ki *ki) WeekdayWide(weekday time.Weekday) string { + return ki.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ki *ki) WeekdaysWide() []string { + return ki.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ki' and handles both Whole and Real numbers based on 'v' +func (ki *ki) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ki' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ki *ki) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ki' +func (ki *ki) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ki.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ki.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ki.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ki.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ki.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ki' +// in accounting notation. +func (ki *ki) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ki.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ki.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ki.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ki.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ki.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ki.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ki' +func (ki *ki) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ki' +func (ki *ki) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ki.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ki' +func (ki *ki) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ki.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ki' +func (ki *ki) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ki.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ki.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ki' +func (ki *ki) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ki.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ki' +func (ki *ki) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ki.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ki.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ki' +func (ki *ki) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ki.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ki.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ki' +func (ki *ki) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ki.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ki.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ki.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ki/ki_test.go b/vendor/github.com/go-playground/locales/ki/ki_test.go new file mode 100644 index 0000000000..70990041c3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ki/ki_test.go @@ -0,0 +1,1120 @@ +package ki + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ki" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ki_KE/ki_KE.go b/vendor/github.com/go-playground/locales/ki_KE/ki_KE.go new file mode 100644 index 0000000000..dcc1b9bb9f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ki_KE/ki_KE.go @@ -0,0 +1,518 @@ +package ki_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ki_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ki_KE' locale +func New() locales.Translator { + return &ki_KE{ + locale: "ki_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "JEN", "WKR", "WGT", "WKN", "WTN", "WTD", "WMJ", "WNN", "WKD", "WIK", "WMW", "DIT"}, + monthsNarrow: []string{"", "J", "K", "G", "K", "G", "G", "M", "K", "K", "I", "I", "D"}, + monthsWide: []string{"", "Njenuarĩ", "Mwere wa kerĩ", "Mwere wa gatatũ", "Mwere wa kana", "Mwere wa gatano", "Mwere wa gatandatũ", "Mwere wa mũgwanja", "Mwere wa kanana", "Mwere wa kenda", "Mwere wa ikũmi", "Mwere wa ikũmi na ũmwe", "Ndithemba"}, + daysAbbreviated: []string{"KMA", "NTT", "NMN", "NMT", "ART", "NMA", "NMM"}, + daysNarrow: []string{"K", "N", "N", "N", "A", "N", "N"}, + daysWide: []string{"Kiumia", "Njumatatũ", "Njumaine", "Njumatana", "Aramithi", "Njumaa", "Njumamothi"}, + periodsAbbreviated: []string{"Kiroko", "Hwaĩ-inĩ"}, + periodsWide: []string{"Kiroko", "Hwaĩ-inĩ"}, + erasAbbreviated: []string{"MK", "TK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbere ya Kristo", "Thutha wa Kristo"}, + timezones: map[string]string{"HEPM": "HEPM", "LHST": "LHST", "EAT": "EAT", "NZDT": "NZDT", "COST": "COST", "AKDT": "AKDT", "AEDT": "AEDT", "CHAST": "CHAST", "AST": "AST", "TMT": "TMT", "HKST": "HKST", "HAT": "HAT", "SAST": "SAST", "CDT": "CDT", "HNT": "HNT", "SGT": "SGT", "PDT": "PDT", "CST": "CST", "MESZ": "MESZ", "ACST": "ACST", "HNPMX": "HNPMX", "HNCU": "HNCU", "HKT": "HKT", "SRT": "SRT", "BOT": "BOT", "WAST": "WAST", "HADT": "HADT", "JST": "JST", "HNOG": "HNOG", "WIB": "WIB", "AWDT": "AWDT", "PST": "PST", "OESZ": "OESZ", "EDT": "EDT", "MDT": "MDT", "HEPMX": "HEPMX", "CAT": "CAT", "AKST": "AKST", "HECU": "HECU", "OEZ": "OEZ", "LHDT": "LHDT", "GYT": "GYT", "ECT": "ECT", "JDT": "JDT", "CLT": "CLT", "ACDT": "ACDT", "BT": "BT", "HNEG": "HNEG", "ADT": "ADT", "WEZ": "WEZ", "TMST": "TMST", "ACWST": "ACWST", "WARST": "WARST", "HENOMX": "HENOMX", "CHADT": "CHADT", "IST": "IST", "HNNOMX": "HNNOMX", "ACWDT": "ACWDT", "WAT": "WAT", "HAST": "HAST", "WART": "WART", "MYT": "MYT", "EST": "EST", "COT": "COT", "∅∅∅": "∅∅∅", "MST": "MST", "GMT": "GMT", "UYST": "UYST", "HNPM": "HNPM", "NZST": "NZST", "AWST": "AWST", "MEZ": "MEZ", "VET": "VET", "CLST": "CLST", "HEOG": "HEOG", "HEEG": "HEEG", "GFT": "GFT", "ChST": "ChST", "ARST": "ARST", "WESZ": "WESZ", "AEST": "AEST", "UYT": "UYT", "WIT": "WIT", "WITA": "WITA", "ART": "ART"}, + } +} + +// Locale returns the current translators string locale +func (ki *ki_KE) Locale() string { + return ki.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ki_KE' +func (ki *ki_KE) PluralsCardinal() []locales.PluralRule { + return ki.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ki_KE' +func (ki *ki_KE) PluralsOrdinal() []locales.PluralRule { + return ki.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ki_KE' +func (ki *ki_KE) PluralsRange() []locales.PluralRule { + return ki.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ki_KE' +func (ki *ki_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ki_KE' +func (ki *ki_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ki_KE' +func (ki *ki_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ki *ki_KE) MonthAbbreviated(month time.Month) string { + return ki.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ki *ki_KE) MonthsAbbreviated() []string { + return ki.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ki *ki_KE) MonthNarrow(month time.Month) string { + return ki.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ki *ki_KE) MonthsNarrow() []string { + return ki.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ki *ki_KE) MonthWide(month time.Month) string { + return ki.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ki *ki_KE) MonthsWide() []string { + return ki.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ki *ki_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return ki.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ki *ki_KE) WeekdaysAbbreviated() []string { + return ki.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ki *ki_KE) WeekdayNarrow(weekday time.Weekday) string { + return ki.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ki *ki_KE) WeekdaysNarrow() []string { + return ki.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ki *ki_KE) WeekdayShort(weekday time.Weekday) string { + return ki.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ki *ki_KE) WeekdaysShort() []string { + return ki.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ki *ki_KE) WeekdayWide(weekday time.Weekday) string { + return ki.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ki *ki_KE) WeekdaysWide() []string { + return ki.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ki_KE' and handles both Whole and Real numbers based on 'v' +func (ki *ki_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ki_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ki *ki_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ki_KE' +func (ki *ki_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ki.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ki.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ki.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ki.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ki.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ki_KE' +// in accounting notation. +func (ki *ki_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ki.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ki.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ki.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ki.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ki.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ki.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ki_KE' +func (ki *ki_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ki_KE' +func (ki *ki_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ki.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ki_KE' +func (ki *ki_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ki.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ki_KE' +func (ki *ki_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ki.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ki.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ki_KE' +func (ki *ki_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ki.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ki_KE' +func (ki *ki_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ki.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ki.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ki_KE' +func (ki *ki_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ki.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ki.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ki_KE' +func (ki *ki_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ki.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ki.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ki.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ki_KE/ki_KE_test.go b/vendor/github.com/go-playground/locales/ki_KE/ki_KE_test.go new file mode 100644 index 0000000000..e03393b91f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ki_KE/ki_KE_test.go @@ -0,0 +1,1120 @@ +package ki_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ki_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kk/kk.go b/vendor/github.com/go-playground/locales/kk/kk.go new file mode 100644 index 0000000000..6ef96a1206 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kk/kk.go @@ -0,0 +1,621 @@ +package kk + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kk struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kk' locale +func New() locales.Translator { + return &kk{ + locale: "kk", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "₸", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "₽", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "қаң.", "ақп.", "нау.", "сәу.", "мам.", "мау.", "шіл.", "там.", "қыр.", "қаз.", "қар.", "жел."}, + monthsNarrow: []string{"", "Қ", "А", "Н", "С", "М", "М", "Ш", "Т", "Қ", "Қ", "Қ", "Ж"}, + monthsWide: []string{"", "қаңтар", "ақпан", "наурыз", "сәуір", "мамыр", "маусым", "шілде", "тамыз", "қыркүйек", "қазан", "қараша", "желтоқсан"}, + daysAbbreviated: []string{"Жс", "Дс", "Сс", "Ср", "Бс", "Жм", "Сб"}, + daysNarrow: []string{"Ж", "Д", "С", "С", "Б", "Ж", "С"}, + daysShort: []string{"Жс", "Дс", "Сс", "Ср", "Бс", "Жм", "Сб"}, + daysWide: []string{"жексенбі", "дүйсенбі", "сейсенбі", "сәрсенбі", "бейсенбі", "жұма", "сенбі"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"б.з.д.", "б.з."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Біздің заманымызға дейін", "Біздің заманымыз"}, + timezones: map[string]string{"EST": "Солтүстік Америка стандартты шығыс уақыты", "HNT": "Ньюфаундленд стандартты уақыты", "HNPMX": "Мексика стандартты Тынық мұхит уақыты", "HNCU": "Куба стандартты уақыты", "MDT": "MDT", "WAT": "Батыс Африка стандартты уақыты", "HNEG": "Шығыс Гренландия стандартты уақыты", "EAT": "Шығыс Африка уақыты", "SGT": "Сингапур стандартты уақыты", "MEZ": "Орталық Еуропа стандартты уақыты", "WESZ": "Батыс Еуропа жазғы уақыты", "TMT": "Түрікменстан стандартты уақыты", "ACST": "Австралия стандартты орталық уақыты", "AKST": "Аляска стандартты уақыты", "LHST": "Лорд-Хау стандартты уақыты", "AWST": "Австралия стандартты батыс уақыты", "COST": "Колумбия жазғы уақыты", "AKDT": "Аляска жазғы уақыты", "HEPM": "Сен-Пьер және Микелон жазғы уақыты", "HEPMX": "Мексика жазғы Тынық мұхит уақыты", "WIT": "Шығыс Индонезия уақыты", "JDT": "Жапония жазғы уақыты", "HENOMX": "Солтүстік-Батыс Мексика жазғы уақыты", "LHDT": "Лорд-Хау жазғы уақыты", "MST": "MST", "WITA": "Орталық Индонезия уақыты", "ChST": "Чаморро стандартты уақыты", "SRT": "Суринам уақыты", "CDT": "Солтүстік Америка жазғы орталық уақыты", "GFT": "Француз Гвианасы уақыты", "AST": "Атлантика стандартты уақыты", "WART": "Батыс Аргентина стандартты уақыты", "HNOG": "Батыс Гренландия стандартты уақыты", "EDT": "Солтүстік Америка жазғы шығыс уақыты", "HKST": "Гонконг жазғы уақыты", "HNNOMX": "Солтүстік-Батыс Мексика стандартты уақыты", "∅∅∅": "∅∅∅", "VET": "Венесуэла уақыты", "CLST": "Чили жазғы уақыты", "HKT": "Гонконг стандартты уақыты", "HNPM": "Сен-Пьер және Микелон стандартты уақыты", "ACWDT": "Австралия жазғы орталық-батыс уақыты", "NZST": "Жаңа Зеландия стандартты уақыты", "NZDT": "Жаңа Зеландия жазғы уақыты", "JST": "Жапония стандартты уақыты", "ADT": "Атлантика жазғы уақыты", "CLT": "Чили стандартты уақыты", "ACDT": "Австралия жазғы орталық уақыты", "SAST": "Оңтүстік Африка уақыты", "AWDT": "Австралия жазғы батыс уақыты", "PST": "Солтүстік Америка стандартты Тынық мұхиты уақыты", "OEZ": "Шығыс Еуропа стандартты уақыты", "MYT": "Малайзия уақыты", "HEOG": "Батыс Гренландия жазғы уақыты", "ART": "Аргентина стандартты уақыты", "HAT": "Ньюфаундленд жазғы уақыты", "WIB": "Батыс Индонезия уақыты", "BOT": "Боливия уақыты", "COT": "Колумбия стандартты уақыты", "IST": "Үндістан стандартты уақыты", "WARST": "Батыс Аргентина жазғы уақыты", "ARST": "Аргентина жазғы уақыты", "CST": "Солтүстік Америка стандартты орталық уақыты", "PDT": "Солтүстік Америка жазғы Тынық мұхиты уақыты", "MESZ": "Орталық Еуропа жазғы уақыты", "WEZ": "Батыс Еуропа стандартты уақыты", "CHAST": "Чатем стандартты уақыты", "HADT": "Гавай және Алеут аралдары жазғы уақыты", "GMT": "Гринвич уақыты", "HEEG": "Шығыс Гренландия жазғы уақыты", "HECU": "Куба жазғы уақыты", "CHADT": "Чатем жазғы уақыты", "ECT": "Эквадор уақыты", "WAST": "Батыс Африка жазғы уақыты", "BT": "Бутан уақыты", "AEST": "Австралия стандартты шығыс уақыты", "UYST": "Уругвай жазғы уақыты", "HAST": "Гавай және Алеут аралдары стандартты уақыты", "OESZ": "Шығыс Еуропа жазғы уақыты", "TMST": "Түрікменстан жазғы уақыты", "AEDT": "Австралия жазғы шығыс уақыты", "UYT": "Уругвай стандартты уақыты", "GYT": "Гайана уақыты", "CAT": "Орталық Африка уақыты", "ACWST": "Австралия стандартты орталық-батыс уақыты"}, + } +} + +// Locale returns the current translators string locale +func (kk *kk) Locale() string { + return kk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kk' +func (kk *kk) PluralsCardinal() []locales.PluralRule { + return kk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kk' +func (kk *kk) PluralsOrdinal() []locales.PluralRule { + return kk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kk' +func (kk *kk) PluralsRange() []locales.PluralRule { + return kk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kk' +func (kk *kk) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kk' +func (kk *kk) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + + if (nMod10 == 6) || (nMod10 == 9) || (nMod10 == 0 && n != 0) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kk' +func (kk *kk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := kk.CardinalPluralRule(num1, v1) + end := kk.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kk *kk) MonthAbbreviated(month time.Month) string { + return kk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kk *kk) MonthsAbbreviated() []string { + return kk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kk *kk) MonthNarrow(month time.Month) string { + return kk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kk *kk) MonthsNarrow() []string { + return kk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kk *kk) MonthWide(month time.Month) string { + return kk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kk *kk) MonthsWide() []string { + return kk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kk *kk) WeekdayAbbreviated(weekday time.Weekday) string { + return kk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kk *kk) WeekdaysAbbreviated() []string { + return kk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kk *kk) WeekdayNarrow(weekday time.Weekday) string { + return kk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kk *kk) WeekdaysNarrow() []string { + return kk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kk *kk) WeekdayShort(weekday time.Weekday) string { + return kk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kk *kk) WeekdaysShort() []string { + return kk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kk *kk) WeekdayWide(weekday time.Weekday) string { + return kk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kk *kk) WeekdaysWide() []string { + return kk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kk' and handles both Whole and Real numbers based on 'v' +func (kk *kk) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kk.group) - 1; j >= 0; j-- { + b = append(b, kk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kk' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kk *kk) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kk' +func (kk *kk) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kk.group) - 1; j >= 0; j-- { + b = append(b, kk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, kk.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kk' +// in accounting notation. +func (kk *kk) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kk.group) - 1; j >= 0; j-- { + b = append(b, kk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, kk.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, kk.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kk' +func (kk *kk) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kk' +func (kk *kk) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kk.monthsAbbreviated[t.Month()]...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kk' +func (kk *kk) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kk.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kk' +func (kk *kk) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kk.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, kk.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kk' +func (kk *kk) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kk' +func (kk *kk) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kk' +func (kk *kk) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kk' +func (kk *kk) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kk/kk_test.go b/vendor/github.com/go-playground/locales/kk/kk_test.go new file mode 100644 index 0000000000..ccd83e787d --- /dev/null +++ b/vendor/github.com/go-playground/locales/kk/kk_test.go @@ -0,0 +1,1120 @@ +package kk + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kk" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kk_KZ/kk_KZ.go b/vendor/github.com/go-playground/locales/kk_KZ/kk_KZ.go new file mode 100644 index 0000000000..054b5c94fc --- /dev/null +++ b/vendor/github.com/go-playground/locales/kk_KZ/kk_KZ.go @@ -0,0 +1,621 @@ +package kk_KZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kk_KZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kk_KZ' locale +func New() locales.Translator { + return &kk_KZ{ + locale: "kk_KZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "қаң.", "ақп.", "нау.", "сәу.", "мам.", "мау.", "шіл.", "там.", "қыр.", "қаз.", "қар.", "жел."}, + monthsNarrow: []string{"", "Қ", "А", "Н", "С", "М", "М", "Ш", "Т", "Қ", "Қ", "Қ", "Ж"}, + monthsWide: []string{"", "қаңтар", "ақпан", "наурыз", "сәуір", "мамыр", "маусым", "шілде", "тамыз", "қыркүйек", "қазан", "қараша", "желтоқсан"}, + daysAbbreviated: []string{"Жс", "Дс", "Сс", "Ср", "Бс", "Жм", "Сб"}, + daysNarrow: []string{"Ж", "Д", "С", "С", "Б", "Ж", "С"}, + daysShort: []string{"Жс", "Дс", "Сс", "Ср", "Бс", "Жм", "Сб"}, + daysWide: []string{"жексенбі", "дүйсенбі", "сейсенбі", "сәрсенбі", "бейсенбі", "жұма", "сенбі"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"б.з.д.", "б.з."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Біздің заманымызға дейін", "Біздің заманымыз"}, + timezones: map[string]string{"OEZ": "Шығыс Еуропа стандартты уақыты", "TMST": "Түрікменстан жазғы уақыты", "SGT": "Сингапур стандартты уақыты", "BOT": "Боливия уақыты", "NZDT": "Жаңа Зеландия жазғы уақыты", "MEZ": "Орталық Еуропа стандартты уақыты", "HNOG": "Батыс Гренландия стандартты уақыты", "HKT": "Гонконг стандартты уақыты", "LHDT": "Лорд-Хау жазғы уақыты", "GYT": "Гайана уақыты", "HECU": "Куба жазғы уақыты", "ACWST": "Австралия стандартты орталық-батыс уақыты", "JDT": "Жапония жазғы уақыты", "HENOMX": "Солтүстік-Батыс Мексика жазғы уақыты", "AEST": "Австралия стандартты шығыс уақыты", "HEOG": "Батыс Гренландия жазғы уақыты", "COST": "Колумбия жазғы уақыты", "PST": "Солтүстік Америка стандартты Тынық мұхиты уақыты", "HAST": "Гавай және Алеут аралдары стандартты уақыты", "ACWDT": "Австралия жазғы орталық-батыс уақыты", "AKST": "Аляска стандартты уақыты", "ChST": "Чаморро стандартты уақыты", "WIT": "Шығыс Индонезия уақыты", "AWST": "Австралия стандартты батыс уақыты", "MST": "MST", "ARST": "Аргентина жазғы уақыты", "ACST": "Австралия стандартты орталық уақыты", "BT": "Бутан уақыты", "HNEG": "Шығыс Гренландия стандартты уақыты", "CHADT": "Чатем жазғы уақыты", "HADT": "Гавай және Алеут аралдары жазғы уақыты", "CAT": "Орталық Африка уақыты", "ART": "Аргентина стандартты уақыты", "EST": "Солтүстік Америка стандартты шығыс уақыты", "HNNOMX": "Солтүстік-Батыс Мексика стандартты уақыты", "HNT": "Ньюфаундленд стандартты уақыты", "WITA": "Орталық Индонезия уақыты", "ECT": "Эквадор уақыты", "VET": "Венесуэла уақыты", "GMT": "Гринвич уақыты", "LHST": "Лорд-Хау стандартты уақыты", "MESZ": "Орталық Еуропа жазғы уақыты", "UYT": "Уругвай стандартты уақыты", "MDT": "MDT", "WAT": "Батыс Африка стандартты уақыты", "EDT": "Солтүстік Америка жазғы шығыс уақыты", "HKST": "Гонконг жазғы уақыты", "HEEG": "Шығыс Гренландия жазғы уақыты", "HEPM": "Сен-Пьер және Микелон жазғы уақыты", "WART": "Батыс Аргентина стандартты уақыты", "MYT": "Малайзия уақыты", "TMT": "Түрікменстан стандартты уақыты", "ACDT": "Австралия жазғы орталық уақыты", "HAT": "Ньюфаундленд жазғы уақыты", "GFT": "Француз Гвианасы уақыты", "SRT": "Суринам уақыты", "HNCU": "Куба стандартты уақыты", "∅∅∅": "Амазон жазғы уақыты", "NZST": "Жаңа Зеландия стандартты уақыты", "IST": "Үндістан стандартты уақыты", "SAST": "Оңтүстік Африка уақыты", "PDT": "Солтүстік Америка жазғы Тынық мұхиты уақыты", "WARST": "Батыс Аргентина жазғы уақыты", "WEZ": "Батыс Еуропа стандартты уақыты", "OESZ": "Шығыс Еуропа жазғы уақыты", "WESZ": "Батыс Еуропа жазғы уақыты", "AKDT": "Аляска жазғы уақыты", "AEDT": "Австралия жазғы шығыс уақыты", "CHAST": "Чатем стандартты уақыты", "JST": "Жапония стандартты уақыты", "ADT": "Атлантика жазғы уақыты", "WAST": "Батыс Африка жазғы уақыты", "HEPMX": "Мексика жазғы Тынық мұхит уақыты", "WIB": "Батыс Индонезия уақыты", "CDT": "Солтүстік Америка жазғы орталық уақыты", "AWDT": "Австралия жазғы батыс уақыты", "CLST": "Чили жазғы уақыты", "AST": "Атлантика стандартты уақыты", "UYST": "Уругвай жазғы уақыты", "HNPM": "Сен-Пьер және Микелон стандартты уақыты", "CLT": "Чили стандартты уақыты", "COT": "Колумбия стандартты уақыты", "CST": "Солтүстік Америка стандартты орталық уақыты", "HNPMX": "Мексика стандартты Тынық мұхит уақыты", "EAT": "Шығыс Африка уақыты"}, + } +} + +// Locale returns the current translators string locale +func (kk *kk_KZ) Locale() string { + return kk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kk_KZ' +func (kk *kk_KZ) PluralsCardinal() []locales.PluralRule { + return kk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kk_KZ' +func (kk *kk_KZ) PluralsOrdinal() []locales.PluralRule { + return kk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kk_KZ' +func (kk *kk_KZ) PluralsRange() []locales.PluralRule { + return kk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kk_KZ' +func (kk *kk_KZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kk_KZ' +func (kk *kk_KZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + + if (nMod10 == 6) || (nMod10 == 9) || (nMod10 == 0 && n != 0) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kk_KZ' +func (kk *kk_KZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := kk.CardinalPluralRule(num1, v1) + end := kk.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kk *kk_KZ) MonthAbbreviated(month time.Month) string { + return kk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kk *kk_KZ) MonthsAbbreviated() []string { + return kk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kk *kk_KZ) MonthNarrow(month time.Month) string { + return kk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kk *kk_KZ) MonthsNarrow() []string { + return kk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kk *kk_KZ) MonthWide(month time.Month) string { + return kk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kk *kk_KZ) MonthsWide() []string { + return kk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kk *kk_KZ) WeekdayAbbreviated(weekday time.Weekday) string { + return kk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kk *kk_KZ) WeekdaysAbbreviated() []string { + return kk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kk *kk_KZ) WeekdayNarrow(weekday time.Weekday) string { + return kk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kk *kk_KZ) WeekdaysNarrow() []string { + return kk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kk *kk_KZ) WeekdayShort(weekday time.Weekday) string { + return kk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kk *kk_KZ) WeekdaysShort() []string { + return kk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kk *kk_KZ) WeekdayWide(weekday time.Weekday) string { + return kk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kk *kk_KZ) WeekdaysWide() []string { + return kk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kk_KZ' and handles both Whole and Real numbers based on 'v' +func (kk *kk_KZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kk.group) - 1; j >= 0; j-- { + b = append(b, kk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kk_KZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kk *kk_KZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kk_KZ' +func (kk *kk_KZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kk.group) - 1; j >= 0; j-- { + b = append(b, kk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, kk.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kk_KZ' +// in accounting notation. +func (kk *kk_KZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(kk.group) - 1; j >= 0; j-- { + b = append(b, kk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, kk.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, kk.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kk_KZ' +func (kk *kk_KZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kk_KZ' +func (kk *kk_KZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kk.monthsAbbreviated[t.Month()]...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kk_KZ' +func (kk *kk_KZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kk.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kk_KZ' +func (kk *kk_KZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kk.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, kk.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kk_KZ' +func (kk *kk_KZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kk_KZ' +func (kk *kk_KZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kk_KZ' +func (kk *kk_KZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kk_KZ' +func (kk *kk_KZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kk_KZ/kk_KZ_test.go b/vendor/github.com/go-playground/locales/kk_KZ/kk_KZ_test.go new file mode 100644 index 0000000000..71c78e4f7f --- /dev/null +++ b/vendor/github.com/go-playground/locales/kk_KZ/kk_KZ_test.go @@ -0,0 +1,1120 @@ +package kk_KZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kk_KZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kkj/kkj.go b/vendor/github.com/go-playground/locales/kkj/kkj.go new file mode 100644 index 0000000000..2e3a307382 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kkj/kkj.go @@ -0,0 +1,450 @@ +package kkj + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kkj struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kkj' locale +func New() locales.Translator { + return &kkj{ + locale: "kkj", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsWide: []string{"", "pamba", "wanja", "mbiyɔ mɛndoŋgɔ", "Nyɔlɔmbɔŋgɔ", "Mɔnɔ ŋgbanja", "Nyaŋgwɛ ŋgbanja", "kuŋgwɛ", "fɛ", "njapi", "nyukul", "11", "ɓulɓusɛ"}, + daysAbbreviated: []string{"sɔndi", "lundi", "mardi", "mɛrkɛrɛdi", "yedi", "vaŋdɛrɛdi", "mɔnɔ sɔndi"}, + daysNarrow: []string{"so", "lu", "ma", "mɛ", "ye", "va", "ms"}, + daysShort: []string{"sɔndi", "lundi", "mardi", "mɛrkɛrɛdi", "yedi", "vaŋdɛrɛdi", "mɔnɔ sɔndi"}, + daysWide: []string{"sɔndi", "lundi", "mardi", "mɛrkɛrɛdi", "yedi", "vaŋdɛrɛdi", "mɔnɔ sɔndi"}, + timezones: map[string]string{"WART": "WART", "HEPMX": "HEPMX", "WIT": "WIT", "WEZ": "WEZ", "HEOG": "HEOG", "TMST": "TMST", "ChST": "ChST", "CDT": "CDT", "CHADT": "CHADT", "NZST": "NZST", "NZDT": "NZDT", "WARST": "WARST", "HNPM": "HNPM", "ECT": "ECT", "VET": "VET", "UYST": "UYST", "COST": "COST", "GFT": "GFT", "HEPM": "HEPM", "HNPMX": "HNPMX", "IST": "IST", "WAST": "WAST", "AEDT": "AEDT", "LHDT": "LHDT", "GMT": "GMT", "MST": "MST", "BT": "BT", "HNT": "HNT", "HADT": "HADT", "ACWDT": "ACWDT", "CLT": "CLT", "WESZ": "WESZ", "ACDT": "ACDT", "HENOMX": "HENOMX", "EAT": "EAT", "WIB": "WIB", "PST": "PST", "HAST": "HAST", "OEZ": "OEZ", "JDT": "JDT", "EST": "EST", "HEEG": "HEEG", "LHST": "LHST", "HECU": "HECU", "CLST": "CLST", "HNEG": "HNEG", "∅∅∅": "∅∅∅", "JST": "JST", "EDT": "EDT", "WAT": "WAT", "HAT": "HAT", "SAST": "SAST", "HNCU": "HNCU", "ARST": "ARST", "HNNOMX": "HNNOMX", "AEST": "AEST", "SRT": "SRT", "ACWST": "ACWST", "ART": "ART", "COT": "COT", "SGT": "SGT", "MESZ": "MESZ", "OESZ": "OESZ", "HKST": "HKST", "UYT": "UYT", "GYT": "GYT", "CST": "CST", "MEZ": "MEZ", "MYT": "MYT", "TMT": "TMT", "MDT": "MDT", "WITA": "WITA", "CHAST": "CHAST", "BOT": "BOT", "CAT": "CAT", "HNOG": "HNOG", "ADT": "ADT", "HKT": "HKT", "AKST": "AKST", "AWST": "AWST", "AWDT": "AWDT", "AST": "AST", "AKDT": "AKDT", "PDT": "PDT", "ACST": "ACST"}, + } +} + +// Locale returns the current translators string locale +func (kkj *kkj) Locale() string { + return kkj.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kkj' +func (kkj *kkj) PluralsCardinal() []locales.PluralRule { + return kkj.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kkj' +func (kkj *kkj) PluralsOrdinal() []locales.PluralRule { + return kkj.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kkj' +func (kkj *kkj) PluralsRange() []locales.PluralRule { + return kkj.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kkj' +func (kkj *kkj) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kkj' +func (kkj *kkj) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kkj' +func (kkj *kkj) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kkj *kkj) MonthAbbreviated(month time.Month) string { + return kkj.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kkj *kkj) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kkj *kkj) MonthNarrow(month time.Month) string { + return kkj.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kkj *kkj) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kkj *kkj) MonthWide(month time.Month) string { + return kkj.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kkj *kkj) MonthsWide() []string { + return kkj.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kkj *kkj) WeekdayAbbreviated(weekday time.Weekday) string { + return kkj.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kkj *kkj) WeekdaysAbbreviated() []string { + return kkj.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kkj *kkj) WeekdayNarrow(weekday time.Weekday) string { + return kkj.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kkj *kkj) WeekdaysNarrow() []string { + return kkj.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kkj *kkj) WeekdayShort(weekday time.Weekday) string { + return kkj.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kkj *kkj) WeekdaysShort() []string { + return kkj.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kkj *kkj) WeekdayWide(weekday time.Weekday) string { + return kkj.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kkj *kkj) WeekdaysWide() []string { + return kkj.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kkj' and handles both Whole and Real numbers based on 'v' +func (kkj *kkj) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kkj' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kkj *kkj) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kkj' +func (kkj *kkj) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kkj.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kkj.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kkj.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, kkj.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, kkj.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kkj.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kkj' +// in accounting notation. +func (kkj *kkj) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kkj.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kkj.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kkj.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, kkj.currencyNegativePrefix[j]) + } + + b = append(b, kkj.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kkj.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, kkj.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, kkj.currencyNegativeSuffix...) + } else { + + b = append(b, kkj.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kkj' +func (kkj *kkj) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kkj' +func (kkj *kkj) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kkj.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kkj' +func (kkj *kkj) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kkj.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kkj' +func (kkj *kkj) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kkj.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kkj.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kkj' +func (kkj *kkj) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kkj.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kkj' +func (kkj *kkj) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kkj.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kkj.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kkj' +func (kkj *kkj) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kkj' +func (kkj *kkj) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kkj/kkj_test.go b/vendor/github.com/go-playground/locales/kkj/kkj_test.go new file mode 100644 index 0000000000..bfab5ad0f8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kkj/kkj_test.go @@ -0,0 +1,1120 @@ +package kkj + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kkj" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kkj_CM/kkj_CM.go b/vendor/github.com/go-playground/locales/kkj_CM/kkj_CM.go new file mode 100644 index 0000000000..d64d560731 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kkj_CM/kkj_CM.go @@ -0,0 +1,450 @@ +package kkj_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kkj_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kkj_CM' locale +func New() locales.Translator { + return &kkj_CM{ + locale: "kkj_CM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsWide: []string{"", "pamba", "wanja", "mbiyɔ mɛndoŋgɔ", "Nyɔlɔmbɔŋgɔ", "Mɔnɔ ŋgbanja", "Nyaŋgwɛ ŋgbanja", "kuŋgwɛ", "fɛ", "njapi", "nyukul", "11", "ɓulɓusɛ"}, + daysAbbreviated: []string{"sɔndi", "lundi", "mardi", "mɛrkɛrɛdi", "yedi", "vaŋdɛrɛdi", "mɔnɔ sɔndi"}, + daysNarrow: []string{"so", "lu", "ma", "mɛ", "ye", "va", "ms"}, + daysShort: []string{"sɔndi", "lundi", "mardi", "mɛrkɛrɛdi", "yedi", "vaŋdɛrɛdi", "mɔnɔ sɔndi"}, + daysWide: []string{"sɔndi", "lundi", "mardi", "mɛrkɛrɛdi", "yedi", "vaŋdɛrɛdi", "mɔnɔ sɔndi"}, + timezones: map[string]string{"HNEG": "HNEG", "CST": "CST", "MYT": "MYT", "WARST": "WARST", "HENOMX": "HENOMX", "AEDT": "AEDT", "HNPM": "HNPM", "HNPMX": "HNPMX", "GYT": "GYT", "CHADT": "CHADT", "BOT": "BOT", "ACDT": "ACDT", "∅∅∅": "∅∅∅", "CDT": "CDT", "VET": "VET", "CLST": "CLST", "EST": "EST", "WITA": "WITA", "HNCU": "HNCU", "PST": "PST", "JST": "JST", "HEOG": "HEOG", "OESZ": "OESZ", "WAST": "WAST", "UYT": "UYT", "SAST": "SAST", "ECT": "ECT", "AKDT": "AKDT", "LHST": "LHST", "SGT": "SGT", "MESZ": "MESZ", "TMST": "TMST", "ARST": "ARST", "HKT": "HKT", "HAT": "HAT", "EAT": "EAT", "WIT": "WIT", "ACWST": "ACWST", "HEPM": "HEPM", "LHDT": "LHDT", "HADT": "HADT", "CAT": "CAT", "NZDT": "NZDT", "CLT": "CLT", "WESZ": "WESZ", "WAT": "WAT", "COST": "COST", "GFT": "GFT", "AWST": "AWST", "ADT": "ADT", "WIB": "WIB", "IST": "IST", "ACWDT": "ACWDT", "OEZ": "OEZ", "MST": "MST", "EDT": "EDT", "AEST": "AEST", "AWDT": "AWDT", "COT": "COT", "HNT": "HNT", "AKST": "AKST", "PDT": "PDT", "HAST": "HAST", "HNOG": "HNOG", "MDT": "MDT", "HKST": "HKST", "BT": "BT", "NZST": "NZST", "WART": "WART", "GMT": "GMT", "ACST": "ACST", "MEZ": "MEZ", "AST": "AST", "WEZ": "WEZ", "TMT": "TMT", "ART": "ART", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "JDT": "JDT", "ChST": "ChST", "UYST": "UYST", "HEPMX": "HEPMX", "SRT": "SRT", "HECU": "HECU", "CHAST": "CHAST"}, + } +} + +// Locale returns the current translators string locale +func (kkj *kkj_CM) Locale() string { + return kkj.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kkj_CM' +func (kkj *kkj_CM) PluralsCardinal() []locales.PluralRule { + return kkj.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kkj_CM' +func (kkj *kkj_CM) PluralsOrdinal() []locales.PluralRule { + return kkj.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kkj_CM' +func (kkj *kkj_CM) PluralsRange() []locales.PluralRule { + return kkj.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kkj_CM' +func (kkj *kkj_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kkj_CM' +func (kkj *kkj_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kkj_CM' +func (kkj *kkj_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kkj *kkj_CM) MonthAbbreviated(month time.Month) string { + return kkj.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kkj *kkj_CM) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kkj *kkj_CM) MonthNarrow(month time.Month) string { + return kkj.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kkj *kkj_CM) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kkj *kkj_CM) MonthWide(month time.Month) string { + return kkj.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kkj *kkj_CM) MonthsWide() []string { + return kkj.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kkj *kkj_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return kkj.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kkj *kkj_CM) WeekdaysAbbreviated() []string { + return kkj.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kkj *kkj_CM) WeekdayNarrow(weekday time.Weekday) string { + return kkj.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kkj *kkj_CM) WeekdaysNarrow() []string { + return kkj.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kkj *kkj_CM) WeekdayShort(weekday time.Weekday) string { + return kkj.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kkj *kkj_CM) WeekdaysShort() []string { + return kkj.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kkj *kkj_CM) WeekdayWide(weekday time.Weekday) string { + return kkj.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kkj *kkj_CM) WeekdaysWide() []string { + return kkj.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kkj_CM' and handles both Whole and Real numbers based on 'v' +func (kkj *kkj_CM) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kkj_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kkj *kkj_CM) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kkj_CM' +func (kkj *kkj_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kkj.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kkj.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kkj.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, kkj.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, kkj.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kkj.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kkj_CM' +// in accounting notation. +func (kkj *kkj_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kkj.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kkj.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kkj.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, kkj.currencyNegativePrefix[j]) + } + + b = append(b, kkj.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kkj.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, kkj.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, kkj.currencyNegativeSuffix...) + } else { + + b = append(b, kkj.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kkj_CM' +func (kkj *kkj_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kkj_CM' +func (kkj *kkj_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kkj.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kkj_CM' +func (kkj *kkj_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kkj.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kkj_CM' +func (kkj *kkj_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kkj.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kkj.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kkj_CM' +func (kkj *kkj_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kkj.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kkj_CM' +func (kkj *kkj_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kkj.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kkj.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kkj_CM' +func (kkj *kkj_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kkj_CM' +func (kkj *kkj_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kkj_CM/kkj_CM_test.go b/vendor/github.com/go-playground/locales/kkj_CM/kkj_CM_test.go new file mode 100644 index 0000000000..eb9a7aa112 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kkj_CM/kkj_CM_test.go @@ -0,0 +1,1120 @@ +package kkj_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kkj_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kl/kl.go b/vendor/github.com/go-playground/locales/kl/kl.go new file mode 100644 index 0000000000..c970aaf99a --- /dev/null +++ b/vendor/github.com/go-playground/locales/kl/kl.go @@ -0,0 +1,649 @@ +package kl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kl' locale +func New() locales.Translator { + return &kl{ + locale: "kl", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "kr.", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "Nkr", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "Skr", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "aug", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "martsi", "aprili", "maji", "juni", "juli", "augustusi", "septemberi", "oktoberi", "novemberi", "decemberi"}, + daysAbbreviated: []string{"sab", "ata", "mar", "pin", "sis", "tal", "arf"}, + daysNarrow: []string{"S", "A", "M", "P", "S", "T", "A"}, + daysShort: []string{"sab", "ata", "mar", "pin", "sis", "tal", "arf"}, + daysWide: []string{"sabaat", "ataasinngorneq", "marlunngorneq", "pingasunngorneq", "sisamanngorneq", "tallimanngorneq", "arfininngorneq"}, + periodsAbbreviated: []string{"u.t.", "u.k."}, + periodsWide: []string{"ulloqeqqata-tungaa", "ulloqeqqata-kingorna"}, + erasAbbreviated: []string{"Kr.in.si.", "Kr.in.king."}, + erasNarrow: []string{"Kr.s.", "Kr.k."}, + erasWide: []string{"Kristusip inunngornerata siornagut", "Kristusip inunngornerata kingornagut"}, + timezones: map[string]string{"EAT": "EAT", "AWDT": "AWDT", "WART": "WART", "OESZ": "OESZ", "TMST": "TMST", "HEEG": "HEEG", "AEST": "AEST", "SRT": "SRT", "ARST": "ARST", "EDT": "EDT", "HNPMX": "HNPMX", "AWST": "AWST", "CLST": "CLST", "ADT": "ADT", "HAT": "HAT", "MST": "MST", "UYT": "UYT", "WITA": "WITA", "UYST": "UYST", "HEOG": "HEOG", "MESZ": "MESZ", "WIB": "WIB", "ACWST": "ACWST", "JST": "JST", "PST": "PST", "CHADT": "CHADT", "IST": "IST", "OEZ": "OEZ", "HNPM": "HNPM", "LHST": "LHST", "GYT": "GYT", "AKST": "AKST", "ACWDT": "ACWDT", "HNOG": "HNOG", "WAST": "WAST", "HENOMX": "HENOMX", "COST": "COST", "LHDT": "LHDT", "NZDT": "NZDT", "VET": "VET", "HADT": "HADT", "WEZ": "WEZ", "WESZ": "WESZ", "MYT": "MYT", "EST": "EST", "HEPM": "HEPM", "CST": "CST", "WIT": "WIT", "ACDT": "ACDT", "GFT": "GFT", "HECU": "HECU", "PDT": "PDT", "GMT": "GMT", "COT": "COT", "BT": "BT", "HNT": "HNT", "MDT": "MDT", "HKT": "HKT", "HNCU": "HNCU", "TMT": "TMT", "ART": "ART", "BOT": "BOT", "HAST": "HAST", "JDT": "JDT", "HNEG": "HNEG", "HEPMX": "HEPMX", "SAST": "SAST", "WARST": "WARST", "AST": "AST", "CHAST": "CHAST", "NZST": "NZST", "CAT": "CAT", "HKST": "HKST", "HNNOMX": "HNNOMX", "∅∅∅": "∅∅∅", "CDT": "CDT", "MEZ": "MEZ", "ECT": "ECT", "ACST": "ACST", "AEDT": "AEDT", "AKDT": "AKDT", "ChST": "ChST", "SGT": "SGT", "CLT": "CLT", "WAT": "WAT"}, + } +} + +// Locale returns the current translators string locale +func (kl *kl) Locale() string { + return kl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kl' +func (kl *kl) PluralsCardinal() []locales.PluralRule { + return kl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kl' +func (kl *kl) PluralsOrdinal() []locales.PluralRule { + return kl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kl' +func (kl *kl) PluralsRange() []locales.PluralRule { + return kl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kl' +func (kl *kl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kl' +func (kl *kl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kl' +func (kl *kl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kl *kl) MonthAbbreviated(month time.Month) string { + return kl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kl *kl) MonthsAbbreviated() []string { + return kl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kl *kl) MonthNarrow(month time.Month) string { + return kl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kl *kl) MonthsNarrow() []string { + return kl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kl *kl) MonthWide(month time.Month) string { + return kl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kl *kl) MonthsWide() []string { + return kl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kl *kl) WeekdayAbbreviated(weekday time.Weekday) string { + return kl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kl *kl) WeekdaysAbbreviated() []string { + return kl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kl *kl) WeekdayNarrow(weekday time.Weekday) string { + return kl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kl *kl) WeekdaysNarrow() []string { + return kl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kl *kl) WeekdayShort(weekday time.Weekday) string { + return kl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kl *kl) WeekdaysShort() []string { + return kl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kl *kl) WeekdayWide(weekday time.Weekday) string { + return kl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kl *kl) WeekdaysWide() []string { + return kl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kl' and handles both Whole and Real numbers based on 'v' +func (kl *kl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(kl.minus) - 1; j >= 0; j-- { + b = append(b, kl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kl *kl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(kl.minus) - 1; j >= 0; j-- { + b = append(b, kl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kl.percentSuffix...) + + b = append(b, kl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kl' +func (kl *kl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + for j := len(kl.minus) - 1; j >= 0; j-- { + b = append(b, kl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kl' +// in accounting notation. +func (kl *kl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kl.minus) - 1; j >= 0; j-- { + b = append(b, kl.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kl' +func (kl *kl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kl' +func (kl *kl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kl' +func (kl *kl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kl' +func (kl *kl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kl' +func (kl *kl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kl.periodsAbbreviated[0]...) + } else { + b = append(b, kl.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kl' +func (kl *kl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kl.periodsAbbreviated[0]...) + } else { + b = append(b, kl.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kl' +func (kl *kl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kl.periodsAbbreviated[0]...) + } else { + b = append(b, kl.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kl' +func (kl *kl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kl.periodsAbbreviated[0]...) + } else { + b = append(b, kl.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kl/kl_test.go b/vendor/github.com/go-playground/locales/kl/kl_test.go new file mode 100644 index 0000000000..acd084e5c3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kl/kl_test.go @@ -0,0 +1,1120 @@ +package kl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kl_GL/kl_GL.go b/vendor/github.com/go-playground/locales/kl_GL/kl_GL.go new file mode 100644 index 0000000000..4451ed0f2a --- /dev/null +++ b/vendor/github.com/go-playground/locales/kl_GL/kl_GL.go @@ -0,0 +1,649 @@ +package kl_GL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kl_GL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kl_GL' locale +func New() locales.Translator { + return &kl_GL{ + locale: "kl_GL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "aug", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "martsi", "aprili", "maji", "juni", "juli", "augustusi", "septemberi", "oktoberi", "novemberi", "decemberi"}, + daysAbbreviated: []string{"sab", "ata", "mar", "pin", "sis", "tal", "arf"}, + daysNarrow: []string{"S", "A", "M", "P", "S", "T", "A"}, + daysShort: []string{"sab", "ata", "mar", "pin", "sis", "tal", "arf"}, + daysWide: []string{"sabaat", "ataasinngorneq", "marlunngorneq", "pingasunngorneq", "sisamanngorneq", "tallimanngorneq", "arfininngorneq"}, + periodsAbbreviated: []string{"u.t.", "u.k."}, + periodsWide: []string{"ulloqeqqata-tungaa", "ulloqeqqata-kingorna"}, + erasAbbreviated: []string{"Kr.in.si.", "Kr.in.king."}, + erasNarrow: []string{"Kr.s.", "Kr.k."}, + erasWide: []string{"Kristusip inunngornerata siornagut", "Kristusip inunngornerata kingornagut"}, + timezones: map[string]string{"MST": "MST", "HEPM": "HEPM", "WESZ": "WESZ", "MYT": "MYT", "WARST": "WARST", "CLT": "CLT", "HNOG": "HNOG", "HEOG": "HEOG", "MEZ": "MEZ", "VET": "VET", "GMT": "GMT", "WAST": "WAST", "ChST": "ChST", "LHDT": "LHDT", "ECT": "ECT", "WEZ": "WEZ", "HNNOMX": "HNNOMX", "CHAST": "CHAST", "ART": "ART", "AKST": "AKST", "UYST": "UYST", "AWDT": "AWDT", "CLST": "CLST", "PDT": "PDT", "EST": "EST", "AKDT": "AKDT", "NZST": "NZST", "ADT": "ADT", "HKT": "HKT", "HNPM": "HNPM", "GYT": "GYT", "HNCU": "HNCU", "WIT": "WIT", "∅∅∅": "∅∅∅", "JST": "JST", "BT": "BT", "HEPMX": "HEPMX", "NZDT": "NZDT", "UYT": "UYT", "LHST": "LHST", "COST": "COST", "AEDT": "AEDT", "HECU": "HECU", "BOT": "BOT", "CAT": "CAT", "ACWST": "ACWST", "OEZ": "OEZ", "EDT": "EDT", "ACDT": "ACDT", "HNT": "HNT", "CST": "CST", "HAST": "HAST", "IST": "IST", "ACWDT": "ACWDT", "TMT": "TMT", "TMST": "TMST", "HAT": "HAT", "HEEG": "HEEG", "AEST": "AEST", "SRT": "SRT", "EAT": "EAT", "WAT": "WAT", "ACST": "ACST", "COT": "COT", "HENOMX": "HENOMX", "HADT": "HADT", "AST": "AST", "ARST": "ARST", "HKST": "HKST", "HNEG": "HNEG", "CDT": "CDT", "MESZ": "MESZ", "GFT": "GFT", "WITA": "WITA", "WIB": "WIB", "AWST": "AWST", "CHADT": "CHADT", "SGT": "SGT", "PST": "PST", "JDT": "JDT", "HNPMX": "HNPMX", "OESZ": "OESZ", "WART": "WART", "MDT": "MDT", "SAST": "SAST"}, + } +} + +// Locale returns the current translators string locale +func (kl *kl_GL) Locale() string { + return kl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kl_GL' +func (kl *kl_GL) PluralsCardinal() []locales.PluralRule { + return kl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kl_GL' +func (kl *kl_GL) PluralsOrdinal() []locales.PluralRule { + return kl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kl_GL' +func (kl *kl_GL) PluralsRange() []locales.PluralRule { + return kl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kl_GL' +func (kl *kl_GL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kl_GL' +func (kl *kl_GL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kl_GL' +func (kl *kl_GL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kl *kl_GL) MonthAbbreviated(month time.Month) string { + return kl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kl *kl_GL) MonthsAbbreviated() []string { + return kl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kl *kl_GL) MonthNarrow(month time.Month) string { + return kl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kl *kl_GL) MonthsNarrow() []string { + return kl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kl *kl_GL) MonthWide(month time.Month) string { + return kl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kl *kl_GL) MonthsWide() []string { + return kl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kl *kl_GL) WeekdayAbbreviated(weekday time.Weekday) string { + return kl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kl *kl_GL) WeekdaysAbbreviated() []string { + return kl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kl *kl_GL) WeekdayNarrow(weekday time.Weekday) string { + return kl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kl *kl_GL) WeekdaysNarrow() []string { + return kl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kl *kl_GL) WeekdayShort(weekday time.Weekday) string { + return kl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kl *kl_GL) WeekdaysShort() []string { + return kl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kl *kl_GL) WeekdayWide(weekday time.Weekday) string { + return kl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kl *kl_GL) WeekdaysWide() []string { + return kl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kl_GL' and handles both Whole and Real numbers based on 'v' +func (kl *kl_GL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(kl.minus) - 1; j >= 0; j-- { + b = append(b, kl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kl_GL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kl *kl_GL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(kl.minus) - 1; j >= 0; j-- { + b = append(b, kl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kl.percentSuffix...) + + b = append(b, kl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kl_GL' +func (kl *kl_GL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + for j := len(kl.minus) - 1; j >= 0; j-- { + b = append(b, kl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kl_GL' +// in accounting notation. +func (kl *kl_GL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kl.minus) - 1; j >= 0; j-- { + b = append(b, kl.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kl_GL' +func (kl *kl_GL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kl_GL' +func (kl *kl_GL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kl_GL' +func (kl *kl_GL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kl_GL' +func (kl *kl_GL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kl_GL' +func (kl *kl_GL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kl.periodsAbbreviated[0]...) + } else { + b = append(b, kl.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kl_GL' +func (kl *kl_GL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kl.periodsAbbreviated[0]...) + } else { + b = append(b, kl.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kl_GL' +func (kl *kl_GL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kl.periodsAbbreviated[0]...) + } else { + b = append(b, kl.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kl_GL' +func (kl *kl_GL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kl.periodsAbbreviated[0]...) + } else { + b = append(b, kl.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kl_GL/kl_GL_test.go b/vendor/github.com/go-playground/locales/kl_GL/kl_GL_test.go new file mode 100644 index 0000000000..6e968392c3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kl_GL/kl_GL_test.go @@ -0,0 +1,1120 @@ +package kl_GL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kl_GL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kln/kln.go b/vendor/github.com/go-playground/locales/kln/kln.go new file mode 100644 index 0000000000..e18020bfc2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kln/kln.go @@ -0,0 +1,518 @@ +package kln + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kln struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kln' locale +func New() locales.Translator { + return &kln{ + locale: "kln", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Mul", "Ngat", "Taa", "Iwo", "Mam", "Paa", "Nge", "Roo", "Bur", "Epe", "Kpt", "Kpa"}, + monthsNarrow: []string{"", "M", "N", "T", "I", "M", "P", "N", "R", "B", "E", "K", "K"}, + monthsWide: []string{"", "Mulgul", "Ng’atyaato", "Kiptaamo", "Iwootkuut", "Mamuut", "Paagi", "Ng’eiyeet", "Rooptui", "Bureet", "Epeeso", "Kipsuunde ne taai", "Kipsuunde nebo aeng’"}, + daysAbbreviated: []string{"Kts", "Kot", "Koo", "Kos", "Koa", "Kom", "Kol"}, + daysNarrow: []string{"T", "T", "O", "S", "A", "M", "L"}, + daysWide: []string{"Kotisap", "Kotaai", "Koaeng’", "Kosomok", "Koang’wan", "Komuut", "Kolo"}, + periodsAbbreviated: []string{"krn", "koosk"}, + periodsWide: []string{"karoon", "kooskoliny"}, + erasAbbreviated: []string{"AM", "KO"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Amait kesich Jesu", "Kokakesich Jesu"}, + timezones: map[string]string{"OESZ": "OESZ", "COST": "COST", "AKST": "AKST", "AKDT": "AKDT", "UYT": "UYT", "HECU": "HECU", "CHAST": "CHAST", "PST": "PST", "HADT": "HADT", "CAT": "CAT", "JDT": "JDT", "WEZ": "WEZ", "WART": "WART", "CLT": "CLT", "BT": "BT", "HEPM": "HEPM", "IST": "IST", "CLST": "CLST", "WAT": "WAT", "HNT": "HNT", "∅∅∅": "∅∅∅", "GYT": "GYT", "CST": "CST", "HAST": "HAST", "HNOG": "HNOG", "MYT": "MYT", "HNCU": "HNCU", "SGT": "SGT", "EDT": "EDT", "HNNOMX": "HNNOMX", "CDT": "CDT", "ACST": "ACST", "HAT": "HAT", "NZDT": "NZDT", "WESZ": "WESZ", "TMT": "TMT", "COT": "COT", "HNEG": "HNEG", "LHDT": "LHDT", "AWST": "AWST", "AWDT": "AWDT", "BOT": "BOT", "ACWDT": "ACWDT", "NZST": "NZST", "UYST": "UYST", "HEOG": "HEOG", "EST": "EST", "AEST": "AEST", "HEPMX": "HEPMX", "PDT": "PDT", "ECT": "ECT", "MEZ": "MEZ", "MESZ": "MESZ", "JST": "JST", "AST": "AST", "ACDT": "ACDT", "ChST": "ChST", "HNPM": "HNPM", "HNPMX": "HNPMX", "ARST": "ARST", "HKT": "HKT", "SAST": "SAST", "EAT": "EAT", "WIT": "WIT", "VET": "VET", "HEEG": "HEEG", "ACWST": "ACWST", "ADT": "ADT", "OEZ": "OEZ", "WARST": "WARST", "MST": "MST", "WITA": "WITA", "MDT": "MDT", "WAST": "WAST", "LHST": "LHST", "SRT": "SRT", "CHADT": "CHADT", "GMT": "GMT", "ART": "ART", "HKST": "HKST", "WIB": "WIB", "TMST": "TMST", "HENOMX": "HENOMX", "AEDT": "AEDT", "GFT": "GFT"}, + } +} + +// Locale returns the current translators string locale +func (kln *kln) Locale() string { + return kln.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kln' +func (kln *kln) PluralsCardinal() []locales.PluralRule { + return kln.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kln' +func (kln *kln) PluralsOrdinal() []locales.PluralRule { + return kln.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kln' +func (kln *kln) PluralsRange() []locales.PluralRule { + return kln.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kln' +func (kln *kln) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kln' +func (kln *kln) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kln' +func (kln *kln) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kln *kln) MonthAbbreviated(month time.Month) string { + return kln.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kln *kln) MonthsAbbreviated() []string { + return kln.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kln *kln) MonthNarrow(month time.Month) string { + return kln.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kln *kln) MonthsNarrow() []string { + return kln.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kln *kln) MonthWide(month time.Month) string { + return kln.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kln *kln) MonthsWide() []string { + return kln.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kln *kln) WeekdayAbbreviated(weekday time.Weekday) string { + return kln.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kln *kln) WeekdaysAbbreviated() []string { + return kln.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kln *kln) WeekdayNarrow(weekday time.Weekday) string { + return kln.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kln *kln) WeekdaysNarrow() []string { + return kln.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kln *kln) WeekdayShort(weekday time.Weekday) string { + return kln.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kln *kln) WeekdaysShort() []string { + return kln.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kln *kln) WeekdayWide(weekday time.Weekday) string { + return kln.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kln *kln) WeekdaysWide() []string { + return kln.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kln' and handles both Whole and Real numbers based on 'v' +func (kln *kln) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kln' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kln *kln) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kln' +func (kln *kln) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kln.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kln' +// in accounting notation. +func (kln *kln) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kln.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kln.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kln.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kln' +func (kln *kln) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kln' +func (kln *kln) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kln.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kln' +func (kln *kln) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kln' +func (kln *kln) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kln.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kln' +func (kln *kln) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kln' +func (kln *kln) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kln' +func (kln *kln) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kln' +func (kln *kln) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kln.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kln/kln_test.go b/vendor/github.com/go-playground/locales/kln/kln_test.go new file mode 100644 index 0000000000..b5e4e7d944 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kln/kln_test.go @@ -0,0 +1,1120 @@ +package kln + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kln" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kln_KE/kln_KE.go b/vendor/github.com/go-playground/locales/kln_KE/kln_KE.go new file mode 100644 index 0000000000..f37b301991 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kln_KE/kln_KE.go @@ -0,0 +1,518 @@ +package kln_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kln_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kln_KE' locale +func New() locales.Translator { + return &kln_KE{ + locale: "kln_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Mul", "Ngat", "Taa", "Iwo", "Mam", "Paa", "Nge", "Roo", "Bur", "Epe", "Kpt", "Kpa"}, + monthsNarrow: []string{"", "M", "N", "T", "I", "M", "P", "N", "R", "B", "E", "K", "K"}, + monthsWide: []string{"", "Mulgul", "Ng’atyaato", "Kiptaamo", "Iwootkuut", "Mamuut", "Paagi", "Ng’eiyeet", "Rooptui", "Bureet", "Epeeso", "Kipsuunde ne taai", "Kipsuunde nebo aeng’"}, + daysAbbreviated: []string{"Kts", "Kot", "Koo", "Kos", "Koa", "Kom", "Kol"}, + daysNarrow: []string{"T", "T", "O", "S", "A", "M", "L"}, + daysWide: []string{"Kotisap", "Kotaai", "Koaeng’", "Kosomok", "Koang’wan", "Komuut", "Kolo"}, + periodsAbbreviated: []string{"krn", "koosk"}, + periodsWide: []string{"karoon", "kooskoliny"}, + erasAbbreviated: []string{"AM", "KO"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Amait kesich Jesu", "Kokakesich Jesu"}, + timezones: map[string]string{"NZST": "NZST", "HENOMX": "HENOMX", "AEST": "AEST", "ChST": "ChST", "AWDT": "AWDT", "BOT": "BOT", "AST": "AST", "HKST": "HKST", "HEEG": "HEEG", "HEPMX": "HEPMX", "ACWST": "ACWST", "CLT": "CLT", "HAST": "HAST", "ACWDT": "ACWDT", "WESZ": "WESZ", "COST": "COST", "GFT": "GFT", "HNCU": "HNCU", "OESZ": "OESZ", "ART": "ART", "HNOG": "HNOG", "HEOG": "HEOG", "MYT": "MYT", "MDT": "MDT", "COT": "COT", "CHAST": "CHAST", "CHADT": "CHADT", "IST": "IST", "HNT": "HNT", "UYST": "UYST", "HADT": "HADT", "ADT": "ADT", "WITA": "WITA", "LHST": "LHST", "LHDT": "LHDT", "CST": "CST", "WARST": "WARST", "MST": "MST", "AWST": "AWST", "MEZ": "MEZ", "JST": "JST", "ECT": "ECT", "BT": "BT", "AKDT": "AKDT", "WAST": "WAST", "HNPM": "HNPM", "CDT": "CDT", "SGT": "SGT", "VET": "VET", "HAT": "HAT", "HNEG": "HNEG", "AEDT": "AEDT", "UYT": "UYT", "HEPM": "HEPM", "HECU": "HECU", "WART": "WART", "EDT": "EDT", "TMT": "TMT", "ARST": "ARST", "SRT": "SRT", "EAT": "EAT", "PST": "PST", "PDT": "PDT", "MESZ": "MESZ", "JDT": "JDT", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "∅∅∅": "∅∅∅", "WIT": "WIT", "GMT": "GMT", "ACST": "ACST", "ACDT": "ACDT", "GYT": "GYT", "NZDT": "NZDT", "OEZ": "OEZ", "WEZ": "WEZ", "WAT": "WAT", "EST": "EST", "CLST": "CLST", "TMST": "TMST", "HKT": "HKT", "AKST": "AKST", "SAST": "SAST", "WIB": "WIB", "CAT": "CAT"}, + } +} + +// Locale returns the current translators string locale +func (kln *kln_KE) Locale() string { + return kln.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kln_KE' +func (kln *kln_KE) PluralsCardinal() []locales.PluralRule { + return kln.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kln_KE' +func (kln *kln_KE) PluralsOrdinal() []locales.PluralRule { + return kln.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kln_KE' +func (kln *kln_KE) PluralsRange() []locales.PluralRule { + return kln.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kln_KE' +func (kln *kln_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kln_KE' +func (kln *kln_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kln_KE' +func (kln *kln_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kln *kln_KE) MonthAbbreviated(month time.Month) string { + return kln.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kln *kln_KE) MonthsAbbreviated() []string { + return kln.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kln *kln_KE) MonthNarrow(month time.Month) string { + return kln.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kln *kln_KE) MonthsNarrow() []string { + return kln.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kln *kln_KE) MonthWide(month time.Month) string { + return kln.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kln *kln_KE) MonthsWide() []string { + return kln.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kln *kln_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return kln.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kln *kln_KE) WeekdaysAbbreviated() []string { + return kln.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kln *kln_KE) WeekdayNarrow(weekday time.Weekday) string { + return kln.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kln *kln_KE) WeekdaysNarrow() []string { + return kln.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kln *kln_KE) WeekdayShort(weekday time.Weekday) string { + return kln.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kln *kln_KE) WeekdaysShort() []string { + return kln.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kln *kln_KE) WeekdayWide(weekday time.Weekday) string { + return kln.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kln *kln_KE) WeekdaysWide() []string { + return kln.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kln_KE' and handles both Whole and Real numbers based on 'v' +func (kln *kln_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kln_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kln *kln_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kln_KE' +func (kln *kln_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kln.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kln_KE' +// in accounting notation. +func (kln *kln_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kln.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kln.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, kln.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kln_KE' +func (kln *kln_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kln_KE' +func (kln *kln_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kln.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kln_KE' +func (kln *kln_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kln_KE' +func (kln *kln_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kln.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kln_KE' +func (kln *kln_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kln_KE' +func (kln *kln_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kln_KE' +func (kln *kln_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kln_KE' +func (kln *kln_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kln.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kln_KE/kln_KE_test.go b/vendor/github.com/go-playground/locales/kln_KE/kln_KE_test.go new file mode 100644 index 0000000000..b8c5cbfbcb --- /dev/null +++ b/vendor/github.com/go-playground/locales/kln_KE/kln_KE_test.go @@ -0,0 +1,1120 @@ +package kln_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kln_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/km/km.go b/vendor/github.com/go-playground/locales/km/km.go new file mode 100644 index 0000000000..feff5d559a --- /dev/null +++ b/vendor/github.com/go-playground/locales/km/km.go @@ -0,0 +1,606 @@ +package km + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type km struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'km' locale +func New() locales.Translator { + return &km{ + locale: "km", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "៛", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "មករា", "កុម្ភៈ", "មីនា", "មេសា", "ឧសភា", "មិថុនា", "កក្កដា", "សីហា", "កញ្ញា", "តុលា", "វិច្ឆិកា", "ធ្នូ"}, + monthsNarrow: []string{"", "ម", "ក", "ម", "ម", "ឧ", "ម", "ក", "ស", "ក", "ត", "វ", "ធ"}, + monthsWide: []string{"", "មករា", "កុម្ភៈ", "មីនា", "មេសា", "ឧសភា", "មិថុនា", "កក្កដា", "សីហា", "កញ្ញា", "តុលា", "វិច្ឆិកា", "ធ្នូ"}, + daysAbbreviated: []string{"អាទិត្យ", "ច័ន្ទ", "អង្គារ", "ពុធ", "ព្រហស្បតិ៍", "សុក្រ", "សៅរ៍"}, + daysNarrow: []string{"អ", "ច", "អ", "ព", "ព", "ស", "ស"}, + daysShort: []string{"អា", "ច", "អ", "ពុ", "ព្រ", "សុ", "ស"}, + daysWide: []string{"អាទិត្យ", "ច័ន្ទ", "អង្គារ", "ពុធ", "ព្រហស្បតិ៍", "សុក្រ", "សៅរ៍"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"មុន គ.ស.", "គ.ស."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"មុន\u200bគ្រិស្តសករាជ", "គ្រិស្តសករាជ"}, + timezones: map[string]string{"SGT": "ម៉ោង\u200bនៅ\u200bសិង្ហបូរី", "HADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bហាវៃ-អាល់ដ្យូសិន", "IST": "ម៉ោង\u200bនៅ\u200bឥណ្ឌា", "CLT": "ម៉ោងស្តង់ដារនៅឈីលី", "TMST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bតួកម៉េនីស្ថាន\u200b", "HEEG": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bហ្គ្រីនលែនខាង\u200bកើត", "WIB": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200bខាង\u200bលិច", "AWDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bលិច", "JST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bជប៉ុន", "EST": "ម៉ោង\u200bស្តង់ដារ\u200bភាគ\u200bខាង\u200bកើត\u200bនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "ChST": "ម៉ោង\u200bនៅ\u200bចាំម៉ូរ៉ូ", "WIT": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200bខាង\u200bកើត", "HAST": "ម៉ោង\u200bស្តង់ដារ\u200b\u200bនៅ\u200bហាវៃ-អាល់ដ្យូសិន", "BT": "ម៉ោងនៅប៊ូតាន", "AKDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200b\u200bអាឡាស្កា", "HECU": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bគុយបា", "HEPMX": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bប៉ាសីុហ្វិក\u200bម៉ិកស៊ិក", "SRT": "ម៉ោង\u200bនៅ\u200bសូរីណាម", "HNOG": "ម៉ោងស្តង់ដារនៅហ្គ្រីនលែនខាងលិច", "WEZ": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអឺរ៉ុប\u200bខាង\u200bលិច", "MYT": "ម៉ោង\u200bនៅ\u200bម៉ាឡេស៊ី", "AEDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bកើត", "LHDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bឡតហៅ", "HNCU": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bគុយបា", "ACWDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200b\u200bភាគ\u200bខាង\u200bលិច\u200bនៃ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "MEZ": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអឺរ៉ុប\u200bកណ្ដាល", "WESZ": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអឺរ៉ុប\u200bខាង\u200bលិច", "ART": "ម៉ោង\u200b\u200bស្តង់ដារ\u200bនៅ\u200bអាសង់ទីន", "WAST": "ម៉ោង\u200b\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអាហ្វ្រិក\u200b\u200b\u200bខាងលិច", "ACST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "ACDT": "ម៉ោង\u200bពេលថ្ងៃ\u200b\u200b\u200b\u200bនៅ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "HENOMX": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bម៉ិកស៊ិកភាគពាយព្យ", "HNT": "ម៉ោង\u200b\u200bស្តង់ដារ\u200b\u200bនៅ\u200bញូហ្វោនឡែន", "HAT": "ម៉ោង\u200bពេលថ្ងៃ\u200bនៅ\u200bញូហ្វោនឡែន", "UYT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអ៊ុយរូហ្គាយ", "MESZ": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអឺរ៉ុប\u200bកណ្ដាល", "ADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអាត្លង់ទិក", "WART": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាសង់ទីន\u200b\u200bខាង\u200bលិច", "EDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bភាគខាង\u200bកើតនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "GFT": "ម៉ោង\u200bនៅ\u200bឃ្វីយ៉ាន\u200bបារាំង", "ACWST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bភាគ\u200bខាង\u200bលិច\u200bនៃ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "BOT": "ម៉ោង\u200bនៅ\u200bបូលីវី", "GMT": "ម៉ោងនៅគ្រីនវិច", "HNEG": "ម៉ោង\u200b\u200b\u200bស្តង់ដារ\u200bនៅ\u200b\u200bហ្គ្រីនលែន\u200bខាង\u200bកើត", "HEPM": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅសង់\u200bព្យែរ និង\u200bមីគុយឡុង", "AWST": "ម៉ោង\u200b\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bលិច", "CHADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bចាថាំ", "WARST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអាសង់ទីន\u200b\u200bខាង\u200bលិច", "MDT": "MDT", "WAT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bលិច", "HNPM": "ម៉ោង\u200bស្តង់ដារ\u200bនៅសង់\u200bព្យែរ និង\u200bមីគុយឡុង", "SAST": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bត្បូង", "AST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាត្លង់ទិក", "OESZ": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអឺរ៉ុប\u200b\u200bខាង\u200bកើត\u200b", "∅∅∅": "∅∅∅", "CDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bភាគ\u200bកណ្ដាល\u200bនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "JDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅជប៉ុន", "HEOG": "ម៉ោងរដូវក្តៅនៅហ្គ្រីនលែនខាងលិច", "CHAST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bចាថាំ", "NZST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bនូវែលសេឡង់", "NZDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bនូវែលសេឡង់", "CAT": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bកណ្ដាល", "VET": "ម៉ោង\u200bនៅ\u200bវ៉េណេស៊ុយអេឡា", "MST": "MST", "ARST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអាសង់ទីន", "UYST": "ម៉ោង\u200b\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអ៊ុយរូហ្គាយ", "EAT": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bកើត", "PST": "ម៉ោង\u200bស្តង់ដារ\u200bភាគ\u200bខាង\u200bលិច\u200bនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "CLST": "ម៉ោងរដូវក្តៅនៅឈីលី", "TMT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅតួកម៉េនីស្ថាន", "LHST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bឡត\u200bហៅ", "HNPMX": "ម៉ោង\u200bស្តង់ដា\u200bនៅ\u200bប៉ាសីុហ្វិក\u200bម៉ិកស៊ិក", "ECT": "ម៉ោង\u200bនៅ\u200bអេក្វាទ័រ", "OEZ": "ម៉ោង\u200bស្តង់ដារ\u200b\u200bនៅ\u200bអឺរ៉ុប\u200b\u200bខាង\u200bកើត\u200b", "COT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bកូឡុំប៊ី", "PDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200b\u200bភាគ\u200bខាងលិច\u200bនៅ\u200bអាមេរិក\u200bភាគ\u200bខាង\u200bជើង", "GYT": "ម៉ោង\u200bនៅ\u200bឃ្វីយ៉ាន", "CST": "ម៉ោង\u200bស្តង់ដារ\u200bភាគ\u200bកណ្ដាល\u200bនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "COST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bកូឡុំប៊ី", "HNNOMX": "ម៉ោង\u200bស្តង់ដា\u200bនៅ\u200bម៉ិកស៊ិកភាគពាយព្យ", "WITA": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200b\u200bកណ្ដាល", "AKST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាឡាស្កា", "AEST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bកើត", "HKT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bហុងកុង", "HKST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bហុងកុង"}, + } +} + +// Locale returns the current translators string locale +func (km *km) Locale() string { + return km.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'km' +func (km *km) PluralsCardinal() []locales.PluralRule { + return km.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'km' +func (km *km) PluralsOrdinal() []locales.PluralRule { + return km.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'km' +func (km *km) PluralsRange() []locales.PluralRule { + return km.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'km' +func (km *km) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'km' +func (km *km) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'km' +func (km *km) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (km *km) MonthAbbreviated(month time.Month) string { + return km.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (km *km) MonthsAbbreviated() []string { + return km.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (km *km) MonthNarrow(month time.Month) string { + return km.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (km *km) MonthsNarrow() []string { + return km.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (km *km) MonthWide(month time.Month) string { + return km.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (km *km) MonthsWide() []string { + return km.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (km *km) WeekdayAbbreviated(weekday time.Weekday) string { + return km.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (km *km) WeekdaysAbbreviated() []string { + return km.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (km *km) WeekdayNarrow(weekday time.Weekday) string { + return km.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (km *km) WeekdaysNarrow() []string { + return km.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (km *km) WeekdayShort(weekday time.Weekday) string { + return km.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (km *km) WeekdaysShort() []string { + return km.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (km *km) WeekdayWide(weekday time.Weekday) string { + return km.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (km *km) WeekdaysWide() []string { + return km.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'km' and handles both Whole and Real numbers based on 'v' +func (km *km) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, km.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, km.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, km.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'km' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (km *km) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, km.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, km.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, km.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'km' +func (km *km) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := km.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, km.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, km.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, km.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, km.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'km' +// in accounting notation. +func (km *km) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := km.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, km.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, km.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, km.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, km.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, km.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'km' +func (km *km) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'km' +func (km *km) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, km.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'km' +func (km *km) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, km.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'km' +func (km *km) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, km.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, km.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'km' +func (km *km) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, km.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, km.periodsAbbreviated[0]...) + } else { + b = append(b, km.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'km' +func (km *km) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, km.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, km.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, km.periodsAbbreviated[0]...) + } else { + b = append(b, km.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'km' +func (km *km) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, km.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, km.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, km.periodsAbbreviated[0]...) + } else { + b = append(b, km.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'km' +func (km *km) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, km.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, km.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, km.periodsAbbreviated[0]...) + } else { + b = append(b, km.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := km.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/km/km_test.go b/vendor/github.com/go-playground/locales/km/km_test.go new file mode 100644 index 0000000000..8eea489afd --- /dev/null +++ b/vendor/github.com/go-playground/locales/km/km_test.go @@ -0,0 +1,1120 @@ +package km + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "km" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/km_KH/km_KH.go b/vendor/github.com/go-playground/locales/km_KH/km_KH.go new file mode 100644 index 0000000000..87673a187d --- /dev/null +++ b/vendor/github.com/go-playground/locales/km_KH/km_KH.go @@ -0,0 +1,606 @@ +package km_KH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type km_KH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'km_KH' locale +func New() locales.Translator { + return &km_KH{ + locale: "km_KH", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "មករា", "កុម្ភៈ", "មីនា", "មេសា", "ឧសភា", "មិថុនា", "កក្កដា", "សីហា", "កញ្ញា", "តុលា", "វិច្ឆិកា", "ធ្នូ"}, + monthsNarrow: []string{"", "ម", "ក", "ម", "ម", "ឧ", "ម", "ក", "ស", "ក", "ត", "វ", "ធ"}, + monthsWide: []string{"", "មករា", "កុម្ភៈ", "មីនា", "មេសា", "ឧសភា", "មិថុនា", "កក្កដា", "សីហា", "កញ្ញា", "តុលា", "វិច្ឆិកា", "ធ្នូ"}, + daysAbbreviated: []string{"អាទិត្យ", "ច័ន្ទ", "អង្គារ", "ពុធ", "ព្រហស្បតិ៍", "សុក្រ", "សៅរ៍"}, + daysNarrow: []string{"អ", "ច", "អ", "ព", "ព", "ស", "ស"}, + daysShort: []string{"អា", "ច", "អ", "ពុ", "ព្រ", "សុ", "ស"}, + daysWide: []string{"អាទិត្យ", "ច័ន្ទ", "អង្គារ", "ពុធ", "ព្រហស្បតិ៍", "សុក្រ", "សៅរ៍"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"មុន គ.ស.", "គ.ស."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"មុន\u200bគ្រិស្តសករាជ", "គ្រិស្តសករាជ"}, + timezones: map[string]string{"COST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bកូឡុំប៊ី", "HENOMX": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bម៉ិកស៊ិកភាគពាយព្យ", "GFT": "ម៉ោង\u200bនៅ\u200bឃ្វីយ៉ាន\u200bបារាំង", "AWST": "ម៉ោង\u200b\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bលិច", "∅∅∅": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអាម៉ាសូន", "OEZ": "ម៉ោង\u200bស្តង់ដារ\u200b\u200bនៅ\u200bអឺរ៉ុប\u200b\u200bខាង\u200bកើត\u200b", "JST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bជប៉ុន", "GMT": "ម៉ោងនៅគ្រីនវិច", "HNEG": "ម៉ោង\u200b\u200b\u200bស្តង់ដារ\u200bនៅ\u200b\u200bហ្គ្រីនលែន\u200bខាង\u200bកើត", "LHDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bឡតហៅ", "IST": "ម៉ោង\u200bនៅ\u200bឥណ្ឌា", "MESZ": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអឺរ៉ុប\u200bកណ្ដាល", "HAT": "ម៉ោង\u200bពេលថ្ងៃ\u200bនៅ\u200bញូហ្វោនឡែន", "HEEG": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bហ្គ្រីនលែនខាង\u200bកើត", "ChST": "ម៉ោង\u200bនៅ\u200bចាំម៉ូរ៉ូ", "HEPM": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅសង់\u200bព្យែរ និង\u200bមីគុយឡុង", "CDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bភាគ\u200bកណ្ដាល\u200bនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "WIT": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200bខាង\u200bកើត", "MEZ": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអឺរ៉ុប\u200bកណ្ដាល", "TMT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅតួកម៉េនីស្ថាន", "EAT": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bកើត", "HADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bហាវៃ-អាល់ដ្យូសិន", "NZDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bនូវែលសេឡង់", "ACST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "COT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bកូឡុំប៊ី", "ACWDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200b\u200bភាគ\u200bខាង\u200bលិច\u200bនៃ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "VET": "ម៉ោង\u200bនៅ\u200bវ៉េណេស៊ុយអេឡា", "CLST": "ម៉ោងរដូវក្តៅនៅឈីលី", "WEZ": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអឺរ៉ុប\u200bខាង\u200bលិច", "HAST": "ម៉ោង\u200bស្តង់ដារ\u200b\u200bនៅ\u200bហាវៃ-អាល់ដ្យូសិន", "CAT": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bកណ្ដាល", "HEPMX": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bប៉ាសីុហ្វិក\u200bម៉ិកស៊ិក", "CHAST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bចាថាំ", "SGT": "ម៉ោង\u200bនៅ\u200bសិង្ហបូរី", "HKST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bហុងកុង", "HECU": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bគុយបា", "MYT": "ម៉ោង\u200bនៅ\u200bម៉ាឡេស៊ី", "HKT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bហុងកុង", "AKST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាឡាស្កា", "UYST": "ម៉ោង\u200b\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអ៊ុយរូហ្គាយ", "JDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅជប៉ុន", "MDT": "MDT", "WARST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអាសង់ទីន\u200b\u200bខាង\u200bលិច", "ART": "ម៉ោង\u200b\u200bស្តង់ដារ\u200bនៅ\u200bអាសង់ទីន", "HNNOMX": "ម៉ោង\u200bស្តង់ដា\u200bនៅ\u200bម៉ិកស៊ិកភាគពាយព្យ", "AEDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bកើត", "UYT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអ៊ុយរូហ្គាយ", "AWDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bលិច", "CLT": "ម៉ោងស្តង់ដារនៅឈីលី", "OESZ": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអឺរ៉ុប\u200b\u200bខាង\u200bកើត\u200b", "LHST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bឡត\u200bហៅ", "HEOG": "ម៉ោងរដូវក្តៅនៅហ្គ្រីនលែនខាងលិច", "WAST": "ម៉ោង\u200b\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអាហ្វ្រិក\u200b\u200b\u200bខាងលិច", "ADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអាត្លង់ទិក", "WESZ": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអឺរ៉ុប\u200bខាង\u200bលិច", "WART": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាសង់ទីន\u200b\u200bខាង\u200bលិច", "EST": "ម៉ោង\u200bស្តង់ដារ\u200bភាគ\u200bខាង\u200bកើត\u200bនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "SRT": "ម៉ោង\u200bនៅ\u200bសូរីណាម", "ECT": "ម៉ោង\u200bនៅ\u200bអេក្វាទ័រ", "NZST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bនូវែលសេឡង់", "PDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200b\u200bភាគ\u200bខាងលិច\u200bនៅ\u200bអាមេរិក\u200bភាគ\u200bខាង\u200bជើង", "TMST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bតួកម៉េនីស្ថាន\u200b", "WAT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bលិច", "BOT": "ម៉ោង\u200bនៅ\u200bបូលីវី", "PST": "ម៉ោង\u200bស្តង់ដារ\u200bភាគ\u200bខាង\u200bលិច\u200bនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "BT": "ម៉ោងនៅប៊ូតាន", "WITA": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200b\u200bកណ្ដាល", "AEST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bកើត", "GYT": "ម៉ោង\u200bនៅ\u200bឃ្វីយ៉ាន", "CST": "ម៉ោង\u200bស្តង់ដារ\u200bភាគ\u200bកណ្ដាល\u200bនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "ACWST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bភាគ\u200bខាង\u200bលិច\u200bនៃ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "MST": "MST", "ACDT": "ម៉ោង\u200bពេលថ្ងៃ\u200b\u200b\u200b\u200bនៅ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "HNPM": "ម៉ោង\u200bស្តង់ដារ\u200bនៅសង់\u200bព្យែរ និង\u200bមីគុយឡុង", "HNPMX": "ម៉ោង\u200bស្តង់ដា\u200bនៅ\u200bប៉ាសីុហ្វិក\u200bម៉ិកស៊ិក", "WIB": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200bខាង\u200bលិច", "CHADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bចាថាំ", "AST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាត្លង់ទិក", "EDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bភាគខាង\u200bកើតនៅ\u200bអាមេរិក\u200bខាង\u200bជើង", "HNT": "ម៉ោង\u200b\u200bស្តង់ដារ\u200b\u200bនៅ\u200bញូហ្វោនឡែន", "AKDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200b\u200bអាឡាស្កា", "SAST": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bត្បូង", "HNCU": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bគុយបា", "HNOG": "ម៉ោងស្តង់ដារនៅហ្គ្រីនលែនខាងលិច", "ARST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bអាសង់ទីន"}, + } +} + +// Locale returns the current translators string locale +func (km *km_KH) Locale() string { + return km.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'km_KH' +func (km *km_KH) PluralsCardinal() []locales.PluralRule { + return km.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'km_KH' +func (km *km_KH) PluralsOrdinal() []locales.PluralRule { + return km.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'km_KH' +func (km *km_KH) PluralsRange() []locales.PluralRule { + return km.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'km_KH' +func (km *km_KH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'km_KH' +func (km *km_KH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'km_KH' +func (km *km_KH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (km *km_KH) MonthAbbreviated(month time.Month) string { + return km.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (km *km_KH) MonthsAbbreviated() []string { + return km.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (km *km_KH) MonthNarrow(month time.Month) string { + return km.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (km *km_KH) MonthsNarrow() []string { + return km.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (km *km_KH) MonthWide(month time.Month) string { + return km.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (km *km_KH) MonthsWide() []string { + return km.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (km *km_KH) WeekdayAbbreviated(weekday time.Weekday) string { + return km.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (km *km_KH) WeekdaysAbbreviated() []string { + return km.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (km *km_KH) WeekdayNarrow(weekday time.Weekday) string { + return km.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (km *km_KH) WeekdaysNarrow() []string { + return km.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (km *km_KH) WeekdayShort(weekday time.Weekday) string { + return km.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (km *km_KH) WeekdaysShort() []string { + return km.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (km *km_KH) WeekdayWide(weekday time.Weekday) string { + return km.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (km *km_KH) WeekdaysWide() []string { + return km.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'km_KH' and handles both Whole and Real numbers based on 'v' +func (km *km_KH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, km.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, km.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, km.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'km_KH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (km *km_KH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, km.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, km.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, km.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'km_KH' +func (km *km_KH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := km.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, km.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, km.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, km.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, km.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'km_KH' +// in accounting notation. +func (km *km_KH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := km.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, km.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, km.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, km.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, km.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, km.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'km_KH' +func (km *km_KH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'km_KH' +func (km *km_KH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, km.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'km_KH' +func (km *km_KH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, km.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'km_KH' +func (km *km_KH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, km.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, km.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'km_KH' +func (km *km_KH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, km.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, km.periodsAbbreviated[0]...) + } else { + b = append(b, km.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'km_KH' +func (km *km_KH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, km.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, km.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, km.periodsAbbreviated[0]...) + } else { + b = append(b, km.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'km_KH' +func (km *km_KH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, km.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, km.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, km.periodsAbbreviated[0]...) + } else { + b = append(b, km.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'km_KH' +func (km *km_KH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, km.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, km.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, km.periodsAbbreviated[0]...) + } else { + b = append(b, km.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := km.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/km_KH/km_KH_test.go b/vendor/github.com/go-playground/locales/km_KH/km_KH_test.go new file mode 100644 index 0000000000..aca05e2d71 --- /dev/null +++ b/vendor/github.com/go-playground/locales/km_KH/km_KH_test.go @@ -0,0 +1,1120 @@ +package km_KH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "km_KH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kn/kn.go b/vendor/github.com/go-playground/locales/kn/kn.go new file mode 100644 index 0000000000..49cf027564 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kn/kn.go @@ -0,0 +1,641 @@ +package kn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kn' locale +func New() locales.Translator { + return &kn{ + locale: "kn", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ಜನ", "ಫೆಬ್ರ", "ಮಾರ್ಚ್", "ಏಪ್ರಿ", "ಮೇ", "ಜೂನ್", "ಜುಲೈ", "ಆಗ", "ಸೆಪ್ಟೆಂ", "ಅಕ್ಟೋ", "ನವೆಂ", "ಡಿಸೆಂ"}, + monthsNarrow: []string{"", "ಜ", "ಫೆ", "ಮಾ", "ಏ", "ಮೇ", "ಜೂ", "ಜು", "ಆ", "ಸೆ", "ಅ", "ನ", "ಡಿ"}, + monthsWide: []string{"", "ಜನವರಿ", "ಫೆಬ್ರವರಿ", "ಮಾರ್ಚ್", "ಏಪ್ರಿಲ್", "ಮೇ", "ಜೂನ್", "ಜುಲೈ", "ಆಗಸ್ಟ್", "ಸೆಪ್ಟೆಂಬರ್", "ಅಕ್ಟೋಬರ್", "ನವೆಂಬರ್", "ಡಿಸೆಂಬರ್"}, + daysAbbreviated: []string{"ಭಾನು", "ಸೋಮ", "ಮಂಗಳ", "ಬುಧ", "ಗುರು", "ಶುಕ್ರ", "ಶನಿ"}, + daysNarrow: []string{"ಭಾ", "ಸೋ", "ಮಂ", "ಬು", "ಗು", "ಶು", "ಶ"}, + daysShort: []string{"ಭಾನು", "ಸೋಮ", "ಮಂಗಳ", "ಬುಧ", "ಗುರು", "ಶುಕ್ರ", "ಶನಿ"}, + daysWide: []string{"ಭಾನುವಾರ", "ಸೋಮವಾರ", "ಮಂಗಳವಾರ", "ಬುಧವಾರ", "ಗುರುವಾರ", "ಶುಕ್ರವಾರ", "ಶನಿವಾರ"}, + periodsAbbreviated: []string{"ಪೂರ್ವಾಹ್ನ", "ಅಪರಾಹ್ನ"}, + periodsNarrow: []string{"ಪೂ", "ಅ"}, + periodsWide: []string{"ಪೂರ್ವಾಹ್ನ", "ಅಪರಾಹ್ನ"}, + erasAbbreviated: []string{"ಕ್ರಿ.ಪೂ", "ಕ್ರಿ.ಶ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ಕ್ರಿಸ್ತ ಪೂರ್ವ", "ಕ್ರಿಸ್ತ ಶಕ"}, + timezones: map[string]string{"∅∅∅": "ಅಮೆಜಾನ್ ಬೇಸಿಗೆ ಸಮಯ", "MEZ": "ಮಧ್ಯ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ACDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಹಗಲು ಸಮಯ", "AEDT": "ಪೂರ್ವ ಆಸ್ಟ್ರೇಲಿಯಾದ ಹಗಲು ಸಮಯ", "ACWST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪಶ್ಚಿಮ ಪ್ರಮಾಣಿತ ಸಮಯ", "HKST": "ಹಾಂಗ್ ಕಾಂಗ್ ಬೇಸಿಗೆ ಸಮಯ", "HNNOMX": "ವಾಯವ್ಯ ಮೆಕ್ಸಿಕೊ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNT": "ನ್ಯೂಫೌಂಡ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "SGT": "ಸಿಂಗಾಪುರ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "PDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೆಸಿಫಿಕ್ ದಿನದ ಸಮಯ", "WART": "ಪಶ್ಚಿಮ ಅರ್ಜೆಂಟೀನಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "GFT": "ಫ್ರೆಂಚ್ ಗಯಾನಾ ಸಮಯ", "GYT": "ಗಯಾನಾ ಸಮಯ", "HECU": "ಕ್ಯೂಬಾ ದಿನದ ಸಮಯ", "BOT": "ಬೊಲಿವಿಯಾ ಸಮಯ", "WEZ": "ಪಶ್ಚಿಮ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNOG": "ಪಶ್ಚಿಮ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ARST": "ಅರ್ಜೆಂಟಿನಾ ಬೇಸಿಗೆ ಸಮಯ", "ACST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪ್ರಮಾಣಿತ ಸಮಯ", "TMST": "ತುರ್ಕ್\u200cಮೇನಿಸ್ತಾನ್ ಬೇಸಿಗೆ ಸಮಯ", "ART": "ಅರ್ಜೆಂಟೀನಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "HENOMX": "ವಾಯವ್ಯ ಮೆಕ್ಸಿಕೊ ಹಗಲು ಸಮಯ", "SAST": "ದಕ್ಷಿಣ ಆಫ್ರಿಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "IST": "ಭಾರತೀಯ ಪ್ರಮಾಣಿತ ಸಮಯ", "OEZ": "ಪೂರ್ವ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HEOG": "ಪಶ್ಚಿಮ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಬೇಸಿಗೆ ಸಮಯ", "ADT": "ಅಟ್ಲಾಂಟಿಕ್ ದಿನದ ಸಮಯ", "AWDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪಶ್ಚಿಮ ಹಗಲು ಸಮಯ", "HEPMX": "ಮೆಕ್ಸಿಕನ್ ಪೆಸಿಫಿಕ್ ಹಗಲು ಸಮಯ", "EAT": "ಪೂರ್ವ ಆಫ್ರಿಕಾ ಸಮಯ", "CST": "ಉತ್ತರ ಅಮೆರಿಕದ ಕೇಂದ್ರ ಪ್ರಮಾಣಿತ ಸಮಯ", "HAST": "ಹವಾಯಿ-ಅಲ್ಯುಟಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "AST": "ಅಟ್ಲಾಂಟಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HEEG": "ಪೂರ್ವ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಬೇಸಿಗೆ ಸಮಯ", "CHAST": "ಚಥಾಮ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNEG": "ಪೂರ್ವ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "PST": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೆಸಿಫಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ACWDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪಶ್ಚಿಮ ಹಗಲು ಸಮಯ", "CAT": "ಮಧ್ಯ ಆಫ್ರಿಕಾ ಸಮಯ", "MDT": "ಮಕಾವ್ ಬೇಸಿಗೆ ಸಮಯ", "WAST": "ಪಶ್ಚಿಮ ಆಫ್ರಿಕಾ ಬೇಸಿಗೆ ಸಮಯ", "JST": "ಜಪಾನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HKT": "ಹಾಂಗ್ ಕಾಂಗ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HAT": "ನ್ಯೂಫೌಂಡ್\u200cಲ್ಯಾಂಡ್ ದಿನದ ಸಮಯ", "EDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೂರ್ವದ ದಿನದ ಸಮಯ", "BT": "ಭೂತಾನ್ ಸಮಯ", "WITA": "ಮಧ್ಯ ಇಂಡೋನೇಷಿಯಾ ಸಮಯ", "AKST": "ಅಲಸ್ಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "NZDT": "ನ್ಯೂಜಿಲ್ಯಾಂಡ್ ಹಗಲು ಸಮಯ", "VET": "ವೆನಿಜುವೆಲಾ ಸಮಯ", "JDT": "ಜಪಾನ್ ಹಗಲು ಸಮಯ", "MYT": "ಮಲೇಷಿಯಾ ಸಮಯ", "ChST": "ಚಮೋರೋ ಪ್ರಮಾಣಿತ ಸಮಯ", "WARST": "ಪಶ್ಚಿಮ ಅರ್ಜೆಂಟೀನಾ ಬೇಸಿಗೆ ಸಮಯ", "MST": "ಮಕಾವ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNPM": "ಸೇಂಟ್ ಪಿಯರ್ ಮತ್ತು ಮಿಕ್ವೆಲನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "GMT": "ಗ್ರೀನ್\u200cವಿಚ್ ಸರಾಸರಿ ಕಾಲಮಾನ", "EST": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೂರ್ವದ ಪ್ರಮಾಣಿತ ಸಮಯ", "WAT": "ಪಶ್ಚಿಮ ಆಫ್ರಿಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNCU": "ಕ್ಯೂಬಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "LHDT": "ಲಾರ್ಡ್ ಹೋವ್ ಬೆಳಗಿನ ಸಮಯ", "HNPMX": "ಮೆಕ್ಸಿಕನ್ ಪೆಸಿಫಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "WIB": "ಪಶ್ಚಿಮ ಇಂಡೋನೇಷಿಯ ಸಮಯ", "CHADT": "ಚಥಾಮ್ ಹಗಲು ಸಮಯ", "WESZ": "ಪಶ್ಚಿಮ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "CLST": "ಚಿಲಿ ಬೇಸಿಗೆ ಸಮಯ", "COT": "ಕೊಲಂಬಿಯಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "HEPM": "ಸೇಂಟ್ ಪಿಯರ್ ಮತ್ತು ಮಿಕ್ವೆಲನ್ ಹಗಲು ಸಮಯ", "HADT": "ಹವಾಯಿ-ಅಲ್ಯುಟಿಯನ್ ಹಗಲು ಸಮಯ", "LHST": "ಲಾರ್ಡ್ ಹೋವ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "SRT": "ಸುರಿನೇಮ್ ಸಮಯ", "ECT": "ಈಕ್ವೆಡಾರ್ ಸಮಯ", "MESZ": "ಮಧ್ಯ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "AEST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪೂರ್ವ ಪ್ರಮಾಣಿತ ಸಮಯ", "AKDT": "\u200cಅಲಾಸ್ಕಾ ಹಗಲು ಸಮಯ", "UYT": "ಉರುಗ್ವೇ ಪ್ರಮಾಣಿತ ಸಮಯ", "AWST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪಶ್ಚಿಮ ಪ್ರಮಾಣಿತ ಸಮಯ", "TMT": "ತುರ್ಕ್\u200cಮೇನಿಸ್ತಾನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "UYST": "ಉರುಗ್ವೇ ಬೇಸಿಗೆ ಸಮಯ", "WIT": "ಪೂರ್ವ ಇಂಡೋನೇಷಿಯಾ ಸಮಯ", "CDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಕೇಂದ್ರೀಯ ದಿನದ ಸಮಯ", "NZST": "ನ್ಯೂಜಿಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "OESZ": "ಪೂರ್ವ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "CLT": "ಚಿಲಿ ಪ್ರಮಾಣಿತ ಸಮಯ", "COST": "ಕೊಲಂಬಿಯಾ ಬೇಸಿಗೆ ಸಮಯ"}, + } +} + +// Locale returns the current translators string locale +func (kn *kn) Locale() string { + return kn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kn' +func (kn *kn) PluralsCardinal() []locales.PluralRule { + return kn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kn' +func (kn *kn) PluralsOrdinal() []locales.PluralRule { + return kn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kn' +func (kn *kn) PluralsRange() []locales.PluralRule { + return kn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kn' +func (kn *kn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kn' +func (kn *kn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kn' +func (kn *kn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := kn.CardinalPluralRule(num1, v1) + end := kn.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kn *kn) MonthAbbreviated(month time.Month) string { + return kn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kn *kn) MonthsAbbreviated() []string { + return kn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kn *kn) MonthNarrow(month time.Month) string { + return kn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kn *kn) MonthsNarrow() []string { + return kn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kn *kn) MonthWide(month time.Month) string { + return kn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kn *kn) MonthsWide() []string { + return kn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kn *kn) WeekdayAbbreviated(weekday time.Weekday) string { + return kn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kn *kn) WeekdaysAbbreviated() []string { + return kn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kn *kn) WeekdayNarrow(weekday time.Weekday) string { + return kn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kn *kn) WeekdaysNarrow() []string { + return kn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kn *kn) WeekdayShort(weekday time.Weekday) string { + return kn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kn *kn) WeekdaysShort() []string { + return kn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kn *kn) WeekdayWide(weekday time.Weekday) string { + return kn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kn *kn) WeekdaysWide() []string { + return kn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kn' and handles both Whole and Real numbers based on 'v' +func (kn *kn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kn *kn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kn' +func (kn *kn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kn.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kn' +// in accounting notation. +func (kn *kn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kn.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kn.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kn' +func (kn *kn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kn' +func (kn *kn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kn' +func (kn *kn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kn' +func (kn *kn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, kn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kn' +func (kn *kn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kn.periodsAbbreviated[0]...) + } else { + b = append(b, kn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kn' +func (kn *kn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kn.periodsAbbreviated[0]...) + } else { + b = append(b, kn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kn' +func (kn *kn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kn.periodsAbbreviated[0]...) + } else { + b = append(b, kn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kn' +func (kn *kn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kn.periodsAbbreviated[0]...) + } else { + b = append(b, kn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kn/kn_test.go b/vendor/github.com/go-playground/locales/kn/kn_test.go new file mode 100644 index 0000000000..6df80acb2e --- /dev/null +++ b/vendor/github.com/go-playground/locales/kn/kn_test.go @@ -0,0 +1,1120 @@ +package kn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kn_IN/kn_IN.go b/vendor/github.com/go-playground/locales/kn_IN/kn_IN.go new file mode 100644 index 0000000000..ec9ed68963 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kn_IN/kn_IN.go @@ -0,0 +1,641 @@ +package kn_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kn_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kn_IN' locale +func New() locales.Translator { + return &kn_IN{ + locale: "kn_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ಜನ", "ಫೆಬ್ರ", "ಮಾರ್ಚ್", "ಏಪ್ರಿ", "ಮೇ", "ಜೂನ್", "ಜುಲೈ", "ಆಗ", "ಸೆಪ್ಟೆಂ", "ಅಕ್ಟೋ", "ನವೆಂ", "ಡಿಸೆಂ"}, + monthsNarrow: []string{"", "ಜ", "ಫೆ", "ಮಾ", "ಏ", "ಮೇ", "ಜೂ", "ಜು", "ಆ", "ಸೆ", "ಅ", "ನ", "ಡಿ"}, + monthsWide: []string{"", "ಜನವರಿ", "ಫೆಬ್ರವರಿ", "ಮಾರ್ಚ್", "ಏಪ್ರಿಲ್", "ಮೇ", "ಜೂನ್", "ಜುಲೈ", "ಆಗಸ್ಟ್", "ಸೆಪ್ಟೆಂಬರ್", "ಅಕ್ಟೋಬರ್", "ನವೆಂಬರ್", "ಡಿಸೆಂಬರ್"}, + daysAbbreviated: []string{"ಭಾನು", "ಸೋಮ", "ಮಂಗಳ", "ಬುಧ", "ಗುರು", "ಶುಕ್ರ", "ಶನಿ"}, + daysNarrow: []string{"ಭಾ", "ಸೋ", "ಮಂ", "ಬು", "ಗು", "ಶು", "ಶ"}, + daysShort: []string{"ಭಾನು", "ಸೋಮ", "ಮಂಗಳ", "ಬುಧ", "ಗುರು", "ಶುಕ್ರ", "ಶನಿ"}, + daysWide: []string{"ಭಾನುವಾರ", "ಸೋಮವಾರ", "ಮಂಗಳವಾರ", "ಬುಧವಾರ", "ಗುರುವಾರ", "ಶುಕ್ರವಾರ", "ಶನಿವಾರ"}, + periodsAbbreviated: []string{"ಪೂರ್ವಾಹ್ನ", "ಅಪರಾಹ್ನ"}, + periodsNarrow: []string{"ಪೂ", "ಅ"}, + periodsWide: []string{"ಪೂರ್ವಾಹ್ನ", "ಅಪರಾಹ್ನ"}, + erasAbbreviated: []string{"ಕ್ರಿ.ಪೂ", "ಕ್ರಿ.ಶ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ಕ್ರಿಸ್ತ ಪೂರ್ವ", "ಕ್ರಿಸ್ತ ಶಕ"}, + timezones: map[string]string{"BOT": "ಬೊಲಿವಿಯಾ ಸಮಯ", "COST": "ಕೊಲಂಬಿಯಾ ಬೇಸಿಗೆ ಸಮಯ", "HNNOMX": "ವಾಯವ್ಯ ಮೆಕ್ಸಿಕೊ ಪ್ರಮಾಣಿತ ಸಮಯ", "CHAST": "ಚಥಾಮ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "∅∅∅": "ಏಕರ್ ಬೇಸಿಗೆ ಸಮಯ", "AKST": "ಅಲಸ್ಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "UYST": "ಉರುಗ್ವೇ ಬೇಸಿಗೆ ಸಮಯ", "HNPM": "ಸೇಂಟ್ ಪಿಯರ್ ಮತ್ತು ಮಿಕ್ವೆಲನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNPMX": "ಮೆಕ್ಸಿಕನ್ ಪೆಸಿಫಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "SRT": "ಸುರಿನೇಮ್ ಸಮಯ", "AWDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪಶ್ಚಿಮ ಹಗಲು ಸಮಯ", "HAT": "ನ್ಯೂಫೌಂಡ್\u200cಲ್ಯಾಂಡ್ ದಿನದ ಸಮಯ", "TMST": "ತುರ್ಕ್\u200cಮೇನಿಸ್ತಾನ್ ಬೇಸಿಗೆ ಸಮಯ", "WAT": "ಪಶ್ಚಿಮ ಆಫ್ರಿಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNOG": "ಪಶ್ಚಿಮ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "CST": "ಉತ್ತರ ಅಮೆರಿಕದ ಕೇಂದ್ರ ಪ್ರಮಾಣಿತ ಸಮಯ", "HECU": "ಕ್ಯೂಬಾ ದಿನದ ಸಮಯ", "WIB": "ಪಶ್ಚಿಮ ಇಂಡೋನೇಷಿಯ ಸಮಯ", "CAT": "ಮಧ್ಯ ಆಫ್ರಿಕಾ ಸಮಯ", "NZDT": "ನ್ಯೂಜಿಲ್ಯಾಂಡ್ ಹಗಲು ಸಮಯ", "AST": "ಅಟ್ಲಾಂಟಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "UYT": "ಉರುಗ್ವೇ ಪ್ರಮಾಣಿತ ಸಮಯ", "MYT": "ಮಲೇಷಿಯಾ ಸಮಯ", "AEST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪೂರ್ವ ಪ್ರಮಾಣಿತ ಸಮಯ", "SAST": "ದಕ್ಷಿಣ ಆಫ್ರಿಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNCU": "ಕ್ಯೂಬಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "ACWDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪಶ್ಚಿಮ ಹಗಲು ಸಮಯ", "MEZ": "ಮಧ್ಯ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "EST": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೂರ್ವದ ಪ್ರಮಾಣಿತ ಸಮಯ", "HEEG": "ಪೂರ್ವ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಬೇಸಿಗೆ ಸಮಯ", "GYT": "ಗಯಾನಾ ಸಮಯ", "HAST": "ಹವಾಯಿ-ಅಲ್ಯುಟಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ECT": "ಈಕ್ವೆಡಾರ್ ಸಮಯ", "ADT": "ಅಟ್ಲಾಂಟಿಕ್ ದಿನದ ಸಮಯ", "OESZ": "ಪೂರ್ವ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "WEZ": "ಪಶ್ಚಿಮ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "CLT": "ಚಿಲಿ ಪ್ರಮಾಣಿತ ಸಮಯ", "LHST": "ಲಾರ್ಡ್ ಹೋವ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ACDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಹಗಲು ಸಮಯ", "WESZ": "ಪಶ್ಚಿಮ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "EDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೂರ್ವದ ದಿನದ ಸಮಯ", "OEZ": "ಪೂರ್ವ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "LHDT": "ಲಾರ್ಡ್ ಹೋವ್ ಬೆಳಗಿನ ಸಮಯ", "HEPMX": "ಮೆಕ್ಸಿಕನ್ ಪೆಸಿಫಿಕ್ ಹಗಲು ಸಮಯ", "CHADT": "ಚಥಾಮ್ ಹಗಲು ಸಮಯ", "SGT": "ಸಿಂಗಾಪುರ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HADT": "ಹವಾಯಿ-ಅಲ್ಯುಟಿಯನ್ ಹಗಲು ಸಮಯ", "JDT": "ಜಪಾನ್ ಹಗಲು ಸಮಯ", "BT": "ಭೂತಾನ್ ಸಮಯ", "WART": "ಪಶ್ಚಿಮ ಅರ್ಜೆಂಟೀನಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "TMT": "ತುರ್ಕ್\u200cಮೇನಿಸ್ತಾನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "WAST": "ಪಶ್ಚಿಮ ಆಫ್ರಿಕಾ ಬೇಸಿಗೆ ಸಮಯ", "COT": "ಕೊಲಂಬಿಯಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "MESZ": "ಮಧ್ಯ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "MDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಪರ್ವತ ದಿನದ ಸಮಯ", "HEPM": "ಸೇಂಟ್ ಪಿಯರ್ ಮತ್ತು ಮಿಕ್ವೆಲನ್ ಹಗಲು ಸಮಯ", "CDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಕೇಂದ್ರೀಯ ದಿನದ ಸಮಯ", "WIT": "ಪೂರ್ವ ಇಂಡೋನೇಷಿಯಾ ಸಮಯ", "PDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೆಸಿಫಿಕ್ ದಿನದ ಸಮಯ", "IST": "ಭಾರತೀಯ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNEG": "ಪೂರ್ವ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "AEDT": "ಪೂರ್ವ ಆಸ್ಟ್ರೇಲಿಯಾದ ಹಗಲು ಸಮಯ", "WITA": "ಮಧ್ಯ ಇಂಡೋನೇಷಿಯಾ ಸಮಯ", "NZST": "ನ್ಯೂಜಿಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "GMT": "ಗ್ರೀನ್\u200cವಿಚ್ ಸರಾಸರಿ ಕಾಲಮಾನ", "CLST": "ಚಿಲಿ ಬೇಸಿಗೆ ಸಮಯ", "HEOG": "ಪಶ್ಚಿಮ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಬೇಸಿಗೆ ಸಮಯ", "HKST": "ಹಾಂಗ್ ಕಾಂಗ್ ಬೇಸಿಗೆ ಸಮಯ", "HNT": "ನ್ಯೂಫೌಂಡ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "PST": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೆಸಿಫಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ACWST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪಶ್ಚಿಮ ಪ್ರಮಾಣಿತ ಸಮಯ", "VET": "ವೆನಿಜುವೆಲಾ ಸಮಯ", "WARST": "ಪಶ್ಚಿಮ ಅರ್ಜೆಂಟೀನಾ ಬೇಸಿಗೆ ಸಮಯ", "AKDT": "\u200cಅಲಾಸ್ಕಾ ಹಗಲು ಸಮಯ", "GFT": "ಫ್ರೆಂಚ್ ಗಯಾನಾ ಸಮಯ", "ChST": "ಚಮೋರೋ ಪ್ರಮಾಣಿತ ಸಮಯ", "EAT": "ಪೂರ್ವ ಆಫ್ರಿಕಾ ಸಮಯ", "HENOMX": "ವಾಯವ್ಯ ಮೆಕ್ಸಿಕೊ ಹಗಲು ಸಮಯ", "MST": "ಉತ್ತರ ಅಮೆರಿಕದ ಪರ್ವತ ಪ್ರಮಾಣಿತ ಸಮಯ", "ARST": "ಅರ್ಜೆಂಟಿನಾ ಬೇಸಿಗೆ ಸಮಯ", "HKT": "ಹಾಂಗ್ ಕಾಂಗ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "AWST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪಶ್ಚಿಮ ಪ್ರಮಾಣಿತ ಸಮಯ", "ART": "ಅರ್ಜೆಂಟೀನಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "ACST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪ್ರಮಾಣಿತ ಸಮಯ", "JST": "ಜಪಾನ್ ಪ್ರಮಾಣಿತ ಸಮಯ"}, + } +} + +// Locale returns the current translators string locale +func (kn *kn_IN) Locale() string { + return kn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kn_IN' +func (kn *kn_IN) PluralsCardinal() []locales.PluralRule { + return kn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kn_IN' +func (kn *kn_IN) PluralsOrdinal() []locales.PluralRule { + return kn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kn_IN' +func (kn *kn_IN) PluralsRange() []locales.PluralRule { + return kn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kn_IN' +func (kn *kn_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kn_IN' +func (kn *kn_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kn_IN' +func (kn *kn_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := kn.CardinalPluralRule(num1, v1) + end := kn.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kn *kn_IN) MonthAbbreviated(month time.Month) string { + return kn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kn *kn_IN) MonthsAbbreviated() []string { + return kn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kn *kn_IN) MonthNarrow(month time.Month) string { + return kn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kn *kn_IN) MonthsNarrow() []string { + return kn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kn *kn_IN) MonthWide(month time.Month) string { + return kn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kn *kn_IN) MonthsWide() []string { + return kn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kn *kn_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return kn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kn *kn_IN) WeekdaysAbbreviated() []string { + return kn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kn *kn_IN) WeekdayNarrow(weekday time.Weekday) string { + return kn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kn *kn_IN) WeekdaysNarrow() []string { + return kn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kn *kn_IN) WeekdayShort(weekday time.Weekday) string { + return kn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kn *kn_IN) WeekdaysShort() []string { + return kn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kn *kn_IN) WeekdayWide(weekday time.Weekday) string { + return kn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kn *kn_IN) WeekdaysWide() []string { + return kn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kn_IN' and handles both Whole and Real numbers based on 'v' +func (kn *kn_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kn_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kn *kn_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kn_IN' +func (kn *kn_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kn.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kn_IN' +// in accounting notation. +func (kn *kn_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kn.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kn.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kn_IN' +func (kn *kn_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kn_IN' +func (kn *kn_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kn_IN' +func (kn *kn_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kn_IN' +func (kn *kn_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, kn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kn_IN' +func (kn *kn_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kn.periodsAbbreviated[0]...) + } else { + b = append(b, kn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kn_IN' +func (kn *kn_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kn.periodsAbbreviated[0]...) + } else { + b = append(b, kn.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kn_IN' +func (kn *kn_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kn.periodsAbbreviated[0]...) + } else { + b = append(b, kn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kn_IN' +func (kn *kn_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + if h < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kn.periodsAbbreviated[0]...) + } else { + b = append(b, kn.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kn_IN/kn_IN_test.go b/vendor/github.com/go-playground/locales/kn_IN/kn_IN_test.go new file mode 100644 index 0000000000..a070438e3b --- /dev/null +++ b/vendor/github.com/go-playground/locales/kn_IN/kn_IN_test.go @@ -0,0 +1,1120 @@ +package kn_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kn_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ko/ko.go b/vendor/github.com/go-playground/locales/ko/ko.go new file mode 100644 index 0000000000..5b957bf881 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ko/ko.go @@ -0,0 +1,599 @@ +package ko + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ko struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ko' locale +func New() locales.Translator { + return &ko{ + locale: "ko", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + monthsNarrow: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + monthsWide: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + daysAbbreviated: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysNarrow: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysShort: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysWide: []string{"일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"오전", "오후"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"기원전", "서기"}, + timezones: map[string]string{"OEZ": "동유럽 표준시", "OESZ": "동유럽 하계 표준시", "HNEG": "그린란드 동부 표준시", "ACWST": "오스트레일리아 중서부 표준시", "ACWDT": "오스트레일리아 중서부 하계 표준시", "MESZ": "중부 유럽 하계 표준시", "GMT": "그리니치 표준시", "CLT": "칠레 표준시", "HNPM": "세인트피에르 미클롱 표준시", "LHST": "로드 하우 표준시", "WAT": "서아프리카 표준시", "HENOMX": "멕시코 북서부 하계 표준시", "AEDT": "오스트레일리아 동부 하계 표준시", "HECU": "쿠바 하계 표준시", "ARST": "아르헨티나 하계 표준시", "COT": "콜롬비아 표준시", "WITA": "중부 인도네시아 시간", "ECT": "에콰도르 시간", "HEOG": "그린란드 서부 하계 표준시", "ADT": "미 대서양 하계 표준시", "MDT": "마카오 하계 표준시", "SGT": "싱가포르 표준시", "HNT": "뉴펀들랜드 표준시", "HEPMX": "멕시코 태평양 하계 표준시", "GYT": "가이아나 시간", "JDT": "일본 하계 표준시", "TMT": "투르크메니스탄 표준시", "WAST": "서아프리카 하계 표준시", "ChST": "차모로 시간", "HEPM": "세인트피에르 미클롱 하계 표준시", "HNCU": "쿠바 표준시", "PST": "미 태평양 표준시", "PDT": "미 태평양 하계 표준시", "CAT": "중앙아프리카 시간", "MST": "마카오 표준 시간", "BOT": "볼리비아 시간", "HADT": "하와이 알류샨 하계 표준시", "HKT": "홍콩 표준시", "AKST": "알래스카 표준시", "HEEG": "그린란드 동부 하계 표준시", "AKDT": "알래스카 하계 표준시", "UYT": "우루과이 표준시", "HAST": "하와이 알류샨 표준시", "NZST": "뉴질랜드 표준시", "MEZ": "중부 유럽 표준시", "ACST": "오스트레일리아 중부 표준시", "AWST": "오스트레일리아 서부 표준시", "CHADT": "채텀 하계 표준시", "VET": "베네수엘라 시간", "WEZ": "서유럽 표준시", "AEST": "오스트레일리아 동부 표준시", "NZDT": "뉴질랜드 하계 표준시", "AST": "대서양 표준시", "EST": "미 동부 표준시", "EDT": "미 동부 하계 표준시", "HNNOMX": "멕시코 북서부 표준시", "SAST": "남아프리카 시간", "LHDT": "로드 하우 하계 표준시", "∅∅∅": "아마존 하계 표준시", "JST": "일본 표준시", "MYT": "말레이시아 시간", "HKST": "홍콩 하계 표준시", "HAT": "뉴펀들랜드 하계 표준시", "SRT": "수리남 시간", "CST": "미 중부 표준시", "CDT": "미 중부 하계 표준시", "CHAST": "채텀 표준시", "WESZ": "서유럽 하계 표준시", "HNOG": "그린란드 서부 표준시", "BT": "부탄 시간", "WART": "아르헨티나 서부 표준시", "ART": "아르헨티나 표준시", "UYST": "우루과이 하계 표준시", "EAT": "동아프리카 시간", "WARST": "아르헨티나 서부 하계 표준시", "CLST": "칠레 하계 표준시", "TMST": "투르크메니스탄 하계 표준시", "WIB": "서부 인도네시아 시간", "GFT": "프랑스령 가이아나 시간", "HNPMX": "멕시코 태평양 표준시", "WIT": "동부 인도네시아 시간", "AWDT": "오스트레일리아 서부 하계 표준시", "IST": "인도 표준시", "ACDT": "오스트레일리아 중부 하계 표준시", "COST": "콜롬비아 하계 표준시"}, + } +} + +// Locale returns the current translators string locale +func (ko *ko) Locale() string { + return ko.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ko' +func (ko *ko) PluralsCardinal() []locales.PluralRule { + return ko.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ko' +func (ko *ko) PluralsOrdinal() []locales.PluralRule { + return ko.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ko' +func (ko *ko) PluralsRange() []locales.PluralRule { + return ko.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ko' +func (ko *ko) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ko' +func (ko *ko) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ko' +func (ko *ko) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ko *ko) MonthAbbreviated(month time.Month) string { + return ko.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ko *ko) MonthsAbbreviated() []string { + return ko.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ko *ko) MonthNarrow(month time.Month) string { + return ko.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ko *ko) MonthsNarrow() []string { + return ko.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ko *ko) MonthWide(month time.Month) string { + return ko.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ko *ko) MonthsWide() []string { + return ko.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ko *ko) WeekdayAbbreviated(weekday time.Weekday) string { + return ko.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ko *ko) WeekdaysAbbreviated() []string { + return ko.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ko *ko) WeekdayNarrow(weekday time.Weekday) string { + return ko.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ko *ko) WeekdaysNarrow() []string { + return ko.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ko *ko) WeekdayShort(weekday time.Weekday) string { + return ko.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ko *ko) WeekdaysShort() []string { + return ko.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ko *ko) WeekdayWide(weekday time.Weekday) string { + return ko.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ko *ko) WeekdaysWide() []string { + return ko.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ko' and handles both Whole and Real numbers based on 'v' +func (ko *ko) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ko' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ko *ko) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ko.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ko' +func (ko *ko) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ko.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ko.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ko' +// in accounting notation. +func (ko *ko) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ko.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ko.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ko.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ko.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ko' +func (ko *ko) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ko' +func (ko *ko) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ko' +func (ko *ko) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xeb, 0x85, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xec, 0x9b, 0x94, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xec, 0x9d, 0xbc}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ko' +func (ko *ko) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xeb, 0x85, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xec, 0x9b, 0x94, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xec, 0x9d, 0xbc, 0x20}...) + b = append(b, ko.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ko' +func (ko *ko) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ko.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ko' +func (ko *ko) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ko.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ko.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ko' +func (ko *ko) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0xec, 0x8b, 0x9c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0xeb, 0xb6, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0xec, 0xb4, 0x88, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ko' +func (ko *ko) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0xec, 0x8b, 0x9c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0xeb, 0xb6, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0xec, 0xb4, 0x88, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ko.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ko/ko_test.go b/vendor/github.com/go-playground/locales/ko/ko_test.go new file mode 100644 index 0000000000..2b29b38cde --- /dev/null +++ b/vendor/github.com/go-playground/locales/ko/ko_test.go @@ -0,0 +1,1120 @@ +package ko + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ko" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ko_KP/ko_KP.go b/vendor/github.com/go-playground/locales/ko_KP/ko_KP.go new file mode 100644 index 0000000000..fd1fc37ac7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ko_KP/ko_KP.go @@ -0,0 +1,599 @@ +package ko_KP + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ko_KP struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ko_KP' locale +func New() locales.Translator { + return &ko_KP{ + locale: "ko_KP", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + monthsNarrow: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + monthsWide: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + daysAbbreviated: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysNarrow: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysShort: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysWide: []string{"일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"오전", "오후"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"기원전", "서기"}, + timezones: map[string]string{"HAT": "뉴펀들랜드 하계 표준시", "WITA": "중부 인도네시아 시간", "HEPMX": "멕시코 태평양 하계 표준시", "HADT": "하와이 알류샨 하계 표준시", "IST": "인도 표준시", "OEZ": "동유럽 표준시", "HENOMX": "멕시코 북서부 하계 표준시", "HEPM": "세인트피에르 미클롱 하계 표준시", "HNPMX": "멕시코 태평양 표준시", "CST": "미 중부 표준시", "ACWST": "오스트레일리아 중서부 표준시", "JDT": "일본 하계 표준시", "WAT": "서아프리카 표준시", "HNNOMX": "멕시코 북서부 표준시", "EAT": "동아프리카 시간", "WEZ": "서유럽 표준시", "WART": "아르헨티나 서부 표준시", "HEOG": "그린란드 서부 하계 표준시", "AST": "대서양 표준시", "AEST": "오스트레일리아 동부 표준시", "HECU": "쿠바 하계 표준시", "MESZ": "중부 유럽 하계 표준시", "CLT": "칠레 표준시", "OESZ": "동유럽 하계 표준시", "TMT": "투르크메니스탄 표준시", "UYST": "우루과이 하계 표준시", "CHADT": "채텀 하계 표준시", "ECT": "에콰도르 시간", "PDT": "미 태평양 하계 표준시", "VET": "베네수엘라 시간", "WARST": "아르헨티나 서부 하계 표준시", "ChST": "차모로 시간", "HNCU": "쿠바 표준시", "PST": "미 태평양 표준시", "NZDT": "뉴질랜드 하계 표준시", "HKST": "홍콩 하계 표준시", "HNPM": "세인트피에르 미클롱 표준시", "SGT": "싱가포르 표준시", "HAST": "하와이 알류샨 표준시", "CAT": "중앙아프리카 시간", "LHST": "로드 하우 표준시", "LHDT": "로드 하우 하계 표준시", "AWDT": "오스트레일리아 서부 하계 표준시", "ART": "아르헨티나 표준시", "EDT": "미 동부 하계 표준시", "HEEG": "그린란드 동부 하계 표준시", "BT": "부탄 시간", "UYT": "우루과이 표준시", "CHAST": "채텀 표준시", "MST": "마카오 표준 시간", "MDT": "마카오 하계 표준시", "ARST": "아르헨티나 하계 표준시", "HNT": "뉴펀들랜드 표준시", "AKDT": "알래스카 하계 표준시", "GYT": "가이아나 시간", "WIB": "서부 인도네시아 시간", "AWST": "오스트레일리아 서부 표준시", "JST": "일본 표준시", "GMT": "그리니치 표준시", "TMST": "투르크메니스탄 하계 표준시", "HNEG": "그린란드 동부 표준시", "WESZ": "서유럽 하계 표준시", "WAST": "서아프리카 하계 표준시", "COST": "콜롬비아 하계 표준시", "ACWDT": "오스트레일리아 중서부 하계 표준시", "ACST": "오스트레일리아 중부 표준시", "SRT": "수리남 시간", "BOT": "볼리비아 시간", "ACDT": "오스트레일리아 중부 하계 표준시", "GFT": "프랑스령 가이아나 시간", "AKST": "알래스카 표준시", "SAST": "남아프리카 시간", "MEZ": "중부 유럽 표준시", "MYT": "말레이시아 시간", "CLST": "칠레 하계 표준시", "EST": "미 동부 표준시", "CDT": "미 중부 하계 표준시", "HNOG": "그린란드 서부 표준시", "ADT": "미 대서양 하계 표준시", "WIT": "동부 인도네시아 시간", "NZST": "뉴질랜드 표준시", "∅∅∅": "아마존 하계 표준시", "HKT": "홍콩 표준시", "COT": "콜롬비아 표준시", "AEDT": "오스트레일리아 동부 하계 표준시"}, + } +} + +// Locale returns the current translators string locale +func (ko *ko_KP) Locale() string { + return ko.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ko_KP' +func (ko *ko_KP) PluralsCardinal() []locales.PluralRule { + return ko.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ko_KP' +func (ko *ko_KP) PluralsOrdinal() []locales.PluralRule { + return ko.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ko_KP' +func (ko *ko_KP) PluralsRange() []locales.PluralRule { + return ko.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ko_KP' +func (ko *ko_KP) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ko_KP' +func (ko *ko_KP) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ko_KP' +func (ko *ko_KP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ko *ko_KP) MonthAbbreviated(month time.Month) string { + return ko.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ko *ko_KP) MonthsAbbreviated() []string { + return ko.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ko *ko_KP) MonthNarrow(month time.Month) string { + return ko.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ko *ko_KP) MonthsNarrow() []string { + return ko.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ko *ko_KP) MonthWide(month time.Month) string { + return ko.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ko *ko_KP) MonthsWide() []string { + return ko.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ko *ko_KP) WeekdayAbbreviated(weekday time.Weekday) string { + return ko.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ko *ko_KP) WeekdaysAbbreviated() []string { + return ko.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ko *ko_KP) WeekdayNarrow(weekday time.Weekday) string { + return ko.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ko *ko_KP) WeekdaysNarrow() []string { + return ko.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ko *ko_KP) WeekdayShort(weekday time.Weekday) string { + return ko.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ko *ko_KP) WeekdaysShort() []string { + return ko.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ko *ko_KP) WeekdayWide(weekday time.Weekday) string { + return ko.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ko *ko_KP) WeekdaysWide() []string { + return ko.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ko_KP' and handles both Whole and Real numbers based on 'v' +func (ko *ko_KP) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ko_KP' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ko *ko_KP) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ko.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ko_KP' +func (ko *ko_KP) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ko.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ko.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ko_KP' +// in accounting notation. +func (ko *ko_KP) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ko.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ko.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ko.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ko.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ko_KP' +func (ko *ko_KP) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ko_KP' +func (ko *ko_KP) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ko_KP' +func (ko *ko_KP) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xeb, 0x85, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xec, 0x9b, 0x94, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xec, 0x9d, 0xbc}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ko_KP' +func (ko *ko_KP) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xeb, 0x85, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xec, 0x9b, 0x94, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xec, 0x9d, 0xbc, 0x20}...) + b = append(b, ko.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ko_KP' +func (ko *ko_KP) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ko.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ko_KP' +func (ko *ko_KP) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ko.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ko.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ko_KP' +func (ko *ko_KP) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0xec, 0x8b, 0x9c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0xeb, 0xb6, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0xec, 0xb4, 0x88, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ko_KP' +func (ko *ko_KP) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0xec, 0x8b, 0x9c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0xeb, 0xb6, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0xec, 0xb4, 0x88, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ko.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ko_KP/ko_KP_test.go b/vendor/github.com/go-playground/locales/ko_KP/ko_KP_test.go new file mode 100644 index 0000000000..5e2da590d2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ko_KP/ko_KP_test.go @@ -0,0 +1,1120 @@ +package ko_KP + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ko_KP" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ko_KR/ko_KR.go b/vendor/github.com/go-playground/locales/ko_KR/ko_KR.go new file mode 100644 index 0000000000..69419be901 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ko_KR/ko_KR.go @@ -0,0 +1,599 @@ +package ko_KR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ko_KR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ko_KR' locale +func New() locales.Translator { + return &ko_KR{ + locale: "ko_KR", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + monthsNarrow: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + monthsWide: []string{"", "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"}, + daysAbbreviated: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysNarrow: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysShort: []string{"일", "월", "화", "수", "목", "금", "토"}, + daysWide: []string{"일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"오전", "오후"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"기원전", "서기"}, + timezones: map[string]string{"BT": "부탄 시간", "AEST": "오스트레일리아 동부 표준시", "HECU": "쿠바 하계 표준시", "ECT": "에콰도르 시간", "MEZ": "중부 유럽 표준시", "WART": "아르헨티나 서부 표준시", "AST": "대서양 표준시", "HKT": "홍콩 표준시", "ACDT": "오스트레일리아 중부 하계 표준시", "GYT": "가이아나 시간", "ACWDT": "오스트레일리아 중서부 하계 표준시", "MESZ": "중부 유럽 하계 표준시", "OESZ": "동유럽 하계 표준시", "WIB": "서부 인도네시아 시간", "PST": "미 태평양 표준시", "∅∅∅": "아마존 하계 표준시", "ADT": "미 대서양 하계 표준시", "ACST": "오스트레일리아 중부 표준시", "HNEG": "그린란드 동부 표준시", "CHADT": "채텀 하계 표준시", "NZST": "뉴질랜드 표준시", "CLST": "칠레 하계 표준시", "OEZ": "동유럽 표준시", "MST": "마카오 표준 시간", "LHDT": "로드 하우 하계 표준시", "WESZ": "서유럽 하계 표준시", "WARST": "아르헨티나 서부 하계 표준시", "CLT": "칠레 표준시", "HENOMX": "멕시코 북서부 하계 표준시", "COST": "콜롬비아 하계 표준시", "AKST": "알래스카 표준시", "HNPMX": "멕시코 태평양 표준시", "AWST": "오스트레일리아 서부 표준시", "ACWST": "오스트레일리아 중서부 표준시", "JST": "일본 표준시", "LHST": "로드 하우 표준시", "HAST": "하와이 알류샨 표준시", "WAT": "서아프리카 표준시", "SAST": "남아프리카 시간", "WAST": "서아프리카 하계 표준시", "WITA": "중부 인도네시아 시간", "HNCU": "쿠바 표준시", "JDT": "일본 하계 표준시", "TMST": "투르크메니스탄 하계 표준시", "GMT": "그리니치 표준시", "ART": "아르헨티나 표준시", "ARST": "아르헨티나 하계 표준시", "UYT": "우루과이 표준시", "UYST": "우루과이 하계 표준시", "AWDT": "오스트레일리아 서부 하계 표준시", "NZDT": "뉴질랜드 하계 표준시", "IST": "인도 표준시", "HADT": "하와이 알류샨 하계 표준시", "TMT": "투르크메니스탄 표준시", "MDT": "마카오 하계 표준시", "EDT": "미 동부 하계 표준시", "HNPM": "세인트피에르 미클롱 표준시", "BOT": "볼리비아 시간", "VET": "베네수엘라 시간", "HNOG": "그린란드 서부 표준시", "WEZ": "서유럽 표준시", "SGT": "싱가포르 표준시", "EAT": "동아프리카 시간", "HNNOMX": "멕시코 북서부 표준시", "GFT": "프랑스령 가이아나 시간", "HKST": "홍콩 하계 표준시", "COT": "콜롬비아 표준시", "HNT": "뉴펀들랜드 표준시", "AKDT": "알래스카 하계 표준시", "CDT": "미 중부 하계 표준시", "MYT": "말레이시아 시간", "HEOG": "그린란드 서부 하계 표준시", "PDT": "미 태평양 하계 표준시", "CAT": "중앙아프리카 시간", "CST": "미 중부 표준시", "CHAST": "채텀 표준시", "HEPM": "세인트피에르 미클롱 하계 표준시", "HEPMX": "멕시코 태평양 하계 표준시", "HAT": "뉴펀들랜드 하계 표준시", "AEDT": "오스트레일리아 동부 하계 표준시", "ChST": "차모로 시간", "SRT": "수리남 시간", "WIT": "동부 인도네시아 시간", "EST": "미 동부 표준시", "HEEG": "그린란드 동부 하계 표준시"}, + } +} + +// Locale returns the current translators string locale +func (ko *ko_KR) Locale() string { + return ko.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ko_KR' +func (ko *ko_KR) PluralsCardinal() []locales.PluralRule { + return ko.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ko_KR' +func (ko *ko_KR) PluralsOrdinal() []locales.PluralRule { + return ko.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ko_KR' +func (ko *ko_KR) PluralsRange() []locales.PluralRule { + return ko.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ko_KR' +func (ko *ko_KR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ko_KR' +func (ko *ko_KR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ko_KR' +func (ko *ko_KR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ko *ko_KR) MonthAbbreviated(month time.Month) string { + return ko.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ko *ko_KR) MonthsAbbreviated() []string { + return ko.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ko *ko_KR) MonthNarrow(month time.Month) string { + return ko.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ko *ko_KR) MonthsNarrow() []string { + return ko.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ko *ko_KR) MonthWide(month time.Month) string { + return ko.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ko *ko_KR) MonthsWide() []string { + return ko.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ko *ko_KR) WeekdayAbbreviated(weekday time.Weekday) string { + return ko.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ko *ko_KR) WeekdaysAbbreviated() []string { + return ko.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ko *ko_KR) WeekdayNarrow(weekday time.Weekday) string { + return ko.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ko *ko_KR) WeekdaysNarrow() []string { + return ko.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ko *ko_KR) WeekdayShort(weekday time.Weekday) string { + return ko.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ko *ko_KR) WeekdaysShort() []string { + return ko.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ko *ko_KR) WeekdayWide(weekday time.Weekday) string { + return ko.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ko *ko_KR) WeekdaysWide() []string { + return ko.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ko_KR' and handles both Whole and Real numbers based on 'v' +func (ko *ko_KR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ko_KR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ko *ko_KR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ko.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ko_KR' +func (ko *ko_KR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ko.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ko.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ko.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ko_KR' +// in accounting notation. +func (ko *ko_KR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ko.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ko.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ko.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ko.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ko.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ko.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ko_KR' +func (ko *ko_KR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ko_KR' +func (ko *ko_KR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ko_KR' +func (ko *ko_KR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xeb, 0x85, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xec, 0x9b, 0x94, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xec, 0x9d, 0xbc}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ko_KR' +func (ko *ko_KR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xeb, 0x85, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xec, 0x9b, 0x94, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xec, 0x9d, 0xbc, 0x20}...) + b = append(b, ko.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ko_KR' +func (ko *ko_KR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ko.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ko_KR' +func (ko *ko_KR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ko.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ko.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ko_KR' +func (ko *ko_KR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0xec, 0x8b, 0x9c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0xeb, 0xb6, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0xec, 0xb4, 0x88, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ko_KR' +func (ko *ko_KR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ko.periodsAbbreviated[0]...) + } else { + b = append(b, ko.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, []byte{0xec, 0x8b, 0x9c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0xeb, 0xb6, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0xec, 0xb4, 0x88, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ko.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ko_KR/ko_KR_test.go b/vendor/github.com/go-playground/locales/ko_KR/ko_KR_test.go new file mode 100644 index 0000000000..1a9ff91d42 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ko_KR/ko_KR_test.go @@ -0,0 +1,1120 @@ +package ko_KR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ko_KR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kok/kok.go b/vendor/github.com/go-playground/locales/kok/kok.go new file mode 100644 index 0000000000..f2d580c75e --- /dev/null +++ b/vendor/github.com/go-playground/locales/kok/kok.go @@ -0,0 +1,648 @@ +package kok + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kok struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kok' locale +func New() locales.Translator { + return &kok{ + locale: "kok", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsWide: []string{"", "जानेवारी", "फेब्रुवारी", "मार्च", "एप्रिल", "मे", "जून", "जुलै", "ओगस्ट", "सेप्टेंबर", "ओक्टोबर", "नोव्हेंबर", "डिसेंबर"}, + daysAbbreviated: []string{"रवि", "सोम", "मंगळ", "बुध", "गुरु", "शुक्र", "शनि"}, + daysWide: []string{"आदित्यवार", "सोमवार", "मंगळार", "बुधवार", "गुरुवार", "शुक्रवार", "शनिवार"}, + periodsAbbreviated: []string{"म.पू.", "म.नं."}, + periodsWide: []string{"म.पू.", "म.नं."}, + erasAbbreviated: []string{"क्रिस्तपूर्व", "क्रिस्तशखा"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"UYST": "UYST", "SGT": "SGT", "GMT": "GMT", "ARST": "ARST", "COT": "COT", "HNNOMX": "HNNOMX", "ChST": "ChST", "PST": "PST", "PDT": "PDT", "∅∅∅": "∅∅∅", "MESZ": "MESZ", "TMST": "TMST", "BT": "BT", "WITA": "WITA", "MEZ": "MEZ", "ADT": "ADT", "MST": "MST", "EDT": "EDT", "GYT": "GYT", "ECT": "ECT", "ACWST": "ACWST", "NZDT": "NZDT", "JDT": "JDT", "MYT": "MYT", "HEOG": "HEOG", "ACST": "ACST", "LHDT": "LHDT", "WIT": "WIT", "JST": "JST", "MDT": "MDT", "WAST": "WAST", "HKST": "HKST", "ACDT": "ACDT", "HNEG": "HNEG", "HNPMX": "HNPMX", "HNPM": "HNPM", "WESZ": "WESZ", "ART": "ART", "HNT": "HNT", "AKST": "AKST", "ACWDT": "ACWDT", "WARST": "WARST", "HAT": "HAT", "HEPM": "HEPM", "SAST": "SAST", "SRT": "SRT", "HNCU": "HNCU", "HECU": "HECU", "IST": "भारतीय समय", "WEZ": "WEZ", "UYT": "UYT", "CST": "CST", "AWST": "AWST", "CHAST": "CHAST", "CAT": "CAT", "HENOMX": "HENOMX", "HEEG": "HEEG", "GFT": "GFT", "AKDT": "AKDT", "AEDT": "AEDT", "LHST": "LHST", "AWDT": "AWDT", "CHADT": "CHADT", "HAST": "HAST", "VET": "VET", "HNOG": "HNOG", "AST": "AST", "OEZ": "OEZ", "OESZ": "OESZ", "WART": "WART", "CLST": "CLST", "EST": "EST", "AEST": "AEST", "TMT": "TMT", "WAT": "WAT", "HKT": "HKT", "COST": "COST", "CDT": "CDT", "BOT": "BOT", "HADT": "HADT", "NZST": "NZST", "CLT": "CLT", "HEPMX": "HEPMX", "EAT": "EAT", "WIB": "WIB"}, + } +} + +// Locale returns the current translators string locale +func (kok *kok) Locale() string { + return kok.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kok' +func (kok *kok) PluralsCardinal() []locales.PluralRule { + return kok.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kok' +func (kok *kok) PluralsOrdinal() []locales.PluralRule { + return kok.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kok' +func (kok *kok) PluralsRange() []locales.PluralRule { + return kok.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kok' +func (kok *kok) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kok' +func (kok *kok) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kok' +func (kok *kok) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kok *kok) MonthAbbreviated(month time.Month) string { + return kok.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kok *kok) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kok *kok) MonthNarrow(month time.Month) string { + return kok.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kok *kok) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kok *kok) MonthWide(month time.Month) string { + return kok.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kok *kok) MonthsWide() []string { + return kok.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kok *kok) WeekdayAbbreviated(weekday time.Weekday) string { + return kok.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kok *kok) WeekdaysAbbreviated() []string { + return kok.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kok *kok) WeekdayNarrow(weekday time.Weekday) string { + return kok.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kok *kok) WeekdaysNarrow() []string { + return kok.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kok *kok) WeekdayShort(weekday time.Weekday) string { + return kok.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kok *kok) WeekdaysShort() []string { + return kok.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kok *kok) WeekdayWide(weekday time.Weekday) string { + return kok.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kok *kok) WeekdaysWide() []string { + return kok.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kok' and handles both Whole and Real numbers based on 'v' +func (kok *kok) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kok.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, kok.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kok.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kok' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kok *kok) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kok.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kok.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kok.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kok' +func (kok *kok) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kok.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kok.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, kok.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kok.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, kok.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, kok.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kok.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kok' +// in accounting notation. +func (kok *kok) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kok.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kok.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, kok.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kok.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, kok.currencyNegativePrefix[j]) + } + + b = append(b, kok.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kok.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, kok.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kok.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kok' +func (kok *kok) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kok' +func (kok *kok) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kok' +func (kok *kok) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kok.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kok' +func (kok *kok) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kok.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kok.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kok' +func (kok *kok) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kok.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kok.periodsAbbreviated[0]...) + } else { + b = append(b, kok.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kok' +func (kok *kok) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kok.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kok.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kok.periodsAbbreviated[0]...) + } else { + b = append(b, kok.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kok' +func (kok *kok) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kok.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kok.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kok.periodsAbbreviated[0]...) + } else { + b = append(b, kok.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kok' +func (kok *kok) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kok.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kok.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kok.periodsAbbreviated[0]...) + } else { + b = append(b, kok.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kok.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kok/kok_test.go b/vendor/github.com/go-playground/locales/kok/kok_test.go new file mode 100644 index 0000000000..7188e5ccce --- /dev/null +++ b/vendor/github.com/go-playground/locales/kok/kok_test.go @@ -0,0 +1,1120 @@ +package kok + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kok" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kok_IN/kok_IN.go b/vendor/github.com/go-playground/locales/kok_IN/kok_IN.go new file mode 100644 index 0000000000..b58801839a --- /dev/null +++ b/vendor/github.com/go-playground/locales/kok_IN/kok_IN.go @@ -0,0 +1,648 @@ +package kok_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kok_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kok_IN' locale +func New() locales.Translator { + return &kok_IN{ + locale: "kok_IN", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsWide: []string{"", "जानेवारी", "फेब्रुवारी", "मार्च", "एप्रिल", "मे", "जून", "जुलै", "ओगस्ट", "सेप्टेंबर", "ओक्टोबर", "नोव्हेंबर", "डिसेंबर"}, + daysAbbreviated: []string{"रवि", "सोम", "मंगळ", "बुध", "गुरु", "शुक्र", "शनि"}, + daysWide: []string{"आदित्यवार", "सोमवार", "मंगळार", "बुधवार", "गुरुवार", "शुक्रवार", "शनिवार"}, + periodsAbbreviated: []string{"म.पू.", "म.नं."}, + periodsWide: []string{"म.पू.", "म.नं."}, + erasAbbreviated: []string{"क्रिस्तपूर्व", "क्रिस्तशखा"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"AWDT": "AWDT", "MYT": "MYT", "ADT": "ADT", "HAT": "HAT", "SRT": "SRT", "GYT": "GYT", "WIT": "WIT", "HADT": "HADT", "HNEG": "HNEG", "AKDT": "AKDT", "AEDT": "AEDT", "CAT": "CAT", "HNT": "HNT", "AKST": "AKST", "EAT": "EAT", "WARST": "WARST", "HKT": "HKT", "HENOMX": "HENOMX", "BT": "BT", "PST": "PST", "MEZ": "MEZ", "HNOG": "HNOG", "HEOG": "HEOG", "OESZ": "OESZ", "ART": "ART", "ACST": "ACST", "WIB": "WIB", "NZDT": "NZDT", "OEZ": "OEZ", "GMT": "GMT", "ECT": "ECT", "CLT": "CLT", "WAT": "WAT", "AEST": "AEST", "UYT": "UYT", "HEPM": "HEPM", "LHDT": "LHDT", "HECU": "HECU", "CHAST": "CHAST", "MESZ": "MESZ", "TMT": "TMT", "WAST": "WAST", "GFT": "GFT", "WESZ": "WESZ", "MDT": "MDT", "ARST": "ARST", "COT": "COT", "COST": "COST", "LHST": "LHST", "HNPMX": "HNPMX", "CST": "CST", "CHADT": "CHADT", "PDT": "PDT", "ACWDT": "ACWDT", "WART": "WART", "AWST": "AWST", "HAST": "HAST", "NZST": "NZST", "EST": "EST", "HEEG": "HEEG", "ChST": "ChST", "UYST": "UYST", "HEPMX": "HEPMX", "BOT": "BOT", "IST": "भारतीय समय", "ACWST": "ACWST", "VET": "VET", "WEZ": "WEZ", "EDT": "EDT", "ACDT": "ACDT", "HNPM": "HNPM", "CDT": "CDT", "∅∅∅": "∅∅∅", "SGT": "SGT", "TMST": "TMST", "HNNOMX": "HNNOMX", "AST": "AST", "JST": "JST", "JDT": "JDT", "MST": "MST", "HNCU": "HNCU", "CLST": "CLST", "HKST": "HKST", "WITA": "WITA", "SAST": "SAST"}, + } +} + +// Locale returns the current translators string locale +func (kok *kok_IN) Locale() string { + return kok.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kok_IN' +func (kok *kok_IN) PluralsCardinal() []locales.PluralRule { + return kok.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kok_IN' +func (kok *kok_IN) PluralsOrdinal() []locales.PluralRule { + return kok.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kok_IN' +func (kok *kok_IN) PluralsRange() []locales.PluralRule { + return kok.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kok_IN' +func (kok *kok_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kok_IN' +func (kok *kok_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kok_IN' +func (kok *kok_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kok *kok_IN) MonthAbbreviated(month time.Month) string { + return kok.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kok *kok_IN) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kok *kok_IN) MonthNarrow(month time.Month) string { + return kok.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kok *kok_IN) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kok *kok_IN) MonthWide(month time.Month) string { + return kok.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kok *kok_IN) MonthsWide() []string { + return kok.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kok *kok_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return kok.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kok *kok_IN) WeekdaysAbbreviated() []string { + return kok.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kok *kok_IN) WeekdayNarrow(weekday time.Weekday) string { + return kok.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kok *kok_IN) WeekdaysNarrow() []string { + return kok.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kok *kok_IN) WeekdayShort(weekday time.Weekday) string { + return kok.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kok *kok_IN) WeekdaysShort() []string { + return kok.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kok *kok_IN) WeekdayWide(weekday time.Weekday) string { + return kok.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kok *kok_IN) WeekdaysWide() []string { + return kok.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kok_IN' and handles both Whole and Real numbers based on 'v' +func (kok *kok_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kok.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, kok.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kok.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kok_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kok *kok_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kok.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, kok.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, kok.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kok_IN' +func (kok *kok_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kok.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kok.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, kok.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kok.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, kok.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, kok.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kok.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kok_IN' +// in accounting notation. +func (kok *kok_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kok.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kok.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, kok.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kok.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, kok.currencyNegativePrefix[j]) + } + + b = append(b, kok.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(kok.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, kok.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kok.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kok_IN' +func (kok *kok_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kok_IN' +func (kok *kok_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kok_IN' +func (kok *kok_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kok.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kok_IN' +func (kok *kok_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kok.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kok.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kok_IN' +func (kok *kok_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kok.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kok.periodsAbbreviated[0]...) + } else { + b = append(b, kok.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kok_IN' +func (kok *kok_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kok.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kok.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kok.periodsAbbreviated[0]...) + } else { + b = append(b, kok.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kok_IN' +func (kok *kok_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kok.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kok.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kok.periodsAbbreviated[0]...) + } else { + b = append(b, kok.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kok_IN' +func (kok *kok_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, kok.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kok.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, kok.periodsAbbreviated[0]...) + } else { + b = append(b, kok.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kok.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kok_IN/kok_IN_test.go b/vendor/github.com/go-playground/locales/kok_IN/kok_IN_test.go new file mode 100644 index 0000000000..0dc3b57709 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kok_IN/kok_IN_test.go @@ -0,0 +1,1120 @@ +package kok_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kok_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ks/ks.go b/vendor/github.com/go-playground/locales/ks/ks.go new file mode 100644 index 0000000000..baa66d1b0b --- /dev/null +++ b/vendor/github.com/go-playground/locales/ks/ks.go @@ -0,0 +1,659 @@ +package ks + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ks struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ks' locale +func New() locales.Translator { + return &ks{ + locale: "ks", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "‎-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsNarrow: []string{"", "ج", "ف", "م", "ا", "م", "ج", "ج", "ا", "س", "س", "ا", "ن"}, + monthsWide: []string{"", "جنؤری", "فرؤری", "مارٕچ", "اپریل", "میٔ", "جوٗن", "جوٗلایی", "اگست", "ستمبر", "اکتوٗبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"آتھوار", "ژٔنٛدٕروار", "بوٚموار", "بودوار", "برٛٮ۪سوار", "جُمہ", "بٹوار"}, + daysNarrow: []string{"ا", "ژ", "ب", "ب", "ب", "ج", "ب"}, + daysWide: []string{"اَتھوار", "ژٔنٛدرٕروار", "بوٚموار", "بودوار", "برٛٮ۪سوار", "جُمہ", "بٹوار"}, + erasAbbreviated: []string{"بی سی", "اے ڈی"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"قبٕل مسیٖح", "عیٖسوی سنہٕ"}, + timezones: map[string]string{"HAST": "حَواے اٮ۪لیوٗٹِیَن سٹینڑاڑ ٹایِم", "AST": "اٮ۪ٹلانٹِک سٹینڑاڑ ٹایِم", "HNNOMX": "HNNOMX", "GFT": "فرٛٮ۪نٛچ گیوٗٮ۪نا ٹایِم", "AEST": "آسٹریلِیَن مشرقی سٹینڑاڑ ٹایِم", "HEPM": "سینٛٹ پَیری مِقیوٗلَن ڑےلایِٔٹ ٹایِم", "SRT": "سُرِنام ٹایِم", "WAST": "مغربی افریٖقا سَمَر ٹایِم", "∅∅∅": "پٔروٗ سَمَر ٹایِم", "AKDT": "اٮ۪لاسکا ڈےلایِٔٹ ٹایِم", "HADT": "حَواے اٮ۪لیوٗٹِیَن سَمَر ٹایِم", "ACDT": "آسٹریلِیَن مرکزی ڈےلایِٔٹ ٹایِم", "COT": "کولومبِیا سٹینڑاڑ ٹایِم", "AKST": "اٮ۪لاسکا سٹینڑاڑ ٹایِم", "UYT": "یوٗرٮ۪گوَے سٹینڑاڑ ٹایِم", "CST": "مرکزی سٹینڑاڑ ٹایِم", "MST": "مَکَعوٗ سٹینڑاڑ ٹایِم", "EDT": "مشرقی ڈےلایِٔٹ ٹایِم", "ACST": "آسٹریلِیَن مرکزی سٹینڑاڑ ٹایِم", "HNPM": "سینٛٹ پَیری مِقیوٗلَن سٹینڑاڑ ٹایِم", "CLST": "چِلی سَمَر ٹایِم", "HAT": "نیوٗ فاونڑ لینڑ ڑےلایِٔٹ ٹایِم", "SAST": "جنوٗبی افریقا ٹایِم", "BOT": "بولِوِیا ٹایِم", "JDT": "جاپٲنۍ ڑےلایِٔٹ ٹایِم", "ART": "ارجٮ۪نٹیٖنا سٹینڑاڑ ٹایِم", "EAT": "مشرقی افریٖقا ٹایِم", "CDT": "مرکزی ڈےلایِٔٹ ٹایِم", "JST": "جاپٲنۍ سٹینڑاڑ ٹایِم", "OEZ": "مشرقی یوٗرپی سٹینڑاڑ ٹایِم", "HKST": "حانٛگ کانٛگ سَمَر ٹایِم", "BT": "بوٗٹان ٹایِم", "NZDT": "نِوزِلینڑ ڑےلایٔٹ ٹایِم", "WARST": "مغربی ارجٮ۪نٹیٖنا سَمَر ٹایِم", "CLT": "چِلی سٹینڑاڑ ٹایِم", "IST": "ہِنٛدوستان", "WESZ": "مغرِبی یوٗرِپی سَمَر ٹایِم", "GMT": "گرٛیٖن وِچ میٖن ٹایِم", "MDT": "مَکَعوٗ سَمَر ٹایِم", "HNT": "نیوٗ فاونڑلینڑ سٹینڑاڑ ٹایِم", "WIB": "مغرِبی اِنڑونیشِیا ٹایِم", "AWST": "آسٹریلِیَن مغرِبی سٹینڑاڑ ٹایِم", "CHAST": "کٮ۪تھَم سٹینڑاڑ ٹایِم", "MYT": "مَلیشِیا ٹایِم", "LHDT": "لعاڑ ڑےلایٔٹ ٹایِم", "HNPMX": "HNPMX", "OESZ": "مشرقی یوٗرپی سَمَر ٹایِم", "TMT": "تُرکمٮ۪نِستان سٹینڑاڑ ٹایِم", "GYT": "گُیَنا ٹایِم", "SGT": "سِنٛگاپوٗر ٹایِم", "VET": "وٮ۪نٮ۪زیوٗلا ٹایِم", "MEZ": "مرکزی یوٗرپی سٹینڑاڑ ٹایِم", "HNOG": "مغرِبی گریٖن لینڑُک سٹینڑاڑ ٹایِم", "HEOG": "مغرِبی گریٖن لینڑُک سَمَر ٹایِم", "HNEG": "مشرِقی گریٖن لینڑُک سٹینڑاڑ ٹایِم", "WITA": "مرکزی اِنڑونیشِیا ٹایِم", "PDT": "پیسِفِک ڈےلایِٔٹ ٹایِم", "CAT": "مرکزی افریٖقا ٹایِم", "ACWST": "آسٹریلِیَن مرکزی مغربی سٹینڑاڑ ٹایِم", "WAT": "مغربی افریٖقا سٹینڑاڑ ٹایِم", "HENOMX": "HENOMX", "UYST": "یوٗرٮ۪گوَے سَمَر ٹایِم", "WEZ": "مغرِبی یوٗرپی سٹینڑاڑ ٹایِم", "ChST": "کٮ۪مورو سٹینڑاڑ ٹایِم", "HEPMX": "HEPMX", "HECU": "کیوٗبا ڈےلایِٔٹ ٹایِم", "ARST": "ارجٮ۪نٹیٖنا سَمَر ٹایِم", "EST": "مشرقی سٹینڑاڑ ٹایِم", "HKT": "حانگ کانٛگ سٹینڑاڑ ٹایِم", "COST": "کولومبِیا سَمَر ٹایِم", "HEEG": "مشرِقی گریٖن لینڑُک سَمَر ٹایِم", "WIT": "مشرِقی اِنڑونیشِیا ٹایِم", "ACWDT": "آسٹریلِیَن مرکزی مغربی ڈےلایِٔٹ ٹایِم", "MESZ": "مرکزی یوٗرپی سَمَر ٹایِم", "TMST": "تُرکمٮ۪نِستان سَمَر ٹایِم", "AEDT": "آسٹریلِیَن مشرقی ڈےلایِٔٹ ٹایِم", "HNCU": "کیوٗبا سٹینڑاڑ ٹایِم", "AWDT": "آسٹریلِیَن مغرِبیٖ ڈےلایٔٹ ٹایِم", "NZST": "نِوزِلینڑ سٹینڑاڑ ٹایِم", "LHST": "لعاڑ حووے سٹینڑاڑ ٹایِم", "CHADT": "چٮ۪تھَم سَمَر ٹایِم", "WART": "مغربی ارجٮ۪نٹیٖنا سٹینڑاڑ ٹایِم", "ADT": "اٮ۪ٹلانٹِک ڈےلایِٔٹ ٹایِم", "ECT": "اِکویڑَر ٹایِم", "PST": "پیسِفِک سٹینڑاڑ ٹایِم"}, + } +} + +// Locale returns the current translators string locale +func (ks *ks) Locale() string { + return ks.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ks' +func (ks *ks) PluralsCardinal() []locales.PluralRule { + return ks.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ks' +func (ks *ks) PluralsOrdinal() []locales.PluralRule { + return ks.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ks' +func (ks *ks) PluralsRange() []locales.PluralRule { + return ks.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ks' +func (ks *ks) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ks' +func (ks *ks) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ks' +func (ks *ks) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ks *ks) MonthAbbreviated(month time.Month) string { + return ks.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ks *ks) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ks *ks) MonthNarrow(month time.Month) string { + return ks.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ks *ks) MonthsNarrow() []string { + return ks.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ks *ks) MonthWide(month time.Month) string { + return ks.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ks *ks) MonthsWide() []string { + return ks.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ks *ks) WeekdayAbbreviated(weekday time.Weekday) string { + return ks.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ks *ks) WeekdaysAbbreviated() []string { + return ks.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ks *ks) WeekdayNarrow(weekday time.Weekday) string { + return ks.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ks *ks) WeekdaysNarrow() []string { + return ks.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ks *ks) WeekdayShort(weekday time.Weekday) string { + return ks.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ks *ks) WeekdaysShort() []string { + return ks.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ks *ks) WeekdayWide(weekday time.Weekday) string { + return ks.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ks *ks) WeekdaysWide() []string { + return ks.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ks' and handles both Whole and Real numbers based on 'v' +func (ks *ks) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ks.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ks.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ks.minus) - 1; j >= 0; j-- { + b = append(b, ks.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ks' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ks *ks) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ks.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ks.minus) - 1; j >= 0; j-- { + b = append(b, ks.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ks.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ks' +func (ks *ks) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ks.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ks.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ks.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ks.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ks.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(ks.minus) - 1; j >= 0; j-- { + b = append(b, ks.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ks.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ks' +// in accounting notation. +func (ks *ks) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ks.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ks.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ks.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ks.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ks.currencyNegativePrefix[j]) + } + + for j := len(ks.minus) - 1; j >= 0; j-- { + b = append(b, ks.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ks.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ks.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ks.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ks' +func (ks *ks) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ks' +func (ks *ks) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ks.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ks' +func (ks *ks) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ks.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ks' +func (ks *ks) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ks.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ks.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ks' +func (ks *ks) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ks.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ks.periodsAbbreviated[0]...) + } else { + b = append(b, ks.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ks' +func (ks *ks) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ks.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ks.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ks.periodsAbbreviated[0]...) + } else { + b = append(b, ks.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ks' +func (ks *ks) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ks.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ks.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ks.periodsAbbreviated[0]...) + } else { + b = append(b, ks.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ks' +func (ks *ks) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ks.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ks.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ks.periodsAbbreviated[0]...) + } else { + b = append(b, ks.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ks.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ks/ks_test.go b/vendor/github.com/go-playground/locales/ks/ks_test.go new file mode 100644 index 0000000000..42b6119a0f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ks/ks_test.go @@ -0,0 +1,1120 @@ +package ks + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ks" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ks_IN/ks_IN.go b/vendor/github.com/go-playground/locales/ks_IN/ks_IN.go new file mode 100644 index 0000000000..d7b5894883 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ks_IN/ks_IN.go @@ -0,0 +1,659 @@ +package ks_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ks_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ks_IN' locale +func New() locales.Translator { + return &ks_IN{ + locale: "ks_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "‎-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsNarrow: []string{"", "ج", "ف", "م", "ا", "م", "ج", "ج", "ا", "س", "س", "ا", "ن"}, + monthsWide: []string{"", "جنؤری", "فرؤری", "مارٕچ", "اپریل", "میٔ", "جوٗن", "جوٗلایی", "اگست", "ستمبر", "اکتوٗبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"آتھوار", "ژٔنٛدٕروار", "بوٚموار", "بودوار", "برٛٮ۪سوار", "جُمہ", "بٹوار"}, + daysNarrow: []string{"ا", "ژ", "ب", "ب", "ب", "ج", "ب"}, + daysWide: []string{"اَتھوار", "ژٔنٛدرٕروار", "بوٚموار", "بودوار", "برٛٮ۪سوار", "جُمہ", "بٹوار"}, + erasAbbreviated: []string{"بی سی", "اے ڈی"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"قبٕل مسیٖح", "عیٖسوی سنہٕ"}, + timezones: map[string]string{"LHDT": "لعاڑ ڑےلایٔٹ ٹایِم", "HNCU": "کیوٗبا سٹینڑاڑ ٹایِم", "PST": "پیسِفِک سٹینڑاڑ ٹایِم", "OEZ": "مشرقی یوٗرپی سٹینڑاڑ ٹایِم", "JST": "جاپٲنۍ سٹینڑاڑ ٹایِم", "WART": "مغربی ارجٮ۪نٹیٖنا سٹینڑاڑ ٹایِم", "TMST": "تُرکمٮ۪نِستان سَمَر ٹایِم", "COST": "کولومبِیا سَمَر ٹایِم", "UYT": "یوٗرٮ۪گوَے سٹینڑاڑ ٹایِم", "WITA": "مرکزی اِنڑونیشِیا ٹایِم", "ChST": "کٮ۪مورو سٹینڑاڑ ٹایِم", "GYT": "گُیَنا ٹایِم", "AWST": "آسٹریلِیَن مغرِبی سٹینڑاڑ ٹایِم", "ACST": "آسٹریلِیَن مرکزی سٹینڑاڑ ٹایِم", "BT": "بوٗٹان ٹایِم", "HNT": "نیوٗ فاونڑلینڑ سٹینڑاڑ ٹایِم", "HAT": "نیوٗ فاونڑ لینڑ ڑےلایِٔٹ ٹایِم", "UYST": "یوٗرٮ۪گوَے سَمَر ٹایِم", "∅∅∅": "اٮ۪زورٕس سَمَر ٹ", "SAST": "جنوٗبی افریقا ٹایِم", "CHAST": "کٮ۪تھَم سٹینڑاڑ ٹایِم", "CHADT": "چٮ۪تھَم سَمَر ٹایِم", "OESZ": "مشرقی یوٗرپی سَمَر ٹایِم", "COT": "کولومبِیا سٹینڑاڑ ٹایِم", "HNNOMX": "HNNOMX", "NZDT": "نِوزِلینڑ ڑےلایٔٹ ٹایِم", "MST": "مَکَعوٗ سٹینڑاڑ ٹایِم", "AKDT": "اٮ۪لاسکا ڈےلایِٔٹ ٹایِم", "SRT": "سُرِنام ٹایِم", "IST": "ہِنٛدوستان", "ACWDT": "آسٹریلِیَن مرکزی مغربی ڈےلایِٔٹ ٹایِم", "VET": "وٮ۪نٮ۪زیوٗلا ٹایِم", "JDT": "جاپٲنۍ ڑےلایِٔٹ ٹایِم", "CLST": "چِلی سَمَر ٹایِم", "HKST": "حانٛگ کانٛگ سَمَر ٹایِم", "ACDT": "آسٹریلِیَن مرکزی ڈےلایِٔٹ ٹایِم", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "CST": "مرکزی سٹینڑاڑ ٹایِم", "ECT": "اِکویڑَر ٹایِم", "NZST": "نِوزِلینڑ سٹینڑاڑ ٹایِم", "MESZ": "مرکزی یوٗرپی سَمَر ٹایِم", "AST": "اٮ۪ٹلانٹِک سٹینڑاڑ ٹایِم", "AEST": "آسٹریلِیَن مشرقی سٹینڑاڑ ٹایِم", "HNPM": "سینٛٹ پَیری مِقیوٗلَن سٹینڑاڑ ٹایِم", "EST": "مشرقی سٹینڑاڑ ٹایِم", "HKT": "حانگ کانٛگ سٹینڑاڑ ٹایِم", "EAT": "مشرقی افریٖقا ٹایِم", "CAT": "مرکزی افریٖقا ٹایِم", "MYT": "مَلیشِیا ٹایِم", "HNOG": "مغرِبی گریٖن لینڑُک سٹینڑاڑ ٹایِم", "WESZ": "مغرِبی یوٗرِپی سَمَر ٹایِم", "ART": "ارجٮ۪نٹیٖنا سٹینڑاڑ ٹایِم", "ARST": "ارجٮ۪نٹیٖنا سَمَر ٹایِم", "WIB": "مغرِبی اِنڑونیشِیا ٹایِم", "PDT": "پیسِفِک ڈےلایِٔٹ ٹایِم", "ACWST": "آسٹریلِیَن مرکزی مغربی سٹینڑاڑ ٹایِم", "WAT": "مغربی افریٖقا سٹینڑاڑ ٹایِم", "HEPM": "سینٛٹ پَیری مِقیوٗلَن ڑےلایِٔٹ ٹایِم", "HECU": "کیوٗبا ڈےلایِٔٹ ٹایِم", "SGT": "سِنٛگاپوٗر ٹایِم", "HEOG": "مغرِبی گریٖن لینڑُک سَمَر ٹایِم", "WIT": "مشرِقی اِنڑونیشِیا ٹایِم", "WARST": "مغربی ارجٮ۪نٹیٖنا سَمَر ٹایِم", "GMT": "گرٛیٖن وِچ میٖن ٹایِم", "MDT": "مَکَعوٗ سَمَر ٹایِم", "HEEG": "مشرِقی گریٖن لینڑُک سَمَر ٹایِم", "GFT": "فرٛٮ۪نٛچ گیوٗٮ۪نا ٹایِم", "BOT": "بولِوِیا ٹایِم", "HADT": "حَواے اٮ۪لیوٗٹِیَن سَمَر ٹایِم", "WEZ": "مغرِبی یوٗرپی سٹینڑاڑ ٹایِم", "AKST": "اٮ۪لاسکا سٹینڑاڑ ٹایِم", "AEDT": "آسٹریلِیَن مشرقی ڈےلایِٔٹ ٹایِم", "LHST": "لعاڑ حووے سٹینڑاڑ ٹایِم", "HAST": "حَواے اٮ۪لیوٗٹِیَن سٹینڑاڑ ٹایِم", "ADT": "اٮ۪ٹلانٹِک ڈےلایِٔٹ ٹایِم", "WAST": "مغربی افریٖقا سَمَر ٹایِم", "HENOMX": "HENOMX", "CDT": "مرکزی ڈےلایِٔٹ ٹایِم", "AWDT": "آسٹریلِیَن مغرِبیٖ ڈےلایٔٹ ٹایِم", "MEZ": "مرکزی یوٗرپی سٹینڑاڑ ٹایِم", "CLT": "چِلی سٹینڑاڑ ٹایِم", "TMT": "تُرکمٮ۪نِستان سٹینڑاڑ ٹایِم", "EDT": "مشرقی ڈےلایِٔٹ ٹایِم", "HNEG": "مشرِقی گریٖن لینڑُک سٹینڑاڑ ٹایِم"}, + } +} + +// Locale returns the current translators string locale +func (ks *ks_IN) Locale() string { + return ks.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ks_IN' +func (ks *ks_IN) PluralsCardinal() []locales.PluralRule { + return ks.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ks_IN' +func (ks *ks_IN) PluralsOrdinal() []locales.PluralRule { + return ks.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ks_IN' +func (ks *ks_IN) PluralsRange() []locales.PluralRule { + return ks.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ks_IN' +func (ks *ks_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ks_IN' +func (ks *ks_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ks_IN' +func (ks *ks_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ks *ks_IN) MonthAbbreviated(month time.Month) string { + return ks.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ks *ks_IN) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ks *ks_IN) MonthNarrow(month time.Month) string { + return ks.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ks *ks_IN) MonthsNarrow() []string { + return ks.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ks *ks_IN) MonthWide(month time.Month) string { + return ks.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ks *ks_IN) MonthsWide() []string { + return ks.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ks *ks_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return ks.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ks *ks_IN) WeekdaysAbbreviated() []string { + return ks.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ks *ks_IN) WeekdayNarrow(weekday time.Weekday) string { + return ks.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ks *ks_IN) WeekdaysNarrow() []string { + return ks.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ks *ks_IN) WeekdayShort(weekday time.Weekday) string { + return ks.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ks *ks_IN) WeekdaysShort() []string { + return ks.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ks *ks_IN) WeekdayWide(weekday time.Weekday) string { + return ks.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ks *ks_IN) WeekdaysWide() []string { + return ks.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ks_IN' and handles both Whole and Real numbers based on 'v' +func (ks *ks_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ks.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ks.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ks.minus) - 1; j >= 0; j-- { + b = append(b, ks.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ks_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ks *ks_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ks.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ks.minus) - 1; j >= 0; j-- { + b = append(b, ks.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ks.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ks_IN' +func (ks *ks_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ks.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ks.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ks.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ks.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ks.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(ks.minus) - 1; j >= 0; j-- { + b = append(b, ks.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ks.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ks_IN' +// in accounting notation. +func (ks *ks_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ks.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ks.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ks.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ks.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ks.currencyNegativePrefix[j]) + } + + for j := len(ks.minus) - 1; j >= 0; j-- { + b = append(b, ks.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ks.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ks.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ks.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ks_IN' +func (ks *ks_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ks_IN' +func (ks *ks_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ks.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ks_IN' +func (ks *ks_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ks.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ks_IN' +func (ks *ks_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ks.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ks.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ks_IN' +func (ks *ks_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ks.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ks.periodsAbbreviated[0]...) + } else { + b = append(b, ks.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ks_IN' +func (ks *ks_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ks.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ks.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ks.periodsAbbreviated[0]...) + } else { + b = append(b, ks.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ks_IN' +func (ks *ks_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ks.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ks.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ks.periodsAbbreviated[0]...) + } else { + b = append(b, ks.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ks_IN' +func (ks *ks_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ks.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ks.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ks.periodsAbbreviated[0]...) + } else { + b = append(b, ks.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ks.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ks_IN/ks_IN_test.go b/vendor/github.com/go-playground/locales/ks_IN/ks_IN_test.go new file mode 100644 index 0000000000..a02bf47cc2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ks_IN/ks_IN_test.go @@ -0,0 +1,1120 @@ +package ks_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ks_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ksb/ksb.go b/vendor/github.com/go-playground/locales/ksb/ksb.go new file mode 100644 index 0000000000..da6bd8989c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksb/ksb.go @@ -0,0 +1,512 @@ +package ksb + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ksb struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ksb' locale +func New() locales.Translator { + return &ksb{ + locale: "ksb", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januali", "Febluali", "Machi", "Aplili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jmn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"2", "3", "4", "5", "A", "I", "1"}, + daysWide: []string{"Jumaapii", "Jumaatatu", "Jumaane", "Jumaatano", "Alhamisi", "Ijumaa", "Jumaamosi"}, + periodsAbbreviated: []string{"makeo", "nyiaghuo"}, + periodsWide: []string{"makeo", "nyiaghuo"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Klisto", "Baada ya Klisto"}, + timezones: map[string]string{"CST": "CST", "CDT": "CDT", "MST": "MST", "HNNOMX": "HNNOMX", "HNCU": "HNCU", "HNEG": "HNEG", "AKST": "AKST", "AKDT": "AKDT", "AWST": "AWST", "CHADT": "CHADT", "WESZ": "WESZ", "TMST": "TMST", "WAT": "WAT", "HEEG": "HEEG", "CHAST": "CHAST", "BOT": "BOT", "MYT": "MYT", "HKT": "HKT", "COST": "COST", "HNT": "HNT", "HKST": "HKST", "BT": "BT", "WITA": "WITA", "LHST": "LHST", "WART": "WART", "OEZ": "OEZ", "HAT": "HAT", "HNPMX": "HNPMX", "CLT": "CLT", "AST": "AST", "HECU": "HECU", "WIT": "WIT", "PDT": "PDT", "CAT": "CAT", "NZST": "NZST", "WARST": "WARST", "ART": "ART", "ARST": "ARST", "UYT": "UYT", "LHDT": "LHDT", "SRT": "SRT", "∅∅∅": "∅∅∅", "GFT": "GFT", "UYST": "UYST", "JDT": "JDT", "WEZ": "WEZ", "WAST": "WAST", "COT": "COT", "ACWST": "ACWST", "NZDT": "NZDT", "MESZ": "MESZ", "VET": "VET", "JST": "JST", "OESZ": "OESZ", "HNPM": "HNPM", "EAT": "EAT", "WIB": "WIB", "SGT": "SGT", "HAST": "HAST", "GMT": "GMT", "ChST": "ChST", "AWDT": "AWDT", "MEZ": "MEZ", "SAST": "SAST", "GYT": "GYT", "ECT": "ECT", "HADT": "HADT", "IST": "IST", "EDT": "EDT", "ACDT": "ACDT", "HENOMX": "HENOMX", "ACWDT": "ACWDT", "CLST": "CLST", "HNOG": "HNOG", "EST": "EST", "HEOG": "HEOG", "ADT": "ADT", "MDT": "MDT", "ACST": "ACST", "AEDT": "AEDT", "HEPMX": "HEPMX", "PST": "PST", "TMT": "TMT", "AEST": "AEST", "HEPM": "HEPM"}, + } +} + +// Locale returns the current translators string locale +func (ksb *ksb) Locale() string { + return ksb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ksb' +func (ksb *ksb) PluralsCardinal() []locales.PluralRule { + return ksb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ksb' +func (ksb *ksb) PluralsOrdinal() []locales.PluralRule { + return ksb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ksb' +func (ksb *ksb) PluralsRange() []locales.PluralRule { + return ksb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ksb' +func (ksb *ksb) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ksb' +func (ksb *ksb) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ksb' +func (ksb *ksb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ksb *ksb) MonthAbbreviated(month time.Month) string { + return ksb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ksb *ksb) MonthsAbbreviated() []string { + return ksb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ksb *ksb) MonthNarrow(month time.Month) string { + return ksb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ksb *ksb) MonthsNarrow() []string { + return ksb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ksb *ksb) MonthWide(month time.Month) string { + return ksb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ksb *ksb) MonthsWide() []string { + return ksb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ksb *ksb) WeekdayAbbreviated(weekday time.Weekday) string { + return ksb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ksb *ksb) WeekdaysAbbreviated() []string { + return ksb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ksb *ksb) WeekdayNarrow(weekday time.Weekday) string { + return ksb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ksb *ksb) WeekdaysNarrow() []string { + return ksb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ksb *ksb) WeekdayShort(weekday time.Weekday) string { + return ksb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ksb *ksb) WeekdaysShort() []string { + return ksb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ksb *ksb) WeekdayWide(weekday time.Weekday) string { + return ksb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ksb *ksb) WeekdaysWide() []string { + return ksb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ksb' and handles both Whole and Real numbers based on 'v' +func (ksb *ksb) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ksb' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ksb *ksb) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ksb' +func (ksb *ksb) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksb.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ksb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ksb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ksb' +// in accounting notation. +func (ksb *ksb) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksb.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ksb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ksb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ksb' +func (ksb *ksb) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ksb' +func (ksb *ksb) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ksb' +func (ksb *ksb) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ksb' +func (ksb *ksb) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ksb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ksb' +func (ksb *ksb) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ksb' +func (ksb *ksb) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ksb' +func (ksb *ksb) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ksb' +func (ksb *ksb) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ksb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ksb/ksb_test.go b/vendor/github.com/go-playground/locales/ksb/ksb_test.go new file mode 100644 index 0000000000..7f8bff7b0b --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksb/ksb_test.go @@ -0,0 +1,1120 @@ +package ksb + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ksb" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ksb_TZ/ksb_TZ.go b/vendor/github.com/go-playground/locales/ksb_TZ/ksb_TZ.go new file mode 100644 index 0000000000..bb6f8e3deb --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksb_TZ/ksb_TZ.go @@ -0,0 +1,512 @@ +package ksb_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ksb_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ksb_TZ' locale +func New() locales.Translator { + return &ksb_TZ{ + locale: "ksb_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januali", "Febluali", "Machi", "Aplili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jmn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"2", "3", "4", "5", "A", "I", "1"}, + daysWide: []string{"Jumaapii", "Jumaatatu", "Jumaane", "Jumaatano", "Alhamisi", "Ijumaa", "Jumaamosi"}, + periodsAbbreviated: []string{"makeo", "nyiaghuo"}, + periodsWide: []string{"makeo", "nyiaghuo"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Klisto", "Baada ya Klisto"}, + timezones: map[string]string{"HNEG": "HNEG", "AWST": "AWST", "PDT": "PDT", "MESZ": "MESZ", "WARST": "WARST", "ACWST": "ACWST", "HEEG": "HEEG", "HNPMX": "HNPMX", "HKT": "HKT", "WAST": "WAST", "EST": "EST", "COT": "COT", "BOT": "BOT", "AST": "AST", "OEZ": "OEZ", "MST": "MST", "COST": "COST", "HAT": "HAT", "WEZ": "WEZ", "WART": "WART", "CLT": "CLT", "ARST": "ARST", "JDT": "JDT", "ADT": "ADT", "HKST": "HKST", "LHST": "LHST", "LHDT": "LHDT", "∅∅∅": "∅∅∅", "CDT": "CDT", "SGT": "SGT", "PST": "PST", "VET": "VET", "GMT": "GMT", "ChST": "ChST", "HNCU": "HNCU", "CHADT": "CHADT", "HAST": "HAST", "ACWDT": "ACWDT", "CHAST": "CHAST", "HADT": "HADT", "HNOG": "HNOG", "GFT": "GFT", "UYT": "UYT", "UYST": "UYST", "EAT": "EAT", "HECU": "HECU", "NZST": "NZST", "MEZ": "MEZ", "GYT": "GYT", "CST": "CST", "JST": "JST", "WITA": "WITA", "SRT": "SRT", "WIT": "WIT", "AWDT": "AWDT", "ART": "ART", "AKST": "AKST", "IST": "IST", "EDT": "EDT", "TMST": "TMST", "HEPMX": "HEPMX", "WIB": "WIB", "ECT": "ECT", "CLST": "CLST", "TMT": "TMT", "SAST": "SAST", "CAT": "CAT", "MYT": "MYT", "MDT": "MDT", "ACST": "ACST", "AKDT": "AKDT", "HEPM": "HEPM", "WAT": "WAT", "HNNOMX": "HNNOMX", "HNT": "HNT", "AEDT": "AEDT", "HENOMX": "HENOMX", "ACDT": "ACDT", "BT": "BT", "AEST": "AEST", "NZDT": "NZDT", "WESZ": "WESZ", "HEOG": "HEOG", "OESZ": "OESZ", "HNPM": "HNPM"}, + } +} + +// Locale returns the current translators string locale +func (ksb *ksb_TZ) Locale() string { + return ksb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ksb_TZ' +func (ksb *ksb_TZ) PluralsCardinal() []locales.PluralRule { + return ksb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ksb_TZ' +func (ksb *ksb_TZ) PluralsOrdinal() []locales.PluralRule { + return ksb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ksb_TZ' +func (ksb *ksb_TZ) PluralsRange() []locales.PluralRule { + return ksb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ksb_TZ' +func (ksb *ksb_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ksb_TZ' +func (ksb *ksb_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ksb_TZ' +func (ksb *ksb_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ksb *ksb_TZ) MonthAbbreviated(month time.Month) string { + return ksb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ksb *ksb_TZ) MonthsAbbreviated() []string { + return ksb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ksb *ksb_TZ) MonthNarrow(month time.Month) string { + return ksb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ksb *ksb_TZ) MonthsNarrow() []string { + return ksb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ksb *ksb_TZ) MonthWide(month time.Month) string { + return ksb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ksb *ksb_TZ) MonthsWide() []string { + return ksb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ksb *ksb_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return ksb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ksb *ksb_TZ) WeekdaysAbbreviated() []string { + return ksb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ksb *ksb_TZ) WeekdayNarrow(weekday time.Weekday) string { + return ksb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ksb *ksb_TZ) WeekdaysNarrow() []string { + return ksb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ksb *ksb_TZ) WeekdayShort(weekday time.Weekday) string { + return ksb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ksb *ksb_TZ) WeekdaysShort() []string { + return ksb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ksb *ksb_TZ) WeekdayWide(weekday time.Weekday) string { + return ksb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ksb *ksb_TZ) WeekdaysWide() []string { + return ksb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ksb_TZ' and handles both Whole and Real numbers based on 'v' +func (ksb *ksb_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ksb_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ksb *ksb_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksb.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ksb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ksb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ksb_TZ' +// in accounting notation. +func (ksb *ksb_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksb.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ksb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ksb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ksb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ksb_TZ' +func (ksb *ksb_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ksb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ksb_TZ/ksb_TZ_test.go b/vendor/github.com/go-playground/locales/ksb_TZ/ksb_TZ_test.go new file mode 100644 index 0000000000..748c939f58 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksb_TZ/ksb_TZ_test.go @@ -0,0 +1,1120 @@ +package ksb_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ksb_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ksf/ksf.go b/vendor/github.com/go-playground/locales/ksf/ksf.go new file mode 100644 index 0000000000..92aea31e76 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksf/ksf.go @@ -0,0 +1,545 @@ +package ksf + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ksf struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ksf' locale +func New() locales.Translator { + return &ksf{ + locale: "ksf", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ŋ1", "ŋ2", "ŋ3", "ŋ4", "ŋ5", "ŋ6", "ŋ7", "ŋ8", "ŋ9", "ŋ10", "ŋ11", "ŋ12"}, + monthsWide: []string{"", "ŋwíí a ntɔ́ntɔ", "ŋwíí akǝ bɛ́ɛ", "ŋwíí akǝ ráá", "ŋwíí akǝ nin", "ŋwíí akǝ táan", "ŋwíí akǝ táafɔk", "ŋwíí akǝ táabɛɛ", "ŋwíí akǝ táaraa", "ŋwíí akǝ táanin", "ŋwíí akǝ ntɛk", "ŋwíí akǝ ntɛk di bɔ́k", "ŋwíí akǝ ntɛk di bɛ́ɛ"}, + daysAbbreviated: []string{"sɔ́n", "lǝn", "maa", "mɛk", "jǝǝ", "júm", "sam"}, + daysNarrow: []string{"s", "l", "m", "m", "j", "j", "s"}, + daysWide: []string{"sɔ́ndǝ", "lǝndí", "maadí", "mɛkrɛdí", "jǝǝdí", "júmbá", "samdí"}, + periodsAbbreviated: []string{"sárúwá", "cɛɛ́nko"}, + periodsWide: []string{"sárúwá", "cɛɛ́nko"}, + erasAbbreviated: []string{"d.Y.", "k.Y."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"di Yɛ́sus aká yálɛ", "cámɛɛn kǝ kǝbɔpka Y"}, + timezones: map[string]string{"HNOG": "HNOG", "OEZ": "OEZ", "MYT": "MYT", "PDT": "PDT", "MEZ": "MEZ", "WART": "WART", "COST": "COST", "WITA": "WITA", "AKDT": "AKDT", "CHADT": "CHADT", "JDT": "JDT", "EST": "EST", "HKST": "HKST", "ECT": "ECT", "JST": "JST", "HNEG": "HNEG", "CLST": "CLST", "EDT": "EDT", "HEEG": "HEEG", "HADT": "HADT", "ACWDT": "ACWDT", "NZST": "NZST", "BOT": "BOT", "ACST": "ACST", "HENOMX": "HENOMX", "HEPM": "HEPM", "HECU": "HECU", "WIB": "WIB", "AWDT": "AWDT", "VET": "VET", "AEDT": "AEDT", "HEPMX": "HEPMX", "CAT": "CAT", "HAST": "HAST", "ACWST": "ACWST", "CLT": "CLT", "AKST": "AKST", "GFT": "GFT", "HNPM": "HNPM", "LHST": "LHST", "CHAST": "CHAST", "HEOG": "HEOG", "WEZ": "WEZ", "WARST": "WARST", "ARST": "ARST", "HNCU": "HNCU", "SGT": "SGT", "MESZ": "MESZ", "MDT": "MDT", "COT": "COT", "HNT": "HNT", "UYT": "UYT", "GYT": "GYT", "PST": "PST", "WESZ": "WESZ", "WAT": "WAT", "HKT": "HKT", "ACDT": "ACDT", "ChST": "ChST", "CST": "CST", "∅∅∅": "∅∅∅", "HNPMX": "HNPMX", "SRT": "SRT", "CDT": "CDT", "AST": "AST", "GMT": "GMT", "MST": "MST", "WAST": "WAST", "BT": "BT", "ADT": "ADT", "OESZ": "OESZ", "IST": "IST", "SAST": "SAST", "LHDT": "LHDT", "TMT": "TMT", "TMST": "TMST", "HNNOMX": "HNNOMX", "HAT": "HAT", "AEST": "AEST", "UYST": "UYST", "EAT": "EAT", "WIT": "WIT", "AWST": "AWST", "ART": "ART", "NZDT": "NZDT"}, + } +} + +// Locale returns the current translators string locale +func (ksf *ksf) Locale() string { + return ksf.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ksf' +func (ksf *ksf) PluralsCardinal() []locales.PluralRule { + return ksf.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ksf' +func (ksf *ksf) PluralsOrdinal() []locales.PluralRule { + return ksf.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ksf' +func (ksf *ksf) PluralsRange() []locales.PluralRule { + return ksf.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ksf' +func (ksf *ksf) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ksf' +func (ksf *ksf) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ksf' +func (ksf *ksf) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ksf *ksf) MonthAbbreviated(month time.Month) string { + return ksf.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ksf *ksf) MonthsAbbreviated() []string { + return ksf.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ksf *ksf) MonthNarrow(month time.Month) string { + return ksf.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ksf *ksf) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ksf *ksf) MonthWide(month time.Month) string { + return ksf.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ksf *ksf) MonthsWide() []string { + return ksf.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ksf *ksf) WeekdayAbbreviated(weekday time.Weekday) string { + return ksf.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ksf *ksf) WeekdaysAbbreviated() []string { + return ksf.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ksf *ksf) WeekdayNarrow(weekday time.Weekday) string { + return ksf.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ksf *ksf) WeekdaysNarrow() []string { + return ksf.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ksf *ksf) WeekdayShort(weekday time.Weekday) string { + return ksf.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ksf *ksf) WeekdaysShort() []string { + return ksf.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ksf *ksf) WeekdayWide(weekday time.Weekday) string { + return ksf.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ksf *ksf) WeekdaysWide() []string { + return ksf.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ksf' and handles both Whole and Real numbers based on 'v' +func (ksf *ksf) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksf.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksf.group) - 1; j >= 0; j-- { + b = append(b, ksf.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ksf.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ksf' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ksf *ksf) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ksf' +func (ksf *ksf) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksf.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksf.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksf.group) - 1; j >= 0; j-- { + b = append(b, ksf.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ksf.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksf.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ksf.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ksf' +// in accounting notation. +func (ksf *ksf) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksf.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksf.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksf.group) - 1; j >= 0; j-- { + b = append(b, ksf.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ksf.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksf.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ksf.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ksf.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ksf' +func (ksf *ksf) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ksf' +func (ksf *ksf) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksf.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ksf' +func (ksf *ksf) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksf.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ksf' +func (ksf *ksf) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ksf.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksf.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ksf' +func (ksf *ksf) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ksf' +func (ksf *ksf) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ksf' +func (ksf *ksf) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ksf' +func (ksf *ksf) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ksf.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ksf/ksf_test.go b/vendor/github.com/go-playground/locales/ksf/ksf_test.go new file mode 100644 index 0000000000..73f743cfd6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksf/ksf_test.go @@ -0,0 +1,1120 @@ +package ksf + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ksf" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ksf_CM/ksf_CM.go b/vendor/github.com/go-playground/locales/ksf_CM/ksf_CM.go new file mode 100644 index 0000000000..320e7abea3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksf_CM/ksf_CM.go @@ -0,0 +1,545 @@ +package ksf_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ksf_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ksf_CM' locale +func New() locales.Translator { + return &ksf_CM{ + locale: "ksf_CM", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ŋ1", "ŋ2", "ŋ3", "ŋ4", "ŋ5", "ŋ6", "ŋ7", "ŋ8", "ŋ9", "ŋ10", "ŋ11", "ŋ12"}, + monthsWide: []string{"", "ŋwíí a ntɔ́ntɔ", "ŋwíí akǝ bɛ́ɛ", "ŋwíí akǝ ráá", "ŋwíí akǝ nin", "ŋwíí akǝ táan", "ŋwíí akǝ táafɔk", "ŋwíí akǝ táabɛɛ", "ŋwíí akǝ táaraa", "ŋwíí akǝ táanin", "ŋwíí akǝ ntɛk", "ŋwíí akǝ ntɛk di bɔ́k", "ŋwíí akǝ ntɛk di bɛ́ɛ"}, + daysAbbreviated: []string{"sɔ́n", "lǝn", "maa", "mɛk", "jǝǝ", "júm", "sam"}, + daysNarrow: []string{"s", "l", "m", "m", "j", "j", "s"}, + daysWide: []string{"sɔ́ndǝ", "lǝndí", "maadí", "mɛkrɛdí", "jǝǝdí", "júmbá", "samdí"}, + periodsAbbreviated: []string{"sárúwá", "cɛɛ́nko"}, + periodsWide: []string{"sárúwá", "cɛɛ́nko"}, + erasAbbreviated: []string{"d.Y.", "k.Y."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"di Yɛ́sus aká yálɛ", "cámɛɛn kǝ kǝbɔpka Y"}, + timezones: map[string]string{"HEPMX": "HEPMX", "IST": "IST", "ACST": "ACST", "∅∅∅": "∅∅∅", "WIB": "WIB", "NZDT": "NZDT", "MEZ": "MEZ", "ADT": "ADT", "HNCU": "HNCU", "MESZ": "MESZ", "AST": "AST", "WEZ": "WEZ", "EDT": "EDT", "BT": "BT", "LHST": "LHST", "PDT": "PDT", "HNOG": "HNOG", "GMT": "GMT", "TMT": "TMT", "HEPM": "HEPM", "OESZ": "OESZ", "MYT": "MYT", "TMST": "TMST", "HNNOMX": "HNNOMX", "WITA": "WITA", "ECT": "ECT", "ACWDT": "ACWDT", "NZST": "NZST", "MDT": "MDT", "HNEG": "HNEG", "UYST": "UYST", "VET": "VET", "OEZ": "OEZ", "EST": "EST", "HAT": "HAT", "ChST": "ChST", "HAST": "HAST", "HADT": "HADT", "WARST": "WARST", "ACDT": "ACDT", "AKST": "AKST", "LHDT": "LHDT", "WIT": "WIT", "CHAST": "CHAST", "WART": "WART", "CLST": "CLST", "WAT": "WAT", "COT": "COT", "EAT": "EAT", "HECU": "HECU", "CHADT": "CHADT", "CAT": "CAT", "HENOMX": "HENOMX", "SAST": "SAST", "AWST": "AWST", "JST": "JST", "COST": "COST", "AKDT": "AKDT", "HNPMX": "HNPMX", "BOT": "BOT", "CLT": "CLT", "HNT": "HNT", "AEST": "AEST", "HNPM": "HNPM", "ART": "ART", "GYT": "GYT", "CST": "CST", "CDT": "CDT", "PST": "PST", "ACWST": "ACWST", "JDT": "JDT", "MST": "MST", "WAST": "WAST", "UYT": "UYT", "AWDT": "AWDT", "SGT": "SGT", "ARST": "ARST", "HKT": "HKT", "AEDT": "AEDT", "GFT": "GFT", "SRT": "SRT", "HEOG": "HEOG", "WESZ": "WESZ", "HKST": "HKST", "HEEG": "HEEG"}, + } +} + +// Locale returns the current translators string locale +func (ksf *ksf_CM) Locale() string { + return ksf.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ksf_CM' +func (ksf *ksf_CM) PluralsCardinal() []locales.PluralRule { + return ksf.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ksf_CM' +func (ksf *ksf_CM) PluralsOrdinal() []locales.PluralRule { + return ksf.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ksf_CM' +func (ksf *ksf_CM) PluralsRange() []locales.PluralRule { + return ksf.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ksf_CM' +func (ksf *ksf_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ksf_CM' +func (ksf *ksf_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ksf_CM' +func (ksf *ksf_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ksf *ksf_CM) MonthAbbreviated(month time.Month) string { + return ksf.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ksf *ksf_CM) MonthsAbbreviated() []string { + return ksf.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ksf *ksf_CM) MonthNarrow(month time.Month) string { + return ksf.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ksf *ksf_CM) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ksf *ksf_CM) MonthWide(month time.Month) string { + return ksf.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ksf *ksf_CM) MonthsWide() []string { + return ksf.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ksf *ksf_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return ksf.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ksf *ksf_CM) WeekdaysAbbreviated() []string { + return ksf.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ksf *ksf_CM) WeekdayNarrow(weekday time.Weekday) string { + return ksf.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ksf *ksf_CM) WeekdaysNarrow() []string { + return ksf.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ksf *ksf_CM) WeekdayShort(weekday time.Weekday) string { + return ksf.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ksf *ksf_CM) WeekdaysShort() []string { + return ksf.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ksf *ksf_CM) WeekdayWide(weekday time.Weekday) string { + return ksf.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ksf *ksf_CM) WeekdaysWide() []string { + return ksf.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ksf_CM' and handles both Whole and Real numbers based on 'v' +func (ksf *ksf_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksf.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksf.group) - 1; j >= 0; j-- { + b = append(b, ksf.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ksf.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ksf_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ksf *ksf_CM) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ksf_CM' +func (ksf *ksf_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksf.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksf.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksf.group) - 1; j >= 0; j-- { + b = append(b, ksf.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ksf.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksf.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ksf.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ksf_CM' +// in accounting notation. +func (ksf *ksf_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksf.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksf.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksf.group) - 1; j >= 0; j-- { + b = append(b, ksf.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ksf.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksf.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ksf.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ksf.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ksf_CM' +func (ksf *ksf_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ksf_CM' +func (ksf *ksf_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksf.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ksf_CM' +func (ksf *ksf_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksf.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ksf_CM' +func (ksf *ksf_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ksf.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ksf.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ksf_CM' +func (ksf *ksf_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ksf_CM' +func (ksf *ksf_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ksf_CM' +func (ksf *ksf_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ksf_CM' +func (ksf *ksf_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksf.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ksf.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ksf_CM/ksf_CM_test.go b/vendor/github.com/go-playground/locales/ksf_CM/ksf_CM_test.go new file mode 100644 index 0000000000..147b772ea2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksf_CM/ksf_CM_test.go @@ -0,0 +1,1120 @@ +package ksf_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ksf_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ksh/ksh.go b/vendor/github.com/go-playground/locales/ksh/ksh.go new file mode 100644 index 0000000000..39f1091966 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksh/ksh.go @@ -0,0 +1,598 @@ +package ksh + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ksh struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ksh' locale +func New() locales.Translator { + return &ksh{ + locale: "ksh", + pluralsCardinal: []locales.PluralRule{1, 2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Fäb", "Mäz", "Apr", "Mai", "Jun", "Jul", "Ouj", "Säp", "Okt", "Nov", "Dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "O", "S", "O", "N", "D"}, + monthsWide: []string{"", "Jannewa", "Fäbrowa", "Määz", "Aprell", "Mai", "Juuni", "Juuli", "Oujoß", "Septämber", "Oktohber", "Novämber", "Dezämber"}, + daysAbbreviated: []string{"Su.", "Mo.", "Di.", "Me.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"Su", "Mo", "Di", "Me", "Du", "Fr", "Sa"}, + daysWide: []string{"Sunndaach", "Mohndaach", "Dinnsdaach", "Metwoch", "Dunnersdaach", "Friidaach", "Samsdaach"}, + periodsAbbreviated: []string{"v.M.", "n.M."}, + periodsWide: []string{"Uhr vörmiddaachs", "Uhr nommendaachs"}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"vC", "nC"}, + erasWide: []string{"vür Krestos", "noh Krestos"}, + timezones: map[string]string{"ECT": "ECT", "IST": "IST", "OESZ": "Oß-Europpa sing Summerzick", "HKST": "HKST", "CHAST": "CHAST", "CAT": "Zentraal-Affrekaanesche Zigg", "GMT": "Greenwich sing Standat-Zick", "EST": "EST", "COST": "COST", "HEPMX": "HEPMX", "HAT": "HAT", "HEEG": "HEEG", "LHST": "LHST", "WIB": "WIB", "HNCU": "HNCU", "SGT": "SGT", "∅∅∅": "∅∅∅", "JST": "JST", "WEZ": "Weß-Europpa sing jewöhnlijje Zick", "MDT": "MDT", "HKT": "HKT", "PST": "PST", "HEOG": "HEOG", "ACST": "ACST", "ACDT": "ACDT", "COT": "COT", "HECU": "HECU", "BOT": "BOT", "JDT": "JDT", "WART": "WART", "WARST": "WARST", "TMST": "TMST", "LHDT": "LHDT", "CLT": "CLT", "HNOG": "HNOG", "SAST": "Söd-Affrekaanesche Zigg", "HAST": "HAST", "CLST": "CLST", "TMT": "TMT", "WAT": "Jewöhnlijje Wäß-Affrekaanesche Zigg", "WITA": "WITA", "HNPM": "HNPM", "MST": "MST", "HADT": "HADT", "ARST": "ARST", "AKDT": "AKDT", "AEST": "AEST", "AEDT": "AEDT", "CHADT": "CHADT", "PDT": "PDT", "NZDT": "NZDT", "ACWST": "ACWST", "ACWDT": "ACWDT", "HENOMX": "HENOMX", "GFT": "GFT", "ChST": "ChST", "GYT": "GYT", "UYST": "UYST", "EAT": "Oß-Affrekaanesche Zigg", "AST": "AST", "WAST": "Wäß-Affrekaanesche Sommerzigg", "EDT": "EDT", "HNT": "HNT", "AKST": "AKST", "UYT": "UYT", "AWST": "AWST", "NZST": "NZST", "MYT": "MYT", "OEZ": "Oß-Europpa sing jewöhnlijje Zick", "MEZ": "Meddel-Europpa sing jewöhnlijje Zick", "WESZ": "Weß-Europpa sing Summerzick", "HNNOMX": "HNNOMX", "HNEG": "HNEG", "HEPM": "HEPM", "WIT": "WIT", "AWDT": "AWDT", "MESZ": "Meddel-Europpa sing Summerzick", "VET": "VET", "ART": "ART", "BT": "BT", "SRT": "SRT", "ADT": "ADT", "HNPMX": "HNPMX", "CST": "CST", "CDT": "CDT"}, + } +} + +// Locale returns the current translators string locale +func (ksh *ksh) Locale() string { + return ksh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ksh' +func (ksh *ksh) PluralsCardinal() []locales.PluralRule { + return ksh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ksh' +func (ksh *ksh) PluralsOrdinal() []locales.PluralRule { + return ksh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ksh' +func (ksh *ksh) PluralsRange() []locales.PluralRule { + return ksh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ksh' +func (ksh *ksh) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ksh' +func (ksh *ksh) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ksh' +func (ksh *ksh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ksh *ksh) MonthAbbreviated(month time.Month) string { + return ksh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ksh *ksh) MonthsAbbreviated() []string { + return ksh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ksh *ksh) MonthNarrow(month time.Month) string { + return ksh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ksh *ksh) MonthsNarrow() []string { + return ksh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ksh *ksh) MonthWide(month time.Month) string { + return ksh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ksh *ksh) MonthsWide() []string { + return ksh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ksh *ksh) WeekdayAbbreviated(weekday time.Weekday) string { + return ksh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ksh *ksh) WeekdaysAbbreviated() []string { + return ksh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ksh *ksh) WeekdayNarrow(weekday time.Weekday) string { + return ksh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ksh *ksh) WeekdaysNarrow() []string { + return ksh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ksh *ksh) WeekdayShort(weekday time.Weekday) string { + return ksh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ksh *ksh) WeekdaysShort() []string { + return ksh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ksh *ksh) WeekdayWide(weekday time.Weekday) string { + return ksh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ksh *ksh) WeekdaysWide() []string { + return ksh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ksh' and handles both Whole and Real numbers based on 'v' +func (ksh *ksh) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksh.group) - 1; j >= 0; j-- { + b = append(b, ksh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ksh.minus) - 1; j >= 0; j-- { + b = append(b, ksh.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ksh' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ksh *ksh) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ksh.minus) - 1; j >= 0; j-- { + b = append(b, ksh.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ksh.percentSuffix...) + + b = append(b, ksh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ksh' +func (ksh *ksh) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksh.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksh.group) - 1; j >= 0; j-- { + b = append(b, ksh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ksh.minus) - 1; j >= 0; j-- { + b = append(b, ksh.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ksh.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ksh' +// in accounting notation. +func (ksh *ksh) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksh.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksh.group) - 1; j >= 0; j-- { + b = append(b, ksh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ksh.minus) - 1; j >= 0; j-- { + b = append(b, ksh.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ksh.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ksh.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ksh' +func (ksh *ksh) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ksh' +func (ksh *ksh) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, ksh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ksh' +func (ksh *ksh) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, ksh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ksh' +func (ksh *ksh) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ksh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0x64, 0xc3, 0xa4}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, ksh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ksh' +func (ksh *ksh) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ksh' +func (ksh *ksh) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ksh' +func (ksh *ksh) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ksh' +func (ksh *ksh) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ksh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ksh/ksh_test.go b/vendor/github.com/go-playground/locales/ksh/ksh_test.go new file mode 100644 index 0000000000..611d165575 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksh/ksh_test.go @@ -0,0 +1,1120 @@ +package ksh + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ksh" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ksh_DE/ksh_DE.go b/vendor/github.com/go-playground/locales/ksh_DE/ksh_DE.go new file mode 100644 index 0000000000..5b05a6272e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksh_DE/ksh_DE.go @@ -0,0 +1,598 @@ +package ksh_DE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ksh_DE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ksh_DE' locale +func New() locales.Translator { + return &ksh_DE{ + locale: "ksh_DE", + pluralsCardinal: []locales.PluralRule{1, 2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Fäb", "Mäz", "Apr", "Mai", "Jun", "Jul", "Ouj", "Säp", "Okt", "Nov", "Dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "O", "S", "O", "N", "D"}, + monthsWide: []string{"", "Jannewa", "Fäbrowa", "Määz", "Aprell", "Mai", "Juuni", "Juuli", "Oujoß", "Septämber", "Oktohber", "Novämber", "Dezämber"}, + daysAbbreviated: []string{"Su.", "Mo.", "Di.", "Me.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"Su", "Mo", "Di", "Me", "Du", "Fr", "Sa"}, + daysWide: []string{"Sunndaach", "Mohndaach", "Dinnsdaach", "Metwoch", "Dunnersdaach", "Friidaach", "Samsdaach"}, + periodsAbbreviated: []string{"v.M.", "n.M."}, + periodsWide: []string{"Uhr vörmiddaachs", "Uhr nommendaachs"}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"vC", "nC"}, + erasWide: []string{"vür Krestos", "noh Krestos"}, + timezones: map[string]string{"AWST": "AWST", "AWDT": "AWDT", "IST": "IST", "HENOMX": "HENOMX", "CDT": "CDT", "JST": "JST", "OESZ": "Oß-Europpa sing Summerzick", "WAT": "Jewöhnlijje Wäß-Affrekaanesche Zigg", "HKST": "HKST", "HNEG": "HNEG", "WITA": "WITA", "SGT": "SGT", "HEPM": "HEPM", "ACWDT": "ACWDT", "AST": "AST", "MYT": "MYT", "AKDT": "AKDT", "UYST": "UYST", "EAT": "Oß-Affrekaanesche Zigg", "OEZ": "Oß-Europpa sing jewöhnlijje Zick", "GFT": "GFT", "LHDT": "LHDT", "WAST": "Wäß-Affrekaanesche Sommerzigg", "EST": "EST", "AEST": "AEST", "TMST": "TMST", "SRT": "SRT", "CST": "CST", "WIT": "WIT", "ECT": "ECT", "WESZ": "Weß-Europpa sing Summerzick", "HNPM": "HNPM", "HNCU": "HNCU", "WARST": "WARST", "CLST": "CLST", "ACDT": "ACDT", "AKST": "AKST", "ChST": "ChST", "WIB": "WIB", "CHAST": "CHAST", "CAT": "Zentraal-Affrekaanesche Zigg", "HNOG": "HNOG", "COT": "COT", "HEEG": "HEEG", "UYT": "UYT", "PDT": "PDT", "HEOG": "HEOG", "HNNOMX": "HNNOMX", "BT": "BT", "HAT": "HAT", "PST": "PST", "HAST": "HAST", "ART": "ART", "HNT": "HNT", "AEDT": "AEDT", "GYT": "GYT", "CHADT": "CHADT", "VET": "VET", "ADT": "ADT", "CLT": "CLT", "HECU": "HECU", "NZST": "NZST", "NZDT": "NZDT", "WEZ": "Weß-Europpa sing jewöhnlijje Zick", "GMT": "Greenwich sing Standat-Zick", "TMT": "TMT", "COST": "COST", "∅∅∅": "de Azore ier Summerzick", "JDT": "JDT", "HADT": "HADT", "BOT": "BOT", "ACWST": "ACWST", "MEZ": "Meddel-Europpa sing jewöhnlijje Zick", "WART": "WART", "ARST": "ARST", "ACST": "ACST", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "MESZ": "Meddel-Europpa sing Summerzick", "MST": "MST", "EDT": "EDT", "HKT": "HKT", "LHST": "LHST", "MDT": "MDT", "SAST": "Söd-Affrekaanesche Zigg"}, + } +} + +// Locale returns the current translators string locale +func (ksh *ksh_DE) Locale() string { + return ksh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ksh_DE' +func (ksh *ksh_DE) PluralsCardinal() []locales.PluralRule { + return ksh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ksh_DE' +func (ksh *ksh_DE) PluralsOrdinal() []locales.PluralRule { + return ksh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ksh_DE' +func (ksh *ksh_DE) PluralsRange() []locales.PluralRule { + return ksh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ksh_DE' +func (ksh *ksh_DE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 0 { + return locales.PluralRuleZero + } else if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ksh_DE' +func (ksh *ksh_DE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ksh_DE' +func (ksh *ksh_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ksh *ksh_DE) MonthAbbreviated(month time.Month) string { + return ksh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ksh *ksh_DE) MonthsAbbreviated() []string { + return ksh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ksh *ksh_DE) MonthNarrow(month time.Month) string { + return ksh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ksh *ksh_DE) MonthsNarrow() []string { + return ksh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ksh *ksh_DE) MonthWide(month time.Month) string { + return ksh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ksh *ksh_DE) MonthsWide() []string { + return ksh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ksh *ksh_DE) WeekdayAbbreviated(weekday time.Weekday) string { + return ksh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ksh *ksh_DE) WeekdaysAbbreviated() []string { + return ksh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ksh *ksh_DE) WeekdayNarrow(weekday time.Weekday) string { + return ksh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ksh *ksh_DE) WeekdaysNarrow() []string { + return ksh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ksh *ksh_DE) WeekdayShort(weekday time.Weekday) string { + return ksh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ksh *ksh_DE) WeekdaysShort() []string { + return ksh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ksh *ksh_DE) WeekdayWide(weekday time.Weekday) string { + return ksh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ksh *ksh_DE) WeekdaysWide() []string { + return ksh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ksh_DE' and handles both Whole and Real numbers based on 'v' +func (ksh *ksh_DE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksh.group) - 1; j >= 0; j-- { + b = append(b, ksh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ksh.minus) - 1; j >= 0; j-- { + b = append(b, ksh.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ksh_DE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ksh *ksh_DE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ksh.minus) - 1; j >= 0; j-- { + b = append(b, ksh.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ksh.percentSuffix...) + + b = append(b, ksh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ksh_DE' +func (ksh *ksh_DE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksh.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksh.group) - 1; j >= 0; j-- { + b = append(b, ksh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ksh.minus) - 1; j >= 0; j-- { + b = append(b, ksh.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ksh.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ksh_DE' +// in accounting notation. +func (ksh *ksh_DE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ksh.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ksh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ksh.group) - 1; j >= 0; j-- { + b = append(b, ksh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ksh.minus) - 1; j >= 0; j-- { + b = append(b, ksh.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ksh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ksh.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ksh.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ksh_DE' +func (ksh *ksh_DE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ksh_DE' +func (ksh *ksh_DE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, ksh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ksh_DE' +func (ksh *ksh_DE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, ksh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ksh_DE' +func (ksh *ksh_DE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ksh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0x64, 0xc3, 0xa4}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, ksh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ksh_DE' +func (ksh *ksh_DE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ksh_DE' +func (ksh *ksh_DE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ksh_DE' +func (ksh *ksh_DE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ksh_DE' +func (ksh *ksh_DE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ksh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ksh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ksh_DE/ksh_DE_test.go b/vendor/github.com/go-playground/locales/ksh_DE/ksh_DE_test.go new file mode 100644 index 0000000000..3ccccd7615 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ksh_DE/ksh_DE_test.go @@ -0,0 +1,1120 @@ +package ksh_DE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ksh_DE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kw/kw.go b/vendor/github.com/go-playground/locales/kw/kw.go new file mode 100644 index 0000000000..fe5ddfba61 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kw/kw.go @@ -0,0 +1,517 @@ +package kw + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kw struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kw' locale +func New() locales.Translator { + return &kw{ + locale: "kw", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Gen", "Hwe", "Meu", "Ebr", "Me", "Met", "Gor", "Est", "Gwn", "Hed", "Du", "Kev"}, + monthsWide: []string{"", "mis Genver", "mis Hwevrer", "mis Meurth", "mis Ebrel", "mis Me", "mis Metheven", "mis Gortheren", "mis Est", "mis Gwynngala", "mis Hedra", "mis Du", "mis Kevardhu"}, + daysAbbreviated: []string{"Sul", "Lun", "Mth", "Mhr", "Yow", "Gwe", "Sad"}, + daysWide: []string{"dy Sul", "dy Lun", "dy Meurth", "dy Merher", "dy Yow", "dy Gwener", "dy Sadorn"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"RC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HAT": "HAT", "AEDT": "AEDT", "CHADT": "CHADT", "CAT": "CAT", "MEZ": "MEZ", "MST": "MST", "ACST": "ACST", "BT": "BT", "JDT": "JDT", "HECU": "HECU", "CST": "CST", "OESZ": "OESZ", "EST": "EST", "HNEG": "HNEG", "HEPM": "HEPM", "HNT": "HNT", "HNPMX": "HNPMX", "EAT": "EAT", "PDT": "PDT", "MESZ": "MESZ", "HKST": "HKST", "ACDT": "ACDT", "HENOMX": "HENOMX", "TMT": "TMT", "WEZ": "WEZ", "AKST": "AKST", "AEST": "AEST", "ChST": "ChST", "LHDT": "LHDT", "WIB": "WIB", "WARST": "WARST", "HAST": "HAST", "CLT": "CLT", "CLST": "CLST", "AST": "AST", "WESZ": "WESZ", "ARST": "ARST", "HEEG": "HEEG", "BOT": "BOT", "LHST": "LHST", "AWDT": "AWDT", "GMT": "GMT", "SAST": "SAST", "WIT": "WIT", "AWST": "AWST", "SGT": "SGT", "PST": "PST", "HNNOMX": "HNNOMX", "GFT": "GFT", "HNPM": "HNPM", "HADT": "HADT", "NZST": "NZST", "MDT": "MDT", "WAST": "WAST", "∅∅∅": "∅∅∅", "SRT": "SRT", "ADT": "ADT", "TMST": "TMST", "VET": "VET", "HNOG": "HNOG", "WAT": "WAT", "CHAST": "CHAST", "OEZ": "OEZ", "EDT": "EDT", "COT": "COT", "GYT": "GYT", "JST": "JST", "WART": "WART", "HEOG": "HEOG", "HNCU": "HNCU", "CDT": "CDT", "ACWDT": "ACWDT", "WITA": "WITA", "HEPMX": "HEPMX", "ECT": "ECT", "IST": "IST", "ACWST": "ACWST", "ART": "ART", "HKT": "HKT", "COST": "COST", "MYT": "MYT", "NZDT": "NZDT", "AKDT": "AKDT", "UYT": "UYT", "UYST": "UYST"}, + } +} + +// Locale returns the current translators string locale +func (kw *kw) Locale() string { + return kw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kw' +func (kw *kw) PluralsCardinal() []locales.PluralRule { + return kw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kw' +func (kw *kw) PluralsOrdinal() []locales.PluralRule { + return kw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kw' +func (kw *kw) PluralsRange() []locales.PluralRule { + return kw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kw' +func (kw *kw) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kw' +func (kw *kw) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kw' +func (kw *kw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kw *kw) MonthAbbreviated(month time.Month) string { + return kw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kw *kw) MonthsAbbreviated() []string { + return kw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kw *kw) MonthNarrow(month time.Month) string { + return kw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kw *kw) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kw *kw) MonthWide(month time.Month) string { + return kw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kw *kw) MonthsWide() []string { + return kw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kw *kw) WeekdayAbbreviated(weekday time.Weekday) string { + return kw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kw *kw) WeekdaysAbbreviated() []string { + return kw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kw *kw) WeekdayNarrow(weekday time.Weekday) string { + return kw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kw *kw) WeekdaysNarrow() []string { + return kw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kw *kw) WeekdayShort(weekday time.Weekday) string { + return kw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kw *kw) WeekdaysShort() []string { + return kw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kw *kw) WeekdayWide(weekday time.Weekday) string { + return kw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kw *kw) WeekdaysWide() []string { + return kw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kw' and handles both Whole and Real numbers based on 'v' +func (kw *kw) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kw' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kw *kw) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kw' +func (kw *kw) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kw.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kw' +// in accounting notation. +func (kw *kw) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kw.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kw.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kw' +func (kw *kw) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kw' +func (kw *kw) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kw' +func (kw *kw) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kw' +func (kw *kw) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kw' +func (kw *kw) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kw' +func (kw *kw) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kw' +func (kw *kw) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kw' +func (kw *kw) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kw/kw_test.go b/vendor/github.com/go-playground/locales/kw/kw_test.go new file mode 100644 index 0000000000..f941244c0f --- /dev/null +++ b/vendor/github.com/go-playground/locales/kw/kw_test.go @@ -0,0 +1,1120 @@ +package kw + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kw" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/kw_GB/kw_GB.go b/vendor/github.com/go-playground/locales/kw_GB/kw_GB.go new file mode 100644 index 0000000000..ab0cb46313 --- /dev/null +++ b/vendor/github.com/go-playground/locales/kw_GB/kw_GB.go @@ -0,0 +1,517 @@ +package kw_GB + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type kw_GB struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'kw_GB' locale +func New() locales.Translator { + return &kw_GB{ + locale: "kw_GB", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Gen", "Hwe", "Meu", "Ebr", "Me", "Met", "Gor", "Est", "Gwn", "Hed", "Du", "Kev"}, + monthsWide: []string{"", "mis Genver", "mis Hwevrer", "mis Meurth", "mis Ebrel", "mis Me", "mis Metheven", "mis Gortheren", "mis Est", "mis Gwynngala", "mis Hedra", "mis Du", "mis Kevardhu"}, + daysAbbreviated: []string{"Sul", "Lun", "Mth", "Mhr", "Yow", "Gwe", "Sad"}, + daysWide: []string{"dy Sul", "dy Lun", "dy Meurth", "dy Merher", "dy Yow", "dy Gwener", "dy Sadorn"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"RC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HKST": "HKST", "GFT": "GFT", "CHADT": "CHADT", "MEZ": "MEZ", "MESZ": "MESZ", "WARST": "WARST", "CLST": "CLST", "MDT": "MDT", "SAST": "SAST", "IST": "IST", "HNPMX": "HNPMX", "ECT": "ECT", "WIB": "WIB", "OEZ": "OEZ", "HNNOMX": "HNNOMX", "AEST": "AEST", "HADT": "HADT", "WESZ": "WESZ", "HENOMX": "HENOMX", "AWST": "AWST", "VET": "VET", "TMT": "TMT", "HNT": "HNT", "AKST": "AKST", "EST": "EST", "SRT": "SRT", "CDT": "CDT", "AWDT": "AWDT", "CAT": "CAT", "ADT": "ADT", "MYT": "MYT", "ARST": "ARST", "GYT": "GYT", "HKT": "HKT", "UYT": "UYT", "∅∅∅": "∅∅∅", "BOT": "BOT", "NZDT": "NZDT", "TMST": "TMST", "MST": "MST", "ART": "ART", "HNPM": "HNPM", "HEPMX": "HEPMX", "LHST": "LHST", "JST": "JST", "AST": "AST", "WART": "WART", "WAST": "WAST", "EDT": "EDT", "HNEG": "HNEG", "HECU": "HECU", "CST": "CST", "CHAST": "CHAST", "ACWST": "ACWST", "HNOG": "HNOG", "BT": "BT", "HNCU": "HNCU", "PST": "PST", "GMT": "GMT", "WIT": "WIT", "NZST": "NZST", "ACST": "ACST", "HEEG": "HEEG", "UYST": "UYST", "HAST": "HAST", "WEZ": "WEZ", "ACDT": "ACDT", "HAT": "HAT", "EAT": "EAT", "SGT": "SGT", "WAT": "WAT", "PDT": "PDT", "JDT": "JDT", "HEOG": "HEOG", "COT": "COT", "ChST": "ChST", "LHDT": "LHDT", "WITA": "WITA", "HEPM": "HEPM", "ACWDT": "ACWDT", "OESZ": "OESZ", "CLT": "CLT", "COST": "COST", "AKDT": "AKDT", "AEDT": "AEDT"}, + } +} + +// Locale returns the current translators string locale +func (kw *kw_GB) Locale() string { + return kw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'kw_GB' +func (kw *kw_GB) PluralsCardinal() []locales.PluralRule { + return kw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'kw_GB' +func (kw *kw_GB) PluralsOrdinal() []locales.PluralRule { + return kw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'kw_GB' +func (kw *kw_GB) PluralsRange() []locales.PluralRule { + return kw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kw_GB' +func (kw *kw_GB) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kw_GB' +func (kw *kw_GB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kw_GB' +func (kw *kw_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (kw *kw_GB) MonthAbbreviated(month time.Month) string { + return kw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (kw *kw_GB) MonthsAbbreviated() []string { + return kw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (kw *kw_GB) MonthNarrow(month time.Month) string { + return kw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (kw *kw_GB) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (kw *kw_GB) MonthWide(month time.Month) string { + return kw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (kw *kw_GB) MonthsWide() []string { + return kw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (kw *kw_GB) WeekdayAbbreviated(weekday time.Weekday) string { + return kw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (kw *kw_GB) WeekdaysAbbreviated() []string { + return kw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (kw *kw_GB) WeekdayNarrow(weekday time.Weekday) string { + return kw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (kw *kw_GB) WeekdaysNarrow() []string { + return kw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (kw *kw_GB) WeekdayShort(weekday time.Weekday) string { + return kw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (kw *kw_GB) WeekdaysShort() []string { + return kw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (kw *kw_GB) WeekdayWide(weekday time.Weekday) string { + return kw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (kw *kw_GB) WeekdaysWide() []string { + return kw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'kw_GB' and handles both Whole and Real numbers based on 'v' +func (kw *kw_GB) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'kw_GB' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (kw *kw_GB) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kw_GB' +func (kw *kw_GB) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kw.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, kw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kw_GB' +// in accounting notation. +func (kw *kw_GB) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := kw.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, kw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, kw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, kw.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, kw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'kw_GB' +func (kw *kw_GB) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'kw_GB' +func (kw *kw_GB) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'kw_GB' +func (kw *kw_GB) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'kw_GB' +func (kw *kw_GB) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, kw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, kw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'kw_GB' +func (kw *kw_GB) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'kw_GB' +func (kw *kw_GB) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'kw_GB' +func (kw *kw_GB) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'kw_GB' +func (kw *kw_GB) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, kw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, kw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := kw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/kw_GB/kw_GB_test.go b/vendor/github.com/go-playground/locales/kw_GB/kw_GB_test.go new file mode 100644 index 0000000000..d95f1648ef --- /dev/null +++ b/vendor/github.com/go-playground/locales/kw_GB/kw_GB_test.go @@ -0,0 +1,1120 @@ +package kw_GB + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "kw_GB" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ky/ky.go b/vendor/github.com/go-playground/locales/ky/ky.go new file mode 100644 index 0000000000..40e2460fcd --- /dev/null +++ b/vendor/github.com/go-playground/locales/ky/ky.go @@ -0,0 +1,598 @@ +package ky + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ky struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ky' locale +func New() locales.Translator { + return &ky{ + locale: "ky", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "сом", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "фев.", "мар.", "апр.", "май", "июн.", "июл.", "авг.", "сен.", "окт.", "ноя.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь"}, + daysAbbreviated: []string{"жек.", "дүй.", "шейш.", "шарш.", "бейш.", "жума", "ишм."}, + daysNarrow: []string{"Ж", "Д", "Ш", "Ш", "Б", "Ж", "И"}, + daysShort: []string{"жек.", "дүй.", "шейш.", "шарш.", "бейш.", "жума", "ишм."}, + daysWide: []string{"жекшемби", "дүйшөмбү", "шейшемби", "шаршемби", "бейшемби", "жума", "ишемби"}, + periodsAbbreviated: []string{"тң", "тк"}, + periodsNarrow: []string{"тң", "тк"}, + periodsWide: []string{"таңкы", "түштөн кийинки"}, + erasAbbreviated: []string{"б.з.ч.", "б.з."}, + erasNarrow: []string{"б.з.ч.", "б.з."}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ChST": "Чаморро убактысы", "HECU": "Куба жайкы убактысы", "CST": "Түндүк Америка, борбордук кышкы убактысы", "GMT": "GMT, кышкы убакыты", "AST": "Атлантика кышкы убактысы", "HNT": "Нюфаундлэнд кышкы убактысы", "HAT": "Нюфаундлэнд жайкы убактысы", "WITA": "Борбордук Индонезия убактысы", "SGT": "Сингапур убактысы", "ACWDT": "Австралия борбордук чыгыш жайкы убактысы", "ADT": "Атлантика жайкы убактысы", "TMT": "Түркмөнстан кышкы убакыты", "HNNOMX": "Түндүк-чыгыш Мексика кышкы убактысы", "MEZ": "Борбордук Европа кышкы убакыты", "MYT": "Малайзия убактысы", "CLT": "Чили кышкы убактысы", "UYST": "Уругвай жайкы убактысы", "HNPMX": "Мексика, Тынч океан кышкы убактысы", "CAT": "Борбордук Африка убактысы", "MST": "MST", "AKST": "Аляска кышкы убактысы", "AWDT": "Австралия батыш жайкы убактысы", "CHADT": "Чатам жайкы убактысы", "VET": "Венесуэла убактысы", "HKT": "Гонконг кышкы убакыты", "BT": "Бутан убактысы", "HNCU": "Куба кышкы убактысы", "JDT": "Жапон жайкы убактысы", "CHAST": "Чатам кышкы убакыт", "ACWST": "Австралия борбордук батыш кышкы убакыты", "WEZ": "Батыш Европа кышкы убакыты", "OESZ": "Чыгыш Европа жайкы убактысы", "HKST": "Гонконг жайкы убактысы", "ACST": "Австралия борбордук кышкы убакыты", "HNPM": "Сен Пьер жана Микелон кышкы убактысы", "EAT": "Чыгыш Африка убактысы", "ECT": "Экуадор убактысы", "MESZ": "Борбордук Европа жайкы убактысы", "CLST": "Чили жайкы убактысы", "ACDT": "Австралия борбордук жайкы убактысы", "COT": "Колумбия кышкы убактысы", "HEEG": "Чыгыш Гренландия жайкы убактысы", "UYT": "Уругвай кышкы убактысы", "AWST": "Австралия батыш кышкы убакыты", "JST": "Жапон кышкы убакыты", "OEZ": "Чыгыш Европа кышкы убакыты", "TMST": "Түркмөнстан жайкы убактысы", "WAST": "Батыш Африка жайкы убактысы", "∅∅∅": "∅∅∅", "HEPM": "Сен Пьер жана Микелон жайкы убактысы", "COST": "Колумбия жайкы убактысы", "GFT": "Француз Гвиана убактысы", "BOT": "Боливия убактысы", "NZST": "Жаӊы Зеландия кышкы убакыты", "HEOG": "Батыш Гренландия жайкы убактысы", "WAT": "Батыш Африка кышкы убакыты", "SAST": "Түштүк Африка убактысы", "WIB": "Батыш Индонезия убактысы", "PDT": "Түндүк Америка, Тынч океан жайкы убактысы", "WESZ": "Батыш Европа жайкы убактысы", "WART": "Батыш Аргентина кышкы убактысы", "ART": "Аргентина кышкы убактысы", "NZDT": "Жаңы Зеландия жайкы убакыты", "WARST": "Батыш Аргентина жайкы убактысы", "ARST": "Аргентина жайкы убактысы", "LHST": "Лорд Хау кышкы убакыты", "LHDT": "Лорд Хау жайкы убактысы", "HAST": "Гавайи-Алеут кышкы убактысы", "MDT": "MDT", "PST": "Түндүк Америка, Тынч океан кышкы убактысы", "IST": "Индия убактысы", "CDT": "Түндүк Америка, борбордук жайкы убакыт", "HNOG": "Батыш Гренландия кышкы убактысы", "HENOMX": "Түндүк-чыгыш Мексика жайкы убактысы", "HNEG": "Чыгыш Гренландия кышкы убактысы", "AKDT": "Аляска жайкы убактысы", "SRT": "Суринаме убактысы", "HADT": "Гавайи-Алеут жайкы убактысы", "EST": "Түндүк Америка, чыгыш кышкы убактысы", "EDT": "Түндүк Америка, чыгыш жайкы убактысы", "AEDT": "Австралия чыгыш жайкы убактысы", "GYT": "Гвиана убактысы", "WIT": "Чыгыш Индонезия убактысы", "AEST": "Австралия чыгыш кышкы убакыты", "HEPMX": "Мексика, Тынч океан жайкы убактысы"}, + } +} + +// Locale returns the current translators string locale +func (ky *ky) Locale() string { + return ky.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ky' +func (ky *ky) PluralsCardinal() []locales.PluralRule { + return ky.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ky' +func (ky *ky) PluralsOrdinal() []locales.PluralRule { + return ky.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ky' +func (ky *ky) PluralsRange() []locales.PluralRule { + return ky.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ky' +func (ky *ky) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ky' +func (ky *ky) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ky' +func (ky *ky) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ky.CardinalPluralRule(num1, v1) + end := ky.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ky *ky) MonthAbbreviated(month time.Month) string { + return ky.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ky *ky) MonthsAbbreviated() []string { + return ky.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ky *ky) MonthNarrow(month time.Month) string { + return ky.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ky *ky) MonthsNarrow() []string { + return ky.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ky *ky) MonthWide(month time.Month) string { + return ky.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ky *ky) MonthsWide() []string { + return ky.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ky *ky) WeekdayAbbreviated(weekday time.Weekday) string { + return ky.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ky *ky) WeekdaysAbbreviated() []string { + return ky.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ky *ky) WeekdayNarrow(weekday time.Weekday) string { + return ky.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ky *ky) WeekdaysNarrow() []string { + return ky.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ky *ky) WeekdayShort(weekday time.Weekday) string { + return ky.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ky *ky) WeekdaysShort() []string { + return ky.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ky *ky) WeekdayWide(weekday time.Weekday) string { + return ky.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ky *ky) WeekdaysWide() []string { + return ky.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ky' and handles both Whole and Real numbers based on 'v' +func (ky *ky) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ky.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ky.group) - 1; j >= 0; j-- { + b = append(b, ky.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ky.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ky' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ky *ky) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ky.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ky.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ky.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ky' +func (ky *ky) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ky.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ky.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ky.group) - 1; j >= 0; j-- { + b = append(b, ky.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ky.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ky.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ky.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ky' +// in accounting notation. +func (ky *ky) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ky.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ky.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ky.group) - 1; j >= 0; j-- { + b = append(b, ky.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ky.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ky.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ky.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ky.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ky' +func (ky *ky) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ky' +func (ky *ky) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ky.monthsAbbreviated[t.Month()]...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ky' +func (ky *ky) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ky.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ky' +func (ky *ky) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ky.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ky.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ky' +func (ky *ky) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ky.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ky' +func (ky *ky) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ky.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ky.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ky' +func (ky *ky) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ky.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ky.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ky' +func (ky *ky) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ky.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ky.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ky.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ky/ky_test.go b/vendor/github.com/go-playground/locales/ky/ky_test.go new file mode 100644 index 0000000000..53aa700c1c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ky/ky_test.go @@ -0,0 +1,1120 @@ +package ky + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ky" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ky_KG/ky_KG.go b/vendor/github.com/go-playground/locales/ky_KG/ky_KG.go new file mode 100644 index 0000000000..3a7b75206c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ky_KG/ky_KG.go @@ -0,0 +1,598 @@ +package ky_KG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ky_KG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ky_KG' locale +func New() locales.Translator { + return &ky_KG{ + locale: "ky_KG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "фев.", "мар.", "апр.", "май", "июн.", "июл.", "авг.", "сен.", "окт.", "ноя.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь"}, + daysAbbreviated: []string{"жек.", "дүй.", "шейш.", "шарш.", "бейш.", "жума", "ишм."}, + daysNarrow: []string{"Ж", "Д", "Ш", "Ш", "Б", "Ж", "И"}, + daysShort: []string{"жек.", "дүй.", "шейш.", "шарш.", "бейш.", "жума", "ишм."}, + daysWide: []string{"жекшемби", "дүйшөмбү", "шейшемби", "шаршемби", "бейшемби", "жума", "ишемби"}, + periodsAbbreviated: []string{"тң", "тк"}, + periodsNarrow: []string{"тң", "тк"}, + periodsWide: []string{"таңкы", "түштөн кийинки"}, + erasAbbreviated: []string{"б.з.ч.", "б.з."}, + erasNarrow: []string{"б.з.ч.", "б.з."}, + erasWide: []string{"", ""}, + timezones: map[string]string{"WIB": "Батыш Индонезия убактысы", "SGT": "Сингапур убактысы", "WART": "Батыш Аргентина кышкы убактысы", "MST": "Түндүк Америка, тоо кышкы убактысы", "HNEG": "Чыгыш Гренландия кышкы убактысы", "HEEG": "Чыгыш Гренландия жайкы убактысы", "GFT": "Француз Гвиана убактысы", "LHST": "Лорд Хау кышкы убакыты", "HNCU": "Куба кышкы убактысы", "HECU": "Куба жайкы убактысы", "ECT": "Экуадор убактысы", "COT": "Колумбия кышкы убактысы", "CLST": "Чили жайкы убактысы", "ART": "Аргентина кышкы убактысы", "NZST": "Жаӊы Зеландия кышкы убакыты", "EDT": "Түндүк Америка, чыгыш жайкы убактысы", "BT": "Бутан убактысы", "WITA": "Борбордук Индонезия убактысы", "CHAST": "Чатам кышкы убакыт", "WARST": "Батыш Аргентина жайкы убактысы", "WAST": "Батыш Африка жайкы убактысы", "HEPMX": "Мексика, Тынч океан жайкы убактысы", "WIT": "Чыгыш Индонезия убактысы", "BOT": "Боливия убактысы", "CLT": "Чили кышкы убактысы", "WAT": "Батыш Африка кышкы убакыты", "AEST": "Австралия чыгыш кышкы убакыты", "UYST": "Уругвай жайкы убактысы", "AWST": "Австралия батыш кышкы убакыты", "CHADT": "Чатам жайкы убактысы", "ACST": "Австралия борбордук кышкы убакыты", "MDT": "Түндүк Америка, тоо жайкы убактысы", "PDT": "Түндүк Америка, Тынч океан жайкы убактысы", "NZDT": "Жаңы Зеландия жайкы убакыты", "IST": "Индия убактысы", "HNOG": "Батыш Гренландия кышкы убактысы", "ADT": "Атлантика жайкы убактысы", "TMST": "Түркмөнстан жайкы убактысы", "HKT": "Гонконг кышкы убакыты", "UYT": "Уругвай кышкы убактысы", "MESZ": "Борбордук Европа жайкы убактысы", "VET": "Венесуэла убактысы", "EST": "Түндүк Америка, чыгыш кышкы убактысы", "MYT": "Малайзия убактысы", "AST": "Атлантика кышкы убактысы", "WESZ": "Батыш Европа жайкы убактысы", "CDT": "Түндүк Америка, борбордук жайкы убакыт", "AKDT": "Аляска жайкы убактысы", "LHDT": "Лорд Хау жайкы убактысы", "GMT": "GMT, кышкы убакыты", "COST": "Колумбия жайкы убактысы", "ChST": "Чаморро убактысы", "HNPMX": "Мексика, Тынч океан кышкы убактысы", "CST": "Түндүк Америка, борбордук кышкы убактысы", "ACWST": "Австралия борбордук батыш кышкы убакыты", "OEZ": "Чыгыш Европа кышкы убакыты", "HENOMX": "Түндүк-чыгыш Мексика жайкы убактысы", "HAT": "Нюфаундлэнд жайкы убактысы", "HEPM": "Сен Пьер жана Микелон жайкы убактысы", "HAST": "Гавайи-Алеут кышкы убактысы", "WEZ": "Батыш Европа кышкы убакыты", "TMT": "Түркмөнстан кышкы убакыты", "HNNOMX": "Түндүк-чыгыш Мексика кышкы убактысы", "CAT": "Борбордук Африка убактысы", "MEZ": "Борбордук Европа кышкы убакыты", "JST": "Жапон кышкы убакыты", "OESZ": "Чыгыш Европа жайкы убактысы", "ARST": "Аргентина жайкы убактысы", "∅∅∅": "∅∅∅", "JDT": "Жапон жайкы убактысы", "EAT": "Чыгыш Африка убактысы", "HEOG": "Батыш Гренландия жайкы убактысы", "HNT": "Нюфаундлэнд кышкы убактысы", "AEDT": "Австралия чыгыш жайкы убактысы", "HNPM": "Сен Пьер жана Микелон кышкы убактысы", "SAST": "Түштүк Африка убактысы", "PST": "Түндүк Америка, Тынч океан кышкы убактысы", "ACWDT": "Австралия борбордук чыгыш жайкы убактысы", "ACDT": "Австралия борбордук жайкы убактысы", "AKST": "Аляска кышкы убактысы", "SRT": "Суринаме убактысы", "GYT": "Гвиана убактысы", "AWDT": "Австралия батыш жайкы убактысы", "HADT": "Гавайи-Алеут жайкы убактысы", "HKST": "Гонконг жайкы убактысы"}, + } +} + +// Locale returns the current translators string locale +func (ky *ky_KG) Locale() string { + return ky.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ky_KG' +func (ky *ky_KG) PluralsCardinal() []locales.PluralRule { + return ky.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ky_KG' +func (ky *ky_KG) PluralsOrdinal() []locales.PluralRule { + return ky.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ky_KG' +func (ky *ky_KG) PluralsRange() []locales.PluralRule { + return ky.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ky_KG' +func (ky *ky_KG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ky_KG' +func (ky *ky_KG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ky_KG' +func (ky *ky_KG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ky.CardinalPluralRule(num1, v1) + end := ky.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ky *ky_KG) MonthAbbreviated(month time.Month) string { + return ky.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ky *ky_KG) MonthsAbbreviated() []string { + return ky.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ky *ky_KG) MonthNarrow(month time.Month) string { + return ky.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ky *ky_KG) MonthsNarrow() []string { + return ky.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ky *ky_KG) MonthWide(month time.Month) string { + return ky.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ky *ky_KG) MonthsWide() []string { + return ky.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ky *ky_KG) WeekdayAbbreviated(weekday time.Weekday) string { + return ky.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ky *ky_KG) WeekdaysAbbreviated() []string { + return ky.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ky *ky_KG) WeekdayNarrow(weekday time.Weekday) string { + return ky.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ky *ky_KG) WeekdaysNarrow() []string { + return ky.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ky *ky_KG) WeekdayShort(weekday time.Weekday) string { + return ky.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ky *ky_KG) WeekdaysShort() []string { + return ky.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ky *ky_KG) WeekdayWide(weekday time.Weekday) string { + return ky.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ky *ky_KG) WeekdaysWide() []string { + return ky.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ky_KG' and handles both Whole and Real numbers based on 'v' +func (ky *ky_KG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ky.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ky.group) - 1; j >= 0; j-- { + b = append(b, ky.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ky.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ky_KG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ky *ky_KG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ky.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ky.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ky.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ky_KG' +func (ky *ky_KG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ky.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ky.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ky.group) - 1; j >= 0; j-- { + b = append(b, ky.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ky.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ky.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ky.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ky_KG' +// in accounting notation. +func (ky *ky_KG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ky.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ky.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ky.group) - 1; j >= 0; j-- { + b = append(b, ky.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ky.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ky.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ky.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ky.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ky_KG' +func (ky *ky_KG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ky_KG' +func (ky *ky_KG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ky.monthsAbbreviated[t.Month()]...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ky_KG' +func (ky *ky_KG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ky.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ky_KG' +func (ky *ky_KG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d, 0xd0, 0xb6}...) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ky.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ky.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ky_KG' +func (ky *ky_KG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ky.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ky_KG' +func (ky *ky_KG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ky.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ky.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ky_KG' +func (ky *ky_KG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ky.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ky.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ky_KG' +func (ky *ky_KG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ky.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ky.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ky.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ky_KG/ky_KG_test.go b/vendor/github.com/go-playground/locales/ky_KG/ky_KG_test.go new file mode 100644 index 0000000000..a63a107cd8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ky_KG/ky_KG_test.go @@ -0,0 +1,1120 @@ +package ky_KG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ky_KG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lag/lag.go b/vendor/github.com/go-playground/locales/lag/lag.go new file mode 100644 index 0000000000..1541db5971 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lag/lag.go @@ -0,0 +1,505 @@ +package lag + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lag struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lag' locale +func New() locales.Translator { + return &lag{ + locale: "lag", + pluralsCardinal: []locales.PluralRule{1, 2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "Fúngatɨ", "Naanɨ", "Keenda", "Ikúmi", "Inyambala", "Idwaata", "Mʉʉnchɨ", "Vɨɨrɨ", "Saatʉ", "Inyi", "Saano", "Sasatʉ"}, + monthsNarrow: []string{"", "F", "N", "K", "I", "I", "I", "M", "V", "S", "I", "S", "S"}, + monthsWide: []string{"", "Kʉfúngatɨ", "Kʉnaanɨ", "Kʉkeenda", "Kwiikumi", "Kwiinyambála", "Kwiidwaata", "Kʉmʉʉnchɨ", "Kʉvɨɨrɨ", "Kʉsaatʉ", "Kwiinyi", "Kʉsaano", "Kʉsasatʉ"}, + daysAbbreviated: []string{"Píili", "Táatu", "Íne", "Táano", "Alh", "Ijm", "Móosi"}, + daysNarrow: []string{"P", "T", "E", "O", "A", "I", "M"}, + daysWide: []string{"Jumapíiri", "Jumatátu", "Jumaíne", "Jumatáano", "Alamíisi", "Ijumáa", "Jumamóosi"}, + periodsAbbreviated: []string{"TOO", "MUU"}, + periodsWide: []string{"TOO", "MUU"}, + erasAbbreviated: []string{"KSA", "KA"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kɨrɨsitʉ sɨ anavyaal", "Kɨrɨsitʉ akavyaalwe"}, + timezones: map[string]string{"CDT": "CDT", "AWST": "AWST", "VET": "VET", "OEZ": "OEZ", "MESZ": "MESZ", "JST": "JST", "HEOG": "HEOG", "MST": "MST", "COST": "COST", "BT": "BT", "BOT": "BOT", "ACWDT": "ACWDT", "HAT": "HAT", "AKST": "AKST", "HNCU": "HNCU", "CST": "CST", "CLT": "CLT", "ACDT": "ACDT", "UYST": "UYST", "∅∅∅": "∅∅∅", "HNEG": "HNEG", "OESZ": "OESZ", "WEZ": "WEZ", "EDT": "EDT", "ChST": "ChST", "HNPM": "HNPM", "AWDT": "AWDT", "ECT": "ECT", "HNOG": "HNOG", "HADT": "HADT", "ARST": "ARST", "EST": "EST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "HNT": "HNT", "WITA": "WITA", "CHADT": "CHADT", "CLST": "CLST", "NZDT": "NZDT", "ADT": "ADT", "ART": "ART", "HKST": "HKST", "AEDT": "AEDT", "UYT": "UYT", "CAT": "CAT", "ACWST": "ACWST", "WIB": "WIB", "MYT": "MYT", "LHST": "LHST", "SGT": "SGT", "NZST": "NZST", "WARST": "WARST", "WAST": "WAST", "HEEG": "HEEG", "AEST": "AEST", "LHDT": "LHDT", "WIT": "WIT", "PST": "PST", "PDT": "PDT", "GFT": "GFT", "WART": "WART", "TMT": "TMT", "JDT": "JDT", "AST": "AST", "TMST": "TMST", "WAT": "WAT", "AKDT": "AKDT", "HEPM": "HEPM", "CHAST": "CHAST", "IST": "IST", "GYT": "GYT", "HKT": "HKT", "HNPMX": "HNPMX", "WESZ": "WESZ", "GMT": "GMT", "HEPMX": "HEPMX", "MDT": "MDT", "ACST": "ACST", "SAST": "SAST", "SRT": "SRT", "EAT": "EAT", "HECU": "HECU", "HAST": "HAST", "MEZ": "MEZ", "COT": "COT"}, + } +} + +// Locale returns the current translators string locale +func (lag *lag) Locale() string { + return lag.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lag' +func (lag *lag) PluralsCardinal() []locales.PluralRule { + return lag.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lag' +func (lag *lag) PluralsOrdinal() []locales.PluralRule { + return lag.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lag' +func (lag *lag) PluralsRange() []locales.PluralRule { + return lag.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lag' +func (lag *lag) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if n == 0 { + return locales.PluralRuleZero + } else if (i == 0 || i == 1) && n != 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lag' +func (lag *lag) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lag' +func (lag *lag) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lag *lag) MonthAbbreviated(month time.Month) string { + return lag.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lag *lag) MonthsAbbreviated() []string { + return lag.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lag *lag) MonthNarrow(month time.Month) string { + return lag.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lag *lag) MonthsNarrow() []string { + return lag.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lag *lag) MonthWide(month time.Month) string { + return lag.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lag *lag) MonthsWide() []string { + return lag.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lag *lag) WeekdayAbbreviated(weekday time.Weekday) string { + return lag.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lag *lag) WeekdaysAbbreviated() []string { + return lag.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lag *lag) WeekdayNarrow(weekday time.Weekday) string { + return lag.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lag *lag) WeekdaysNarrow() []string { + return lag.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lag *lag) WeekdayShort(weekday time.Weekday) string { + return lag.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lag *lag) WeekdaysShort() []string { + return lag.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lag *lag) WeekdayWide(weekday time.Weekday) string { + return lag.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lag *lag) WeekdaysWide() []string { + return lag.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lag' and handles both Whole and Real numbers based on 'v' +func (lag *lag) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lag' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lag *lag) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lag' +func (lag *lag) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lag.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lag.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lag.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lag.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, lag.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lag.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lag' +// in accounting notation. +func (lag *lag) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lag.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lag.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lag.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, lag.currencyNegativePrefix[j]) + } + + b = append(b, lag.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lag.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lag.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, lag.currencyNegativeSuffix...) + } else { + + b = append(b, lag.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lag' +func (lag *lag) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lag' +func (lag *lag) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lag.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lag' +func (lag *lag) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lag.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lag' +func (lag *lag) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lag.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lag.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lag' +func (lag *lag) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lag.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lag' +func (lag *lag) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lag.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lag.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lag' +func (lag *lag) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lag.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lag.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lag' +func (lag *lag) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lag.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lag.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lag.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lag/lag_test.go b/vendor/github.com/go-playground/locales/lag/lag_test.go new file mode 100644 index 0000000000..5c1e38ba0a --- /dev/null +++ b/vendor/github.com/go-playground/locales/lag/lag_test.go @@ -0,0 +1,1120 @@ +package lag + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lag" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lag_TZ/lag_TZ.go b/vendor/github.com/go-playground/locales/lag_TZ/lag_TZ.go new file mode 100644 index 0000000000..0851ea20df --- /dev/null +++ b/vendor/github.com/go-playground/locales/lag_TZ/lag_TZ.go @@ -0,0 +1,505 @@ +package lag_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lag_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lag_TZ' locale +func New() locales.Translator { + return &lag_TZ{ + locale: "lag_TZ", + pluralsCardinal: []locales.PluralRule{1, 2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "Fúngatɨ", "Naanɨ", "Keenda", "Ikúmi", "Inyambala", "Idwaata", "Mʉʉnchɨ", "Vɨɨrɨ", "Saatʉ", "Inyi", "Saano", "Sasatʉ"}, + monthsNarrow: []string{"", "F", "N", "K", "I", "I", "I", "M", "V", "S", "I", "S", "S"}, + monthsWide: []string{"", "Kʉfúngatɨ", "Kʉnaanɨ", "Kʉkeenda", "Kwiikumi", "Kwiinyambála", "Kwiidwaata", "Kʉmʉʉnchɨ", "Kʉvɨɨrɨ", "Kʉsaatʉ", "Kwiinyi", "Kʉsaano", "Kʉsasatʉ"}, + daysAbbreviated: []string{"Píili", "Táatu", "Íne", "Táano", "Alh", "Ijm", "Móosi"}, + daysNarrow: []string{"P", "T", "E", "O", "A", "I", "M"}, + daysWide: []string{"Jumapíiri", "Jumatátu", "Jumaíne", "Jumatáano", "Alamíisi", "Ijumáa", "Jumamóosi"}, + periodsAbbreviated: []string{"TOO", "MUU"}, + periodsWide: []string{"TOO", "MUU"}, + erasAbbreviated: []string{"KSA", "KA"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kɨrɨsitʉ sɨ anavyaal", "Kɨrɨsitʉ akavyaalwe"}, + timezones: map[string]string{"CHAST": "CHAST", "PST": "PST", "HNOG": "HNOG", "COST": "COST", "HEOG": "HEOG", "HEEG": "HEEG", "AEST": "AEST", "HNPM": "HNPM", "AWDT": "AWDT", "WARST": "WARST", "CLST": "CLST", "HKST": "HKST", "ACDT": "ACDT", "AEDT": "AEDT", "HEPM": "HEPM", "LHDT": "LHDT", "HECU": "HECU", "CDT": "CDT", "SGT": "SGT", "ECT": "ECT", "WAST": "WAST", "HAST": "HAST", "MESZ": "MESZ", "TMST": "TMST", "EAT": "EAT", "OESZ": "OESZ", "WEZ": "WEZ", "HNNOMX": "HNNOMX", "HNT": "HNT", "HAT": "HAT", "UYT": "UYT", "PDT": "PDT", "CAT": "CAT", "ACWST": "ACWST", "MEZ": "MEZ", "EST": "EST", "EDT": "EDT", "COT": "COT", "HEPMX": "HEPMX", "JST": "JST", "JDT": "JDT", "AST": "AST", "OEZ": "OEZ", "WESZ": "WESZ", "∅∅∅": "∅∅∅", "AWST": "AWST", "CHADT": "CHADT", "MST": "MST", "WITA": "WITA", "SAST": "SAST", "LHST": "LHST", "HNPMX": "HNPMX", "NZST": "NZST", "ADT": "ADT", "WAT": "WAT", "UYST": "UYST", "WIB": "WIB", "CLT": "CLT", "HENOMX": "HENOMX", "AKST": "AKST", "NZDT": "NZDT", "ART": "ART", "BT": "BT", "HNEG": "HNEG", "WIT": "WIT", "BOT": "BOT", "IST": "IST", "ARST": "ARST", "ChST": "ChST", "WART": "WART", "TMT": "TMT", "HKT": "HKT", "GYT": "GYT", "HNCU": "HNCU", "CST": "CST", "HADT": "HADT", "VET": "VET", "MYT": "MYT", "GFT": "GFT", "ACWDT": "ACWDT", "GMT": "GMT", "MDT": "MDT", "ACST": "ACST", "AKDT": "AKDT", "SRT": "SRT"}, + } +} + +// Locale returns the current translators string locale +func (lag *lag_TZ) Locale() string { + return lag.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lag_TZ' +func (lag *lag_TZ) PluralsCardinal() []locales.PluralRule { + return lag.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lag_TZ' +func (lag *lag_TZ) PluralsOrdinal() []locales.PluralRule { + return lag.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lag_TZ' +func (lag *lag_TZ) PluralsRange() []locales.PluralRule { + return lag.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lag_TZ' +func (lag *lag_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if n == 0 { + return locales.PluralRuleZero + } else if (i == 0 || i == 1) && n != 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lag_TZ' +func (lag *lag_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lag_TZ' +func (lag *lag_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lag *lag_TZ) MonthAbbreviated(month time.Month) string { + return lag.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lag *lag_TZ) MonthsAbbreviated() []string { + return lag.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lag *lag_TZ) MonthNarrow(month time.Month) string { + return lag.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lag *lag_TZ) MonthsNarrow() []string { + return lag.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lag *lag_TZ) MonthWide(month time.Month) string { + return lag.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lag *lag_TZ) MonthsWide() []string { + return lag.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lag *lag_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return lag.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lag *lag_TZ) WeekdaysAbbreviated() []string { + return lag.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lag *lag_TZ) WeekdayNarrow(weekday time.Weekday) string { + return lag.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lag *lag_TZ) WeekdaysNarrow() []string { + return lag.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lag *lag_TZ) WeekdayShort(weekday time.Weekday) string { + return lag.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lag *lag_TZ) WeekdaysShort() []string { + return lag.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lag *lag_TZ) WeekdayWide(weekday time.Weekday) string { + return lag.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lag *lag_TZ) WeekdaysWide() []string { + return lag.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lag_TZ' and handles both Whole and Real numbers based on 'v' +func (lag *lag_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lag_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lag *lag_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lag_TZ' +func (lag *lag_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lag.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lag.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lag.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lag.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, lag.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lag.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lag_TZ' +// in accounting notation. +func (lag *lag_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lag.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lag.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lag.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, lag.currencyNegativePrefix[j]) + } + + b = append(b, lag.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lag.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lag.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, lag.currencyNegativeSuffix...) + } else { + + b = append(b, lag.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lag_TZ' +func (lag *lag_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lag_TZ' +func (lag *lag_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lag.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lag_TZ' +func (lag *lag_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lag.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lag_TZ' +func (lag *lag_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lag.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lag.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lag_TZ' +func (lag *lag_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lag.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lag_TZ' +func (lag *lag_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lag.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lag.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lag_TZ' +func (lag *lag_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lag.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lag.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lag_TZ' +func (lag *lag_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lag.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lag.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lag.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lag_TZ/lag_TZ_test.go b/vendor/github.com/go-playground/locales/lag_TZ/lag_TZ_test.go new file mode 100644 index 0000000000..df20ccc5e7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lag_TZ/lag_TZ_test.go @@ -0,0 +1,1120 @@ +package lag_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lag_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lb/lb.go b/vendor/github.com/go-playground/locales/lb/lb.go new file mode 100644 index 0000000000..0a98717992 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lb/lb.go @@ -0,0 +1,592 @@ +package lb + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lb struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lb' locale +func New() locales.Translator { + return &lb{ + locale: "lb", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "öS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "Mäe.", "Abr.", "Mee", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "Mäerz", "Abrëll", "Mee", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"Son.", "Méi.", "Dën.", "Mët.", "Don.", "Fre.", "Sam."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mé.", "Dë.", "Më.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonndeg", "Méindeg", "Dënschdeg", "Mëttwoch", "Donneschdeg", "Freideg", "Samschdeg"}, + periodsAbbreviated: []string{"moies", "nomëttes"}, + periodsNarrow: []string{"mo.", "nomë."}, + periodsWide: []string{"moies", "nomëttes"}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"HECU": "Kubanesch Summerzäit", "BOT": "Bolivianesch Zäit", "CLST": "Chilenesch Summerzäit", "HEOG": "Westgrönland-Summerzäit", "ACST": "Zentralaustralesch Normalzäit", "COT": "Kolumbianesch Normalzäit", "HNPMX": "Mexikanesch Pazifik-Normalzäit", "CDT": "Nordamerikanesch Inland-Summerzäit", "ACWDT": "Zentral-/Westaustralesch Summerzäit", "EDT": "Nordamerikanesch Ostküsten-Summerzäit", "ACDT": "Zentralaustralesch Summerzäit", "HENOMX": "Nordwest-Mexiko-Summerzäit", "GFT": "Franséisch-Guayane-Zäit", "WIT": "Ostindonesesch Zäit", "MESZ": "Mëtteleuropäesch Summerzäit", "OEZ": "Osteuropäesch Normalzäit", "HNPM": "Saint-Pierre-a-Miquelon-Normalzäit", "HEPM": "Saint-Pierre-a-Miquelon-Summerzäit", "NZST": "Neiséiland-Normalzäit", "HNOG": "Westgrönland-Normalzäit", "WAT": "Westafrikanesch Normalzäit", "BT": "Bhutan-Zäit", "SRT": "Suriname-Zäit", "LHST": "Lord-Howe-Normalzäit", "CST": "Nordamerikanesch Inland-Normalzäit", "PST": "Nordamerikanesch Westküsten-Normalzäit", "HNNOMX": "Nordwest-Mexiko-Normalzäit", "HNEG": "Ostgrönland-Normalzäit", "JST": "Japanesch Normalzäit", "ADT": "Atlantik-Summerzäit", "HNT": "Neifundland-Normalzäit", "WITA": "Zentralindonesesch Zäit", "GYT": "Guyana-Zäit", "SGT": "Singapur-Standardzäit", "MYT": "Malaysesch Zäit", "WESZ": "Westeuropäesch Summerzäit", "ARST": "Argentinesch Summerzäit", "ChST": "Chamorro-Zäit", "VET": "Venezuela-Zäit", "WART": "Westargentinesch Normalzäit", "AKST": "Alaska-Normalzäit", "HAST": "Hawaii-Aleuten-Normalzäit", "JDT": "Japanesch Summerzäit", "GMT": "Mëttler Greenwich-Zäit", "WARST": "Westargentinesch Summerzäit", "WAST": "Westafrikanesch Summerzäit", "CLT": "Chilenesch Normalzäit", "OESZ": "Osteuropäesch Summerzäit", "TMT": "Turkmenistan-Normalzäit", "HKST": "Hong-Kong-Summerzäit", "UYST": "Uruguayanesch Summerzäit", "AWST": "Westaustralesch Normalzäit", "AEST": "Ostaustralesch Normalzäit", "UYT": "Uruguyanesch Normalzäit", "EAT": "Ostafrikanesch Zäit", "WIB": "Westindonesesch Zäit", "CAT": "Zentralafrikanesch Zäit", "HKT": "Hong-Kong-Normalzäit", "SAST": "Südafrikanesch Zäit", "HEPMX": "Mexikanesch Pazifik-Summerzäit", "HNCU": "Kubanesch Normalzäit", "CHADT": "Chatham-Summerzäit", "AST": "Atlantik-Normalzäit", "TMST": "Turkmenistan-Summerzäit", "MST": "MST", "AEDT": "Ostaustralesch Summerzäit", "AKDT": "Alaska-Summerzäit", "∅∅∅": "Brasília-Summerzäit", "PDT": "Nordamerikanesch Westküsten-Summerzäit", "NZDT": "Neiséiland-Summerzäit", "MEZ": "Mëtteleuropäesch Normalzäit", "MDT": "MDT", "HEEG": "Ostgrönland-Summerzäit", "ECT": "Ecuadorianesch Zäit", "IST": "Indesch Zäit", "ART": "Argentinesch Normalzäit", "COST": "Kolumbianesch Summerzäit", "HAT": "Neifundland-Summerzäit", "AWDT": "Westaustralesch Summerzäit", "CHAST": "Chatham-Normalzäit", "HADT": "Hawaii-Aleuten-Summerzäit", "ACWST": "Zentral-/Westaustralesch Normalzäit", "WEZ": "Westeuropäesch Normalzäit", "EST": "Nordamerikanesch Ostküsten-Normalzäit", "LHDT": "Lord-Howe-Summerzäit"}, + } +} + +// Locale returns the current translators string locale +func (lb *lb) Locale() string { + return lb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lb' +func (lb *lb) PluralsCardinal() []locales.PluralRule { + return lb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lb' +func (lb *lb) PluralsOrdinal() []locales.PluralRule { + return lb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lb' +func (lb *lb) PluralsRange() []locales.PluralRule { + return lb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lb' +func (lb *lb) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lb' +func (lb *lb) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lb' +func (lb *lb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lb *lb) MonthAbbreviated(month time.Month) string { + return lb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lb *lb) MonthsAbbreviated() []string { + return lb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lb *lb) MonthNarrow(month time.Month) string { + return lb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lb *lb) MonthsNarrow() []string { + return lb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lb *lb) MonthWide(month time.Month) string { + return lb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lb *lb) MonthsWide() []string { + return lb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lb *lb) WeekdayAbbreviated(weekday time.Weekday) string { + return lb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lb *lb) WeekdaysAbbreviated() []string { + return lb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lb *lb) WeekdayNarrow(weekday time.Weekday) string { + return lb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lb *lb) WeekdaysNarrow() []string { + return lb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lb *lb) WeekdayShort(weekday time.Weekday) string { + return lb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lb *lb) WeekdaysShort() []string { + return lb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lb *lb) WeekdayWide(weekday time.Weekday) string { + return lb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lb *lb) WeekdaysWide() []string { + return lb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lb' and handles both Whole and Real numbers based on 'v' +func (lb *lb) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lb' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lb *lb) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lb.percentSuffix...) + + b = append(b, lb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lb' +func (lb *lb) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, lb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lb' +// in accounting notation. +func (lb *lb) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, lb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, lb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, lb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lb' +func (lb *lb) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lb' +func (lb *lb) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lb' +func (lb *lb) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lb' +func (lb *lb) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lb' +func (lb *lb) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lb' +func (lb *lb) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lb' +func (lb *lb) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lb' +func (lb *lb) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lb/lb_test.go b/vendor/github.com/go-playground/locales/lb/lb_test.go new file mode 100644 index 0000000000..a51b75f916 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lb/lb_test.go @@ -0,0 +1,1120 @@ +package lb + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lb" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lb_LU/lb_LU.go b/vendor/github.com/go-playground/locales/lb_LU/lb_LU.go new file mode 100644 index 0000000000..b2b3be08eb --- /dev/null +++ b/vendor/github.com/go-playground/locales/lb_LU/lb_LU.go @@ -0,0 +1,592 @@ +package lb_LU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lb_LU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lb_LU' locale +func New() locales.Translator { + return &lb_LU{ + locale: "lb_LU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "Mäe.", "Abr.", "Mee", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januar", "Februar", "Mäerz", "Abrëll", "Mee", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}, + daysAbbreviated: []string{"Son.", "Méi.", "Dën.", "Mët.", "Don.", "Fre.", "Sam."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysShort: []string{"So.", "Mé.", "Dë.", "Më.", "Do.", "Fr.", "Sa."}, + daysWide: []string{"Sonndeg", "Méindeg", "Dënschdeg", "Mëttwoch", "Donneschdeg", "Freideg", "Samschdeg"}, + periodsAbbreviated: []string{"moies", "nomëttes"}, + periodsNarrow: []string{"mo.", "nomë."}, + periodsWide: []string{"moies", "nomëttes"}, + erasAbbreviated: []string{"v. Chr.", "n. Chr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"v. Chr.", "n. Chr."}, + timezones: map[string]string{"ACST": "Zentralaustralesch Normalzäit", "COST": "Kolumbianesch Summerzäit", "AKDT": "Alaska-Summerzäit", "HNPM": "Saint-Pierre-a-Miquelon-Normalzäit", "SRT": "Suriname-Zäit", "SAST": "Südafrikanesch Zäit", "AWST": "Westaustralesch Normalzäit", "WARST": "Westargentinesch Summerzäit", "WESZ": "Westeuropäesch Summerzäit", "TMST": "Turkmenistan-Summerzäit", "ARST": "Argentinesch Summerzäit", "EST": "Nordamerikanesch Ostküsten-Normalzäit", "∅∅∅": "Acre-Summerzäit", "HECU": "Kubanesch Summerzäit", "NZST": "Neiséiland-Normalzäit", "CAT": "Zentralafrikanesch Zäit", "ART": "Argentinesch Normalzäit", "MDT": "Rocky-Mountain-Summerzäit", "AKST": "Alaska-Normalzäit", "UYT": "Uruguyanesch Normalzäit", "CST": "Nordamerikanesch Inland-Normalzäit", "PDT": "Nordamerikanesch Westküsten-Summerzäit", "HENOMX": "Nordwest-Mexiko-Summerzäit", "WIT": "Ostindonesesch Zäit", "ECT": "Ecuadorianesch Zäit", "ACWDT": "Zentral-/Westaustralesch Summerzäit", "WART": "Westargentinesch Normalzäit", "HNT": "Neifundland-Normalzäit", "LHST": "Lord-Howe-Normalzäit", "HEPMX": "Mexikanesch Pazifik-Summerzäit", "MEZ": "Mëtteleuropäesch Normalzäit", "VET": "Venezuela-Zäit", "HADT": "Hawaii-Aleuten-Summerzäit", "MYT": "Malaysesch Zäit", "HNOG": "Westgrönland-Normalzäit", "OESZ": "Osteuropäesch Summerzäit", "ACDT": "Zentralaustralesch Summerzäit", "HNPMX": "Mexikanesch Pazifik-Normalzäit", "SGT": "Singapur-Standardzäit", "JST": "Japanesch Normalzäit", "MESZ": "Mëtteleuropäesch Summerzäit", "HEEG": "Ostgrönland-Summerzäit", "AEST": "Ostaustralesch Normalzäit", "ChST": "Chamorro-Zäit", "UYST": "Uruguayanesch Summerzäit", "LHDT": "Lord-Howe-Summerzäit", "GYT": "Guyana-Zäit", "CHADT": "Chatham-Summerzäit", "GMT": "Mëttler Greenwich-Zäit", "OEZ": "Osteuropäesch Normalzäit", "WAT": "Westafrikanesch Normalzäit", "GFT": "Franséisch-Guayane-Zäit", "IST": "Indesch Zäit", "ACWST": "Zentral-/Westaustralesch Normalzäit", "TMT": "Turkmenistan-Normalzäit", "HKST": "Hong-Kong-Summerzäit", "AEDT": "Ostaustralesch Summerzäit", "HNCU": "Kubanesch Normalzäit", "AST": "Atlantik-Normalzäit", "BT": "Bhutan-Zäit", "PST": "Nordamerikanesch Westküsten-Normalzäit", "NZDT": "Neiséiland-Summerzäit", "CLST": "Chilenesch Summerzäit", "HAT": "Neifundland-Summerzäit", "MST": "Rocky-Mountain-Normalzäit", "AWDT": "Westaustralesch Summerzäit", "BOT": "Bolivianesch Zäit", "CLT": "Chilenesch Normalzäit", "EDT": "Nordamerikanesch Ostküsten-Summerzäit", "HEPM": "Saint-Pierre-a-Miquelon-Summerzäit", "EAT": "Ostafrikanesch Zäit", "CDT": "Nordamerikanesch Inland-Summerzäit", "WEZ": "Westeuropäesch Normalzäit", "HKT": "Hong-Kong-Normalzäit", "HNNOMX": "Nordwest-Mexiko-Normalzäit", "WITA": "Zentralindonesesch Zäit", "WIB": "Westindonesesch Zäit", "HAST": "Hawaii-Aleuten-Normalzäit", "ADT": "Atlantik-Summerzäit", "WAST": "Westafrikanesch Summerzäit", "COT": "Kolumbianesch Normalzäit", "HNEG": "Ostgrönland-Normalzäit", "CHAST": "Chatham-Normalzäit", "JDT": "Japanesch Summerzäit", "HEOG": "Westgrönland-Summerzäit"}, + } +} + +// Locale returns the current translators string locale +func (lb *lb_LU) Locale() string { + return lb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lb_LU' +func (lb *lb_LU) PluralsCardinal() []locales.PluralRule { + return lb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lb_LU' +func (lb *lb_LU) PluralsOrdinal() []locales.PluralRule { + return lb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lb_LU' +func (lb *lb_LU) PluralsRange() []locales.PluralRule { + return lb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lb_LU' +func (lb *lb_LU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lb_LU' +func (lb *lb_LU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lb_LU' +func (lb *lb_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lb *lb_LU) MonthAbbreviated(month time.Month) string { + return lb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lb *lb_LU) MonthsAbbreviated() []string { + return lb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lb *lb_LU) MonthNarrow(month time.Month) string { + return lb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lb *lb_LU) MonthsNarrow() []string { + return lb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lb *lb_LU) MonthWide(month time.Month) string { + return lb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lb *lb_LU) MonthsWide() []string { + return lb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lb *lb_LU) WeekdayAbbreviated(weekday time.Weekday) string { + return lb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lb *lb_LU) WeekdaysAbbreviated() []string { + return lb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lb *lb_LU) WeekdayNarrow(weekday time.Weekday) string { + return lb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lb *lb_LU) WeekdaysNarrow() []string { + return lb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lb *lb_LU) WeekdayShort(weekday time.Weekday) string { + return lb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lb *lb_LU) WeekdaysShort() []string { + return lb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lb *lb_LU) WeekdayWide(weekday time.Weekday) string { + return lb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lb *lb_LU) WeekdaysWide() []string { + return lb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lb_LU' and handles both Whole and Real numbers based on 'v' +func (lb *lb_LU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lb_LU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lb *lb_LU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lb.percentSuffix...) + + b = append(b, lb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lb_LU' +func (lb *lb_LU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lb.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, lb.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lb_LU' +// in accounting notation. +func (lb *lb_LU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lb.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lb.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, lb.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, lb.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, lb.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lb_LU' +func (lb *lb_LU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lb_LU' +func (lb *lb_LU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lb_LU' +func (lb *lb_LU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lb_LU' +func (lb *lb_LU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lb_LU' +func (lb *lb_LU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lb_LU' +func (lb *lb_LU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lb_LU' +func (lb *lb_LU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lb_LU' +func (lb *lb_LU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lb_LU/lb_LU_test.go b/vendor/github.com/go-playground/locales/lb_LU/lb_LU_test.go new file mode 100644 index 0000000000..ff94ec311c --- /dev/null +++ b/vendor/github.com/go-playground/locales/lb_LU/lb_LU_test.go @@ -0,0 +1,1120 @@ +package lb_LU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lb_LU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lg/lg.go b/vendor/github.com/go-playground/locales/lg/lg.go new file mode 100644 index 0000000000..9351c11e5c --- /dev/null +++ b/vendor/github.com/go-playground/locales/lg/lg.go @@ -0,0 +1,510 @@ +package lg + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lg struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lg' locale +func New() locales.Translator { + return &lg{ + locale: "lg", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "USh", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apu", "Maa", "Juu", "Jul", "Agu", "Seb", "Oki", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janwaliyo", "Febwaliyo", "Marisi", "Apuli", "Maayi", "Juuni", "Julaayi", "Agusito", "Sebuttemba", "Okitobba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Sab", "Bal", "Lw2", "Lw3", "Lw4", "Lw5", "Lw6"}, + daysNarrow: []string{"S", "B", "L", "L", "L", "L", "L"}, + daysWide: []string{"Sabbiiti", "Balaza", "Lwakubiri", "Lwakusatu", "Lwakuna", "Lwakutaano", "Lwamukaaga"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kulisito nga tannaza", "Bukya Kulisito Azaal"}, + timezones: map[string]string{"JDT": "JDT", "AWDT": "AWDT", "PDT": "PDT", "AEST": "AEST", "AEDT": "AEDT", "LHDT": "LHDT", "CHAST": "CHAST", "HEOG": "HEOG", "WIB": "WIB", "AST": "AST", "GYT": "GYT", "ECT": "ECT", "NZDT": "NZDT", "WEZ": "WEZ", "GMT": "GMT", "WART": "WART", "ARST": "ARST", "WIT": "WIT", "PST": "PST", "ChST": "ChST", "HNPMX": "HNPMX", "COST": "COST", "WITA": "WITA", "OEZ": "OEZ", "MYT": "MYT", "WAST": "WAST", "HNNOMX": "HNNOMX", "HNCU": "HNCU", "BOT": "BOT", "CLST": "CLST", "WARST": "WARST", "TMST": "TMST", "EST": "EST", "HKST": "HKST", "ACST": "ACST", "BT": "BT", "ACWST": "ACWST", "WESZ": "WESZ", "HEEG": "HEEG", "HEPMX": "HEPMX", "AKDT": "AKDT", "UYST": "UYST", "CDT": "CDT", "HNOG": "HNOG", "VET": "VET", "MDT": "MDT", "UYT": "UYT", "SAST": "SAST", "EAT": "EAT", "IST": "IST", "MEZ": "MEZ", "CAT": "CAT", "ACDT": "ACDT", "HNEG": "HNEG", "HNPM": "HNPM", "LHST": "LHST", "CST": "CST", "HADT": "HADT", "MST": "MST", "HAT": "HAT", "HEPM": "HEPM", "SRT": "SRT", "MESZ": "MESZ", "CLT": "CLT", "OESZ": "OESZ", "ART": "ART", "HENOMX": "HENOMX", "SGT": "SGT", "ACWDT": "ACWDT", "EDT": "EDT", "COT": "COT", "GFT": "GFT", "HECU": "HECU", "HAST": "HAST", "JST": "JST", "WAT": "WAT", "HNT": "HNT", "AKST": "AKST", "TMT": "TMT", "HKT": "HKT", "CHADT": "CHADT", "NZST": "NZST", "ADT": "ADT", "∅∅∅": "∅∅∅", "AWST": "AWST"}, + } +} + +// Locale returns the current translators string locale +func (lg *lg) Locale() string { + return lg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lg' +func (lg *lg) PluralsCardinal() []locales.PluralRule { + return lg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lg' +func (lg *lg) PluralsOrdinal() []locales.PluralRule { + return lg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lg' +func (lg *lg) PluralsRange() []locales.PluralRule { + return lg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lg' +func (lg *lg) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lg' +func (lg *lg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lg' +func (lg *lg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lg *lg) MonthAbbreviated(month time.Month) string { + return lg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lg *lg) MonthsAbbreviated() []string { + return lg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lg *lg) MonthNarrow(month time.Month) string { + return lg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lg *lg) MonthsNarrow() []string { + return lg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lg *lg) MonthWide(month time.Month) string { + return lg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lg *lg) MonthsWide() []string { + return lg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lg *lg) WeekdayAbbreviated(weekday time.Weekday) string { + return lg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lg *lg) WeekdaysAbbreviated() []string { + return lg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lg *lg) WeekdayNarrow(weekday time.Weekday) string { + return lg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lg *lg) WeekdaysNarrow() []string { + return lg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lg *lg) WeekdayShort(weekday time.Weekday) string { + return lg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lg *lg) WeekdaysShort() []string { + return lg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lg *lg) WeekdayWide(weekday time.Weekday) string { + return lg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lg *lg) WeekdaysWide() []string { + return lg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lg' and handles both Whole and Real numbers based on 'v' +func (lg *lg) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lg' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lg *lg) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lg' +func (lg *lg) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lg.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lg' +// in accounting notation. +func (lg *lg) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lg.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, lg.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lg' +func (lg *lg) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lg' +func (lg *lg) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lg' +func (lg *lg) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lg' +func (lg *lg) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lg' +func (lg *lg) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lg' +func (lg *lg) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lg' +func (lg *lg) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lg' +func (lg *lg) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lg/lg_test.go b/vendor/github.com/go-playground/locales/lg/lg_test.go new file mode 100644 index 0000000000..553c1cf85b --- /dev/null +++ b/vendor/github.com/go-playground/locales/lg/lg_test.go @@ -0,0 +1,1120 @@ +package lg + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lg" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lg_UG/lg_UG.go b/vendor/github.com/go-playground/locales/lg_UG/lg_UG.go new file mode 100644 index 0000000000..064e90252f --- /dev/null +++ b/vendor/github.com/go-playground/locales/lg_UG/lg_UG.go @@ -0,0 +1,510 @@ +package lg_UG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lg_UG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lg_UG' locale +func New() locales.Translator { + return &lg_UG{ + locale: "lg_UG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apu", "Maa", "Juu", "Jul", "Agu", "Seb", "Oki", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janwaliyo", "Febwaliyo", "Marisi", "Apuli", "Maayi", "Juuni", "Julaayi", "Agusito", "Sebuttemba", "Okitobba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Sab", "Bal", "Lw2", "Lw3", "Lw4", "Lw5", "Lw6"}, + daysNarrow: []string{"S", "B", "L", "L", "L", "L", "L"}, + daysWide: []string{"Sabbiiti", "Balaza", "Lwakubiri", "Lwakusatu", "Lwakuna", "Lwakutaano", "Lwamukaaga"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kulisito nga tannaza", "Bukya Kulisito Azaal"}, + timezones: map[string]string{"HAST": "HAST", "ACWDT": "ACWDT", "CLT": "CLT", "HNPMX": "HNPMX", "TMT": "TMT", "HKT": "HKT", "CDT": "CDT", "NZDT": "NZDT", "VET": "VET", "OESZ": "OESZ", "AWDT": "AWDT", "HKST": "HKST", "ACST": "ACST", "HNPM": "HNPM", "ECT": "ECT", "JDT": "JDT", "HNEG": "HNEG", "HECU": "HECU", "HNNOMX": "HNNOMX", "GFT": "GFT", "GYT": "GYT", "AKST": "AKST", "HEPM": "HEPM", "LHDT": "LHDT", "ACWST": "ACWST", "AEST": "AEST", "AEDT": "AEDT", "UYST": "UYST", "EAT": "EAT", "HNCU": "HNCU", "IST": "IST", "ChST": "ChST", "∅∅∅": "∅∅∅", "ART": "ART", "ACDT": "ACDT", "BT": "BT", "GMT": "GMT", "COT": "COT", "HNT": "HNT", "HAT": "HAT", "WIB": "WIB", "SGT": "SGT", "NZST": "NZST", "JST": "JST", "WITA": "WITA", "MST": "MST", "HENOMX": "HENOMX", "HEPMX": "HEPMX", "SRT": "SRT", "CST": "CST", "HEOG": "HEOG", "AST": "AST", "TMST": "TMST", "WAST": "WAST", "WIT": "WIT", "AWST": "AWST", "CHADT": "CHADT", "WAT": "WAT", "ARST": "ARST", "MESZ": "MESZ", "HNOG": "HNOG", "OEZ": "OEZ", "WEZ": "WEZ", "EST": "EST", "UYT": "UYT", "PST": "PST", "CAT": "CAT", "MYT": "MYT", "MDT": "MDT", "EDT": "EDT", "COST": "COST", "HEEG": "HEEG", "LHST": "LHST", "CHAST": "CHAST", "PDT": "PDT", "WARST": "WARST", "WESZ": "WESZ", "CLST": "CLST", "ADT": "ADT", "AKDT": "AKDT", "SAST": "SAST", "BOT": "BOT", "HADT": "HADT", "MEZ": "MEZ", "WART": "WART"}, + } +} + +// Locale returns the current translators string locale +func (lg *lg_UG) Locale() string { + return lg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lg_UG' +func (lg *lg_UG) PluralsCardinal() []locales.PluralRule { + return lg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lg_UG' +func (lg *lg_UG) PluralsOrdinal() []locales.PluralRule { + return lg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lg_UG' +func (lg *lg_UG) PluralsRange() []locales.PluralRule { + return lg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lg_UG' +func (lg *lg_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lg_UG' +func (lg *lg_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lg_UG' +func (lg *lg_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lg *lg_UG) MonthAbbreviated(month time.Month) string { + return lg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lg *lg_UG) MonthsAbbreviated() []string { + return lg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lg *lg_UG) MonthNarrow(month time.Month) string { + return lg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lg *lg_UG) MonthsNarrow() []string { + return lg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lg *lg_UG) MonthWide(month time.Month) string { + return lg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lg *lg_UG) MonthsWide() []string { + return lg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lg *lg_UG) WeekdayAbbreviated(weekday time.Weekday) string { + return lg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lg *lg_UG) WeekdaysAbbreviated() []string { + return lg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lg *lg_UG) WeekdayNarrow(weekday time.Weekday) string { + return lg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lg *lg_UG) WeekdaysNarrow() []string { + return lg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lg *lg_UG) WeekdayShort(weekday time.Weekday) string { + return lg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lg *lg_UG) WeekdaysShort() []string { + return lg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lg *lg_UG) WeekdayWide(weekday time.Weekday) string { + return lg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lg *lg_UG) WeekdaysWide() []string { + return lg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lg_UG' and handles both Whole and Real numbers based on 'v' +func (lg *lg_UG) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lg_UG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lg *lg_UG) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lg_UG' +func (lg *lg_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lg.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lg_UG' +// in accounting notation. +func (lg *lg_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lg.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, lg.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lg_UG' +func (lg *lg_UG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lg_UG' +func (lg *lg_UG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lg_UG' +func (lg *lg_UG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lg_UG' +func (lg *lg_UG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lg_UG' +func (lg *lg_UG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lg_UG' +func (lg *lg_UG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lg_UG' +func (lg *lg_UG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lg_UG' +func (lg *lg_UG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lg_UG/lg_UG_test.go b/vendor/github.com/go-playground/locales/lg_UG/lg_UG_test.go new file mode 100644 index 0000000000..e9458eef29 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lg_UG/lg_UG_test.go @@ -0,0 +1,1120 @@ +package lg_UG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lg_UG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lkt/lkt.go b/vendor/github.com/go-playground/locales/lkt/lkt.go new file mode 100644 index 0000000000..c3ec411e02 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lkt/lkt.go @@ -0,0 +1,521 @@ +package lkt + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lkt struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lkt' locale +func New() locales.Translator { + return &lkt{ + locale: "lkt", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsWide: []string{"", "Wiótheȟika Wí", "Thiyóȟeyuŋka Wí", "Ištáwičhayazaŋ Wí", "Pȟežítȟo Wí", "Čhaŋwápetȟo Wí", "Wípazukȟa-wašté Wí", "Čhaŋpȟásapa Wí", "Wasútȟuŋ Wí", "Čhaŋwápeǧi Wí", "Čhaŋwápe-kasná Wí", "Waníyetu Wí", "Tȟahékapšuŋ Wí"}, + daysNarrow: []string{"A", "W", "N", "Y", "T", "Z", "O"}, + daysWide: []string{"Aŋpétuwakȟaŋ", "Aŋpétuwaŋži", "Aŋpétunuŋpa", "Aŋpétuyamni", "Aŋpétutopa", "Aŋpétuzaptaŋ", "Owáŋgyužažapi"}, + timezones: map[string]string{"HEEG": "HEEG", "MEZ": "MEZ", "WART": "WART", "CHAST": "CHAST", "OEZ": "OEZ", "COT": "COT", "COST": "COST", "HNT": "HNT", "UYST": "UYST", "WIB": "WIB", "WESZ": "WESZ", "MYT": "MYT", "ART": "ART", "HEPMX": "HEPMX", "EAT": "EAT", "WIT": "WIT", "PDT": "PDT", "CLT": "CLT", "HKST": "HKST", "EST": "EST", "HKT": "HKT", "HAT": "HAT", "HAST": "HAST", "HADT": "HADT", "CAT": "CAT", "WAT": "WAT", "AKST": "AKST", "MST": "MST", "GYT": "GYT", "SGT": "SGT", "VET": "VET", "TMST": "TMST", "MDT": "MDT", "CDT": "CDT", "OESZ": "OESZ", "WEZ": "WEZ", "CLST": "CLST", "BT": "BT", "HNEG": "HNEG", "AEST": "AEST", "ChST": "ChST", "NZDT": "NZDT", "HNOG": "HNOG", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "CST": "CST", "IST": "IST", "JST": "JST", "HENOMX": "HENOMX", "ADT": "ADT", "TMT": "TMT", "HEOG": "HEOG", "GMT": "GMT", "ACDT": "ACDT", "WITA": "WITA", "AKDT": "AKDT", "HNCU": "HNCU", "ACWST": "ACWST", "AWDT": "AWDT", "CHADT": "CHADT", "ECT": "ECT", "ACST": "ACST", "HNPM": "HNPM", "SRT": "SRT", "HECU": "HECU", "AWST": "AWST", "JDT": "JDT", "ARST": "ARST", "EDT": "EDT", "GFT": "GFT", "LHST": "LHST", "PST": "PST", "WARST": "WARST", "SAST": "SAST", "BOT": "BOT", "ACWDT": "ACWDT", "MESZ": "MESZ", "UYT": "UYT", "HEPM": "HEPM", "NZST": "NZST", "WAST": "WAST", "∅∅∅": "∅∅∅", "AEDT": "AEDT", "LHDT": "LHDT", "AST": "AST"}, + } +} + +// Locale returns the current translators string locale +func (lkt *lkt) Locale() string { + return lkt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lkt' +func (lkt *lkt) PluralsCardinal() []locales.PluralRule { + return lkt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lkt' +func (lkt *lkt) PluralsOrdinal() []locales.PluralRule { + return lkt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lkt' +func (lkt *lkt) PluralsRange() []locales.PluralRule { + return lkt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lkt' +func (lkt *lkt) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lkt' +func (lkt *lkt) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lkt' +func (lkt *lkt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lkt *lkt) MonthAbbreviated(month time.Month) string { + return lkt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lkt *lkt) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lkt *lkt) MonthNarrow(month time.Month) string { + return lkt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lkt *lkt) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lkt *lkt) MonthWide(month time.Month) string { + return lkt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lkt *lkt) MonthsWide() []string { + return lkt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lkt *lkt) WeekdayAbbreviated(weekday time.Weekday) string { + return lkt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lkt *lkt) WeekdaysAbbreviated() []string { + return lkt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lkt *lkt) WeekdayNarrow(weekday time.Weekday) string { + return lkt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lkt *lkt) WeekdaysNarrow() []string { + return lkt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lkt *lkt) WeekdayShort(weekday time.Weekday) string { + return lkt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lkt *lkt) WeekdaysShort() []string { + return lkt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lkt *lkt) WeekdayWide(weekday time.Weekday) string { + return lkt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lkt *lkt) WeekdaysWide() []string { + return lkt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lkt' and handles both Whole and Real numbers based on 'v' +func (lkt *lkt) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lkt' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lkt *lkt) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lkt' +func (lkt *lkt) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lkt.currencies[currency] + l := len(s) + len(symbol) + 5 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lkt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lkt.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lkt.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, lkt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lkt.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lkt' +// in accounting notation. +func (lkt *lkt) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lkt.currencies[currency] + l := len(s) + len(symbol) + 5 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lkt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lkt.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, lkt.currencyNegativePrefix[j]) + } + + b = append(b, lkt.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lkt.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lkt.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, lkt.currencyNegativeSuffix...) + } else { + + b = append(b, lkt.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lkt' +func (lkt *lkt) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lkt' +func (lkt *lkt) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lkt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lkt' +func (lkt *lkt) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lkt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lkt' +func (lkt *lkt) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lkt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, lkt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lkt' +func (lkt *lkt) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lkt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lkt.periodsAbbreviated[0]...) + } else { + b = append(b, lkt.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lkt' +func (lkt *lkt) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lkt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lkt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lkt.periodsAbbreviated[0]...) + } else { + b = append(b, lkt.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lkt' +func (lkt *lkt) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lkt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lkt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lkt.periodsAbbreviated[0]...) + } else { + b = append(b, lkt.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lkt' +func (lkt *lkt) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lkt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lkt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lkt.periodsAbbreviated[0]...) + } else { + b = append(b, lkt.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lkt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lkt/lkt_test.go b/vendor/github.com/go-playground/locales/lkt/lkt_test.go new file mode 100644 index 0000000000..d33a3584a1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lkt/lkt_test.go @@ -0,0 +1,1120 @@ +package lkt + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lkt" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lkt_US/lkt_US.go b/vendor/github.com/go-playground/locales/lkt_US/lkt_US.go new file mode 100644 index 0000000000..8f71d06830 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lkt_US/lkt_US.go @@ -0,0 +1,521 @@ +package lkt_US + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lkt_US struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lkt_US' locale +func New() locales.Translator { + return &lkt_US{ + locale: "lkt_US", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsWide: []string{"", "Wiótheȟika Wí", "Thiyóȟeyuŋka Wí", "Ištáwičhayazaŋ Wí", "Pȟežítȟo Wí", "Čhaŋwápetȟo Wí", "Wípazukȟa-wašté Wí", "Čhaŋpȟásapa Wí", "Wasútȟuŋ Wí", "Čhaŋwápeǧi Wí", "Čhaŋwápe-kasná Wí", "Waníyetu Wí", "Tȟahékapšuŋ Wí"}, + daysNarrow: []string{"A", "W", "N", "Y", "T", "Z", "O"}, + daysWide: []string{"Aŋpétuwakȟaŋ", "Aŋpétuwaŋži", "Aŋpétunuŋpa", "Aŋpétuyamni", "Aŋpétutopa", "Aŋpétuzaptaŋ", "Owáŋgyužažapi"}, + timezones: map[string]string{"COT": "COT", "∅∅∅": "∅∅∅", "HNEG": "HNEG", "UYST": "UYST", "JST": "JST", "ARST": "ARST", "EDT": "EDT", "GFT": "GFT", "NZST": "NZST", "MESZ": "MESZ", "WESZ": "WESZ", "WAT": "WAT", "ACST": "ACST", "ACDT": "ACDT", "AEST": "AEST", "WART": "WART", "HNOG": "HNOG", "OEZ": "OEZ", "ACWDT": "ACWDT", "AKDT": "AKDT", "SAST": "SAST", "LHDT": "LHDT", "GYT": "GYT", "HNCU": "HNCU", "CHADT": "CHADT", "NZDT": "NZDT", "CLT": "CLT", "AST": "AST", "JDT": "JDT", "WAST": "WAST", "ACWST": "ACWST", "CLST": "CLST", "HKT": "HKT", "ADT": "ADT", "HNNOMX": "HNNOMX", "WITA": "WITA", "AKST": "AKST", "LHST": "LHST", "HADT": "HADT", "CAT": "CAT", "IST": "IST", "WEZ": "WEZ", "TMT": "TMT", "EST": "EST", "SRT": "SRT", "TMST": "TMST", "HENOMX": "HENOMX", "HEEG": "HEEG", "ChST": "ChST", "CDT": "CDT", "BOT": "BOT", "VET": "VET", "HEOG": "HEOG", "HAT": "HAT", "HKST": "HKST", "MST": "MST", "EAT": "EAT", "HECU": "HECU", "WIT": "WIT", "AWDT": "AWDT", "ECT": "ECT", "COST": "COST", "HNPM": "HNPM", "HEPMX": "HEPMX", "SGT": "SGT", "PST": "PST", "HAST": "HAST", "BT": "BT", "MDT": "MDT", "HEPM": "HEPM", "GMT": "GMT", "HNT": "HNT", "MYT": "MYT", "OESZ": "OESZ", "ART": "ART", "AEDT": "AEDT", "AWST": "AWST", "WARST": "WARST", "UYT": "UYT", "HNPMX": "HNPMX", "WIB": "WIB", "CST": "CST", "CHAST": "CHAST", "PDT": "PDT", "MEZ": "MEZ"}, + } +} + +// Locale returns the current translators string locale +func (lkt *lkt_US) Locale() string { + return lkt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lkt_US' +func (lkt *lkt_US) PluralsCardinal() []locales.PluralRule { + return lkt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lkt_US' +func (lkt *lkt_US) PluralsOrdinal() []locales.PluralRule { + return lkt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lkt_US' +func (lkt *lkt_US) PluralsRange() []locales.PluralRule { + return lkt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lkt_US' +func (lkt *lkt_US) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lkt_US' +func (lkt *lkt_US) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lkt_US' +func (lkt *lkt_US) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lkt *lkt_US) MonthAbbreviated(month time.Month) string { + return lkt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lkt *lkt_US) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lkt *lkt_US) MonthNarrow(month time.Month) string { + return lkt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lkt *lkt_US) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lkt *lkt_US) MonthWide(month time.Month) string { + return lkt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lkt *lkt_US) MonthsWide() []string { + return lkt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lkt *lkt_US) WeekdayAbbreviated(weekday time.Weekday) string { + return lkt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lkt *lkt_US) WeekdaysAbbreviated() []string { + return lkt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lkt *lkt_US) WeekdayNarrow(weekday time.Weekday) string { + return lkt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lkt *lkt_US) WeekdaysNarrow() []string { + return lkt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lkt *lkt_US) WeekdayShort(weekday time.Weekday) string { + return lkt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lkt *lkt_US) WeekdaysShort() []string { + return lkt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lkt *lkt_US) WeekdayWide(weekday time.Weekday) string { + return lkt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lkt *lkt_US) WeekdaysWide() []string { + return lkt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lkt_US' and handles both Whole and Real numbers based on 'v' +func (lkt *lkt_US) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lkt_US' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lkt *lkt_US) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lkt_US' +func (lkt *lkt_US) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lkt.currencies[currency] + l := len(s) + len(symbol) + 5 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lkt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lkt.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lkt.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, lkt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lkt.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lkt_US' +// in accounting notation. +func (lkt *lkt_US) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lkt.currencies[currency] + l := len(s) + len(symbol) + 5 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lkt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lkt.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, lkt.currencyNegativePrefix[j]) + } + + b = append(b, lkt.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lkt.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lkt.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, lkt.currencyNegativeSuffix...) + } else { + + b = append(b, lkt.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lkt_US' +func (lkt *lkt_US) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lkt_US' +func (lkt *lkt_US) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lkt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lkt_US' +func (lkt *lkt_US) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lkt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lkt_US' +func (lkt *lkt_US) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lkt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, lkt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lkt_US' +func (lkt *lkt_US) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lkt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lkt.periodsAbbreviated[0]...) + } else { + b = append(b, lkt.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lkt_US' +func (lkt *lkt_US) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lkt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lkt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lkt.periodsAbbreviated[0]...) + } else { + b = append(b, lkt.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lkt_US' +func (lkt *lkt_US) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lkt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lkt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lkt.periodsAbbreviated[0]...) + } else { + b = append(b, lkt.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lkt_US' +func (lkt *lkt_US) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lkt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lkt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lkt.periodsAbbreviated[0]...) + } else { + b = append(b, lkt.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lkt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lkt_US/lkt_US_test.go b/vendor/github.com/go-playground/locales/lkt_US/lkt_US_test.go new file mode 100644 index 0000000000..0669675167 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lkt_US/lkt_US_test.go @@ -0,0 +1,1120 @@ +package lkt_US + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lkt_US" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ln/ln.go b/vendor/github.com/go-playground/locales/ln/ln.go new file mode 100644 index 0000000000..2913b8d891 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln/ln.go @@ -0,0 +1,551 @@ +package ln + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ln struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ln' locale +func New() locales.Translator { + return &ln{ + locale: "ln", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "Kz", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "FC", "CHE", "Fr.", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "T$", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "F CFP", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fbl", "msi", "apl", "mai", "yun", "yul", "agt", "stb", "ɔtb", "nvb", "dsb"}, + monthsNarrow: []string{"", "y", "f", "m", "a", "m", "y", "y", "a", "s", "ɔ", "n", "d"}, + monthsWide: []string{"", "sánzá ya yambo", "sánzá ya míbalé", "sánzá ya mísáto", "sánzá ya mínei", "sánzá ya mítáno", "sánzá ya motóbá", "sánzá ya nsambo", "sánzá ya mwambe", "sánzá ya libwa", "sánzá ya zómi", "sánzá ya zómi na mɔ̌kɔ́", "sánzá ya zómi na míbalé"}, + daysAbbreviated: []string{"eye", "ybo", "mbl", "mst", "min", "mtn", "mps"}, + daysNarrow: []string{"e", "y", "m", "m", "m", "m", "p"}, + daysWide: []string{"eyenga", "mokɔlɔ mwa yambo", "mokɔlɔ mwa míbalé", "mokɔlɔ mwa mísáto", "mokɔlɔ ya mínéi", "mokɔlɔ ya mítáno", "mpɔ́sɔ"}, + periodsAbbreviated: []string{"ntɔ́ngɔ́", "mpókwa"}, + periodsWide: []string{"ntɔ́ngɔ́", "mpókwa"}, + erasAbbreviated: []string{"libóso ya", "nsima ya Y"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Yambo ya Yézu Krís", "Nsima ya Yézu Krís"}, + timezones: map[string]string{"HADT": "HADT", "OEZ": "OEZ", "LHST": "LHST", "CST": "CST", "PST": "PST", "JDT": "JDT", "WEZ": "WEZ", "HNOG": "HNOG", "ACST": "ACST", "EST": "EST", "HNT": "HNT", "MDT": "MDT", "UYST": "UYST", "JST": "JST", "HEOG": "HEOG", "WAST": "WAST", "CHADT": "CHADT", "HKT": "HKT", "HENOMX": "HENOMX", "AEST": "AEST", "MST": "MST", "HAST": "HAST", "NZDT": "NZDT", "COST": "COST", "BT": "BT", "∅∅∅": "∅∅∅", "AEDT": "AEDT", "SAST": "Ntángo ya Afríka ya Sidi", "SGT": "SGT", "WAT": "WAT", "CDT": "CDT", "PDT": "PDT", "NZST": "NZST", "WIB": "WIB", "AKST": "AKST", "ChST": "ChST", "HNPM": "HNPM", "AWST": "AWST", "OESZ": "OESZ", "GMT": "Ntángo ya Londoni", "EDT": "EDT", "UYT": "UYT", "LHDT": "LHDT", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "BOT": "BOT", "TMT": "TMT", "ART": "ART", "AKDT": "AKDT", "HNNOMX": "HNNOMX", "CAT": "Ntángo ya Lubumbashi", "CLT": "CLT", "HKST": "HKST", "HEEG": "HEEG", "SRT": "SRT", "ACWST": "ACWST", "ADT": "ADT", "WART": "WART", "TMST": "TMST", "HNEG": "HNEG", "HAT": "HAT", "VET": "VET", "CLST": "CLST", "COT": "COT", "MYT": "MYT", "WITA": "WITA", "WIT": "WIT", "AWDT": "AWDT", "ACWDT": "ACWDT", "HNCU": "HNCU", "GYT": "GYT", "EAT": "Ntángo ya Afríka ya Ɛ́sita", "HECU": "HECU", "IST": "IST", "MEZ": "MEZ", "AST": "AST", "GFT": "GFT", "HEPM": "HEPM", "CHAST": "CHAST", "ECT": "ECT", "MESZ": "MESZ", "WESZ": "WESZ", "WARST": "WARST", "ARST": "ARST", "ACDT": "ACDT"}, + } +} + +// Locale returns the current translators string locale +func (ln *ln) Locale() string { + return ln.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ln' +func (ln *ln) PluralsCardinal() []locales.PluralRule { + return ln.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ln' +func (ln *ln) PluralsOrdinal() []locales.PluralRule { + return ln.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ln' +func (ln *ln) PluralsRange() []locales.PluralRule { + return ln.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ln' +func (ln *ln) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ln' +func (ln *ln) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ln' +func (ln *ln) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ln *ln) MonthAbbreviated(month time.Month) string { + return ln.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ln *ln) MonthsAbbreviated() []string { + return ln.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ln *ln) MonthNarrow(month time.Month) string { + return ln.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ln *ln) MonthsNarrow() []string { + return ln.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ln *ln) MonthWide(month time.Month) string { + return ln.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ln *ln) MonthsWide() []string { + return ln.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ln *ln) WeekdayAbbreviated(weekday time.Weekday) string { + return ln.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ln *ln) WeekdaysAbbreviated() []string { + return ln.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ln *ln) WeekdayNarrow(weekday time.Weekday) string { + return ln.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ln *ln) WeekdaysNarrow() []string { + return ln.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ln *ln) WeekdayShort(weekday time.Weekday) string { + return ln.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ln *ln) WeekdaysShort() []string { + return ln.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ln *ln) WeekdayWide(weekday time.Weekday) string { + return ln.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ln *ln) WeekdaysWide() []string { + return ln.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ln' and handles both Whole and Real numbers based on 'v' +func (ln *ln) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ln' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ln *ln) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ln' +func (ln *ln) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ln.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ln' +// in accounting notation. +func (ln *ln) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ln.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ln.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ln.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ln' +func (ln *ln) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ln' +func (ln *ln) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ln' +func (ln *ln) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ln' +func (ln *ln) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ln.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ln' +func (ln *ln) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ln' +func (ln *ln) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ln' +func (ln *ln) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ln' +func (ln *ln) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ln.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ln/ln_test.go b/vendor/github.com/go-playground/locales/ln/ln_test.go new file mode 100644 index 0000000000..2991619483 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln/ln_test.go @@ -0,0 +1,1120 @@ +package ln + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ln" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ln_AO/ln_AO.go b/vendor/github.com/go-playground/locales/ln_AO/ln_AO.go new file mode 100644 index 0000000000..7a6d869695 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln_AO/ln_AO.go @@ -0,0 +1,551 @@ +package ln_AO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ln_AO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ln_AO' locale +func New() locales.Translator { + return &ln_AO{ + locale: "ln_AO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "Kz", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fbl", "msi", "apl", "mai", "yun", "yul", "agt", "stb", "ɔtb", "nvb", "dsb"}, + monthsNarrow: []string{"", "y", "f", "m", "a", "m", "y", "y", "a", "s", "ɔ", "n", "d"}, + monthsWide: []string{"", "sánzá ya yambo", "sánzá ya míbalé", "sánzá ya mísáto", "sánzá ya mínei", "sánzá ya mítáno", "sánzá ya motóbá", "sánzá ya nsambo", "sánzá ya mwambe", "sánzá ya libwa", "sánzá ya zómi", "sánzá ya zómi na mɔ̌kɔ́", "sánzá ya zómi na míbalé"}, + daysAbbreviated: []string{"eye", "ybo", "mbl", "mst", "min", "mtn", "mps"}, + daysNarrow: []string{"e", "y", "m", "m", "m", "m", "p"}, + daysWide: []string{"eyenga", "mokɔlɔ mwa yambo", "mokɔlɔ mwa míbalé", "mokɔlɔ mwa mísáto", "mokɔlɔ ya mínéi", "mokɔlɔ ya mítáno", "mpɔ́sɔ"}, + periodsAbbreviated: []string{"ntɔ́ngɔ́", "mpókwa"}, + periodsWide: []string{"ntɔ́ngɔ́", "mpókwa"}, + erasAbbreviated: []string{"libóso ya", "nsima ya Y"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Yambo ya Yézu Krís", "Nsima ya Yézu Krís"}, + timezones: map[string]string{"SAST": "Ntángo ya Afríka ya Sidi", "HNOG": "HNOG", "CHAST": "CHAST", "MESZ": "MESZ", "CLST": "CLST", "WARST": "WARST", "AST": "AST", "OESZ": "OESZ", "MDT": "MDT", "AWDT": "AWDT", "VET": "VET", "WART": "WART", "CLT": "CLT", "HKT": "HKT", "∅∅∅": "∅∅∅", "HNPM": "HNPM", "WIT": "WIT", "CHADT": "CHADT", "BOT": "BOT", "MYT": "MYT", "HNT": "HNT", "UYT": "UYT", "EAT": "Ntángo ya Afríka ya Ɛ́sita", "ACDT": "ACDT", "HEPM": "HEPM", "HNPMX": "HNPMX", "UYST": "UYST", "WESZ": "WESZ", "ARST": "ARST", "COST": "COST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "HEPMX": "HEPMX", "GYT": "GYT", "OEZ": "OEZ", "ACWST": "ACWST", "ECT": "ECT", "MST": "MST", "GFT": "GFT", "WITA": "WITA", "AKST": "AKST", "ChST": "ChST", "SGT": "SGT", "JDT": "JDT", "GMT": "Ntángo ya Londoni", "HKST": "HKST", "HAT": "HAT", "PDT": "PDT", "HADT": "HADT", "ADT": "ADT", "WAT": "WAT", "SRT": "SRT", "HNCU": "HNCU", "CST": "CST", "PST": "PST", "HEOG": "HEOG", "ACST": "ACST", "BT": "BT", "WIB": "WIB", "AWST": "AWST", "HAST": "HAST", "WEZ": "WEZ", "COT": "COT", "AEST": "AEST", "NZST": "NZST", "TMT": "TMT", "AEDT": "AEDT", "HECU": "HECU", "NZDT": "NZDT", "HNEG": "HNEG", "WAST": "WAST", "EDT": "EDT", "AKDT": "AKDT", "CDT": "CDT", "IST": "IST", "JST": "JST", "TMST": "TMST", "CAT": "Ntángo ya Lubumbashi", "LHDT": "LHDT", "EST": "EST", "HEEG": "HEEG", "LHST": "LHST", "ACWDT": "ACWDT", "MEZ": "MEZ", "ART": "ART"}, + } +} + +// Locale returns the current translators string locale +func (ln *ln_AO) Locale() string { + return ln.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ln_AO' +func (ln *ln_AO) PluralsCardinal() []locales.PluralRule { + return ln.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ln_AO' +func (ln *ln_AO) PluralsOrdinal() []locales.PluralRule { + return ln.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ln_AO' +func (ln *ln_AO) PluralsRange() []locales.PluralRule { + return ln.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ln_AO' +func (ln *ln_AO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ln_AO' +func (ln *ln_AO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ln_AO' +func (ln *ln_AO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ln *ln_AO) MonthAbbreviated(month time.Month) string { + return ln.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ln *ln_AO) MonthsAbbreviated() []string { + return ln.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ln *ln_AO) MonthNarrow(month time.Month) string { + return ln.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ln *ln_AO) MonthsNarrow() []string { + return ln.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ln *ln_AO) MonthWide(month time.Month) string { + return ln.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ln *ln_AO) MonthsWide() []string { + return ln.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ln *ln_AO) WeekdayAbbreviated(weekday time.Weekday) string { + return ln.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ln *ln_AO) WeekdaysAbbreviated() []string { + return ln.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ln *ln_AO) WeekdayNarrow(weekday time.Weekday) string { + return ln.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ln *ln_AO) WeekdaysNarrow() []string { + return ln.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ln *ln_AO) WeekdayShort(weekday time.Weekday) string { + return ln.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ln *ln_AO) WeekdaysShort() []string { + return ln.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ln *ln_AO) WeekdayWide(weekday time.Weekday) string { + return ln.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ln *ln_AO) WeekdaysWide() []string { + return ln.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ln_AO' and handles both Whole and Real numbers based on 'v' +func (ln *ln_AO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ln_AO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ln *ln_AO) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ln_AO' +func (ln *ln_AO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ln.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ln_AO' +// in accounting notation. +func (ln *ln_AO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ln.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ln.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ln.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ln_AO' +func (ln *ln_AO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ln_AO' +func (ln *ln_AO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ln_AO' +func (ln *ln_AO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ln_AO' +func (ln *ln_AO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ln.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ln_AO' +func (ln *ln_AO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ln_AO' +func (ln *ln_AO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ln_AO' +func (ln *ln_AO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ln_AO' +func (ln *ln_AO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ln.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ln_AO/ln_AO_test.go b/vendor/github.com/go-playground/locales/ln_AO/ln_AO_test.go new file mode 100644 index 0000000000..c7eb4f2270 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln_AO/ln_AO_test.go @@ -0,0 +1,1120 @@ +package ln_AO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ln_AO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ln_CD/ln_CD.go b/vendor/github.com/go-playground/locales/ln_CD/ln_CD.go new file mode 100644 index 0000000000..2a4cc58c53 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln_CD/ln_CD.go @@ -0,0 +1,551 @@ +package ln_CD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ln_CD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ln_CD' locale +func New() locales.Translator { + return &ln_CD{ + locale: "ln_CD", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fbl", "msi", "apl", "mai", "yun", "yul", "agt", "stb", "ɔtb", "nvb", "dsb"}, + monthsNarrow: []string{"", "y", "f", "m", "a", "m", "y", "y", "a", "s", "ɔ", "n", "d"}, + monthsWide: []string{"", "sánzá ya yambo", "sánzá ya míbalé", "sánzá ya mísáto", "sánzá ya mínei", "sánzá ya mítáno", "sánzá ya motóbá", "sánzá ya nsambo", "sánzá ya mwambe", "sánzá ya libwa", "sánzá ya zómi", "sánzá ya zómi na mɔ̌kɔ́", "sánzá ya zómi na míbalé"}, + daysAbbreviated: []string{"eye", "ybo", "mbl", "mst", "min", "mtn", "mps"}, + daysNarrow: []string{"e", "y", "m", "m", "m", "m", "p"}, + daysWide: []string{"eyenga", "mokɔlɔ mwa yambo", "mokɔlɔ mwa míbalé", "mokɔlɔ mwa mísáto", "mokɔlɔ ya mínéi", "mokɔlɔ ya mítáno", "mpɔ́sɔ"}, + periodsAbbreviated: []string{"ntɔ́ngɔ́", "mpókwa"}, + periodsWide: []string{"ntɔ́ngɔ́", "mpókwa"}, + erasAbbreviated: []string{"libóso ya", "nsima ya Y"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Yambo ya Yézu Krís", "Nsima ya Yézu Krís"}, + timezones: map[string]string{"IST": "IST", "HEOG": "HEOG", "COST": "COST", "HNEG": "HNEG", "WITA": "WITA", "HEPM": "HEPM", "LHDT": "LHDT", "CDT": "CDT", "CAT": "Ntángo ya Lubumbashi", "ACWST": "ACWST", "ART": "ART", "WAST": "WAST", "ChST": "ChST", "MESZ": "MESZ", "HNNOMX": "HNNOMX", "CHAST": "CHAST", "CHADT": "CHADT", "WEZ": "WEZ", "TMT": "TMT", "COT": "COT", "HEEG": "HEEG", "LHST": "LHST", "WESZ": "WESZ", "ACDT": "ACDT", "HENOMX": "HENOMX", "AKST": "AKST", "SAST": "Ntángo ya Afríka ya Sidi", "CST": "CST", "SGT": "SGT", "HAST": "HAST", "JST": "JST", "HKT": "HKT", "AWST": "AWST", "WART": "WART", "WARST": "WARST", "ACST": "ACST", "HNT": "HNT", "GYT": "GYT", "EDT": "EDT", "∅∅∅": "∅∅∅", "HKST": "HKST", "AEST": "AEST", "EST": "EST", "WIT": "WIT", "PST": "PST", "PDT": "PDT", "ACWDT": "ACWDT", "NZDT": "NZDT", "MEZ": "MEZ", "ADT": "ADT", "HEPMX": "HEPMX", "SRT": "SRT", "HADT": "HADT", "MDT": "MDT", "HNPMX": "HNPMX", "HNCU": "HNCU", "WIB": "WIB", "BOT": "BOT", "ECT": "ECT", "GMT": "Ntángo ya Londoni", "ARST": "ARST", "UYT": "UYT", "HNPM": "HNPM", "AST": "AST", "CLT": "CLT", "CLST": "CLST", "MST": "MST", "HECU": "HECU", "NZST": "NZST", "JDT": "JDT", "HNOG": "HNOG", "HAT": "HAT", "AKDT": "AKDT", "GFT": "GFT", "BT": "BT", "UYST": "UYST", "EAT": "Ntángo ya Afríka ya Ɛ́sita", "AWDT": "AWDT", "VET": "VET", "OESZ": "OESZ", "MYT": "MYT", "TMST": "TMST", "AEDT": "AEDT", "OEZ": "OEZ", "WAT": "WAT"}, + } +} + +// Locale returns the current translators string locale +func (ln *ln_CD) Locale() string { + return ln.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ln_CD' +func (ln *ln_CD) PluralsCardinal() []locales.PluralRule { + return ln.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ln_CD' +func (ln *ln_CD) PluralsOrdinal() []locales.PluralRule { + return ln.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ln_CD' +func (ln *ln_CD) PluralsRange() []locales.PluralRule { + return ln.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CD' +func (ln *ln_CD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CD' +func (ln *ln_CD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ln_CD' +func (ln *ln_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ln *ln_CD) MonthAbbreviated(month time.Month) string { + return ln.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ln *ln_CD) MonthsAbbreviated() []string { + return ln.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ln *ln_CD) MonthNarrow(month time.Month) string { + return ln.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ln *ln_CD) MonthsNarrow() []string { + return ln.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ln *ln_CD) MonthWide(month time.Month) string { + return ln.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ln *ln_CD) MonthsWide() []string { + return ln.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ln *ln_CD) WeekdayAbbreviated(weekday time.Weekday) string { + return ln.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ln *ln_CD) WeekdaysAbbreviated() []string { + return ln.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ln *ln_CD) WeekdayNarrow(weekday time.Weekday) string { + return ln.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ln *ln_CD) WeekdaysNarrow() []string { + return ln.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ln *ln_CD) WeekdayShort(weekday time.Weekday) string { + return ln.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ln *ln_CD) WeekdaysShort() []string { + return ln.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ln *ln_CD) WeekdayWide(weekday time.Weekday) string { + return ln.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ln *ln_CD) WeekdaysWide() []string { + return ln.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ln_CD' and handles both Whole and Real numbers based on 'v' +func (ln *ln_CD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ln_CD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ln *ln_CD) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CD' +func (ln *ln_CD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ln.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CD' +// in accounting notation. +func (ln *ln_CD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ln.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ln.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ln.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ln_CD' +func (ln *ln_CD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ln_CD' +func (ln *ln_CD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ln_CD' +func (ln *ln_CD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ln_CD' +func (ln *ln_CD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ln.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ln_CD' +func (ln *ln_CD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ln_CD' +func (ln *ln_CD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ln_CD' +func (ln *ln_CD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ln_CD' +func (ln *ln_CD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ln.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ln_CD/ln_CD_test.go b/vendor/github.com/go-playground/locales/ln_CD/ln_CD_test.go new file mode 100644 index 0000000000..42fc0ca787 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln_CD/ln_CD_test.go @@ -0,0 +1,1120 @@ +package ln_CD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ln_CD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ln_CF/ln_CF.go b/vendor/github.com/go-playground/locales/ln_CF/ln_CF.go new file mode 100644 index 0000000000..dc4e8a7408 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln_CF/ln_CF.go @@ -0,0 +1,551 @@ +package ln_CF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ln_CF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ln_CF' locale +func New() locales.Translator { + return &ln_CF{ + locale: "ln_CF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fbl", "msi", "apl", "mai", "yun", "yul", "agt", "stb", "ɔtb", "nvb", "dsb"}, + monthsNarrow: []string{"", "y", "f", "m", "a", "m", "y", "y", "a", "s", "ɔ", "n", "d"}, + monthsWide: []string{"", "sánzá ya yambo", "sánzá ya míbalé", "sánzá ya mísáto", "sánzá ya mínei", "sánzá ya mítáno", "sánzá ya motóbá", "sánzá ya nsambo", "sánzá ya mwambe", "sánzá ya libwa", "sánzá ya zómi", "sánzá ya zómi na mɔ̌kɔ́", "sánzá ya zómi na míbalé"}, + daysAbbreviated: []string{"eye", "ybo", "mbl", "mst", "min", "mtn", "mps"}, + daysNarrow: []string{"e", "y", "m", "m", "m", "m", "p"}, + daysWide: []string{"eyenga", "mokɔlɔ mwa yambo", "mokɔlɔ mwa míbalé", "mokɔlɔ mwa mísáto", "mokɔlɔ ya mínéi", "mokɔlɔ ya mítáno", "mpɔ́sɔ"}, + periodsAbbreviated: []string{"ntɔ́ngɔ́", "mpókwa"}, + periodsWide: []string{"ntɔ́ngɔ́", "mpókwa"}, + erasAbbreviated: []string{"libóso ya", "nsima ya Y"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Yambo ya Yézu Krís", "Nsima ya Yézu Krís"}, + timezones: map[string]string{"PST": "PST", "ACWST": "ACWST", "WART": "WART", "HENOMX": "HENOMX", "HNEG": "HNEG", "WITA": "WITA", "CHAST": "CHAST", "ACDT": "ACDT", "BT": "BT", "BOT": "BOT", "HAST": "HAST", "IST": "IST", "CLT": "CLT", "MDT": "MDT", "WAT": "WAT", "EAT": "Ntángo ya Afríka ya Ɛ́sita", "CDT": "CDT", "MYT": "MYT", "EDT": "EDT", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "ChST": "ChST", "UYST": "UYST", "SRT": "SRT", "CAT": "Ntángo ya Lubumbashi", "WARST": "WARST", "TMT": "TMT", "HNT": "HNT", "MESZ": "MESZ", "WEZ": "WEZ", "AEST": "AEST", "SAST": "Ntángo ya Afríka ya Sidi", "WIB": "WIB", "AWST": "AWST", "PDT": "PDT", "ACWDT": "ACWDT", "∅∅∅": "∅∅∅", "JDT": "JDT", "MST": "MST", "AKDT": "AKDT", "HADT": "HADT", "OEZ": "OEZ", "WESZ": "WESZ", "ART": "ART", "ARST": "ARST", "HNPMX": "HNPMX", "GYT": "GYT", "GMT": "Ntángo ya Londoni", "COT": "COT", "AKST": "AKST", "HNPM": "HNPM", "HECU": "HECU", "WIT": "WIT", "NZST": "NZST", "VET": "VET", "AEDT": "AEDT", "HNCU": "HNCU", "ECT": "ECT", "MEZ": "MEZ", "JST": "JST", "HAT": "HAT", "LHDT": "LHDT", "SGT": "SGT", "NZDT": "NZDT", "HNOG": "HNOG", "TMST": "TMST", "HKT": "HKT", "HKST": "HKST", "CLST": "CLST", "COST": "COST", "HEPM": "HEPM", "HEPMX": "HEPMX", "CST": "CST", "EST": "EST", "WAST": "WAST", "GFT": "GFT", "UYT": "UYT", "CHADT": "CHADT", "HEOG": "HEOG", "AST": "AST", "ADT": "ADT", "OESZ": "OESZ", "ACST": "ACST", "LHST": "LHST", "AWDT": "AWDT"}, + } +} + +// Locale returns the current translators string locale +func (ln *ln_CF) Locale() string { + return ln.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ln_CF' +func (ln *ln_CF) PluralsCardinal() []locales.PluralRule { + return ln.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ln_CF' +func (ln *ln_CF) PluralsOrdinal() []locales.PluralRule { + return ln.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ln_CF' +func (ln *ln_CF) PluralsRange() []locales.PluralRule { + return ln.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CF' +func (ln *ln_CF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CF' +func (ln *ln_CF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ln_CF' +func (ln *ln_CF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ln *ln_CF) MonthAbbreviated(month time.Month) string { + return ln.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ln *ln_CF) MonthsAbbreviated() []string { + return ln.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ln *ln_CF) MonthNarrow(month time.Month) string { + return ln.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ln *ln_CF) MonthsNarrow() []string { + return ln.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ln *ln_CF) MonthWide(month time.Month) string { + return ln.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ln *ln_CF) MonthsWide() []string { + return ln.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ln *ln_CF) WeekdayAbbreviated(weekday time.Weekday) string { + return ln.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ln *ln_CF) WeekdaysAbbreviated() []string { + return ln.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ln *ln_CF) WeekdayNarrow(weekday time.Weekday) string { + return ln.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ln *ln_CF) WeekdaysNarrow() []string { + return ln.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ln *ln_CF) WeekdayShort(weekday time.Weekday) string { + return ln.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ln *ln_CF) WeekdaysShort() []string { + return ln.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ln *ln_CF) WeekdayWide(weekday time.Weekday) string { + return ln.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ln *ln_CF) WeekdaysWide() []string { + return ln.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ln_CF' and handles both Whole and Real numbers based on 'v' +func (ln *ln_CF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ln_CF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ln *ln_CF) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CF' +func (ln *ln_CF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ln.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CF' +// in accounting notation. +func (ln *ln_CF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ln.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ln.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ln.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ln_CF' +func (ln *ln_CF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ln_CF' +func (ln *ln_CF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ln_CF' +func (ln *ln_CF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ln_CF' +func (ln *ln_CF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ln.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ln_CF' +func (ln *ln_CF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ln_CF' +func (ln *ln_CF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ln_CF' +func (ln *ln_CF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ln_CF' +func (ln *ln_CF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ln.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ln_CF/ln_CF_test.go b/vendor/github.com/go-playground/locales/ln_CF/ln_CF_test.go new file mode 100644 index 0000000000..ffedd862d0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln_CF/ln_CF_test.go @@ -0,0 +1,1120 @@ +package ln_CF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ln_CF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ln_CG/ln_CG.go b/vendor/github.com/go-playground/locales/ln_CG/ln_CG.go new file mode 100644 index 0000000000..6dacbbd698 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln_CG/ln_CG.go @@ -0,0 +1,551 @@ +package ln_CG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ln_CG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ln_CG' locale +func New() locales.Translator { + return &ln_CG{ + locale: "ln_CG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fbl", "msi", "apl", "mai", "yun", "yul", "agt", "stb", "ɔtb", "nvb", "dsb"}, + monthsNarrow: []string{"", "y", "f", "m", "a", "m", "y", "y", "a", "s", "ɔ", "n", "d"}, + monthsWide: []string{"", "sánzá ya yambo", "sánzá ya míbalé", "sánzá ya mísáto", "sánzá ya mínei", "sánzá ya mítáno", "sánzá ya motóbá", "sánzá ya nsambo", "sánzá ya mwambe", "sánzá ya libwa", "sánzá ya zómi", "sánzá ya zómi na mɔ̌kɔ́", "sánzá ya zómi na míbalé"}, + daysAbbreviated: []string{"eye", "ybo", "mbl", "mst", "min", "mtn", "mps"}, + daysNarrow: []string{"e", "y", "m", "m", "m", "m", "p"}, + daysWide: []string{"eyenga", "mokɔlɔ mwa yambo", "mokɔlɔ mwa míbalé", "mokɔlɔ mwa mísáto", "mokɔlɔ ya mínéi", "mokɔlɔ ya mítáno", "mpɔ́sɔ"}, + periodsAbbreviated: []string{"ntɔ́ngɔ́", "mpókwa"}, + periodsWide: []string{"ntɔ́ngɔ́", "mpókwa"}, + erasAbbreviated: []string{"libóso ya", "nsima ya Y"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Yambo ya Yézu Krís", "Nsima ya Yézu Krís"}, + timezones: map[string]string{"AEST": "AEST", "IST": "IST", "MESZ": "MESZ", "WITA": "WITA", "CHAST": "CHAST", "MEZ": "MEZ", "ARST": "ARST", "BOT": "BOT", "PST": "PST", "WART": "WART", "HEOG": "HEOG", "TMT": "TMT", "COST": "COST", "HNPM": "HNPM", "AWDT": "AWDT", "CHADT": "CHADT", "HADT": "HADT", "CAT": "Ntángo ya Lubumbashi", "MYT": "MYT", "ACST": "ACST", "HEEG": "HEEG", "SRT": "SRT", "HNCU": "HNCU", "GMT": "Ntángo ya Londoni", "CLST": "CLST", "TMST": "TMST", "HKST": "HKST", "ACDT": "ACDT", "HEPMX": "HEPMX", "CDT": "CDT", "ACWST": "ACWST", "BT": "BT", "∅∅∅": "∅∅∅", "ACWDT": "ACWDT", "CLT": "CLT", "WESZ": "WESZ", "AKDT": "AKDT", "JST": "JST", "OEZ": "OEZ", "HKT": "HKT", "HNEG": "HNEG", "ChST": "ChST", "UYT": "UYT", "CST": "CST", "AWST": "AWST", "PDT": "PDT", "ART": "ART", "WAST": "WAST", "AEDT": "AEDT", "LHST": "LHST", "GYT": "GYT", "NZDT": "NZDT", "HENOMX": "HENOMX", "HAT": "HAT", "HNT": "HNT", "GFT": "GFT", "AKST": "AKST", "HEPM": "HEPM", "WIT": "WIT", "JDT": "JDT", "WARST": "WARST", "ADT": "ADT", "SGT": "SGT", "HAST": "HAST", "EST": "EST", "EDT": "EDT", "HNNOMX": "HNNOMX", "MST": "MST", "SAST": "Ntángo ya Afríka ya Sidi", "ECT": "ECT", "OESZ": "OESZ", "LHDT": "LHDT", "EAT": "Ntángo ya Afríka ya Ɛ́sita", "WIB": "WIB", "UYST": "UYST", "COT": "COT", "WEZ": "WEZ", "MDT": "MDT", "HNPMX": "HNPMX", "HECU": "HECU", "NZST": "NZST", "VET": "VET", "HNOG": "HNOG", "AST": "AST", "WAT": "WAT"}, + } +} + +// Locale returns the current translators string locale +func (ln *ln_CG) Locale() string { + return ln.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ln_CG' +func (ln *ln_CG) PluralsCardinal() []locales.PluralRule { + return ln.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ln_CG' +func (ln *ln_CG) PluralsOrdinal() []locales.PluralRule { + return ln.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ln_CG' +func (ln *ln_CG) PluralsRange() []locales.PluralRule { + return ln.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CG' +func (ln *ln_CG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ln_CG' +func (ln *ln_CG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ln_CG' +func (ln *ln_CG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ln *ln_CG) MonthAbbreviated(month time.Month) string { + return ln.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ln *ln_CG) MonthsAbbreviated() []string { + return ln.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ln *ln_CG) MonthNarrow(month time.Month) string { + return ln.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ln *ln_CG) MonthsNarrow() []string { + return ln.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ln *ln_CG) MonthWide(month time.Month) string { + return ln.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ln *ln_CG) MonthsWide() []string { + return ln.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ln *ln_CG) WeekdayAbbreviated(weekday time.Weekday) string { + return ln.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ln *ln_CG) WeekdaysAbbreviated() []string { + return ln.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ln *ln_CG) WeekdayNarrow(weekday time.Weekday) string { + return ln.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ln *ln_CG) WeekdaysNarrow() []string { + return ln.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ln *ln_CG) WeekdayShort(weekday time.Weekday) string { + return ln.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ln *ln_CG) WeekdaysShort() []string { + return ln.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ln *ln_CG) WeekdayWide(weekday time.Weekday) string { + return ln.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ln *ln_CG) WeekdaysWide() []string { + return ln.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ln_CG' and handles both Whole and Real numbers based on 'v' +func (ln *ln_CG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ln_CG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ln *ln_CG) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CG' +func (ln *ln_CG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ln.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ln.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ln_CG' +// in accounting notation. +func (ln *ln_CG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ln.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ln.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ln.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ln.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ln.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ln.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ln.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ln_CG' +func (ln *ln_CG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ln_CG' +func (ln *ln_CG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ln_CG' +func (ln *ln_CG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ln_CG' +func (ln *ln_CG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ln.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ln.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ln_CG' +func (ln *ln_CG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ln_CG' +func (ln *ln_CG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ln_CG' +func (ln *ln_CG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ln_CG' +func (ln *ln_CG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ln.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ln.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ln.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ln_CG/ln_CG_test.go b/vendor/github.com/go-playground/locales/ln_CG/ln_CG_test.go new file mode 100644 index 0000000000..b47cafc381 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ln_CG/ln_CG_test.go @@ -0,0 +1,1120 @@ +package ln_CG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ln_CG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lo/lo.go b/vendor/github.com/go-playground/locales/lo/lo.go new file mode 100644 index 0000000000..f890ce4d5f --- /dev/null +++ b/vendor/github.com/go-playground/locales/lo/lo.go @@ -0,0 +1,524 @@ +package lo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lo' locale +func New() locales.Translator { + return &lo{ + locale: "lo", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "₭", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "-", + monthsAbbreviated: []string{"", "ມ.ກ.", "ກ.ພ.", "ມ.ນ.", "ມ.ສ.", "ພ.ພ.", "ມິ.ຖ.", "ກ.ລ.", "ສ.ຫ.", "ກ.ຍ.", "ຕ.ລ.", "ພ.ຈ.", "ທ.ວ."}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "ມັງກອນ", "ກຸມພາ", "ມີນາ", "ເມສາ", "ພຶດສະພາ", "ມິຖຸນາ", "ກໍລະກົດ", "ສິງຫາ", "ກັນຍາ", "ຕຸລາ", "ພະຈິກ", "ທັນວາ"}, + daysAbbreviated: []string{"ອາທິດ", "ຈັນ", "ອັງຄານ", "ພຸດ", "ພະຫັດ", "ສຸກ", "ເສົາ"}, + daysNarrow: []string{"ອາ", "ຈ", "ອ", "ພ", "ພຫ", "ສຸ", "ສ"}, + daysShort: []string{"ອາ.", "ຈ.", "ອ.", "ພ.", "ພຫ.", "ສຸ.", "ສ."}, + daysWide: []string{"ວັນອາທິດ", "ວັນຈັນ", "ວັນອັງຄານ", "ວັນພຸດ", "ວັນພະຫັດ", "ວັນສຸກ", "ວັນເສົາ"}, + periodsAbbreviated: []string{"ກ່ອນທ່ຽງ", "ຫຼັງທ່ຽງ"}, + periodsNarrow: []string{"ກທ", "ຫຼທ"}, + periodsWide: []string{"ກ່ອນທ່ຽງ", "ຫຼັງທ່ຽງ"}, + erasAbbreviated: []string{"ກ່ອນ ຄ.ສ.", "ຄ.ສ."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ກ່ອນຄຣິດສັກກະລາດ", "ຄຣິດສັກກະລາດ"}, + timezones: map[string]string{"EST": "ເວລາມາດຕະຖານຕາເວັນອອກ", "HNT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bນິວ\u200bຟາວ\u200bແລນ", "GFT": "ເວ\u200bລາ\u200bເຟ\u200bຣນ\u200bຊ໌\u200bເກຍ\u200bນາ", "WITA": "ເວ\u200bລາ\u200bອິນ\u200bໂດ\u200bເນ\u200bເຊຍ\u200bກາງ", "SGT": "ເວ\u200bລາ\u200bສິງ\u200bກະ\u200bໂປ", "AST": "ເວລາມາດຕະຖານຂອງອາແລນຕິກ", "HNNOMX": "\u200bເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານນອດ\u200bເວ\u200bສ\u200bເມັກ\u200bຊິ\u200bໂກ", "HENOMX": "ເວລາກາງເວັນເມັກຊິກັນນອດເວສ", "EAT": "ເວ\u200bລາ\u200bອາ\u200bຟຣິ\u200bກາ\u200bຕາ\u200bເວັນ\u200bອອກ", "MST": "ເວລາມາດຕະຖານມາເກົາ", "HAT": "ເວລາກາງເວັນນິວຟາວແລນ", "UYST": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bອູ\u200bຣູ\u200bກວຍ", "GYT": "ເວລາກາຍອານາ", "WIT": "ເວ\u200bລາ\u200bອິນ\u200bໂດ\u200bເນ\u200bເຊຍ\u200bຕາ\u200bເວັນ\u200bອອກ", "∅∅∅": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນອາ\u200bເມ\u200bຊອນ", "CAT": "ເວ\u200bລາ\u200bອາ\u200bຟຣິ\u200bກາ\u200bກາງ", "HEOG": "ເວລາຕອນທ່ຽງກຣີນແລນຕາເວັນຕົກ", "WAST": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bອາ\u200bຟຣິ\u200bກາ\u200bຕາ\u200bເວັນ\u200bຕົກ", "BT": "ເວ\u200bລາ\u200bພູ\u200bຖານ", "UYT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bອູ\u200bຣູ\u200bກວຍ", "HADT": "ເວລາຕອນທ່ຽງຮາວາຍ-ເອລູທຽນ", "VET": "ເວ\u200bລາ\u200bເວ\u200bເນ\u200bຊູ\u200bເອ\u200bລາ", "WARST": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນເວ\u200bສ\u200bເທິນອາ\u200bເຈນ\u200bທິ\u200bນາ", "CLST": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນຊິ\u200bລີ", "AEST": "ເວ\u200bລາ\u200bມາດຕະຖານ\u200b\u200b\u200bອອສ\u200bເຕຣ\u200bລຽນ\u200bຕາ\u200bເວັນ\u200bອອກ", "HECU": "ເວລາກາງເວັນຄິວບາ", "CST": "ເວລາມາດຕະຖານກາງ", "CDT": "ເວລາກາງເວັນກາງ", "HAST": "ເວລາມາດຕະຖານຮາວາຍ-ເອລູທຽນ", "MESZ": "\u200bເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bຢູ\u200bໂຣບ\u200bກາງ", "HEEG": "ເວລາລະດູຮ້ອນກຣີນແລນຕາເວັນອອກ", "AEDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bອອສ\u200bເຕຣ\u200bລຽນ\u200bຕາ\u200bເວັນ\u200bອອກ", "JST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bຍີ່\u200bປຸ່ນ", "MYT": "ເວ\u200bລາ\u200bມາ\u200bເລ\u200bເຊຍ", "ACDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bອອສ\u200bເຕຣ\u200bເລຍ\u200bກາງ", "AKDT": "ເວລາກາງເວັນອະແລສກາ", "CHAST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bຊາ\u200bທາມ", "ECT": "ເວ\u200bລາ\u200bເອ\u200bກົວ\u200bດໍ", "PDT": "ເວລາກາງເວັນແປຊິຟິກ", "ACWST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານອອສ\u200bເຕຣ\u200bລຽນ\u200bກາງ\u200bຕາ\u200bເວັນ\u200bຕົກ", "ACWDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bອອສ\u200bເຕຣ\u200bລຽນ\u200bກາງ\u200bຕາ\u200bເວັນ\u200bຕົກ", "MEZ": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bຢູ\u200bໂຣບກາງ", "GMT": "ເວ\u200bລາກຣີນ\u200bວິ\u200bຊ", "HNOG": "ເວລາມາດຕະຖານກຣີນແລນຕາເວັນຕົກ", "TMST": "ເວລາລະດູຮ້ອນຕວກເມນິສຖານ", "MDT": "ເວລາລະດູຮ້ອນມາເກົາ", "COST": "ເວລາລະດູຮ້ອນໂຄລໍາເບຍ", "SAST": "ເວ\u200bລາ\u200bອາ\u200bຟຣິ\u200bກາ\u200bໃຕ້", "JDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bຍີ່\u200bປຸ່ນ", "OESZ": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນຢູ\u200bໂຣບ\u200bຕາ\u200bເວັນ\u200bອອກ", "ART": "\u200bເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານອາ\u200bເຈນ\u200bທິ\u200bນາ", "NZST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານນິວ\u200bຊີ\u200bແລນ", "ARST": "\u200bເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bອາ\u200bເຈນ\u200bທິ\u200bນາ", "HKST": "\u200bເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bຮອງ\u200bກົງ", "HEPM": "\u200bເວ\u200bລາຕອນ\u200bທ່ຽງເຊນ\u200bປີ\u200bແອ ແລະ\u200bມິ\u200bກົວ\u200bລອນ", "SRT": "ເວ\u200bລາ\u200bຊຸ\u200bຣິ\u200bນາມ", "LHDT": "\u200bເວ\u200bລ\u200bສາ\u200bຕອນ\u200b\u200bທ່ຽງ\u200bລອດ\u200bເຮົາ\u200b", "WIB": "ເວ\u200bລາ\u200bອິນ\u200bໂດ\u200bເນ\u200bເຊຍ\u200bຕາ\u200bເວັນ\u200bຕົກ", "CHADT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bຊາ\u200bທາມ", "WAT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bອາ\u200bຟຣິ\u200bກາ\u200bຕາ\u200bເວັນ\u200bຕົກ", "EDT": "ເວລາກາງເວັນຕາເວັນອອກ", "HKT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bຮອງ\u200bກົງ", "HNEG": "ເວລາມາດຕະຖານຕາເວັນອອກກຣີນແລນ", "AKST": "ເວລາມາດຕະຖານອະແລສກາ", "HNPM": "\u200bເວ\u200bລາມາດ\u200bຕະ\u200bຖານເຊນ\u200bປີ\u200bແອ ແລະ\u200bມິ\u200bກົວ\u200bລອນ", "HNPMX": "ເວລາມາດຕະຖານແປຊິຟິກເມັກຊິກັນ", "BOT": "ເວ\u200bລາ\u200bໂບ\u200bລິ\u200bເວຍ", "WART": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານເວ\u200bສ\u200bເທິນອາ\u200bເຈນ\u200bທິ\u200bນາ", "OEZ": "ເວ\u200bລາ\u200bມາ\u200bດ\u200bຕະ\u200bຖານ\u200bຢູ\u200bໂຣບ\u200bຕາ\u200bເວັນ\u200bອອກ", "WESZ": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນຢູ\u200bໂຣບ\u200bຕາ\u200bເວັນ\u200bຕົກ", "COT": "ເວລາມາດຕະຖານໂຄລຳເບຍ", "HNCU": "ເວລາມາດຕະຖານຂອງຄິວບາ", "PST": "ເວລາມາດຕະຖານແປຊິຟິກ", "NZDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bນິວ\u200bຊີ\u200bແລນ", "IST": "ເວລາ ອິນເດຍ", "ADT": "ເວລາກາງເວັນຂອງອາແລນຕິກ", "WEZ": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານຢູ\u200bໂຣບ\u200bຕາ\u200bເວັນ\u200bຕົກ", "TMT": "ເວລາມາດຕະຖານຕວກເມນິສຖານ", "ACST": "ເວ\u200bລາມາດ\u200bຕະ\u200bຖານອອ\u200bສ\u200bເຕຣ\u200bເລຍ\u200bກ\u200bາງ", "LHST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bລອດ\u200bເຮົາ", "HEPMX": "ເວລາກາງເວັນແປຊິຟິກເມັກຊິກັນ", "CLT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານຊິ\u200bລີ", "ChST": "ເວ\u200bລາ\u200bຈາ\u200bໂມ\u200bໂຣ", "AWST": "ເວ\u200bລາ\u200bມາ\u200bດ\u200bຕະ\u200bຖານອອສ\u200bເຕຣ\u200bລຽນ\u200bຕາ\u200bເວັນ\u200bຕົກ", "AWDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bອອສ\u200bເຕຣ\u200bລຽນ\u200bຕາ\u200bເວັນ\u200bຕົກ"}, + } +} + +// Locale returns the current translators string locale +func (lo *lo) Locale() string { + return lo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lo' +func (lo *lo) PluralsCardinal() []locales.PluralRule { + return lo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lo' +func (lo *lo) PluralsOrdinal() []locales.PluralRule { + return lo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lo' +func (lo *lo) PluralsRange() []locales.PluralRule { + return lo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lo' +func (lo *lo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lo' +func (lo *lo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lo' +func (lo *lo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lo *lo) MonthAbbreviated(month time.Month) string { + return lo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lo *lo) MonthsAbbreviated() []string { + return lo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lo *lo) MonthNarrow(month time.Month) string { + return lo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lo *lo) MonthsNarrow() []string { + return lo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lo *lo) MonthWide(month time.Month) string { + return lo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lo *lo) MonthsWide() []string { + return lo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lo *lo) WeekdayAbbreviated(weekday time.Weekday) string { + return lo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lo *lo) WeekdaysAbbreviated() []string { + return lo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lo *lo) WeekdayNarrow(weekday time.Weekday) string { + return lo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lo *lo) WeekdaysNarrow() []string { + return lo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lo *lo) WeekdayShort(weekday time.Weekday) string { + return lo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lo *lo) WeekdaysShort() []string { + return lo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lo *lo) WeekdayWide(weekday time.Weekday) string { + return lo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lo *lo) WeekdaysWide() []string { + return lo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lo' and handles both Whole and Real numbers based on 'v' +func (lo *lo) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lo *lo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lo' +func (lo *lo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lo.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, lo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lo' +// in accounting notation. +func (lo *lo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lo.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, lo.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lo' +func (lo *lo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lo' +func (lo *lo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lo' +func (lo *lo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lo' +func (lo *lo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, lo.erasWide[0]...) + } else { + b = append(b, lo.erasWide[1]...) + } + + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lo' +func (lo *lo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lo' +func (lo *lo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lo' +func (lo *lo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0xe0, 0xbb, 0x82, 0xe0, 0xba, 0xa1, 0xe0, 0xba, 0x87, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0xe0, 0xba, 0x99, 0xe0, 0xba, 0xb2, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0xe0, 0xba, 0xa7, 0xe0, 0xba, 0xb4, 0xe0, 0xba, 0x99, 0xe0, 0xba, 0xb2, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lo' +func (lo *lo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0xe0, 0xbb, 0x82, 0xe0, 0xba, 0xa1, 0xe0, 0xba, 0x87, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0xe0, 0xba, 0x99, 0xe0, 0xba, 0xb2, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0xe0, 0xba, 0xa7, 0xe0, 0xba, 0xb4, 0xe0, 0xba, 0x99, 0xe0, 0xba, 0xb2, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lo/lo_test.go b/vendor/github.com/go-playground/locales/lo/lo_test.go new file mode 100644 index 0000000000..d7e51fae33 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lo/lo_test.go @@ -0,0 +1,1120 @@ +package lo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lo_LA/lo_LA.go b/vendor/github.com/go-playground/locales/lo_LA/lo_LA.go new file mode 100644 index 0000000000..33150b1d15 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lo_LA/lo_LA.go @@ -0,0 +1,524 @@ +package lo_LA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lo_LA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lo_LA' locale +func New() locales.Translator { + return &lo_LA{ + locale: "lo_LA", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "-", + monthsAbbreviated: []string{"", "ມ.ກ.", "ກ.ພ.", "ມ.ນ.", "ມ.ສ.", "ພ.ພ.", "ມິ.ຖ.", "ກ.ລ.", "ສ.ຫ.", "ກ.ຍ.", "ຕ.ລ.", "ພ.ຈ.", "ທ.ວ."}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "ມັງກອນ", "ກຸມພາ", "ມີນາ", "ເມສາ", "ພຶດສະພາ", "ມິຖຸນາ", "ກໍລະກົດ", "ສິງຫາ", "ກັນຍາ", "ຕຸລາ", "ພະຈິກ", "ທັນວາ"}, + daysAbbreviated: []string{"ອາທິດ", "ຈັນ", "ອັງຄານ", "ພຸດ", "ພະຫັດ", "ສຸກ", "ເສົາ"}, + daysNarrow: []string{"ອາ", "ຈ", "ອ", "ພ", "ພຫ", "ສຸ", "ສ"}, + daysShort: []string{"ອາ.", "ຈ.", "ອ.", "ພ.", "ພຫ.", "ສຸ.", "ສ."}, + daysWide: []string{"ວັນອາທິດ", "ວັນຈັນ", "ວັນອັງຄານ", "ວັນພຸດ", "ວັນພະຫັດ", "ວັນສຸກ", "ວັນເສົາ"}, + periodsAbbreviated: []string{"ກ່ອນທ່ຽງ", "ຫຼັງທ່ຽງ"}, + periodsNarrow: []string{"ກທ", "ຫຼທ"}, + periodsWide: []string{"ກ່ອນທ່ຽງ", "ຫຼັງທ່ຽງ"}, + erasAbbreviated: []string{"ກ່ອນ ຄ.ສ.", "ຄ.ສ."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ກ່ອນຄຣິດສັກກະລາດ", "ຄຣິດສັກກະລາດ"}, + timezones: map[string]string{"HKT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bຮອງ\u200bກົງ", "WIT": "ເວ\u200bລາ\u200bອິນ\u200bໂດ\u200bເນ\u200bເຊຍ\u200bຕາ\u200bເວັນ\u200bອອກ", "WESZ": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນຢູ\u200bໂຣບ\u200bຕາ\u200bເວັນ\u200bຕົກ", "AKDT": "ເວລາກາງເວັນອະແລສກາ", "AWDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bອອສ\u200bເຕຣ\u200bລຽນ\u200bຕາ\u200bເວັນ\u200bຕົກ", "CHADT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bຊາ\u200bທາມ", "ACWST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານອອສ\u200bເຕຣ\u200bລຽນ\u200bກາງ\u200bຕາ\u200bເວັນ\u200bຕົກ", "JST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bຍີ່\u200bປຸ່ນ", "WARST": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນເວ\u200bສ\u200bເທິນອາ\u200bເຈນ\u200bທິ\u200bນາ", "OESZ": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນຢູ\u200bໂຣບ\u200bຕາ\u200bເວັນ\u200bອອກ", "ACDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bອອສ\u200bເຕຣ\u200bເລຍ\u200bກາງ", "HNT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bນິວ\u200bຟາວ\u200bແລນ", "WIB": "ເວ\u200bລາ\u200bອິນ\u200bໂດ\u200bເນ\u200bເຊຍ\u200bຕາ\u200bເວັນ\u200bຕົກ", "CST": "ເວລາມາດຕະຖານກາງ", "SRT": "ເວ\u200bລາ\u200bຊຸ\u200bຣິ\u200bນາມ", "HEPM": "\u200bເວ\u200bລາຕອນ\u200bທ່ຽງເຊນ\u200bປີ\u200bແອ ແລະ\u200bມິ\u200bກົວ\u200bລອນ", "SAST": "ເວ\u200bລາ\u200bອາ\u200bຟຣິ\u200bກາ\u200bໃຕ້", "EAT": "ເວ\u200bລາ\u200bອາ\u200bຟຣິ\u200bກາ\u200bຕາ\u200bເວັນ\u200bອອກ", "HNCU": "ເວລາມາດຕະຖານຂອງຄິວບາ", "ART": "\u200bເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານອາ\u200bເຈນ\u200bທິ\u200bນາ", "CAT": "ເວ\u200bລາ\u200bອາ\u200bຟຣິ\u200bກາ\u200bກາງ", "CLT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານຊິ\u200bລີ", "WAT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bອາ\u200bຟຣິ\u200bກາ\u200bຕາ\u200bເວັນ\u200bຕົກ", "WITA": "ເວ\u200bລາ\u200bອິນ\u200bໂດ\u200bເນ\u200bເຊຍ\u200bກາງ", "LHST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bລອດ\u200bເຮົາ", "SGT": "ເວ\u200bລາ\u200bສິງ\u200bກະ\u200bໂປ", "MDT": "ເວລາລະດູຮ້ອນມາເກົາ", "TMT": "ເວລາມາດຕະຖານຕວກເມນິສຖານ", "LHDT": "\u200bເວ\u200bລ\u200bສາ\u200bຕອນ\u200b\u200bທ່ຽງ\u200bລອດ\u200bເຮົາ\u200b", "PST": "ເວລາມາດຕະຖານແປຊິຟິກ", "MESZ": "\u200bເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bຢູ\u200bໂຣບ\u200bກາງ", "HEOG": "ເວລາຕອນທ່ຽງກຣີນແລນຕາເວັນຕົກ", "COT": "ເວລາມາດຕະຖານໂຄລຳເບຍ", "AKST": "ເວລາມາດຕະຖານອະແລສກາ", "ChST": "ເວ\u200bລາ\u200bຈາ\u200bໂມ\u200bໂຣ", "PDT": "ເວລາກາງເວັນແປຊິຟິກ", "MYT": "ເວ\u200bລາ\u200bມາ\u200bເລ\u200bເຊຍ", "EST": "ເວລາມາດຕະຖານຕາເວັນອອກ", "HECU": "ເວລາກາງເວັນຄິວບາ", "CLST": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນຊິ\u200bລີ", "EDT": "ເວລາກາງເວັນຕາເວັນອອກ", "HNNOMX": "\u200bເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານນອດ\u200bເວ\u200bສ\u200bເມັກ\u200bຊິ\u200bໂກ", "GYT": "ເວລາກາຍອານາ", "NZST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານນິວ\u200bຊີ\u200bແລນ", "JDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bຍີ່\u200bປຸ່ນ", "ADT": "ເວລາກາງເວັນຂອງອາແລນຕິກ", "ARST": "\u200bເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bອາ\u200bເຈນ\u200bທິ\u200bນາ", "ACST": "ເວ\u200bລາມາດ\u200bຕະ\u200bຖານອອ\u200bສ\u200bເຕຣ\u200bເລຍ\u200bກ\u200bາງ", "HNEG": "ເວລາມາດຕະຖານຕາເວັນອອກກຣີນແລນ", "HEEG": "ເວລາລະດູຮ້ອນກຣີນແລນຕາເວັນອອກ", "CDT": "ເວລາກາງເວັນກາງ", "BOT": "ເວ\u200bລາ\u200bໂບ\u200bລິ\u200bເວຍ", "UYST": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bອູ\u200bຣູ\u200bກວຍ", "HNPMX": "ເວລາມາດຕະຖານແປຊິຟິກເມັກຊິກັນ", "WART": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານເວ\u200bສ\u200bເທິນອາ\u200bເຈນ\u200bທິ\u200bນາ", "AST": "ເວລາມາດຕະຖານຂອງອາແລນຕິກ", "AEST": "ເວ\u200bລາ\u200bມາດຕະຖານ\u200b\u200b\u200bອອສ\u200bເຕຣ\u200bລຽນ\u200bຕາ\u200bເວັນ\u200bອອກ", "GFT": "ເວ\u200bລາ\u200bເຟ\u200bຣນ\u200bຊ໌\u200bເກຍ\u200bນາ", "CHAST": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bຊາ\u200bທາມ", "NZDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bນິວ\u200bຊີ\u200bແລນ", "IST": "ເວລາ ອິນເດຍ", "HAST": "ເວລາມາດຕະຖານຮາວາຍ-ເອລູທຽນ", "ECT": "ເວ\u200bລາ\u200bເອ\u200bກົວ\u200bດໍ", "TMST": "ເວລາລະດູຮ້ອນຕວກເມນິສຖານ", "MST": "ເວລາມາດຕະຖານມາເກົາ", "HKST": "\u200bເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bຮອງ\u200bກົງ", "WAST": "ເວ\u200bລາ\u200bລະ\u200bດູ\u200bຮ້ອນ\u200bອາ\u200bຟຣິ\u200bກາ\u200bຕາ\u200bເວັນ\u200bຕົກ", "COST": "ເວລາລະດູຮ້ອນໂຄລໍາເບຍ", "BT": "ເວ\u200bລາ\u200bພູ\u200bຖານ", "AWST": "ເວ\u200bລາ\u200bມາ\u200bດ\u200bຕະ\u200bຖານອອສ\u200bເຕຣ\u200bລຽນ\u200bຕາ\u200bເວັນ\u200bຕົກ", "HADT": "ເວລາຕອນທ່ຽງຮາວາຍ-ເອລູທຽນ", "UYT": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bອູ\u200bຣູ\u200bກວຍ", "HNOG": "ເວລາມາດຕະຖານກຣີນແລນຕາເວັນຕົກ", "OEZ": "ເວ\u200bລາ\u200bມາ\u200bດ\u200bຕະ\u200bຖານ\u200bຢູ\u200bໂຣບ\u200bຕາ\u200bເວັນ\u200bອອກ", "HAT": "ເວລາກາງເວັນນິວຟາວແລນ", "AEDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bອອສ\u200bເຕຣ\u200bລຽນ\u200bຕາ\u200bເວັນ\u200bອອກ", "HNPM": "\u200bເວ\u200bລາມາດ\u200bຕະ\u200bຖານເຊນ\u200bປີ\u200bແອ ແລະ\u200bມິ\u200bກົວ\u200bລອນ", "∅∅∅": "ເວລາຕາມເຂດລະດູຮ້ອນຕາມເຂດບຣາຊີເລຍ", "GMT": "ເວ\u200bລາກຣີນ\u200bວິ\u200bຊ", "VET": "ເວ\u200bລາ\u200bເວ\u200bເນ\u200bຊູ\u200bເອ\u200bລາ", "WEZ": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານຢູ\u200bໂຣບ\u200bຕາ\u200bເວັນ\u200bຕົກ", "HENOMX": "ເວລາກາງເວັນເມັກຊິກັນນອດເວສ", "HEPMX": "ເວລາກາງເວັນແປຊິຟິກເມັກຊິກັນ", "ACWDT": "ເວ\u200bລາ\u200bຕອນ\u200bທ່ຽງ\u200bອອສ\u200bເຕຣ\u200bລຽນ\u200bກາງ\u200bຕາ\u200bເວັນ\u200bຕົກ", "MEZ": "ເວ\u200bລາ\u200bມາດ\u200bຕະ\u200bຖານ\u200bຢູ\u200bໂຣບກາງ"}, + } +} + +// Locale returns the current translators string locale +func (lo *lo_LA) Locale() string { + return lo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lo_LA' +func (lo *lo_LA) PluralsCardinal() []locales.PluralRule { + return lo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lo_LA' +func (lo *lo_LA) PluralsOrdinal() []locales.PluralRule { + return lo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lo_LA' +func (lo *lo_LA) PluralsRange() []locales.PluralRule { + return lo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lo_LA' +func (lo *lo_LA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lo_LA' +func (lo *lo_LA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lo_LA' +func (lo *lo_LA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lo *lo_LA) MonthAbbreviated(month time.Month) string { + return lo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lo *lo_LA) MonthsAbbreviated() []string { + return lo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lo *lo_LA) MonthNarrow(month time.Month) string { + return lo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lo *lo_LA) MonthsNarrow() []string { + return lo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lo *lo_LA) MonthWide(month time.Month) string { + return lo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lo *lo_LA) MonthsWide() []string { + return lo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lo *lo_LA) WeekdayAbbreviated(weekday time.Weekday) string { + return lo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lo *lo_LA) WeekdaysAbbreviated() []string { + return lo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lo *lo_LA) WeekdayNarrow(weekday time.Weekday) string { + return lo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lo *lo_LA) WeekdaysNarrow() []string { + return lo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lo *lo_LA) WeekdayShort(weekday time.Weekday) string { + return lo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lo *lo_LA) WeekdaysShort() []string { + return lo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lo *lo_LA) WeekdayWide(weekday time.Weekday) string { + return lo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lo *lo_LA) WeekdaysWide() []string { + return lo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lo_LA' and handles both Whole and Real numbers based on 'v' +func (lo *lo_LA) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lo_LA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lo *lo_LA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lo_LA' +func (lo *lo_LA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lo.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, lo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lo_LA' +// in accounting notation. +func (lo *lo_LA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lo.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, lo.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lo_LA' +func (lo *lo_LA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lo_LA' +func (lo *lo_LA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lo_LA' +func (lo *lo_LA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lo_LA' +func (lo *lo_LA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, lo.erasWide[0]...) + } else { + b = append(b, lo.erasWide[1]...) + } + + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lo_LA' +func (lo *lo_LA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lo_LA' +func (lo *lo_LA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lo_LA' +func (lo *lo_LA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0xe0, 0xbb, 0x82, 0xe0, 0xba, 0xa1, 0xe0, 0xba, 0x87, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0xe0, 0xba, 0x99, 0xe0, 0xba, 0xb2, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0xe0, 0xba, 0xa7, 0xe0, 0xba, 0xb4, 0xe0, 0xba, 0x99, 0xe0, 0xba, 0xb2, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lo_LA' +func (lo *lo_LA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0xe0, 0xbb, 0x82, 0xe0, 0xba, 0xa1, 0xe0, 0xba, 0x87, 0x20}...) + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0xe0, 0xba, 0x99, 0xe0, 0xba, 0xb2, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0xe0, 0xba, 0xa7, 0xe0, 0xba, 0xb4, 0xe0, 0xba, 0x99, 0xe0, 0xba, 0xb2, 0xe0, 0xba, 0x97, 0xe0, 0xba, 0xb5, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lo_LA/lo_LA_test.go b/vendor/github.com/go-playground/locales/lo_LA/lo_LA_test.go new file mode 100644 index 0000000000..7ed0e7fe7d --- /dev/null +++ b/vendor/github.com/go-playground/locales/lo_LA/lo_LA_test.go @@ -0,0 +1,1120 @@ +package lo_LA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lo_LA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/logo.png b/vendor/github.com/go-playground/locales/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..3038276e6873076ecd542099e95b25037b1c0c34 GIT binary patch literal 37360 zcmV(-K-|BHP)ysx*JK zMpBX=dbK}5gAy}y3R{{beYQe$t~_(EI9HY=983!yQ4BbH2t9fee6m7kr7b^x7%_4X zJ9`gfp(=T?K~s?>F>nbtbqz;?9&D*HLWLAVf)p1<2qIzzh`mlUaSo2aQfQ+xioj4u zi57RSK09+4J$n}=VG1>K6C+;`IdT#dKnQiRIYfOMa;!RRrZpi|42HT(K7kH5Z51D0 z2RV8bBU%zznI$e~3~;G9N{kpKWf73XRDQWdPL3KgZV)nR5J7tvJAVu-VG5JQScJDo zR+bL!Ta3IbT6ncoYNbC?j4!6pWoxTBl*n#=wPJ6nPG_V?T&y%kcr-zED1W(DRHZFT zhB7~qA6u3+V3JBCZ4gs{L}jKoF=`!luS|!&X@DUWZdUYba2WIU7L}XOvil!bU7wAXuO|PIN?OtwU_FF?ptGuGegAxjs8(G9yYG zg|%{%%2R#1JvUt~pwDwIP%5I+ft0_2vEYw`$yQ3QA)Db+A{7b_0054wNkl}YE}wrc9DS+rDCwcq-kLn z6*rr9Gievg)&9W#+|En4X(tdH=fj-$InQ~{3w3k;I<^V903k*-k%?L`+gy zD<80`%CcVCt7&b)>-AWo}M*k4L#h*SN=*WN=wOPGQCc(S19x{GH}}yZ*TGF ziK2LMaUoYPF2r$dT&q?u0Q}(MpEI#8)^7>wy*j~dU6yeGL|G)4Z!`D?6v$J?4GNiF zGNUM+N-|jqFSt^;^pX20u^KaC*wKL1)CJS$%Vk@iEmQRU!98y?czh5h263h#&UI8G~>;F&}3tQ$@xhmG@h5396##KW2c6&nD-->t* zzH&?cgu?c})WwUscng4f{a@;`oGHloVP3&K8 zYWaY-m3_Qz=Z77^NgMadOSSCt@E=Ps4GgQlTkY0kAe~EC|Lpg z0C`J&DPN2UyU7&Gu-tM7^CfvM>!_q$|F7zV-={;NRk*zX^&Xy|sN>Mfv~agPsrszZ zST{=H##(12j$1JtBfT5p%`HZ(R~kw8ecKQFg5WJ*x&2m`V}}Y*yZ+#L(7tQhrOc;? zl-q4QvB#(*`_Y3X_Vss0x8Fk3#a~Y$nt>$Qn2*D~V85{yB8iQ{r9&gU|I zev9S7uL8Gt)I|dF=Y>|QegWzPvP@{V3Nn!IR4VydvXh@BKI2xUMBh(6aBL~@%r!AuWVG?f=&mJDxzGOktCLsq`D9Be0N@V+ zw0ap7DLEZtMdX4AhRfVstkov-f;^PxlkxbXr%Y<&X1CewisGbJ`y`1>y^eD%RgLHX zYcVG7w{0ENyVVm($?-3NBx$ln5*EKMtyUbD4wv+JlvSVUD^3~+YL43}RqjpaZ>3ze_N$kOC+VOY{hW+5B@jP%seQ7^>9XbyLO_reD=`#sdf2i+$u9o?M zdc~#Q*=#JUW~0w|6Dzl8Ec<(uJGK{c1uP-ECFnFoEcE?p>b=X@zgJgrNs7N?y_(l62vH_2aOTu; zH1Wkuhrd?fG^jc{yVoI7S9+u_MCut_7!Id3v9PUUb&ldf@7>y_JFay%O|e@o7B~1R zR>f}jzhMAekSBme7+=8B<$4CP2M`qy9;PHYV6Jyi@gzzQxufnYeT4}(ia$$dqsPwU z5sO*J_umWFSAy&Qz_!oZ_MFx;KV|fIOpaJ^|IlRj`#mo`7L%L${sFWDr)GmSX15!x z-ju0rqgjo2_ERjgP*qK!X^q!LX;y>Hu?d|?f1KrU_f9eo=CJlH^$aSqrQQSef(+VI zC|ev?=iM66d@OdmUC?cIyVcDG)WLl$UUUh>iAb>R_igW2u?(N61L7?ic^SATn9E7n zNxqRMszu^JF zAl2kMNq7&8r$ZVW%4{j9Mn@?q+c73i$N&u<3-i9;kLlEE%cl5$T`V6CkTnyOJ+mDaOaDWQ*^ecn!U$EDGLmsW}B zARh3Q)rAo6JL!FggZ3F6jy>B;&&!jW5FMg-Pfri`&2I0*$r<%!@Z{{~#$u(6L5tIC z^ct$p<0cjz2bs`3+o&=gg zN0I9tG<<%Iswa`AOAJdUZZ^xs-z{*A5120pqimm1%e$$8lj2Rz-5n3_^+!xU`FD3; z?p{7vc6^8QYfHemZ=l>~d!hFs`#E}j$4Ogk{OLe2Q=08L;!#{n!QPLNUsaV8bX6T_ zoZeWG8?W;fL^?9qw}QvFOlz1NW~S4EBF|xQlOZ}B-97Er#?yIiJSVn3uGPB5yDgsX za>d8T9K^q@j<*wkQ>~J@2auzPFOmx}x0!EFdB9!yU9WwxvgjR&?#kfg)Re^ zU-wz6Z!-%j`#HxBkmxujd;G3VYpX;y0Xtz}E(t{V$~uW0lOc^)=|GS@GK+e7MHx=# z!*RE|?AE3ejI;Sv?ZxLMm2b0E0P-M#%6ch}d~Pk7{t#OF7gYEvW_6V_EC`1%sm z;p`;DqvO$3nU9KswqGY#rE*CRhZCi6Vg+4BzY4?O1Z^=|F|5~1w-IQ|ecyr0B;3%> z6NBS&$4u{pLhhSaJ04eT@6<#cQlX#RA=lns%xy$Iav8;|8b2CeW=l2{s^~`vfxD{}nt5yRf<*f`crJol5KDpU+ooq#9&8 zolytKS$vp#7S*yGSBhp|TzSfi1;>|pT8b=!z8&|j&*(e&+8TUqFrCtl8|%?a$FBL@ z{y>@BXE$djM^uFJTU_rioz{q{e5Fbf#|)xZ>^Gwk$Huc-c9m^sKiA@Euns4o_3#?h z5i=0rkge;=Umc~s?o7dWGHh16c;nOB7RtO!P^{%PB)h}wuHU|SgU1_E^|#l+Q}qdS zH#zt}!9}+!7OMbK0D7Km3rMzut~&X`M`exqrYM-~VVJwhgjJnk7U?*AzI_a9V$zJD zYHhE&WAk}!5pOwiZ;S039$dytin18|FPwW+$P$X}!sSCocO(=%2_8{qAMNLT)*Y5M ztEsG{FE zcd6Zz*ty+c+4me7W7MhL5el9=Tt?^XuMb_;vSwBV%E_{HLRF>yV3AH_j|HcTm^;>a zvC_jO>{*oxChK<3CbtTePO|dXP!_ATF7#edCex`hO``srW-Zsv6_-_5+@v|i8We%Y zyMIuG>bHs?7YPXYC-gp6qnLxi$pt8CqEy8~wN7FkrU^!Uudp5tkYr|StbYSr7gfDV zsM%*}B(Tv6Atx0*<3}nIIDfx$@1=y-X3vRdKeE41dk)V6r>|lW>)}zv|MC*Fy`WVDgB%|{yeSf>k=9~(Lk%M*Vv}w0f(3C@}$xW z=X;gp5Q-lcaybmN2}XLiG@bn1#U(Pt?#M*{@CI`K@ZrY~KmPdP15Q4?y(75}eD891 zC_7n)=49M0h?tLJO|BA$D3Dz}f!wJx7^$#1Y~R+{IWt^h(BQN*7k{Rg64=2xqpssD zn`W{H_xI(6YZSCPV+TC8tNs^9A%it&I(jN+PxAE94F2TRn(Smgm^H4&{6j33fOh zZjjt+-FdS%$#sj9&A8U=j_334usFvB82#hjhsQtOJig5p-xephIDsOb#>Knora0d; z5&SmI<#x`^b0pP@Q&HaT3K3^9*D>9aop88;9J?Or>4dJ6EzBUTMqjBY_GmR4Fe6FO z3~ldwf$o=IUERAW(~Wh{VsiKmmaF?;oDlu_3w%;_Zb7fRgLaG6Y~wF^?Tgs-~d>j&DCZN@>`>j_xTR{}t_f9U)W2S+R648V8hb{3Dmp813n?7e z6LF4tmd&OUt5Qilew8{x$Uy@An?-AlX{&(3EiElA<#AhfOL=T557!owu4yP~DebPa ztx)PswzAR!84X=8C4fe0x=1Ru)JJIjfz$+3Ov@v(L?jKOMvF@vC=8ABl}ra>#Kgob zYE1lL)E|Bqy)c%ACEK~@obP-O%4%vKqpYuMEaDb% z>Xe*wLNU)%FK*z7Jri6>qYAqoQ~6u3ywE}DD8MH{89OM0G^)dF;hsksFBVOkXtT0L zA)0_y?A`NfeW$BFX`cjk;gmBhQ?bvFCP#gkc*f;o0ClWv2_(_=U@$V0blZKCc3>Z- zBH*?Mrjtn*NIp28+w$lrc+K<-%I$&t#c9`?SWEITs|_o5YRdX)Clyr@1azy>;plKs zILBxE2xv?d84A5>{!r^s^r5BjTb85%_(J2Zgm{-@VQR0h$oiG zruagSqDUa91*Hjf5jbT!=~D(dN$Ax^u%=i_N2ScHLF4s8w)Nt}WP($HD+eob4+B3P z2EH?PEIFp0@qxWyt=$peI9dq>gRu@o0?Cm`BpwOQCWH9i=%n2qna56ySnw)tT9SZx z7W;3W%9&~C7}KMVF^|Hnz%@C&C$MdCP+=BOb8{&*LJl6^&o&ZZ4|lRKcdWUR5qED&dJGwX)i)6B?n$ zOosG;3l-6!Kd&dR7|)UkH5H9Iqee`1;=ypJmBx9KQkSgDkU6M&@Vi>>Nx#3cdf>G)y~J z&y#G)I3rK8{v8dNM(U#AD~htsQ86ORxE5|0tFhji;NKFrW=+J=$c#L1JJ;M3Mo_yeqOj zI*IXjLAHKtzljb9u;77UFc6Gj1l&oB<)$6oo{t240gG#7-W|uHxO+xnbWFQPvFn(8 z06vU5$U{urHQalQn-%>gb9(cFpCbKaOy_`aLnc}uni3iZLGy;BwGx#%B&?Pz`TT~< zFIEW7G%Cug1j7}YPEPZslA;&+91*slk5kMm7b`V6lCvX`*`#a40zeNW<2d^Ek(+jmJ02821OEzy2yukV2AJ!GIcxE4Ry$&BNVa08W#W3>t(6_>z^&514EIOeh48)L8Is~0v&gIH(NED?41y597-PtVe ztf&wb7hftBovGq@#uW{fb@gJ6a7rT=iAw}xLt+TXNf>nJ_2#p+1oW!jxIpLhY~ImD z)3g=0m8H?JDzsiy-{OUD>}momhezG8Bi!@ho?h3ew`JS6?XyoO?MX`{Ih#D(y!*>9 z+lTvccHUpd#|p+Dy$89$(8o`yZD0gi7RQifvXf1ZYH!*`dtl5$w6P=Kgt*4kqBS`k zZ87L|XlFX4PEgbw;V@nSjrSXf1d#yj8;QQY>e`_$saY=MD$1%SN@bU1&CUD<4__hV z);A6)J(s#KahiuakvBoOl!z)MwHkBvl!nWJ!}XfO2yB<)O8EN?dLu~@C>lNY(lkk7 z%>nDC$81b5fCsm>ZD!Jk+96JX>F(s=w?{|5h$UdRj7(eX(}C@~J3Bka`S;#<@4-$0 zs&(!CIG#W-fb9;T-S`X!lEL|TOC(^QwOb;}TLyyISCYV#&QNUdD#Y z8cn6pZ6c?m`rBi=tFajL1t5>Cl`71}b}+o5E}^8lt4sD`?W>%+@rl6-nShT&4y3zu z8==dP>3Wy1BO2Ja{(tAGGVi5@LkIAJwZ<;7?X>ZyThF6J~`Y z)dCX%APghL<^pjCuKBRackk|hcl*w*Z@=B1Y#ROVdfolx?VXeNj^BImX<_HkJrc05 zj6_zF$ys;A9uG$1zIf2h-uU^X9kUJ%=Y~_m(xIEDwiTcqN6i|B)e9EEdXumwL8`1& zMpfH^;0e_3JWWwVDArE2OAW1aF%rh2G&ZEFl#M;DktuGJb$6dB@|-KL@Kn@^M9re{ zhQ2{g5qM3txY(o6C^cf4CS(u*89P+chm7aXN)cmGdP*JDJM<|%kEnDhfBfDX$0tW? zAoA>p2jW0=7V%I26rcSc=fUTpc+l`3#xgzGV?*%LG};1-3g@H=8*c-DhDDXIB6tJT zr5tkcWhiB#^XZIIm1NVpA^G9I5_BDio#spM7E7oU-V+LUlO z4fsyEh|j4W6I6>PM6!tv%1n_lIQmi&c7>6|9Ca9}s2ai{ipE?0aO7Z*GreB;q7}Kubavrj@AubsZ=XzW9AwkkEC&9KH}c1afW4b6*s)YD zhzARg)~`io0r_Y>i}1b~@L*74Bok~L#RinfAsDTdZgXPfuCWdqal^+`jaeh0fc2EuRfs}21N(Wucufk-eWo4VJO@TRbITCj|;iwPI3 z1%1Yu%S>+Uj_#b?-A|{dJj<)ku0H$4Zl-X1=iueT&4a0Qb}4_nxpU{>zRwbAdjF<< z#WKHQ58~KI;_j8Wdln22EEd`Ybk;qCgE(Vx2Uwi%VY4XQ&o){M|Jww}ga41D8AfPS z?I8TRJ~BpuZRphiB&omMIA}Ds8;H;i5Lu+{;Ka8 zjzHW{*EtRfFB|KtmGEwu`yh75Nb^Gp74AB28zK&*j9pPZ%7bJ@@?b*5*6VF)Q!{j1 zrjWUp$=qZ1!h0^)^ufu4^won0X|z54$mY8{yE~t}a_9bsZ|~g7ZebR_Iyzcgiv%od zcaKu8;0m!87n4#^Z#FKMQfWtRskx*I$t7X%HQl4ee4k?0&e z=jqeVA`sR->zDR%cc6xa!o83J4WaIv= z{lK4_CvT$6wfO%!W{v%f2UphcLfC<~!^gFQ9AVd4mlB>&3+5|)&BSD)pGK6meIzMVeKuIEwv`uggJnf^Ohf13E{t)+ba?R@_D_&E3A)6YNu z^ysf&e*Ja-@XcUwWn?A(=IqFdeFdLEh?*oT)+27;G<=(x86f;=BnSLtv>3QV8w%H+ zhS|tl;Y{Msbd=PO>4$0_A}KXqfjUNz{&tn>s+15Cp{^G>!m)|2nu!<7#v7h~y1t}@ zgIzBwI#=H~F)+Ys7}xN)-P~#cU(A**htCpJGhxb^JvD-(;$%ZrQ4 zi_7cl>)HI$`X`4=U*>N^qOQ$Dy{)kpWn>KxJM1GEe0*giNtE0(ZFeEBvuW|dZB{1S zW`j3ysvg*c4_${NONQp=q;SVCrocl~p^!?alU})qyDl}io8dRr+z@k1U*ai;i_cUP z^AwGB^^GNEobK*tlurZUmG#XR_`C|vm|Q9y>{6A14n9m0=hcMKK^sxOns(03MF}Iq zCMOMp4C2KG-N<-p#u3eAavO!rwM?N<$lUt=+uM7)Ki#_XRXV-y`QejyKYM<4@fDQ4 zwY8OAPN&n^d_JGu-vG|<2iPmdmdS267~Rpz>8>BHS?qyP-@MB`13y#S(*oK69Tdic zFQ%}~i_5OH0`Gu&=sK-tX{?HN_#Gr9y2{)N8QX3oC>g| zXU$OB6#RcscMw^Kv*~O17!*%$4sSn5uWzm2`tIvzpMB-o)yEfC zS5f@(@_KrG=}X+UU-EC{ckGr~cYMSi4bSp6msiLj;2dNjDu$sapwhfG|r#9TaG%npBZ&Y*wR__7PL^>hj{! zhSJLC#F_~K`?Cb1649CKGA>W^Dn~F;<|(Z&;_&32b|L?&+{`hD&N})jI)!MX7MB9v zR3?{!M5FiFNgC)>ByvrE|@PjEy=b-Tkq=Zw-B>wiqn3eAY9GuJ=o(q0QQg?kxmfzA}X_tOpOcW>u!zq_>b<9Ej= z7Z0|+$A+(>7``SsB%8%S6Mug<@ z_U9@EFYy)QV*D)4_2>9iMUC~B&+v=OMM{oLSrRVcs=E3IjZ#=mB^Nc-+X^+f;%C7}i4*&k=@UQ!y7VZb!M;2H&tOT;d zwMPWun}j;R#Ggt87z6!nY_{I(@M>WRTQTe@u-SzaITqDjA+8{EBM`W%DN03v>$DGP zifYEMOpS9C7rKjh`~gKV3WZ=99;hm+;*^x*qhU-bn;N?!mlV~6Zs_}U3u*{Kf1g8Y zq;pmr5gNr)>`zieO;)XyO@7pLKdsJWG8;hn%*Izge3X0b?caV#FMsq00PWqomS2C} z+xbGXzP069U*BTez78Ubw&$~7qI4v2kSKQh2nIe7S-E>}XXCHKjeQ^%@n(GN~bst8Gk zv^}ON<(3z7J={vqAV(uB?<{{+R54s!RD8MnOgX1iQzkA`@I1V+=7(idax=-rt|zDj zJh*yJoj9WS#cr^YO)|G@n$Hd23R`dQppMU!KCx7lAjU0~Lv><~( zR)y4#fw}FPoUC%e?Fg^z+?p<}J=66#)ITdnb`Ybn|1SX6^|F z&1eSc=uzx}EzriYEwckj;no(|Elv)0PS#iq2J7g)*=n=vW(p~)kVGnWb#Wv6F%bd$ zL69v(G6ly$BNz&S4>b;g4Vqg3OqO|ZVwhnD1^PIVIbg8Uq%2<6ESr_LUMzQMhA&<; z)Xpoq+9Ao|YQF{-9GKxzyYJk1xGO0Q07&TG`2bdNVU1f_U+P?6`l_Kd79t@Yc&Icu zD7M*H4$R%_dFry)->(J86Uv+rQ1}ReP!JKs1Vzhn;K0ctArSPA36XVd#!f=APZ%wj z%%U>@qpM>uf?baWM&Yunu|TzziGgJ`PGTbb~05fO#S>Cx;DFzWV-e>SdLCJx8S}7zx{Zv{UQYY#S7-kNwt?-Tcxc@T!3r2Qs8377nzGH zE}xqZ#SaEJ2zbD;fq{At;{A10mGp5?Z9qgk;6j`a(4G!`4L**?F`=2EkOD&gjF6d1 zW`s0>XgGus$)eK=pj;(0QbdemLap=wn;Qu>uAAbmzLy_ODPtXjj z2lIsT1+B1C|4=caxpjATJ>o-Cd)I{@Z~f=>c3535La-0az;#tS-t&?Vg}s4`f>aV2 zd~A%bk3-})yi(XCC7~Q7%2Jodmx16euPg}I*0LZ7`~Xx?0dfXF$38%nb7a3LpWMP^ zeB6lw@^Q%e$T~k_fe$S*B!n1=_uI3V;ep#^>w>p;am3nStT65XKSz7)b)sUeQyi%n zM^f@$yq6``$>bqgGPJ9KL|34T?Z$8jBLp*nNlsvcCK5J+gph;~IzmMJ{MeBRad|LE z!NN;c9ut|O7`J%~u;~JdyF4XJjCU*y*3OG0J z44B5#e#xn9h)t8kN?T>XNz^XQgVUuFAf?cmJ|FnF%CDf@)h0n#Q%~z^UoXpp?p_-Z zP%D707NPw5p*%#a;bN; z2Tsue6a{-7FwR?TtZWWYx42_0tSDRdkQ{+w##p!(6xK!hve^fjG#WdM+!PnVgdhhk zE=Lr~q0>U?en>>X#|e2bO~URRFlKtNYSac9mSf{P7ss_P=3XqkP|n?6n=%HdYv)Zc z&p^Q6ZHIa0;dZ(b>F&mOZZkQrn$Z-#l9Fvq2PU7!x+xN z082&|oIuENO)P{(rW2Z=)FT`=B80IHA_2-CCn16W%4A_)xoJ-QXPa?;_K{9#?C&2m zDM!@mGPQ9eZR}C}eWSu)FkQRVbqgB%H7IizFW!Km2Cj833PATr_zk0A?x>V21vnaI zX29pL$w0}^IW&LhP-|XVUfKK$W4lf+hg}`+k89ugEl9nn))s$_y<2~7QXfN)D&!Qh zXe)_?( z<V}u8invj{s)^GKhDyeJdBx z15F*R@B2SBSw0!c}C!c-R)*O|2u#nh76OfxS zKncajV1S;c7*9$8B{bE^!`ssX>tt1eLQEk(^&sYU^*>3Jn61DZ}9 zP+MlWV3OwvBg8BO5{{W5H1~EDUAlDFtK*V)J@2HFUV8Z0;ZK{7eH#1H_liA`2kj*$5(lN6!%o1&CjZsBdUisW9tJ3Sp4k zJZLTtFqx-;cbK0q4;ULe0u0&5dAgv5T-4`x1_sbbpMimOVBqg*zN`mwy&+%Hlk=6V zb=PR6Od?gG7vwr9OQD^k;@a}Xua_a%KN#$kqet9n)=YU<)x*xs%jTV|xqZDQ{a8%Q zCvDdcx3#n!ON?obilGq;X{^FTRn zt*g9KFk9?NR*s%nU#f4lH6WONb#9R-SSOGs;93aq5a=9)AZGgsLy=H2!Uj|_4i+_3 zyCgg=pDpgXq*R;`Bjw^w+2g_?kHdOY!tmEXg}xjM^zGuOvUF*xKQACC4rpu(2*p=)S?{h?nJ~wwmd|x&@A_M z@h$~=dKMMce>XHYH`m|acDR4I?|O?*>0w&iXKlw~XrC6x96MZ?OLQTVLDwBd!5_{2 z+{MNx%_6!G>F=ojwEixyKK!m{RsG44{)(Ch=O^c;e)j)<>a)Yw zzwj%LE=?uwtWIVGlM16^aG8uuP_*x1WRP5O7^-b<(Wlu(MbUPE+1OfJVh&h=JQzo! zI1_Q3DVsLgSl}66j7WD;=s}?$S-cy80-8+ch&XVIL_$si1Og)D2z>-dZ~}Q}gudOS z{YC!;=wbbGwMO6f$MWLF!zUv*^b3aRq_o%5)MaV%TD9TEjVBK$z}XWMPr&V3fMaC& zNitQXET?ibsZw%?4@3kXjd%$<&8M|WVQ~XgB2I0b)j^zh4yp}Cn*GdE&~LRUd`SPow+4*`|gHqVR$=w@X_Oi6YY;hr3xNXL}?J20+TtEm8CF9r}LIQyWdSD+i^Z0Ip zh{57;(m5glB7lk?3Fx~R+MNDz;B949efHFprWaApu8fS_U!ttNxUgoJrH{9M1;ASD zduj0_7w$Zqm;tX(47^(0))&SvOY1*=Z`|{2R?cLsS~_jt?qF?+-R!Z|0fR}gx3Tnc zv87N*pfJV|8L6R7VJ8w`M@6-1AqdnqA5mgd-(kJEH(eAeM1&%=u?g60(a-&6^KyOk zvHF!+Jx8Hgm^IFuW(^O~QGMDlAOCJ6=x5$BXu;plC*bR0+`z=ZlZ7YaGPJ6rxjmZC zg^y84dQ~MLRg%$GZi9qd2@F*HSnc%MoI)o?Ezg(8%F04K_N|aa|M~KJ;lYU8V4JjbM8Sq z+i-V}Dy#5p=V&UZrl|I|7%I-5LUE!{d~p=Q9yTDmO$F#{B_~d>VUUdo>J$k2MkeRx z^u5xZ@*Ti3&@*a zn0|s*Hz;#Z-Pz+y@BS^7E?wsLr1b!umQ>jQaC919C6Tp$wXyM6Qa-4pK`sgFTAyxM zqf20m&9gk7VRCZy%%A&tHDB(p0JF3FOWr6c>4vkdySt?1_n%I`QF1yftK0uf$-UdR z=lW8EiK&q5(AbaeVK` zwXdsdVu25fLlEv3!bS}1Famw8RI$8r?%cUajY6R?r^6g4>>GO8JEdRg{rTtBOT2Hx zr(Q%1z9>|xwZ^rzsc|JBuWREV2~r;#n;+LgVMjy$`OMWDzb$QyFC=lf@4+bZOa}gj zI9Ewqfp<}D{GooN|4X{7^<_Rlv6ti1?rV*Z>|(`QJ#Tf2cmCA9Q~OV!^4||9YoGrc zZ)}5m8$5xMH_mP=DLGqm<;vOan>YP$-aOM`rqL69`byK&n~RGB1E~&FFDlj1+SwO4 zCwLjc*4fU%5>OkAGsa@eQ5$Q##byegQHLj!@u6fIA(Vx#f=3YsEkV$Su=M(>qAFh1 z$#ds;9V`6`p+dR5I<>qyq*U}j=(yC;vGREJk-}is=+flI1%pw$b_ckIrKEQcjlHim zY@q&zA_snlxPLe@`Vv~2tS5(is3Ephs)F!GOZ?LGqx&;6kH#h3*tFK##@ct@7Iz8} zv(l^>=GClroUAzo4nJSI4N0@-~&5Ot|!i)Me4|u$jypwSAfLEA;UFEiy=YwO-ZFZ3YBk9c=WLC0w5Qrp z9lX7>v#C|#ftXycz})6&-*6Ho5I}3+OgfH32qyRiGt!d_qkf+3Eln?NnLBm<`h(Sb3;XDv?N%%BAI%5@_-83ebk~>T@RGwG$Vw-qJSiT3FEP z{#Y<5hu1E7dCh&>aqq#?@6i9~pM^Sj+nZ<4g5Ccg_z|o=y92(TJqw=i2It?*I&<^P znKL)De(3)+)xtKnnOfxJbk4IV+Z$w(ILqzO-0d*dHh60W-qj6{PjPh2ZT=|g)2No_ z^y@M7QXjDS%8>m&PR7_^Yku>hp;K?Z#+B&Ms9CEa_iee(l||{MSG&#gBc) z?-{>y_2I<8KzsWPkhJTy+Tq2qmHK~~xc0Cn>nJ?#7ZE`q!4v^?6v3Kgk&i_*77q~? z1414GvI#^YY($PGd!~aJw}%aJlb914EH26#A><%Q0^=HD$W1U*KoLO!#qe6a-xk%` zw+s7&Z|`@`dC%o{eqVjQl*OV7cpP5yjq4%?557+E6f-?NJ)m?T)vEp5Z=w3_+wsI_ zToWg!k|OB-B;dRog z^%m>bS-ks6tc8~)3IV!0fnG>g(}z4yitqQPoLion17apFIR(%OA+ABPNDSN}9#5*| zm7x*SpFJ+QIl6TGvj5r9{@RAl+B**)jOE5OE;gcEJJoaIX=SKiT>8Vyqn(`#8SyW7 zd>q*E#es;7^!8n?Wp60POO>Xl>gDsJrMG^6dQc!AJg8(j7c)34*--N}c$g=X$t2jk z#K{BLR@_{Ncm+B%|IgP&S}94Me!a+JNK>6d02lK4QMLj48#W@wZQZ+-MCC(rl6=!_ z;Ok+uFmh5fndTmy6&)Q`m@t29h%(iCZECv2(-W$O1OYle>t4h`GKM$^k(MQv>K2)n znwP$Q<@n{kHiWm%*2k4`s=O-`NMaWoXCFUJeURJU9@p8{x%l=(MY`V>|9DIg#O1|w zv@Q0JOU66fuF7lce;dD3Cn-*1v4nhNFd{L9fru>@F=QY(oF2b|IJu7Db>abcCxGi< z!}y8ILvX@L&*}R^w@Q|WI0agf<>VLh6MdbjW|2lHTS==(_N&&}SeTeZ3E6CFrjW}P z(%5Viz%+FNw;`vu6eTx3^p17uXjKK%y<*D)_ z`nv0DC5pPbHiB+1X0@pM5PkYRE#GvYS@HQ?zKuKj=m&{t%|3JBAm zo_eIA%-t)1ax^gdf}F&}99!E>k(Q=wEDbjxs$1!Y2LwdLCdI}^Me*4o!mO;!LOMHv zoxtU*s|(b<%|GX8TBeFTa84MymSk`cdWZXg{onJuB%{}6iieEduCqct^(np179=wy{~ zCAH_2Wh|*&AlNI&AJKr^f`DI4sGPZ?@a_M(I^K2AbymM(?Fe>|=|^)6j#yKm)p}wM z#MU=5U{k;beLGV-QfRfE`B2|4^N&ZHP>}goJe*yu z?H|1|q34kHNf1` z+|tZo(}p)m&dyXMdd8&i@HC6(9gV}t#$FQ;mgub=xMj_5m z=pFVCJA^(!bTXCzYl}VKb)5R>c*FUg%iV2bJ$)FLscd?XSNRxCn#W(nv`3_>o?(M_ zQ{4Lpki@9c|CsSle^A+1qmY-Dw$}ArJyj!}tdZ|kyeU;4%vWM0qnO8Gh{Uk?AVgFc zJiJYd9l#+vl>(vTy<0?J7H*=!i1yUZ@GOtnJ67_dOWnm zCx$(8cnl4)yxzLw!{2=K<1cq^7D{@$D^*A1;`*AZ;+j-#zy5kW%K+#CUB@ZJB)Z?xm}8IZIlm+$$*K9Fua2M~-oh!PF@Pui*ekK)Aoj zbV`Qawce&fOvsALaS%e7`nMh}_m*$n$5+eusyP~srXYu3Pz~^W-$be}_BfesG_}R* zi%p;YkG|L1HlvxuQk}eFr6Lp~K{~M5FU{ zoz+8hA9N`Vk<>Z0+@=h*OwSF?wJ-=L*FK53&bOuVsR3q2tMyl}F)}hU+(@!=TW9yK z)oM&xJ^$qkn6uj!wQY~hTE~#AtOW49kSpX?bGa9qmy?}}TAGJ?h3cPsZxlV+?g86N zCW>ZM6$LB-kLBz#_|q>xb{wBQ|JLQYhFZm$)GMQ%ss#-FS5)OLl*hEkS1sh_rm6xD zRpf>4%d1fNEq=Oq>HP6$7ZtUF`cmcmhZ9S!1IlWp;2=*a6CcbM33x%GW60QHZn}_4 zq!U_((-HehNMB+1`;Q(?FE2m3Q6ReaX#QHkg&d(!2nWX-4t}I%W@Lbao`Igdsl5To zj*4tf-_lH)BXXc)59zW66$5

^J3SC{O=CWxCY&tzNKiT7Ed?5&{U3B&KGl|Qi^kMOQv-cdv&|b# zHv+SZnT-wAe#7(YZP%L^B$3jDwEgJu(xPef1bPBj%~dC;>1=x8>E5aNpVdk9wEbN6 znfaFOK%PuQ9ON7bZ#)?~79(fcCXQqA`D`Z^Rgu8`diJp@{pdoRYN4v4B4!~qJ-xju zz9IuzeC7N8f2iUny2fVW&qlO$b@fXohTE2YkVtuxm^Lfs2*8}h`MmELTD7An)$top z>)iW4A+RHqf!yXsIQ;4yji&n6bje&nP9`W_hdwjbH)&I*Wh8ZLl=GX0)U9S4oXxg6 zZ{12VGBnnQ1(;YF+gRC~?6xwY(n4ZEb7U-Fc{#E{b-*pmQcv9y{)P@%LPCS`v-JaK zT8IV_uYiNZn#0rZdHL1O0GRqoE^pN`*{DwiyuB!#aE=KF62E}$cw>RQ+gAg zsYe&`UP`U3`0(qQqqLS-DIYLd2FV&Z7OZ9beu-$Fy5@4Pb z6%`PyADnHMZKoHEky+BJHLEtSH`ZHcVG(Ar7F!#4+W1&I9@$}i^N1`Z}+u zyi=Qw=EXF5SA_bhQsc@)(<>q}u&VxP-`GS?*T*03`fjmreyMNxr#i(*y+SY|FB7<- zD&PpDJk~K?2M(O7O=WZpM`W%ZI&sp{EfdLxXo|~@txkZj&oI8f*6T%cbPRVShlPZM z#D<5PS=s3u8DSG|fYF-ZZ2e%+oP!-UfH)X$UQIF%U!9HeWsmU-pG8@J7J`j}&tbIQ z+S<{5tvflT?#xdObSDT|o*GbB3%T4RuJ9Z)`NCCN zY)F{#>hap_GezrY3Wg~|+7OjT3*K0kle_;}|XMc1yy z$2TV>jf%nkGC}`HjgpA$0<@fqWrFW{_|MQg1>#9aGQhu16cF2;{t<%wz=60#_pdGA zQYR#Ex%{7)qSI_)Y)E7XEs7QyYn7N}a?r%~O%u#hSUOW(Tx@r5^^M)@>+4KfV_;-p zVn{O9vr4itNlJ3tZ*K0D7T_2{^9rMxxJSiC(=r>_v}kiWo1c=zEli*{@X2IqA-7<@ zh)L1fBhoDf*e-}C;vkz>3ah^5K?(!o;_$)KVhple11Wk?gIgQTKrF(Zh{Bw!Q8r!I#@`l`!c zi87)Hf^SQ-jfv!w_vWru=OAUhaDO0CSm46;%@k5IU0hBHAa`bPTpq*eA77VFTTbKCQR$>Gl|b{yVw~P=d z3=WBRgDu98<0@Q&37mDX67^AAcaqNd*F>^iooNO>OPEi{rzytxqraRR!ji z@2WTy5$7M1TD7Iz`+zDi=$U9%U8o5M@M-iZal% zBN^G5t}c6CZY*#!^&6N=h@@7dR~*C@GVH9bPHo@K{nFELN^ijCYQ;XLNq^q|ZAdG;UY> z7yj)T54L-~<*q85t>WG@_0-w!Jhz$v$g?NSA(AGJaSUK24kyaZS z6S~$92FY)>vopnp=HNBKo3o9wadS3{FW-IFWY1@M*ztZC8($6|w*Knyw!^q_A0}^K z!IJZ~BZSs>ypnPRAIOfU2cF#Hh|#6wKmeNXc@1bj)45FYd})7AS5Irj<+0)MEA7w9 z;{q!V>}vWvFx6ibxa-0DGgY52e!jR^{_xqK{ffq#$yyYxW&LtQHK|-9Rce$x@cTjM zVsxJwFf3HaI%mff*uFyUcxtuI#N~%=FvaJt-x9KELUuSilg6fj*J&1CW{2BnuUVa~ zA0BL%9gMpX8Ll=Ax4?^Au!Ef$QMo~EoNbc$Nl~_L25xBv_GzT`ULotq`@?tInERwf zoiN$oKqK$ZjHV}?E(|*%bajnAolvd5aPM9+n3u`K`BB*sZi$vHPg9I^zO3eV(s*6P z<+i>jqZzNp9O@`PkP+{HH1yM|R}Y{&^YZ&0!*?@g(2NA;Nu>f?BnFiT=PaItB|G;> z=ES5--_}esVNF_g15yalbVaU?7pNT%0zLHZS;BU$*E=+RI`!3C1&z7ahRpK z>^67a?SlKSP#s*HF&1pR*V64E>CHEd4hGng0vt#VHs(gbdaDuOOh^`MNzd=m!v+HE zD8L;$$e(PpUb_?ffUI4~m`-tb-)a3^iqFny*FrU2-4a9;t#C9k;pssL@;nVoIwGi% zl%lU(+t~fEGriI;9f>>E7xUsUD^%%M?jP^nG1C$8hyTo9fBntVmB%$*#^H@!>>f;H z12$xXjbIXJvXT&*vtSJZW&;HlM}#`=iGi$$h{MWFXAp=MA{BH%fgGiiL(Iz1C`GbE zR8Uu>r9t)Sdxr(_A z0$UfPC8dZcl(ZzN#zR9#%1#wA=?srh4F{cOwo4h4=Bf15d&YWG0|S{`x3a>Y$-p$H z8?=qwpyaoDb@T%dtae+y_h4!S*hBKvy(bTvOs2lsMYIgp4JZ;GI6d@13nO>8Ihnw( zet+?si)Wu)SGw-;xWjSUEtS>#FqvK15w)%B?&_#hKb82;|NZwLf4z06;@zoh7cU(u z1iob+KlIu0fm1$Rst>+3>tN^bI(ha%i^i8c-a}-fMQ_l@CS3MGm}FT zDxgbhRgF$nmkuAN^i~pCUW_u9hD{{YGkFvymndb|OOvE9c%U>C0voo@CbH`JYyqE7 z%S*2CEYRyKWO)@8%8G)#0=-IQsxhgJs9}m~dUI5UT_#zrsl2nc`@0bQVt8IBOba)c zwHV+~a<&1XMEP>;%lS3hn4{W`(k-Q>>(*@BxA}#2G0(>Pw?tJxaO$VvkN*7g?>|33 zG+_Va=g@QZm+}uBXc(M0^6J}fUmE&uMab~b(-&!1cwxpKmO9=0;@?UnC8JJmX1X`b%C`tvlhL}z%z@rEp7uuDZ7 zo<$$Gl;1khlF5Gfo?GK1HdUIjMwb_wuBu7T)bOZ~Tw`L;hv&=lkuZdzzQXkZ$$kOC z$n|O2%Od>He+ zohpx~R0@=t*jO32zFt~Z&u0-Un6P*$5f7P6p=*2yOmdP7kqd<;9*vs97ZN?`PQEOS z0NO0yRiEsu;4|cWb#%HxohH|zLm`Vc%A-{V6Hxle+s-{><48G?%;1a)tMU&70hT^} z43z$k2jSn}*#(yY^;73UVfY7*$tZ=!MTowV<%pH|F1s}$2=HwIR1x^e{OC0 z==YwU>9-rI4wb}6dk-~kZ7eEWud(0*sOyS8&; zc&>Ms5jMW7Hm9%#P*g$kGGWj%1|tX;-jz!ANJ3nPfAb)+rED@Y$q7btLenH^X(>V- zEmT0GS75%AEa3B4L{GN2CoO|U#ZW=`{o?SzFtIpHrVtzC^1KK|pFwX@mk(aXnP+7! z8oRT6vox9u^V{1bMypCAsl8zxw9* z$7fHUzH+7K`1Y^H9{#jzwEEgW|MluLNK{Q8PkB*QTBEsab^$1(E8@Ar7 zF7ND~xl@e5>WnXlzl~NL(oVkvRRz~ZbB}@73dU#flck&A*xUi>(3tHVTJ5%HgCE_p zCU?X3(x{_x4}NcSH*R!K8P!F3=#l2h#C*M{ zx4_$r=HM<%Wf?kF*Kfs@hPs9Xj83f#Uj=x8$lpTJ#r-uU-IhES#r%?&+mEGiN| zt>f3^g$h-n1)&8TPSG+lmm~r^)Pv#bL4iUxh0l~S$xNavmCW^^Q?sF=>cU~r1+FQc z$pWf`&vj)$Zr9h7%kbjyyr_JyVCyMF7E3_jQRyB8 zj#Nlbqthidz8Z-rNuuG1D3Jkv=)TmG>nRjAJBdiFFJqL&l9BV)ds0$(z-TEzZorgx z7evP@#6^4cM!8xXT`up_^_lAA>T&~6!2Y2d-|g7lT$nxS_JG^Ty$2t<*l=Rgqo+3H zLOc|rO3w!G>(Kfi-Wa@YyW_!9d=bQjhaD%6o~-`%D#l&gfW#eWKh)6NFol=@L@7@<{w?&jLA*2zBB*-$ey~||AJ@Q%<>a}Q@s8j`f z9XNn|0fEKl)t9lU0u~oyYAm8hJ(Ec!N{P7pJ`9dX6tFXtK$cK_m?SQbz~zH4D@mb+ z(geb?ydZairy$5PnZyesxeJ1}dMcFqt%|%%gDgxPW&rg-A(NS8261oi$c^K(0H*v# znwkzaVI1(Tu^wnQtSxyorg}@qzK(71aSKmY#xHE{S}18bdb1__e77nA1hADi`t7&u!?%Zj`)z6KO9|{!E|=v5EvO0AUu!;2abZ;J!%oR}qy-Fz*@Pb{W6cI&AVUi?h!Dy01 zDH`aA)9C3W&U(6VXAXTmQzFbGpwZ$*Lr2Q%{&4SSFbR(_st9-3y4p=1CYQ;>6nTIu z4Jz9=#|JL?9Y`Md;;Ge7J2T$Fm#b791N(tK;HhP91BF zIu_pAbk zS-S(1U)(zGyJgmX&TgtxtI-lx$z;Hv-Q9Ii5@oV@JcKS^Ave;6;RE;0b0zWp7#hEH zjt~*tg(&rK@%8g1Joz^3n4M9Yxc$keSe!`>p3!Pa!G>b%cH>%*z1Klykpcl7wEe`);MN3~k)xMMy( zc)oODzO*Z5Avf27F%E^};Dsq66dVdIW~+H;L%U^vW1@L~R^oe!AuC?lvGSKshgYCF zFK%3kt3F<3o|+wAdHc0R@csJS+}vybb~=ZLC&zmSdu^S%U9~!tl{$4@C?b#&Ghc#0 z&sdr_i-+9Yg9y41)rUl<`-;+bl6(S0bQcL-D9TyyD4&vr z18HC8cCGOr{p63cXECSTv1NXrzr!C9E!P3HfyYj@mUJmnqocY88qB*7Ou^dQ3lSX5 z2~#0p<~3XoNf<0nFyF8@6gHb18bcCS+SQkm{W{N#&)vK7<$LbAetUXwdUz#V-1U%g z`|qIqcXroxmm6yhIw?(H5HLGL2_)6*Vb5Nmm=IvvHZTh zvIp*49vybyeXHd!rrwo$R~X3Rtvv%6Xd9R~5_D|MT~TWHJVWZ?f+${KVeVR?mfl7 z-0piizZ~=@>l{q{-a9kXgPnVZ?u0l~8vB_cm1muL$X;%<88P>x(&_6|>FBla^}?JW zjy{0z?Lz|-6z9z#ijc=ZFx`bK(ulYaX(15n^VyhgBqed!n0;Y08H^n0!=q7^EQu5_ z2xU|VchTxuWs5P+J2o%Y9kC-EZ3%qEPIOqRTeL#av^ua!X=oAyyMZXj@hZu;S3cQv zSIdP*$4+gC(w1ob7fRwC{>Qc>Y0q6a)%EBCUe(Q~4t~*}xU;#c%C8;mR15m{K-aAA zCA`^aS&`Lvz4+c6{j0Ke?Hbc2 zd5&>-&X}SuLI$f=DBLqMV#B>-Gh&&sEEXY!$q|yXef@Sy0wmmJWQGQOp>!$R!wJxc z=yZG`0D;S)`vzpY?i7+Dd0bHtTObq&7+!2HE;|Dv2g%7n1VNb~7AZZ-S2(<|5t-HlSzI(7e0Zj5c*b;o$Y_mWDxVqO}v=Zv56rL1F*J)No^O?Ik0Y ze(0A~*2(gkBDL6PFdR<+tqZQs}x>hCBz5#V8BBqIu=AgDw{1J z2v})Mz9^K#$qrZ+8Q?34qz3u1T^NxJczcnb$d%3^Xeb^O3Q-^-5;+7egnCFkBC1va zgF$2D=yM8WLRyeOuY?;>gsJ6jXhALCyF4t_xd7Zm;N#xtgO4=zoE~W(Go?QA(Abx! z$DWFUf@pk8+@_lg59gLdJ#yjZrlx~y@4HK{?;0rF{dDvG#=`61Wi&VMPq2c3idWE> zXjy?9Uwr%Wg#F}QDRSE`paQtiioV&91f;A6gTZ$2xs!8tOLOD6EmIa~f>Odcl|C<1 zta(Ps$gHSvqn9aJK`8`2bhU&OK7~Z(feR~QQlxBbkEhZ2Nz-<6BeNs3G3Vy$=i=*u zP(X!NIFm>&i*@zlk6i_B}5 zZR&JE#YByX|9p=6t-B>8@SXF1-+OzW=l%GjZ_nKG^k2|+$3Tnji;p~X@k@L3;>FtP z?aCs$YYT7qR-a#f7e4K-xh|aY+*DT=>e;yQE*%fc`2JSKoTVw+fw3cr^jfAZCa^X6)+U@~PL)O)#Ma@_ zk-BMk#wIB@7&nPzav9!lP!c4N$Tum(0Rxg*x0UOz#uw6zVCQt=}b3M%P<#DO}=^wwQJyno{aG_O#npRTrR>&@&f{mYzm+QQUoCqb{!~0gC_;(m9y-x@ zGIj!GjuVlcW*yquNi=Ex;gtW~ptjZngsWi%$)zqL6%*92e@$1MtIBvKBE3Y}7+ zCirS2m?6;8KiP1<=>E3G@m7(8GE$-Vc;Yk$jo3gW>%@4ol@>5WAP5zW7CYKcf$jR< z`|n>?UHKmCHSVjQzSn*G@!O9)a(t@2_srzo4}?FYQq|1xam)5XR}N_pkn1CJBW!SX z$Jx2{vj7|eQZWVCec=mNd-J)np8?;hx)|;Fd~d5vQRQ}~W1iaHDOZ?gv(8@$``_O> z+M6~Hj`lmu;nOM2#2pE>O{(_DiMk@Xf=_1Lne}RlWv*C5R__yBoFl(Er)B; zb7iDNA{O(SR6=7=frD<8RuNSpOPt4%fF5O;4w1YtkEp3T-Ij3H&euS(7L6zf8iL(# z@AO0;=vcy;pLf~jPfhmT-G1uMjkmrRqpR}PYu~^2^N-&>c;>Hrx{n{ZxN>}E1yVoJ zUVAtyDpq!{?OxtL+}!y6@7vfqHXuWN=q(qLR~9l?rg96Ffhawi_GY7C8HPNQ2?lh& zbP1u<#`fl=3XLWxy?yCM_1<2^6LP@0)j1RmpmZk3MV3epGE?NKD71?S4#`((b*+fDY-!8hMZ_H9$>L@8byigVrD+5X!j{F_-7#D>IgePfb`w5sTcy0i;qQ zwtxrr#A$XaL@UI+TE}ZdI%S;)o{cGbI%aEGQdsR0v^71Mk!tV6Q1#~RNlL>SE?CkPMOhGRU+#i zf1)ma;=~ET6DRrnNN^|}% zzVo%_9w8BSG>juMktjF{u22BBu8OA$$^t=?P~-FYjP8DGM9kyFd_t*If+lmos_vKh zcy1F3B0pgjNM)ibC~K=ZgqSbm%k&n#$xBA+rS-7;L}NWVG7c!9u%gO#mI!9+)X`BL ztxI`yOgW^}v5=#$fQuONx!;(Ih{YDu>o2@H}ZlV-Ij@E;vLpK`idVg2^v{@m5g z%Kq8)&CM@DDF< zz7YUvOcFgup8*vH-XFIjuocFj%EaXw_;LfGSF4js(l8z&2sW7!iR#deX@-O{jd=s% z5XGy(ejT=U8&t%jo+xhkB31M->GbB=97sZi!qfs&w7q47ce%x`!c-=Au(zfRhs!RHISMnfN9|AvSh9QI zLgv9kqv*u;SC3WV8{1oz-QRv-KL7J@^S4_+EiNx_?e=*0;>}M8>c&ZZBx!ZKNrN!h zUlr6=Nn?DmSR*!wtsF(hs}>uR7>FPxs>mQuC2!)gLmdrLq0GW}TS%Y9q>fFitvqDA zb&wuB(a_WIgrm+F4iTY72jy^eOt#dr2H#G3pvxCFqjZ7d6?$>m&9fsJ@PRTu!|>G0 z5yR_OED&gcud96B-Tihi#@;=!vNQqN@kw(hV{U0~on^ju8*nWQxu*;Zxi=&W8*SlY zI28@iblhz2cbOF~nxb3`?SWt{)9xyJvfG=0bou>`neDAn@3hY`xVw3U zh$x;sp*kT|#mSzWAy6=glPW$J!<_^w+;MV~Po|N;)=2ak^!Y#Uo!dvFWbrwa9G{W~^2>PbSlv zFw_i6n;ENtE0kmQlTfLbgX_!H2o*+!+ejq&GB=QB5v8RLvsxS5+A!Fyrg6BgXFMFH zU1oD_2Oa_>rEN?qA5P^%-n@5g?B?phr9PGn$9AJY5EFSmy&iOE|&5hx!Mn#pR3Uv!a@LI&J zq%tWnka{am&*A6=$YGGjYr*d3Sw-X4NMtBtGVzjDiJAl2A4e#CMmP@VhMSHjs>7(a zfdOZ=4TBRCE(-4VD*z# zNh(HQII#jfxCV$lxmp3EqFpFWQeJ%0*)b-aH-jFBrw{!67eD=9C&%mW>RMmyLSDYx zGU~E7uF&UuYdh|S;_p39XKxz!cadt_e!P%;ys$X3Siq-{dv|Z`^R4UKlv5Y=z%1+@ zT=GtEO=+`E_iR4xW&D0Bn{tHE6v&R2E?+vlus*jxT%P;=8c3=`R_hG-OECfjW_3T= zPg;3$4PWj9S6>^G2@3&;uJJi?0}p3i9MniPY$iYC)9}bDkya|#i?t@ToG;`^)uxmI z_r0}0E>h|e=s%+8UN_JTpo+*G3h7{s9Xe-iEtO5{vi|YWHI_Q?EVjRYlif4BmPgLQ z>T!jYoavH1)lq^(R`gDUeRmf<6J}Q%sy+8#&5c}n90w1sFlQL~>ae)GKeyxYhIQVW zM5?;lHjhcXY#3p4MYAsa-w~oxgIO5BaN_eDxeR=1;b>>`X#JL;rw2bO&{FOs8Plo+ zQf{0b0zk%MrkFMoAZ0k}Ds99>YV=Jp#5QhU@|=Xv#ZCq6h2Y}~v{g#uI38C9Gd+1? zxC$ZScSMNwpty_b@C;hpXh@0M=J8`B9OfFjCdJSc8gY=zSpDkxRd9?B{(kH~FyAZa z!!CB+(RY0VCw3lF*H)a+s_dP(yBjiYQM>0QWGBDP}(GzkarYYh?rCjHA)TGl%*)e+wBj>RD%j*Ti5V^v7;VTf=%W*<20$3;%Gm3?J zlOzc}HNCV-5@Z{VVu{9@F&K@Sq!{pE=*Y_50dQfE$BVg|02I@OZaG4kq+6^}6Odaa z;N4*RBDFMvo&-k$qj$7n?r~y(mA!#SccmE@n(Z@r?@Sh0#npd5V}rQr{*_Z;0anYb zz`~^xqOu~w6uZvjY_q#uEr4TE@DPxe!51$Be#O$n3)lA2X5IF}@-CCWX`*d57l!%R z;Z1A22%siHc0@IfaJ7wULx_KQe-0;v-TgX#Eza%iPWOA+R(gyinvjheG#rglD}f(Z z3%R(^3`%2wi@24S(aVw?+yN%ORm_)T+8GQ&#w!ScAhd{^xTFlqd>kbqtJ4}S2Eu9) zHPqF&wY56f$(V^SokFQ1p{VxK9@-YxnE@;UGI@0sTW8mP9~wi;iw|FTcyS%OpWDha zB!GE}Lbj|Mt%P_5DQ1P#h&Nt)6 zYsY*Wlq$jrue!#I`b1^n@eAu%7ykc^KexUDqw85c*)LNf<(4b8e6%5CVw7xf)$xg> z*raWeD0qA$8NgeYsPr5XnuBhAl2m3C3Tu$i5M;Qi0Dw7Z4`kr zK!kKcI^5`V=&EaR--XjUGt{nXY&Is%i~`fK%C3X!7w)*w*N2}5O!7PSE8BU*qzLzm z9yTy#7d(}{$fQeYJThz@3r4@(_tSxYaOTE~*AMbuzc;R<<90e89S*r@q_1=~)la(+ zEhBjy1Z437yYMX*3+osDTd%;wtv-A1Szl&I4q(PF zEfa`Qs?cOepMfMn`inQ25X%Y`G9^c*!iZ|fOrsnrsy_+8CQ_?J^}@Qk`V&esWcS0T z?}tq7zBe1wRm3u|$%YjJCjVH|9;3N5W-KqF8E42=ZL`tE!E6Yj>*y#N ztOxrnIe#7d1ylY1H~-jeET0hs<)NYB3<->wMr?v`a!^22srWeQZiyRmb9_~VgtnxZ zBr{grX2{mH@*vO`$tGEHIO*o|2m&U-=gZ|nk@}=sWR#?o1kQS6Rr6_J>RN3;*PzMc zBv6-z;+amD_QO>FJ?>bWM}3RzT3*Lz%j-{%tx;YxlP(YX(_z*@+lpx_no6g!^|7(t zo9ve^!?7*w>ZZf~)w184&Fa9i)PaXVowqyB!=WO4s2U& z`}haeZNGrI%5t+oc4C7%nM}q<1xm<^LtwEd5X1$57p=~iK;qZCwI;ci-^7>mtuk&V z7AwRJG6fF0M#fVK|EZ!VJQA7~*Am03C)o*upc9*$){oeO`@BQBUy>GX__i|0_qxU@A z`VA0BaO}62r>6&Z{`>$Zf~e+$r#`s&q;ws83sR6>2q=JcnBErJd+5`V>8+qI`1Dl_ z*f{||eGb%Xgsqhn-L_CnHaWyFU0(N^YZFz~xnwL((xgBg6131ZdDYSl70^e|Z~^jp8?99- zf+o;bJW~dCD#F$h5hBYll9cI)w3yu^67@um1tC;_QQQT8bOYyu(^yQQB0NG5>GIQC zPle|QpnLVzPjSd)tqT9Q6S7TL@bj8eeFwdl;kI#8rmG>0H)Q1Re7XuZcm@DCo(4-) zj~klk^ma<#uG89G-MDeH1!KQC4FUD&;%Dp?JHEH)XYoB;e?Y|w1?$mx0Y#^vrX?fQ zqtl!*Xu9KTa-8C66UjQsg?C-g4=l?9&M7uW>frFAgi2F-(J;6HYLNs{iKeJYSgK9T zr8&iBscd$mg9nth#gMSt9-+@-G+Cmz;TXmYls`pZ%h~y@5ASUpD(BB{?BLwo)vkxQ z{~c{-YZvRC(#}XL4@2>2Yk4+Z{sKMp;mLPj;_rTIhz$nA<8XdJ8Bn^l9$qe|wKZ*M zr)Y?T(sp?YY4*jR&qA*K=dZv1_1Di2W9#AGANT_&9{xUB9FEa2D;Rn^D&PT(SI`_T zHwRsKZK@c>u2E#hT}PFfE5y=dJgz25lgiJefdM~=dr{z%JV;$?u5*CIL%bP=}=a;KtaNQrRra(og&9(q=AOpm(RTIf#V|n{_C_%XR z`Qbl*{R`#Sqn|GR{tGQ;5cB>T+WP@8eu3Yz{Y-O4xs;NQPnuA1Lh(UyLScZ?qQOwa z0OfT)Miyz3)77F%(O?+T_sbt};bLcGGDFtfT6E1_JCKFSmu+1pR;XDd5=H&d&L zcqs*s5a2dyVZHZYxI8*IJy?Eq=ZQC-1E+rZ%iS-ukIPsq*gLrU^_^YxnqS3XLR!)< zjR1|SRqICS?6Z$P`R0@BH~L$3q z7r*`S=bx`09o@e5+fP3}5N`eFyN@5e6>c8eKmBD|w2;NP$X{Zr8Rf50vTWwlF(xnB zU~CD#kkl#FQuRE*zI{lMvo@ut^-!PndX7}{r`J#6M}Toh_aw@% zzVPaE&mBGYI5a3vUHlztxc_+Y=--V$fsrJ4ep)WnisfZvYt#vXdL6<(I$bmisv-%D zO`uoOR%C@UY+)eKFGb^AnpTTNGuE`oLDW!r-t&??i;@h-`f`QGu5-`lG8y!gAF4DjR0kRMZr@qvaw;kP1C+&JGI({(3E~=Skg5 z+l(=;*n%2Mb_oflPMh5Ugn-#ZHkFOU3n9$0IjK`ACjmQXGaKY z?%etiQT62)UmxGRQG&TwtDS1Kj7Je+?8x+9Tn|rk2aOq>P6q)&38~61Dwp^k{;)O* zJ=(}&=JAcncCNjJ(q65f(`q%xA32bghorz0w{hKHeeRxVFYxE>7cMU^PoKb%W9!XO zzx>6szug{>Ay=llZ9bXL<5n}Vg22rXttxSvXdVs@JsIu-`&)a=O}WRIeOAR@%9G<+1wx4{g0&-FdHH#U3>@gCLH<8@TB09RkftxYpb7 zgIDWULwRX+jz;BNVN%KE_P6KPM-V9ew@y!C?>Of%_USGU4(@)t7#}T;76%6t*!x%C zo_~D6T#HeraN>K>sMl*-oJw9Jl>##`b(0Vj+6Kz2a*QWwb<7E~cH50c3rT{@>*z2{ z32KVryL8BNVwwp@Nlm_zVY8vZ1L{Yt?>iPhvCzC#^H$EvIreV`r@vof>p$LUVAe}( zRc^pi{mzbtG;F<&Q-1{M>mztD?S2ptRdBiZyc)p3N4K164UoBAV-P1rH}{BoW@BHh z?>!x^{mnW?=P8r9+^~Eg%OYF{;TkuWFQKb;arVbwf#tdjkW<{@?Ci&jPY)Kcq9CPa zi8c~5j`P4srf6N^lAK&Y=4Oz#>n16~hO(P#Mp>av%5BC-n+j!CKzD$++Cgh>D{SRyg&fsye_-o(ZbBW_DpxnJS7GpF$SF{| zz&pR#`Mrf_xe%OUVaRhCugtu>D?(az72qkNBO8GuRhQ;_Jm#T_Vou!KM1?a zH;}Z!WLJ~c)L#r2i_vl<24F1Ce|qEHJ70h}L_=G@-$DK{*N|?n=N{X{E8&lBJ-WO3 zc7N+JaZ7_veib;Hd!<&p;y7Zb-`^CsH|n_^dMTx2e32K}!R{H+()Oe}DPz-F6(zYjeEdl^$kpscN30$e0ZZPK^~6 z@a)21aOfL4MX8(_L);S?FwL1ODAyz!t>e1dmQB_~>PrhsC6$%3y`CZa_C!HYlj-O7 zYAlE_ZwklO3be)u*wn%}-%o%1;KOG>Z2-A%0LXTyqsAy0l}BQ~ysm9uspFZ7^7>Wa zeHf(y=5WzR>)Ya^b@3r>Tg-@&TneEb7&2$F?ztd$!MF?VcLq``uvZ}K%uAEWVm=8-l#|wg*Yin&Mq?daA$SEE=()TW4@=J343&{s#}A~& zy*URCu(wlNIhug%?Y9r#ci$gU9pz58+YW^{pz9 zZY7Gl;GH&iVC$Rv;W$jhii(&KuB2Fz&y3g&tlUOve}6yq{A99x#-A0erWN?hMH2=O zg_kWi7nUx&NYavwKpFn{`?E3K_GDfj$B9^)_GgwW@LW3S@j8*`p?5L~({!i&6CNl3^kx<8S0G8(+tSyD5tbJO3o%3)HK>lmIX^kWjQ-;rVwesJ@p$Sr{@hV z%UL!cL74`~C*M6EPMzbDgj5SI`8q~-Yfwf$(g(5i8s3lYzo*sj7eVH?MlH+Hq$^@) zd*oo-`?>u(n9pr7ThHw5Z{*P2WP%Epn7zzC5Z;-%!D0f7p9PDtbvTADbul*l1@8Dj zE)-0@?dyUfnZ7Rw7G&y#AMd$QQgta$p4f8CZO0-M4JEUU!c(!yH3x<+I|2h>i^i@+ zT+e_JA!ubN5*2xp(IpTWN=%_BHu1_N5*bj2HJ{AUNvCzfn5SV4{YFsr8h!9aD25!I zfB4~#A0Hq0!)~_Px`&X|Z(Q;EAl2AXsfM=t{^pKWeOj!C>WY@^^u6`|_KV`))4e(l zoXPPWB#C^*scndxn|pxwM7GNoC`rhyIlW%n_bssOiohEK|73h}B+H9yNnQ!8=FIYK zo}keY>bgwNx5m~$kldcsW?WTJx?IJkRLbNqx}i&OwhrqVOhDe|i*YVmk-PFtYQqtN zsRY(jN>>$BicC^0#8Ujk=sv>}1S`D~N#IXuUYX2&WNniMme+Dtojzn{%ex=k`gU=1 zQR7>UPNy^ywd*Sw{Q7IJq1_M*I#Iy;I$lq|TGcQKM%+U6w!B%@#Lj#)8cCyQB1ejQ z<0=pyA=MngBL?Tx_xBPKV@$?lO844|tEdJ#95GGokSom0@R^4q9CKkjwr$oX;+*Tc zV>Vjwe2Dv8zg|=2gE+Mq>V7e z9;mk4uf5ja-0EW(hSq3iOrGjA_@**rT$s~2i$z~T`8hdku`i&%`+tj|qYpaNs3l z(WE3PNLyzzqY|?w*-Yk(BnS+l;M+akgwiz&}U@7Q?QWT}=tit7$bRukmqULN90$RTVB`UY5qa*s9xR2McYi$hM&i~E4prOsJ0oRM5gWb! zQ1qOtr-hFfR2!YGRJDUlESQc&shUf?oQXV?%E61XsZ=(D>ZVuQ$Pl@DCYS3}x*&^y zJM3PD@dR`XFrEk5`Qga{R2*cIv7&83m>HB2c6}FJANu7&P#6pONbwbD9nxxEiI{Vl z7u+_vM)6UBJ0y}S?z#}|mG31xwKz`?j_4Pw@qY7=BM-ELyZUMi9&72RN?G;3QrPtGA&PU8d(y&|)MAk$G2 zF+6AH2b4AI>M=3~^(Xq~6nM;J3^NU4#U#yBf=#FbB(Efcep*U5Q{z;HsnF0&xILnB z)?9{Kai1NHY8`3R8_mzgH-jTopT219=YVIuvM81T@uNBb3_)2AacXTlA?|fHLt0Y| z|1&4To!7TSQ9~gohkvqr8{sUpST04Z3E?MSsjv)~;l%SE%AMB))~o3 z)-nhtN)A!?Ry~2|^dzmsd$qZg%T+p(S7n_lsLhc!!jPY^bej}wUO9s?{<#_gyfu@Ev4vb2#*4xizdX^%)ETV1Nvd5URB1~u=FVlvTqmOFeA;7=$78UE*t=saXJmvTiqJp-X$Z}_G!jXXl|a!J2(nN{ZxIp&$jvK3 z;@@(d1q$v<#(BRM?|Uh~`ugQ-WGQePH-yKC`)cBbLf^fISFq3S zKKb~=4-wF-xI`MU_3CgJsn2;9l{m9`KA?=uuAhGWvic(eA{ z4`~#gyc>2eEpbw8IVmg==ii33iFD+kj^Yg`d3-Q#vqmp}e0=(H_@SvDpK*!$c>nNz zh8t7-^2he~@1MVTzxd?-^ZK(-KF2L+K8nAEJ|jgTPi1$X!kb@bHU56T5I%#fe+YxN ze}fpf`?`4fVe`@)p0^vm(S?l*Nc1>rV;*pQAlqKjJ~}=cGdbp4pYt>NuH3f?lZb%J z3e^rg{5tCZRIa%~A{qg|47p`BCO^PkhIAV!b;IiESt99qq_zzp4`Fn9x+I zBp)J%|3%MQVoz1N9iH|?NGqt`pi0c2t2CyjE{`v@c}e;G;qcStx9#)OSMMG_e;41Y z_?!aJx8HvI?pG-IVfUZjEr6Gsqd(l;;u_Fv4Bvc%d&OsqmaXa)%H-@NTiLJc`h^yX z zdbo>>9#4yxG~&4x-VdcTG>^dWq?!z+~;V$UdQhi!-Wo9r-Q9N z|K=NP$SRHs1XK|(zomaMvVy;bXh;#`Js$4{{v)cqyEvoHw#p{)x^MRVunsPlEZ@E9 zFYA-s zxqI)E?-n7i@38^cgazBb&$zCSXoK*jpab>QT)(qU@V(=;y3OG+0&9J{2~IX|hm(b2=8MRE(@kPy}(F2o+qxmnupIO&6Evx6WT-~E0yI-hH7RWf#`y1iEx%+g9`5Vta1?`uUU<6zYuh;Qnw5~VD zto}61ZeB+&*%U>gNfbp$sFR6`JO#aXsdYq-Y3}n&yM7Z`+f`MUKW%@!ti^K@#UVJG zd$TJ@KTW}Cn>_EDB%=92g^=?#@x2(V?a{bJt(hvK8|l!YCqxG+o#*SOqq2n`8_C#^ z4;>_iYzXHdSUf-k8$u!~j`N(YNKKE$0v*5S<3qDRN2wL5&ft9CKeZ5|dgpws_GGhEoPujA;bY?P0 zZOf`I?(He@e!n3ifBW@f{vaML1N{f7;7 ziu|@ui+gm|85j+;48AnRtTg-zS3hK*!o#nYEite>Rtwt^)DZ}@i6V68*a|$x<0BDV zD99Y8)(Xb#X~LXVhQO?)v>;4*-(8}^o^>6rR$O+;d8kTBtvh(p(H(JvGlw~Q+*Kay zpAtnFE=CM*8YKNKKSM1g`nKiL#g(?2vVv4mCq_x7c0nPuP$rzfJkljq|3+{wMhA^0 zR+54ja3C)!jpGP@B~QasTGUH$-!1GOfnkM5gkiDct3lu5qBbToc(2G_zvfuP$7MHT zQDC6Q@vCKS!U)WAVxfGeDMElF6s5C>b!j347WJPp4L##x_sSWaw>=dHvAUeeFD*#TiIR&DsL3(3mJNkic0@xc9BCP=5XOSI@|Z z1-2^QC4PhylQ=sG`=)l0<~(4#4v;J3P}2B4BE;?U{%i)FwrpnE^-Z%oWV4$NIiZTU z&@wtp>ilk3@`85~6`Y0?Zo@sEqi*DS7+f@~s9 zSLGu2uvK=2-7Uk6C+y)qzQ5@}nSxFNpbL@RUBMO}ixH>Tg48uiC8|`jF%#p81veQ= zly8F*mhhd=&zr;g@K?8f6ts|?SNxE_iTB^x}tLrx2Nn-?w(nPdEFv24!tyhdyL9o1I!nP5lXY@qM1v-L~$JEeG z_gEYe#4cOvk*mm#6tEV-$5kf8Gr}8|&8DW=JexV2R|Vb!cDPn+3X3?BxQpllT}LDV z+xf^Wfy;6ygya(LzzK&mWm)UhroXh@SImMK3N5yWzKPQ`MGbS8&BTo6Rz~5lgYwP3 zP>uI|Pu>hxczy3zm2$9i6GdZV?d)bpgo`&X#p8bDD}0 zGTU)!Rx6#+Xk71_$RNwnhlSV=={@?IMdmQTOtGl-t#FA;TECjjU_ig5bOWOnLuO`C zj%@Ka>f1;(xnG*`nM#KjmTJ9pFG-Mur*HTBU@hl)*Qtn%p;f!C+%9rZU&pB36Qhl2 z0LQJX)=zBvsqfOOHWdCK0&~s`X4+a zNklAA1HZ9x1a~BoX4y*>(He=2KESRI_Bv zO}HKBfU|~1NdihUCL=0k#h8%77zwQrl12#Q{_^JW(F@;oETrH-dx|2%(abf%0mW$M zGF|6P(wX=rE%oc6iCWo`wr3Z;-66M`XrevpqH7eWmO5(k#L3x6m^)4qE*C@z)$WxF z%0pkfrh&q=*4oqy5W{FJ*Tii^Gl6glYr2S*)gb z^9Ehqju71?)@5)}Btw#%#!)6nZcY(!KRD?GZ)~^gd7CUxwP;W-tO|m(QahFo+olkj zGCI{=!nt%aBP6MsCK+r;c+dY7jhqT*g{sf9OXjP)LzZMNrU?AmOok{)4T)@`fHPF8 zYV+0-+aby<#Lh|0C>BfQ0=-t0E72ttv?2#Z$@KVo0|dptBKom z3v>mj3&VgIcXeKGY-ArdDSJIV?6g2^iZ%4%VmXac@YcUt}E&?3f9K0 z9+)o-D-v9cT(8O7OUS2Z&fvD?`w=rFIr0@!YQ~hj(km5AU#FD`-cHlR6pAJrN#1*} z+JZo77-Viz3k2%SVodA*pwF++VgEq~?8UHjvK%5n7q8GU0ev;L%(g%WLipA?Bw4Hw z!pm@GA_igJiefrmwn?8Scz<7YjdHFT1|^ZdRYzhwN$%s!nXaj>lhKTkP50uNKUz`_ z{!H?<8-jl>wpCP_2X@s7ul=1t+Qi0B*20g5GBHuRH11wN-58oBMIr))cUG#Uw0d2u z`zJ!pe1nb+_&;>0Hvlh~WdzNH0eT^D{vYW2)$6zE3=|&FC36;D4?#+8*sSR^P7~fI z_+~>o%D_4#@y?E_^IWw|AQ)}L3f4NP6D2L3qeA6L6wQ-zqvs;`)+V$kz6x8Nzljo= zEv2uGI;;Soslz8{ji84Uu~NA#lzD|%55#d5>;gTYRj>}wDOU84*TW3_sBf;>40#I~ zeT7~da9A(U$zqNWetQMS3!J~117wY-SdPGX#0VD#w?KEV(5ap*1y$hfA|6kHB|t8^ zG4Y)ejZa#pFmG#_pbj#j?K}x8xe!80F+=6mx!JS{8wgvIzf__p8koI;Ac8$$)sn5Q z8nhzwJn67xcq5pCi-oW~bd$9qEHyk7sC5pkkEH$=Ix_~CF$qSqKwr$*8pyF^0u!&$ zg?)uyup3^Oi(a8Kz1Yp`k#r2uCH}qtpo1J@C{ryF3?$__SN_~C#jYPJB?wb3!3>O9 s>SmKTFz#xX%2+j_#T4;&ea^-9Z+8#z7el$et^fc407*qoM6N<$f?|Tx;{X5v literal 0 HcmV?d00001 diff --git a/vendor/github.com/go-playground/locales/lrc/lrc.go b/vendor/github.com/go-playground/locales/lrc/lrc.go new file mode 100644 index 0000000000..234fb343f0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lrc/lrc.go @@ -0,0 +1,588 @@ +package lrc + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lrc struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lrc' locale +func New() locales.Translator { + return &lrc{ + locale: "lrc", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "جانڤیە", "فئڤریە", "مارس", "آڤریل", "مئی", "جوٙأن", "جوٙلا", "آگوست", "سئپتامر", "ئوکتوڤر", "نوڤامر", "دئسامر"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "جانڤیە", "فئڤریە", "مارس", "آڤریل", "مئی", "جوٙأن", "جوٙلا", "آگوست", "سئپتامر", "ئوکتوڤر", "نوڤامر", "دئسامر"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ART": "ART", "HNPM": "HNPM", "SRT": "SRT", "HECU": "HECU", "JDT": "JDT", "WART": "WART", "EST": "EST", "GYT": "GYT", "CHADT": "CHADT", "NZST": "NZST", "AST": "AST", "EDT": "EDT", "COT": "COT", "UYT": "UYT", "CST": "گاٛت مینجاٛیی ئستاٛنداٛرد", "AWST": "AWST", "AWDT": "AWDT", "ACWDT": "ACWDT", "NZDT": "NZDT", "ADT": "ADT", "HNEG": "HNEG", "HEEG": "HEEG", "AEST": "AEST", "BOT": "BOT", "ACWST": "ACWST", "MESZ": "MESZ", "AKDT": "AKDT", "UYST": "UYST", "MYT": "MYT", "HNT": "HNT", "CLST": "CLST", "HKST": "HKST", "HNCU": "HNCU", "PDT": "PDT", "MEZ": "MEZ", "MST": "MST", "HNNOMX": "HNNOMX", "HEPM": "HEPM", "LHST": "LHST", "CDT": "روٙشنایی نئهادار روٙز", "CHAST": "CHAST", "HAST": "HAST", "VET": "VET", "BT": "BT", "HAT": "HAT", "ARST": "ARST", "ACDT": "ACDT", "TMT": "TMT", "HKT": "HKT", "HNOG": "HNOG", "OESZ": "OESZ", "WEZ": "WEZ", "WAT": "WAT", "WIB": "WIB", "PST": "PST", "WARST": "WARST", "MDT": "MDT", "GFT": "GFT", "AKST": "AKST", "AEDT": "AEDT", "HEPMX": "HEPMX", "EAT": "EAT", "∅∅∅": "∅∅∅", "GMT": "GMT", "SGT": "SGT", "HENOMX": "HENOMX", "ChST": "ChST", "SAST": "SAST", "HNPMX": "HNPMX", "IST": "IST", "CLT": "CLT", "WESZ": "WESZ", "JST": "JST", "OEZ": "OEZ", "TMST": "TMST", "WAST": "WAST", "COST": "COST", "WITA": "WITA", "LHDT": "LHDT", "WIT": "WIT", "ECT": "ECT", "HADT": "HADT", "ACST": "ACST", "CAT": "CAT", "HEOG": "HEOG"}, + } +} + +// Locale returns the current translators string locale +func (lrc *lrc) Locale() string { + return lrc.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lrc' +func (lrc *lrc) PluralsCardinal() []locales.PluralRule { + return lrc.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lrc' +func (lrc *lrc) PluralsOrdinal() []locales.PluralRule { + return lrc.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lrc' +func (lrc *lrc) PluralsRange() []locales.PluralRule { + return lrc.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lrc' +func (lrc *lrc) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lrc' +func (lrc *lrc) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lrc' +func (lrc *lrc) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lrc *lrc) MonthAbbreviated(month time.Month) string { + return lrc.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lrc *lrc) MonthsAbbreviated() []string { + return lrc.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lrc *lrc) MonthNarrow(month time.Month) string { + return lrc.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lrc *lrc) MonthsNarrow() []string { + return lrc.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lrc *lrc) MonthWide(month time.Month) string { + return lrc.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lrc *lrc) MonthsWide() []string { + return lrc.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lrc *lrc) WeekdayAbbreviated(weekday time.Weekday) string { + return lrc.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lrc *lrc) WeekdaysAbbreviated() []string { + return lrc.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lrc *lrc) WeekdayNarrow(weekday time.Weekday) string { + return lrc.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lrc *lrc) WeekdaysNarrow() []string { + return lrc.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lrc *lrc) WeekdayShort(weekday time.Weekday) string { + return lrc.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lrc *lrc) WeekdaysShort() []string { + return lrc.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lrc *lrc) WeekdayWide(weekday time.Weekday) string { + return lrc.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lrc *lrc) WeekdaysWide() []string { + return lrc.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lrc' and handles both Whole and Real numbers based on 'v' +func (lrc *lrc) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lrc' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lrc *lrc) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lrc.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lrc' +func (lrc *lrc) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lrc.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lrc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lrc' +// in accounting notation. +func (lrc *lrc) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lrc.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyNegativePrefix[j]) + } + + b = append(b, lrc.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lrc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lrc' +func (lrc *lrc) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lrc' +func (lrc *lrc) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lrc' +func (lrc *lrc) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lrc' +func (lrc *lrc) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, lrc.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lrc' +func (lrc *lrc) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lrc' +func (lrc *lrc) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lrc' +func (lrc *lrc) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lrc' +func (lrc *lrc) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lrc.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lrc/lrc_test.go b/vendor/github.com/go-playground/locales/lrc/lrc_test.go new file mode 100644 index 0000000000..b4f9a6c4eb --- /dev/null +++ b/vendor/github.com/go-playground/locales/lrc/lrc_test.go @@ -0,0 +1,1120 @@ +package lrc + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lrc" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lrc_IQ/lrc_IQ.go b/vendor/github.com/go-playground/locales/lrc_IQ/lrc_IQ.go new file mode 100644 index 0000000000..a7b9db8c7a --- /dev/null +++ b/vendor/github.com/go-playground/locales/lrc_IQ/lrc_IQ.go @@ -0,0 +1,626 @@ +package lrc_IQ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lrc_IQ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lrc_IQ' locale +func New() locales.Translator { + return &lrc_IQ{ + locale: "lrc_IQ", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "جانڤیە", "فئڤریە", "مارس", "آڤریل", "مئی", "جوٙأن", "جوٙلا", "آگوست", "سئپتامر", "ئوکتوڤر", "نوڤامر", "دئسامر"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "جانڤیە", "فئڤریە", "مارس", "آڤریل", "مئی", "جوٙأن", "جوٙلا", "آگوست", "سئپتامر", "ئوکتوڤر", "نوڤامر", "دئسامر"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"JDT": "JDT", "MST": "MST", "CLST": "CLST", "ACST": "ACST", "PST": "PST", "IST": "IST", "MEZ": "MEZ", "MYT": "MYT", "BT": "BT", "HAT": "HAT", "AKDT": "AKDT", "UYST": "UYST", "VET": "VET", "HKST": "HKST", "HEEG": "HEEG", "SAST": "SAST", "HNCU": "HNCU", "AWST": "AWST", "ECT": "ECT", "NZDT": "NZDT", "JST": "JST", "HNOG": "HNOG", "UYT": "UYT", "LHST": "LHST", "HNPMX": "HNPMX", "NZST": "NZST", "OEZ": "OEZ", "WESZ": "WESZ", "WART": "WART", "PDT": "PDT", "ACWDT": "ACWDT", "MESZ": "MESZ", "CLT": "CLT", "TMST": "TMST", "HNNOMX": "HNNOMX", "SGT": "SGT", "TMT": "TMT", "WAT": "WAT", "WAST": "WAST", "AEST": "AEST", "HAST": "HAST", "AST": "AST", "ARST": "ARST", "HENOMX": "HENOMX", "CST": "گاٛت مینجاٛیی ئستاٛنداٛرد", "ADT": "ADT", "GMT": "GMT", "WARST": "WARST", "COT": "COT", "ChST": "ChST", "EAT": "EAT", "CDT": "روٙشنایی نئهادار روٙز", "HEOG": "HEOG", "AEDT": "AEDT", "HNPM": "HNPM", "HEPM": "HEPM", "WIT": "WIT", "CHADT": "CHADT", "BOT": "BOT", "ART": "ART", "ACDT": "ACDT", "COST": "COST", "HNT": "HNT", "∅∅∅": "∅∅∅", "AWDT": "AWDT", "OESZ": "OESZ", "MDT": "MDT", "HNEG": "HNEG", "AKST": "AKST", "GFT": "GFT", "SRT": "SRT", "GYT": "GYT", "ACWST": "ACWST", "EST": "EST", "HKT": "HKT", "WITA": "WITA", "LHDT": "LHDT", "CHAST": "CHAST", "HECU": "HECU", "WIB": "WIB", "HADT": "HADT", "CAT": "CAT", "WEZ": "WEZ", "EDT": "EDT", "HEPMX": "HEPMX"}, + } +} + +// Locale returns the current translators string locale +func (lrc *lrc_IQ) Locale() string { + return lrc.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lrc_IQ' +func (lrc *lrc_IQ) PluralsCardinal() []locales.PluralRule { + return lrc.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lrc_IQ' +func (lrc *lrc_IQ) PluralsOrdinal() []locales.PluralRule { + return lrc.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lrc_IQ' +func (lrc *lrc_IQ) PluralsRange() []locales.PluralRule { + return lrc.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lrc_IQ' +func (lrc *lrc_IQ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lrc_IQ' +func (lrc *lrc_IQ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lrc_IQ' +func (lrc *lrc_IQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lrc *lrc_IQ) MonthAbbreviated(month time.Month) string { + return lrc.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lrc *lrc_IQ) MonthsAbbreviated() []string { + return lrc.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lrc *lrc_IQ) MonthNarrow(month time.Month) string { + return lrc.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lrc *lrc_IQ) MonthsNarrow() []string { + return lrc.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lrc *lrc_IQ) MonthWide(month time.Month) string { + return lrc.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lrc *lrc_IQ) MonthsWide() []string { + return lrc.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lrc *lrc_IQ) WeekdayAbbreviated(weekday time.Weekday) string { + return lrc.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lrc *lrc_IQ) WeekdaysAbbreviated() []string { + return lrc.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lrc *lrc_IQ) WeekdayNarrow(weekday time.Weekday) string { + return lrc.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lrc *lrc_IQ) WeekdaysNarrow() []string { + return lrc.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lrc *lrc_IQ) WeekdayShort(weekday time.Weekday) string { + return lrc.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lrc *lrc_IQ) WeekdaysShort() []string { + return lrc.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lrc *lrc_IQ) WeekdayWide(weekday time.Weekday) string { + return lrc.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lrc *lrc_IQ) WeekdaysWide() []string { + return lrc.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lrc_IQ' and handles both Whole and Real numbers based on 'v' +func (lrc *lrc_IQ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lrc_IQ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lrc *lrc_IQ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lrc.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lrc.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lrc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lrc_IQ' +// in accounting notation. +func (lrc *lrc_IQ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lrc.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyNegativePrefix[j]) + } + + b = append(b, lrc.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lrc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, lrc.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lrc.periodsAbbreviated[0]...) + } else { + b = append(b, lrc.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lrc.periodsAbbreviated[0]...) + } else { + b = append(b, lrc.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lrc.periodsAbbreviated[0]...) + } else { + b = append(b, lrc.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lrc_IQ' +func (lrc *lrc_IQ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, lrc.periodsAbbreviated[0]...) + } else { + b = append(b, lrc.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lrc.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lrc_IQ/lrc_IQ_test.go b/vendor/github.com/go-playground/locales/lrc_IQ/lrc_IQ_test.go new file mode 100644 index 0000000000..e8528e0053 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lrc_IQ/lrc_IQ_test.go @@ -0,0 +1,1120 @@ +package lrc_IQ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lrc_IQ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lrc_IR/lrc_IR.go b/vendor/github.com/go-playground/locales/lrc_IR/lrc_IR.go new file mode 100644 index 0000000000..223255fdb8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lrc_IR/lrc_IR.go @@ -0,0 +1,588 @@ +package lrc_IR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lrc_IR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lrc_IR' locale +func New() locales.Translator { + return &lrc_IR{ + locale: "lrc_IR", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "جانڤیە", "فئڤریە", "مارس", "آڤریل", "مئی", "جوٙأن", "جوٙلا", "آگوست", "سئپتامر", "ئوکتوڤر", "نوڤامر", "دئسامر"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "جانڤیە", "فئڤریە", "مارس", "آڤریل", "مئی", "جوٙأن", "جوٙلا", "آگوست", "سئپتامر", "ئوکتوڤر", "نوڤامر", "دئسامر"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNCU": "HNCU", "OEZ": "OEZ", "CLT": "CLT", "BOT": "BOT", "CHAST": "CHAST", "MEZ": "MEZ", "MYT": "MYT", "CLST": "CLST", "WIB": "WIB", "EAT": "EAT", "AWDT": "AWDT", "CST": "گاٛت مینجاٛیی ئستاٛنداٛرد", "SGT": "SGT", "HEEG": "HEEG", "LHDT": "LHDT", "SRT": "SRT", "SAST": "SAST", "AKDT": "AKDT", "ECT": "ECT", "TMT": "TMT", "WAT": "WAT", "WITA": "WITA", "∅∅∅": "∅∅∅", "IST": "IST", "NZDT": "NZDT", "WEZ": "WEZ", "AST": "AST", "HENOMX": "HENOMX", "AEDT": "AEDT", "HNPM": "HNPM", "HEPM": "HEPM", "WESZ": "WESZ", "TMST": "TMST", "HNNOMX": "HNNOMX", "HNEG": "HNEG", "BT": "BT", "AEST": "AEST", "HADT": "HADT", "CAT": "CAT", "ACWDT": "ACWDT", "JST": "JST", "HKT": "HKT", "HEOG": "HEOG", "EDT": "EDT", "COT": "COT", "COST": "COST", "ChST": "ChST", "GYT": "GYT", "HAST": "HAST", "MESZ": "MESZ", "WARST": "WARST", "HNOG": "HNOG", "ACST": "ACST", "HAT": "HAT", "MST": "MST", "HNPMX": "HNPMX", "JDT": "JDT", "NZST": "NZST", "UYT": "UYT", "LHST": "LHST", "WIT": "WIT", "OESZ": "OESZ", "ARST": "ARST", "EST": "EST", "HECU": "HECU", "CDT": "روٙشنایی نئهادار روٙز", "ACWST": "ACWST", "WAST": "WAST", "HNT": "HNT", "AKST": "AKST", "VET": "VET", "HKST": "HKST", "PST": "PST", "UYST": "UYST", "HEPMX": "HEPMX", "AWST": "AWST", "PDT": "PDT", "GMT": "GMT", "WART": "WART", "ADT": "ADT", "ART": "ART", "MDT": "MDT", "GFT": "GFT", "CHADT": "CHADT", "ACDT": "ACDT"}, + } +} + +// Locale returns the current translators string locale +func (lrc *lrc_IR) Locale() string { + return lrc.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lrc_IR' +func (lrc *lrc_IR) PluralsCardinal() []locales.PluralRule { + return lrc.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lrc_IR' +func (lrc *lrc_IR) PluralsOrdinal() []locales.PluralRule { + return lrc.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lrc_IR' +func (lrc *lrc_IR) PluralsRange() []locales.PluralRule { + return lrc.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lrc_IR' +func (lrc *lrc_IR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lrc_IR' +func (lrc *lrc_IR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lrc_IR' +func (lrc *lrc_IR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lrc *lrc_IR) MonthAbbreviated(month time.Month) string { + return lrc.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lrc *lrc_IR) MonthsAbbreviated() []string { + return lrc.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lrc *lrc_IR) MonthNarrow(month time.Month) string { + return lrc.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lrc *lrc_IR) MonthsNarrow() []string { + return lrc.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lrc *lrc_IR) MonthWide(month time.Month) string { + return lrc.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lrc *lrc_IR) MonthsWide() []string { + return lrc.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lrc *lrc_IR) WeekdayAbbreviated(weekday time.Weekday) string { + return lrc.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lrc *lrc_IR) WeekdaysAbbreviated() []string { + return lrc.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lrc *lrc_IR) WeekdayNarrow(weekday time.Weekday) string { + return lrc.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lrc *lrc_IR) WeekdaysNarrow() []string { + return lrc.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lrc *lrc_IR) WeekdayShort(weekday time.Weekday) string { + return lrc.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lrc *lrc_IR) WeekdaysShort() []string { + return lrc.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lrc *lrc_IR) WeekdayWide(weekday time.Weekday) string { + return lrc.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lrc *lrc_IR) WeekdaysWide() []string { + return lrc.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lrc_IR' and handles both Whole and Real numbers based on 'v' +func (lrc *lrc_IR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lrc_IR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lrc *lrc_IR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lrc.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lrc_IR' +func (lrc *lrc_IR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lrc.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, lrc.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lrc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lrc_IR' +// in accounting notation. +func (lrc *lrc_IR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lrc.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lrc.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lrc.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyNegativePrefix[j]) + } + + b = append(b, lrc.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(lrc.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, lrc.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lrc.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lrc_IR' +func (lrc *lrc_IR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lrc_IR' +func (lrc *lrc_IR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lrc_IR' +func (lrc *lrc_IR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lrc_IR' +func (lrc *lrc_IR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, lrc.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, lrc.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lrc_IR' +func (lrc *lrc_IR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lrc_IR' +func (lrc *lrc_IR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lrc_IR' +func (lrc *lrc_IR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lrc_IR' +func (lrc *lrc_IR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lrc.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lrc.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lrc_IR/lrc_IR_test.go b/vendor/github.com/go-playground/locales/lrc_IR/lrc_IR_test.go new file mode 100644 index 0000000000..92e4c28fbb --- /dev/null +++ b/vendor/github.com/go-playground/locales/lrc_IR/lrc_IR_test.go @@ -0,0 +1,1120 @@ +package lrc_IR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lrc_IR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lt/lt.go b/vendor/github.com/go-playground/locales/lt/lt.go new file mode 100644 index 0000000000..f7cc1c5a4f --- /dev/null +++ b/vendor/github.com/go-playground/locales/lt/lt.go @@ -0,0 +1,667 @@ +package lt + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lt struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lt' locale +func New() locales.Translator { + return <{ + locale: "lt", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "saus.", "vas.", "kov.", "bal.", "geg.", "birž.", "liep.", "rugp.", "rugs.", "spal.", "lapkr.", "gruod."}, + monthsNarrow: []string{"", "S", "V", "K", "B", "G", "B", "L", "R", "R", "S", "L", "G"}, + monthsWide: []string{"", "sausio", "vasario", "kovo", "balandžio", "gegužės", "birželio", "liepos", "rugpjūčio", "rugsėjo", "spalio", "lapkričio", "gruodžio"}, + daysAbbreviated: []string{"sk", "pr", "an", "tr", "kt", "pn", "št"}, + daysNarrow: []string{"S", "P", "A", "T", "K", "P", "Š"}, + daysShort: []string{"Sk", "Pr", "An", "Tr", "Kt", "Pn", "Št"}, + daysWide: []string{"sekmadienis", "pirmadienis", "antradienis", "trečiadienis", "ketvirtadienis", "penktadienis", "šeštadienis"}, + periodsAbbreviated: []string{"priešpiet", "popiet"}, + periodsNarrow: []string{"pr. p.", "pop."}, + periodsWide: []string{"priešpiet", "popiet"}, + erasAbbreviated: []string{"pr. Kr.", "po Kr."}, + erasNarrow: []string{"pr. Kr.", "po Kr."}, + erasWide: []string{"prieš Kristų", "po Kristaus"}, + timezones: map[string]string{"JDT": "Japonijos vasaros laikas", "TMT": "Turkmėnistano žiemos laikas", "WAT": "Vakarų Afrikos žiemos laikas", "HKST": "Honkongo vasaros laikas", "ACDT": "Centrinės Australijos vasaros laikas", "HNT": "Niufaundlendo žiemos laikas", "ACWDT": "Centrinės vakarų Australijos vasaros laikas", "VET": "Venesuelos laikas", "AEDT": "Rytų Australijos vasaros laikas", "HEPM": "Sen Pjero ir Mikelono vasaros laikas", "ACST": "Centrinės Australijos žiemos laikas", "BT": "Butano laikas", "HNPMX": "Meksikos Ramiojo vandenyno žiemos laikas", "GYT": "Gajanos laikas", "CHAST": "Čatamo žiemos laikas", "EDT": "Šiaurės Amerikos rytų vasaros laikas", "OESZ": "Rytų Europos vasaros laikas", "WEZ": "Vakarų Europos žiemos laikas", "MST": "Makau žiemos laikas", "HNNOMX": "Šiaurės Vakarų Meksikos žiemos laikas", "CDT": "Šiaurės Amerikos centro vasaros laikas", "NZDT": "Naujosios Zelandijos vasaros laikas", "WART": "Vakarų Argentinos žiemos laikas", "HENOMX": "Šiaurės Vakarų Meksikos vasaros laikas", "HEEG": "Grenlandijos rytų vasaros laikas", "AKDT": "Aliaskos vasaros laikas", "AWDT": "Vakarų Australijos vasaros laikas", "CLT": "Čilės žiemos laikas", "MEZ": "Vidurio Europos žiemos laikas", "OEZ": "Rytų Europos žiemos laikas", "ACWST": "Centrinės vakarų Australijos žiemos laikas", "COST": "Kolumbijos vasaros laikas", "ECT": "Ekvadoro laikas", "IST": "Indijos laikas", "CAT": "Centrinės Afrikos laikas", "JST": "Japonijos žiemos laikas", "AST": "Atlanto žiemos laikas", "HNEG": "Grenlandijos rytų žiemos laikas", "EAT": "Rytų Afrikos laikas", "SGT": "Singapūro laikas", "PDT": "Šiaurės Amerikos Ramiojo vandenyno vasaros laikas", "ChST": "Čamoro laikas", "SRT": "Surinamo laikas", "WIT": "Rytų Indonezijos laikas", "GFT": "Prancūzijos Gvianos laikas", "WITA": "Centrinės Indonezijos laikas", "HNOG": "Grenlandijos vakarų žiemos laikas", "ADT": "Atlanto vasaros laikas", "MDT": "Makau vasaros laikas", "UYST": "Urugvajaus vasaros laikas", "CST": "Šiaurės Amerikos centro žiemos laikas", "HADT": "Havajų–Aleutų vasaros laikas", "WARST": "Vakarų Argentinos vasaros laikas", "HAT": "Niufaundlendo vasaros laikas", "CLST": "Čilės vasaros laikas", "GMT": "Grinvičo laikas", "WAST": "Vakarų Afrikos vasaros laikas", "SAST": "Pietų Afrikos laikas", "HNCU": "Kubos žiemos laikas", "HECU": "Kubos vasaros laikas", "MESZ": "Vidurio Europos vasaros laikas", "WESZ": "Vakarų Europos vasaros laikas", "MYT": "Malaizijos laikas", "ARST": "Argentinos vasaros laikas", "COT": "Kolumbijos žiemos laikas", "AEST": "Rytų Australijos žiemos laikas", "CHADT": "Čatamo vasaros laikas", "NZST": "Naujosios Zelandijos žiemos laikas", "UYT": "Urugvajaus žiemos laikas", "WIB": "Vakarų Indonezijos laikas", "LHST": "Lordo Hau žiemos laikas", "ART": "Argentinos žiemos laikas", "AKST": "Aliaskos žiemos laikas", "EST": "Šiaurės Amerikos rytų žiemos laikas", "HEPMX": "Meksikos Ramiojo vandenyno vasaros laikas", "PST": "Šiaurės Amerikos Ramiojo vandenyno žiemos laikas", "∅∅∅": "Amazonės vasaros laikas", "HAST": "Havajų–Aleutų žiemos laikas", "HEOG": "Grenlandijos vakarų vasaros laikas", "TMST": "Turkmėnistano vasaros laikas", "HKT": "Honkongo žiemos laikas", "HNPM": "Sen Pjero ir Mikelono žiemos laikas", "LHDT": "Lordo Hau vasaros laikas", "AWST": "Vakarų Australijos žiemos laikas", "BOT": "Bolivijos laikas"}, + } +} + +// Locale returns the current translators string locale +func (lt *lt) Locale() string { + return lt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lt' +func (lt *lt) PluralsCardinal() []locales.PluralRule { + return lt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lt' +func (lt *lt) PluralsOrdinal() []locales.PluralRule { + return lt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lt' +func (lt *lt) PluralsRange() []locales.PluralRule { + return lt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lt' +func (lt *lt) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + f := locales.F(n, v) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && (nMod100 < 11 || nMod100 > 19) { + return locales.PluralRuleOne + } else if nMod10 >= 2 && nMod10 <= 9 && (nMod100 < 11 || nMod100 > 19) { + return locales.PluralRuleFew + } else if f != 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lt' +func (lt *lt) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lt' +func (lt *lt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := lt.CardinalPluralRule(num1, v1) + end := lt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lt *lt) MonthAbbreviated(month time.Month) string { + return lt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lt *lt) MonthsAbbreviated() []string { + return lt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lt *lt) MonthNarrow(month time.Month) string { + return lt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lt *lt) MonthsNarrow() []string { + return lt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lt *lt) MonthWide(month time.Month) string { + return lt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lt *lt) MonthsWide() []string { + return lt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lt *lt) WeekdayAbbreviated(weekday time.Weekday) string { + return lt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lt *lt) WeekdaysAbbreviated() []string { + return lt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lt *lt) WeekdayNarrow(weekday time.Weekday) string { + return lt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lt *lt) WeekdaysNarrow() []string { + return lt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lt *lt) WeekdayShort(weekday time.Weekday) string { + return lt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lt *lt) WeekdaysShort() []string { + return lt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lt *lt) WeekdayWide(weekday time.Weekday) string { + return lt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lt *lt) WeekdaysWide() []string { + return lt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lt' and handles both Whole and Real numbers based on 'v' +func (lt *lt) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lt.group) - 1; j >= 0; j-- { + b = append(b, lt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(lt.minus) - 1; j >= 0; j-- { + b = append(b, lt.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lt' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lt *lt) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(lt.minus) - 1; j >= 0; j-- { + b = append(b, lt.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lt.percentSuffix...) + + b = append(b, lt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lt' +func (lt *lt) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lt.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lt.group) - 1; j >= 0; j-- { + b = append(b, lt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(lt.minus) - 1; j >= 0; j-- { + b = append(b, lt.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, lt.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lt' +// in accounting notation. +func (lt *lt) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lt.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lt.group) - 1; j >= 0; j-- { + b = append(b, lt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(lt.minus) - 1; j >= 0; j-- { + b = append(b, lt.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, lt.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, lt.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lt' +func (lt *lt) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lt' +func (lt *lt) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lt' +func (lt *lt) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0x6d}...) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lt' +func (lt *lt) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0x6d}...) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64}...) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = append(b, lt.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lt' +func (lt *lt) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lt' +func (lt *lt) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lt' +func (lt *lt) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lt' +func (lt *lt) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lt/lt_test.go b/vendor/github.com/go-playground/locales/lt/lt_test.go new file mode 100644 index 0000000000..97823f94f8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lt/lt_test.go @@ -0,0 +1,1120 @@ +package lt + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lt" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lt_LT/lt_LT.go b/vendor/github.com/go-playground/locales/lt_LT/lt_LT.go new file mode 100644 index 0000000000..96855a48b3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lt_LT/lt_LT.go @@ -0,0 +1,667 @@ +package lt_LT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lt_LT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lt_LT' locale +func New() locales.Translator { + return <_LT{ + locale: "lt_LT", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "saus.", "vas.", "kov.", "bal.", "geg.", "birž.", "liep.", "rugp.", "rugs.", "spal.", "lapkr.", "gruod."}, + monthsNarrow: []string{"", "S", "V", "K", "B", "G", "B", "L", "R", "R", "S", "L", "G"}, + monthsWide: []string{"", "sausio", "vasario", "kovo", "balandžio", "gegužės", "birželio", "liepos", "rugpjūčio", "rugsėjo", "spalio", "lapkričio", "gruodžio"}, + daysAbbreviated: []string{"sk", "pr", "an", "tr", "kt", "pn", "št"}, + daysNarrow: []string{"S", "P", "A", "T", "K", "P", "Š"}, + daysShort: []string{"Sk", "Pr", "An", "Tr", "Kt", "Pn", "Št"}, + daysWide: []string{"sekmadienis", "pirmadienis", "antradienis", "trečiadienis", "ketvirtadienis", "penktadienis", "šeštadienis"}, + periodsAbbreviated: []string{"priešpiet", "popiet"}, + periodsNarrow: []string{"pr. p.", "pop."}, + periodsWide: []string{"priešpiet", "popiet"}, + erasAbbreviated: []string{"pr. Kr.", "po Kr."}, + erasNarrow: []string{"pr. Kr.", "po Kr."}, + erasWide: []string{"prieš Kristų", "po Kristaus"}, + timezones: map[string]string{"ARST": "Argentinos vasaros laikas", "WAT": "Vakarų Afrikos žiemos laikas", "ACWST": "Centrinės vakarų Australijos žiemos laikas", "HNOG": "Grenlandijos vakarų žiemos laikas", "UYT": "Urugvajaus žiemos laikas", "UYST": "Urugvajaus vasaros laikas", "HNPM": "Sen Pjero ir Mikelono žiemos laikas", "EAT": "Rytų Afrikos laikas", "OESZ": "Rytų Europos vasaros laikas", "ADT": "Atlanto vasaros laikas", "EST": "Šiaurės Amerikos rytų žiemos laikas", "COST": "Kolumbijos vasaros laikas", "CST": "Šiaurės Amerikos centro žiemos laikas", "JDT": "Japonijos vasaros laikas", "MESZ": "Vidurio Europos vasaros laikas", "HADT": "Havajų–Aleutų vasaros laikas", "NZST": "Naujosios Zelandijos žiemos laikas", "HKT": "Honkongo žiemos laikas", "HNNOMX": "Šiaurės Vakarų Meksikos žiemos laikas", "CDT": "Šiaurės Amerikos centro vasaros laikas", "AWDT": "Vakarų Australijos vasaros laikas", "PDT": "Šiaurės Amerikos Ramiojo vandenyno vasaros laikas", "WAST": "Vakarų Afrikos vasaros laikas", "PST": "Šiaurės Amerikos Ramiojo vandenyno žiemos laikas", "ECT": "Ekvadoro laikas", "VET": "Venesuelos laikas", "GMT": "Grinvičo laikas", "ACST": "Centrinės Australijos žiemos laikas", "∅∅∅": "Ako vasaros laikas", "AEDT": "Rytų Australijos vasaros laikas", "ChST": "Čamoro laikas", "WIB": "Vakarų Indonezijos laikas", "TMT": "Turkmėnistano žiemos laikas", "EDT": "Šiaurės Amerikos rytų vasaros laikas", "HECU": "Kubos vasaros laikas", "BOT": "Bolivijos laikas", "JST": "Japonijos žiemos laikas", "OEZ": "Rytų Europos žiemos laikas", "AWST": "Vakarų Australijos žiemos laikas", "ACWDT": "Centrinės vakarų Australijos vasaros laikas", "HAT": "Niufaundlendo vasaros laikas", "HEEG": "Grenlandijos rytų vasaros laikas", "AKST": "Aliaskos žiemos laikas", "HEPMX": "Meksikos Ramiojo vandenyno vasaros laikas", "GYT": "Gajanos laikas", "ACDT": "Centrinės Australijos vasaros laikas", "HEPM": "Sen Pjero ir Mikelono vasaros laikas", "LHDT": "Lordo Hau vasaros laikas", "GFT": "Prancūzijos Gvianos laikas", "HNPMX": "Meksikos Ramiojo vandenyno žiemos laikas", "WIT": "Rytų Indonezijos laikas", "MEZ": "Vidurio Europos žiemos laikas", "CLT": "Čilės žiemos laikas", "HNEG": "Grenlandijos rytų žiemos laikas", "AKDT": "Aliaskos vasaros laikas", "SAST": "Pietų Afrikos laikas", "CHADT": "Čatamo vasaros laikas", "WESZ": "Vakarų Europos vasaros laikas", "BT": "Butano laikas", "IST": "Indijos laikas", "WART": "Vakarų Argentinos žiemos laikas", "TMST": "Turkmėnistano vasaros laikas", "HKST": "Honkongo vasaros laikas", "COT": "Kolumbijos žiemos laikas", "LHST": "Lordo Hau žiemos laikas", "CAT": "Centrinės Afrikos laikas", "CLST": "Čilės vasaros laikas", "HNCU": "Kubos žiemos laikas", "WEZ": "Vakarų Europos žiemos laikas", "MYT": "Malaizijos laikas", "HEOG": "Grenlandijos vakarų vasaros laikas", "AST": "Atlanto žiemos laikas", "SRT": "Surinamo laikas", "SGT": "Singapūro laikas", "CHAST": "Čatamo žiemos laikas", "ART": "Argentinos žiemos laikas", "MST": "Makau žiemos laikas", "MDT": "Makau vasaros laikas", "HNT": "Niufaundlendo žiemos laikas", "AEST": "Rytų Australijos žiemos laikas", "HAST": "Havajų–Aleutų žiemos laikas", "WARST": "Vakarų Argentinos vasaros laikas", "HENOMX": "Šiaurės Vakarų Meksikos vasaros laikas", "WITA": "Centrinės Indonezijos laikas", "NZDT": "Naujosios Zelandijos vasaros laikas"}, + } +} + +// Locale returns the current translators string locale +func (lt *lt_LT) Locale() string { + return lt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lt_LT' +func (lt *lt_LT) PluralsCardinal() []locales.PluralRule { + return lt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lt_LT' +func (lt *lt_LT) PluralsOrdinal() []locales.PluralRule { + return lt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lt_LT' +func (lt *lt_LT) PluralsRange() []locales.PluralRule { + return lt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lt_LT' +func (lt *lt_LT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + f := locales.F(n, v) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 1 && (nMod100 < 11 || nMod100 > 19) { + return locales.PluralRuleOne + } else if nMod10 >= 2 && nMod10 <= 9 && (nMod100 < 11 || nMod100 > 19) { + return locales.PluralRuleFew + } else if f != 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lt_LT' +func (lt *lt_LT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lt_LT' +func (lt *lt_LT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := lt.CardinalPluralRule(num1, v1) + end := lt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lt *lt_LT) MonthAbbreviated(month time.Month) string { + return lt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lt *lt_LT) MonthsAbbreviated() []string { + return lt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lt *lt_LT) MonthNarrow(month time.Month) string { + return lt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lt *lt_LT) MonthsNarrow() []string { + return lt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lt *lt_LT) MonthWide(month time.Month) string { + return lt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lt *lt_LT) MonthsWide() []string { + return lt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lt *lt_LT) WeekdayAbbreviated(weekday time.Weekday) string { + return lt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lt *lt_LT) WeekdaysAbbreviated() []string { + return lt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lt *lt_LT) WeekdayNarrow(weekday time.Weekday) string { + return lt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lt *lt_LT) WeekdaysNarrow() []string { + return lt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lt *lt_LT) WeekdayShort(weekday time.Weekday) string { + return lt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lt *lt_LT) WeekdaysShort() []string { + return lt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lt *lt_LT) WeekdayWide(weekday time.Weekday) string { + return lt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lt *lt_LT) WeekdaysWide() []string { + return lt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lt_LT' and handles both Whole and Real numbers based on 'v' +func (lt *lt_LT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lt.group) - 1; j >= 0; j-- { + b = append(b, lt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(lt.minus) - 1; j >= 0; j-- { + b = append(b, lt.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lt_LT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lt *lt_LT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(lt.minus) - 1; j >= 0; j-- { + b = append(b, lt.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lt.percentSuffix...) + + b = append(b, lt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lt_LT' +func (lt *lt_LT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lt.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lt.group) - 1; j >= 0; j-- { + b = append(b, lt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(lt.minus) - 1; j >= 0; j-- { + b = append(b, lt.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, lt.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lt_LT' +// in accounting notation. +func (lt *lt_LT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lt.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lt.group) - 1; j >= 0; j-- { + b = append(b, lt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(lt.minus) - 1; j >= 0; j-- { + b = append(b, lt.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, lt.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, lt.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lt_LT' +func (lt *lt_LT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lt_LT' +func (lt *lt_LT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lt_LT' +func (lt *lt_LT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0x6d}...) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lt_LT' +func (lt *lt_LT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0x6d}...) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64}...) + b = append(b, []byte{0x2e, 0x2c, 0x20}...) + b = append(b, lt.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lt_LT' +func (lt *lt_LT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lt_LT' +func (lt *lt_LT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lt_LT' +func (lt *lt_LT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lt_LT' +func (lt *lt_LT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lt_LT/lt_LT_test.go b/vendor/github.com/go-playground/locales/lt_LT/lt_LT_test.go new file mode 100644 index 0000000000..20d56847dc --- /dev/null +++ b/vendor/github.com/go-playground/locales/lt_LT/lt_LT_test.go @@ -0,0 +1,1120 @@ +package lt_LT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lt_LT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lu/lu.go b/vendor/github.com/go-playground/locales/lu/lu.go new file mode 100644 index 0000000000..8a0818ef78 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lu/lu.go @@ -0,0 +1,532 @@ +package lu + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lu struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lu' locale +func New() locales.Translator { + return &lu{ + locale: "lu", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "FC", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Cio", "Lui", "Lus", "Muu", "Lum", "Luf", "Kab", "Lush", "Lut", "Lun", "Kas", "Cis"}, + monthsNarrow: []string{"", "C", "L", "L", "M", "L", "L", "K", "L", "L", "L", "K", "C"}, + monthsWide: []string{"", "Ciongo", "Lùishi", "Lusòlo", "Mùuyà", "Lumùngùlù", "Lufuimi", "Kabàlàshìpù", "Lùshìkà", "Lutongolo", "Lungùdi", "Kaswèkèsè", "Ciswà"}, + daysAbbreviated: []string{"Lum", "Nko", "Ndy", "Ndg", "Njw", "Ngv", "Lub"}, + daysNarrow: []string{"L", "N", "N", "N", "N", "N", "L"}, + daysWide: []string{"Lumingu", "Nkodya", "Ndàayà", "Ndangù", "Njòwa", "Ngòvya", "Lubingu"}, + periodsAbbreviated: []string{"Dinda", "Dilolo"}, + periodsWide: []string{"Dinda", "Dilolo"}, + erasAbbreviated: []string{"kmp. Y.K.", "kny. Y. K."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kumpala kwa Yezu Kli", "Kunyima kwa Yezu Kli"}, + timezones: map[string]string{"LHDT": "LHDT", "AWDT": "AWDT", "JDT": "JDT", "CLT": "CLT", "WAST": "WAST", "EST": "EST", "ACST": "ACST", "WIT": "WIT", "∅∅∅": "∅∅∅", "SGT": "SGT", "NZST": "NZST", "MDT": "MDT", "COST": "COST", "NZDT": "NZDT", "ACWDT": "ACWDT", "HNT": "HNT", "AKST": "AKST", "HEPMX": "HEPMX", "UYST": "UYST", "HNCU": "HNCU", "CHADT": "CHADT", "ECT": "ECT", "HEOG": "HEOG", "ART": "ART", "ACDT": "ACDT", "EAT": "EAT", "GMT": "GMT", "TMST": "TMST", "GFT": "GFT", "ChST": "ChST", "UYT": "UYT", "CDT": "CDT", "HADT": "HADT", "MEZ": "MEZ", "COT": "COT", "HEPM": "HEPM", "HNEG": "HNEG", "CST": "CST", "HAST": "HAST", "VET": "VET", "WARST": "WARST", "WAT": "WAT", "HKT": "HKT", "HNOG": "HNOG", "OEZ": "OEZ", "WEZ": "WEZ", "AEDT": "AEDT", "WITA": "WITA", "ARST": "ARST", "WIB": "WIB", "IST": "IST", "CLST": "CLST", "AST": "AST", "OESZ": "OESZ", "MST": "MST", "MYT": "MYT", "ADT": "ADT", "TMT": "TMT", "AWST": "AWST", "PDT": "PDT", "AKDT": "AKDT", "HNPMX": "HNPMX", "LHST": "LHST", "PST": "PST", "HENOMX": "HENOMX", "HAT": "HAT", "HEEG": "HEEG", "AEST": "AEST", "HNPM": "HNPM", "BT": "BT", "WESZ": "WESZ", "HNNOMX": "HNNOMX", "SRT": "SRT", "GYT": "GYT", "HECU": "HECU", "EDT": "EDT", "HKST": "HKST", "SAST": "SAST", "WART": "WART", "CHAST": "CHAST", "BOT": "BOT", "CAT": "CAT", "ACWST": "ACWST", "MESZ": "MESZ", "JST": "JST"}, + } +} + +// Locale returns the current translators string locale +func (lu *lu) Locale() string { + return lu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lu' +func (lu *lu) PluralsCardinal() []locales.PluralRule { + return lu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lu' +func (lu *lu) PluralsOrdinal() []locales.PluralRule { + return lu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lu' +func (lu *lu) PluralsRange() []locales.PluralRule { + return lu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lu' +func (lu *lu) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lu' +func (lu *lu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lu' +func (lu *lu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lu *lu) MonthAbbreviated(month time.Month) string { + return lu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lu *lu) MonthsAbbreviated() []string { + return lu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lu *lu) MonthNarrow(month time.Month) string { + return lu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lu *lu) MonthsNarrow() []string { + return lu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lu *lu) MonthWide(month time.Month) string { + return lu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lu *lu) MonthsWide() []string { + return lu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lu *lu) WeekdayAbbreviated(weekday time.Weekday) string { + return lu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lu *lu) WeekdaysAbbreviated() []string { + return lu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lu *lu) WeekdayNarrow(weekday time.Weekday) string { + return lu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lu *lu) WeekdaysNarrow() []string { + return lu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lu *lu) WeekdayShort(weekday time.Weekday) string { + return lu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lu *lu) WeekdaysShort() []string { + return lu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lu *lu) WeekdayWide(weekday time.Weekday) string { + return lu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lu *lu) WeekdaysWide() []string { + return lu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lu' and handles both Whole and Real numbers based on 'v' +func (lu *lu) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lu' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lu *lu) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lu' +func (lu *lu) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lu.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lu' +// in accounting notation. +func (lu *lu) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lu.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, lu.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lu' +func (lu *lu) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lu' +func (lu *lu) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lu' +func (lu *lu) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lu' +func (lu *lu) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lu' +func (lu *lu) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lu' +func (lu *lu) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lu' +func (lu *lu) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lu' +func (lu *lu) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lu/lu_test.go b/vendor/github.com/go-playground/locales/lu/lu_test.go new file mode 100644 index 0000000000..3507bf3972 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lu/lu_test.go @@ -0,0 +1,1120 @@ +package lu + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lu" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lu_CD/lu_CD.go b/vendor/github.com/go-playground/locales/lu_CD/lu_CD.go new file mode 100644 index 0000000000..f1e83be3ed --- /dev/null +++ b/vendor/github.com/go-playground/locales/lu_CD/lu_CD.go @@ -0,0 +1,532 @@ +package lu_CD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lu_CD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lu_CD' locale +func New() locales.Translator { + return &lu_CD{ + locale: "lu_CD", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Cio", "Lui", "Lus", "Muu", "Lum", "Luf", "Kab", "Lush", "Lut", "Lun", "Kas", "Cis"}, + monthsNarrow: []string{"", "C", "L", "L", "M", "L", "L", "K", "L", "L", "L", "K", "C"}, + monthsWide: []string{"", "Ciongo", "Lùishi", "Lusòlo", "Mùuyà", "Lumùngùlù", "Lufuimi", "Kabàlàshìpù", "Lùshìkà", "Lutongolo", "Lungùdi", "Kaswèkèsè", "Ciswà"}, + daysAbbreviated: []string{"Lum", "Nko", "Ndy", "Ndg", "Njw", "Ngv", "Lub"}, + daysNarrow: []string{"L", "N", "N", "N", "N", "N", "L"}, + daysWide: []string{"Lumingu", "Nkodya", "Ndàayà", "Ndangù", "Njòwa", "Ngòvya", "Lubingu"}, + periodsAbbreviated: []string{"Dinda", "Dilolo"}, + periodsWide: []string{"Dinda", "Dilolo"}, + erasAbbreviated: []string{"kmp. Y.K.", "kny. Y. K."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kumpala kwa Yezu Kli", "Kunyima kwa Yezu Kli"}, + timezones: map[string]string{"ADT": "ADT", "HKT": "HKT", "HEPM": "HEPM", "AST": "AST", "ACST": "ACST", "GFT": "GFT", "WITA": "WITA", "HNT": "HNT", "HNCU": "HNCU", "AWDT": "AWDT", "PDT": "PDT", "IST": "IST", "NZST": "NZST", "MST": "MST", "EST": "EST", "CAT": "CAT", "MEZ": "MEZ", "SRT": "SRT", "CDT": "CDT", "WARST": "WARST", "ARST": "ARST", "SGT": "SGT", "HNPM": "HNPM", "CHAST": "CHAST", "PST": "PST", "ACWST": "ACWST", "JDT": "JDT", "ART": "ART", "AEDT": "AEDT", "LHST": "LHST", "WIB": "WIB", "WIT": "WIT", "AWST": "AWST", "WESZ": "WESZ", "ACDT": "ACDT", "AEST": "AEST", "SAST": "SAST", "VET": "VET", "MYT": "MYT", "HNNOMX": "HNNOMX", "HADT": "HADT", "BT": "BT", "AKDT": "AKDT", "UYST": "UYST", "CST": "CST", "ACWDT": "ACWDT", "NZDT": "NZDT", "WART": "WART", "OESZ": "OESZ", "ECT": "ECT", "COST": "COST", "HENOMX": "HENOMX", "ChST": "ChST", "UYT": "UYT", "CLT": "CLT", "WEZ": "WEZ", "TMT": "TMT", "COT": "COT", "HEPMX": "HEPMX", "EAT": "EAT", "BOT": "BOT", "CLST": "CLST", "WAT": "WAT", "∅∅∅": "∅∅∅", "JST": "JST", "HKST": "HKST", "CHADT": "CHADT", "HAT": "HAT", "HEEG": "HEEG", "LHDT": "LHDT", "GYT": "GYT", "MESZ": "MESZ", "HEOG": "HEOG", "TMST": "TMST", "EDT": "EDT", "AKST": "AKST", "HNPMX": "HNPMX", "HECU": "HECU", "HAST": "HAST", "HNOG": "HNOG", "GMT": "GMT", "MDT": "MDT", "HNEG": "HNEG", "OEZ": "OEZ", "WAST": "WAST"}, + } +} + +// Locale returns the current translators string locale +func (lu *lu_CD) Locale() string { + return lu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lu_CD' +func (lu *lu_CD) PluralsCardinal() []locales.PluralRule { + return lu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lu_CD' +func (lu *lu_CD) PluralsOrdinal() []locales.PluralRule { + return lu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lu_CD' +func (lu *lu_CD) PluralsRange() []locales.PluralRule { + return lu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lu_CD' +func (lu *lu_CD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lu_CD' +func (lu *lu_CD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lu_CD' +func (lu *lu_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lu *lu_CD) MonthAbbreviated(month time.Month) string { + return lu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lu *lu_CD) MonthsAbbreviated() []string { + return lu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lu *lu_CD) MonthNarrow(month time.Month) string { + return lu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lu *lu_CD) MonthsNarrow() []string { + return lu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lu *lu_CD) MonthWide(month time.Month) string { + return lu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lu *lu_CD) MonthsWide() []string { + return lu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lu *lu_CD) WeekdayAbbreviated(weekday time.Weekday) string { + return lu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lu *lu_CD) WeekdaysAbbreviated() []string { + return lu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lu *lu_CD) WeekdayNarrow(weekday time.Weekday) string { + return lu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lu *lu_CD) WeekdaysNarrow() []string { + return lu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lu *lu_CD) WeekdayShort(weekday time.Weekday) string { + return lu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lu *lu_CD) WeekdaysShort() []string { + return lu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lu *lu_CD) WeekdayWide(weekday time.Weekday) string { + return lu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lu *lu_CD) WeekdaysWide() []string { + return lu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lu_CD' and handles both Whole and Real numbers based on 'v' +func (lu *lu_CD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lu_CD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lu *lu_CD) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lu_CD' +func (lu *lu_CD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lu.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lu_CD' +// in accounting notation. +func (lu *lu_CD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lu.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, lu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, lu.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lu_CD' +func (lu *lu_CD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lu_CD' +func (lu *lu_CD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lu_CD' +func (lu *lu_CD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lu_CD' +func (lu *lu_CD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, lu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lu_CD' +func (lu *lu_CD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lu_CD' +func (lu *lu_CD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lu_CD' +func (lu *lu_CD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lu_CD' +func (lu *lu_CD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lu_CD/lu_CD_test.go b/vendor/github.com/go-playground/locales/lu_CD/lu_CD_test.go new file mode 100644 index 0000000000..cbc4fadbb3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lu_CD/lu_CD_test.go @@ -0,0 +1,1120 @@ +package lu_CD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lu_CD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/luo/luo.go b/vendor/github.com/go-playground/locales/luo/luo.go new file mode 100644 index 0000000000..814e9284f5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/luo/luo.go @@ -0,0 +1,505 @@ +package luo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type luo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'luo' locale +func New() locales.Translator { + return &luo{ + locale: "luo", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "DAC", "DAR", "DAD", "DAN", "DAH", "DAU", "DAO", "DAB", "DOC", "DAP", "DGI", "DAG"}, + monthsNarrow: []string{"", "C", "R", "D", "N", "B", "U", "B", "B", "C", "P", "C", "P"}, + monthsWide: []string{"", "Dwe mar Achiel", "Dwe mar Ariyo", "Dwe mar Adek", "Dwe mar Ang’wen", "Dwe mar Abich", "Dwe mar Auchiel", "Dwe mar Abiriyo", "Dwe mar Aboro", "Dwe mar Ochiko", "Dwe mar Apar", "Dwe mar gi achiel", "Dwe mar Apar gi ariyo"}, + daysAbbreviated: []string{"JMP", "WUT", "TAR", "TAD", "TAN", "TAB", "NGS"}, + daysNarrow: []string{"J", "W", "T", "T", "T", "T", "N"}, + daysWide: []string{"Jumapil", "Wuok Tich", "Tich Ariyo", "Tich Adek", "Tich Ang’wen", "Tich Abich", "Ngeso"}, + periodsAbbreviated: []string{"OD", "OT"}, + periodsWide: []string{"OD", "OT"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kapok Kristo obiro", "Ka Kristo osebiro"}, + timezones: map[string]string{"MDT": "MDT", "HENOMX": "HENOMX", "CDT": "CDT", "CHADT": "CHADT", "OESZ": "OESZ", "WEZ": "WEZ", "CAT": "CAT", "WESZ": "WESZ", "EAT": "EAT", "MST": "MST", "COT": "COT", "BT": "BT", "GYT": "GYT", "ACWDT": "ACWDT", "HNNOMX": "HNNOMX", "AEST": "AEST", "LHST": "LHST", "CLST": "CLST", "WAT": "WAT", "EST": "EST", "ACDT": "ACDT", "CHAST": "CHAST", "BOT": "BOT", "HADT": "HADT", "NZDT": "NZDT", "SRT": "SRT", "MESZ": "MESZ", "HNT": "HNT", "HEPM": "HEPM", "HEPMX": "HEPMX", "MEZ": "MEZ", "MYT": "MYT", "WART": "WART", "WITA": "WITA", "ECT": "ECT", "HKST": "HKST", "VET": "VET", "JDT": "JDT", "HKT": "HKT", "HEEG": "HEEG", "SGT": "SGT", "HAST": "HAST", "IST": "IST", "ACWST": "ACWST", "GFT": "GFT", "EDT": "EDT", "ACST": "ACST", "HAT": "HAT", "AKST": "AKST", "WIT": "WIT", "PDT": "PDT", "HEOG": "HEOG", "WARST": "WARST", "∅∅∅": "∅∅∅", "GMT": "GMT", "ARST": "ARST", "HNPMX": "HNPMX", "CLT": "CLT", "HNOG": "HNOG", "AEDT": "AEDT", "HNPM": "HNPM", "HNCU": "HNCU", "JST": "JST", "ADT": "ADT", "WAST": "WAST", "AKDT": "AKDT", "COST": "COST", "ChST": "ChST", "LHDT": "LHDT", "HECU": "HECU", "AWST": "AWST", "AWDT": "AWDT", "OEZ": "OEZ", "TMST": "TMST", "TMT": "TMT", "ART": "ART", "HNEG": "HNEG", "UYT": "UYT", "CST": "CST", "PST": "PST", "NZST": "NZST", "AST": "AST", "UYST": "UYST", "SAST": "SAST", "WIB": "WIB"}, + } +} + +// Locale returns the current translators string locale +func (luo *luo) Locale() string { + return luo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'luo' +func (luo *luo) PluralsCardinal() []locales.PluralRule { + return luo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'luo' +func (luo *luo) PluralsOrdinal() []locales.PluralRule { + return luo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'luo' +func (luo *luo) PluralsRange() []locales.PluralRule { + return luo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'luo' +func (luo *luo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'luo' +func (luo *luo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'luo' +func (luo *luo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (luo *luo) MonthAbbreviated(month time.Month) string { + return luo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (luo *luo) MonthsAbbreviated() []string { + return luo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (luo *luo) MonthNarrow(month time.Month) string { + return luo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (luo *luo) MonthsNarrow() []string { + return luo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (luo *luo) MonthWide(month time.Month) string { + return luo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (luo *luo) MonthsWide() []string { + return luo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (luo *luo) WeekdayAbbreviated(weekday time.Weekday) string { + return luo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (luo *luo) WeekdaysAbbreviated() []string { + return luo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (luo *luo) WeekdayNarrow(weekday time.Weekday) string { + return luo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (luo *luo) WeekdaysNarrow() []string { + return luo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (luo *luo) WeekdayShort(weekday time.Weekday) string { + return luo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (luo *luo) WeekdaysShort() []string { + return luo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (luo *luo) WeekdayWide(weekday time.Weekday) string { + return luo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (luo *luo) WeekdaysWide() []string { + return luo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'luo' and handles both Whole and Real numbers based on 'v' +func (luo *luo) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'luo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (luo *luo) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'luo' +func (luo *luo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := luo.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, luo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, luo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, luo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, luo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'luo' +// in accounting notation. +func (luo *luo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := luo.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, luo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, luo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, luo.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, luo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'luo' +func (luo *luo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'luo' +func (luo *luo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'luo' +func (luo *luo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'luo' +func (luo *luo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, luo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'luo' +func (luo *luo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'luo' +func (luo *luo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'luo' +func (luo *luo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'luo' +func (luo *luo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := luo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/luo/luo_test.go b/vendor/github.com/go-playground/locales/luo/luo_test.go new file mode 100644 index 0000000000..795303def8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/luo/luo_test.go @@ -0,0 +1,1120 @@ +package luo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "luo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/luo_KE/luo_KE.go b/vendor/github.com/go-playground/locales/luo_KE/luo_KE.go new file mode 100644 index 0000000000..f0ec82a21f --- /dev/null +++ b/vendor/github.com/go-playground/locales/luo_KE/luo_KE.go @@ -0,0 +1,505 @@ +package luo_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type luo_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'luo_KE' locale +func New() locales.Translator { + return &luo_KE{ + locale: "luo_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "DAC", "DAR", "DAD", "DAN", "DAH", "DAU", "DAO", "DAB", "DOC", "DAP", "DGI", "DAG"}, + monthsNarrow: []string{"", "C", "R", "D", "N", "B", "U", "B", "B", "C", "P", "C", "P"}, + monthsWide: []string{"", "Dwe mar Achiel", "Dwe mar Ariyo", "Dwe mar Adek", "Dwe mar Ang’wen", "Dwe mar Abich", "Dwe mar Auchiel", "Dwe mar Abiriyo", "Dwe mar Aboro", "Dwe mar Ochiko", "Dwe mar Apar", "Dwe mar gi achiel", "Dwe mar Apar gi ariyo"}, + daysAbbreviated: []string{"JMP", "WUT", "TAR", "TAD", "TAN", "TAB", "NGS"}, + daysNarrow: []string{"J", "W", "T", "T", "T", "T", "N"}, + daysWide: []string{"Jumapil", "Wuok Tich", "Tich Ariyo", "Tich Adek", "Tich Ang’wen", "Tich Abich", "Ngeso"}, + periodsAbbreviated: []string{"OD", "OT"}, + periodsWide: []string{"OD", "OT"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kapok Kristo obiro", "Ka Kristo osebiro"}, + timezones: map[string]string{"VET": "VET", "ADT": "ADT", "ARST": "ARST", "CLST": "CLST", "CHADT": "CHADT", "COST": "COST", "HNNOMX": "HNNOMX", "SRT": "SRT", "SGT": "SGT", "NZDT": "NZDT", "MEZ": "MEZ", "MDT": "MDT", "EST": "EST", "HAT": "HAT", "HNPMX": "HNPMX", "GYT": "GYT", "WIB": "WIB", "WIT": "WIT", "CHAST": "CHAST", "PST": "PST", "HAST": "HAST", "HNOG": "HNOG", "HKST": "HKST", "GFT": "GFT", "UYT": "UYT", "BOT": "BOT", "HADT": "HADT", "TMT": "TMT", "EDT": "EDT", "UYST": "UYST", "HECU": "HECU", "OEZ": "OEZ", "WAST": "WAST", "HNEG": "HNEG", "LHDT": "LHDT", "MESZ": "MESZ", "TMST": "TMST", "HNT": "HNT", "AEDT": "AEDT", "HKT": "HKT", "ACST": "ACST", "AKST": "AKST", "AKDT": "AKDT", "LHST": "LHST", "HEPMX": "HEPMX", "AWST": "AWST", "OESZ": "OESZ", "WEZ": "WEZ", "GMT": "GMT", "ART": "ART", "JST": "JST", "WART": "WART", "∅∅∅": "∅∅∅", "HEPM": "HEPM", "CAT": "CAT", "WESZ": "WESZ", "MYT": "MYT", "AEST": "AEST", "HNPM": "HNPM", "ECT": "ECT", "ACWST": "ACWST", "NZST": "NZST", "JDT": "JDT", "COT": "COT", "WITA": "WITA", "HNCU": "HNCU", "AWDT": "AWDT", "CLT": "CLT", "HEOG": "HEOG", "WAT": "WAT", "HENOMX": "HENOMX", "ChST": "ChST", "SAST": "SAST", "EAT": "EAT", "CST": "CST", "ACWDT": "ACWDT", "AST": "AST", "MST": "MST", "BT": "BT", "HEEG": "HEEG", "IST": "IST", "WARST": "WARST", "ACDT": "ACDT", "CDT": "CDT", "PDT": "PDT"}, + } +} + +// Locale returns the current translators string locale +func (luo *luo_KE) Locale() string { + return luo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'luo_KE' +func (luo *luo_KE) PluralsCardinal() []locales.PluralRule { + return luo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'luo_KE' +func (luo *luo_KE) PluralsOrdinal() []locales.PluralRule { + return luo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'luo_KE' +func (luo *luo_KE) PluralsRange() []locales.PluralRule { + return luo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'luo_KE' +func (luo *luo_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'luo_KE' +func (luo *luo_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'luo_KE' +func (luo *luo_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (luo *luo_KE) MonthAbbreviated(month time.Month) string { + return luo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (luo *luo_KE) MonthsAbbreviated() []string { + return luo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (luo *luo_KE) MonthNarrow(month time.Month) string { + return luo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (luo *luo_KE) MonthsNarrow() []string { + return luo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (luo *luo_KE) MonthWide(month time.Month) string { + return luo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (luo *luo_KE) MonthsWide() []string { + return luo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (luo *luo_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return luo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (luo *luo_KE) WeekdaysAbbreviated() []string { + return luo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (luo *luo_KE) WeekdayNarrow(weekday time.Weekday) string { + return luo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (luo *luo_KE) WeekdaysNarrow() []string { + return luo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (luo *luo_KE) WeekdayShort(weekday time.Weekday) string { + return luo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (luo *luo_KE) WeekdaysShort() []string { + return luo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (luo *luo_KE) WeekdayWide(weekday time.Weekday) string { + return luo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (luo *luo_KE) WeekdaysWide() []string { + return luo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'luo_KE' and handles both Whole and Real numbers based on 'v' +func (luo *luo_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'luo_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (luo *luo_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'luo_KE' +func (luo *luo_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := luo.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, luo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, luo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, luo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, luo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'luo_KE' +// in accounting notation. +func (luo *luo_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := luo.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, luo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, luo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, luo.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, luo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'luo_KE' +func (luo *luo_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'luo_KE' +func (luo *luo_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'luo_KE' +func (luo *luo_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'luo_KE' +func (luo *luo_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, luo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'luo_KE' +func (luo *luo_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'luo_KE' +func (luo *luo_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'luo_KE' +func (luo *luo_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'luo_KE' +func (luo *luo_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := luo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/luo_KE/luo_KE_test.go b/vendor/github.com/go-playground/locales/luo_KE/luo_KE_test.go new file mode 100644 index 0000000000..5d46321de5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/luo_KE/luo_KE_test.go @@ -0,0 +1,1120 @@ +package luo_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "luo_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/luy/luy.go b/vendor/github.com/go-playground/locales/luy/luy.go new file mode 100644 index 0000000000..e7ee835d33 --- /dev/null +++ b/vendor/github.com/go-playground/locales/luy/luy.go @@ -0,0 +1,510 @@ +package luy + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type luy struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'luy' locale +func New() locales.Translator { + return &luy{ + locale: "luy", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"J2", "J3", "J4", "J5", "Al", "Ij", "J1"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysWide: []string{"Jumapiri", "Jumatatu", "Jumanne", "Jumatano", "Murwa wa Kanne", "Murwa wa Katano", "Jumamosi"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Imberi ya Kuuza Kwa", "Muhiga Kuvita Kuuza"}, + timezones: map[string]string{"UYST": "UYST", "PDT": "PDT", "NZDT": "NZDT", "WARST": "WARST", "HNNOMX": "HNNOMX", "HKT": "HKT", "WAT": "WAT", "AWST": "AWST", "PST": "PST", "CLST": "CLST", "ARST": "ARST", "IST": "IST", "VET": "VET", "ACWST": "ACWST", "JST": "JST", "HEOG": "HEOG", "ADT": "ADT", "TMT": "TMT", "AEDT": "AEDT", "EAT": "EAT", "∅∅∅": "∅∅∅", "SGT": "SGT", "JDT": "JDT", "MESZ": "MESZ", "HNOG": "HNOG", "COT": "COT", "GFT": "GFT", "CST": "CST", "BOT": "BOT", "CHADT": "CHADT", "HADT": "HADT", "HAT": "HAT", "GYT": "GYT", "CAT": "CAT", "HKST": "HKST", "ACDT": "ACDT", "GMT": "GMT", "MST": "MST", "UYT": "UYT", "HENOMX": "HENOMX", "WITA": "WITA", "AKST": "AKST", "MEZ": "MEZ", "WART": "WART", "WAST": "WAST", "COST": "COST", "OEZ": "OEZ", "ChST": "ChST", "LHDT": "LHDT", "LHST": "LHST", "SAST": "SAST", "HECU": "HECU", "ACWDT": "ACWDT", "WESZ": "WESZ", "AST": "AST", "HNEG": "HNEG", "HNPM": "HNPM", "HNCU": "HNCU", "HAST": "HAST", "WEZ": "WEZ", "EDT": "EDT", "EST": "EST", "HEEG": "HEEG", "CDT": "CDT", "AWDT": "AWDT", "OESZ": "OESZ", "MDT": "MDT", "HEPM": "HEPM", "HEPMX": "HEPMX", "WIT": "WIT", "ECT": "ECT", "MYT": "MYT", "BT": "BT", "HNPMX": "HNPMX", "WIB": "WIB", "NZST": "NZST", "ACST": "ACST", "AEST": "AEST", "HNT": "HNT", "AKDT": "AKDT", "SRT": "SRT", "CHAST": "CHAST", "CLT": "CLT", "TMST": "TMST", "ART": "ART"}, + } +} + +// Locale returns the current translators string locale +func (luy *luy) Locale() string { + return luy.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'luy' +func (luy *luy) PluralsCardinal() []locales.PluralRule { + return luy.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'luy' +func (luy *luy) PluralsOrdinal() []locales.PluralRule { + return luy.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'luy' +func (luy *luy) PluralsRange() []locales.PluralRule { + return luy.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'luy' +func (luy *luy) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'luy' +func (luy *luy) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'luy' +func (luy *luy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (luy *luy) MonthAbbreviated(month time.Month) string { + return luy.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (luy *luy) MonthsAbbreviated() []string { + return luy.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (luy *luy) MonthNarrow(month time.Month) string { + return luy.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (luy *luy) MonthsNarrow() []string { + return luy.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (luy *luy) MonthWide(month time.Month) string { + return luy.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (luy *luy) MonthsWide() []string { + return luy.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (luy *luy) WeekdayAbbreviated(weekday time.Weekday) string { + return luy.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (luy *luy) WeekdaysAbbreviated() []string { + return luy.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (luy *luy) WeekdayNarrow(weekday time.Weekday) string { + return luy.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (luy *luy) WeekdaysNarrow() []string { + return luy.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (luy *luy) WeekdayShort(weekday time.Weekday) string { + return luy.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (luy *luy) WeekdaysShort() []string { + return luy.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (luy *luy) WeekdayWide(weekday time.Weekday) string { + return luy.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (luy *luy) WeekdaysWide() []string { + return luy.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'luy' and handles both Whole and Real numbers based on 'v' +func (luy *luy) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'luy' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (luy *luy) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'luy' +func (luy *luy) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := luy.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, luy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, luy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, luy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, luy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'luy' +// in accounting notation. +func (luy *luy) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := luy.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, luy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, luy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, luy.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, luy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'luy' +func (luy *luy) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'luy' +func (luy *luy) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luy.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'luy' +func (luy *luy) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'luy' +func (luy *luy) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, luy.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'luy' +func (luy *luy) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'luy' +func (luy *luy) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'luy' +func (luy *luy) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'luy' +func (luy *luy) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := luy.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/luy/luy_test.go b/vendor/github.com/go-playground/locales/luy/luy_test.go new file mode 100644 index 0000000000..703744af73 --- /dev/null +++ b/vendor/github.com/go-playground/locales/luy/luy_test.go @@ -0,0 +1,1120 @@ +package luy + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "luy" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/luy_KE/luy_KE.go b/vendor/github.com/go-playground/locales/luy_KE/luy_KE.go new file mode 100644 index 0000000000..4c260d58e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/luy_KE/luy_KE.go @@ -0,0 +1,510 @@ +package luy_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type luy_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'luy_KE' locale +func New() locales.Translator { + return &luy_KE{ + locale: "luy_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"J2", "J3", "J4", "J5", "Al", "Ij", "J1"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysWide: []string{"Jumapiri", "Jumatatu", "Jumanne", "Jumatano", "Murwa wa Kanne", "Murwa wa Katano", "Jumamosi"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Imberi ya Kuuza Kwa", "Muhiga Kuvita Kuuza"}, + timezones: map[string]string{"HENOMX": "HENOMX", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "HAST": "HAST", "WESZ": "WESZ", "AWST": "AWST", "ACWDT": "ACWDT", "WART": "WART", "MESZ": "MESZ", "GMT": "GMT", "ART": "ART", "HAT": "HAT", "AKST": "AKST", "LHDT": "LHDT", "JST": "JST", "MEZ": "MEZ", "HNNOMX": "HNNOMX", "COT": "COT", "MDT": "MDT", "UYT": "UYT", "SAST": "SAST", "AST": "AST", "WAT": "WAT", "BT": "BT", "CDT": "CDT", "BOT": "BOT", "HADT": "HADT", "CLST": "CLST", "HEEG": "HEEG", "AKDT": "AKDT", "ECT": "ECT", "VET": "VET", "CLT": "CLT", "HEPM": "HEPM", "HNOG": "HNOG", "TMT": "TMT", "TMST": "TMST", "ACST": "ACST", "GFT": "GFT", "WITA": "WITA", "GYT": "GYT", "HKT": "HKT", "WIT": "WIT", "NZDT": "NZDT", "OESZ": "OESZ", "EDT": "EDT", "MST": "MST", "SRT": "SRT", "ARST": "ARST", "OEZ": "OEZ", "EST": "EST", "HNEG": "HNEG", "∅∅∅": "∅∅∅", "AEST": "AEST", "ACWST": "ACWST", "IST": "IST", "HKST": "HKST", "HNT": "HNT", "AEDT": "AEDT", "HECU": "HECU", "CHAST": "CHAST", "WEZ": "WEZ", "PST": "PST", "JDT": "JDT", "ChST": "ChST", "LHST": "LHST", "WIB": "WIB", "AWDT": "AWDT", "CHADT": "CHADT", "HEOG": "HEOG", "ADT": "ADT", "WAST": "WAST", "COST": "COST", "EAT": "EAT", "HNCU": "HNCU", "CAT": "CAT", "MYT": "MYT", "ACDT": "ACDT", "HNPM": "HNPM", "UYST": "UYST", "CST": "CST", "NZST": "NZST", "SGT": "SGT", "PDT": "PDT", "WARST": "WARST"}, + } +} + +// Locale returns the current translators string locale +func (luy *luy_KE) Locale() string { + return luy.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'luy_KE' +func (luy *luy_KE) PluralsCardinal() []locales.PluralRule { + return luy.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'luy_KE' +func (luy *luy_KE) PluralsOrdinal() []locales.PluralRule { + return luy.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'luy_KE' +func (luy *luy_KE) PluralsRange() []locales.PluralRule { + return luy.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'luy_KE' +func (luy *luy_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'luy_KE' +func (luy *luy_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'luy_KE' +func (luy *luy_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (luy *luy_KE) MonthAbbreviated(month time.Month) string { + return luy.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (luy *luy_KE) MonthsAbbreviated() []string { + return luy.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (luy *luy_KE) MonthNarrow(month time.Month) string { + return luy.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (luy *luy_KE) MonthsNarrow() []string { + return luy.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (luy *luy_KE) MonthWide(month time.Month) string { + return luy.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (luy *luy_KE) MonthsWide() []string { + return luy.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (luy *luy_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return luy.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (luy *luy_KE) WeekdaysAbbreviated() []string { + return luy.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (luy *luy_KE) WeekdayNarrow(weekday time.Weekday) string { + return luy.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (luy *luy_KE) WeekdaysNarrow() []string { + return luy.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (luy *luy_KE) WeekdayShort(weekday time.Weekday) string { + return luy.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (luy *luy_KE) WeekdaysShort() []string { + return luy.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (luy *luy_KE) WeekdayWide(weekday time.Weekday) string { + return luy.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (luy *luy_KE) WeekdaysWide() []string { + return luy.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'luy_KE' and handles both Whole and Real numbers based on 'v' +func (luy *luy_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'luy_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (luy *luy_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'luy_KE' +func (luy *luy_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := luy.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, luy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, luy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, luy.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, luy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'luy_KE' +// in accounting notation. +func (luy *luy_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := luy.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, luy.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, luy.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, luy.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, luy.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'luy_KE' +func (luy *luy_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'luy_KE' +func (luy *luy_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luy.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'luy_KE' +func (luy *luy_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'luy_KE' +func (luy *luy_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, luy.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, luy.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'luy_KE' +func (luy *luy_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'luy_KE' +func (luy *luy_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'luy_KE' +func (luy *luy_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'luy_KE' +func (luy *luy_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, luy.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, luy.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := luy.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/luy_KE/luy_KE_test.go b/vendor/github.com/go-playground/locales/luy_KE/luy_KE_test.go new file mode 100644 index 0000000000..2746529e16 --- /dev/null +++ b/vendor/github.com/go-playground/locales/luy_KE/luy_KE_test.go @@ -0,0 +1,1120 @@ +package luy_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "luy_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lv/lv.go b/vendor/github.com/go-playground/locales/lv/lv.go new file mode 100644 index 0000000000..3de39192f2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lv/lv.go @@ -0,0 +1,628 @@ +package lv + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lv struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lv' locale +func New() locales.Translator { + return &lv{ + locale: "lv", + pluralsCardinal: []locales.PluralRule{1, 2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "Ls", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "janv.", "febr.", "marts", "apr.", "maijs", "jūn.", "jūl.", "aug.", "sept.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvāris", "februāris", "marts", "aprīlis", "maijs", "jūnijs", "jūlijs", "augusts", "septembris", "oktobris", "novembris", "decembris"}, + daysAbbreviated: []string{"svētd.", "pirmd.", "otrd.", "trešd.", "ceturtd.", "piektd.", "sestd."}, + daysNarrow: []string{"S", "P", "O", "T", "C", "P", "S"}, + daysShort: []string{"Sv", "Pr", "Ot", "Tr", "Ce", "Pk", "Se"}, + daysWide: []string{"svētdiena", "pirmdiena", "otrdiena", "trešdiena", "ceturtdiena", "piektdiena", "sestdiena"}, + periodsAbbreviated: []string{"priekšp.", "pēcp."}, + periodsNarrow: []string{"priekšp.", "pēcp."}, + periodsWide: []string{"priekšpusdienā", "pēcpusdienā"}, + erasAbbreviated: []string{"p.m.ē.", "m.ē."}, + erasNarrow: []string{"p.m.ē.", "m.ē."}, + erasWide: []string{"pirms mūsu ēras", "mūsu ērā"}, + timezones: map[string]string{"AKDT": "Aļaskas vasaras laiks", "AEST": "Austrālijas austrumu ziemas laiks", "UYT": "Urugvajas ziemas laiks", "ARST": "Argentīnas vasaras laiks", "HADT": "Havaju–Aleutu vasaras laiks", "EDT": "Austrumu vasaras laiks", "ACST": "Austrālijas centrālais ziemas laiks", "MDT": "Kalnu vasaras laiks", "HNCU": "Kubas ziemas laiks", "CDT": "Centrālais vasaras laiks", "WIT": "Austrumindonēzijas laiks", "HKST": "Honkongas vasaras laiks", "HAT": "Ņūfaundlendas vasaras laiks", "HEEG": "Austrumgrenlandes vasaras laiks", "CAT": "Centrālāfrikas laiks", "MESZ": "Centrāleiropas vasaras laiks", "WAT": "Rietumāfrikas ziemas laiks", "ACDT": "Austrālijas centrālais vasaras laiks", "CHAST": "Četemas ziemas laiks", "HNOG": "Rietumgrenlandes ziemas laiks", "PDT": "Klusā okeāna vasaras laiks", "WESZ": "Rietumeiropas vasaras laiks", "TMST": "Turkmenistānas vasaras laiks", "COST": "Kolumbijas vasaras laiks", "HENOMX": "Ziemeļrietumu Meksikas vasaras laiks", "ChST": "Čamorra ziemas laiks", "AWST": "Austrālijas rietumu ziemas laiks", "CHADT": "Četemas vasaras laiks", "HNEG": "Austrumgrenlandes ziemas laiks", "HNPM": "Senpjēras un Mikelonas ziemas laiks", "LHST": "Lorda Hava salas ziemas laiks", "OESZ": "Austrumeiropas vasaras laiks", "WART": "Rietumargentīnas ziemas laiks", "WAST": "Rietumāfrikas vasaras laiks", "EST": "Austrumu ziemas laiks", "HEPMX": "Meksikas Klusā okeāna piekrastes vasaras laiks", "SGT": "Singapūras laiks", "HEOG": "Rietumgrenlandes vasaras laiks", "OEZ": "Austrumeiropas ziemas laiks", "ART": "Argentīnas ziemas laiks", "MST": "Kalnu ziemas laiks", "HNPMX": "Meksikas Klusā okeāna piekrastes ziemas laiks", "TMT": "Turkmenistānas ziemas laiks", "UYST": "Urugvajas vasaras laiks", "GYT": "Gajānas laiks", "ECT": "Ekvadoras laiks", "AST": "Atlantijas ziemas laiks", "GMT": "Griničas laiks", "AWDT": "Austrālijas rietumu vasaras laiks", "BOT": "Bolīvijas laiks", "PST": "Klusā okeāna ziemas laiks", "NZST": "Jaunzēlandes ziemas laiks", "ADT": "Atlantijas vasaras laiks", "IST": "Indijas ziemas laiks", "WIB": "Rietumindonēzijas laiks", "NZDT": "Jaunzēlandes vasaras laiks", "MEZ": "Centrāleiropas ziemas laiks", "COT": "Kolumbijas ziemas laiks", "∅∅∅": "∅∅∅", "WITA": "Centrālindonēzijas laiks", "AEDT": "Austrālijas austrumu vasaras laiks", "SRT": "Surinamas laiks", "CLT": "Čīles ziemas laiks", "WEZ": "Rietumeiropas ziemas laiks", "BT": "Butānas laiks", "AKST": "Aļaskas ziemas laiks", "HECU": "Kubas vasaras laiks", "HAST": "Havaju–Aleutu ziemas laiks", "JDT": "Japānas vasaras laiks", "JST": "Japānas ziemas laiks", "CLST": "Čīles vasaras laiks", "HNNOMX": "Ziemeļrietumu Meksikas ziemas laiks", "GFT": "Franču Gviānas laiks", "LHDT": "Lorda Hava salas vasaras laiks", "CST": "Centrālais ziemas laiks", "ACWST": "Austrālijas centrālais rietumu ziemas laiks", "HKT": "Honkongas ziemas laiks", "HEPM": "Senpjēras un Mikelonas vasaras laiks", "EAT": "Austrumāfrikas laiks", "VET": "Venecuēlas laiks", "MYT": "Malaizijas laiks", "WARST": "Rietumargentīnas vasaras laiks", "HNT": "Ņūfaundlendas ziemas laiks", "SAST": "Dienvidāfrikas ziemas laiks", "ACWDT": "Austrālijas centrālais rietumu vasaras laiks"}, + } +} + +// Locale returns the current translators string locale +func (lv *lv) Locale() string { + return lv.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lv' +func (lv *lv) PluralsCardinal() []locales.PluralRule { + return lv.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lv' +func (lv *lv) PluralsOrdinal() []locales.PluralRule { + return lv.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lv' +func (lv *lv) PluralsRange() []locales.PluralRule { + return lv.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lv' +func (lv *lv) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + f := locales.F(n, v) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + fMod100 := f % 100 + fMod10 := f % 10 + + if (nMod10 == 0) || (nMod100 >= 11 && nMod100 <= 19) || (v == 2 && fMod100 >= 11 && fMod100 <= 19) { + return locales.PluralRuleZero + } else if (nMod10 == 1 && nMod100 != 11) || (v == 2 && fMod10 == 1 && fMod100 != 11) || (v != 2 && fMod10 == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lv' +func (lv *lv) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lv' +func (lv *lv) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := lv.CardinalPluralRule(num1, v1) + end := lv.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleZero { + return locales.PluralRuleOther + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleZero { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleZero { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lv *lv) MonthAbbreviated(month time.Month) string { + return lv.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lv *lv) MonthsAbbreviated() []string { + return lv.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lv *lv) MonthNarrow(month time.Month) string { + return lv.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lv *lv) MonthsNarrow() []string { + return lv.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lv *lv) MonthWide(month time.Month) string { + return lv.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lv *lv) MonthsWide() []string { + return lv.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lv *lv) WeekdayAbbreviated(weekday time.Weekday) string { + return lv.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lv *lv) WeekdaysAbbreviated() []string { + return lv.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lv *lv) WeekdayNarrow(weekday time.Weekday) string { + return lv.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lv *lv) WeekdaysNarrow() []string { + return lv.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lv *lv) WeekdayShort(weekday time.Weekday) string { + return lv.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lv *lv) WeekdaysShort() []string { + return lv.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lv *lv) WeekdayWide(weekday time.Weekday) string { + return lv.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lv *lv) WeekdaysWide() []string { + return lv.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lv' and handles both Whole and Real numbers based on 'v' +func (lv *lv) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lv.group) - 1; j >= 0; j-- { + b = append(b, lv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lv.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lv' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lv *lv) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lv.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lv.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lv.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lv' +func (lv *lv) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lv.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lv.group) - 1; j >= 0; j-- { + b = append(b, lv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lv.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, lv.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lv' +// in accounting notation. +func (lv *lv) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lv.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lv.group) - 1; j >= 0; j-- { + b = append(b, lv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, lv.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, lv.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, lv.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lv' +func (lv *lv) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lv' +func (lv *lv) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lv.monthsAbbreviated[t.Month()]...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lv' +func (lv *lv) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lv.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lv' +func (lv *lv) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lv.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lv.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lv' +func (lv *lv) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lv' +func (lv *lv) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lv' +func (lv *lv) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lv' +func (lv *lv) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lv.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lv/lv_test.go b/vendor/github.com/go-playground/locales/lv/lv_test.go new file mode 100644 index 0000000000..a4ee46a100 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lv/lv_test.go @@ -0,0 +1,1120 @@ +package lv + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lv" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/lv_LV/lv_LV.go b/vendor/github.com/go-playground/locales/lv_LV/lv_LV.go new file mode 100644 index 0000000000..f8933772dd --- /dev/null +++ b/vendor/github.com/go-playground/locales/lv_LV/lv_LV.go @@ -0,0 +1,628 @@ +package lv_LV + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type lv_LV struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'lv_LV' locale +func New() locales.Translator { + return &lv_LV{ + locale: "lv_LV", + pluralsCardinal: []locales.PluralRule{1, 2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "janv.", "febr.", "marts", "apr.", "maijs", "jūn.", "jūl.", "aug.", "sept.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janvāris", "februāris", "marts", "aprīlis", "maijs", "jūnijs", "jūlijs", "augusts", "septembris", "oktobris", "novembris", "decembris"}, + daysAbbreviated: []string{"svētd.", "pirmd.", "otrd.", "trešd.", "ceturtd.", "piektd.", "sestd."}, + daysNarrow: []string{"S", "P", "O", "T", "C", "P", "S"}, + daysShort: []string{"Sv", "Pr", "Ot", "Tr", "Ce", "Pk", "Se"}, + daysWide: []string{"svētdiena", "pirmdiena", "otrdiena", "trešdiena", "ceturtdiena", "piektdiena", "sestdiena"}, + periodsAbbreviated: []string{"priekšp.", "pēcp."}, + periodsNarrow: []string{"priekšp.", "pēcp."}, + periodsWide: []string{"priekšpusdienā", "pēcpusdienā"}, + erasAbbreviated: []string{"p.m.ē.", "m.ē."}, + erasNarrow: []string{"p.m.ē.", "m.ē."}, + erasWide: []string{"pirms mūsu ēras", "mūsu ērā"}, + timezones: map[string]string{"JST": "Japānas ziemas laiks", "HEOG": "Rietumgrenlandes vasaras laiks", "ART": "Argentīnas ziemas laiks", "HKT": "Honkongas ziemas laiks", "COST": "Kolumbijas vasaras laiks", "AEDT": "Austrālijas austrumu vasaras laiks", "CDT": "Centrālais vasaras laiks", "HAST": "Havaju–Aleutu ziemas laiks", "ACWDT": "Austrālijas centrālais rietumu vasaras laiks", "MST": "MST", "ARST": "Argentīnas vasaras laiks", "EDT": "Austrumu vasaras laiks", "ACDT": "Austrālijas centrālais vasaras laiks", "WITA": "Centrālindonēzijas laiks", "BOT": "Bolīvijas laiks", "PDT": "Klusā okeāna vasaras laiks", "UYT": "Urugvajas ziemas laiks", "ADT": "Atlantijas vasaras laiks", "HNPM": "Senpjēras un Mikelonas ziemas laiks", "HNPMX": "Meksikas Klusā okeāna piekrastes ziemas laiks", "SRT": "Surinamas laiks", "WIT": "Austrumindonēzijas laiks", "CLT": "Čīles ziemas laiks", "HENOMX": "Ziemeļrietumu Meksikas vasaras laiks", "HAT": "Ņūfaundlendas vasaras laiks", "GFT": "Franču Gviānas laiks", "ECT": "Ekvadoras laiks", "OEZ": "Austrumeiropas ziemas laiks", "GMT": "Griničas laiks", "HECU": "Kubas vasaras laiks", "PST": "Klusā okeāna ziemas laiks", "MESZ": "Centrāleiropas vasaras laiks", "WAST": "Rietumāfrikas vasaras laiks", "EST": "Austrumu ziemas laiks", "HNT": "Ņūfaundlendas ziemas laiks", "SAST": "Dienvidāfrikas ziemas laiks", "EAT": "Austrumāfrikas laiks", "MEZ": "Centrāleiropas ziemas laiks", "WART": "Rietumargentīnas ziemas laiks", "TMST": "Turkmenistānas vasaras laiks", "WAT": "Rietumāfrikas ziemas laiks", "LHST": "Lorda Hava salas ziemas laiks", "∅∅∅": "Brazīlijas vasaras laiks", "HADT": "Havaju–Aleutu vasaras laiks", "AST": "Atlantijas ziemas laiks", "HEEG": "Austrumgrenlandes vasaras laiks", "AEST": "Austrālijas austrumu ziemas laiks", "GYT": "Gajānas laiks", "AWST": "Austrālijas rietumu ziemas laiks", "ACWST": "Austrālijas centrālais rietumu ziemas laiks", "CHADT": "Četemas vasaras laiks", "WARST": "Rietumargentīnas vasaras laiks", "HEPM": "Senpjēras un Mikelonas vasaras laiks", "HNCU": "Kubas ziemas laiks", "CST": "Centrālais ziemas laiks", "HNOG": "Rietumgrenlandes ziemas laiks", "HNNOMX": "Ziemeļrietumu Meksikas ziemas laiks", "AKDT": "Aļaskas vasaras laiks", "ChST": "Čamorra ziemas laiks", "VET": "Venecuēlas laiks", "CLST": "Čīles vasaras laiks", "HKST": "Honkongas vasaras laiks", "BT": "Butānas laiks", "UYST": "Urugvajas vasaras laiks", "HEPMX": "Meksikas Klusā okeāna piekrastes vasaras laiks", "LHDT": "Lorda Hava salas vasaras laiks", "IST": "Indijas ziemas laiks", "JDT": "Japānas vasaras laiks", "COT": "Kolumbijas ziemas laiks", "AKST": "Aļaskas ziemas laiks", "WEZ": "Rietumeiropas ziemas laiks", "MYT": "Malaizijas laiks", "ACST": "Austrālijas centrālais ziemas laiks", "HNEG": "Austrumgrenlandes ziemas laiks", "WESZ": "Rietumeiropas vasaras laiks", "OESZ": "Austrumeiropas vasaras laiks", "NZST": "Jaunzēlandes ziemas laiks", "CAT": "Centrālāfrikas laiks", "TMT": "Turkmenistānas ziemas laiks", "MDT": "MDT", "AWDT": "Austrālijas rietumu vasaras laiks", "CHAST": "Četemas ziemas laiks", "NZDT": "Jaunzēlandes vasaras laiks", "WIB": "Rietumindonēzijas laiks", "SGT": "Singapūras laiks"}, + } +} + +// Locale returns the current translators string locale +func (lv *lv_LV) Locale() string { + return lv.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'lv_LV' +func (lv *lv_LV) PluralsCardinal() []locales.PluralRule { + return lv.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'lv_LV' +func (lv *lv_LV) PluralsOrdinal() []locales.PluralRule { + return lv.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'lv_LV' +func (lv *lv_LV) PluralsRange() []locales.PluralRule { + return lv.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lv_LV' +func (lv *lv_LV) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + f := locales.F(n, v) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + fMod100 := f % 100 + fMod10 := f % 10 + + if (nMod10 == 0) || (nMod100 >= 11 && nMod100 <= 19) || (v == 2 && fMod100 >= 11 && fMod100 <= 19) { + return locales.PluralRuleZero + } else if (nMod10 == 1 && nMod100 != 11) || (v == 2 && fMod10 == 1 && fMod100 != 11) || (v != 2 && fMod10 == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lv_LV' +func (lv *lv_LV) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lv_LV' +func (lv *lv_LV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := lv.CardinalPluralRule(num1, v1) + end := lv.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleZero && end == locales.PluralRuleZero { + return locales.PluralRuleOther + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleZero { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleZero { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (lv *lv_LV) MonthAbbreviated(month time.Month) string { + return lv.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (lv *lv_LV) MonthsAbbreviated() []string { + return lv.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (lv *lv_LV) MonthNarrow(month time.Month) string { + return lv.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (lv *lv_LV) MonthsNarrow() []string { + return lv.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (lv *lv_LV) MonthWide(month time.Month) string { + return lv.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (lv *lv_LV) MonthsWide() []string { + return lv.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (lv *lv_LV) WeekdayAbbreviated(weekday time.Weekday) string { + return lv.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (lv *lv_LV) WeekdaysAbbreviated() []string { + return lv.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (lv *lv_LV) WeekdayNarrow(weekday time.Weekday) string { + return lv.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (lv *lv_LV) WeekdaysNarrow() []string { + return lv.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (lv *lv_LV) WeekdayShort(weekday time.Weekday) string { + return lv.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (lv *lv_LV) WeekdaysShort() []string { + return lv.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (lv *lv_LV) WeekdayWide(weekday time.Weekday) string { + return lv.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (lv *lv_LV) WeekdaysWide() []string { + return lv.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'lv_LV' and handles both Whole and Real numbers based on 'v' +func (lv *lv_LV) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lv.group) - 1; j >= 0; j-- { + b = append(b, lv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lv.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'lv_LV' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (lv *lv_LV) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lv.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lv.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, lv.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lv_LV' +func (lv *lv_LV) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lv.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lv.group) - 1; j >= 0; j-- { + b = append(b, lv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, lv.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, lv.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lv_LV' +// in accounting notation. +func (lv *lv_LV) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := lv.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, lv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(lv.group) - 1; j >= 0; j-- { + b = append(b, lv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, lv.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, lv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, lv.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, lv.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'lv_LV' +func (lv *lv_LV) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'lv_LV' +func (lv *lv_LV) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lv.monthsAbbreviated[t.Month()]...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'lv_LV' +func (lv *lv_LV) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lv.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'lv_LV' +func (lv *lv_LV) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, lv.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, lv.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'lv_LV' +func (lv *lv_LV) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'lv_LV' +func (lv *lv_LV) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'lv_LV' +func (lv *lv_LV) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'lv_LV' +func (lv *lv_LV) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, lv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, lv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := lv.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/lv_LV/lv_LV_test.go b/vendor/github.com/go-playground/locales/lv_LV/lv_LV_test.go new file mode 100644 index 0000000000..ac35517db4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/lv_LV/lv_LV_test.go @@ -0,0 +1,1120 @@ +package lv_LV + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "lv_LV" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mas/mas.go b/vendor/github.com/go-playground/locales/mas/mas.go new file mode 100644 index 0000000000..5c16ebfb14 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mas/mas.go @@ -0,0 +1,524 @@ +package mas + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mas struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mas' locale +func New() locales.Translator { + return &mas{ + locale: "mas", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Dal", "Ará", "Ɔɛn", "Doy", "Lép", "Rok", "Sás", "Bɔ́r", "Kús", "Gís", "Shʉ́", "Ntʉ́"}, + monthsWide: []string{"", "Oladalʉ́", "Arát", "Ɔɛnɨ́ɔɨŋɔk", "Olodoyíóríê inkókúâ", "Oloilépūnyīē inkókúâ", "Kújúɔrɔk", "Mórusásin", "Ɔlɔ́ɨ́bɔ́rárɛ", "Kúshîn", "Olgísan", "Pʉshʉ́ka", "Ntʉ́ŋʉ́s"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"}, + daysWide: []string{"Jumapílí", "Jumatátu", "Jumane", "Jumatánɔ", "Alaámisi", "Jumáa", "Jumamósi"}, + periodsAbbreviated: []string{"Ɛnkakɛnyá", "Ɛndámâ"}, + periodsWide: []string{"Ɛnkakɛnyá", "Ɛndámâ"}, + erasAbbreviated: []string{"MY", "EY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Meínō Yɛ́sʉ", "Eínō Yɛ́sʉ"}, + timezones: map[string]string{"AEST": "AEST", "HEPM": "HEPM", "AWST": "AWST", "AWDT": "AWDT", "∅∅∅": "∅∅∅", "EST": "EST", "ACST": "ACST", "UYT": "UYT", "HNPM": "HNPM", "HNCU": "HNCU", "WAST": "WAST", "AEDT": "AEDT", "SAST": "SAST", "HEPMX": "HEPMX", "HECU": "HECU", "HADT": "HADT", "ARST": "ARST", "BT": "BT", "PDT": "PDT", "JDT": "JDT", "WEZ": "WEZ", "MDT": "MDT", "WITA": "WITA", "BOT": "BOT", "HKST": "HKST", "HENOMX": "HENOMX", "HEEG": "HEEG", "CDT": "CDT", "HNT": "HNT", "SGT": "SGT", "CAT": "CAT", "HNOG": "HNOG", "ADT": "ADT", "MST": "MST", "COST": "COST", "HNNOMX": "HNNOMX", "ECT": "ECT", "WARST": "WARST", "AST": "AST", "HNEG": "HNEG", "CHADT": "CHADT", "TMST": "TMST", "LHST": "LHST", "ACWST": "ACWST", "NZST": "NZST", "NZDT": "NZDT", "VET": "VET", "WART": "WART", "HEOG": "HEOG", "CST": "CST", "WIT": "WIT", "CHAST": "CHAST", "JST": "JST", "GFT": "GFT", "WIB": "WIB", "WESZ": "WESZ", "HAT": "HAT", "UYST": "UYST", "LHDT": "LHDT", "HAST": "HAST", "CLST": "CLST", "OESZ": "OESZ", "GMT": "GMT", "GYT": "GYT", "ACWDT": "ACWDT", "MESZ": "MESZ", "TMT": "TMT", "AKST": "AKST", "AKDT": "AKDT", "ChST": "ChST", "IST": "IST", "MEZ": "MEZ", "CLT": "CLT", "OEZ": "OEZ", "ACDT": "ACDT", "COT": "COT", "ART": "ART", "WAT": "WAT", "HKT": "HKT", "HNPMX": "HNPMX", "EAT": "EAT", "PST": "PST", "MYT": "MYT", "EDT": "EDT", "SRT": "SRT"}, + } +} + +// Locale returns the current translators string locale +func (mas *mas) Locale() string { + return mas.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mas' +func (mas *mas) PluralsCardinal() []locales.PluralRule { + return mas.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mas' +func (mas *mas) PluralsOrdinal() []locales.PluralRule { + return mas.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mas' +func (mas *mas) PluralsRange() []locales.PluralRule { + return mas.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mas' +func (mas *mas) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mas' +func (mas *mas) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mas' +func (mas *mas) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mas *mas) MonthAbbreviated(month time.Month) string { + return mas.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mas *mas) MonthsAbbreviated() []string { + return mas.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mas *mas) MonthNarrow(month time.Month) string { + return mas.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mas *mas) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mas *mas) MonthWide(month time.Month) string { + return mas.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mas *mas) MonthsWide() []string { + return mas.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mas *mas) WeekdayAbbreviated(weekday time.Weekday) string { + return mas.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mas *mas) WeekdaysAbbreviated() []string { + return mas.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mas *mas) WeekdayNarrow(weekday time.Weekday) string { + return mas.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mas *mas) WeekdaysNarrow() []string { + return mas.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mas *mas) WeekdayShort(weekday time.Weekday) string { + return mas.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mas *mas) WeekdaysShort() []string { + return mas.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mas *mas) WeekdayWide(weekday time.Weekday) string { + return mas.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mas *mas) WeekdaysWide() []string { + return mas.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mas' and handles both Whole and Real numbers based on 'v' +func (mas *mas) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mas' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mas *mas) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mas' +func (mas *mas) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mas.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mas.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mas' +// in accounting notation. +func (mas *mas) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mas.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mas.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mas.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mas.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mas' +func (mas *mas) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mas' +func (mas *mas) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mas' +func (mas *mas) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mas' +func (mas *mas) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mas.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mas' +func (mas *mas) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mas' +func (mas *mas) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mas' +func (mas *mas) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mas' +func (mas *mas) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mas.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mas/mas_test.go b/vendor/github.com/go-playground/locales/mas/mas_test.go new file mode 100644 index 0000000000..a09bbf6dd1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mas/mas_test.go @@ -0,0 +1,1120 @@ +package mas + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mas" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mas_KE/mas_KE.go b/vendor/github.com/go-playground/locales/mas_KE/mas_KE.go new file mode 100644 index 0000000000..2c594e5e84 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mas_KE/mas_KE.go @@ -0,0 +1,524 @@ +package mas_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mas_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mas_KE' locale +func New() locales.Translator { + return &mas_KE{ + locale: "mas_KE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Dal", "Ará", "Ɔɛn", "Doy", "Lép", "Rok", "Sás", "Bɔ́r", "Kús", "Gís", "Shʉ́", "Ntʉ́"}, + monthsWide: []string{"", "Oladalʉ́", "Arát", "Ɔɛnɨ́ɔɨŋɔk", "Olodoyíóríê inkókúâ", "Oloilépūnyīē inkókúâ", "Kújúɔrɔk", "Mórusásin", "Ɔlɔ́ɨ́bɔ́rárɛ", "Kúshîn", "Olgísan", "Pʉshʉ́ka", "Ntʉ́ŋʉ́s"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"}, + daysWide: []string{"Jumapílí", "Jumatátu", "Jumane", "Jumatánɔ", "Alaámisi", "Jumáa", "Jumamósi"}, + periodsAbbreviated: []string{"Ɛnkakɛnyá", "Ɛndámâ"}, + periodsWide: []string{"Ɛnkakɛnyá", "Ɛndámâ"}, + erasAbbreviated: []string{"MY", "EY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Meínō Yɛ́sʉ", "Eínō Yɛ́sʉ"}, + timezones: map[string]string{"PDT": "PDT", "MESZ": "MESZ", "HNOG": "HNOG", "COT": "COT", "HENOMX": "HENOMX", "HNPM": "HNPM", "AWST": "AWST", "CHADT": "CHADT", "ACWST": "ACWST", "OEZ": "OEZ", "MST": "MST", "ACDT": "ACDT", "AKST": "AKST", "CDT": "CDT", "HKT": "HKT", "AKDT": "AKDT", "LHST": "LHST", "AWDT": "AWDT", "EAT": "EAT", "CST": "CST", "NZDT": "NZDT", "JST": "JST", "AST": "AST", "GFT": "GFT", "ChST": "ChST", "LHDT": "LHDT", "CHAST": "CHAST", "ACWDT": "ACWDT", "AEST": "AEST", "HNCU": "HNCU", "HECU": "HECU", "MEZ": "MEZ", "ACST": "ACST", "HNEG": "HNEG", "SGT": "SGT", "JDT": "JDT", "CLST": "CLST", "EDT": "EDT", "HNT": "HNT", "HAT": "HAT", "WIB": "WIB", "∅∅∅": "∅∅∅", "ADT": "ADT", "CLT": "CLT", "WAST": "WAST", "AEDT": "AEDT", "SAST": "SAST", "SRT": "SRT", "IST": "IST", "GMT": "GMT", "TMST": "TMST", "MDT": "MDT", "ARST": "ARST", "HKST": "HKST", "ECT": "ECT", "VET": "VET", "WITA": "WITA", "TMT": "TMT", "COST": "COST", "GYT": "GYT", "WIT": "WIT", "HEOG": "HEOG", "UYST": "UYST", "BOT": "BOT", "HAST": "HAST", "OESZ": "OESZ", "WEZ": "WEZ", "WESZ": "WESZ", "WART": "WART", "HEEG": "HEEG", "BT": "BT", "HEPM": "HEPM", "PST": "PST", "CAT": "CAT", "WARST": "WARST", "ART": "ART", "WAT": "WAT", "EST": "EST", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "NZST": "NZST", "MYT": "MYT", "HNNOMX": "HNNOMX", "HADT": "HADT", "UYT": "UYT"}, + } +} + +// Locale returns the current translators string locale +func (mas *mas_KE) Locale() string { + return mas.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mas_KE' +func (mas *mas_KE) PluralsCardinal() []locales.PluralRule { + return mas.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mas_KE' +func (mas *mas_KE) PluralsOrdinal() []locales.PluralRule { + return mas.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mas_KE' +func (mas *mas_KE) PluralsRange() []locales.PluralRule { + return mas.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mas_KE' +func (mas *mas_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mas_KE' +func (mas *mas_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mas_KE' +func (mas *mas_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mas *mas_KE) MonthAbbreviated(month time.Month) string { + return mas.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mas *mas_KE) MonthsAbbreviated() []string { + return mas.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mas *mas_KE) MonthNarrow(month time.Month) string { + return mas.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mas *mas_KE) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mas *mas_KE) MonthWide(month time.Month) string { + return mas.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mas *mas_KE) MonthsWide() []string { + return mas.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mas *mas_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return mas.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mas *mas_KE) WeekdaysAbbreviated() []string { + return mas.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mas *mas_KE) WeekdayNarrow(weekday time.Weekday) string { + return mas.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mas *mas_KE) WeekdaysNarrow() []string { + return mas.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mas *mas_KE) WeekdayShort(weekday time.Weekday) string { + return mas.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mas *mas_KE) WeekdaysShort() []string { + return mas.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mas *mas_KE) WeekdayWide(weekday time.Weekday) string { + return mas.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mas *mas_KE) WeekdaysWide() []string { + return mas.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mas_KE' and handles both Whole and Real numbers based on 'v' +func (mas *mas_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mas_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mas *mas_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mas_KE' +func (mas *mas_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mas.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mas.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mas_KE' +// in accounting notation. +func (mas *mas_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mas.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mas.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mas.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mas.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mas_KE' +func (mas *mas_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mas_KE' +func (mas *mas_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mas_KE' +func (mas *mas_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mas_KE' +func (mas *mas_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mas.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mas_KE' +func (mas *mas_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mas_KE' +func (mas *mas_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mas_KE' +func (mas *mas_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mas_KE' +func (mas *mas_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mas.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mas_KE/mas_KE_test.go b/vendor/github.com/go-playground/locales/mas_KE/mas_KE_test.go new file mode 100644 index 0000000000..9d0b24e533 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mas_KE/mas_KE_test.go @@ -0,0 +1,1120 @@ +package mas_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mas_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mas_TZ/mas_TZ.go b/vendor/github.com/go-playground/locales/mas_TZ/mas_TZ.go new file mode 100644 index 0000000000..516de0dc50 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mas_TZ/mas_TZ.go @@ -0,0 +1,524 @@ +package mas_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mas_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mas_TZ' locale +func New() locales.Translator { + return &mas_TZ{ + locale: "mas_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Dal", "Ará", "Ɔɛn", "Doy", "Lép", "Rok", "Sás", "Bɔ́r", "Kús", "Gís", "Shʉ́", "Ntʉ́"}, + monthsWide: []string{"", "Oladalʉ́", "Arát", "Ɔɛnɨ́ɔɨŋɔk", "Olodoyíóríê inkókúâ", "Oloilépūnyīē inkókúâ", "Kújúɔrɔk", "Mórusásin", "Ɔlɔ́ɨ́bɔ́rárɛ", "Kúshîn", "Olgísan", "Pʉshʉ́ka", "Ntʉ́ŋʉ́s"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"}, + daysWide: []string{"Jumapílí", "Jumatátu", "Jumane", "Jumatánɔ", "Alaámisi", "Jumáa", "Jumamósi"}, + periodsAbbreviated: []string{"Ɛnkakɛnyá", "Ɛndámâ"}, + periodsWide: []string{"Ɛnkakɛnyá", "Ɛndámâ"}, + erasAbbreviated: []string{"MY", "EY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Meínō Yɛ́sʉ", "Eínō Yɛ́sʉ"}, + timezones: map[string]string{"OEZ": "OEZ", "WART": "WART", "WAT": "WAT", "HKT": "HKT", "AKDT": "AKDT", "CST": "CST", "IST": "IST", "ACWST": "ACWST", "BT": "BT", "AKST": "AKST", "SGT": "SGT", "HADT": "HADT", "NZST": "NZST", "WEZ": "WEZ", "ART": "ART", "HENOMX": "HENOMX", "WIB": "WIB", "AWDT": "AWDT", "PST": "PST", "ECT": "ECT", "HNT": "HNT", "HEEG": "HEEG", "SAST": "SAST", "ACWDT": "ACWDT", "CLT": "CLT", "HEOG": "HEOG", "ADT": "ADT", "GFT": "GFT", "HNPM": "HNPM", "LHST": "LHST", "HNPMX": "HNPMX", "CHADT": "CHADT", "BOT": "BOT", "AWST": "AWST", "HNOG": "HNOG", "AST": "AST", "MYT": "MYT", "MDT": "MDT", "UYT": "UYT", "GYT": "GYT", "CAT": "CAT", "VET": "VET", "∅∅∅": "∅∅∅", "ARST": "ARST", "WAST": "WAST", "COT": "COT", "AEDT": "AEDT", "ChST": "ChST", "CHAST": "CHAST", "PDT": "PDT", "HKST": "HKST", "ACST": "ACST", "CDT": "CDT", "OESZ": "OESZ", "EDT": "EDT", "GMT": "GMT", "TMT": "TMT", "HNCU": "HNCU", "JDT": "JDT", "CLST": "CLST", "WARST": "WARST", "TMST": "TMST", "AEST": "AEST", "LHDT": "LHDT", "WIT": "WIT", "NZDT": "NZDT", "MEZ": "MEZ", "HAT": "HAT", "SRT": "SRT", "HAST": "HAST", "EST": "EST", "HEPM": "HEPM", "EAT": "EAT", "HNEG": "HNEG", "WITA": "WITA", "HNNOMX": "HNNOMX", "HEPMX": "HEPMX", "HECU": "HECU", "MST": "MST", "ACDT": "ACDT", "UYST": "UYST", "MESZ": "MESZ", "WESZ": "WESZ", "JST": "JST", "COST": "COST"}, + } +} + +// Locale returns the current translators string locale +func (mas *mas_TZ) Locale() string { + return mas.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mas_TZ' +func (mas *mas_TZ) PluralsCardinal() []locales.PluralRule { + return mas.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mas_TZ' +func (mas *mas_TZ) PluralsOrdinal() []locales.PluralRule { + return mas.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mas_TZ' +func (mas *mas_TZ) PluralsRange() []locales.PluralRule { + return mas.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mas_TZ' +func (mas *mas_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mas_TZ' +func (mas *mas_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mas_TZ' +func (mas *mas_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mas *mas_TZ) MonthAbbreviated(month time.Month) string { + return mas.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mas *mas_TZ) MonthsAbbreviated() []string { + return mas.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mas *mas_TZ) MonthNarrow(month time.Month) string { + return mas.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mas *mas_TZ) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mas *mas_TZ) MonthWide(month time.Month) string { + return mas.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mas *mas_TZ) MonthsWide() []string { + return mas.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mas *mas_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return mas.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mas *mas_TZ) WeekdaysAbbreviated() []string { + return mas.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mas *mas_TZ) WeekdayNarrow(weekday time.Weekday) string { + return mas.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mas *mas_TZ) WeekdaysNarrow() []string { + return mas.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mas *mas_TZ) WeekdayShort(weekday time.Weekday) string { + return mas.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mas *mas_TZ) WeekdaysShort() []string { + return mas.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mas *mas_TZ) WeekdayWide(weekday time.Weekday) string { + return mas.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mas *mas_TZ) WeekdaysWide() []string { + return mas.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mas_TZ' and handles both Whole and Real numbers based on 'v' +func (mas *mas_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mas_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mas *mas_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mas_TZ' +func (mas *mas_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mas.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mas.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mas.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mas_TZ' +// in accounting notation. +func (mas *mas_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mas.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mas.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mas.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mas.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mas.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mas.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mas_TZ' +func (mas *mas_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mas_TZ' +func (mas *mas_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mas_TZ' +func (mas *mas_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mas_TZ' +func (mas *mas_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mas.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mas.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mas_TZ' +func (mas *mas_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mas_TZ' +func (mas *mas_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mas_TZ' +func (mas *mas_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mas_TZ' +func (mas *mas_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mas.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mas.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mas.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mas_TZ/mas_TZ_test.go b/vendor/github.com/go-playground/locales/mas_TZ/mas_TZ_test.go new file mode 100644 index 0000000000..4a2d4e84e7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mas_TZ/mas_TZ_test.go @@ -0,0 +1,1120 @@ +package mas_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mas_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mer/mer.go b/vendor/github.com/go-playground/locales/mer/mer.go new file mode 100644 index 0000000000..830a73b2a9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mer/mer.go @@ -0,0 +1,518 @@ +package mer + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mer struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mer' locale +func New() locales.Translator { + return &mer{ + locale: "mer", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "JAN", "FEB", "MAC", "ĨPU", "MĨĨ", "NJU", "NJR", "AGA", "SPT", "OKT", "NOV", "DEC"}, + monthsNarrow: []string{"", "J", "F", "M", "Ĩ", "M", "N", "N", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januarĩ", "Feburuarĩ", "Machi", "Ĩpurũ", "Mĩĩ", "Njuni", "Njuraĩ", "Agasti", "Septemba", "Oktũba", "Novemba", "Dicemba"}, + daysAbbreviated: []string{"KIU", "MRA", "WAI", "WET", "WEN", "WTN", "JUM"}, + daysNarrow: []string{"K", "M", "W", "W", "W", "W", "J"}, + daysWide: []string{"Kiumia", "Muramuko", "Wairi", "Wethatu", "Wena", "Wetano", "Jumamosi"}, + periodsAbbreviated: []string{"RŨ", "ŨG"}, + periodsWide: []string{"RŨ", "ŨG"}, + erasAbbreviated: []string{"MK", "NK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbere ya Kristũ", "Nyuma ya Kristũ"}, + timezones: map[string]string{"ACDT": "ACDT", "ACWDT": "ACWDT", "JST": "JST", "CLT": "CLT", "EDT": "EDT", "MST": "MST", "GYT": "GYT", "HECU": "HECU", "SGT": "SGT", "HAST": "HAST", "AST": "AST", "COST": "COST", "HEEG": "HEEG", "AKST": "AKST", "ChST": "ChST", "SAST": "SAST", "EAT": "EAT", "AWST": "AWST", "HENOMX": "HENOMX", "AKDT": "AKDT", "CDT": "CDT", "ECT": "ECT", "HADT": "HADT", "MEZ": "MEZ", "OEZ": "OEZ", "HKST": "HKST", "HEPMX": "HEPMX", "CST": "CST", "CHADT": "CHADT", "BOT": "BOT", "CLST": "CLST", "ART": "ART", "WAT": "WAT", "∅∅∅": "∅∅∅", "AEST": "AEST", "UYST": "UYST", "HNPM": "HNPM", "WIT": "WIT", "GMT": "GMT", "HAT": "HAT", "LHST": "LHST", "HNPMX": "HNPMX", "HNCU": "HNCU", "CHAST": "CHAST", "WESZ": "WESZ", "EST": "EST", "GFT": "GFT", "AWDT": "AWDT", "MYT": "MYT", "TMST": "TMST", "HNNOMX": "HNNOMX", "UYT": "UYT", "NZDT": "NZDT", "ARST": "ARST", "HNT": "HNT", "CAT": "CAT", "ADT": "ADT", "MESZ": "MESZ", "JDT": "JDT", "WAST": "WAST", "HKT": "HKT", "BT": "BT", "PDT": "PDT", "ACWST": "ACWST", "VET": "VET", "WEZ": "WEZ", "ACST": "ACST", "HNEG": "HNEG", "WITA": "WITA", "HEPM": "HEPM", "HNOG": "HNOG", "OESZ": "OESZ", "COT": "COT", "TMT": "TMT", "AEDT": "AEDT", "MDT": "MDT", "SRT": "SRT", "IST": "IST", "WARST": "WARST", "HEOG": "HEOG", "LHDT": "LHDT", "WIB": "WIB", "PST": "PST", "NZST": "NZST", "WART": "WART"}, + } +} + +// Locale returns the current translators string locale +func (mer *mer) Locale() string { + return mer.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mer' +func (mer *mer) PluralsCardinal() []locales.PluralRule { + return mer.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mer' +func (mer *mer) PluralsOrdinal() []locales.PluralRule { + return mer.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mer' +func (mer *mer) PluralsRange() []locales.PluralRule { + return mer.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mer' +func (mer *mer) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mer' +func (mer *mer) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mer' +func (mer *mer) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mer *mer) MonthAbbreviated(month time.Month) string { + return mer.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mer *mer) MonthsAbbreviated() []string { + return mer.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mer *mer) MonthNarrow(month time.Month) string { + return mer.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mer *mer) MonthsNarrow() []string { + return mer.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mer *mer) MonthWide(month time.Month) string { + return mer.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mer *mer) MonthsWide() []string { + return mer.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mer *mer) WeekdayAbbreviated(weekday time.Weekday) string { + return mer.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mer *mer) WeekdaysAbbreviated() []string { + return mer.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mer *mer) WeekdayNarrow(weekday time.Weekday) string { + return mer.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mer *mer) WeekdaysNarrow() []string { + return mer.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mer *mer) WeekdayShort(weekday time.Weekday) string { + return mer.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mer *mer) WeekdaysShort() []string { + return mer.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mer *mer) WeekdayWide(weekday time.Weekday) string { + return mer.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mer *mer) WeekdaysWide() []string { + return mer.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mer' and handles both Whole and Real numbers based on 'v' +func (mer *mer) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mer' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mer *mer) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mer' +func (mer *mer) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mer.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mer.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mer.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mer.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mer.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mer' +// in accounting notation. +func (mer *mer) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mer.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mer.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mer.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mer.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mer.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mer.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mer' +func (mer *mer) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mer' +func (mer *mer) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mer.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mer' +func (mer *mer) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mer.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mer' +func (mer *mer) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mer.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mer.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mer' +func (mer *mer) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mer.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mer' +func (mer *mer) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mer.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mer.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mer' +func (mer *mer) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mer.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mer.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mer' +func (mer *mer) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mer.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mer.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mer.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mer/mer_test.go b/vendor/github.com/go-playground/locales/mer/mer_test.go new file mode 100644 index 0000000000..4d268b93d6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mer/mer_test.go @@ -0,0 +1,1120 @@ +package mer + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mer" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mer_KE/mer_KE.go b/vendor/github.com/go-playground/locales/mer_KE/mer_KE.go new file mode 100644 index 0000000000..66795adf13 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mer_KE/mer_KE.go @@ -0,0 +1,518 @@ +package mer_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mer_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mer_KE' locale +func New() locales.Translator { + return &mer_KE{ + locale: "mer_KE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "JAN", "FEB", "MAC", "ĨPU", "MĨĨ", "NJU", "NJR", "AGA", "SPT", "OKT", "NOV", "DEC"}, + monthsNarrow: []string{"", "J", "F", "M", "Ĩ", "M", "N", "N", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januarĩ", "Feburuarĩ", "Machi", "Ĩpurũ", "Mĩĩ", "Njuni", "Njuraĩ", "Agasti", "Septemba", "Oktũba", "Novemba", "Dicemba"}, + daysAbbreviated: []string{"KIU", "MRA", "WAI", "WET", "WEN", "WTN", "JUM"}, + daysNarrow: []string{"K", "M", "W", "W", "W", "W", "J"}, + daysWide: []string{"Kiumia", "Muramuko", "Wairi", "Wethatu", "Wena", "Wetano", "Jumamosi"}, + periodsAbbreviated: []string{"RŨ", "ŨG"}, + periodsWide: []string{"RŨ", "ŨG"}, + erasAbbreviated: []string{"MK", "NK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbere ya Kristũ", "Nyuma ya Kristũ"}, + timezones: map[string]string{"MYT": "MYT", "HEPM": "HEPM", "SAST": "SAST", "LHDT": "LHDT", "SRT": "SRT", "PDT": "PDT", "ACWDT": "ACWDT", "ARST": "ARST", "HAT": "HAT", "WITA": "WITA", "HNPMX": "HNPMX", "CDT": "CDT", "SGT": "SGT", "HAST": "HAST", "VET": "VET", "TMST": "TMST", "WAT": "WAT", "ACST": "ACST", "COST": "COST", "BT": "BT", "AKST": "AKST", "ChST": "ChST", "HNPM": "HNPM", "LHST": "LHST", "AWDT": "AWDT", "BOT": "BOT", "MEZ": "MEZ", "OESZ": "OESZ", "ART": "ART", "MDT": "MDT", "WIB": "WIB", "NZDT": "NZDT", "∅∅∅": "∅∅∅", "UYT": "UYT", "HEPMX": "HEPMX", "GYT": "GYT", "HECU": "HECU", "ECT": "ECT", "NZST": "NZST", "EDT": "EDT", "EAT": "EAT", "WIT": "WIT", "GFT": "GFT", "CST": "CST", "IST": "IST", "ADT": "ADT", "WEZ": "WEZ", "CLST": "CLST", "MST": "MST", "COT": "COT", "HADT": "HADT", "CAT": "CAT", "AST": "AST", "EST": "EST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "CHAST": "CHAST", "ACWST": "ACWST", "WARST": "WARST", "ACDT": "ACDT", "HNEG": "HNEG", "AKDT": "AKDT", "PST": "PST", "MESZ": "MESZ", "HEOG": "HEOG", "WAST": "WAST", "HKST": "HKST", "UYST": "UYST", "AWST": "AWST", "HNOG": "HNOG", "WESZ": "WESZ", "TMT": "TMT", "HEEG": "HEEG", "CHADT": "CHADT", "OEZ": "OEZ", "GMT": "GMT", "WART": "WART", "HKT": "HKT", "AEST": "AEST", "AEDT": "AEDT", "HNCU": "HNCU", "JST": "JST", "JDT": "JDT", "CLT": "CLT", "HNT": "HNT"}, + } +} + +// Locale returns the current translators string locale +func (mer *mer_KE) Locale() string { + return mer.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mer_KE' +func (mer *mer_KE) PluralsCardinal() []locales.PluralRule { + return mer.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mer_KE' +func (mer *mer_KE) PluralsOrdinal() []locales.PluralRule { + return mer.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mer_KE' +func (mer *mer_KE) PluralsRange() []locales.PluralRule { + return mer.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mer_KE' +func (mer *mer_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mer_KE' +func (mer *mer_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mer_KE' +func (mer *mer_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mer *mer_KE) MonthAbbreviated(month time.Month) string { + return mer.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mer *mer_KE) MonthsAbbreviated() []string { + return mer.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mer *mer_KE) MonthNarrow(month time.Month) string { + return mer.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mer *mer_KE) MonthsNarrow() []string { + return mer.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mer *mer_KE) MonthWide(month time.Month) string { + return mer.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mer *mer_KE) MonthsWide() []string { + return mer.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mer *mer_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return mer.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mer *mer_KE) WeekdaysAbbreviated() []string { + return mer.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mer *mer_KE) WeekdayNarrow(weekday time.Weekday) string { + return mer.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mer *mer_KE) WeekdaysNarrow() []string { + return mer.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mer *mer_KE) WeekdayShort(weekday time.Weekday) string { + return mer.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mer *mer_KE) WeekdaysShort() []string { + return mer.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mer *mer_KE) WeekdayWide(weekday time.Weekday) string { + return mer.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mer *mer_KE) WeekdaysWide() []string { + return mer.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mer_KE' and handles both Whole and Real numbers based on 'v' +func (mer *mer_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mer_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mer *mer_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mer_KE' +func (mer *mer_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mer.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mer.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mer.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mer.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mer.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mer_KE' +// in accounting notation. +func (mer *mer_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mer.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mer.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mer.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mer.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mer.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mer.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mer_KE' +func (mer *mer_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mer_KE' +func (mer *mer_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mer.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mer_KE' +func (mer *mer_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mer.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mer_KE' +func (mer *mer_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mer.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mer.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mer_KE' +func (mer *mer_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mer.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mer_KE' +func (mer *mer_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mer.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mer.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mer_KE' +func (mer *mer_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mer.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mer.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mer_KE' +func (mer *mer_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mer.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mer.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mer.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mer_KE/mer_KE_test.go b/vendor/github.com/go-playground/locales/mer_KE/mer_KE_test.go new file mode 100644 index 0000000000..80daebb7f1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mer_KE/mer_KE_test.go @@ -0,0 +1,1120 @@ +package mer_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mer_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mfe/mfe.go b/vendor/github.com/go-playground/locales/mfe/mfe.go new file mode 100644 index 0000000000..560a481054 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mfe/mfe.go @@ -0,0 +1,484 @@ +package mfe + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mfe struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mfe' locale +func New() locales.Translator { + return &mfe{ + locale: "mfe", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "Rs", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "zan", "fev", "mar", "avr", "me", "zin", "zil", "out", "sep", "okt", "nov", "des"}, + monthsNarrow: []string{"", "z", "f", "m", "a", "m", "z", "z", "o", "s", "o", "n", "d"}, + monthsWide: []string{"", "zanvie", "fevriye", "mars", "avril", "me", "zin", "zilye", "out", "septam", "oktob", "novam", "desam"}, + daysAbbreviated: []string{"dim", "lin", "mar", "mer", "ze", "van", "sam"}, + daysNarrow: []string{"d", "l", "m", "m", "z", "v", "s"}, + daysWide: []string{"dimans", "lindi", "mardi", "merkredi", "zedi", "vandredi", "samdi"}, + erasAbbreviated: []string{"av. Z-K", "ap. Z-K"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"avan Zezi-Krist", "apre Zezi-Krist"}, + timezones: map[string]string{"NZDT": "NZDT", "ADT": "ADT", "GMT": "GMT", "MYT": "MYT", "EDT": "EDT", "SGT": "SGT", "ART": "ART", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "TMST": "TMST", "HKT": "HKT", "AEDT": "AEDT", "HECU": "HECU", "AST": "AST", "WAST": "WAST", "HNEG": "HNEG", "AKDT": "AKDT", "GYT": "GYT", "ARST": "ARST", "AKST": "AKST", "GFT": "GFT", "HEPM": "HEPM", "HNCU": "HNCU", "CST": "CST", "CHAST": "CHAST", "NZST": "NZST", "HNOG": "HNOG", "MST": "MST", "AEST": "AEST", "HADT": "HADT", "HNT": "HNT", "HAT": "HAT", "UYT": "UYT", "CDT": "CDT", "OESZ": "OESZ", "CLT": "CLT", "MDT": "MDT", "HEEG": "HEEG", "EAT": "EAT", "IST": "IST", "ACWDT": "ACWDT", "HENOMX": "HENOMX", "CLST": "CLST", "HNPM": "HNPM", "SAST": "SAST", "SRT": "SRT", "WITA": "WITA", "ChST": "ChST", "CAT": "CAT", "MEZ": "MEZ", "JST": "JST", "WEZ": "WEZ", "HKST": "HKST", "ACST": "ACST", "AWDT": "AWDT", "BOT": "BOT", "HEOG": "HEOG", "UYST": "UYST", "WIB": "WIB", "PDT": "PDT", "ACWST": "ACWST", "WARST": "WARST", "EST": "EST", "BT": "BT", "HEPMX": "HEPMX", "∅∅∅": "∅∅∅", "ECT": "ECT", "ACDT": "ACDT", "COST": "COST", "OEZ": "OEZ", "TMT": "TMT", "WIT": "WIT", "CHADT": "CHADT", "HAST": "HAST", "MESZ": "MESZ", "VET": "VET", "JDT": "JDT", "COT": "COT", "LHST": "LHST", "LHDT": "LHDT", "AWST": "AWST", "PST": "PST", "WESZ": "WESZ", "WART": "WART", "WAT": "WAT"}, + } +} + +// Locale returns the current translators string locale +func (mfe *mfe) Locale() string { + return mfe.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mfe' +func (mfe *mfe) PluralsCardinal() []locales.PluralRule { + return mfe.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mfe' +func (mfe *mfe) PluralsOrdinal() []locales.PluralRule { + return mfe.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mfe' +func (mfe *mfe) PluralsRange() []locales.PluralRule { + return mfe.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mfe' +func (mfe *mfe) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mfe' +func (mfe *mfe) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mfe' +func (mfe *mfe) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mfe *mfe) MonthAbbreviated(month time.Month) string { + return mfe.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mfe *mfe) MonthsAbbreviated() []string { + return mfe.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mfe *mfe) MonthNarrow(month time.Month) string { + return mfe.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mfe *mfe) MonthsNarrow() []string { + return mfe.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mfe *mfe) MonthWide(month time.Month) string { + return mfe.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mfe *mfe) MonthsWide() []string { + return mfe.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mfe *mfe) WeekdayAbbreviated(weekday time.Weekday) string { + return mfe.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mfe *mfe) WeekdaysAbbreviated() []string { + return mfe.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mfe *mfe) WeekdayNarrow(weekday time.Weekday) string { + return mfe.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mfe *mfe) WeekdaysNarrow() []string { + return mfe.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mfe *mfe) WeekdayShort(weekday time.Weekday) string { + return mfe.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mfe *mfe) WeekdaysShort() []string { + return mfe.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mfe *mfe) WeekdayWide(weekday time.Weekday) string { + return mfe.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mfe *mfe) WeekdaysWide() []string { + return mfe.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mfe' and handles both Whole and Real numbers based on 'v' +func (mfe *mfe) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mfe' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mfe *mfe) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mfe' +func (mfe *mfe) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mfe.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mfe.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mfe.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mfe.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, mfe.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mfe.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mfe' +// in accounting notation. +func (mfe *mfe) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mfe.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mfe.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mfe.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, mfe.currencyNegativePrefix[j]) + } + + b = append(b, mfe.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mfe.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mfe.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, mfe.currencyNegativeSuffix...) + } else { + + b = append(b, mfe.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mfe' +func (mfe *mfe) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mfe' +func (mfe *mfe) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mfe.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mfe' +func (mfe *mfe) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mfe.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mfe' +func (mfe *mfe) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mfe.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mfe.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mfe' +func (mfe *mfe) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mfe' +func (mfe *mfe) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mfe' +func (mfe *mfe) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mfe' +func (mfe *mfe) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mfe.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mfe/mfe_test.go b/vendor/github.com/go-playground/locales/mfe/mfe_test.go new file mode 100644 index 0000000000..629852061a --- /dev/null +++ b/vendor/github.com/go-playground/locales/mfe/mfe_test.go @@ -0,0 +1,1120 @@ +package mfe + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mfe" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mfe_MU/mfe_MU.go b/vendor/github.com/go-playground/locales/mfe_MU/mfe_MU.go new file mode 100644 index 0000000000..71016cf77e --- /dev/null +++ b/vendor/github.com/go-playground/locales/mfe_MU/mfe_MU.go @@ -0,0 +1,484 @@ +package mfe_MU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mfe_MU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mfe_MU' locale +func New() locales.Translator { + return &mfe_MU{ + locale: "mfe_MU", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "zan", "fev", "mar", "avr", "me", "zin", "zil", "out", "sep", "okt", "nov", "des"}, + monthsNarrow: []string{"", "z", "f", "m", "a", "m", "z", "z", "o", "s", "o", "n", "d"}, + monthsWide: []string{"", "zanvie", "fevriye", "mars", "avril", "me", "zin", "zilye", "out", "septam", "oktob", "novam", "desam"}, + daysAbbreviated: []string{"dim", "lin", "mar", "mer", "ze", "van", "sam"}, + daysNarrow: []string{"d", "l", "m", "m", "z", "v", "s"}, + daysWide: []string{"dimans", "lindi", "mardi", "merkredi", "zedi", "vandredi", "samdi"}, + erasAbbreviated: []string{"av. Z-K", "ap. Z-K"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"avan Zezi-Krist", "apre Zezi-Krist"}, + timezones: map[string]string{"HADT": "HADT", "NZDT": "NZDT", "HENOMX": "HENOMX", "LHDT": "LHDT", "IST": "IST", "MYT": "MYT", "HNOG": "HNOG", "TMST": "TMST", "ARST": "ARST", "UYST": "UYST", "EAT": "EAT", "ACWST": "ACWST", "ACWDT": "ACWDT", "WART": "WART", "HKT": "HKT", "COST": "COST", "HNT": "HNT", "HECU": "HECU", "ECT": "ECT", "PDT": "PDT", "AST": "AST", "HEEG": "HEEG", "HNPM": "HNPM", "HNPMX": "HNPMX", "AWST": "AWST", "∅∅∅": "∅∅∅", "MEZ": "MEZ", "JST": "JST", "TMT": "TMT", "HKST": "HKST", "AKDT": "AKDT", "ChST": "ChST", "HEPMX": "HEPMX", "SRT": "SRT", "CHADT": "CHADT", "CLST": "CLST", "WEZ": "WEZ", "MST": "MST", "AEDT": "AEDT", "LHST": "LHST", "GYT": "GYT", "HNCU": "HNCU", "WARST": "WARST", "CLT": "CLT", "HAT": "HAT", "GFT": "GFT", "BOT": "BOT", "EST": "EST", "HEPM": "HEPM", "MESZ": "MESZ", "MDT": "MDT", "WAST": "WAST", "CST": "CST", "VET": "VET", "HEOG": "HEOG", "GMT": "GMT", "ART": "ART", "WITA": "WITA", "AWDT": "AWDT", "CAT": "CAT", "NZST": "NZST", "ADT": "ADT", "OESZ": "OESZ", "WESZ": "WESZ", "UYT": "UYT", "WIT": "WIT", "JDT": "JDT", "ACST": "ACST", "WIB": "WIB", "CDT": "CDT", "PST": "PST", "HNNOMX": "HNNOMX", "SAST": "SAST", "HAST": "HAST", "OEZ": "OEZ", "WAT": "WAT", "COT": "COT", "BT": "BT", "HNEG": "HNEG", "AKST": "AKST", "AEST": "AEST", "EDT": "EDT", "ACDT": "ACDT", "CHAST": "CHAST", "SGT": "SGT"}, + } +} + +// Locale returns the current translators string locale +func (mfe *mfe_MU) Locale() string { + return mfe.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mfe_MU' +func (mfe *mfe_MU) PluralsCardinal() []locales.PluralRule { + return mfe.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mfe_MU' +func (mfe *mfe_MU) PluralsOrdinal() []locales.PluralRule { + return mfe.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mfe_MU' +func (mfe *mfe_MU) PluralsRange() []locales.PluralRule { + return mfe.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mfe_MU' +func (mfe *mfe_MU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mfe_MU' +func (mfe *mfe_MU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mfe_MU' +func (mfe *mfe_MU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mfe *mfe_MU) MonthAbbreviated(month time.Month) string { + return mfe.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mfe *mfe_MU) MonthsAbbreviated() []string { + return mfe.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mfe *mfe_MU) MonthNarrow(month time.Month) string { + return mfe.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mfe *mfe_MU) MonthsNarrow() []string { + return mfe.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mfe *mfe_MU) MonthWide(month time.Month) string { + return mfe.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mfe *mfe_MU) MonthsWide() []string { + return mfe.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mfe *mfe_MU) WeekdayAbbreviated(weekday time.Weekday) string { + return mfe.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mfe *mfe_MU) WeekdaysAbbreviated() []string { + return mfe.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mfe *mfe_MU) WeekdayNarrow(weekday time.Weekday) string { + return mfe.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mfe *mfe_MU) WeekdaysNarrow() []string { + return mfe.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mfe *mfe_MU) WeekdayShort(weekday time.Weekday) string { + return mfe.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mfe *mfe_MU) WeekdaysShort() []string { + return mfe.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mfe *mfe_MU) WeekdayWide(weekday time.Weekday) string { + return mfe.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mfe *mfe_MU) WeekdaysWide() []string { + return mfe.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mfe_MU' and handles both Whole and Real numbers based on 'v' +func (mfe *mfe_MU) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mfe_MU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mfe *mfe_MU) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mfe_MU' +func (mfe *mfe_MU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mfe.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mfe.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mfe.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mfe.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, mfe.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mfe.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mfe_MU' +// in accounting notation. +func (mfe *mfe_MU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mfe.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mfe.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mfe.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, mfe.currencyNegativePrefix[j]) + } + + b = append(b, mfe.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mfe.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mfe.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, mfe.currencyNegativeSuffix...) + } else { + + b = append(b, mfe.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mfe_MU' +func (mfe *mfe_MU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mfe_MU' +func (mfe *mfe_MU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mfe.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mfe_MU' +func (mfe *mfe_MU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mfe.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mfe_MU' +func (mfe *mfe_MU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mfe.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mfe.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mfe_MU' +func (mfe *mfe_MU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mfe_MU' +func (mfe *mfe_MU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mfe_MU' +func (mfe *mfe_MU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mfe_MU' +func (mfe *mfe_MU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mfe.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mfe.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mfe_MU/mfe_MU_test.go b/vendor/github.com/go-playground/locales/mfe_MU/mfe_MU_test.go new file mode 100644 index 0000000000..1fa8237608 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mfe_MU/mfe_MU_test.go @@ -0,0 +1,1120 @@ +package mfe_MU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mfe_MU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mg/mg.go b/vendor/github.com/go-playground/locales/mg/mg.go new file mode 100644 index 0000000000..8329178544 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mg/mg.go @@ -0,0 +1,586 @@ +package mg + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mg struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mg' locale +func New() locales.Translator { + return &mg{ + locale: "mg", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "Ar", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "Mey", "Jon", "Jol", "Aog", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janoary", "Febroary", "Martsa", "Aprily", "Mey", "Jona", "Jolay", "Aogositra", "Septambra", "Oktobra", "Novambra", "Desambra"}, + daysAbbreviated: []string{"Alah", "Alats", "Tal", "Alar", "Alak", "Zom", "Asab"}, + daysNarrow: []string{"A", "A", "T", "A", "A", "Z", "A"}, + daysShort: []string{"Alah", "Alats", "Tal", "Alar", "Alak", "Zom", "Asab"}, + daysWide: []string{"Alahady", "Alatsinainy", "Talata", "Alarobia", "Alakamisy", "Zoma", "Asabotsy"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Alohan’i JK", "Aorian’i JK"}, + timezones: map[string]string{"PDT": "PDT", "JDT": "JDT", "EAT": "EAT", "AWST": "AWST", "ChST": "ChST", "TMT": "TMT", "EST": "EST", "HEOG": "HEOG", "GYT": "GYT", "∅∅∅": "∅∅∅", "HKT": "HKT", "WAT": "WAT", "HNPMX": "HNPMX", "AST": "AST", "TMST": "TMST", "ADT": "ADT", "COST": "COST", "HNT": "HNT", "HAT": "HAT", "SAST": "SAST", "CHADT": "CHADT", "NZST": "NZST", "ACWDT": "ACWDT", "WAST": "WAST", "WITA": "WITA", "HEPM": "HEPM", "HAST": "HAST", "IST": "IST", "ACWST": "ACWST", "OEZ": "OEZ", "WESZ": "WESZ", "CLT": "CLT", "COT": "COT", "GFT": "GFT", "WIT": "WIT", "CHAST": "CHAST", "AKST": "AKST", "SGT": "SGT", "WARST": "WARST", "EDT": "EDT", "ACDT": "ACDT", "WIB": "WIB", "CDT": "CDT", "CLST": "CLST", "HNOG": "HNOG", "ART": "ART", "CAT": "CAT", "MESZ": "MESZ", "HNNOMX": "HNNOMX", "AKDT": "AKDT", "HADT": "HADT", "NZDT": "NZDT", "MST": "MST", "AEST": "AEST", "HECU": "HECU", "BOT": "BOT", "HNEG": "HNEG", "LHST": "LHST", "LHDT": "LHDT", "SRT": "SRT", "MEZ": "MEZ", "ARST": "ARST", "OESZ": "OESZ", "WART": "WART", "BT": "BT", "UYT": "UYT", "UYST": "UYST", "CST": "CST", "AWDT": "AWDT", "MYT": "MYT", "HNPM": "HNPM", "PST": "PST", "GMT": "GMT", "VET": "VET", "MDT": "MDT", "HENOMX": "HENOMX", "ACST": "ACST", "AEDT": "AEDT", "HEPMX": "HEPMX", "HNCU": "HNCU", "ECT": "ECT", "HKST": "HKST", "HEEG": "HEEG", "JST": "JST", "WEZ": "WEZ"}, + } +} + +// Locale returns the current translators string locale +func (mg *mg) Locale() string { + return mg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mg' +func (mg *mg) PluralsCardinal() []locales.PluralRule { + return mg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mg' +func (mg *mg) PluralsOrdinal() []locales.PluralRule { + return mg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mg' +func (mg *mg) PluralsRange() []locales.PluralRule { + return mg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mg' +func (mg *mg) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mg' +func (mg *mg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mg' +func (mg *mg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mg *mg) MonthAbbreviated(month time.Month) string { + return mg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mg *mg) MonthsAbbreviated() []string { + return mg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mg *mg) MonthNarrow(month time.Month) string { + return mg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mg *mg) MonthsNarrow() []string { + return mg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mg *mg) MonthWide(month time.Month) string { + return mg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mg *mg) MonthsWide() []string { + return mg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mg *mg) WeekdayAbbreviated(weekday time.Weekday) string { + return mg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mg *mg) WeekdaysAbbreviated() []string { + return mg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mg *mg) WeekdayNarrow(weekday time.Weekday) string { + return mg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mg *mg) WeekdaysNarrow() []string { + return mg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mg *mg) WeekdayShort(weekday time.Weekday) string { + return mg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mg *mg) WeekdaysShort() []string { + return mg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mg *mg) WeekdayWide(weekday time.Weekday) string { + return mg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mg *mg) WeekdaysWide() []string { + return mg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mg' and handles both Whole and Real numbers based on 'v' +func (mg *mg) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mg' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mg *mg) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mg.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mg' +func (mg *mg) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mg.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mg' +// in accounting notation. +func (mg *mg) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mg.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mg.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mg' +func (mg *mg) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mg' +func (mg *mg) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mg' +func (mg *mg) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mg' +func (mg *mg) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mg' +func (mg *mg) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mg' +func (mg *mg) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mg' +func (mg *mg) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mg' +func (mg *mg) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mg/mg_test.go b/vendor/github.com/go-playground/locales/mg/mg_test.go new file mode 100644 index 0000000000..2cbc2164f7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mg/mg_test.go @@ -0,0 +1,1120 @@ +package mg + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mg" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mg_MG/mg_MG.go b/vendor/github.com/go-playground/locales/mg_MG/mg_MG.go new file mode 100644 index 0000000000..42dceac1f5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mg_MG/mg_MG.go @@ -0,0 +1,586 @@ +package mg_MG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mg_MG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mg_MG' locale +func New() locales.Translator { + return &mg_MG{ + locale: "mg_MG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "Mey", "Jon", "Jol", "Aog", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janoary", "Febroary", "Martsa", "Aprily", "Mey", "Jona", "Jolay", "Aogositra", "Septambra", "Oktobra", "Novambra", "Desambra"}, + daysAbbreviated: []string{"Alah", "Alats", "Tal", "Alar", "Alak", "Zom", "Asab"}, + daysNarrow: []string{"A", "A", "T", "A", "A", "Z", "A"}, + daysShort: []string{"Alah", "Alats", "Tal", "Alar", "Alak", "Zom", "Asab"}, + daysWide: []string{"Alahady", "Alatsinainy", "Talata", "Alarobia", "Alakamisy", "Zoma", "Asabotsy"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Alohan’i JK", "Aorian’i JK"}, + timezones: map[string]string{"∅∅∅": "∅∅∅", "ACWDT": "ACWDT", "WIB": "WIB", "ADT": "ADT", "ACST": "ACST", "GFT": "GFT", "AEST": "AEST", "HEPMX": "HEPMX", "WIT": "WIT", "PST": "PST", "PDT": "PDT", "MEZ": "MEZ", "MESZ": "MESZ", "ART": "ART", "HEPM": "HEPM", "CDT": "CDT", "HNPMX": "HNPMX", "JST": "JST", "COST": "COST", "LHDT": "LHDT", "CST": "CST", "CAT": "CAT", "COT": "COT", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "AKST": "AKST", "UYT": "UYT", "SGT": "SGT", "NZST": "NZST", "CLT": "CLT", "CLST": "CLST", "HNOG": "HNOG", "GYT": "GYT", "AWST": "AWST", "AWDT": "AWDT", "ECT": "ECT", "HAST": "HAST", "HADT": "HADT", "ACWST": "ACWST", "VET": "VET", "HEOG": "HEOG", "ARST": "ARST", "EAT": "EAT", "HECU": "HECU", "MDT": "MDT", "HKT": "HKT", "AEDT": "AEDT", "LHST": "LHST", "BOT": "BOT", "IST": "IST", "JDT": "JDT", "WEZ": "WEZ", "WAT": "WAT", "HKST": "HKST", "CHAST": "CHAST", "CHADT": "CHADT", "EST": "EST", "HENOMX": "HENOMX", "WITA": "WITA", "UYST": "UYST", "SRT": "SRT", "HNCU": "HNCU", "OEZ": "OEZ", "ChST": "ChST", "NZDT": "NZDT", "WART": "WART", "AST": "AST", "WESZ": "WESZ", "TMT": "TMT", "EDT": "EDT", "ACDT": "ACDT", "HAT": "HAT", "MYT": "MYT", "WARST": "WARST", "OESZ": "OESZ", "HNPM": "HNPM", "GMT": "GMT", "TMST": "TMST", "HNT": "HNT", "SAST": "SAST", "MST": "MST", "WAST": "WAST", "BT": "BT", "HNEG": "HNEG", "AKDT": "AKDT"}, + } +} + +// Locale returns the current translators string locale +func (mg *mg_MG) Locale() string { + return mg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mg_MG' +func (mg *mg_MG) PluralsCardinal() []locales.PluralRule { + return mg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mg_MG' +func (mg *mg_MG) PluralsOrdinal() []locales.PluralRule { + return mg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mg_MG' +func (mg *mg_MG) PluralsRange() []locales.PluralRule { + return mg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mg_MG' +func (mg *mg_MG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mg_MG' +func (mg *mg_MG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mg_MG' +func (mg *mg_MG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mg *mg_MG) MonthAbbreviated(month time.Month) string { + return mg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mg *mg_MG) MonthsAbbreviated() []string { + return mg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mg *mg_MG) MonthNarrow(month time.Month) string { + return mg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mg *mg_MG) MonthsNarrow() []string { + return mg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mg *mg_MG) MonthWide(month time.Month) string { + return mg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mg *mg_MG) MonthsWide() []string { + return mg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mg *mg_MG) WeekdayAbbreviated(weekday time.Weekday) string { + return mg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mg *mg_MG) WeekdaysAbbreviated() []string { + return mg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mg *mg_MG) WeekdayNarrow(weekday time.Weekday) string { + return mg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mg *mg_MG) WeekdaysNarrow() []string { + return mg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mg *mg_MG) WeekdayShort(weekday time.Weekday) string { + return mg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mg *mg_MG) WeekdaysShort() []string { + return mg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mg *mg_MG) WeekdayWide(weekday time.Weekday) string { + return mg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mg *mg_MG) WeekdaysWide() []string { + return mg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mg_MG' and handles both Whole and Real numbers based on 'v' +func (mg *mg_MG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mg_MG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mg *mg_MG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mg.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mg_MG' +func (mg *mg_MG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mg.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mg_MG' +// in accounting notation. +func (mg *mg_MG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mg.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mg.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mg_MG' +func (mg *mg_MG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mg_MG' +func (mg *mg_MG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mg_MG' +func (mg *mg_MG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mg_MG' +func (mg *mg_MG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mg_MG' +func (mg *mg_MG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mg_MG' +func (mg *mg_MG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mg_MG' +func (mg *mg_MG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mg_MG' +func (mg *mg_MG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mg_MG/mg_MG_test.go b/vendor/github.com/go-playground/locales/mg_MG/mg_MG_test.go new file mode 100644 index 0000000000..04572823a7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mg_MG/mg_MG_test.go @@ -0,0 +1,1120 @@ +package mg_MG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mg_MG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mgh/mgh.go b/vendor/github.com/go-playground/locales/mgh/mgh.go new file mode 100644 index 0000000000..a806c928c3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mgh/mgh.go @@ -0,0 +1,497 @@ +package mgh + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mgh struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mgh' locale +func New() locales.Translator { + return &mgh{ + locale: "mgh", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MTn", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "Kwa", "Una", "Rar", "Che", "Tha", "Moc", "Sab", "Nan", "Tis", "Kum", "Moj", "Yel"}, + monthsNarrow: []string{"", "K", "U", "R", "C", "T", "M", "S", "N", "T", "K", "M", "Y"}, + monthsWide: []string{"", "Mweri wo kwanza", "Mweri wo unayeli", "Mweri wo uneraru", "Mweri wo unecheshe", "Mweri wo unethanu", "Mweri wo thanu na mocha", "Mweri wo saba", "Mweri wo nane", "Mweri wo tisa", "Mweri wo kumi", "Mweri wo kumi na moja", "Mweri wo kumi na yel’li"}, + daysAbbreviated: []string{"Sab", "Jtt", "Jnn", "Jtn", "Ara", "Iju", "Jmo"}, + daysNarrow: []string{"S", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Sabato", "Jumatatu", "Jumanne", "Jumatano", "Arahamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"wichishu", "mchochil’l"}, + periodsWide: []string{"wichishu", "mchochil’l"}, + erasAbbreviated: []string{"HY", "YY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Hinapiya yesu", "Yopia yesu"}, + timezones: map[string]string{"GYT": "GYT", "CST": "CST", "WIT": "WIT", "MESZ": "MESZ", "HNOG": "HNOG", "WART": "WART", "UYST": "UYST", "ChST": "ChST", "BOT": "BOT", "MST": "MST", "HKT": "HKT", "COST": "COST", "HNNOMX": "HNNOMX", "LHST": "LHST", "LHDT": "LHDT", "WARST": "WARST", "ARST": "ARST", "HNCU": "HNCU", "PDT": "PDT", "CLST": "CLST", "ADT": "ADT", "WEZ": "WEZ", "CDT": "CDT", "CHADT": "CHADT", "IST": "IST", "HKST": "HKST", "WITA": "WITA", "HEPM": "HEPM", "HEOG": "HEOG", "WESZ": "WESZ", "ART": "ART", "AKDT": "AKDT", "EAT": "EAT", "CLT": "CLT", "TMST": "TMST", "MDT": "MDT", "WAST": "WAST", "HNEG": "HNEG", "HEPMX": "HEPMX", "SRT": "SRT", "ECT": "ECT", "∅∅∅": "∅∅∅", "VET": "VET", "BT": "BT", "MEZ": "MEZ", "ACDT": "ACDT", "COT": "COT", "SAST": "SAST", "TMT": "TMT", "AKST": "AKST", "HECU": "HECU", "PST": "PST", "CAT": "CAT", "GMT": "GMT", "MYT": "MYT", "JST": "JST", "AST": "AST", "WAT": "WAT", "HAT": "HAT", "CHAST": "CHAST", "ACWST": "ACWST", "AEST": "AEST", "GFT": "GFT", "AWDT": "AWDT", "SGT": "SGT", "ACWDT": "ACWDT", "OEZ": "OEZ", "HNT": "HNT", "UYT": "UYT", "HNPM": "HNPM", "NZDT": "NZDT", "EST": "EST", "HENOMX": "HENOMX", "HEEG": "HEEG", "HADT": "HADT", "JDT": "JDT", "EDT": "EDT", "AEDT": "AEDT", "HNPMX": "HNPMX", "WIB": "WIB", "AWST": "AWST", "HAST": "HAST", "NZST": "NZST", "OESZ": "OESZ", "ACST": "ACST"}, + } +} + +// Locale returns the current translators string locale +func (mgh *mgh) Locale() string { + return mgh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mgh' +func (mgh *mgh) PluralsCardinal() []locales.PluralRule { + return mgh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mgh' +func (mgh *mgh) PluralsOrdinal() []locales.PluralRule { + return mgh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mgh' +func (mgh *mgh) PluralsRange() []locales.PluralRule { + return mgh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mgh' +func (mgh *mgh) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mgh' +func (mgh *mgh) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mgh' +func (mgh *mgh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mgh *mgh) MonthAbbreviated(month time.Month) string { + return mgh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mgh *mgh) MonthsAbbreviated() []string { + return mgh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mgh *mgh) MonthNarrow(month time.Month) string { + return mgh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mgh *mgh) MonthsNarrow() []string { + return mgh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mgh *mgh) MonthWide(month time.Month) string { + return mgh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mgh *mgh) MonthsWide() []string { + return mgh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mgh *mgh) WeekdayAbbreviated(weekday time.Weekday) string { + return mgh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mgh *mgh) WeekdaysAbbreviated() []string { + return mgh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mgh *mgh) WeekdayNarrow(weekday time.Weekday) string { + return mgh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mgh *mgh) WeekdaysNarrow() []string { + return mgh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mgh *mgh) WeekdayShort(weekday time.Weekday) string { + return mgh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mgh *mgh) WeekdaysShort() []string { + return mgh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mgh *mgh) WeekdayWide(weekday time.Weekday) string { + return mgh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mgh *mgh) WeekdaysWide() []string { + return mgh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mgh' and handles both Whole and Real numbers based on 'v' +func (mgh *mgh) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mgh' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mgh *mgh) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mgh' +func (mgh *mgh) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mgh.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgh.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mgh.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, mgh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mgh.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mgh' +// in accounting notation. +func (mgh *mgh) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mgh.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgh.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, mgh.currencyNegativePrefix[j]) + } + + b = append(b, mgh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgh.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mgh.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, mgh.currencyNegativeSuffix...) + } else { + + b = append(b, mgh.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mgh' +func (mgh *mgh) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mgh' +func (mgh *mgh) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mgh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mgh' +func (mgh *mgh) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mgh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mgh' +func (mgh *mgh) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mgh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mgh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mgh' +func (mgh *mgh) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mgh' +func (mgh *mgh) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mgh' +func (mgh *mgh) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mgh' +func (mgh *mgh) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mgh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mgh/mgh_test.go b/vendor/github.com/go-playground/locales/mgh/mgh_test.go new file mode 100644 index 0000000000..eeb29c8b76 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mgh/mgh_test.go @@ -0,0 +1,1120 @@ +package mgh + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mgh" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mgh_MZ/mgh_MZ.go b/vendor/github.com/go-playground/locales/mgh_MZ/mgh_MZ.go new file mode 100644 index 0000000000..d03ebc2653 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mgh_MZ/mgh_MZ.go @@ -0,0 +1,497 @@ +package mgh_MZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mgh_MZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mgh_MZ' locale +func New() locales.Translator { + return &mgh_MZ{ + locale: "mgh_MZ", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "Kwa", "Una", "Rar", "Che", "Tha", "Moc", "Sab", "Nan", "Tis", "Kum", "Moj", "Yel"}, + monthsNarrow: []string{"", "K", "U", "R", "C", "T", "M", "S", "N", "T", "K", "M", "Y"}, + monthsWide: []string{"", "Mweri wo kwanza", "Mweri wo unayeli", "Mweri wo uneraru", "Mweri wo unecheshe", "Mweri wo unethanu", "Mweri wo thanu na mocha", "Mweri wo saba", "Mweri wo nane", "Mweri wo tisa", "Mweri wo kumi", "Mweri wo kumi na moja", "Mweri wo kumi na yel’li"}, + daysAbbreviated: []string{"Sab", "Jtt", "Jnn", "Jtn", "Ara", "Iju", "Jmo"}, + daysNarrow: []string{"S", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Sabato", "Jumatatu", "Jumanne", "Jumatano", "Arahamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"wichishu", "mchochil’l"}, + periodsWide: []string{"wichishu", "mchochil’l"}, + erasAbbreviated: []string{"HY", "YY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Hinapiya yesu", "Yopia yesu"}, + timezones: map[string]string{"CAT": "CAT", "WARST": "WARST", "WITA": "WITA", "PST": "PST", "NZDT": "NZDT", "HKT": "HKT", "GFT": "GFT", "LHST": "LHST", "HECU": "HECU", "OEZ": "OEZ", "GMT": "GMT", "CLST": "CLST", "AEDT": "AEDT", "HNPM": "HNPM", "SRT": "SRT", "ACDT": "ACDT", "HEPM": "HEPM", "ACWST": "ACWST", "MDT": "MDT", "ARST": "ARST", "HKST": "HKST", "HENOMX": "HENOMX", "HNT": "HNT", "HAT": "HAT", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "BOT": "BOT", "MESZ": "MESZ", "HNOG": "HNOG", "SGT": "SGT", "HAST": "HAST", "∅∅∅": "∅∅∅", "MYT": "MYT", "EST": "EST", "HNNOMX": "HNNOMX", "CST": "CST", "WIT": "WIT", "NZST": "NZST", "WEZ": "WEZ", "EDT": "EDT", "ACST": "ACST", "COT": "COT", "SAST": "SAST", "ACWDT": "ACWDT", "AST": "AST", "TMST": "TMST", "ART": "ART", "VET": "VET", "WAST": "WAST", "HNEG": "HNEG", "CHAST": "CHAST", "JST": "JST", "ADT": "ADT", "TMT": "TMT", "MST": "MST", "AKST": "AKST", "EAT": "EAT", "HNCU": "HNCU", "CDT": "CDT", "COST": "COST", "GYT": "GYT", "CHADT": "CHADT", "MEZ": "MEZ", "CLT": "CLT", "HEOG": "HEOG", "WAT": "WAT", "AKDT": "AKDT", "AEST": "AEST", "UYT": "UYT", "AWDT": "AWDT", "HADT": "HADT", "OESZ": "OESZ", "WESZ": "WESZ", "ChST": "ChST", "UYST": "UYST", "LHDT": "LHDT", "PDT": "PDT", "ECT": "ECT", "BT": "BT", "AWST": "AWST", "IST": "IST", "JDT": "JDT", "WART": "WART", "HEEG": "HEEG", "WIB": "WIB"}, + } +} + +// Locale returns the current translators string locale +func (mgh *mgh_MZ) Locale() string { + return mgh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mgh_MZ' +func (mgh *mgh_MZ) PluralsCardinal() []locales.PluralRule { + return mgh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mgh_MZ' +func (mgh *mgh_MZ) PluralsOrdinal() []locales.PluralRule { + return mgh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mgh_MZ' +func (mgh *mgh_MZ) PluralsRange() []locales.PluralRule { + return mgh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mgh_MZ' +func (mgh *mgh_MZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mgh_MZ' +func (mgh *mgh_MZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mgh_MZ' +func (mgh *mgh_MZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mgh *mgh_MZ) MonthAbbreviated(month time.Month) string { + return mgh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mgh *mgh_MZ) MonthsAbbreviated() []string { + return mgh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mgh *mgh_MZ) MonthNarrow(month time.Month) string { + return mgh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mgh *mgh_MZ) MonthsNarrow() []string { + return mgh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mgh *mgh_MZ) MonthWide(month time.Month) string { + return mgh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mgh *mgh_MZ) MonthsWide() []string { + return mgh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mgh *mgh_MZ) WeekdayAbbreviated(weekday time.Weekday) string { + return mgh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mgh *mgh_MZ) WeekdaysAbbreviated() []string { + return mgh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mgh *mgh_MZ) WeekdayNarrow(weekday time.Weekday) string { + return mgh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mgh *mgh_MZ) WeekdaysNarrow() []string { + return mgh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mgh *mgh_MZ) WeekdayShort(weekday time.Weekday) string { + return mgh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mgh *mgh_MZ) WeekdaysShort() []string { + return mgh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mgh *mgh_MZ) WeekdayWide(weekday time.Weekday) string { + return mgh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mgh *mgh_MZ) WeekdaysWide() []string { + return mgh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mgh_MZ' and handles both Whole and Real numbers based on 'v' +func (mgh *mgh_MZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mgh_MZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mgh *mgh_MZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mgh.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgh.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mgh.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, mgh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mgh.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mgh_MZ' +// in accounting notation. +func (mgh *mgh_MZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mgh.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgh.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, mgh.currencyNegativePrefix[j]) + } + + b = append(b, mgh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgh.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mgh.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, mgh.currencyNegativeSuffix...) + } else { + + b = append(b, mgh.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mgh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mgh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mgh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mgh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mgh_MZ' +func (mgh *mgh_MZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mgh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mgh_MZ/mgh_MZ_test.go b/vendor/github.com/go-playground/locales/mgh_MZ/mgh_MZ_test.go new file mode 100644 index 0000000000..d164502d15 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mgh_MZ/mgh_MZ_test.go @@ -0,0 +1,1120 @@ +package mgh_MZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mgh_MZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mgo/mgo.go b/vendor/github.com/go-playground/locales/mgo/mgo.go new file mode 100644 index 0000000000..b59f67eec3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mgo/mgo.go @@ -0,0 +1,607 @@ +package mgo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mgo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mgo' locale +func New() locales.Translator { + return &mgo{ + locale: "mgo", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "mbegtug", "imeg àbùbì", "imeg mbəŋchubi", "iməg ngwə̀t", "iməg fog", "iməg ichiibɔd", "iməg àdùmbə̀ŋ", "iməg ichika", "iməg kud", "iməg tèsiʼe", "iməg zò", "iməg krizmed"}, + monthsNarrow: []string{"", "M1", "A2", "M3", "N4", "F5", "I6", "A7", "I8", "K9", "10", "11", "12"}, + monthsWide: []string{"", "iməg mbegtug", "imeg àbùbì", "imeg mbəŋchubi", "iməg ngwə̀t", "iməg fog", "iməg ichiibɔd", "iməg àdùmbə̀ŋ", "iməg ichika", "iməg kud", "iməg tèsiʼe", "iməg zò", "iməg krizmed"}, + daysAbbreviated: []string{"Aneg 1", "Aneg 2", "Aneg 3", "Aneg 4", "Aneg 5", "Aneg 6", "Aneg 7"}, + daysNarrow: []string{"A1", "A2", "A3", "A4", "A5", "A6", "A7"}, + daysShort: []string{"1", "2", "3", "4", "5", "6", "7"}, + daysWide: []string{"Aneg 1", "Aneg 2", "Aneg 3", "Aneg 4", "Aneg 5", "Aneg 6", "Aneg 7"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ARST": "ARST", "COT": "COT", "HNEG": "HNEG", "WITA": "WITA", "AWDT": "AWDT", "BOT": "BOT", "AEST": "AEST", "MEZ": "MEZ", "HKT": "HKT", "WIB": "WIB", "AST": "AST", "WAT": "WAT", "NZDT": "NZDT", "JST": "JST", "MDT": "MDT", "ChST": "ChST", "LHDT": "LHDT", "CHADT": "CHADT", "HAST": "HAST", "ACWDT": "ACWDT", "WESZ": "WESZ", "MYT": "MYT", "ACST": "ACST", "HEPMX": "HEPMX", "HNCU": "HNCU", "ECT": "ECT", "PST": "PST", "JDT": "JDT", "CLT": "CLT", "HNOG": "HNOG", "WAST": "WAST", "EDT": "EDT", "HEEG": "HEEG", "CST": "CST", "MESZ": "MESZ", "GFT": "GFT", "HECU": "HECU", "TMT": "TMT", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "BT": "BT", "HAT": "HAT", "HNPM": "HNPM", "IST": "IST", "ACWST": "ACWST", "COST": "COST", "HNT": "HNT", "ART": "ART", "HKST": "HKST", "UYST": "UYST", "SRT": "SRT", "VET": "VET", "TMST": "TMST", "EAT": "EAT", "EST": "EST", "UYT": "UYT", "HEOG": "HEOG", "ADT": "ADT", "GMT": "GMT", "HENOMX": "HENOMX", "HADT": "HADT", "WART": "WART", "AEDT": "AEDT", "LHST": "LHST", "GYT": "GYT", "CHAST": "CHAST", "AKST": "AKST", "SGT": "SGT", "CAT": "CAT", "CLST": "CLST", "HNPMX": "HNPMX", "∅∅∅": "∅∅∅", "AWST": "AWST", "HEPM": "HEPM", "OEZ": "OEZ", "WEZ": "WEZ", "NZST": "NZST", "MST": "MST", "PDT": "PDT", "WARST": "WARST", "OESZ": "OESZ", "AKDT": "AKDT", "SAST": "SAST", "CDT": "CDT", "WIT": "WIT"}, + } +} + +// Locale returns the current translators string locale +func (mgo *mgo) Locale() string { + return mgo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mgo' +func (mgo *mgo) PluralsCardinal() []locales.PluralRule { + return mgo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mgo' +func (mgo *mgo) PluralsOrdinal() []locales.PluralRule { + return mgo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mgo' +func (mgo *mgo) PluralsRange() []locales.PluralRule { + return mgo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mgo' +func (mgo *mgo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mgo' +func (mgo *mgo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mgo' +func (mgo *mgo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mgo *mgo) MonthAbbreviated(month time.Month) string { + return mgo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mgo *mgo) MonthsAbbreviated() []string { + return mgo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mgo *mgo) MonthNarrow(month time.Month) string { + return mgo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mgo *mgo) MonthsNarrow() []string { + return mgo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mgo *mgo) MonthWide(month time.Month) string { + return mgo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mgo *mgo) MonthsWide() []string { + return mgo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mgo *mgo) WeekdayAbbreviated(weekday time.Weekday) string { + return mgo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mgo *mgo) WeekdaysAbbreviated() []string { + return mgo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mgo *mgo) WeekdayNarrow(weekday time.Weekday) string { + return mgo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mgo *mgo) WeekdaysNarrow() []string { + return mgo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mgo *mgo) WeekdayShort(weekday time.Weekday) string { + return mgo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mgo *mgo) WeekdaysShort() []string { + return mgo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mgo *mgo) WeekdayWide(weekday time.Weekday) string { + return mgo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mgo *mgo) WeekdaysWide() []string { + return mgo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mgo' and handles both Whole and Real numbers based on 'v' +func (mgo *mgo) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mgo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mgo *mgo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mgo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mgo' +func (mgo *mgo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mgo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mgo.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, mgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mgo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mgo' +// in accounting notation. +func (mgo *mgo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mgo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, mgo.currencyNegativePrefix[j]) + } + + b = append(b, mgo.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mgo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mgo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mgo' +func (mgo *mgo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mgo' +func (mgo *mgo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mgo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mgo' +func (mgo *mgo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mgo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mgo' +func (mgo *mgo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mgo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mgo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mgo' +func (mgo *mgo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mgo' +func (mgo *mgo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mgo' +func (mgo *mgo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mgo' +func (mgo *mgo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mgo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mgo/mgo_test.go b/vendor/github.com/go-playground/locales/mgo/mgo_test.go new file mode 100644 index 0000000000..8f681c6aff --- /dev/null +++ b/vendor/github.com/go-playground/locales/mgo/mgo_test.go @@ -0,0 +1,1120 @@ +package mgo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mgo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mgo_CM/mgo_CM.go b/vendor/github.com/go-playground/locales/mgo_CM/mgo_CM.go new file mode 100644 index 0000000000..00f0da7525 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mgo_CM/mgo_CM.go @@ -0,0 +1,607 @@ +package mgo_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mgo_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mgo_CM' locale +func New() locales.Translator { + return &mgo_CM{ + locale: "mgo_CM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "mbegtug", "imeg àbùbì", "imeg mbəŋchubi", "iməg ngwə̀t", "iməg fog", "iməg ichiibɔd", "iməg àdùmbə̀ŋ", "iməg ichika", "iməg kud", "iməg tèsiʼe", "iməg zò", "iməg krizmed"}, + monthsNarrow: []string{"", "M1", "A2", "M3", "N4", "F5", "I6", "A7", "I8", "K9", "10", "11", "12"}, + monthsWide: []string{"", "iməg mbegtug", "imeg àbùbì", "imeg mbəŋchubi", "iməg ngwə̀t", "iməg fog", "iməg ichiibɔd", "iməg àdùmbə̀ŋ", "iməg ichika", "iməg kud", "iməg tèsiʼe", "iməg zò", "iməg krizmed"}, + daysAbbreviated: []string{"Aneg 1", "Aneg 2", "Aneg 3", "Aneg 4", "Aneg 5", "Aneg 6", "Aneg 7"}, + daysNarrow: []string{"A1", "A2", "A3", "A4", "A5", "A6", "A7"}, + daysShort: []string{"1", "2", "3", "4", "5", "6", "7"}, + daysWide: []string{"Aneg 1", "Aneg 2", "Aneg 3", "Aneg 4", "Aneg 5", "Aneg 6", "Aneg 7"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HAST": "HAST", "∅∅∅": "∅∅∅", "WART": "WART", "HKST": "HKST", "WIT": "WIT", "MESZ": "MESZ", "WESZ": "WESZ", "WITA": "WITA", "HEPM": "HEPM", "CHADT": "CHADT", "MYT": "MYT", "CLST": "CLST", "EST": "EST", "COT": "COT", "HNEG": "HNEG", "AKDT": "AKDT", "PST": "PST", "IST": "IST", "OEZ": "OEZ", "TMST": "TMST", "CST": "CST", "HECU": "HECU", "SGT": "SGT", "NZST": "NZST", "OESZ": "OESZ", "WARST": "WARST", "WAT": "WAT", "GFT": "GFT", "LHST": "LHST", "MEZ": "MEZ", "AST": "AST", "EDT": "EDT", "HEPMX": "HEPMX", "HNCU": "HNCU", "BOT": "BOT", "ACST": "ACST", "WIB": "WIB", "PDT": "PDT", "HADT": "HADT", "VET": "VET", "HNOG": "HNOG", "TMT": "TMT", "MDT": "MDT", "HNNOMX": "HNNOMX", "HAT": "HAT", "CAT": "CAT", "ACWST": "ACWST", "ADT": "ADT", "ART": "ART", "SAST": "SAST", "HNPMX": "HNPMX", "EAT": "EAT", "JDT": "JDT", "ACDT": "ACDT", "AKST": "AKST", "AEST": "AEST", "UYT": "UYT", "HNPM": "HNPM", "JST": "JST", "HEOG": "HEOG", "ARST": "ARST", "HKT": "HKT", "HENOMX": "HENOMX", "CDT": "CDT", "ACWDT": "ACWDT", "WEZ": "WEZ", "COST": "COST", "HNT": "HNT", "GYT": "GYT", "NZDT": "NZDT", "HEEG": "HEEG", "ChST": "ChST", "AWDT": "AWDT", "BT": "BT", "AEDT": "AEDT", "ECT": "ECT", "MST": "MST", "UYST": "UYST", "CHAST": "CHAST", "GMT": "GMT", "CLT": "CLT", "WAST": "WAST", "LHDT": "LHDT", "SRT": "SRT", "AWST": "AWST"}, + } +} + +// Locale returns the current translators string locale +func (mgo *mgo_CM) Locale() string { + return mgo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mgo_CM' +func (mgo *mgo_CM) PluralsCardinal() []locales.PluralRule { + return mgo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mgo_CM' +func (mgo *mgo_CM) PluralsOrdinal() []locales.PluralRule { + return mgo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mgo_CM' +func (mgo *mgo_CM) PluralsRange() []locales.PluralRule { + return mgo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mgo_CM' +func (mgo *mgo_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mgo_CM' +func (mgo *mgo_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mgo_CM' +func (mgo *mgo_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mgo *mgo_CM) MonthAbbreviated(month time.Month) string { + return mgo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mgo *mgo_CM) MonthsAbbreviated() []string { + return mgo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mgo *mgo_CM) MonthNarrow(month time.Month) string { + return mgo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mgo *mgo_CM) MonthsNarrow() []string { + return mgo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mgo *mgo_CM) MonthWide(month time.Month) string { + return mgo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mgo *mgo_CM) MonthsWide() []string { + return mgo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mgo *mgo_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return mgo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mgo *mgo_CM) WeekdaysAbbreviated() []string { + return mgo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mgo *mgo_CM) WeekdayNarrow(weekday time.Weekday) string { + return mgo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mgo *mgo_CM) WeekdaysNarrow() []string { + return mgo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mgo *mgo_CM) WeekdayShort(weekday time.Weekday) string { + return mgo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mgo *mgo_CM) WeekdaysShort() []string { + return mgo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mgo *mgo_CM) WeekdayWide(weekday time.Weekday) string { + return mgo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mgo *mgo_CM) WeekdaysWide() []string { + return mgo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mgo_CM' and handles both Whole and Real numbers based on 'v' +func (mgo *mgo_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mgo_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mgo *mgo_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mgo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mgo_CM' +func (mgo *mgo_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mgo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mgo.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, mgo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mgo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mgo_CM' +// in accounting notation. +func (mgo *mgo_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mgo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mgo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mgo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgo.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, mgo.currencyNegativePrefix[j]) + } + + b = append(b, mgo.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mgo.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mgo.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mgo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mgo_CM' +func (mgo *mgo_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mgo_CM' +func (mgo *mgo_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mgo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mgo_CM' +func (mgo *mgo_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mgo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mgo_CM' +func (mgo *mgo_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mgo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mgo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mgo_CM' +func (mgo *mgo_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mgo_CM' +func (mgo *mgo_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mgo_CM' +func (mgo *mgo_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mgo_CM' +func (mgo *mgo_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mgo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mgo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mgo_CM/mgo_CM_test.go b/vendor/github.com/go-playground/locales/mgo_CM/mgo_CM_test.go new file mode 100644 index 0000000000..fc88b58db6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mgo_CM/mgo_CM_test.go @@ -0,0 +1,1120 @@ +package mgo_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mgo_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mk/mk.go b/vendor/github.com/go-playground/locales/mk/mk.go new file mode 100644 index 0000000000..a089b2f772 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mk/mk.go @@ -0,0 +1,613 @@ +package mk + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mk struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mk' locale +func New() locales.Translator { + return &mk{ + locale: "mk", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 5, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "ден", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "јан.", "фев.", "мар.", "апр.", "мај", "јун.", "јул.", "авг.", "септ.", "окт.", "ноем.", "дек."}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"}, + daysAbbreviated: []string{"нед.", "пон.", "вт.", "сре.", "чет.", "пет.", "саб."}, + daysNarrow: []string{"н", "п", "в", "с", "ч", "п", "с"}, + daysShort: []string{"нед.", "пон.", "вто.", "сре.", "чет.", "пет.", "саб."}, + daysWide: []string{"недела", "понеделник", "вторник", "среда", "четврток", "петок", "сабота"}, + periodsAbbreviated: []string{"претпл.", "попл."}, + periodsNarrow: []string{"претпл.", "попл."}, + periodsWide: []string{"претпладне", "попладне"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"пр.н.е.", "н.е."}, + erasWide: []string{"пред нашата ера", "од нашата ера"}, + timezones: map[string]string{"EAT": "Источноафриканско време", "IST": "Време во Индија", "MEZ": "Средноевропско стандардно време", "AWDT": "Летно сметање на времето во Западна Австралија", "CHADT": "Летно сметање на времето во Четем", "HADT": "Летно сметање на времето во Хаваи - Алеутски острови", "WART": "Стандардно време во западна Аргентина", "EST": "Источно стандардно време", "UYT": "Стандардно време во Уругвај", "CDT": "Централно летно сметање на времето", "CLT": "Стандардно време во Чиле", "ART": "Стандардно време во Аргентина", "AEDT": "Летно сметање на времето во Источна Австралија", "LHDT": "Летно сметање на времето во Лорд Хау", "HENOMX": "Летно сметање на времето во северозападно Мексико", "CST": "Централно стандардно време во Северна Америка", "AWST": "Стандардно време во Западна Австралија", "NZST": "Стандардно време во Нов Зеланд", "VET": "Време во Венецуела", "MST": "MST", "HKT": "Стандардно време во Хонг Конг", "WIB": "Време во Западна Индонезија", "NZDT": "Летно сметање на времето во Нов Зеланд", "WARST": "Летно сметање на времето во западна Аргентина", "BT": "Време во Бутан", "HEPM": "Летно сметање на времето на Сент Пјер и Микелан", "SAST": "Време во Јужноафриканска Република", "SRT": "Време во Суринам", "HAST": "Стандардно време во Хаваи - Алеутски острови", "ACWST": "Стандардно време во Централна и Западна Австралија", "CLST": "Летно сметање на времето во Чиле", "HNT": "Стандардно време на Њуфаундленд", "HEEG": "Летно сметање на времето во Источен Гренланд", "AKST": "Стандардно време во Аљаска", "HAT": "Летно сметање на времето на Њуфаундленд", "HECU": "Летно сметање на времето во Куба", "WIT": "Време во Источна Индонезија", "SGT": "Време во Сингапур", "GMT": "Средно време по Гринич", "TMST": "Летно време во Туркменистан", "COST": "Летно сметање на времето во Колумбија", "MESZ": "Средноевропско летно време", "HKST": "Летно време во Хонг Конг", "HNEG": "Стандардно време во Источен Гренланд", "GYT": "Време во Гвајана", "HNPM": "Стандардно време на Сент Пјер и Микелан", "ECT": "Време во Еквадор", "ACWDT": "Летно сметање на времето во Централна и Западна Австралија", "MYT": "Време во Малезија", "HEOG": "Летно сметање на времето во Западен Гренланд", "WEZ": "Западноевропско стандардно време", "TMT": "Стандардно време во Туркменистан", "HNOG": "Стандардно време во Западен Гренланд", "OEZ": "Источноевропско стандардно време", "ACDT": "Летно сметање на времето во Централна Австралија", "HNPMX": "Стандардно тихоокеанско време во Мексико", "OESZ": "Источноевропско летно време", "HEPMX": "Летно тихоокеанско време во Мексико", "WITA": "Време во Централна Индонезија", "LHST": "Стандардно време во Лорд Хау", "BOT": "Време во Боливија", "PST": "Пацифичко стандардно време", "MDT": "MDT", "EDT": "Источно летно сметање на времето", "COT": "Стандардно време во Колумбија", "GFT": "Време во Француска Гвајана", "JDT": "Летно сметање на времето во Јапонија", "HNNOMX": "Стандардно време во северозападно Мексико", "AEST": "Стандардно време во Источна Австралија", "HNCU": "Стандардно време во Куба", "WAST": "Западноафриканско летно сметање на времето", "AKDT": "Летно сметање на времето во Аљаска", "UYST": "Летно сметање на времето во Уругвај", "CHAST": "Стандардно време во Четем", "JST": "Стандардно време во Јапонија", "ADT": "Атлантско летно сметање на времето", "WAT": "Западноафриканско стандардно време", "ACST": "Стандардно време во Централна Австралија", "ChST": "Време во Чаморо", "∅∅∅": "Летно сметање на времето во Бразилија", "PDT": "Пацифичко летно сметање на времето", "CAT": "Средноафриканско време", "AST": "Атлантско стандардно време", "WESZ": "Западноевропско летно време", "ARST": "Летно сметање на времето во Аргентина"}, + } +} + +// Locale returns the current translators string locale +func (mk *mk) Locale() string { + return mk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mk' +func (mk *mk) PluralsCardinal() []locales.PluralRule { + return mk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mk' +func (mk *mk) PluralsOrdinal() []locales.PluralRule { + return mk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mk' +func (mk *mk) PluralsRange() []locales.PluralRule { + return mk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mk' +func (mk *mk) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + fMod10 := f % 10 + + if (v == 0 && iMod10 == 1) || (fMod10 == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mk' +func (mk *mk) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if iMod10 == 2 && iMod100 != 12 { + return locales.PluralRuleTwo + } else if (iMod10 == 7 || iMod10 == 8) && (iMod100 != 17 && iMod100 != 18) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mk' +func (mk *mk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mk *mk) MonthAbbreviated(month time.Month) string { + return mk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mk *mk) MonthsAbbreviated() []string { + return mk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mk *mk) MonthNarrow(month time.Month) string { + return mk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mk *mk) MonthsNarrow() []string { + return mk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mk *mk) MonthWide(month time.Month) string { + return mk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mk *mk) MonthsWide() []string { + return mk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mk *mk) WeekdayAbbreviated(weekday time.Weekday) string { + return mk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mk *mk) WeekdaysAbbreviated() []string { + return mk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mk *mk) WeekdayNarrow(weekday time.Weekday) string { + return mk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mk *mk) WeekdaysNarrow() []string { + return mk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mk *mk) WeekdayShort(weekday time.Weekday) string { + return mk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mk *mk) WeekdaysShort() []string { + return mk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mk *mk) WeekdayWide(weekday time.Weekday) string { + return mk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mk *mk) WeekdaysWide() []string { + return mk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mk' and handles both Whole and Real numbers based on 'v' +func (mk *mk) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mk' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mk *mk) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mk' +func (mk *mk) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mk.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, mk.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mk' +// in accounting notation. +func (mk *mk) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mk.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, mk.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, mk.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mk' +func (mk *mk) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mk' +func (mk *mk) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mk' +func (mk *mk) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mk' +func (mk *mk) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mk.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mk' +func (mk *mk) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mk' +func (mk *mk) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mk' +func (mk *mk) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mk' +func (mk *mk) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mk/mk_test.go b/vendor/github.com/go-playground/locales/mk/mk_test.go new file mode 100644 index 0000000000..99b7cbe335 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mk/mk_test.go @@ -0,0 +1,1120 @@ +package mk + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mk" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mk_MK/mk_MK.go b/vendor/github.com/go-playground/locales/mk_MK/mk_MK.go new file mode 100644 index 0000000000..fa8452b60c --- /dev/null +++ b/vendor/github.com/go-playground/locales/mk_MK/mk_MK.go @@ -0,0 +1,613 @@ +package mk_MK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mk_MK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mk_MK' locale +func New() locales.Translator { + return &mk_MK{ + locale: "mk_MK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 5, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "јан.", "фев.", "мар.", "апр.", "мај", "јун.", "јул.", "авг.", "септ.", "окт.", "ноем.", "дек."}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"}, + daysAbbreviated: []string{"нед.", "пон.", "вт.", "сре.", "чет.", "пет.", "саб."}, + daysNarrow: []string{"н", "п", "в", "с", "ч", "п", "с"}, + daysShort: []string{"нед.", "пон.", "вто.", "сре.", "чет.", "пет.", "саб."}, + daysWide: []string{"недела", "понеделник", "вторник", "среда", "четврток", "петок", "сабота"}, + periodsAbbreviated: []string{"претпл.", "попл."}, + periodsNarrow: []string{"претпл.", "попл."}, + periodsWide: []string{"претпладне", "попладне"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"пр.н.е.", "н.е."}, + erasWide: []string{"пред нашата ера", "од нашата ера"}, + timezones: map[string]string{"GMT": "Средно време по Гринич", "WART": "Стандардно време во западна Аргентина", "WIB": "Време во Западна Индонезија", "WIT": "Време во Источна Индонезија", "SGT": "Време во Сингапур", "CAT": "Средноафриканско време", "MESZ": "Средноевропско летно време", "JDT": "Летно сметање на времето во Јапонија", "CLST": "Летно сметање на времето во Чиле", "ART": "Стандардно време во Аргентина", "UYT": "Стандардно време во Уругвај", "HEPMX": "Летно тихоокеанско време во Мексико", "ADT": "Атлантско летно сметање на времето", "WEZ": "Западноевропско стандардно време", "MDT": "MDT", "COT": "Стандардно време во Колумбија", "HNNOMX": "Стандардно време во северозападно Мексико", "AKDT": "Летно сметање на времето во Аљаска", "HECU": "Летно сметање на времето во Куба", "CHADT": "Летно сметање на времето во Четем", "MEZ": "Средноевропско стандардно време", "HNOG": "Стандардно време во Западен Гренланд", "HNPMX": "Стандардно тихоокеанско време во Мексико", "ACWST": "Стандардно време во Централна и Западна Австралија", "JST": "Стандардно време во Јапонија", "TMST": "Летно време во Туркменистан", "AKST": "Стандардно време во Аљаска", "AEST": "Стандардно време во Источна Австралија", "GFT": "Време во Француска Гвајана", "SAST": "Време во Јужноафриканска Република", "PST": "Пацифичко стандардно време", "HAST": "Стандардно време во Хаваи - Алеутски острови", "NZDT": "Летно сметање на времето во Нов Зеланд", "HEOG": "Летно сметање на времето во Западен Гренланд", "EDT": "Источно летно сметање на времето", "HKT": "Стандардно време во Хонг Конг", "COST": "Летно сметање на времето во Колумбија", "UYST": "Летно сметање на времето во Уругвај", "AWST": "Стандардно време во Западна Австралија", "CHAST": "Стандардно време во Четем", "NZST": "Стандардно време во Нов Зеланд", "OESZ": "Источноевропско летно време", "WAST": "Западноафриканско летно сметање на времето", "ACST": "Стандардно време во Централна Австралија", "ChST": "Време во Чаморо", "AWDT": "Летно сметање на времето во Западна Австралија", "HNT": "Стандардно време на Њуфаундленд", "HNEG": "Стандардно време во Источен Гренланд", "HNPM": "Стандардно време на Сент Пјер и Микелан", "LHST": "Стандардно време во Лорд Хау", "HEEG": "Летно сметање на времето во Источен Гренланд", "LHDT": "Летно сметање на времето во Лорд Хау", "EAT": "Источноафриканско време", "∅∅∅": "Летно сметање на времето во Бразилија", "IST": "Време во Индија", "MYT": "Време во Малезија", "ARST": "Летно сметање на времето во Аргентина", "EST": "Источно стандардно време", "CST": "Централно стандардно време во Северна Америка", "ACWDT": "Летно сметање на времето во Централна и Западна Австралија", "VET": "Време во Венецуела", "CLT": "Стандардно време во Чиле", "HKST": "Летно време во Хонг Конг", "BOT": "Време во Боливија", "ECT": "Време во Еквадор", "TMT": "Стандардно време во Туркменистан", "MST": "MST", "HEPM": "Летно сметање на времето на Сент Пјер и Микелан", "PDT": "Пацифичко летно сметање на времето", "OEZ": "Источноевропско стандардно време", "WARST": "Летно сметање на времето во западна Аргентина", "WITA": "Време во Централна Индонезија", "HAT": "Летно сметање на времето на Њуфаундленд", "SRT": "Време во Суринам", "GYT": "Време во Гвајана", "CDT": "Централно летно сметање на времето", "WESZ": "Западноевропско летно време", "ACDT": "Летно сметање на времето во Централна Австралија", "AEDT": "Летно сметање на времето во Источна Австралија", "HNCU": "Стандардно време во Куба", "HADT": "Летно сметање на времето во Хаваи - Алеутски острови", "AST": "Атлантско стандардно време", "WAT": "Западноафриканско стандардно време", "HENOMX": "Летно сметање на времето во северозападно Мексико", "BT": "Време во Бутан"}, + } +} + +// Locale returns the current translators string locale +func (mk *mk_MK) Locale() string { + return mk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mk_MK' +func (mk *mk_MK) PluralsCardinal() []locales.PluralRule { + return mk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mk_MK' +func (mk *mk_MK) PluralsOrdinal() []locales.PluralRule { + return mk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mk_MK' +func (mk *mk_MK) PluralsRange() []locales.PluralRule { + return mk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mk_MK' +func (mk *mk_MK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + fMod10 := f % 10 + + if (v == 0 && iMod10 == 1) || (fMod10 == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mk_MK' +func (mk *mk_MK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if iMod10 == 2 && iMod100 != 12 { + return locales.PluralRuleTwo + } else if (iMod10 == 7 || iMod10 == 8) && (iMod100 != 17 && iMod100 != 18) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mk_MK' +func (mk *mk_MK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mk *mk_MK) MonthAbbreviated(month time.Month) string { + return mk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mk *mk_MK) MonthsAbbreviated() []string { + return mk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mk *mk_MK) MonthNarrow(month time.Month) string { + return mk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mk *mk_MK) MonthsNarrow() []string { + return mk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mk *mk_MK) MonthWide(month time.Month) string { + return mk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mk *mk_MK) MonthsWide() []string { + return mk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mk *mk_MK) WeekdayAbbreviated(weekday time.Weekday) string { + return mk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mk *mk_MK) WeekdaysAbbreviated() []string { + return mk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mk *mk_MK) WeekdayNarrow(weekday time.Weekday) string { + return mk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mk *mk_MK) WeekdaysNarrow() []string { + return mk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mk *mk_MK) WeekdayShort(weekday time.Weekday) string { + return mk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mk *mk_MK) WeekdaysShort() []string { + return mk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mk *mk_MK) WeekdayWide(weekday time.Weekday) string { + return mk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mk *mk_MK) WeekdaysWide() []string { + return mk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mk_MK' and handles both Whole and Real numbers based on 'v' +func (mk *mk_MK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mk_MK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mk *mk_MK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mk_MK' +func (mk *mk_MK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mk.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, mk.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mk_MK' +// in accounting notation. +func (mk *mk_MK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mk.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, mk.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, mk.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mk_MK' +func (mk *mk_MK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mk_MK' +func (mk *mk_MK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mk_MK' +func (mk *mk_MK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mk_MK' +func (mk *mk_MK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mk.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mk_MK' +func (mk *mk_MK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mk_MK' +func (mk *mk_MK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mk_MK' +func (mk *mk_MK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mk_MK' +func (mk *mk_MK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mk_MK/mk_MK_test.go b/vendor/github.com/go-playground/locales/mk_MK/mk_MK_test.go new file mode 100644 index 0000000000..f1c3d593a1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mk_MK/mk_MK_test.go @@ -0,0 +1,1120 @@ +package mk_MK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mk_MK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ml/ml.go b/vendor/github.com/go-playground/locales/ml/ml.go new file mode 100644 index 0000000000..ca58d01ef9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ml/ml.go @@ -0,0 +1,641 @@ +package ml + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ml struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ml' locale +func New() locales.Translator { + return &ml{ + locale: "ml", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ജനു", "ഫെബ്രു", "മാർ", "ഏപ്രി", "മേയ്", "ജൂൺ", "ജൂലൈ", "ഓഗ", "സെപ്റ്റം", "ഒക്ടോ", "നവം", "ഡിസം"}, + monthsNarrow: []string{"", "ജ", "ഫ", "മാ", "ഏ", "മെ", "ജൂൺ", "ജൂ", "ഓ", "സെ", "ഒ", "ന", "ഡി"}, + monthsWide: []string{"", "ജനുവരി", "ഫെബ്രുവരി", "മാർച്ച്", "ഏപ്രിൽ", "മേയ്", "ജൂൺ", "ജൂലൈ", "ഓഗസ്റ്റ്", "സെപ്റ്റംബർ", "ഒക്\u200cടോബർ", "നവംബർ", "ഡിസംബർ"}, + daysAbbreviated: []string{"ഞായർ", "തിങ്കൾ", "ചൊവ്വ", "ബുധൻ", "വ്യാഴം", "വെള്ളി", "ശനി"}, + daysNarrow: []string{"ഞ", "തി", "ചൊ", "ബു", "വ്യാ", "വെ", "ശ"}, + daysShort: []string{"ഞാ", "തി", "ചൊ", "ബു", "വ്യാ", "വെ", "ശ"}, + daysWide: []string{"ഞായറാഴ്\u200cച", "തിങ്കളാഴ്\u200cച", "ചൊവ്വാഴ്ച", "ബുധനാഴ്\u200cച", "വ്യാഴാഴ്\u200cച", "വെള്ളിയാഴ്\u200cച", "ശനിയാഴ്\u200cച"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"ക്രി.മു.", "എഡി"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ക്രിസ്\u200cതുവിന് മുമ്പ്", "ആന്നോ ഡൊമിനി"}, + timezones: map[string]string{"MST": "വടക്കെ അമേരിക്കൻ മൗണ്ടൻ സ്റ്റാൻഡേർഡ് സമയം", "GFT": "ഫ്രഞ്ച് ഗയാന സമയം", "JDT": "ജപ്പാൻ ഡേലൈറ്റ് സമയം", "WESZ": "പടിഞ്ഞാറൻ യൂറോപ്യൻ ഗ്രീഷ്\u200cമകാല സമയം", "EDT": "വടക്കെ അമേരിക്കൻ കിഴക്കൻ ഡേലൈറ്റ് സമയം", "MDT": "വടക്കെ അമേരിക്കൻ മൗണ്ടൻ ഡേലൈറ്റ് സമയം", "AKDT": "അലാസ്\u200cക ഡേലൈറ്റ് സമയം", "CHADT": "ചാത്തം ഗ്രീഷ്\u200cമകാല സമയം", "PDT": "വടക്കെ അമേരിക്കൻ പസഫിക് ഡേലൈറ്റ് സമയം", "HEOG": "പടിഞ്ഞാറൻ ഗ്രീൻലാൻഡ് ഗ്രീഷ്\u200cമകാല സമയം", "TMT": "തുർക്ക്\u200cമെനിസ്ഥാൻ സ്റ്റാൻഡേർഡ് സമയം", "TMST": "തുർക്ക്\u200cമെനിസ്ഥാൻ ഗ്രീഷ്\u200cമകാല സമയം", "HNEG": "കിഴക്കൻ ഗ്രീൻലാൻഡ് സ്റ്റാൻഡേർഡ് സമയം", "UYST": "ഉറുഗ്വേ ഗ്രീഷ്\u200cമകാല സമയം", "HNCU": "ക്യൂബ സ്റ്റാൻഡേർഡ് സമയം", "HECU": "ക്യൂബ ഡേലൈറ്റ് സമയം", "CST": "വടക്കെ അമേരിക്കൻ സെൻട്രൽ സ്റ്റാൻഡേർഡ് സമയം", "HKT": "ഹോങ്കോങ്ങ് സ്റ്റാൻഡേർഡ് സമയം", "HENOMX": "വടക്കുപടിഞ്ഞാറൻ മെക്സിക്കൻ ഡേലൈറ്റ് സമയം", "HNT": "ന്യൂഫൗണ്ട്\u200cലാന്റ് സ്റ്റാൻഡേർഡ് സമയം", "WART": "പടിഞ്ഞാറൻ അർജന്റീന സ്റ്റാൻഡേർഡ് സമയം", "COST": "കൊളംബിയ ഗ്രീഷ്\u200cമകാല സമയം", "ARST": "അർജന്റീന ഗ്രീഷ്\u200cമകാല സമയം", "BOT": "ബൊളീവിയ സമയം", "CHAST": "ചാത്തം സ്റ്റാൻഡേർഡ് സമയം", "HAST": "ഹവായ്-അലൂഷ്യൻ സ്റ്റാൻഡേർഡ് സമയം", "WAT": "പടിഞ്ഞാറൻ ആഫ്രിക്ക സ്റ്റാൻഡേർഡ് സമയം", "HEPM": "സെന്റ് പിയറി ആൻഡ് മിക്വലൻ ഡേലൈറ്റ് സമയം", "ChST": "ചമോറോ സ്റ്റാൻഡേർഡ് സമയം", "LHDT": "ലോർഡ് ഹോവ് ഡേലൈറ്റ് സമയം", "SAST": "ദക്ഷിണാഫ്രിക്ക സ്റ്റാൻഡേർഡ് സമയം", "ACWDT": "ഓസ്ട്രേലിയൻ സെൻട്രൽ പടിഞ്ഞാറൻ ഡേലൈറ്റ് സമയം", "CLST": "ചിലി ഗ്രീഷ്\u200cമകാല സമയം", "HKST": "ഹോങ്കോങ്ങ് ഗ്രീഷ്\u200cമകാല സമയം", "AWDT": "ഓസ്\u200cട്രേലിയൻ പടിഞ്ഞാറൻ ഡേലൈറ്റ് സമയം", "ADT": "അറ്റ്\u200cലാന്റിക് ഡേലൈറ്റ് സമയം", "HAT": "ന്യൂഫൗണ്ട്\u200cലാന്റ് ഡേലൈറ്റ് സമയം", "SGT": "സിംഗപ്പൂർ സ്റ്റാൻഡേർഡ് സമയം", "EST": "വടക്കെ അമേരിക്കൻ കിഴക്കൻ സ്റ്റാൻഡേർഡ് സമയം", "UYT": "ഉറുഗ്വേ സ്റ്റാൻഡേർഡ് സമയം", "SRT": "സുരിനെയിം സമയം", "HADT": "ഹവായ്-അലൂഷ്യൻ ഡേലൈറ്റ് സമയം", "OEZ": "കിഴക്കൻ യൂറോപ്യൻ സ്റ്റാൻഡേർഡ് സമയം", "MEZ": "സെൻട്രൽ യൂറോപ്യൻ സ്റ്റാൻഡേർഡ് സമയം", "COT": "കൊളംബിയ സ്റ്റാൻഡേർഡ് സമയം", "HEPMX": "മെക്സിക്കൻ പസഫിക് ഡേലൈറ്റ് സമയം", "CDT": "വടക്കെ അമേരിക്കൻ സെൻട്രൽ ഡേലൈറ്റ് സമയം", "PST": "വടക്കെ അമേരിക്കൻ പസഫിക് സ്റ്റാൻഡേർഡ് സമയം", "JST": "ജപ്പാൻ സ്റ്റാൻഡേർഡ് സമയം", "WIT": "കിഴക്കൻ ഇന്തോനേഷ്യ സമയം", "ACWST": "ഓസ്ട്രേലിയൻ സെൻട്രൽ പടിഞ്ഞാറൻ സ്റ്റാൻഡേർഡ് സമയം", "CAT": "മധ്യ ആഫ്രിക്ക സമയം", "ACDT": "ഓസ്ട്രേലിയൻ സെൻട്രൽ ഡേലൈറ്റ് സമയം", "HEEG": "കിഴക്കൻ ഗ്രീൻലാൻഡ് ഗ്രീഷ്\u200cമകാല സമയം", "AEDT": "ഓസ്\u200cട്രേലിയൻ കിഴക്കൻ ഡേലൈറ്റ് സമയം", "HNPM": "സെന്റ് പിയറി ആൻഡ് മിക്വലൻ സ്റ്റാൻഡേർഡ് സമയം", "EAT": "കിഴക്കൻ ആഫ്രിക്ക സമയം", "ART": "അർജന്റീന സ്റ്റാൻഡേർഡ് സമയം", "WITA": "മധ്യ ഇന്തോനേഷ്യ സമയം", "WIB": "പടിഞ്ഞാറൻ ഇന്തോനേഷ്യ സമയം", "WARST": "പടിഞ്ഞാറൻ അർജന്റീന ഗ്രീഷ്\u200cമകാല സമയം", "HNOG": "പടിഞ്ഞാറൻ ഗ്രീൻലാൻഡ് സ്റ്റാൻഡേർഡ് സമയം", "AST": "അറ്റ്\u200cലാന്റിക് സ്റ്റാൻഡേർഡ് സമയം", "IST": "ഇന്ത്യൻ സ്റ്റാൻഡേർഡ് സമയം", "CLT": "ചിലി സ്റ്റാൻഡേർഡ് സമയം", "VET": "വെനിസ്വേല സമയം", "WEZ": "പടിഞ്ഞാറൻ യൂറോപ്യൻ സ്റ്റാൻഡേർഡ് സമയം", "GMT": "ഗ്രീൻവിച്ച് മീൻ സമയം", "HNNOMX": "വടക്കുപടിഞ്ഞാറൻ മെക്\u200cസിക്കൻ സ്റ്റാൻഡേർഡ് സമയം", "∅∅∅": "എയ്ക്കർ വേനൽക്കാല സമയം", "AEST": "ഓസ്\u200cട്രേലിയൻ കിഴക്കൻ സ്റ്റാൻഡേർഡ് സമയം", "AKST": "അലാസ്ക സ്റ്റാൻഡേർഡ് സമയം", "LHST": "ലോർഡ് ഹോവ് സ്റ്റാൻഡേർഡ് സമയം", "NZST": "ന്യൂസിലാൻഡ് സ്റ്റാൻഡേർഡ് സമയം", "NZDT": "ന്യൂസിലാൻഡ് ഡേലൈറ്റ് സമയം", "MESZ": "സെൻട്രൽ യൂറോപ്യൻ ഗ്രീഷ്മകാല സമയം", "WAST": "പടിഞ്ഞാറൻ ആഫ്രിക്ക ഗ്രീഷ്\u200cമകാല സമയം", "BT": "ഭൂട്ടാൻ സമയം", "HNPMX": "മെക്\u200cസിക്കൻ പസഫിക് സ്റ്റാൻഡേർഡ് സമയം", "GYT": "ഗയാന സമയം", "AWST": "ഓസ്\u200cട്രേലിയൻ പടിഞ്ഞാറൻ സ്റ്റാൻഡേർഡ് സമയം", "OESZ": "കിഴക്കൻ യൂറോപ്യൻ ഗ്രീഷ്മകാല സമയം", "MYT": "മലേഷ്യ സമയം", "ACST": "ഓസ്ട്രേലിയൻ സെൻട്രൽ സ്റ്റാൻഡേർഡ് സമയം", "ECT": "ഇക്വഡോർ സമയം"}, + } +} + +// Locale returns the current translators string locale +func (ml *ml) Locale() string { + return ml.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ml' +func (ml *ml) PluralsCardinal() []locales.PluralRule { + return ml.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ml' +func (ml *ml) PluralsOrdinal() []locales.PluralRule { + return ml.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ml' +func (ml *ml) PluralsRange() []locales.PluralRule { + return ml.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ml' +func (ml *ml) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ml' +func (ml *ml) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ml' +func (ml *ml) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ml.CardinalPluralRule(num1, v1) + end := ml.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ml *ml) MonthAbbreviated(month time.Month) string { + return ml.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ml *ml) MonthsAbbreviated() []string { + return ml.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ml *ml) MonthNarrow(month time.Month) string { + return ml.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ml *ml) MonthsNarrow() []string { + return ml.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ml *ml) MonthWide(month time.Month) string { + return ml.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ml *ml) MonthsWide() []string { + return ml.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ml *ml) WeekdayAbbreviated(weekday time.Weekday) string { + return ml.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ml *ml) WeekdaysAbbreviated() []string { + return ml.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ml *ml) WeekdayNarrow(weekday time.Weekday) string { + return ml.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ml *ml) WeekdaysNarrow() []string { + return ml.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ml *ml) WeekdayShort(weekday time.Weekday) string { + return ml.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ml *ml) WeekdaysShort() []string { + return ml.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ml *ml) WeekdayWide(weekday time.Weekday) string { + return ml.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ml *ml) WeekdaysWide() []string { + return ml.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ml' and handles both Whole and Real numbers based on 'v' +func (ml *ml) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ml.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ml.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ml.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ml' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ml *ml) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ml.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ml.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ml.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ml' +func (ml *ml) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ml.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ml.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ml.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ml.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ml.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ml' +// in accounting notation. +func (ml *ml) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ml.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ml.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ml.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ml.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ml.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ml.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ml' +func (ml *ml) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ml' +func (ml *ml) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ml.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ml' +func (ml *ml) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ml.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ml' +func (ml *ml) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ml.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ml.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ml' +func (ml *ml) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ml.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ml.periodsAbbreviated[0]...) + } else { + b = append(b, ml.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ml' +func (ml *ml) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ml.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ml.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ml.periodsAbbreviated[0]...) + } else { + b = append(b, ml.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ml' +func (ml *ml) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ml.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ml.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ml.periodsAbbreviated[0]...) + } else { + b = append(b, ml.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ml' +func (ml *ml) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ml.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ml.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ml.periodsAbbreviated[0]...) + } else { + b = append(b, ml.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ml.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ml/ml_test.go b/vendor/github.com/go-playground/locales/ml/ml_test.go new file mode 100644 index 0000000000..c053e2291c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ml/ml_test.go @@ -0,0 +1,1120 @@ +package ml + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ml" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ml_IN/ml_IN.go b/vendor/github.com/go-playground/locales/ml_IN/ml_IN.go new file mode 100644 index 0000000000..6315c6a234 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ml_IN/ml_IN.go @@ -0,0 +1,641 @@ +package ml_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ml_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ml_IN' locale +func New() locales.Translator { + return &ml_IN{ + locale: "ml_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ജനു", "ഫെബ്രു", "മാർ", "ഏപ്രി", "മേയ്", "ജൂൺ", "ജൂലൈ", "ഓഗ", "സെപ്റ്റം", "ഒക്ടോ", "നവം", "ഡിസം"}, + monthsNarrow: []string{"", "ജ", "ഫ", "മാ", "ഏ", "മെ", "ജൂൺ", "ജൂ", "ഓ", "സെ", "ഒ", "ന", "ഡി"}, + monthsWide: []string{"", "ജനുവരി", "ഫെബ്രുവരി", "മാർച്ച്", "ഏപ്രിൽ", "മേയ്", "ജൂൺ", "ജൂലൈ", "ഓഗസ്റ്റ്", "സെപ്റ്റംബർ", "ഒക്\u200cടോബർ", "നവംബർ", "ഡിസംബർ"}, + daysAbbreviated: []string{"ഞായർ", "തിങ്കൾ", "ചൊവ്വ", "ബുധൻ", "വ്യാഴം", "വെള്ളി", "ശനി"}, + daysNarrow: []string{"ഞ", "തി", "ചൊ", "ബു", "വ്യാ", "വെ", "ശ"}, + daysShort: []string{"ഞാ", "തി", "ചൊ", "ബു", "വ്യാ", "വെ", "ശ"}, + daysWide: []string{"ഞായറാഴ്\u200cച", "തിങ്കളാഴ്\u200cച", "ചൊവ്വാഴ്ച", "ബുധനാഴ്\u200cച", "വ്യാഴാഴ്\u200cച", "വെള്ളിയാഴ്\u200cച", "ശനിയാഴ്\u200cച"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"ക്രി.മു.", "എഡി"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ക്രിസ്\u200cതുവിന് മുമ്പ്", "ആന്നോ ഡൊമിനി"}, + timezones: map[string]string{"WAT": "പടിഞ്ഞാറൻ ആഫ്രിക്ക സ്റ്റാൻഡേർഡ് സമയം", "ACST": "ഓസ്ട്രേലിയൻ സെൻട്രൽ സ്റ്റാൻഡേർഡ് സമയം", "COT": "കൊളംബിയ സ്റ്റാൻഡേർഡ് സമയം", "AST": "അറ്റ്\u200cലാന്റിക് സ്റ്റാൻഡേർഡ് സമയം", "TMST": "തുർക്ക്\u200cമെനിസ്ഥാൻ ഗ്രീഷ്\u200cമകാല സമയം", "HNOG": "പടിഞ്ഞാറൻ ഗ്രീൻലാൻഡ് സ്റ്റാൻഡേർഡ് സമയം", "HKST": "ഹോങ്കോങ്ങ് ഗ്രീഷ്\u200cമകാല സമയം", "SAST": "ദക്ഷിണാഫ്രിക്ക സ്റ്റാൻഡേർഡ് സമയം", "HEPMX": "മെക്സിക്കൻ പസഫിക് ഡേലൈറ്റ് സമയം", "WIT": "കിഴക്കൻ ഇന്തോനേഷ്യ സമയം", "ECT": "ഇക്വഡോർ സമയം", "PST": "വടക്കെ അമേരിക്കൻ പസഫിക് സ്റ്റാൻഡേർഡ് സമയം", "CLT": "ചിലി സ്റ്റാൻഡേർഡ് സമയം", "GMT": "ഗ്രീൻവിച്ച് മീൻ സമയം", "HEEG": "കിഴക്കൻ ഗ്രീൻലാൻഡ് ഗ്രീഷ്\u200cമകാല സമയം", "HNPMX": "മെക്\u200cസിക്കൻ പസഫിക് സ്റ്റാൻഡേർഡ് സമയം", "HEOG": "പടിഞ്ഞാറൻ ഗ്രീൻലാൻഡ് ഗ്രീഷ്\u200cമകാല സമയം", "ARST": "അർജന്റീന ഗ്രീഷ്\u200cമകാല സമയം", "HEPM": "സെന്റ് പിയറി ആൻഡ് മിക്വലൻ ഡേലൈറ്റ് സമയം", "CHAST": "ചാത്തം സ്റ്റാൻഡേർഡ് സമയം", "HAST": "ഹവായ്-അലൂഷ്യൻ സ്റ്റാൻഡേർഡ് സമയം", "MYT": "മലേഷ്യ സമയം", "CLST": "ചിലി ഗ്രീഷ്\u200cമകാല സമയം", "ACWDT": "ഓസ്ട്രേലിയൻ സെൻട്രൽ പടിഞ്ഞാറൻ ഡേലൈറ്റ് സമയം", "OEZ": "കിഴക്കൻ യൂറോപ്യൻ സ്റ്റാൻഡേർഡ് സമയം", "AEST": "ഓസ്\u200cട്രേലിയൻ കിഴക്കൻ സ്റ്റാൻഡേർഡ് സമയം", "AWST": "ഓസ്\u200cട്രേലിയൻ പടിഞ്ഞാറൻ സ്റ്റാൻഡേർഡ് സമയം", "ACWST": "ഓസ്ട്രേലിയൻ സെൻട്രൽ പടിഞ്ഞാറൻ സ്റ്റാൻഡേർഡ് സമയം", "WEZ": "പടിഞ്ഞാറൻ യൂറോപ്യൻ സ്റ്റാൻഡേർഡ് സമയം", "WAST": "പടിഞ്ഞാറൻ ആഫ്രിക്ക ഗ്രീഷ്\u200cമകാല സമയം", "HAT": "ന്യൂഫൗണ്ട്\u200cലാന്റ് ഡേലൈറ്റ് സമയം", "AKDT": "അലാസ്\u200cക ഡേലൈറ്റ് സമയം", "SRT": "സുരിനെയിം സമയം", "MEZ": "സെൻട്രൽ യൂറോപ്യൻ സ്റ്റാൻഡേർഡ് സമയം", "WARST": "പടിഞ്ഞാറൻ അർജന്റീന ഗ്രീഷ്\u200cമകാല സമയം", "WESZ": "പടിഞ്ഞാറൻ യൂറോപ്യൻ ഗ്രീഷ്\u200cമകാല സമയം", "HNNOMX": "വടക്കുപടിഞ്ഞാറൻ മെക്\u200cസിക്കൻ സ്റ്റാൻഡേർഡ് സമയം", "HENOMX": "വടക്കുപടിഞ്ഞാറൻ മെക്സിക്കൻ ഡേലൈറ്റ് സമയം", "AKST": "അലാസ്ക സ്റ്റാൻഡേർഡ് സമയം", "CST": "വടക്കെ അമേരിക്കൻ സെൻട്രൽ സ്റ്റാൻഡേർഡ് സമയം", "SGT": "സിംഗപ്പൂർ സ്റ്റാൻഡേർഡ് സമയം", "TMT": "തുർക്ക്\u200cമെനിസ്ഥാൻ സ്റ്റാൻഡേർഡ് സമയം", "ART": "അർജന്റീന സ്റ്റാൻഡേർഡ് സമയം", "JDT": "ജപ്പാൻ ഡേലൈറ്റ് സമയം", "EDT": "വടക്കെ അമേരിക്കൻ കിഴക്കൻ ഡേലൈറ്റ് സമയം", "MDT": "വടക്കെ അമേരിക്കൻ മൗണ്ടൻ ഡേലൈറ്റ് സമയം", "GFT": "ഫ്രഞ്ച് ഗയാന സമയം", "LHST": "ലോർഡ് ഹോവ് സ്റ്റാൻഡേർഡ് സമയം", "EAT": "കിഴക്കൻ ആഫ്രിക്ക സമയം", "HECU": "ക്യൂബ ഡേലൈറ്റ് സമയം", "CHADT": "ചാത്തം ഗ്രീഷ്\u200cമകാല സമയം", "OESZ": "കിഴക്കൻ യൂറോപ്യൻ ഗ്രീഷ്മകാല സമയം", "BT": "ഭൂട്ടാൻ സമയം", "MST": "വടക്കെ അമേരിക്കൻ മൗണ്ടൻ സ്റ്റാൻഡേർഡ് സമയം", "LHDT": "ലോർഡ് ഹോവ് ഡേലൈറ്റ് സമയം", "PDT": "വടക്കെ അമേരിക്കൻ പസഫിക് ഡേലൈറ്റ് സമയം", "NZST": "ന്യൂസിലാൻഡ് സ്റ്റാൻഡേർഡ് സമയം", "JST": "ജപ്പാൻ സ്റ്റാൻഡേർഡ് സമയം", "ADT": "അറ്റ്\u200cലാന്റിക് ഡേലൈറ്റ് സമയം", "HNEG": "കിഴക്കൻ ഗ്രീൻലാൻഡ് സ്റ്റാൻഡേർഡ് സമയം", "WITA": "മധ്യ ഇന്തോനേഷ്യ സമയം", "AEDT": "ഓസ്\u200cട്രേലിയൻ കിഴക്കൻ ഡേലൈറ്റ് സമയം", "HNPM": "സെന്റ് പിയറി ആൻഡ് മിക്വലൻ സ്റ്റാൻഡേർഡ് സമയം", "GYT": "ഗയാന സമയം", "HNCU": "ക്യൂബ സ്റ്റാൻഡേർഡ് സമയം", "WIB": "പടിഞ്ഞാറൻ ഇന്തോനേഷ്യ സമയം", "HKT": "ഹോങ്കോങ്ങ് സ്റ്റാൻഡേർഡ് സമയം", "ACDT": "ഓസ്ട്രേലിയൻ സെൻട്രൽ ഡേലൈറ്റ് സമയം", "ChST": "ചമോറോ സ്റ്റാൻഡേർഡ് സമയം", "BOT": "ബൊളീവിയ സമയം", "NZDT": "ന്യൂസിലാൻഡ് ഡേലൈറ്റ് സമയം", "CAT": "മധ്യ ആഫ്രിക്ക സമയം", "IST": "ഇന്ത്യൻ സ്റ്റാൻഡേർഡ് സമയം", "EST": "വടക്കെ അമേരിക്കൻ കിഴക്കൻ സ്റ്റാൻഡേർഡ് സമയം", "UYST": "ഉറുഗ്വേ ഗ്രീഷ്\u200cമകാല സമയം", "CDT": "വടക്കെ അമേരിക്കൻ സെൻട്രൽ ഡേലൈറ്റ് സമയം", "VET": "വെനിസ്വേല സമയം", "COST": "കൊളംബിയ ഗ്രീഷ്\u200cമകാല സമയം", "HNT": "ന്യൂഫൗണ്ട്\u200cലാന്റ് സ്റ്റാൻഡേർഡ് സമയം", "AWDT": "ഓസ്\u200cട്രേലിയൻ പടിഞ്ഞാറൻ ഡേലൈറ്റ് സമയം", "HADT": "ഹവായ്-അലൂഷ്യൻ ഡേലൈറ്റ് സമയം", "WART": "പടിഞ്ഞാറൻ അർജന്റീന സ്റ്റാൻഡേർഡ് സമയം", "∅∅∅": "എയ്ക്കർ വേനൽക്കാല സമയം", "UYT": "ഉറുഗ്വേ സ്റ്റാൻഡേർഡ് സമയം", "MESZ": "സെൻട്രൽ യൂറോപ്യൻ ഗ്രീഷ്മകാല സമയം"}, + } +} + +// Locale returns the current translators string locale +func (ml *ml_IN) Locale() string { + return ml.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ml_IN' +func (ml *ml_IN) PluralsCardinal() []locales.PluralRule { + return ml.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ml_IN' +func (ml *ml_IN) PluralsOrdinal() []locales.PluralRule { + return ml.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ml_IN' +func (ml *ml_IN) PluralsRange() []locales.PluralRule { + return ml.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ml_IN' +func (ml *ml_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ml_IN' +func (ml *ml_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ml_IN' +func (ml *ml_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ml.CardinalPluralRule(num1, v1) + end := ml.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ml *ml_IN) MonthAbbreviated(month time.Month) string { + return ml.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ml *ml_IN) MonthsAbbreviated() []string { + return ml.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ml *ml_IN) MonthNarrow(month time.Month) string { + return ml.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ml *ml_IN) MonthsNarrow() []string { + return ml.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ml *ml_IN) MonthWide(month time.Month) string { + return ml.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ml *ml_IN) MonthsWide() []string { + return ml.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ml *ml_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return ml.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ml *ml_IN) WeekdaysAbbreviated() []string { + return ml.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ml *ml_IN) WeekdayNarrow(weekday time.Weekday) string { + return ml.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ml *ml_IN) WeekdaysNarrow() []string { + return ml.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ml *ml_IN) WeekdayShort(weekday time.Weekday) string { + return ml.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ml *ml_IN) WeekdaysShort() []string { + return ml.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ml *ml_IN) WeekdayWide(weekday time.Weekday) string { + return ml.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ml *ml_IN) WeekdaysWide() []string { + return ml.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ml_IN' and handles both Whole and Real numbers based on 'v' +func (ml *ml_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ml.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ml.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ml.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ml_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ml *ml_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ml.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ml.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ml.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ml_IN' +func (ml *ml_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ml.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ml.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ml.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ml.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ml.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ml_IN' +// in accounting notation. +func (ml *ml_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ml.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ml.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ml.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ml.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ml.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ml.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ml_IN' +func (ml *ml_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ml_IN' +func (ml *ml_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ml.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ml_IN' +func (ml *ml_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ml.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ml_IN' +func (ml *ml_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ml.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ml.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ml_IN' +func (ml *ml_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ml.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ml.periodsAbbreviated[0]...) + } else { + b = append(b, ml.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ml_IN' +func (ml *ml_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ml.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ml.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ml.periodsAbbreviated[0]...) + } else { + b = append(b, ml.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ml_IN' +func (ml *ml_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ml.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ml.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ml.periodsAbbreviated[0]...) + } else { + b = append(b, ml.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ml_IN' +func (ml *ml_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ml.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ml.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ml.periodsAbbreviated[0]...) + } else { + b = append(b, ml.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ml.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ml_IN/ml_IN_test.go b/vendor/github.com/go-playground/locales/ml_IN/ml_IN_test.go new file mode 100644 index 0000000000..b23f32098c --- /dev/null +++ b/vendor/github.com/go-playground/locales/ml_IN/ml_IN_test.go @@ -0,0 +1,1120 @@ +package ml_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ml_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mn/mn.go b/vendor/github.com/go-playground/locales/mn/mn.go new file mode 100644 index 0000000000..9bfa5efc81 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mn/mn.go @@ -0,0 +1,625 @@ +package mn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mn' locale +func New() locales.Translator { + return &mn{ + locale: "mn", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "₮", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Нэгдүгээр сар", "Хоёрдугаар сар", "Гуравдугаар сар", "Дөрөвдүгээр сар", "Тавдугаар сар", "Зургадугаар сар", "Долдугаар сар", "Наймдугаар сар", "Есдүгээр сар", "Аравдугаар сар", "Арван нэгдүгээр сар", "Арван хоёрдугаар сар"}, + daysAbbreviated: []string{"Ня", "Да", "Мя", "Лх", "Пү", "Ба", "Бя"}, + daysNarrow: []string{"Ня", "Да", "Мя", "Лх", "Пү", "Ба", "Бя"}, + daysShort: []string{"Ня", "Да", "Мя", "Лх", "Пү", "Ба", "Бя"}, + daysWide: []string{"ням", "даваа", "мягмар", "лхагва", "пүрэв", "баасан", "бямба"}, + periodsAbbreviated: []string{"ҮӨ", "ҮХ"}, + periodsNarrow: []string{"үө", "үх"}, + periodsWide: []string{"ү.ө", "ү.х"}, + erasAbbreviated: []string{"м.э.ө", "м.э."}, + erasNarrow: []string{"МЭӨ", "МЭ"}, + erasWide: []string{"манай эриний өмнөх", "манай эриний"}, + timezones: map[string]string{"WIT": "Зүүн Индонезийн цаг", "AWDT": "Австралийн баруун эргийн зуны цаг", "SGT": "Сингапурын цаг", "NZDT": "Шинэ Зеландын зуны цаг", "AEST": "Австралийн зүүн эргийн стандарт цаг", "WIB": "Баруун Индонезийн цаг", "CDT": "Төв зуны цаг", "HEOG": "Баруун Гринландын зуны цаг", "EST": "Зүүн эргийн стандарт цаг", "HAT": "Нью-Фаундлендын зуны цаг", "HEPM": "Сент-Пьер ба Микелоны зуны цаг", "UYT": "Уругвайн стандарт цаг", "HECU": "Кубын зуны цаг", "PST": "Номхон далайн стандарт цаг", "PDT": "Номхон далайн зуны цаг", "ACDT": "Төв Австралийн зуны цаг", "AKST": "Аляскийн стандарт цаг", "HNPM": "Сент-Пьерре ба Микелоны стандарт цаг", "HEPMX": "Мексикийн номхон далайн зуны цаг", "SAST": "Өмнөд Африкийн стандарт цаг", "LHST": "Лорд Хоугийн стандарт цаг", "HAST": "Хавай-Алеутын стандарт цаг", "ECT": "Эквадорын цаг", "WESZ": "Баруун Европын зуны цаг", "OESZ": "Зүүн Европын зуны цаг", "MST": "MST", "WAT": "Баруун Африкийн стандарт цаг", "WAST": "Баруун Африкийн зуны цаг", "CHAST": "Чатемын стандарт цаг", "EAT": "Зүүн Африкийн цаг", "HADT": "Хавай-Алеутын зуны цаг", "ACST": "Төв Австралийн стандарт цаг", "HEEG": "Зүүн Гринландын зуны цаг", "HNT": "Нью-Фаундлендын стандарт цаг", "HNCU": "Кубын стандарт цаг", "MEZ": "Төв Европын стандарт цаг", "HNOG": "Баруун Гринландын стандарт цаг", "OEZ": "Зүүн Европын стандарт цаг", "HNNOMX": "Баруун хойд Мексикийн стандарт цаг", "COST": "Колумбын зуны цаг", "WITA": "Төв Индонезийн цаг", "UYST": "Уругвайн зуны цаг", "JST": "Японы стандарт цаг", "HKST": "Хонг Конгийн зуны цаг", "ChST": "Чаморрогийн цаг", "LHDT": "Лорд Хоугийн зуны цаг", "WARST": "Баруун Аргентины зуны цаг", "BOT": "Боливийн цаг", "NZST": "Шинэ Зеландын стандарт цаг", "VET": "Венесуэлийн цаг", "AST": "Атлантын стандарт цаг", "GFT": "Францын Гияанагийн цаг", "AWST": "Австралийн баруун эргийн стандарт цаг", "MYT": "Малайзын цаг", "TMST": "Туркменистаны зуны цаг", "MDT": "MDT", "HENOMX": "Баруун хойд Мексикийн зуны цаг", "HNPMX": "Мексикийн номхон далайн стандарт цаг", "∅∅∅": "Бразилийн зуны цаг", "GMT": "Гринвичийн үндсэн цаг", "ARST": "Аргентины зуны цаг", "AEDT": "Австралийн зүүн эргийн зуны цаг", "ACWST": "Австралийн төв баруун эргийн стандарт цаг", "ACWDT": "Австралийн төв баруун эргийн зуны цаг", "CLT": "Чилийн стандарт цаг", "ART": "Аргентины стандарт цаг", "HNEG": "Зүүн Гринландын стандарт цаг", "CST": "Төв стандарт цаг", "CAT": "Төв Африкийн цаг", "IST": "Энэтхэгийн цаг", "JDT": "Японы зуны цаг", "EDT": "Зүүн эргийн зуны цаг", "COT": "Колумбын стандарт цаг", "WEZ": "Баруун Европын стандарт цаг", "CLST": "Чилийн зуны цаг", "TMT": "Туркменистаны стандарт цаг", "BT": "Бутаны цаг", "SRT": "Суринамын цаг", "CHADT": "Чатемын зуны цаг", "MESZ": "Төв Европын зуны цаг", "WART": "Баруун Аргентины стандарт цаг", "ADT": "Атлантын зуны цаг", "HKT": "Хонг Конгийн стандарт цаг", "AKDT": "Аляскийн зуны цаг", "GYT": "Гуяанагийн цаг"}, + } +} + +// Locale returns the current translators string locale +func (mn *mn) Locale() string { + return mn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mn' +func (mn *mn) PluralsCardinal() []locales.PluralRule { + return mn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mn' +func (mn *mn) PluralsOrdinal() []locales.PluralRule { + return mn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mn' +func (mn *mn) PluralsRange() []locales.PluralRule { + return mn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mn' +func (mn *mn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mn' +func (mn *mn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mn' +func (mn *mn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := mn.CardinalPluralRule(num1, v1) + end := mn.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mn *mn) MonthAbbreviated(month time.Month) string { + return mn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mn *mn) MonthsAbbreviated() []string { + return mn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mn *mn) MonthNarrow(month time.Month) string { + return mn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mn *mn) MonthsNarrow() []string { + return mn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mn *mn) MonthWide(month time.Month) string { + return mn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mn *mn) MonthsWide() []string { + return mn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mn *mn) WeekdayAbbreviated(weekday time.Weekday) string { + return mn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mn *mn) WeekdaysAbbreviated() []string { + return mn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mn *mn) WeekdayNarrow(weekday time.Weekday) string { + return mn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mn *mn) WeekdaysNarrow() []string { + return mn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mn *mn) WeekdayShort(weekday time.Weekday) string { + return mn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mn *mn) WeekdaysShort() []string { + return mn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mn *mn) WeekdayWide(weekday time.Weekday) string { + return mn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mn *mn) WeekdaysWide() []string { + return mn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mn' and handles both Whole and Real numbers based on 'v' +func (mn *mn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mn *mn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mn' +func (mn *mn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mn.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mn.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mn.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, mn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mn' +// in accounting notation. +func (mn *mn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mn.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mn.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, mn.currencyNegativePrefix[j]) + } + + b = append(b, mn.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mn.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mn.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mn' +func (mn *mn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mn' +func (mn *mn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mn' +func (mn *mn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xd0, 0xbe, 0xd0, 0xbd, 0xd1, 0x8b}...) + b = append(b, []byte{0x20}...) + b = append(b, mn.monthsWide[t.Month()]...) + b = append(b, []byte{0xd1, 0x81, 0xd0, 0xb0, 0xd1, 0x80, 0xd1, 0x8b, 0xd0, 0xbd}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xd3, 0xa9, 0xd0, 0xb4, 0xd3, 0xa9, 0xd1, 0x80}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mn' +func (mn *mn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xbe, 0xd0, 0xbd, 0xd1, 0x8b}...) + b = append(b, []byte{0x20}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x20, 0xd1, 0x81, 0xd0, 0xb0, 0xd1, 0x80, 0xd1, 0x8b, 0xd0, 0xbd}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mn' +func (mn *mn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mn' +func (mn *mn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mn' +func (mn *mn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mn' +func (mn *mn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mn/mn_test.go b/vendor/github.com/go-playground/locales/mn/mn_test.go new file mode 100644 index 0000000000..320705b727 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mn/mn_test.go @@ -0,0 +1,1120 @@ +package mn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mn_MN/mn_MN.go b/vendor/github.com/go-playground/locales/mn_MN/mn_MN.go new file mode 100644 index 0000000000..407039f1e9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mn_MN/mn_MN.go @@ -0,0 +1,625 @@ +package mn_MN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mn_MN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mn_MN' locale +func New() locales.Translator { + return &mn_MN{ + locale: "mn_MN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Нэгдүгээр сар", "Хоёрдугаар сар", "Гуравдугаар сар", "Дөрөвдүгээр сар", "Тавдугаар сар", "Зургадугаар сар", "Долдугаар сар", "Наймдугаар сар", "Есдүгээр сар", "Аравдугаар сар", "Арван нэгдүгээр сар", "Арван хоёрдугаар сар"}, + daysAbbreviated: []string{"Ня", "Да", "Мя", "Лх", "Пү", "Ба", "Бя"}, + daysNarrow: []string{"Ня", "Да", "Мя", "Лх", "Пү", "Ба", "Бя"}, + daysShort: []string{"Ня", "Да", "Мя", "Лх", "Пү", "Ба", "Бя"}, + daysWide: []string{"ням", "даваа", "мягмар", "лхагва", "пүрэв", "баасан", "бямба"}, + periodsAbbreviated: []string{"ҮӨ", "ҮХ"}, + periodsNarrow: []string{"үө", "үх"}, + periodsWide: []string{"ү.ө", "ү.х"}, + erasAbbreviated: []string{"м.э.ө", "м.э."}, + erasNarrow: []string{"МЭӨ", "МЭ"}, + erasWide: []string{"манай эриний өмнөх", "манай эриний"}, + timezones: map[string]string{"GMT": "Гринвичийн үндсэн цаг", "MST": "Уулын стандарт цаг", "MDT": "Уулын зуны цаг", "NZST": "Шинэ Зеландын стандарт цаг", "WIB": "Баруун Индонезийн цаг", "EAT": "Зүүн Африкийн цаг", "MESZ": "Төв Европын зуны цаг", "WESZ": "Баруун Европын зуны цаг", "∅∅∅": "∅∅∅", "UYST": "Уругвайн зуны цаг", "GYT": "Гуяанагийн цаг", "CHAST": "Чатемын стандарт цаг", "MYT": "Малайзын цаг", "JST": "Японы стандарт цаг", "OEZ": "Зүүн Европын стандарт цаг", "GFT": "Францын Гияанагийн цаг", "AKDT": "Аляскийн зуны цаг", "CDT": "Төв зуны цаг", "HEOG": "Баруун Гринландын зуны цаг", "WEZ": "Баруун Европын стандарт цаг", "WARST": "Баруун Аргентины зуны цаг", "CLST": "Чилийн зуны цаг", "CST": "Төв стандарт цаг", "NZDT": "Шинэ Зеландын зуны цаг", "WITA": "Төв Индонезийн цаг", "ChST": "Чаморрогийн цаг", "HECU": "Кубын зуны цаг", "SGT": "Сингапурын цаг", "ART": "Аргентины стандарт цаг", "WAT": "Баруун Африкийн стандарт цаг", "COST": "Колумбын зуны цаг", "HNNOMX": "Баруун хойд Мексикийн стандарт цаг", "HNPM": "Сент-Пьерре ба Микелоны стандарт цаг", "HEPM": "Сент-Пьер ба Микелоны зуны цаг", "IST": "Энэтхэгийн цаг", "LHDT": "Лорд Хоугийн зуны цаг", "HNPMX": "Мексикийн номхон далайн стандарт цаг", "HAST": "Хавай-Алеутын стандарт цаг", "ECT": "Эквадорын цаг", "JDT": "Японы зуны цаг", "EDT": "Зүүн эргийн зуны цаг", "BT": "Бутаны цаг", "AKST": "Аляскийн стандарт цаг", "CLT": "Чилийн стандарт цаг", "HKST": "Хонг Конгийн зуны цаг", "PST": "Номхон далайн стандарт цаг", "ADT": "Атлантын зуны цаг", "TMST": "Туркменистаны зуны цаг", "SRT": "Суринамын цаг", "AWDT": "Австралийн баруун эргийн зуны цаг", "VET": "Венесуэлийн цаг", "CAT": "Төв Африкийн цаг", "ACST": "Төв Австралийн стандарт цаг", "AEST": "Австралийн зүүн эргийн стандарт цаг", "WIT": "Зүүн Индонезийн цаг", "HADT": "Хавай-Алеутын зуны цаг", "HNOG": "Баруун Гринландын стандарт цаг", "TMT": "Туркменистаны стандарт цаг", "ARST": "Аргентины зуны цаг", "EST": "Зүүн эргийн стандарт цаг", "HAT": "Нью-Фаундлендын зуны цаг", "HNCU": "Кубын стандарт цаг", "AEDT": "Австралийн зүүн эргийн зуны цаг", "UYT": "Уругвайн стандарт цаг", "HEPMX": "Мексикийн номхон далайн зуны цаг", "AWST": "Австралийн баруун эргийн стандарт цаг", "BOT": "Боливийн цаг", "HKT": "Хонг Конгийн стандарт цаг", "HENOMX": "Баруун хойд Мексикийн зуны цаг", "HEEG": "Зүүн Гринландын зуны цаг", "OESZ": "Зүүн Европын зуны цаг", "WART": "Баруун Аргентины стандарт цаг", "AST": "Атлантын стандарт цаг", "CHADT": "Чатемын зуны цаг", "PDT": "Номхон далайн зуны цаг", "ACWDT": "Австралийн төв баруун эргийн зуны цаг", "MEZ": "Төв Европын стандарт цаг", "COT": "Колумбын стандарт цаг", "HNT": "Нью-Фаундлендын стандарт цаг", "ACWST": "Австралийн төв баруун эргийн стандарт цаг", "LHST": "Лорд Хоугийн стандарт цаг", "SAST": "Өмнөд Африкийн стандарт цаг", "WAST": "Баруун Африкийн зуны цаг", "ACDT": "Төв Австралийн зуны цаг", "HNEG": "Зүүн Гринландын стандарт цаг"}, + } +} + +// Locale returns the current translators string locale +func (mn *mn_MN) Locale() string { + return mn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mn_MN' +func (mn *mn_MN) PluralsCardinal() []locales.PluralRule { + return mn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mn_MN' +func (mn *mn_MN) PluralsOrdinal() []locales.PluralRule { + return mn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mn_MN' +func (mn *mn_MN) PluralsRange() []locales.PluralRule { + return mn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mn_MN' +func (mn *mn_MN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mn_MN' +func (mn *mn_MN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mn_MN' +func (mn *mn_MN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := mn.CardinalPluralRule(num1, v1) + end := mn.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mn *mn_MN) MonthAbbreviated(month time.Month) string { + return mn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mn *mn_MN) MonthsAbbreviated() []string { + return mn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mn *mn_MN) MonthNarrow(month time.Month) string { + return mn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mn *mn_MN) MonthsNarrow() []string { + return mn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mn *mn_MN) MonthWide(month time.Month) string { + return mn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mn *mn_MN) MonthsWide() []string { + return mn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mn *mn_MN) WeekdayAbbreviated(weekday time.Weekday) string { + return mn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mn *mn_MN) WeekdaysAbbreviated() []string { + return mn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mn *mn_MN) WeekdayNarrow(weekday time.Weekday) string { + return mn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mn *mn_MN) WeekdaysNarrow() []string { + return mn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mn *mn_MN) WeekdayShort(weekday time.Weekday) string { + return mn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mn *mn_MN) WeekdaysShort() []string { + return mn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mn *mn_MN) WeekdayWide(weekday time.Weekday) string { + return mn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mn *mn_MN) WeekdaysWide() []string { + return mn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mn_MN' and handles both Whole and Real numbers based on 'v' +func (mn *mn_MN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mn_MN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mn *mn_MN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mn_MN' +func (mn *mn_MN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mn.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mn.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mn.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, mn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mn_MN' +// in accounting notation. +func (mn *mn_MN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mn.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mn.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, mn.currencyNegativePrefix[j]) + } + + b = append(b, mn.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(mn.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, mn.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mn_MN' +func (mn *mn_MN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mn_MN' +func (mn *mn_MN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, mn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mn_MN' +func (mn *mn_MN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xd0, 0xbe, 0xd0, 0xbd, 0xd1, 0x8b}...) + b = append(b, []byte{0x20}...) + b = append(b, mn.monthsWide[t.Month()]...) + b = append(b, []byte{0xd1, 0x81, 0xd0, 0xb0, 0xd1, 0x80, 0xd1, 0x8b, 0xd0, 0xbd}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xd3, 0xa9, 0xd0, 0xb4, 0xd3, 0xa9, 0xd1, 0x80}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mn_MN' +func (mn *mn_MN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xbe, 0xd0, 0xbd, 0xd1, 0x8b}...) + b = append(b, []byte{0x20}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x20, 0xd1, 0x81, 0xd0, 0xb0, 0xd1, 0x80, 0xd1, 0x8b, 0xd0, 0xbd}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mn_MN' +func (mn *mn_MN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mn_MN' +func (mn *mn_MN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mn_MN' +func (mn *mn_MN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mn_MN' +func (mn *mn_MN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mn_MN/mn_MN_test.go b/vendor/github.com/go-playground/locales/mn_MN/mn_MN_test.go new file mode 100644 index 0000000000..455c45b852 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mn_MN/mn_MN_test.go @@ -0,0 +1,1120 @@ +package mn_MN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mn_MN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mr/mr.go b/vendor/github.com/go-playground/locales/mr/mr.go new file mode 100644 index 0000000000..94e44578fc --- /dev/null +++ b/vendor/github.com/go-playground/locales/mr/mr.go @@ -0,0 +1,645 @@ +package mr + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mr struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mr' locale +func New() locales.Translator { + return &mr{ + locale: "mr", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "जाने", "फेब्रु", "मार्च", "एप्रि", "मे", "जून", "जुलै", "ऑग", "सप्टें", "ऑक्टो", "नोव्हें", "डिसें"}, + monthsNarrow: []string{"", "जा", "फे", "मा", "ए", "मे", "जू", "जु", "ऑ", "स", "ऑ", "नो", "डि"}, + monthsWide: []string{"", "जानेवारी", "फेब्रुवारी", "मार्च", "एप्रिल", "मे", "जून", "जुलै", "ऑगस्ट", "सप्टेंबर", "ऑक्टोबर", "नोव्हेंबर", "डिसेंबर"}, + daysAbbreviated: []string{"रवि", "सोम", "मंगळ", "बुध", "गुरु", "शुक्र", "शनि"}, + daysNarrow: []string{"र", "सो", "मं", "बु", "गु", "शु", "श"}, + daysShort: []string{"र", "सो", "मं", "बु", "गु", "शु", "श"}, + daysWide: []string{"रविवार", "सोमवार", "मंगळवार", "बुधवार", "गुरुवार", "शुक्रवार", "शनिवार"}, + periodsAbbreviated: []string{"म.पू.", "म.उ."}, + periodsNarrow: []string{"स", "सं"}, + periodsWide: []string{"म.पू.", "म.उ."}, + erasAbbreviated: []string{"इ. स. पू.", "इ. स."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ईसवीसनपूर्व", "ईसवीसन"}, + timezones: map[string]string{"ARST": "अर्जेंटिना उन्हाळी वेळ", "WAST": "पश्चिम आफ्रिका उन्हाळी वेळ", "AST": "अटलांटिक प्रमाण वेळ", "ART": "अर्जेंटिना प्रमाण वेळ", "WITA": "मध्\u200dय इंडोनेशिया वेळ", "LHDT": "लॉर्ड होवे सूर्यप्रकाश वेळ", "HAT": "न्यू फाउंडलंड सूर्यप्रकाश वेळ", "HNEG": "पूर्व ग्रीनलँड प्रमाण वेळ", "MYT": "मलेशिया वेळ", "UYST": "उरुग्वे उन्हाळी वेळ", "HNPM": "सेंट पियर आणि मिक्वेलोन प्रमाण वेळ", "HEPMX": "मेक्सिको पॅसिफिक सूर्यप्रकाश वेळ", "EAT": "पूर्व आफ्रिका वेळ", "BOT": "बोलिव्हिया वेळ", "JST": "जपान प्रमाण वेळ", "OESZ": "पूर्व युरोपियन उन्हाळी वेळ", "HKT": "हाँग काँग प्रमाण वेळ", "ACDT": "ऑस्ट्रेलियन मध्य सूर्यप्रकाश वेळ", "GFT": "फ्रेंच गयाना वेळ", "TMT": "तुर्कमेनिस्तान प्रमाण वेळ", "EST": "पौर्वात्य प्रमाण वेळ", "HNT": "न्यू फाउंडलंड प्रमाण वेळ", "PDT": "पॅसिफिक सूर्यप्रकाश वेळ", "HNNOMX": "वायव्य मेक्सिको प्रमाण वेळ", "HENOMX": "वायव्य मेक्सिको सूर्यप्रकाश वेळ", "HKST": "हाँग काँग उन्हाळी वेळ", "HEEG": "पूर्व ग्रीनलँड उन्हाळी वेळ", "HNPMX": "मेक्सिको पॅसिफिक प्रमाण वेळ", "CAT": "मध्\u200dय आफ्रिका वेळ", "NZST": "न्यूझीलंड प्रमाण वेळ", "HNOG": "पश्चिम ग्रीनलँड प्रमाण वेळ", "MDT": "मकाऊ ग्रीष्मकालीन वेळ", "WESZ": "पश्चिम युरोपियन उन्हाळी वेळ", "GMT": "ग्रीनिच प्रमाण वेळ", "SGT": "सिंगापूर प्रमाण वेळ", "HADT": "हवाई-अलूशन सूर्यप्रकाश वेळ", "CLT": "चिली प्रमाण वेळ", "OEZ": "पूर्व युरोपियन प्रमाण वेळ", "ChST": "चामोरो प्रमाण वेळ", "HNCU": "क्यूबा प्रमाण वेळ", "HECU": "क्यूबा सूर्यप्रकाश वेळ", "IST": "भारतीय प्रमाण वेळ", "MEZ": "मध्\u200dय युरोपियन प्रमाण वेळ", "AEST": "ऑस्ट्रेलियन पूर्व प्रमाण वेळ", "∅∅∅": "ऐकर ग्रीष्म वेळ", "AKST": "अलास्का प्रमाण वेळ", "AEDT": "ऑस्ट्रेलियन पूर्व सूर्यप्रकाश वेळ", "HEPM": "सेंट पियर आणि मिक्वेलोन सूर्यप्रकाश वेळ", "SRT": "सुरिनाम वेळ", "ACWDT": "ऑस्ट्रेलियन मध्य-पश्चिम सूर्यप्रकाश वेळ", "MESZ": "मध्\u200dय युरोपियन उन्हाळी वेळ", "HEOG": "पश्चिम ग्रीनलँड उन्हाळी वेळ", "AKDT": "अलास्का सूर्यप्रकाश वेळ", "SAST": "दक्षिण आफ्रिका प्रमाण वेळ", "CDT": "केंद्रीय सूर्यप्रकाश वेळ", "WIT": "पौर्वात्य इंडोनेशिया वेळ", "AWST": "ऑस्ट्रेलियन पश्चिम प्रमाण वेळ", "COT": "कोलंबिया प्रमाण वेळ", "BT": "भूतान वेळ", "CST": "केंद्रीय प्रमाण वेळ", "ADT": "अटलांटिक सूर्यप्रकाश वेळ", "COST": "कोलंबिया उन्हाळी वेळ", "GYT": "गयाना वेळ", "AWDT": "ऑस्ट्रेलियन पश्चिम सूर्यप्रकाश वेळ", "HAST": "हवाई-अलूशन प्रमाण वेळ", "CLST": "चिली उन्हाळी वेळ", "WARST": "पश्चिमी अर्जेंटिना उन्हाळी वेळ", "WAT": "पश्चिम आफ्रिका प्रमाण वेळ", "CHAST": "चॅथम प्रमाण वेळ", "ACWST": "ऑस्ट्रेलियन मध्य-पश्चिम प्रमाण वेळ", "JDT": "जपान सूर्यप्रकाश वेळ", "TMST": "तुर्कमेनिस्तान उन्हाळी वेळ", "UYT": "उरुग्वे प्रमाण वेळ", "WIB": "पश्चिमी इंडोनेशिया वेळ", "NZDT": "न्यूझीलंड सूर्यप्रकाश वेळ", "WEZ": "पश्चिम युरोपियन प्रमाण वेळ", "WART": "पश्चिमी अर्जेंटिना प्रमाण वेळ", "ACST": "ऑस्ट्रेलियन मध्य प्रमाण वेळ", "PST": "पॅसिफिक प्रमाण वेळ", "VET": "व्हेनेझुएला वेळ", "MST": "मकाऊ प्रमाणवेळ", "CHADT": "चॅथम सूर्यप्रकाश वेळ", "ECT": "इक्वेडोर वेळ", "EDT": "पौर्वात्य सूर्यप्रकाश वेळ", "LHST": "लॉर्ड होवे प्रमाण वेळ"}, + } +} + +// Locale returns the current translators string locale +func (mr *mr) Locale() string { + return mr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mr' +func (mr *mr) PluralsCardinal() []locales.PluralRule { + return mr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mr' +func (mr *mr) PluralsOrdinal() []locales.PluralRule { + return mr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mr' +func (mr *mr) PluralsRange() []locales.PluralRule { + return mr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mr' +func (mr *mr) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mr' +func (mr *mr) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mr' +func (mr *mr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := mr.CardinalPluralRule(num1, v1) + end := mr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mr *mr) MonthAbbreviated(month time.Month) string { + return mr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mr *mr) MonthsAbbreviated() []string { + return mr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mr *mr) MonthNarrow(month time.Month) string { + return mr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mr *mr) MonthsNarrow() []string { + return mr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mr *mr) MonthWide(month time.Month) string { + return mr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mr *mr) MonthsWide() []string { + return mr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mr *mr) WeekdayAbbreviated(weekday time.Weekday) string { + return mr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mr *mr) WeekdaysAbbreviated() []string { + return mr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mr *mr) WeekdayNarrow(weekday time.Weekday) string { + return mr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mr *mr) WeekdaysNarrow() []string { + return mr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mr *mr) WeekdayShort(weekday time.Weekday) string { + return mr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mr *mr) WeekdaysShort() []string { + return mr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mr *mr) WeekdayWide(weekday time.Weekday) string { + return mr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mr *mr) WeekdaysWide() []string { + return mr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mr' and handles both Whole and Real numbers based on 'v' +func (mr *mr) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, mr.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mr' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mr *mr) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mr' +func (mr *mr) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mr' +// in accounting notation. +func (mr *mr) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mr.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mr' +func (mr *mr) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mr' +func (mr *mr) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mr' +func (mr *mr) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mr.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mr' +func (mr *mr) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mr.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mr' +func (mr *mr) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, mr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, mr.periodsAbbreviated[0]...) + } else { + b = append(b, mr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mr' +func (mr *mr) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, mr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, mr.periodsAbbreviated[0]...) + } else { + b = append(b, mr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mr' +func (mr *mr) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, mr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, mr.periodsAbbreviated[0]...) + } else { + b = append(b, mr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mr' +func (mr *mr) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, mr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, mr.periodsAbbreviated[0]...) + } else { + b = append(b, mr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mr/mr_test.go b/vendor/github.com/go-playground/locales/mr/mr_test.go new file mode 100644 index 0000000000..004d4a190b --- /dev/null +++ b/vendor/github.com/go-playground/locales/mr/mr_test.go @@ -0,0 +1,1120 @@ +package mr + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mr" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mr_IN/mr_IN.go b/vendor/github.com/go-playground/locales/mr_IN/mr_IN.go new file mode 100644 index 0000000000..e808d527b6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mr_IN/mr_IN.go @@ -0,0 +1,645 @@ +package mr_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mr_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mr_IN' locale +func New() locales.Translator { + return &mr_IN{ + locale: "mr_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "जाने", "फेब्रु", "मार्च", "एप्रि", "मे", "जून", "जुलै", "ऑग", "सप्टें", "ऑक्टो", "नोव्हें", "डिसें"}, + monthsNarrow: []string{"", "जा", "फे", "मा", "ए", "मे", "जू", "जु", "ऑ", "स", "ऑ", "नो", "डि"}, + monthsWide: []string{"", "जानेवारी", "फेब्रुवारी", "मार्च", "एप्रिल", "मे", "जून", "जुलै", "ऑगस्ट", "सप्टेंबर", "ऑक्टोबर", "नोव्हेंबर", "डिसेंबर"}, + daysAbbreviated: []string{"रवि", "सोम", "मंगळ", "बुध", "गुरु", "शुक्र", "शनि"}, + daysNarrow: []string{"र", "सो", "मं", "बु", "गु", "शु", "श"}, + daysShort: []string{"र", "सो", "मं", "बु", "गु", "शु", "श"}, + daysWide: []string{"रविवार", "सोमवार", "मंगळवार", "बुधवार", "गुरुवार", "शुक्रवार", "शनिवार"}, + periodsAbbreviated: []string{"म.पू.", "म.उ."}, + periodsNarrow: []string{"स", "सं"}, + periodsWide: []string{"म.पू.", "म.उ."}, + erasAbbreviated: []string{"इ. स. पू.", "इ. स."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ईसवीसनपूर्व", "ईसवीसन"}, + timezones: map[string]string{"IST": "भारतीय प्रमाण वेळ", "ART": "अर्जेंटिना प्रमाण वेळ", "HEEG": "पूर्व ग्रीनलँड उन्हाळी वेळ", "SAST": "दक्षिण आफ्रिका प्रमाण वेळ", "AKDT": "अलास्का सूर्यप्रकाश वेळ", "AWDT": "ऑस्ट्रेलियन पश्चिम सूर्यप्रकाश वेळ", "CHADT": "चॅथम सूर्यप्रकाश वेळ", "CLT": "चिली प्रमाण वेळ", "WAST": "पश्चिम आफ्रिका उन्हाळी वेळ", "HNT": "न्यू फाउंडलंड प्रमाण वेळ", "HENOMX": "वायव्य मेक्सिको सूर्यप्रकाश वेळ", "ACDT": "ऑस्ट्रेलियन मध्य सूर्यप्रकाश वेळ", "LHST": "लॉर्ड होवे प्रमाण वेळ", "LHDT": "लॉर्ड होवे सूर्यप्रकाश वेळ", "BOT": "बोलिव्हिया वेळ", "MEZ": "मध्\u200dय युरोपियन प्रमाण वेळ", "HNOG": "पश्चिम ग्रीनलँड प्रमाण वेळ", "EDT": "पौर्वात्य सूर्यप्रकाश वेळ", "HEOG": "पश्चिम ग्रीनलँड उन्हाळी वेळ", "ADT": "अटलांटिक सूर्यप्रकाश वेळ", "UYT": "उरुग्वे प्रमाण वेळ", "WIB": "पश्चिमी इंडोनेशिया वेळ", "HAST": "हवाई-अलूशन प्रमाण वेळ", "ACWST": "ऑस्ट्रेलियन मध्य-पश्चिम प्रमाण वेळ", "NZST": "न्यूझीलंड प्रमाण वेळ", "CAT": "मध्\u200dय आफ्रिका वेळ", "CST": "केंद्रीय प्रमाण वेळ", "WITA": "मध्\u200dय इंडोनेशिया वेळ", "JST": "जपान प्रमाण वेळ", "OEZ": "पूर्व युरोपियन प्रमाण वेळ", "EST": "पौर्वात्य प्रमाण वेळ", "COT": "कोलंबिया प्रमाण वेळ", "AEST": "ऑस्ट्रेलियन पूर्व प्रमाण वेळ", "HADT": "हवाई-अलूशन सूर्यप्रकाश वेळ", "TMST": "तुर्कमेनिस्तान उन्हाळी वेळ", "MST": "मकाऊ प्रमाणवेळ", "MDT": "मकाऊ ग्रीष्मकालीन वेळ", "GYT": "गयाना वेळ", "PST": "पॅसिफिक प्रमाण वेळ", "∅∅∅": "अ\u200dॅमेझॉन उन्हाळी वेळ", "JDT": "जपान सूर्यप्रकाश वेळ", "TMT": "तुर्कमेनिस्तान प्रमाण वेळ", "ARST": "अर्जेंटिना उन्हाळी वेळ", "WIT": "पौर्वात्य इंडोनेशिया वेळ", "HNPM": "सेंट पियर आणि मिक्वेलोन प्रमाण वेळ", "HNPMX": "मेक्सिको पॅसिफिक प्रमाण वेळ", "SRT": "सुरिनाम वेळ", "HKST": "हाँग काँग उन्हाळी वेळ", "BT": "भूतान वेळ", "AEDT": "ऑस्ट्रेलियन पूर्व सूर्यप्रकाश वेळ", "AKST": "अलास्का प्रमाण वेळ", "VET": "व्हेनेझुएला वेळ", "MESZ": "मध्\u200dय युरोपियन उन्हाळी वेळ", "OESZ": "पूर्व युरोपियन उन्हाळी वेळ", "HEPM": "सेंट पियर आणि मिक्वेलोन सूर्यप्रकाश वेळ", "CDT": "केंद्रीय सूर्यप्रकाश वेळ", "PDT": "पॅसिफिक सूर्यप्रकाश वेळ", "HKT": "हाँग काँग प्रमाण वेळ", "HAT": "न्यू फाउंडलंड सूर्यप्रकाश वेळ", "HNEG": "पूर्व ग्रीनलँड प्रमाण वेळ", "HEPMX": "मेक्सिको पॅसिफिक सूर्यप्रकाश वेळ", "AWST": "ऑस्ट्रेलियन पश्चिम प्रमाण वेळ", "ECT": "इक्वेडोर वेळ", "ACWDT": "ऑस्ट्रेलियन मध्य-पश्चिम सूर्यप्रकाश वेळ", "WART": "पश्चिमी अर्जेंटिना प्रमाण वेळ", "UYST": "उरुग्वे उन्हाळी वेळ", "ChST": "चामोरो प्रमाण वेळ", "HECU": "क्यूबा सूर्यप्रकाश वेळ", "NZDT": "न्यूझीलंड सूर्यप्रकाश वेळ", "WEZ": "पश्चिम युरोपियन प्रमाण वेळ", "GMT": "ग्रीनिच प्रमाण वेळ", "MYT": "मलेशिया वेळ", "CLST": "चिली उन्हाळी वेळ", "AST": "अटलांटिक प्रमाण वेळ", "WAT": "पश्चिम आफ्रिका प्रमाण वेळ", "EAT": "पूर्व आफ्रिका वेळ", "COST": "कोलंबिया उन्हाळी वेळ", "HNNOMX": "वायव्य मेक्सिको प्रमाण वेळ", "ACST": "ऑस्ट्रेलियन मध्य प्रमाण वेळ", "GFT": "फ्रेंच गयाना वेळ", "SGT": "सिंगापूर प्रमाण वेळ", "CHAST": "चॅथम प्रमाण वेळ", "WESZ": "पश्चिम युरोपियन उन्हाळी वेळ", "WARST": "पश्चिमी अर्जेंटिना उन्हाळी वेळ", "HNCU": "क्यूबा प्रमाण वेळ"}, + } +} + +// Locale returns the current translators string locale +func (mr *mr_IN) Locale() string { + return mr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mr_IN' +func (mr *mr_IN) PluralsCardinal() []locales.PluralRule { + return mr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mr_IN' +func (mr *mr_IN) PluralsOrdinal() []locales.PluralRule { + return mr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mr_IN' +func (mr *mr_IN) PluralsRange() []locales.PluralRule { + return mr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mr_IN' +func (mr *mr_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mr_IN' +func (mr *mr_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 || n == 3 { + return locales.PluralRuleTwo + } else if n == 4 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mr_IN' +func (mr *mr_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := mr.CardinalPluralRule(num1, v1) + end := mr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mr *mr_IN) MonthAbbreviated(month time.Month) string { + return mr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mr *mr_IN) MonthsAbbreviated() []string { + return mr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mr *mr_IN) MonthNarrow(month time.Month) string { + return mr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mr *mr_IN) MonthsNarrow() []string { + return mr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mr *mr_IN) MonthWide(month time.Month) string { + return mr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mr *mr_IN) MonthsWide() []string { + return mr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mr *mr_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return mr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mr *mr_IN) WeekdaysAbbreviated() []string { + return mr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mr *mr_IN) WeekdayNarrow(weekday time.Weekday) string { + return mr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mr *mr_IN) WeekdaysNarrow() []string { + return mr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mr *mr_IN) WeekdayShort(weekday time.Weekday) string { + return mr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mr *mr_IN) WeekdaysShort() []string { + return mr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mr *mr_IN) WeekdayWide(weekday time.Weekday) string { + return mr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mr *mr_IN) WeekdaysWide() []string { + return mr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mr_IN' and handles both Whole and Real numbers based on 'v' +func (mr *mr_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, mr.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mr_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mr *mr_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mr_IN' +func (mr *mr_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mr_IN' +// in accounting notation. +func (mr *mr_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mr.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mr_IN' +func (mr *mr_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mr_IN' +func (mr *mr_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mr_IN' +func (mr *mr_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mr.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mr_IN' +func (mr *mr_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mr.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mr_IN' +func (mr *mr_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, mr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, mr.periodsAbbreviated[0]...) + } else { + b = append(b, mr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mr_IN' +func (mr *mr_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, mr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, mr.periodsAbbreviated[0]...) + } else { + b = append(b, mr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mr_IN' +func (mr *mr_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, mr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, mr.periodsAbbreviated[0]...) + } else { + b = append(b, mr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mr_IN' +func (mr *mr_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, mr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, mr.periodsAbbreviated[0]...) + } else { + b = append(b, mr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mr_IN/mr_IN_test.go b/vendor/github.com/go-playground/locales/mr_IN/mr_IN_test.go new file mode 100644 index 0000000000..2f83811e51 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mr_IN/mr_IN_test.go @@ -0,0 +1,1120 @@ +package mr_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mr_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ms/ms.go b/vendor/github.com/go-playground/locales/ms/ms.go new file mode 100644 index 0000000000..f2af59b6e9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ms/ms.go @@ -0,0 +1,627 @@ +package ms + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ms struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ms' locale +func New() locales.Translator { + return &ms{ + locale: "ms", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "RM", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "O", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Mac", "April", "Mei", "Jun", "Julai", "Ogos", "September", "Oktober", "November", "Disember"}, + daysAbbreviated: []string{"Ahd", "Isn", "Sel", "Rab", "Kha", "Jum", "Sab"}, + daysNarrow: []string{"A", "I", "S", "R", "K", "J", "S"}, + daysShort: []string{"Ah", "Is", "Se", "Ra", "Kh", "Ju", "Sa"}, + daysWide: []string{"Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu"}, + periodsAbbreviated: []string{"PG", "PTG"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"PG", "PTG"}, + erasAbbreviated: []string{"S.M.", "TM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"S.M.", "TM"}, + timezones: map[string]string{"CAT": "Waktu Afrika Tengah", "NZST": "Waktu Piawai New Zealand", "GMT": "Waktu Min Greenwich", "HKST": "Waktu Musim Panas Hong Kong", "ACDT": "Waktu Siang Australia Tengah", "AKST": "Waktu Piawai Alaska", "HEPMX": "Waktu Siang Pasifik Mexico", "WIB": "Waktu Indonesia Barat", "BOT": "Waktu Bolivia", "HAST": "Waktu Piawai Hawaii-Aleutian", "AST": "Waktu Piawai Atlantik", "MST": "MST", "EDT": "Waktu Siang Timur", "COT": "Waktu Piawai Colombia", "HNPMX": "Waktu Piawai Pasifik Mexico", "HECU": "Waktu Siang Cuba", "JST": "Waktu Piawai Jepun", "HNNOMX": "Waktu Piawai Barat Laut Mexico", "HNPM": "Waktu Piawai Saint Pierre dan Miquelon", "WIT": "Waktu Indonesia Timur", "HEOG": "Waktu Musim Panas Greenland Barat", "ART": "Waktu Piawai Argentina", "WAT": "Waktu Piawai Afrika Barat", "HNT": "Waktu Piawai Newfoundland", "HAT": "Waktu Siang Newfoundland", "HEPM": "Waktu Siang Saint Pierre dan Miquelon", "WESZ": "Waktu Musim Panas Eropah Barat", "WART": "Waktu Piawai Argentina Barat", "ARST": "Waktu Musim Panas Argentina", "UYT": "Waktu Piawai Uruguay", "PDT": "Waktu Siang Pasifik", "OESZ": "Waktu Musim Panas Eropah Timur", "CHAST": "Waktu Piawai Chatham", "HADT": "Waktu Siang Hawaii-Aleutian", "MESZ": "Waktu Musim Panas Eropah Tengah", "CLT": "Waktu Piawai Chile", "LHDT": "Waktu Siang Lord Howe", "CHADT": "Waktu Siang Chatham", "NZDT": "Waktu Siang New Zealand", "CLST": "Waktu Musim Panas Chile", "TMT": "Waktu Piawai Turkmenistan", "GFT": "Waktu Guyana Perancis", "HNCU": "Waktu Piawai Cuba", "AWST": "Waktu Piawai Australia Barat", "MEZ": "Waktu Piawai Eropah Tengah", "AEDT": "Waktu Siang Australia Timur", "UYST": "Waktu Musim Panas Uruguay", "SAST": "Waktu Piawai Afrika Selatan", "SRT": "Waktu Suriname", "ECT": "Waktu Ecuador", "JDT": "Waktu Siang Jepun", "HENOMX": "Waktu Siang Barat Laut Mexico", "CST": "Waktu Piawai Pusat", "SGT": "Waktu Piawai Singapura", "ACWST": "Waktu Piawai Barat Tengah Australia", "WEZ": "Waktu Piawai Eropah Barat", "EST": "Waktu Piawai Timur", "AKDT": "Waktu Siang Alaska", "ACWDT": "Waktu Siang Barat Tengah Australia", "OEZ": "Waktu Piawai Eropah Timur", "TMST": "Waktu Musim Panas Turkmenistan", "WAST": "Waktu Musim Panas Afrika Barat", "BT": "Waktu Bhutan", "AEST": "Waktu Piawai Timur Australia", "MYT": "Waktu Malaysia", "HNEG": "Waktu Piawai Greenland Timur", "ChST": "Waktu Piawai Chamorro", "IST": "Waktu Piawai India", "VET": "Waktu Venezuela", "WARST": "Waktu Musim Panas Argentina Barat", "HNOG": "Waktu Piawai Greenland Barat", "MDT": "MDT", "CDT": "Waktu Siang Tengah", "PST": "Waktu Piawai Pasifik", "HKT": "Waktu Piawai Hong Kong", "COST": "Waktu Musim Panas Colombia", "∅∅∅": "∅∅∅", "LHST": "Waktu Piawai Lord Howe", "EAT": "Waktu Afrika Timur", "AWDT": "Waktu Siang Australia Barat", "ADT": "Waktu Siang Atlantik", "ACST": "Waktu Piawai Australia Tengah", "HEEG": "Waktu Musim Panas Greenland Timur", "WITA": "Waktu Indonesia Tengah", "GYT": "Waktu Guyana"}, + } +} + +// Locale returns the current translators string locale +func (ms *ms) Locale() string { + return ms.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ms' +func (ms *ms) PluralsCardinal() []locales.PluralRule { + return ms.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ms' +func (ms *ms) PluralsOrdinal() []locales.PluralRule { + return ms.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ms' +func (ms *ms) PluralsRange() []locales.PluralRule { + return ms.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ms' +func (ms *ms) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ms' +func (ms *ms) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ms' +func (ms *ms) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ms *ms) MonthAbbreviated(month time.Month) string { + return ms.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ms *ms) MonthsAbbreviated() []string { + return ms.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ms *ms) MonthNarrow(month time.Month) string { + return ms.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ms *ms) MonthsNarrow() []string { + return ms.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ms *ms) MonthWide(month time.Month) string { + return ms.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ms *ms) MonthsWide() []string { + return ms.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ms *ms) WeekdayAbbreviated(weekday time.Weekday) string { + return ms.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ms *ms) WeekdaysAbbreviated() []string { + return ms.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ms *ms) WeekdayNarrow(weekday time.Weekday) string { + return ms.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ms *ms) WeekdaysNarrow() []string { + return ms.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ms *ms) WeekdayShort(weekday time.Weekday) string { + return ms.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ms *ms) WeekdaysShort() []string { + return ms.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ms *ms) WeekdayWide(weekday time.Weekday) string { + return ms.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ms *ms) WeekdaysWide() []string { + return ms.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ms' and handles both Whole and Real numbers based on 'v' +func (ms *ms) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ms' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ms *ms) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ms.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ms' +func (ms *ms) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ms.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ms.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ms' +// in accounting notation. +func (ms *ms) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ms.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ms.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ms.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ms.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ms' +func (ms *ms) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ms' +func (ms *ms) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ms' +func (ms *ms) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ms' +func (ms *ms) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ms.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ms' +func (ms *ms) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ms' +func (ms *ms) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ms' +func (ms *ms) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ms' +func (ms *ms) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ms.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ms/ms_test.go b/vendor/github.com/go-playground/locales/ms/ms_test.go new file mode 100644 index 0000000000..2662ad322a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ms/ms_test.go @@ -0,0 +1,1120 @@ +package ms + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ms" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ms_BN/ms_BN.go b/vendor/github.com/go-playground/locales/ms_BN/ms_BN.go new file mode 100644 index 0000000000..1dfe8cbb27 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ms_BN/ms_BN.go @@ -0,0 +1,637 @@ +package ms_BN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ms_BN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ms_BN' locale +func New() locales.Translator { + return &ms_BN{ + locale: "ms_BN", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "$", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "O", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Mac", "April", "Mei", "Jun", "Julai", "Ogos", "September", "Oktober", "November", "Disember"}, + daysAbbreviated: []string{"Ahd", "Isn", "Sel", "Rab", "Kha", "Jum", "Sab"}, + daysNarrow: []string{"A", "I", "S", "R", "K", "J", "S"}, + daysShort: []string{"Ah", "Is", "Se", "Ra", "Kh", "Ju", "Sa"}, + daysWide: []string{"Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu"}, + periodsAbbreviated: []string{"PG", "PTG"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"PG", "PTG"}, + erasAbbreviated: []string{"S.M.", "TM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"S.M.", "TM"}, + timezones: map[string]string{"SAST": "Waktu Piawai Afrika Selatan", "HEPMX": "Waktu Siang Pasifik Mexico", "SRT": "Waktu Suriname", "PDT": "Waktu Siang Pasifik", "JDT": "Waktu Siang Jepun", "WITA": "Waktu Indonesia Tengah", "AKDT": "Waktu Siang Alaska", "EAT": "Waktu Afrika Timur", "IST": "Waktu Piawai India", "JST": "Waktu Piawai Jepun", "OESZ": "Waktu Musim Panas Eropah Timur", "WAT": "Waktu Piawai Afrika Barat", "MDT": "Waktu Hari Siang Pergunungan", "UYST": "Waktu Musim Panas Uruguay", "CDT": "Waktu Siang Tengah", "HAST": "Waktu Piawai Hawaii-Aleutian", "NZST": "Waktu Piawai New Zealand", "VET": "Waktu Venezuela", "TMT": "Waktu Piawai Turkmenistan", "HNNOMX": "Waktu Piawai Barat Laut Mexico", "HNT": "Waktu Piawai Newfoundland", "AKST": "Waktu Piawai Alaska", "SGT": "Waktu Piawai Singapura", "HADT": "Waktu Siang Hawaii-Aleutian", "HNOG": "Waktu Piawai Greenland Barat", "OEZ": "Waktu Piawai Eropah Timur", "ARST": "Waktu Musim Panas Argentina", "HNPMX": "Waktu Piawai Pasifik Mexico", "GMT": "Waktu Min Greenwich", "HKT": "Waktu Piawai Hong Kong", "ACDT": "Waktu Siang Australia Tengah", "LHST": "Waktu Piawai Lord Howe", "LHDT": "Waktu Siang Lord Howe", "HECU": "Waktu Siang Cuba", "ACWST": "Waktu Piawai Barat Tengah Australia", "CLST": "Waktu Musim Panas Chile", "WEZ": "Waktu Piawai Eropah Barat", "WAST": "Waktu Musim Panas Afrika Barat", "EST": "Waktu Piawai Timur", "∅∅∅": "∅∅∅", "GFT": "Waktu Guyana Perancis", "HNCU": "Waktu Piawai Cuba", "CST": "Waktu Piawai Pusat", "CHAST": "Waktu Piawai Chatham", "BOT": "Waktu Bolivia", "NZDT": "Waktu Siang New Zealand", "COT": "Waktu Piawai Colombia", "HNPM": "Waktu Piawai Saint Pierre dan Miquelon", "MYT": "Waktu Malaysia", "AST": "Waktu Piawai Atlantik", "ACST": "Waktu Piawai Australia Tengah", "HEPM": "Waktu Siang Saint Pierre dan Miquelon", "PST": "Waktu Piawai Pasifik", "WART": "Waktu Piawai Argentina Barat", "UYT": "Waktu Piawai Uruguay", "ECT": "Waktu Ecuador", "ACWDT": "Waktu Siang Barat Tengah Australia", "MEZ": "Waktu Piawai Eropah Tengah", "EDT": "Waktu Siang Timur", "COST": "Waktu Musim Panas Colombia", "AEST": "Waktu Piawai Timur Australia", "ChST": "Waktu Piawai Chamorro", "MESZ": "Waktu Musim Panas Eropah Tengah", "ART": "Waktu Piawai Argentina", "WIB": "Waktu Indonesia Barat", "CHADT": "Waktu Siang Chatham", "HEOG": "Waktu Musim Panas Greenland Barat", "ADT": "Waktu Siang Atlantik", "WESZ": "Waktu Musim Panas Eropah Barat", "TMST": "Waktu Musim Panas Turkmenistan", "HENOMX": "Waktu Siang Barat Laut Mexico", "AEDT": "Waktu Siang Australia Timur", "GYT": "Waktu Guyana", "WIT": "Waktu Indonesia Timur", "AWST": "Waktu Piawai Australia Barat", "AWDT": "Waktu Siang Australia Barat", "CLT": "Waktu Piawai Chile", "HKST": "Waktu Musim Panas Hong Kong", "HAT": "Waktu Siang Newfoundland", "HNEG": "Waktu Piawai Greenland Timur", "MST": "Waktu Piawai Pergunungan", "CAT": "Waktu Afrika Tengah", "WARST": "Waktu Musim Panas Argentina Barat", "BT": "Waktu Bhutan", "HEEG": "Waktu Musim Panas Greenland Timur"}, + } +} + +// Locale returns the current translators string locale +func (ms *ms_BN) Locale() string { + return ms.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ms_BN' +func (ms *ms_BN) PluralsCardinal() []locales.PluralRule { + return ms.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ms_BN' +func (ms *ms_BN) PluralsOrdinal() []locales.PluralRule { + return ms.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ms_BN' +func (ms *ms_BN) PluralsRange() []locales.PluralRule { + return ms.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ms_BN' +func (ms *ms_BN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ms_BN' +func (ms *ms_BN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ms_BN' +func (ms *ms_BN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ms *ms_BN) MonthAbbreviated(month time.Month) string { + return ms.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ms *ms_BN) MonthsAbbreviated() []string { + return ms.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ms *ms_BN) MonthNarrow(month time.Month) string { + return ms.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ms *ms_BN) MonthsNarrow() []string { + return ms.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ms *ms_BN) MonthWide(month time.Month) string { + return ms.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ms *ms_BN) MonthsWide() []string { + return ms.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ms *ms_BN) WeekdayAbbreviated(weekday time.Weekday) string { + return ms.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ms *ms_BN) WeekdaysAbbreviated() []string { + return ms.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ms *ms_BN) WeekdayNarrow(weekday time.Weekday) string { + return ms.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ms *ms_BN) WeekdaysNarrow() []string { + return ms.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ms *ms_BN) WeekdayShort(weekday time.Weekday) string { + return ms.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ms *ms_BN) WeekdaysShort() []string { + return ms.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ms *ms_BN) WeekdayWide(weekday time.Weekday) string { + return ms.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ms *ms_BN) WeekdaysWide() []string { + return ms.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ms_BN' and handles both Whole and Real numbers based on 'v' +func (ms *ms_BN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ms_BN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ms *ms_BN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ms.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ms_BN' +func (ms *ms_BN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ms.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ms.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ms.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ms.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ms_BN' +// in accounting notation. +func (ms *ms_BN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ms.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ms.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ms.currencyNegativePrefix[j]) + } + + b = append(b, ms.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ms.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ms.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ms.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ms_BN' +func (ms *ms_BN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ms_BN' +func (ms *ms_BN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ms_BN' +func (ms *ms_BN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ms_BN' +func (ms *ms_BN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ms_BN' +func (ms *ms_BN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ms_BN' +func (ms *ms_BN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ms_BN' +func (ms *ms_BN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ms_BN' +func (ms *ms_BN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ms.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ms_BN/ms_BN_test.go b/vendor/github.com/go-playground/locales/ms_BN/ms_BN_test.go new file mode 100644 index 0000000000..c160175ffc --- /dev/null +++ b/vendor/github.com/go-playground/locales/ms_BN/ms_BN_test.go @@ -0,0 +1,1120 @@ +package ms_BN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ms_BN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ms_MY/ms_MY.go b/vendor/github.com/go-playground/locales/ms_MY/ms_MY.go new file mode 100644 index 0000000000..2dde1fb3e7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ms_MY/ms_MY.go @@ -0,0 +1,627 @@ +package ms_MY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ms_MY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ms_MY' locale +func New() locales.Translator { + return &ms_MY{ + locale: "ms_MY", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "O", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Mac", "April", "Mei", "Jun", "Julai", "Ogos", "September", "Oktober", "November", "Disember"}, + daysAbbreviated: []string{"Ahd", "Isn", "Sel", "Rab", "Kha", "Jum", "Sab"}, + daysNarrow: []string{"A", "I", "S", "R", "K", "J", "S"}, + daysShort: []string{"Ah", "Is", "Se", "Ra", "Kh", "Ju", "Sa"}, + daysWide: []string{"Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu"}, + periodsAbbreviated: []string{"PG", "PTG"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"PG", "PTG"}, + erasAbbreviated: []string{"S.M.", "TM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"S.M.", "TM"}, + timezones: map[string]string{"ARST": "Waktu Musim Panas Argentina", "HNNOMX": "Waktu Piawai Barat Laut Mexico", "HEEG": "Waktu Musim Panas Greenland Timur", "CDT": "Waktu Siang Tengah", "AWST": "Waktu Piawai Australia Barat", "AWDT": "Waktu Siang Australia Barat", "ECT": "Waktu Ecuador", "ACWST": "Waktu Piawai Barat Tengah Australia", "ACWDT": "Waktu Siang Barat Tengah Australia", "OEZ": "Waktu Piawai Eropah Timur", "HNT": "Waktu Piawai Newfoundland", "LHDT": "Waktu Siang Lord Howe", "EAT": "Waktu Afrika Timur", "HADT": "Waktu Siang Hawaii-Aleutian", "MDT": "Waktu Hari Siang Pergunungan", "HNPMX": "Waktu Piawai Pasifik Mexico", "HECU": "Waktu Siang Cuba", "PDT": "Waktu Siang Pasifik", "IST": "Waktu Piawai India", "VET": "Waktu Venezuela", "GMT": "Waktu Min Greenwich", "COT": "Waktu Piawai Colombia", "∅∅∅": "Waktu Musim Panas Azores", "BT": "Waktu Bhutan", "MESZ": "Waktu Musim Panas Eropah Tengah", "MYT": "Waktu Malaysia", "HKST": "Waktu Musim Panas Hong Kong", "NZST": "Waktu Piawai New Zealand", "WIT": "Waktu Indonesia Timur", "BOT": "Waktu Bolivia", "JST": "Waktu Piawai Jepun", "HENOMX": "Waktu Siang Barat Laut Mexico", "SRT": "Waktu Suriname", "SAST": "Waktu Piawai Afrika Selatan", "CHAST": "Waktu Piawai Chatham", "PST": "Waktu Piawai Pasifik", "WEZ": "Waktu Piawai Eropah Barat", "TMT": "Waktu Piawai Turkmenistan", "ACST": "Waktu Piawai Australia Tengah", "AKST": "Waktu Piawai Alaska", "CLT": "Waktu Piawai Chile", "HNOG": "Waktu Piawai Greenland Barat", "WARST": "Waktu Musim Panas Argentina Barat", "WAST": "Waktu Musim Panas Afrika Barat", "EDT": "Waktu Siang Timur", "NZDT": "Waktu Siang New Zealand", "HNCU": "Waktu Piawai Cuba", "HAST": "Waktu Piawai Hawaii-Aleutian", "WESZ": "Waktu Musim Panas Eropah Barat", "WAT": "Waktu Piawai Afrika Barat", "UYT": "Waktu Piawai Uruguay", "AEST": "Waktu Piawai Timur Australia", "UYST": "Waktu Musim Panas Uruguay", "LHST": "Waktu Piawai Lord Howe", "CHADT": "Waktu Siang Chatham", "HKT": "Waktu Piawai Hong Kong", "HNEG": "Waktu Piawai Greenland Timur", "WITA": "Waktu Indonesia Tengah", "AEDT": "Waktu Siang Australia Timur", "HEPM": "Waktu Siang Saint Pierre dan Miquelon", "CST": "Waktu Piawai Pusat", "HEOG": "Waktu Musim Panas Greenland Barat", "ART": "Waktu Piawai Argentina", "ACDT": "Waktu Siang Australia Tengah", "HAT": "Waktu Siang Newfoundland", "AKDT": "Waktu Siang Alaska", "CLST": "Waktu Musim Panas Chile", "EST": "Waktu Piawai Timur", "CAT": "Waktu Afrika Tengah", "ChST": "Waktu Piawai Chamorro", "HNPM": "Waktu Piawai Saint Pierre dan Miquelon", "GYT": "Waktu Guyana", "WIB": "Waktu Indonesia Barat", "MEZ": "Waktu Piawai Eropah Tengah", "JDT": "Waktu Siang Jepun", "COST": "Waktu Musim Panas Colombia", "MST": "Waktu Piawai Pergunungan", "HEPMX": "Waktu Siang Pasifik Mexico", "SGT": "Waktu Piawai Singapura", "WART": "Waktu Piawai Argentina Barat", "AST": "Waktu Piawai Atlantik", "ADT": "Waktu Siang Atlantik", "OESZ": "Waktu Musim Panas Eropah Timur", "TMST": "Waktu Musim Panas Turkmenistan", "GFT": "Waktu Guyana Perancis"}, + } +} + +// Locale returns the current translators string locale +func (ms *ms_MY) Locale() string { + return ms.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ms_MY' +func (ms *ms_MY) PluralsCardinal() []locales.PluralRule { + return ms.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ms_MY' +func (ms *ms_MY) PluralsOrdinal() []locales.PluralRule { + return ms.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ms_MY' +func (ms *ms_MY) PluralsRange() []locales.PluralRule { + return ms.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ms_MY' +func (ms *ms_MY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ms_MY' +func (ms *ms_MY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ms_MY' +func (ms *ms_MY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ms *ms_MY) MonthAbbreviated(month time.Month) string { + return ms.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ms *ms_MY) MonthsAbbreviated() []string { + return ms.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ms *ms_MY) MonthNarrow(month time.Month) string { + return ms.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ms *ms_MY) MonthsNarrow() []string { + return ms.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ms *ms_MY) MonthWide(month time.Month) string { + return ms.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ms *ms_MY) MonthsWide() []string { + return ms.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ms *ms_MY) WeekdayAbbreviated(weekday time.Weekday) string { + return ms.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ms *ms_MY) WeekdaysAbbreviated() []string { + return ms.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ms *ms_MY) WeekdayNarrow(weekday time.Weekday) string { + return ms.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ms *ms_MY) WeekdaysNarrow() []string { + return ms.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ms *ms_MY) WeekdayShort(weekday time.Weekday) string { + return ms.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ms *ms_MY) WeekdaysShort() []string { + return ms.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ms *ms_MY) WeekdayWide(weekday time.Weekday) string { + return ms.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ms *ms_MY) WeekdaysWide() []string { + return ms.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ms_MY' and handles both Whole and Real numbers based on 'v' +func (ms *ms_MY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ms_MY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ms *ms_MY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ms.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ms_MY' +func (ms *ms_MY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ms.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ms.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ms_MY' +// in accounting notation. +func (ms *ms_MY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ms.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ms.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ms.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ms.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ms_MY' +func (ms *ms_MY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ms_MY' +func (ms *ms_MY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ms_MY' +func (ms *ms_MY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ms_MY' +func (ms *ms_MY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ms.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ms_MY' +func (ms *ms_MY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ms_MY' +func (ms *ms_MY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ms_MY' +func (ms *ms_MY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ms_MY' +func (ms *ms_MY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ms.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ms_MY/ms_MY_test.go b/vendor/github.com/go-playground/locales/ms_MY/ms_MY_test.go new file mode 100644 index 0000000000..1f3b5654d1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ms_MY/ms_MY_test.go @@ -0,0 +1,1120 @@ +package ms_MY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ms_MY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ms_SG/ms_SG.go b/vendor/github.com/go-playground/locales/ms_SG/ms_SG.go new file mode 100644 index 0000000000..df2417ebf3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ms_SG/ms_SG.go @@ -0,0 +1,627 @@ +package ms_SG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ms_SG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ms_SG' locale +func New() locales.Translator { + return &ms_SG{ + locale: "ms_SG", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "$", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "O", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Mac", "April", "Mei", "Jun", "Julai", "Ogos", "September", "Oktober", "November", "Disember"}, + daysAbbreviated: []string{"Ahd", "Isn", "Sel", "Rab", "Kha", "Jum", "Sab"}, + daysNarrow: []string{"A", "I", "S", "R", "K", "J", "S"}, + daysShort: []string{"Ah", "Is", "Se", "Ra", "Kh", "Ju", "Sa"}, + daysWide: []string{"Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu"}, + periodsAbbreviated: []string{"PG", "PTG"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"PG", "PTG"}, + erasAbbreviated: []string{"S.M.", "TM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"S.M.", "TM"}, + timezones: map[string]string{"AWDT": "Waktu Siang Australia Barat", "ART": "Waktu Piawai Argentina", "AEDT": "Waktu Siang Australia Timur", "AWST": "Waktu Piawai Australia Barat", "MEZ": "Waktu Piawai Eropah Tengah", "WART": "Waktu Piawai Argentina Barat", "HEOG": "Waktu Musim Panas Greenland Barat", "ACST": "Waktu Piawai Australia Tengah", "HEEG": "Waktu Musim Panas Greenland Timur", "PDT": "Waktu Siang Pasifik", "BOT": "Waktu Bolivia", "ACWDT": "Waktu Siang Barat Tengah Australia", "JDT": "Waktu Siang Jepun", "TMST": "Waktu Musim Panas Turkmenistan", "MST": "MST", "WAST": "Waktu Musim Panas Afrika Barat", "HEPMX": "Waktu Siang Pasifik Mexico", "ARST": "Waktu Musim Panas Argentina", "HKT": "Waktu Piawai Hong Kong", "COST": "Waktu Musim Panas Colombia", "WITA": "Waktu Indonesia Tengah", "NZST": "Waktu Piawai New Zealand", "LHST": "Waktu Piawai Lord Howe", "SRT": "Waktu Suriname", "CAT": "Waktu Afrika Tengah", "WARST": "Waktu Musim Panas Argentina Barat", "TMT": "Waktu Piawai Turkmenistan", "EDT": "Waktu Siang Timur", "BT": "Waktu Bhutan", "∅∅∅": "Waktu Musim Panas Azores", "GFT": "Waktu Guyana Perancis", "HADT": "Waktu Siang Hawaii-Aleutian", "AKDT": "Waktu Siang Alaska", "CDT": "Waktu Siang Tengah", "PST": "Waktu Piawai Pasifik", "IST": "Waktu Piawai India", "ACWST": "Waktu Piawai Barat Tengah Australia", "GMT": "Waktu Min Greenwich", "HKST": "Waktu Musim Panas Hong Kong", "CHADT": "Waktu Siang Chatham", "ACDT": "Waktu Siang Australia Tengah", "HNNOMX": "Waktu Piawai Barat Laut Mexico", "HENOMX": "Waktu Siang Barat Laut Mexico", "AEST": "Waktu Piawai Timur Australia", "HAST": "Waktu Piawai Hawaii-Aleutian", "GYT": "Waktu Guyana", "CST": "Waktu Piawai Pusat", "WIT": "Waktu Indonesia Timur", "CLT": "Waktu Piawai Chile", "UYT": "Waktu Piawai Uruguay", "ECT": "Waktu Ecuador", "SGT": "Waktu Piawai Singapura", "HNT": "Waktu Piawai Newfoundland", "SAST": "Waktu Piawai Afrika Selatan", "HECU": "Waktu Siang Cuba", "MESZ": "Waktu Musim Panas Eropah Tengah", "VET": "Waktu Venezuela", "ChST": "Waktu Piawai Chamorro", "HNPMX": "Waktu Piawai Pasifik Mexico", "EAT": "Waktu Afrika Timur", "WIB": "Waktu Indonesia Barat", "MYT": "Waktu Malaysia", "HNOG": "Waktu Piawai Greenland Barat", "AST": "Waktu Piawai Atlantik", "WESZ": "Waktu Musim Panas Eropah Barat", "LHDT": "Waktu Siang Lord Howe", "HAT": "Waktu Siang Newfoundland", "EST": "Waktu Piawai Timur", "HNCU": "Waktu Piawai Cuba", "NZDT": "Waktu Siang New Zealand", "JST": "Waktu Piawai Jepun", "CLST": "Waktu Musim Panas Chile", "OEZ": "Waktu Piawai Eropah Timur", "WEZ": "Waktu Piawai Eropah Barat", "MDT": "MDT", "UYST": "Waktu Musim Panas Uruguay", "WAT": "Waktu Piawai Afrika Barat", "HEPM": "Waktu Siang Saint Pierre dan Miquelon", "CHAST": "Waktu Piawai Chatham", "ADT": "Waktu Siang Atlantik", "OESZ": "Waktu Musim Panas Eropah Timur", "COT": "Waktu Piawai Colombia", "HNEG": "Waktu Piawai Greenland Timur", "AKST": "Waktu Piawai Alaska", "HNPM": "Waktu Piawai Saint Pierre dan Miquelon"}, + } +} + +// Locale returns the current translators string locale +func (ms *ms_SG) Locale() string { + return ms.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ms_SG' +func (ms *ms_SG) PluralsCardinal() []locales.PluralRule { + return ms.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ms_SG' +func (ms *ms_SG) PluralsOrdinal() []locales.PluralRule { + return ms.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ms_SG' +func (ms *ms_SG) PluralsRange() []locales.PluralRule { + return ms.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ms_SG' +func (ms *ms_SG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ms_SG' +func (ms *ms_SG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ms_SG' +func (ms *ms_SG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ms *ms_SG) MonthAbbreviated(month time.Month) string { + return ms.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ms *ms_SG) MonthsAbbreviated() []string { + return ms.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ms *ms_SG) MonthNarrow(month time.Month) string { + return ms.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ms *ms_SG) MonthsNarrow() []string { + return ms.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ms *ms_SG) MonthWide(month time.Month) string { + return ms.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ms *ms_SG) MonthsWide() []string { + return ms.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ms *ms_SG) WeekdayAbbreviated(weekday time.Weekday) string { + return ms.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ms *ms_SG) WeekdaysAbbreviated() []string { + return ms.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ms *ms_SG) WeekdayNarrow(weekday time.Weekday) string { + return ms.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ms *ms_SG) WeekdaysNarrow() []string { + return ms.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ms *ms_SG) WeekdayShort(weekday time.Weekday) string { + return ms.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ms *ms_SG) WeekdaysShort() []string { + return ms.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ms *ms_SG) WeekdayWide(weekday time.Weekday) string { + return ms.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ms *ms_SG) WeekdaysWide() []string { + return ms.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ms_SG' and handles both Whole and Real numbers based on 'v' +func (ms *ms_SG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ms_SG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ms *ms_SG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ms.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ms_SG' +func (ms *ms_SG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ms.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ms.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ms.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ms_SG' +// in accounting notation. +func (ms *ms_SG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ms.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ms.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ms.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ms.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ms.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ms.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ms_SG' +func (ms *ms_SG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ms_SG' +func (ms *ms_SG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ms_SG' +func (ms *ms_SG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ms_SG' +func (ms *ms_SG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ms.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ms.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ms_SG' +func (ms *ms_SG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ms_SG' +func (ms *ms_SG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ms_SG' +func (ms *ms_SG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ms_SG' +func (ms *ms_SG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ms.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ms.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ms.periodsAbbreviated[0]...) + } else { + b = append(b, ms.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ms.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ms_SG/ms_SG_test.go b/vendor/github.com/go-playground/locales/ms_SG/ms_SG_test.go new file mode 100644 index 0000000000..6b771c4b54 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ms_SG/ms_SG_test.go @@ -0,0 +1,1120 @@ +package ms_SG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ms_SG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mt/mt.go b/vendor/github.com/go-playground/locales/mt/mt.go new file mode 100644 index 0000000000..42fa63d6b0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mt/mt.go @@ -0,0 +1,596 @@ +package mt + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mt struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mt' locale +func New() locales.Translator { + return &mt{ + locale: "mt", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "Rs", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Fra", "Mar", "Apr", "Mej", "Ġun", "Lul", "Aww", "Set", "Ott", "Nov", "Diċ"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Ġ", "L", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Jannar", "Frar", "Marzu", "April", "Mejju", "Ġunju", "Lulju", "Awwissu", "Settembru", "Ottubru", "Novembru", "Diċembru"}, + daysAbbreviated: []string{"Ħad", "Tne", "Tli", "Erb", "Ħam", "Ġim", "Sib"}, + daysNarrow: []string{"Ħd", "T", "Tl", "Er", "Ħm", "Ġm", "Sb"}, + daysShort: []string{"Ħad", "Tne", "Tli", "Erb", "Ħam", "Ġim", "Sib"}, + daysWide: []string{"Il-Ħadd", "It-Tnejn", "It-Tlieta", "L-Erbgħa", "Il-Ħamis", "Il-Ġimgħa", "Is-Sibt"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"QK", "WK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Qabel Kristu", "Wara Kristu"}, + timezones: map[string]string{"HENOMX": "HENOMX", "HNEG": "HNEG", "MESZ": "Ħin Ċentrali Ewropew tas-Sajf", "WEZ": "WEZ", "MDT": "MDT", "EDT": "EDT", "COST": "COST", "HEEG": "HEEG", "CST": "CST", "AST": "AST", "OESZ": "OESZ", "HKT": "HKT", "HNNOMX": "HNNOMX", "TMST": "TMST", "AEST": "AEST", "HNPM": "HNPM", "LHST": "LHST", "AWDT": "AWDT", "JST": "JST", "WARST": "WARST", "LHDT": "LHDT", "MYT": "MYT", "AKDT": "AKDT", "HECU": "HECU", "MEZ": "Ħin Ċentrali Ewropew Standard", "HEOG": "HEOG", "ADT": "ADT", "AKST": "AKST", "BOT": "BOT", "VET": "VET", "CLT": "CLT", "OEZ": "OEZ", "ACDT": "ACDT", "CLST": "CLST", "COT": "COT", "HNPMX": "HNPMX", "CAT": "CAT", "ACWST": "ACWST", "JDT": "JDT", "WART": "WART", "TMT": "TMT", "ARST": "ARST", "UYT": "UYT", "UYST": "UYST", "HEPM": "HEPM", "HEPMX": "HEPMX", "HADT": "HADT", "CHADT": "CHADT", "PST": "PST", "IST": "IST", "HNT": "HNT", "GFT": "GFT", "SRT": "SRT", "CDT": "CDT", "CHAST": "CHAST", "WAT": "WAT", "ACST": "ACST", "WESZ": "WESZ", "ART": "ART", "EST": "EST", "SAST": "SAST", "∅∅∅": "∅∅∅", "GYT": "GYT", "EAT": "EAT", "WIB": "WIB", "BT": "BT", "WITA": "WITA", "SGT": "SGT", "ECT": "ECT", "NZST": "NZST", "AEDT": "AEDT", "ChST": "ChST", "HAST": "HAST", "NZDT": "NZDT", "WAST": "WAST", "HAT": "HAT", "WIT": "WIT", "PDT": "PDT", "ACWDT": "ACWDT", "GMT": "GMT", "MST": "MST", "HNCU": "HNCU", "AWST": "AWST", "HNOG": "HNOG", "HKST": "HKST"}, + } +} + +// Locale returns the current translators string locale +func (mt *mt) Locale() string { + return mt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mt' +func (mt *mt) PluralsCardinal() []locales.PluralRule { + return mt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mt' +func (mt *mt) PluralsOrdinal() []locales.PluralRule { + return mt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mt' +func (mt *mt) PluralsRange() []locales.PluralRule { + return mt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mt' +func (mt *mt) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 1 { + return locales.PluralRuleOne + } else if (n == 0) || (nMod100 >= 2 && nMod100 <= 10) { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 19 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mt' +func (mt *mt) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mt' +func (mt *mt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mt *mt) MonthAbbreviated(month time.Month) string { + return mt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mt *mt) MonthsAbbreviated() []string { + return mt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mt *mt) MonthNarrow(month time.Month) string { + return mt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mt *mt) MonthsNarrow() []string { + return mt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mt *mt) MonthWide(month time.Month) string { + return mt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mt *mt) MonthsWide() []string { + return mt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mt *mt) WeekdayAbbreviated(weekday time.Weekday) string { + return mt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mt *mt) WeekdaysAbbreviated() []string { + return mt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mt *mt) WeekdayNarrow(weekday time.Weekday) string { + return mt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mt *mt) WeekdaysNarrow() []string { + return mt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mt *mt) WeekdayShort(weekday time.Weekday) string { + return mt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mt *mt) WeekdaysShort() []string { + return mt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mt *mt) WeekdayWide(weekday time.Weekday) string { + return mt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mt *mt) WeekdaysWide() []string { + return mt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mt' and handles both Whole and Real numbers based on 'v' +func (mt *mt) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mt' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mt *mt) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mt' +func (mt *mt) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mt' +// in accounting notation. +func (mt *mt) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mt.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mt' +func (mt *mt) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mt' +func (mt *mt) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mt' +func (mt *mt) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x74, 0x61}...) + b = append(b, []byte{0xe2, 0x80, 0x99, 0x20}...) + b = append(b, mt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mt' +func (mt *mt) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x74, 0x61}...) + b = append(b, []byte{0xe2, 0x80, 0x99, 0x20}...) + b = append(b, mt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mt' +func (mt *mt) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mt' +func (mt *mt) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mt' +func (mt *mt) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mt' +func (mt *mt) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mt/mt_test.go b/vendor/github.com/go-playground/locales/mt/mt_test.go new file mode 100644 index 0000000000..6be1ca29f0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mt/mt_test.go @@ -0,0 +1,1120 @@ +package mt + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mt" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mt_MT/mt_MT.go b/vendor/github.com/go-playground/locales/mt_MT/mt_MT.go new file mode 100644 index 0000000000..1d57febedd --- /dev/null +++ b/vendor/github.com/go-playground/locales/mt_MT/mt_MT.go @@ -0,0 +1,596 @@ +package mt_MT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mt_MT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mt_MT' locale +func New() locales.Translator { + return &mt_MT{ + locale: "mt_MT", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Fra", "Mar", "Apr", "Mej", "Ġun", "Lul", "Aww", "Set", "Ott", "Nov", "Diċ"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "Ġ", "L", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Jannar", "Frar", "Marzu", "April", "Mejju", "Ġunju", "Lulju", "Awwissu", "Settembru", "Ottubru", "Novembru", "Diċembru"}, + daysAbbreviated: []string{"Ħad", "Tne", "Tli", "Erb", "Ħam", "Ġim", "Sib"}, + daysNarrow: []string{"Ħd", "T", "Tl", "Er", "Ħm", "Ġm", "Sb"}, + daysShort: []string{"Ħad", "Tne", "Tli", "Erb", "Ħam", "Ġim", "Sib"}, + daysWide: []string{"Il-Ħadd", "It-Tnejn", "It-Tlieta", "L-Erbgħa", "Il-Ħamis", "Il-Ġimgħa", "Is-Sibt"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"QK", "WK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Qabel Kristu", "Wara Kristu"}, + timezones: map[string]string{"HEEG": "HEEG", "HNCU": "HNCU", "CLT": "CLT", "GMT": "GMT", "HKST": "HKST", "HNEG": "HNEG", "MST": "MST", "ACST": "ACST", "COT": "COT", "AKDT": "AKDT", "HKT": "HKT", "WIB": "WIB", "HADT": "HADT", "CAT": "CAT", "JDT": "JDT", "WARST": "WARST", "MYT": "MYT", "BT": "BT", "WITA": "WITA", "WIT": "WIT", "CHADT": "CHADT", "MESZ": "Ħin Ċentrali Ewropew tas-Sajf", "JST": "JST", "HEOG": "HEOG", "SAST": "SAST", "AWST": "AWST", "BOT": "BOT", "WESZ": "WESZ", "MDT": "MDT", "ART": "ART", "COST": "COST", "AKST": "AKST", "UYT": "UYT", "SGT": "SGT", "NZST": "NZST", "NZDT": "NZDT", "MEZ": "Ħin Ċentrali Ewropew Standard", "HECU": "HECU", "EST": "EST", "EDT": "EDT", "HNPM": "HNPM", "EAT": "EAT", "CHAST": "CHAST", "PDT": "PDT", "ACWDT": "ACWDT", "AST": "AST", "HENOMX": "HENOMX", "HNT": "HNT", "HEPMX": "HEPMX", "GYT": "GYT", "VET": "VET", "HNOG": "HNOG", "ADT": "ADT", "ARST": "ARST", "GFT": "GFT", "AEDT": "AEDT", "CST": "CST", "CDT": "CDT", "AWDT": "AWDT", "PST": "PST", "WEZ": "WEZ", "ACDT": "ACDT", "IST": "IST", "WART": "WART", "HNNOMX": "HNNOMX", "HAST": "HAST", "∅∅∅": "∅∅∅", "TMST": "TMST", "UYST": "UYST", "AEST": "AEST", "LHDT": "LHDT", "HNPMX": "HNPMX", "HEPM": "HEPM", "SRT": "SRT", "CLST": "CLST", "OEZ": "OEZ", "OESZ": "OESZ", "TMT": "TMT", "ECT": "ECT", "ACWST": "ACWST", "WAST": "WAST", "WAT": "WAT", "HAT": "HAT", "LHST": "LHST", "ChST": "ChST"}, + } +} + +// Locale returns the current translators string locale +func (mt *mt_MT) Locale() string { + return mt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mt_MT' +func (mt *mt_MT) PluralsCardinal() []locales.PluralRule { + return mt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mt_MT' +func (mt *mt_MT) PluralsOrdinal() []locales.PluralRule { + return mt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mt_MT' +func (mt *mt_MT) PluralsRange() []locales.PluralRule { + return mt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mt_MT' +func (mt *mt_MT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod100 := math.Mod(n, 100) + + if n == 1 { + return locales.PluralRuleOne + } else if (n == 0) || (nMod100 >= 2 && nMod100 <= 10) { + return locales.PluralRuleFew + } else if nMod100 >= 11 && nMod100 <= 19 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mt_MT' +func (mt *mt_MT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mt_MT' +func (mt *mt_MT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mt *mt_MT) MonthAbbreviated(month time.Month) string { + return mt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mt *mt_MT) MonthsAbbreviated() []string { + return mt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mt *mt_MT) MonthNarrow(month time.Month) string { + return mt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mt *mt_MT) MonthsNarrow() []string { + return mt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mt *mt_MT) MonthWide(month time.Month) string { + return mt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mt *mt_MT) MonthsWide() []string { + return mt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mt *mt_MT) WeekdayAbbreviated(weekday time.Weekday) string { + return mt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mt *mt_MT) WeekdaysAbbreviated() []string { + return mt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mt *mt_MT) WeekdayNarrow(weekday time.Weekday) string { + return mt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mt *mt_MT) WeekdaysNarrow() []string { + return mt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mt *mt_MT) WeekdayShort(weekday time.Weekday) string { + return mt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mt *mt_MT) WeekdaysShort() []string { + return mt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mt *mt_MT) WeekdayWide(weekday time.Weekday) string { + return mt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mt *mt_MT) WeekdaysWide() []string { + return mt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mt_MT' and handles both Whole and Real numbers based on 'v' +func (mt *mt_MT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mt_MT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mt *mt_MT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mt_MT' +func (mt *mt_MT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mt_MT' +// in accounting notation. +func (mt *mt_MT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mt.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mt_MT' +func (mt *mt_MT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mt_MT' +func (mt *mt_MT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mt_MT' +func (mt *mt_MT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x74, 0x61}...) + b = append(b, []byte{0xe2, 0x80, 0x99, 0x20}...) + b = append(b, mt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mt_MT' +func (mt *mt_MT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x74, 0x61}...) + b = append(b, []byte{0xe2, 0x80, 0x99, 0x20}...) + b = append(b, mt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mt_MT' +func (mt *mt_MT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mt_MT' +func (mt *mt_MT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mt_MT' +func (mt *mt_MT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mt_MT' +func (mt *mt_MT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mt_MT/mt_MT_test.go b/vendor/github.com/go-playground/locales/mt_MT/mt_MT_test.go new file mode 100644 index 0000000000..3522f265ab --- /dev/null +++ b/vendor/github.com/go-playground/locales/mt_MT/mt_MT_test.go @@ -0,0 +1,1120 @@ +package mt_MT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mt_MT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mua/mua.go b/vendor/github.com/go-playground/locales/mua/mua.go new file mode 100644 index 0000000000..4625351566 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mua/mua.go @@ -0,0 +1,570 @@ +package mua + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mua struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mua' locale +func New() locales.Translator { + return &mua{ + locale: "mua", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "FLO", "CLA", "CKI", "FMF", "MAD", "MBI", "MLI", "MAM", "FDE", "FMU", "FGW", "FYU"}, + monthsNarrow: []string{"", "O", "A", "I", "F", "D", "B", "L", "M", "E", "U", "W", "Y"}, + monthsWide: []string{"", "Fĩi Loo", "Cokcwaklaŋne", "Cokcwaklii", "Fĩi Marfoo", "Madǝǝuutǝbijaŋ", "Mamǝŋgwãafahbii", "Mamǝŋgwãalii", "Madǝmbii", "Fĩi Dǝɓlii", "Fĩi Mundaŋ", "Fĩi Gwahlle", "Fĩi Yuru"}, + daysAbbreviated: []string{"Cya", "Cla", "Czi", "Cko", "Cka", "Cga", "Cze"}, + daysNarrow: []string{"Y", "L", "Z", "O", "A", "G", "E"}, + daysWide: []string{"Com’yakke", "Comlaaɗii", "Comzyiiɗii", "Comkolle", "Comkaldǝɓlii", "Comgaisuu", "Comzyeɓsuu"}, + periodsAbbreviated: []string{"comme", "lilli"}, + periodsWide: []string{"comme", "lilli"}, + erasAbbreviated: []string{"KK", "PK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"KǝPel Kristu", "Pel Kristu"}, + timezones: map[string]string{"HAST": "HAST", "WEZ": "WEZ", "OEZ": "OEZ", "MST": "MST", "CST": "CST", "CHAST": "CHAST", "BOT": "BOT", "PDT": "PDT", "MDT": "MDT", "HKT": "HKT", "ACST": "ACST", "COST": "COST", "GYT": "GYT", "CDT": "CDT", "SAST": "SAST", "HNPM": "HNPM", "HEOG": "HEOG", "HAT": "HAT", "WAT": "WAT", "HEEG": "HEEG", "HEPM": "HEPM", "HECU": "HECU", "TMT": "TMT", "ACWST": "ACWST", "JDT": "JDT", "VET": "VET", "WESZ": "WESZ", "WAST": "WAST", "EDT": "EDT", "HADT": "HADT", "ECT": "ECT", "AKST": "AKST", "UYT": "UYT", "ART": "ART", "ACDT": "ACDT", "COT": "COT", "WITA": "WITA", "HNPMX": "HNPMX", "CLT": "CLT", "ADT": "ADT", "MYT": "MYT", "WARST": "WARST", "AST": "AST", "BT": "BT", "GFT": "GFT", "HEPMX": "HEPMX", "AWST": "AWST", "SGT": "SGT", "LHDT": "LHDT", "ACWDT": "ACWDT", "HNOG": "HNOG", "IST": "IST", "EST": "EST", "HNNOMX": "HNNOMX", "HNT": "HNT", "ChST": "ChST", "SRT": "SRT", "AWDT": "AWDT", "NZDT": "NZDT", "HENOMX": "HENOMX", "OESZ": "OESZ", "HKST": "HKST", "UYST": "UYST", "WIT": "WIT", "JST": "JST", "MESZ": "MESZ", "AEST": "AEST", "PST": "PST", "NZST": "NZST", "CAT": "CAT", "WART": "WART", "EAT": "EAT", "HNCU": "HNCU", "MEZ": "MEZ", "GMT": "GMT", "AEDT": "AEDT", "AKDT": "AKDT", "LHST": "LHST", "WIB": "WIB", "∅∅∅": "∅∅∅", "ARST": "ARST", "TMST": "TMST", "HNEG": "HNEG", "CHADT": "CHADT", "CLST": "CLST"}, + } +} + +// Locale returns the current translators string locale +func (mua *mua) Locale() string { + return mua.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mua' +func (mua *mua) PluralsCardinal() []locales.PluralRule { + return mua.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mua' +func (mua *mua) PluralsOrdinal() []locales.PluralRule { + return mua.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mua' +func (mua *mua) PluralsRange() []locales.PluralRule { + return mua.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mua' +func (mua *mua) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mua' +func (mua *mua) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mua' +func (mua *mua) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mua *mua) MonthAbbreviated(month time.Month) string { + return mua.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mua *mua) MonthsAbbreviated() []string { + return mua.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mua *mua) MonthNarrow(month time.Month) string { + return mua.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mua *mua) MonthsNarrow() []string { + return mua.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mua *mua) MonthWide(month time.Month) string { + return mua.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mua *mua) MonthsWide() []string { + return mua.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mua *mua) WeekdayAbbreviated(weekday time.Weekday) string { + return mua.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mua *mua) WeekdaysAbbreviated() []string { + return mua.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mua *mua) WeekdayNarrow(weekday time.Weekday) string { + return mua.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mua *mua) WeekdaysNarrow() []string { + return mua.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mua *mua) WeekdayShort(weekday time.Weekday) string { + return mua.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mua *mua) WeekdaysShort() []string { + return mua.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mua *mua) WeekdayWide(weekday time.Weekday) string { + return mua.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mua *mua) WeekdaysWide() []string { + return mua.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mua' and handles both Whole and Real numbers based on 'v' +func (mua *mua) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mua.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mua' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mua *mua) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mua.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mua.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mua' +func (mua *mua) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mua.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mua.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mua.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mua' +// in accounting notation. +func (mua *mua) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mua.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mua.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mua.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mua.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mua.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mua' +func (mua *mua) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mua' +func (mua *mua) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mua.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mua' +func (mua *mua) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mua.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mua' +func (mua *mua) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mua.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mua.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mua' +func (mua *mua) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mua' +func (mua *mua) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mua' +func (mua *mua) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mua' +func (mua *mua) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mua.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mua/mua_test.go b/vendor/github.com/go-playground/locales/mua/mua_test.go new file mode 100644 index 0000000000..4ada0e0ff1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mua/mua_test.go @@ -0,0 +1,1120 @@ +package mua + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mua" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mua_CM/mua_CM.go b/vendor/github.com/go-playground/locales/mua_CM/mua_CM.go new file mode 100644 index 0000000000..284b270192 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mua_CM/mua_CM.go @@ -0,0 +1,570 @@ +package mua_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mua_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mua_CM' locale +func New() locales.Translator { + return &mua_CM{ + locale: "mua_CM", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "FLO", "CLA", "CKI", "FMF", "MAD", "MBI", "MLI", "MAM", "FDE", "FMU", "FGW", "FYU"}, + monthsNarrow: []string{"", "O", "A", "I", "F", "D", "B", "L", "M", "E", "U", "W", "Y"}, + monthsWide: []string{"", "Fĩi Loo", "Cokcwaklaŋne", "Cokcwaklii", "Fĩi Marfoo", "Madǝǝuutǝbijaŋ", "Mamǝŋgwãafahbii", "Mamǝŋgwãalii", "Madǝmbii", "Fĩi Dǝɓlii", "Fĩi Mundaŋ", "Fĩi Gwahlle", "Fĩi Yuru"}, + daysAbbreviated: []string{"Cya", "Cla", "Czi", "Cko", "Cka", "Cga", "Cze"}, + daysNarrow: []string{"Y", "L", "Z", "O", "A", "G", "E"}, + daysWide: []string{"Com’yakke", "Comlaaɗii", "Comzyiiɗii", "Comkolle", "Comkaldǝɓlii", "Comgaisuu", "Comzyeɓsuu"}, + periodsAbbreviated: []string{"comme", "lilli"}, + periodsWide: []string{"comme", "lilli"}, + erasAbbreviated: []string{"KK", "PK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"KǝPel Kristu", "Pel Kristu"}, + timezones: map[string]string{"HNCU": "HNCU", "NZST": "NZST", "MESZ": "MESZ", "EST": "EST", "AKST": "AKST", "GMT": "GMT", "WAT": "WAT", "HNT": "HNT", "ACWDT": "ACWDT", "JDT": "JDT", "WEZ": "WEZ", "MST": "MST", "ARST": "ARST", "AEST": "AEST", "GFT": "GFT", "ChST": "ChST", "UYT": "UYT", "HEPM": "HEPM", "VET": "VET", "WESZ": "WESZ", "HNNOMX": "HNNOMX", "HAT": "HAT", "∅∅∅": "∅∅∅", "BOT": "BOT", "ECT": "ECT", "PDT": "PDT", "HAST": "HAST", "MEZ": "MEZ", "WART": "WART", "CST": "CST", "CHAST": "CHAST", "SGT": "SGT", "HNOG": "HNOG", "WAST": "WAST", "SRT": "SRT", "EAT": "EAT", "HECU": "HECU", "CHADT": "CHADT", "PST": "PST", "CLST": "CLST", "AST": "AST", "EDT": "EDT", "WITA": "WITA", "UYST": "UYST", "OEZ": "OEZ", "TMT": "TMT", "HEPMX": "HEPMX", "HADT": "HADT", "NZDT": "NZDT", "HEOG": "HEOG", "MDT": "MDT", "ACWST": "ACWST", "JST": "JST", "WARST": "WARST", "CLT": "CLT", "HKT": "HKT", "WIT": "WIT", "MYT": "MYT", "TMST": "TMST", "BT": "BT", "AEDT": "AEDT", "HNEG": "HNEG", "GYT": "GYT", "CDT": "CDT", "AWST": "AWST", "IST": "IST", "HKST": "HKST", "ACST": "ACST", "ACDT": "ACDT", "AKDT": "AKDT", "HNPM": "HNPM", "AWDT": "AWDT", "CAT": "CAT", "COT": "COT", "LHST": "LHST", "WIB": "WIB", "ADT": "ADT", "OESZ": "OESZ", "COST": "COST", "HENOMX": "HENOMX", "HEEG": "HEEG", "SAST": "SAST", "LHDT": "LHDT", "HNPMX": "HNPMX", "ART": "ART"}, + } +} + +// Locale returns the current translators string locale +func (mua *mua_CM) Locale() string { + return mua.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mua_CM' +func (mua *mua_CM) PluralsCardinal() []locales.PluralRule { + return mua.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mua_CM' +func (mua *mua_CM) PluralsOrdinal() []locales.PluralRule { + return mua.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mua_CM' +func (mua *mua_CM) PluralsRange() []locales.PluralRule { + return mua.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mua_CM' +func (mua *mua_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mua_CM' +func (mua *mua_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mua_CM' +func (mua *mua_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mua *mua_CM) MonthAbbreviated(month time.Month) string { + return mua.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mua *mua_CM) MonthsAbbreviated() []string { + return mua.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mua *mua_CM) MonthNarrow(month time.Month) string { + return mua.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mua *mua_CM) MonthsNarrow() []string { + return mua.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mua *mua_CM) MonthWide(month time.Month) string { + return mua.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mua *mua_CM) MonthsWide() []string { + return mua.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mua *mua_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return mua.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mua *mua_CM) WeekdaysAbbreviated() []string { + return mua.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mua *mua_CM) WeekdayNarrow(weekday time.Weekday) string { + return mua.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mua *mua_CM) WeekdaysNarrow() []string { + return mua.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mua *mua_CM) WeekdayShort(weekday time.Weekday) string { + return mua.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mua *mua_CM) WeekdaysShort() []string { + return mua.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mua *mua_CM) WeekdayWide(weekday time.Weekday) string { + return mua.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mua *mua_CM) WeekdaysWide() []string { + return mua.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mua_CM' and handles both Whole and Real numbers based on 'v' +func (mua *mua_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mua.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mua_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mua *mua_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mua.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, mua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, mua.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mua_CM' +func (mua *mua_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mua.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mua.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, mua.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mua.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mua_CM' +// in accounting notation. +func (mua *mua_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mua.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, mua.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, mua.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, mua.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, mua.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, mua.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'mua_CM' +func (mua *mua_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mua_CM' +func (mua *mua_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mua.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mua_CM' +func (mua *mua_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mua.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mua_CM' +func (mua *mua_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, mua.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, mua.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mua_CM' +func (mua *mua_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mua_CM' +func (mua *mua_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mua_CM' +func (mua *mua_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mua_CM' +func (mua *mua_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, mua.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, mua.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := mua.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mua_CM/mua_CM_test.go b/vendor/github.com/go-playground/locales/mua_CM/mua_CM_test.go new file mode 100644 index 0000000000..60a64fd3c2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mua_CM/mua_CM_test.go @@ -0,0 +1,1120 @@ +package mua_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mua_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/my/my.go b/vendor/github.com/go-playground/locales/my/my.go new file mode 100644 index 0000000000..cb61bb1765 --- /dev/null +++ b/vendor/github.com/go-playground/locales/my/my.go @@ -0,0 +1,593 @@ +package my + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type my struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'my' locale +func New() locales.Translator { + return &my{ + locale: "my", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "NAf", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "Afl", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "G", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "K", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "B/.", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TT$", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ဇန်", "ဖေ", "မတ်", "ဧ", "မေ", "ဇွန်", "ဇူ", "ဩ", "စက်", "အောက်", "နို", "ဒီ"}, + monthsNarrow: []string{"", "ဇ", "ဖ", "မ", "ဧ", "မ", "ဇ", "ဇ", "ဩ", "စ", "အ", "န", "ဒ"}, + monthsWide: []string{"", "ဇန်နဝါရီ", "ဖေဖော်ဝါရီ", "မတ်", "ဧပြီ", "မေ", "ဇွန်", "ဇူလိုင်", "ဩဂုတ်", "စက်တင်ဘာ", "အောက်တိုဘာ", "နိုဝင်ဘာ", "ဒီဇင်ဘာ"}, + daysAbbreviated: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"}, + daysNarrow: []string{"တ", "တ", "အ", "ဗ", "က", "သ", "စ"}, + daysShort: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"}, + daysWide: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"}, + periodsAbbreviated: []string{"နံနက်", "ညနေ"}, + periodsNarrow: []string{"နံနက်", "ညနေ"}, + periodsWide: []string{"နံနက်", "ညနေ"}, + erasAbbreviated: []string{"ဘီစီ", "အေဒီ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ခရစ်တော် မပေါ်မီနှစ်", "ခရစ်နှစ်"}, + timezones: map[string]string{"AEST": "အရှေ့ဩစတြေးလျား စံတော်ချိန်", "AEDT": "အရှေ့ဩစတြေးလျား နွေရာသီ အချိန်", "LHST": "လော့ဒ်ဟောင်စံတော်ချိန်", "EAT": "အရှေ့အာဖရိက အချိန်", "WIB": "အနောက်ပိုင်း အင်ဒိုနီးရှား အချိန်", "CHADT": "ချာသမ် နွေရာသီ အချိန်", "CAT": "အလယ်အာဖရိက အချိန်", "COST": "ကိုလံဘီယာ နွေရာသီ အချိန်", "HNEG": "အရှေ့ဂရင်းလန်း စံတော်ချိန်", "∅∅∅": "ပီရူး နွေရာသီ အချိန်", "AST": "အတ္တလန်တစ် စံတော်ချိန်", "HNT": "နယူးဖောင်လန် စံတော်ချိန်", "WITA": "အလယ်ပိုင်း အင်ဒိုနီးရှား အချိန်", "MDT": "မြောက်အမေရိက တောင်တန်းဒေသ နွေရာသီစံတော်ချိန်", "BOT": "ဘိုလီးဘီးယား အချိန်", "PDT": "မြောက်အမေရိက ပစိဖိတ် နွေရာသီစံတော်ချိန်", "WEZ": "အနောက်ဥရောပ စံတော်ချိန်", "WAT": "အနောက်အာဖရိက စံတော်ချိန်", "HEEG": "အရှေ့ဂရင်းလန် နွေရာသီ စံတော်ချိန်", "MST": "မြောက်အမေရိက တောင်တန်းဒေသစံတော်ချိန်", "HECU": "ကျူးဘား နွေရာသီ စံတော်ချိန်", "GMT": "ဂရင်းနစ် စံတော်ချိန်", "ACST": "ဩစတြေးလျား အလယ်ပိုင်း စံတော်ချိန်", "PST": "မြောက်အမေရိက ပစိဖိတ်စံတော်ချိန်", "ADT": "အတ္တလန်တစ် နွေရာသီ စံတော်ချိန်", "OESZ": "အရှေ့ဥရောပ နွေရာသီ အချိန်", "MYT": "မလေးရှား အချိန်", "ACDT": "ဩစတြေးလျား အလယ်ပိုင်း နွေရာသီ အချိန်", "HNNOMX": "အနောက်တောင် မက္ကဆီကို စံတော်ချိန်", "HAST": "ဟာဝိုင်ယီ အယ်လူးရှန်း စံတော်ချိန်", "IST": "အိန္ဒိယ စံတော်ချိန်", "WAST": "အနောက်အာဖရိက နွေရာသီ အချိန်", "HKST": "ဟောင်ကောင် နွေရာသီ အချိန်", "AKST": "အလားစကားစံတော်ချိန်", "HNPM": "စိန့်ပီအဲနှင့်မီခွီလွန်စံတော်ချိန်", "SAST": "တောင်အာဖရိက အချိန်", "HADT": "ဟာဝိုင်ယီ အယ်လူးရှန်း နွေရာသီ စံတော်ချိန်", "WART": "အနောက် အာဂျင်တီးနား စံတော်ချိန်", "CLST": "ချီလီ နွေရာသီ အချိန်", "UYT": "ဥရုဂွေး စံတော်ချိန်", "HNCU": "ကျူးဘား စံတော်ချိန်", "AWST": "အနောက်ဩစတြေးလျား စံတော်ချိန်", "TMST": "တာ့ခ်မင်နစ္စတန် နွေရာသီ အချိန်", "CHAST": "ချားသမ်စံတော်ချိန်", "ACWST": "ဩစတြေးလျား အလယ်အနောက်ပိုင်း စံတော်ချိန်", "CLT": "ချီလီ စံတော်ချိန်", "MEZ": "ဥရောပ အလယ်ပိုင်း စံတော်ချိန်", "WARST": "အနောက် အာဂျင်တီးနား နွေရာသီ အချိန်", "ART": "အာဂျင်တီးနား စံတော်ချိန်", "HNPMX": "မက္ကဆီကန် ပစိဖိတ် စံတော်ချိန်", "CST": "မြောက်အမေရိက အလယ်ပိုင်းစံတော်ချိန်", "NZDT": "နယူးဇီလန် နွေရာသီ အချိန်", "JDT": "ဂျပန် နွေရာသီ အချိန်", "GFT": "ပြင်သစ် ဂီအားနား အချိန်", "ChST": "ချာမိုရိုအချိန်", "HEPM": "စိန့်ပီအဲနှင့် မီခွီလွန် နွေရာသီ စံတော်ချိန်", "CDT": "မြောက်အမေရိက အလယ်ပိုင်း နွေရာသီစံတော်ချိန်", "AWDT": "ဩစတြေးလျား နွေရာသီ အချိန်", "SGT": "စင်္ကာပူ အချိန်", "MESZ": "ဥရောပ အလယ်ပိုင်း နွေရာသီ အချိန်", "JST": "ဂျပန် စံတော်ချိန်", "COT": "ကိုလံဘီယာ စံတော်ချိန်", "UYST": "ဥရုဂွေး နွေရာသီ အချိန်", "GYT": "ဂိုင်ယာနာ အချိန်", "ARST": "အာဂျင်တီးနား နွေရာသီအချိန်", "EDT": "မြောက်အမေရိက အရှေ့ပိုင်း နွေရာသီစံတော်ချိန်", "HEOG": "အနောက် ဂရင်းလန် နွေရာသီ စံတော်ချိန်", "OEZ": "အရှေ့ဥရောပ စံတော်ချိန်", "WESZ": "အနောက်ဥရောပ နွေရာသီ အချိန်", "VET": "ဗင်နီဇွဲလား အချိန်", "HNOG": "အနောက် ဂရင်းလန်း စံတော်ချိန်", "TMT": "တာ့ခ်မင်နစ္စတန် စံတော်ချိန်", "HENOMX": "အနောက်တောင် မက္ကစီကို နွေရာသီ စံတော်ချိန်", "WIT": "အရှေ့ပိုင်း အင်ဒိုနီးရှား အချိန်", "ECT": "အီကွေဒေါ အချိန်", "NZST": "နယူးဇီလန် စံတော်ချိန်", "HKT": "ဟောင်ကောင် စံတော်ချိန်", "HAT": "နယူးဖောင်လန် နွေရာသီ စံတော်ချိန်", "AKDT": "အလားစကား နွေရာသီစံတော်ချိန်", "ACWDT": "ဩစတြေးလျား အလယ်အနောက်ပိုင်း နွေရာသီ အချိန်", "SRT": "စူးရီနာမ်အချိန်", "EST": "မြောက်အမေရိက အရှေ့ပိုင်းစံတော်ချိန်", "BT": "ဘူတန် အချိန်", "LHDT": "လော့ဒ်ဟောင် နွေရာသီ အချိန်", "HEPMX": "မက္ကစီကန် ပစိဖိတ် နွေရာသီ စံတော်ချိန်"}, + } +} + +// Locale returns the current translators string locale +func (my *my) Locale() string { + return my.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'my' +func (my *my) PluralsCardinal() []locales.PluralRule { + return my.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'my' +func (my *my) PluralsOrdinal() []locales.PluralRule { + return my.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'my' +func (my *my) PluralsRange() []locales.PluralRule { + return my.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'my' +func (my *my) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'my' +func (my *my) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'my' +func (my *my) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (my *my) MonthAbbreviated(month time.Month) string { + return my.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (my *my) MonthsAbbreviated() []string { + return my.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (my *my) MonthNarrow(month time.Month) string { + return my.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (my *my) MonthsNarrow() []string { + return my.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (my *my) MonthWide(month time.Month) string { + return my.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (my *my) MonthsWide() []string { + return my.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (my *my) WeekdayAbbreviated(weekday time.Weekday) string { + return my.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (my *my) WeekdaysAbbreviated() []string { + return my.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (my *my) WeekdayNarrow(weekday time.Weekday) string { + return my.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (my *my) WeekdaysNarrow() []string { + return my.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (my *my) WeekdayShort(weekday time.Weekday) string { + return my.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (my *my) WeekdaysShort() []string { + return my.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (my *my) WeekdayWide(weekday time.Weekday) string { + return my.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (my *my) WeekdaysWide() []string { + return my.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'my' and handles both Whole and Real numbers based on 'v' +func (my *my) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, my.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, my.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, my.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'my' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (my *my) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, my.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, my.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, my.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'my' +func (my *my) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := my.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, my.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, my.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(my.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, my.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, my.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, my.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'my' +// in accounting notation. +func (my *my) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := my.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, my.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, my.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(my.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, my.currencyNegativePrefix[j]) + } + + b = append(b, my.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(my.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, my.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, my.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'my' +func (my *my) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'my' +func (my *my) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, my.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'my' +func (my *my) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, my.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'my' +func (my *my) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, my.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, my.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'my' +func (my *my) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, my.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'my' +func (my *my) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, my.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, my.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'my' +func (my *my) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, my.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, my.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'my' +func (my *my) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := my.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, my.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, my.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/my/my_test.go b/vendor/github.com/go-playground/locales/my/my_test.go new file mode 100644 index 0000000000..84e1796975 --- /dev/null +++ b/vendor/github.com/go-playground/locales/my/my_test.go @@ -0,0 +1,1120 @@ +package my + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "my" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/my_MM/my_MM.go b/vendor/github.com/go-playground/locales/my_MM/my_MM.go new file mode 100644 index 0000000000..fc514e9aba --- /dev/null +++ b/vendor/github.com/go-playground/locales/my_MM/my_MM.go @@ -0,0 +1,593 @@ +package my_MM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type my_MM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'my_MM' locale +func New() locales.Translator { + return &my_MM{ + locale: "my_MM", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ဇန်", "ဖေ", "မတ်", "ဧ", "မေ", "ဇွန်", "ဇူ", "ဩ", "စက်", "အောက်", "နို", "ဒီ"}, + monthsNarrow: []string{"", "ဇ", "ဖ", "မ", "ဧ", "မ", "ဇ", "ဇ", "ဩ", "စ", "အ", "န", "ဒ"}, + monthsWide: []string{"", "ဇန်နဝါရီ", "ဖေဖော်ဝါရီ", "မတ်", "ဧပြီ", "မေ", "ဇွန်", "ဇူလိုင်", "ဩဂုတ်", "စက်တင်ဘာ", "အောက်တိုဘာ", "နိုဝင်ဘာ", "ဒီဇင်ဘာ"}, + daysAbbreviated: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"}, + daysNarrow: []string{"တ", "တ", "အ", "ဗ", "က", "သ", "စ"}, + daysShort: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"}, + daysWide: []string{"တနင်္ဂနွေ", "တနင်္လာ", "အင်္ဂါ", "ဗုဒ္ဓဟူး", "ကြာသပတေး", "သောကြာ", "စနေ"}, + periodsAbbreviated: []string{"နံနက်", "ညနေ"}, + periodsNarrow: []string{"နံနက်", "ညနေ"}, + periodsWide: []string{"နံနက်", "ညနေ"}, + erasAbbreviated: []string{"ဘီစီ", "အေဒီ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ခရစ်တော် မပေါ်မီနှစ်", "ခရစ်နှစ်"}, + timezones: map[string]string{"MDT": "မြောက်အမေရိက တောင်တန်းဒေသ နွေရာသီစံတော်ချိန်", "WIB": "အနောက်ပိုင်း အင်ဒိုနီးရှား အချိန်", "AWST": "အနောက်ဩစတြေးလျား စံတော်ချိန်", "ECT": "အီကွေဒေါ အချိန်", "WESZ": "အနောက်ဥရောပ နွေရာသီ အချိန်", "HNEG": "အရှေ့ဂရင်းလန်း စံတော်ချိန်", "NZST": "နယူးဇီလန် စံတော်ချိန်", "VET": "ဗင်နီဇွဲလား အချိန်", "EDT": "မြောက်အမေရိက အရှေ့ပိုင်း နွေရာသီစံတော်ချိန်", "BT": "ဘူတန် အချိန်", "WITA": "အလယ်ပိုင်း အင်ဒိုနီးရှား အချိန်", "AEST": "အရှေ့ဩစတြေးလျား စံတော်ချိန်", "HEPM": "စိန့်ပီအဲနှင့် မီခွီလွန် နွေရာသီ စံတော်ချိန်", "LHDT": "လော့ဒ်ဟောင် နွေရာသီ အချိန်", "WEZ": "အနောက်ဥရောပ စံတော်ချိန်", "WAST": "အနောက်အာဖရိက နွေရာသီ အချိန်", "ACDT": "ဩစတြေးလျား အလယ်ပိုင်း နွေရာသီ အချိန်", "HENOMX": "အနောက်တောင် မက္ကစီကို နွေရာသီ စံတော်ချိန်", "∅∅∅": "∅∅∅", "ChST": "ချာမိုရိုအချိန်", "UYST": "ဥရုဂွေး နွေရာသီ အချိန်", "OEZ": "အရှေ့ဥရောပ စံတော်ချိန်", "WAT": "အနောက်အာဖရိက စံတော်ချိန်", "LHST": "လော့ဒ်ဟောင်စံတော်ချိန်", "GYT": "ဂိုင်ယာနာ အချိန်", "CDT": "မြောက်အမေရိက အလယ်ပိုင်း နွေရာသီစံတော်ချိန်", "AWDT": "ဩစတြေးလျား နွေရာသီ အချိန်", "SGT": "စင်္ကာပူ အချိန်", "ACWST": "ဩစတြေးလျား အလယ်အနောက်ပိုင်း စံတော်ချိန်", "JST": "ဂျပန် စံတော်ချိန်", "AEDT": "အရှေ့ဩစတြေးလျား နွေရာသီ အချိန်", "GMT": "ဂရင်းနစ် စံတော်ချိန်", "UYT": "ဥရုဂွေး စံတော်ချိန်", "ACWDT": "ဩစတြေးလျား အလယ်အနောက်ပိုင်း နွေရာသီ အချိန်", "WART": "အနောက် အာဂျင်တီးနား စံတော်ချိန်", "CLST": "ချီလီ နွေရာသီ အချိန်", "TMT": "တာ့ခ်မင်နစ္စတန် စံတော်ချိန်", "HKST": "ဟောင်ကောင် နွေရာသီ အချိန်", "COST": "ကိုလံဘီယာ နွေရာသီ အချိန်", "HNNOMX": "အနောက်တောင် မက္ကဆီကို စံတော်ချိန်", "MESZ": "ဥရောပ အလယ်ပိုင်း နွေရာသီ အချိန်", "CLT": "ချီလီ စံတော်ချိန်", "COT": "ကိုလံဘီယာ စံတော်ချိန်", "SRT": "စူးရီနာမ်အချိန်", "HNCU": "ကျူးဘား စံတော်ချိန်", "IST": "အိန္ဒိယ စံတော်ချိန်", "TMST": "တာ့ခ်မင်နစ္စတန် နွေရာသီ အချိန်", "HNPM": "စိန့်ပီအဲနှင့်မီခွီလွန်စံတော်ချိန်", "HEEG": "အရှေ့ဂရင်းလန် နွေရာသီ စံတော်ချိန်", "SAST": "တောင်အာဖရိက အချိန်", "HEPMX": "မက္ကစီကန် ပစိဖိတ် နွေရာသီ စံတော်ချိန်", "CHAST": "ချားသမ်စံတော်ချိန်", "ACST": "ဩစတြေးလျား အလယ်ပိုင်း စံတော်ချိန်", "HNOG": "အနောက် ဂရင်းလန်း စံတော်ချိန်", "MST": "မြောက်အမေရိက တောင်တန်းဒေသစံတော်ချိန်", "GFT": "ပြင်သစ် ဂီအားနား အချိန်", "HECU": "ကျူးဘား နွေရာသီ စံတော်ချိန်", "PST": "မြောက်အမေရိက ပစိဖိတ်စံတော်ချိန်", "HEOG": "အနောက် ဂရင်းလန် နွေရာသီ စံတော်ချိန်", "ADT": "အတ္တလန်တစ် နွေရာသီ စံတော်ချိန်", "WARST": "အနောက် အာဂျင်တီးနား နွေရာသီ အချိန်", "AKDT": "အလားစကား နွေရာသီစံတော်ချိန်", "HNPMX": "မက္ကဆီကန် ပစိဖိတ် စံတော်ချိန်", "CHADT": "ချာသမ် နွေရာသီ အချိန်", "BOT": "ဘိုလီးဘီးယား အချိန်", "PDT": "မြောက်အမေရိက ပစိဖိတ် နွေရာသီစံတော်ချိန်", "HAST": "ဟာဝိုင်ယီ အယ်လူးရှန်း စံတော်ချိန်", "CAT": "အလယ်အာဖရိက အချိန်", "ARST": "အာဂျင်တီးနား နွေရာသီအချိန်", "HNT": "နယူးဖောင်လန် စံတော်ချိန်", "CST": "မြောက်အမေရိက အလယ်ပိုင်းစံတော်ချိန်", "WIT": "အရှေ့ပိုင်း အင်ဒိုနီးရှား အချိန်", "AST": "အတ္တလန်တစ် စံတော်ချိန်", "HKT": "ဟောင်ကောင် စံတော်ချိန်", "MEZ": "ဥရောပ အလယ်ပိုင်း စံတော်ချိန်", "MYT": "မလေးရှား အချိန်", "ART": "အာဂျင်တီးနား စံတော်ချိန်", "HADT": "ဟာဝိုင်ယီ အယ်လူးရှန်း နွေရာသီ စံတော်ချိန်", "HAT": "နယူးဖောင်လန် နွေရာသီ စံတော်ချိန်", "AKST": "အလားစကားစံတော်ချိန်", "OESZ": "အရှေ့ဥရောပ နွေရာသီ အချိန်", "EST": "မြောက်အမေရိက အရှေ့ပိုင်းစံတော်ချိန်", "NZDT": "နယူးဇီလန် နွေရာသီ အချိန်", "JDT": "ဂျပန် နွေရာသီ အချိန်", "EAT": "အရှေ့အာဖရိက အချိန်"}, + } +} + +// Locale returns the current translators string locale +func (my *my_MM) Locale() string { + return my.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'my_MM' +func (my *my_MM) PluralsCardinal() []locales.PluralRule { + return my.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'my_MM' +func (my *my_MM) PluralsOrdinal() []locales.PluralRule { + return my.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'my_MM' +func (my *my_MM) PluralsRange() []locales.PluralRule { + return my.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'my_MM' +func (my *my_MM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'my_MM' +func (my *my_MM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'my_MM' +func (my *my_MM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (my *my_MM) MonthAbbreviated(month time.Month) string { + return my.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (my *my_MM) MonthsAbbreviated() []string { + return my.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (my *my_MM) MonthNarrow(month time.Month) string { + return my.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (my *my_MM) MonthsNarrow() []string { + return my.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (my *my_MM) MonthWide(month time.Month) string { + return my.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (my *my_MM) MonthsWide() []string { + return my.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (my *my_MM) WeekdayAbbreviated(weekday time.Weekday) string { + return my.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (my *my_MM) WeekdaysAbbreviated() []string { + return my.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (my *my_MM) WeekdayNarrow(weekday time.Weekday) string { + return my.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (my *my_MM) WeekdaysNarrow() []string { + return my.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (my *my_MM) WeekdayShort(weekday time.Weekday) string { + return my.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (my *my_MM) WeekdaysShort() []string { + return my.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (my *my_MM) WeekdayWide(weekday time.Weekday) string { + return my.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (my *my_MM) WeekdaysWide() []string { + return my.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'my_MM' and handles both Whole and Real numbers based on 'v' +func (my *my_MM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, my.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, my.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, my.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'my_MM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (my *my_MM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, my.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, my.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, my.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'my_MM' +func (my *my_MM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := my.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, my.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, my.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(my.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, my.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, my.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, my.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'my_MM' +// in accounting notation. +func (my *my_MM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := my.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, my.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, my.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(my.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, my.currencyNegativePrefix[j]) + } + + b = append(b, my.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(my.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, my.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, my.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'my_MM' +func (my *my_MM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'my_MM' +func (my *my_MM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, my.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'my_MM' +func (my *my_MM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, my.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'my_MM' +func (my *my_MM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, my.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, my.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'my_MM' +func (my *my_MM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, my.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'my_MM' +func (my *my_MM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, my.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, my.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'my_MM' +func (my *my_MM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, my.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, my.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'my_MM' +func (my *my_MM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := my.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, my.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, my.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/my_MM/my_MM_test.go b/vendor/github.com/go-playground/locales/my_MM/my_MM_test.go new file mode 100644 index 0000000000..ce77a4b6de --- /dev/null +++ b/vendor/github.com/go-playground/locales/my_MM/my_MM_test.go @@ -0,0 +1,1120 @@ +package my_MM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "my_MM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mzn/mzn.go b/vendor/github.com/go-playground/locales/mzn/mzn.go new file mode 100644 index 0000000000..e8f13aa68f --- /dev/null +++ b/vendor/github.com/go-playground/locales/mzn/mzn.go @@ -0,0 +1,256 @@ +package mzn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mzn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mzn' locale +func New() locales.Translator { + return &mzn{ + locale: "mzn", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ژانویه", "فوریه", "مارس", "آوریل", "مه", "ژوئن", "ژوئیه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"}, + monthsWide: []string{"", "ژانویه", "فوریه", "مارس", "آوریل", "مه", "ژوئن", "ژوئیه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"}, + erasAbbreviated: []string{"پ.م", "م."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"قبل میلاد", "بعد میلاد"}, + timezones: map[string]string{"MEZ": "MEZ", "HNOG": "HNOG", "ADT": "ADT", "EDT": "EDT", "WIB": "WIB", "AWST": "AWST", "ACWST": "ACWST", "NZST": "NZST", "BT": "BT", "ChST": "ChST", "OEZ": "OEZ", "COT": "COT", "UYT": "UYT", "HNCU": "HNCU", "CST": "CST", "SGT": "SGT", "MESZ": "MESZ", "HEOG": "HEOG", "MST": "MST", "VET": "VET", "ARST": "ARST", "HKT": "HKT", "ACST": "ACST", "HNPMX": "HNPMX", "MYT": "MYT", "ACDT": "ACDT", "COST": "COST", "HAT": "HAT", "AKDT": "AKDT", "UYST": "UYST", "PST": "PST", "GMT": "GMT", "HENOMX": "HENOMX", "HEEG": "HEEG", "HNNOMX": "HNNOMX", "AEST": "AEST", "AEDT": "AEDT", "HAST": "HAST", "JDT": "JDT", "MDT": "MDT", "WAT": "WAT", "ACWDT": "ACWDT", "ART": "ART", "HECU": "HECU", "CDT": "CDT", "WIT": "WIT", "ECT": "ECT", "TMST": "TMST", "WITA": "WITA", "SAST": "SAST", "GYT": "GYT", "BOT": "BOT", "HADT": "HADT", "WARST": "WARST", "AWDT": "AWDT", "OESZ": "OESZ", "SRT": "SRT", "CLT": "CLT", "WAST": "WAST", "GFT": "GFT", "HEPMX": "HEPMX", "WESZ": "WESZ", "EST": "EST", "EAT": "EAT", "TMT": "TMT", "HKST": "HKST", "HNT": "HNT", "NZDT": "NZDT", "IST": "IST", "JST": "JST", "WEZ": "WEZ", "HNPM": "HNPM", "HEPM": "HEPM", "LHST": "LHST", "CHAST": "CHAST", "CAT": "CAT", "WART": "WART", "AST": "AST", "HNEG": "HNEG", "AKST": "AKST", "LHDT": "LHDT", "∅∅∅": "∅∅∅", "CHADT": "CHADT", "PDT": "PDT", "CLST": "CLST"}, + } +} + +// Locale returns the current translators string locale +func (mzn *mzn) Locale() string { + return mzn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mzn' +func (mzn *mzn) PluralsCardinal() []locales.PluralRule { + return mzn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mzn' +func (mzn *mzn) PluralsOrdinal() []locales.PluralRule { + return mzn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mzn' +func (mzn *mzn) PluralsRange() []locales.PluralRule { + return mzn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mzn' +func (mzn *mzn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mzn' +func (mzn *mzn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mzn' +func (mzn *mzn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mzn *mzn) MonthAbbreviated(month time.Month) string { + return mzn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mzn *mzn) MonthsAbbreviated() []string { + return mzn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mzn *mzn) MonthNarrow(month time.Month) string { + return mzn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mzn *mzn) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mzn *mzn) MonthWide(month time.Month) string { + return mzn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mzn *mzn) MonthsWide() []string { + return mzn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mzn *mzn) WeekdayAbbreviated(weekday time.Weekday) string { + return mzn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mzn *mzn) WeekdaysAbbreviated() []string { + return mzn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mzn *mzn) WeekdayNarrow(weekday time.Weekday) string { + return mzn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mzn *mzn) WeekdaysNarrow() []string { + return mzn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mzn *mzn) WeekdayShort(weekday time.Weekday) string { + return mzn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mzn *mzn) WeekdaysShort() []string { + return mzn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mzn *mzn) WeekdayWide(weekday time.Weekday) string { + return mzn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mzn *mzn) WeekdaysWide() []string { + return mzn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mzn' and handles both Whole and Real numbers based on 'v' +func (mzn *mzn) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mzn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mzn *mzn) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mzn' +func (mzn *mzn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mzn.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mzn' +// in accounting notation. +func (mzn *mzn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mzn.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtDateShort returns the short date representation of 't' for 'mzn' +func (mzn *mzn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mzn' +func (mzn *mzn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mzn' +func (mzn *mzn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mzn' +func (mzn *mzn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mzn' +func (mzn *mzn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mzn' +func (mzn *mzn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mzn' +func (mzn *mzn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mzn' +func (mzn *mzn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mzn/mzn_test.go b/vendor/github.com/go-playground/locales/mzn/mzn_test.go new file mode 100644 index 0000000000..82ec119e65 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mzn/mzn_test.go @@ -0,0 +1,1120 @@ +package mzn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mzn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/mzn_IR/mzn_IR.go b/vendor/github.com/go-playground/locales/mzn_IR/mzn_IR.go new file mode 100644 index 0000000000..61cf069f21 --- /dev/null +++ b/vendor/github.com/go-playground/locales/mzn_IR/mzn_IR.go @@ -0,0 +1,256 @@ +package mzn_IR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type mzn_IR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'mzn_IR' locale +func New() locales.Translator { + return &mzn_IR{ + locale: "mzn_IR", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ژانویه", "فوریه", "مارس", "آوریل", "مه", "ژوئن", "ژوئیه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"}, + monthsWide: []string{"", "ژانویه", "فوریه", "مارس", "آوریل", "مه", "ژوئن", "ژوئیه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "دسامبر"}, + erasAbbreviated: []string{"پ.م", "م."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"قبل میلاد", "بعد میلاد"}, + timezones: map[string]string{"HECU": "HECU", "NZST": "NZST", "IST": "IST", "EST": "EST", "HNNOMX": "HNNOMX", "HEPM": "HEPM", "WIT": "WIT", "SGT": "SGT", "MYT": "MYT", "HNOG": "HNOG", "ADT": "ADT", "ART": "ART", "HENOMX": "HENOMX", "SRT": "SRT", "BOT": "BOT", "PDT": "PDT", "MEZ": "MEZ", "SAST": "SAST", "AWST": "AWST", "CLST": "CLST", "AEDT": "AEDT", "WITA": "WITA", "HNPM": "HNPM", "HNPMX": "HNPMX", "WAST": "WAST", "BT": "BT", "HNT": "HNT", "EAT": "EAT", "CDT": "CDT", "HADT": "HADT", "HNEG": "HNEG", "LHST": "LHST", "CST": "CST", "∅∅∅": "∅∅∅", "CHAST": "CHAST", "ECT": "ECT", "PST": "PST", "MESZ": "MESZ", "ACDT": "ACDT", "HAT": "HAT", "ChST": "ChST", "HEPMX": "HEPMX", "JDT": "JDT", "WART": "WART", "TMT": "TMT", "MST": "MST", "JST": "JST", "CLT": "CLT", "AST": "AST", "EDT": "EDT", "HEEG": "HEEG", "AWDT": "AWDT", "MDT": "MDT", "HKST": "HKST", "ACST": "ACST", "AKDT": "AKDT", "WIB": "WIB", "CAT": "CAT", "OESZ": "OESZ", "WEZ": "WEZ", "ACWST": "ACWST", "ACWDT": "ACWDT", "GMT": "GMT", "HEOG": "HEOG", "GFT": "GFT", "AKST": "AKST", "UYT": "UYT", "GYT": "GYT", "NZDT": "NZDT", "WARST": "WARST", "TMST": "TMST", "COST": "COST", "LHDT": "LHDT", "HNCU": "HNCU", "CHADT": "CHADT", "VET": "VET", "ARST": "ARST", "COT": "COT", "HAST": "HAST", "OEZ": "OEZ", "AEST": "AEST", "WESZ": "WESZ", "WAT": "WAT", "HKT": "HKT", "UYST": "UYST"}, + } +} + +// Locale returns the current translators string locale +func (mzn *mzn_IR) Locale() string { + return mzn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'mzn_IR' +func (mzn *mzn_IR) PluralsCardinal() []locales.PluralRule { + return mzn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'mzn_IR' +func (mzn *mzn_IR) PluralsOrdinal() []locales.PluralRule { + return mzn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'mzn_IR' +func (mzn *mzn_IR) PluralsRange() []locales.PluralRule { + return mzn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mzn_IR' +func (mzn *mzn_IR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mzn_IR' +func (mzn *mzn_IR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mzn_IR' +func (mzn *mzn_IR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (mzn *mzn_IR) MonthAbbreviated(month time.Month) string { + return mzn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (mzn *mzn_IR) MonthsAbbreviated() []string { + return mzn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (mzn *mzn_IR) MonthNarrow(month time.Month) string { + return mzn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (mzn *mzn_IR) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (mzn *mzn_IR) MonthWide(month time.Month) string { + return mzn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (mzn *mzn_IR) MonthsWide() []string { + return mzn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (mzn *mzn_IR) WeekdayAbbreviated(weekday time.Weekday) string { + return mzn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (mzn *mzn_IR) WeekdaysAbbreviated() []string { + return mzn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (mzn *mzn_IR) WeekdayNarrow(weekday time.Weekday) string { + return mzn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (mzn *mzn_IR) WeekdaysNarrow() []string { + return mzn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (mzn *mzn_IR) WeekdayShort(weekday time.Weekday) string { + return mzn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (mzn *mzn_IR) WeekdaysShort() []string { + return mzn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (mzn *mzn_IR) WeekdayWide(weekday time.Weekday) string { + return mzn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (mzn *mzn_IR) WeekdaysWide() []string { + return mzn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'mzn_IR' and handles both Whole and Real numbers based on 'v' +func (mzn *mzn_IR) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'mzn_IR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (mzn *mzn_IR) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mzn_IR' +func (mzn *mzn_IR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mzn.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mzn_IR' +// in accounting notation. +func (mzn *mzn_IR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := mzn.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtDateShort returns the short date representation of 't' for 'mzn_IR' +func (mzn *mzn_IR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'mzn_IR' +func (mzn *mzn_IR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'mzn_IR' +func (mzn *mzn_IR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'mzn_IR' +func (mzn *mzn_IR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'mzn_IR' +func (mzn *mzn_IR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'mzn_IR' +func (mzn *mzn_IR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'mzn_IR' +func (mzn *mzn_IR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'mzn_IR' +func (mzn *mzn_IR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/mzn_IR/mzn_IR_test.go b/vendor/github.com/go-playground/locales/mzn_IR/mzn_IR_test.go new file mode 100644 index 0000000000..52f264bc8f --- /dev/null +++ b/vendor/github.com/go-playground/locales/mzn_IR/mzn_IR_test.go @@ -0,0 +1,1120 @@ +package mzn_IR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "mzn_IR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/naq/naq.go b/vendor/github.com/go-playground/locales/naq/naq.go new file mode 100644 index 0000000000..4291d62f16 --- /dev/null +++ b/vendor/github.com/go-playground/locales/naq/naq.go @@ -0,0 +1,557 @@ +package naq + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type naq struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'naq' locale +func New() locales.Translator { + return &naq{ + locale: "naq", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "$", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "ǃKhanni", "ǃKhanǀgôab", "ǀKhuuǁkhâb", "ǃHôaǂkhaib", "ǃKhaitsâb", "Gamaǀaeb", "ǂKhoesaob", "Aoǁkhuumûǁkhâb", "Taraǀkhuumûǁkhâb", "ǂNûǁnâiseb", "ǀHooǂgaeb", "Hôasoreǁkhâb"}, + daysAbbreviated: []string{"Son", "Ma", "De", "Wu", "Do", "Fr", "Sat"}, + daysNarrow: []string{"S", "M", "E", "W", "D", "F", "A"}, + daysWide: []string{"Sontaxtsees", "Mantaxtsees", "Denstaxtsees", "Wunstaxtsees", "Dondertaxtsees", "Fraitaxtsees", "Satertaxtsees"}, + periodsAbbreviated: []string{"ǁgoagas", "ǃuias"}, + periodsWide: []string{"ǁgoagas", "ǃuias"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Xristub aiǃâ", "Xristub khaoǃgâ"}, + timezones: map[string]string{"HECU": "HECU", "CDT": "CDT", "AWDT": "AWDT", "ADT": "ADT", "HAT": "HAT", "AST": "AST", "GMT": "GMT", "ART": "ART", "GYT": "GYT", "EAT": "EAT", "AWST": "AWST", "HADT": "HADT", "MESZ": "MESZ", "AKST": "AKST", "HEOG": "HEOG", "HNPM": "HNPM", "CHAST": "CHAST", "CHADT": "CHADT", "CAT": "CAT", "ACWST": "ACWST", "HEPMX": "HEPMX", "CLST": "CLST", "WESZ": "WESZ", "ACST": "ACST", "HNNOMX": "HNNOMX", "ChST": "ChST", "HEPM": "HEPM", "HNOG": "HNOG", "EDT": "EDT", "IST": "IST", "CLT": "CLT", "WAT": "WAT", "BT": "BT", "EST": "EST", "HEEG": "HEEG", "UYT": "UYT", "∅∅∅": "∅∅∅", "SGT": "SGT", "HAST": "HAST", "ARST": "ARST", "JST": "JST", "WAST": "WAST", "ACDT": "ACDT", "SAST": "SAST", "WIT": "WIT", "ACWDT": "ACWDT", "WEZ": "WEZ", "TMT": "TMT", "WARST": "WARST", "HKST": "HKST", "COST": "COST", "WIB": "WIB", "CST": "CST", "MEZ": "MEZ", "VET": "VET", "OEZ": "OEZ", "HNT": "HNT", "AKDT": "AKDT", "HNCU": "HNCU", "MYT": "MYT", "WITA": "WITA", "BOT": "BOT", "PST": "PST", "PDT": "PDT", "OESZ": "OESZ", "TMST": "TMST", "ECT": "ECT", "JDT": "JDT", "WART": "WART", "COT": "COT", "HNEG": "HNEG", "LHDT": "LHDT", "MDT": "MDT", "AEST": "AEST", "AEDT": "AEDT", "SRT": "SRT", "HKT": "HKT", "GFT": "GFT", "MST": "MST", "HENOMX": "HENOMX", "UYST": "UYST", "LHST": "LHST", "HNPMX": "HNPMX", "NZST": "NZST", "NZDT": "NZDT"}, + } +} + +// Locale returns the current translators string locale +func (naq *naq) Locale() string { + return naq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'naq' +func (naq *naq) PluralsCardinal() []locales.PluralRule { + return naq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'naq' +func (naq *naq) PluralsOrdinal() []locales.PluralRule { + return naq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'naq' +func (naq *naq) PluralsRange() []locales.PluralRule { + return naq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'naq' +func (naq *naq) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'naq' +func (naq *naq) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'naq' +func (naq *naq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (naq *naq) MonthAbbreviated(month time.Month) string { + return naq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (naq *naq) MonthsAbbreviated() []string { + return naq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (naq *naq) MonthNarrow(month time.Month) string { + return naq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (naq *naq) MonthsNarrow() []string { + return naq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (naq *naq) MonthWide(month time.Month) string { + return naq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (naq *naq) MonthsWide() []string { + return naq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (naq *naq) WeekdayAbbreviated(weekday time.Weekday) string { + return naq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (naq *naq) WeekdaysAbbreviated() []string { + return naq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (naq *naq) WeekdayNarrow(weekday time.Weekday) string { + return naq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (naq *naq) WeekdaysNarrow() []string { + return naq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (naq *naq) WeekdayShort(weekday time.Weekday) string { + return naq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (naq *naq) WeekdaysShort() []string { + return naq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (naq *naq) WeekdayWide(weekday time.Weekday) string { + return naq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (naq *naq) WeekdaysWide() []string { + return naq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'naq' and handles both Whole and Real numbers based on 'v' +func (naq *naq) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'naq' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (naq *naq) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'naq' +func (naq *naq) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := naq.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, naq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, naq.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, naq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, naq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'naq' +// in accounting notation. +func (naq *naq) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := naq.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, naq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, naq.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, naq.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, naq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'naq' +func (naq *naq) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'naq' +func (naq *naq) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, naq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'naq' +func (naq *naq) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, naq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'naq' +func (naq *naq) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, naq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, naq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'naq' +func (naq *naq) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, naq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, naq.periodsAbbreviated[0]...) + } else { + b = append(b, naq.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'naq' +func (naq *naq) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, naq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, naq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, naq.periodsAbbreviated[0]...) + } else { + b = append(b, naq.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'naq' +func (naq *naq) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, naq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, naq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, naq.periodsAbbreviated[0]...) + } else { + b = append(b, naq.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'naq' +func (naq *naq) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, naq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, naq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, naq.periodsAbbreviated[0]...) + } else { + b = append(b, naq.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := naq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/naq/naq_test.go b/vendor/github.com/go-playground/locales/naq/naq_test.go new file mode 100644 index 0000000000..c533a2fbb5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/naq/naq_test.go @@ -0,0 +1,1120 @@ +package naq + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "naq" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/naq_NA/naq_NA.go b/vendor/github.com/go-playground/locales/naq_NA/naq_NA.go new file mode 100644 index 0000000000..cac5e37d27 --- /dev/null +++ b/vendor/github.com/go-playground/locales/naq_NA/naq_NA.go @@ -0,0 +1,557 @@ +package naq_NA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type naq_NA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'naq_NA' locale +func New() locales.Translator { + return &naq_NA{ + locale: "naq_NA", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "ǃKhanni", "ǃKhanǀgôab", "ǀKhuuǁkhâb", "ǃHôaǂkhaib", "ǃKhaitsâb", "Gamaǀaeb", "ǂKhoesaob", "Aoǁkhuumûǁkhâb", "Taraǀkhuumûǁkhâb", "ǂNûǁnâiseb", "ǀHooǂgaeb", "Hôasoreǁkhâb"}, + daysAbbreviated: []string{"Son", "Ma", "De", "Wu", "Do", "Fr", "Sat"}, + daysNarrow: []string{"S", "M", "E", "W", "D", "F", "A"}, + daysWide: []string{"Sontaxtsees", "Mantaxtsees", "Denstaxtsees", "Wunstaxtsees", "Dondertaxtsees", "Fraitaxtsees", "Satertaxtsees"}, + periodsAbbreviated: []string{"ǁgoagas", "ǃuias"}, + periodsWide: []string{"ǁgoagas", "ǃuias"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Xristub aiǃâ", "Xristub khaoǃgâ"}, + timezones: map[string]string{"SGT": "SGT", "PDT": "PDT", "WARST": "WARST", "HEOG": "HEOG", "UYT": "UYT", "SAST": "SAST", "AWDT": "AWDT", "NZDT": "NZDT", "MESZ": "MESZ", "WEZ": "WEZ", "HNOG": "HNOG", "WART": "WART", "CLST": "CLST", "AEDT": "AEDT", "UYST": "UYST", "EAT": "EAT", "ACWST": "ACWST", "VET": "VET", "OEZ": "OEZ", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "HNPM": "HNPM", "ChST": "ChST", "HEPMX": "HEPMX", "HADT": "HADT", "MYT": "MYT", "HKT": "HKT", "HKST": "HKST", "HECU": "HECU", "LHDT": "LHDT", "WIB": "WIB", "AST": "AST", "EDT": "EDT", "HNEG": "HNEG", "AEST": "AEST", "AKDT": "AKDT", "SRT": "SRT", "HNCU": "HNCU", "CHAST": "CHAST", "WESZ": "WESZ", "HNT": "HNT", "GFT": "GFT", "HEPM": "HEPM", "OESZ": "OESZ", "TMST": "TMST", "MST": "MST", "ACDT": "ACDT", "IST": "IST", "JDT": "JDT", "CDT": "CDT", "AWST": "AWST", "PST": "PST", "ARST": "ARST", "HENOMX": "HENOMX", "CST": "CST", "WAT": "WAT", "HAT": "HAT", "GYT": "GYT", "WIT": "WIT", "MDT": "MDT", "ACST": "ACST", "LHST": "LHST", "HAST": "HAST", "ECT": "ECT", "JST": "JST", "CLT": "CLT", "BOT": "BOT", "CAT": "CAT", "GMT": "GMT", "ADT": "ADT", "ACWDT": "ACWDT", "MEZ": "MEZ", "COT": "COT", "HNPMX": "HNPMX", "COST": "COST", "BT": "BT", "CHADT": "CHADT", "ART": "ART", "EST": "EST", "WAST": "WAST", "AKST": "AKST", "NZST": "NZST", "∅∅∅": "∅∅∅", "TMT": "TMT", "WITA": "WITA"}, + } +} + +// Locale returns the current translators string locale +func (naq *naq_NA) Locale() string { + return naq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'naq_NA' +func (naq *naq_NA) PluralsCardinal() []locales.PluralRule { + return naq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'naq_NA' +func (naq *naq_NA) PluralsOrdinal() []locales.PluralRule { + return naq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'naq_NA' +func (naq *naq_NA) PluralsRange() []locales.PluralRule { + return naq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'naq_NA' +func (naq *naq_NA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'naq_NA' +func (naq *naq_NA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'naq_NA' +func (naq *naq_NA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (naq *naq_NA) MonthAbbreviated(month time.Month) string { + return naq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (naq *naq_NA) MonthsAbbreviated() []string { + return naq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (naq *naq_NA) MonthNarrow(month time.Month) string { + return naq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (naq *naq_NA) MonthsNarrow() []string { + return naq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (naq *naq_NA) MonthWide(month time.Month) string { + return naq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (naq *naq_NA) MonthsWide() []string { + return naq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (naq *naq_NA) WeekdayAbbreviated(weekday time.Weekday) string { + return naq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (naq *naq_NA) WeekdaysAbbreviated() []string { + return naq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (naq *naq_NA) WeekdayNarrow(weekday time.Weekday) string { + return naq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (naq *naq_NA) WeekdaysNarrow() []string { + return naq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (naq *naq_NA) WeekdayShort(weekday time.Weekday) string { + return naq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (naq *naq_NA) WeekdaysShort() []string { + return naq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (naq *naq_NA) WeekdayWide(weekday time.Weekday) string { + return naq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (naq *naq_NA) WeekdaysWide() []string { + return naq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'naq_NA' and handles both Whole and Real numbers based on 'v' +func (naq *naq_NA) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'naq_NA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (naq *naq_NA) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'naq_NA' +func (naq *naq_NA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := naq.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, naq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, naq.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, naq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, naq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'naq_NA' +// in accounting notation. +func (naq *naq_NA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := naq.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, naq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, naq.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, naq.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, naq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'naq_NA' +func (naq *naq_NA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'naq_NA' +func (naq *naq_NA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, naq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'naq_NA' +func (naq *naq_NA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, naq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'naq_NA' +func (naq *naq_NA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, naq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, naq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'naq_NA' +func (naq *naq_NA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, naq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, naq.periodsAbbreviated[0]...) + } else { + b = append(b, naq.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'naq_NA' +func (naq *naq_NA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, naq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, naq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, naq.periodsAbbreviated[0]...) + } else { + b = append(b, naq.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'naq_NA' +func (naq *naq_NA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, naq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, naq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, naq.periodsAbbreviated[0]...) + } else { + b = append(b, naq.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'naq_NA' +func (naq *naq_NA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, naq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, naq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, naq.periodsAbbreviated[0]...) + } else { + b = append(b, naq.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := naq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/naq_NA/naq_NA_test.go b/vendor/github.com/go-playground/locales/naq_NA/naq_NA_test.go new file mode 100644 index 0000000000..75e637523e --- /dev/null +++ b/vendor/github.com/go-playground/locales/naq_NA/naq_NA_test.go @@ -0,0 +1,1120 @@ +package naq_NA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "naq_NA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nb/nb.go b/vendor/github.com/go-playground/locales/nb/nb.go new file mode 100644 index 0000000000..2429d52bf8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nb/nb.go @@ -0,0 +1,619 @@ +package nb + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nb struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nb' locale +func New() locales.Translator { + return &nb{ + locale: "nb", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "kr", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"}, + daysAbbreviated: []string{"søn.", "man.", "tir.", "ons.", "tor.", "fre.", "lør."}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sø.", "ma.", "ti.", "on.", "to.", "fr.", "lø."}, + daysWide: []string{"søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"før Kristus", "etter Kristus"}, + timezones: map[string]string{"AEST": "østaustralsk normaltid", "AWDT": "vestaustralsk sommertid", "ACWST": "vest-sentralaustralsk normaltid", "MESZ": "sentraleuropeisk sommertid", "MYT": "malaysisk tid", "HNOG": "vestgrønlandsk normaltid", "AKST": "alaskisk normaltid", "AKDT": "alaskisk sommertid", "CDT": "sommertid for det sentrale Nord-Amerika", "HADT": "sommertid for Hawaii og Aleutene", "WART": "vestargentinsk normaltid", "WAT": "vestafrikansk normaltid", "SAST": "sørafrikansk tid", "SGT": "singaporsk tid", "HAST": "normaltid for Hawaii og Aleutene", "ADT": "atlanterhavskystlig sommertid", "WIT": "østindonesisk tid", "ACDT": "sentralaustralsk sommertid", "COST": "colombiansk sommertid", "HENOMX": "sommertid for nordvestlige Mexico", "HNT": "normaltid for Newfoundland", "HAT": "sommertid for Newfoundland", "ChST": "tidssone for Chamorro", "LHST": "normaltid for Lord Howe-øya", "PST": "normaltid for den nordamerikanske Stillehavskysten", "HEOG": "vestgrønlandsk sommertid", "BT": "bhutansk tid", "AEDT": "østaustralsk sommertid", "ECT": "ecuadoriansk tid", "GMT": "Greenwich middeltid", "HNNOMX": "normaltid for nordvestlige Mexico", "AST": "atlanterhavskystlig standardtid", "TMST": "turkmensk sommertid", "COT": "colombiansk normaltid", "VET": "venezuelansk tid", "CLT": "chilensk normaltid", "WESZ": "vesteuropeisk sommertid", "UYT": "uruguayansk normaltid", "LHDT": "sommertid for Lord Howe-øya", "GYT": "guyansk tid", "EAT": "østafrikansk tid", "OESZ": "østeuropeisk sommertid", "EDT": "sommertid for den nordamerikanske østkysten", "HNCU": "cubansk normaltid", "NZDT": "newzealandsk sommertid", "CAT": "sentralafrikansk tid", "IST": "indisk tid", "CLST": "chilensk sommertid", "WAST": "vestafrikansk sommertid", "HNEG": "østgrønlandsk normaltid", "HEEG": "østgrønlandsk sommertid", "CST": "normaltid for det sentrale Nord-Amerika", "OEZ": "østeuropeisk normaltid", "WARST": "vestargentinsk sommertid", "ACST": "sentralaustralsk normaltid", "AWST": "vestaustralsk normaltid", "CHAST": "normaltid for Chatham", "CHADT": "sommertid for Chatham", "BOT": "boliviansk tid", "PDT": "sommertid for den nordamerikanske Stillehavskysten", "JST": "japansk normaltid", "∅∅∅": "Acre sommertid", "MDT": "sommertid for Rocky Mountains (USA)", "GFT": "tidssone for Fransk Guyana", "UYST": "uruguayansk sommertid", "HEPM": "sommertid for Saint-Pierre-et-Miquelon", "NZST": "newzealandsk normaltid", "HEPMX": "sommertid for den meksikanske Stillehavskysten", "MEZ": "sentraleuropeisk normaltid", "JDT": "japansk sommertid", "ARST": "argentinsk sommertid", "MST": "normaltid for Rocky Mountains (USA)", "WITA": "sentralindonesisk tid", "HNPM": "normaltid for Saint-Pierre-et-Miquelon", "HECU": "cubansk sommertid", "ACWDT": "vest-sentralaustralsk sommertid", "ART": "argentinsk normaltid", "HKST": "sommertid for Hongkong", "SRT": "surinamsk tid", "HNPMX": "normaltid for den meksikanske Stillehavskysten", "WIB": "vestindonesisk tid", "WEZ": "vesteuropeisk normaltid", "TMT": "turkmensk normaltid", "EST": "normaltid for den nordamerikanske østkysten", "HKT": "normaltid for Hongkong"}, + } +} + +// Locale returns the current translators string locale +func (nb *nb) Locale() string { + return nb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nb' +func (nb *nb) PluralsCardinal() []locales.PluralRule { + return nb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nb' +func (nb *nb) PluralsOrdinal() []locales.PluralRule { + return nb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nb' +func (nb *nb) PluralsRange() []locales.PluralRule { + return nb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nb' +func (nb *nb) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nb' +func (nb *nb) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nb' +func (nb *nb) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nb *nb) MonthAbbreviated(month time.Month) string { + return nb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nb *nb) MonthsAbbreviated() []string { + return nb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nb *nb) MonthNarrow(month time.Month) string { + return nb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nb *nb) MonthsNarrow() []string { + return nb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nb *nb) MonthWide(month time.Month) string { + return nb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nb *nb) MonthsWide() []string { + return nb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nb *nb) WeekdayAbbreviated(weekday time.Weekday) string { + return nb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nb *nb) WeekdaysAbbreviated() []string { + return nb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nb *nb) WeekdayNarrow(weekday time.Weekday) string { + return nb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nb *nb) WeekdaysNarrow() []string { + return nb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nb *nb) WeekdayShort(weekday time.Weekday) string { + return nb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nb *nb) WeekdaysShort() []string { + return nb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nb *nb) WeekdayWide(weekday time.Weekday) string { + return nb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nb *nb) WeekdaysWide() []string { + return nb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nb' and handles both Whole and Real numbers based on 'v' +func (nb *nb) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nb' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nb *nb) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nb.percentSuffix...) + + b = append(b, nb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nb' +func (nb *nb) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nb.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nb' +// in accounting notation. +func (nb *nb) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nb.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyNegativePrefix[j]) + } + + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nb' +func (nb *nb) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nb' +func (nb *nb) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nb' +func (nb *nb) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nb' +func (nb *nb) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nb' +func (nb *nb) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nb' +func (nb *nb) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nb' +func (nb *nb) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nb' +func (nb *nb) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nb/nb_test.go b/vendor/github.com/go-playground/locales/nb/nb_test.go new file mode 100644 index 0000000000..24fb15ba3d --- /dev/null +++ b/vendor/github.com/go-playground/locales/nb/nb_test.go @@ -0,0 +1,1120 @@ +package nb + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nb" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nb_NO/nb_NO.go b/vendor/github.com/go-playground/locales/nb_NO/nb_NO.go new file mode 100644 index 0000000000..6b0cf3211a --- /dev/null +++ b/vendor/github.com/go-playground/locales/nb_NO/nb_NO.go @@ -0,0 +1,619 @@ +package nb_NO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nb_NO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nb_NO' locale +func New() locales.Translator { + return &nb_NO{ + locale: "nb_NO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"}, + daysAbbreviated: []string{"søn.", "man.", "tir.", "ons.", "tor.", "fre.", "lør."}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sø.", "ma.", "ti.", "on.", "to.", "fr.", "lø."}, + daysWide: []string{"søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"før Kristus", "etter Kristus"}, + timezones: map[string]string{"ADT": "atlanterhavskystlig sommertid", "EDT": "sommertid for den nordamerikanske østkysten", "HKST": "sommertid for Hongkong", "HEEG": "østgrønlandsk sommertid", "JST": "japansk normaltid", "HNCU": "cubansk normaltid", "JDT": "japansk sommertid", "CLST": "chilensk sommertid", "WESZ": "vesteuropeisk sommertid", "HKT": "normaltid for Hongkong", "UYST": "uruguayansk sommertid", "EAT": "østafrikansk tid", "HAST": "normaltid for Hawaii og Aleutene", "ACWDT": "vest-sentralaustralsk sommertid", "HEOG": "vestgrønlandsk sommertid", "MYT": "malaysisk tid", "ACST": "sentralaustralsk normaltid", "GFT": "tidssone for Fransk Guyana", "LHDT": "sommertid for Lord Howe-øya", "ARST": "argentinsk sommertid", "WAT": "vestafrikansk normaltid", "HECU": "cubansk sommertid", "WIB": "vestindonesisk tid", "BOT": "boliviansk tid", "WART": "vestargentinsk normaltid", "WEZ": "vesteuropeisk normaltid", "AKST": "alaskisk normaltid", "HNPMX": "normaltid for den meksikanske Stillehavskysten", "CAT": "sentralafrikansk tid", "HNOG": "vestgrønlandsk normaltid", "MDT": "Macau, sommertid", "COST": "colombiansk sommertid", "HNT": "normaltid for Newfoundland", "HADT": "sommertid for Hawaii og Aleutene", "TMT": "turkmensk normaltid", "CST": "normaltid for det sentrale Nord-Amerika", "CHADT": "sommertid for Chatham", "NZDT": "newzealandsk sommertid", "AEDT": "østaustralsk sommertid", "WIT": "østindonesisk tid", "IST": "indisk tid", "MESZ": "sentraleuropeisk sommertid", "AST": "atlanterhavskystlig standardtid", "MST": "Macau, standardtid", "WAST": "vestafrikansk sommertid", "HEPM": "sommertid for Saint-Pierre-et-Miquelon", "LHST": "normaltid for Lord Howe-øya", "MEZ": "sentraleuropeisk normaltid", "CLT": "chilensk normaltid", "COT": "colombiansk normaltid", "HAT": "sommertid for Newfoundland", "∅∅∅": "peruansk sommertid", "NZST": "newzealandsk normaltid", "OESZ": "østeuropeisk sommertid", "HNPM": "normaltid for Saint-Pierre-et-Miquelon", "SGT": "singaporsk tid", "HENOMX": "sommertid for nordvestlige Mexico", "HNEG": "østgrønlandsk normaltid", "SRT": "surinamsk tid", "SAST": "sørafrikansk tid", "HEPMX": "sommertid for den meksikanske Stillehavskysten", "GYT": "guyansk tid", "ART": "argentinsk normaltid", "ACDT": "sentralaustralsk sommertid", "HNNOMX": "normaltid for nordvestlige Mexico", "BT": "bhutansk tid", "AEST": "østaustralsk normaltid", "AWDT": "vestaustralsk sommertid", "CHAST": "normaltid for Chatham", "ECT": "ecuadoriansk tid", "ACWST": "vest-sentralaustralsk normaltid", "ChST": "tidssone for Chamorro", "UYT": "uruguayansk normaltid", "CDT": "sommertid for det sentrale Nord-Amerika", "WARST": "vestargentinsk sommertid", "OEZ": "østeuropeisk normaltid", "GMT": "Greenwich middeltid", "EST": "normaltid for den nordamerikanske østkysten", "WITA": "sentralindonesisk tid", "AWST": "vestaustralsk normaltid", "PDT": "sommertid for den nordamerikanske Stillehavskysten", "VET": "venezuelansk tid", "TMST": "turkmensk sommertid", "AKDT": "alaskisk sommertid", "PST": "normaltid for den nordamerikanske Stillehavskysten"}, + } +} + +// Locale returns the current translators string locale +func (nb *nb_NO) Locale() string { + return nb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nb_NO' +func (nb *nb_NO) PluralsCardinal() []locales.PluralRule { + return nb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nb_NO' +func (nb *nb_NO) PluralsOrdinal() []locales.PluralRule { + return nb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nb_NO' +func (nb *nb_NO) PluralsRange() []locales.PluralRule { + return nb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nb_NO' +func (nb *nb_NO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nb_NO' +func (nb *nb_NO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nb_NO' +func (nb *nb_NO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nb *nb_NO) MonthAbbreviated(month time.Month) string { + return nb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nb *nb_NO) MonthsAbbreviated() []string { + return nb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nb *nb_NO) MonthNarrow(month time.Month) string { + return nb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nb *nb_NO) MonthsNarrow() []string { + return nb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nb *nb_NO) MonthWide(month time.Month) string { + return nb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nb *nb_NO) MonthsWide() []string { + return nb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nb *nb_NO) WeekdayAbbreviated(weekday time.Weekday) string { + return nb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nb *nb_NO) WeekdaysAbbreviated() []string { + return nb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nb *nb_NO) WeekdayNarrow(weekday time.Weekday) string { + return nb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nb *nb_NO) WeekdaysNarrow() []string { + return nb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nb *nb_NO) WeekdayShort(weekday time.Weekday) string { + return nb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nb *nb_NO) WeekdaysShort() []string { + return nb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nb *nb_NO) WeekdayWide(weekday time.Weekday) string { + return nb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nb *nb_NO) WeekdaysWide() []string { + return nb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nb_NO' and handles both Whole and Real numbers based on 'v' +func (nb *nb_NO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nb_NO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nb *nb_NO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nb.percentSuffix...) + + b = append(b, nb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nb_NO' +func (nb *nb_NO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nb.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nb_NO' +// in accounting notation. +func (nb *nb_NO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nb.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyNegativePrefix[j]) + } + + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nb_NO' +func (nb *nb_NO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nb_NO' +func (nb *nb_NO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nb_NO' +func (nb *nb_NO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nb_NO' +func (nb *nb_NO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nb_NO' +func (nb *nb_NO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nb_NO' +func (nb *nb_NO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nb_NO' +func (nb *nb_NO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nb_NO' +func (nb *nb_NO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nb_NO/nb_NO_test.go b/vendor/github.com/go-playground/locales/nb_NO/nb_NO_test.go new file mode 100644 index 0000000000..e122ee1996 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nb_NO/nb_NO_test.go @@ -0,0 +1,1120 @@ +package nb_NO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nb_NO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nb_SJ/nb_SJ.go b/vendor/github.com/go-playground/locales/nb_SJ/nb_SJ.go new file mode 100644 index 0000000000..87f2f4e0dc --- /dev/null +++ b/vendor/github.com/go-playground/locales/nb_SJ/nb_SJ.go @@ -0,0 +1,619 @@ +package nb_SJ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nb_SJ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nb_SJ' locale +func New() locales.Translator { + return &nb_SJ{ + locale: "nb_SJ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"}, + daysAbbreviated: []string{"søn.", "man.", "tir.", "ons.", "tor.", "fre.", "lør."}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sø.", "ma.", "ti.", "on.", "to.", "fr.", "lø."}, + daysWide: []string{"søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"før Kristus", "etter Kristus"}, + timezones: map[string]string{"HKST": "sommertid for Hongkong", "GFT": "tidssone for Fransk Guyana", "CST": "normaltid for det sentrale Nord-Amerika", "SGT": "singaporsk tid", "ACDT": "sentralaustralsk sommertid", "HNCU": "cubansk normaltid", "WIT": "østindonesisk tid", "PST": "normaltid for den nordamerikanske Stillehavskysten", "NZST": "newzealandsk normaltid", "∅∅∅": "sommertid for Amazonas", "VET": "venezuelansk tid", "HNNOMX": "normaltid for nordvestlige Mexico", "WARST": "vestargentinsk sommertid", "GYT": "guyansk tid", "WIB": "vestindonesisk tid", "ACWST": "vest-sentralaustralsk normaltid", "OESZ": "østeuropeisk sommertid", "HNT": "normaltid for Newfoundland", "COST": "colombiansk sommertid", "AEDT": "østaustralsk sommertid", "ChST": "tidssone for Chamorro", "LHDT": "sommertid for Lord Howe-øya", "CAT": "sentralafrikansk tid", "MESZ": "sentraleuropeisk sommertid", "HNOG": "vestgrønlandsk normaltid", "HEOG": "vestgrønlandsk sommertid", "HECU": "cubansk sommertid", "CHAST": "normaltid for Chatham", "ECT": "ecuadoriansk tid", "PDT": "sommertid for den nordamerikanske Stillehavskysten", "MDT": "Macau, sommertid", "UYST": "uruguayansk sommertid", "CDT": "sommertid for det sentrale Nord-Amerika", "AWDT": "vestaustralsk sommertid", "HNPMX": "normaltid for den meksikanske Stillehavskysten", "MEZ": "sentraleuropeisk normaltid", "WART": "vestargentinsk normaltid", "HAT": "sommertid for Newfoundland", "HNPM": "normaltid for Saint-Pierre-et-Miquelon", "BOT": "boliviansk tid", "WAT": "vestafrikansk normaltid", "COT": "colombiansk normaltid", "LHST": "normaltid for Lord Howe-øya", "AWST": "vestaustralsk normaltid", "MST": "Macau, standardtid", "WAST": "vestafrikansk sommertid", "HEEG": "østgrønlandsk sommertid", "WITA": "sentralindonesisk tid", "AKDT": "alaskisk sommertid", "SRT": "surinamsk tid", "CHADT": "sommertid for Chatham", "ACWDT": "vest-sentralaustralsk sommertid", "CLT": "chilensk normaltid", "CLST": "chilensk sommertid", "HNEG": "østgrønlandsk normaltid", "HAST": "normaltid for Hawaii og Aleutene", "GMT": "Greenwich middeltid", "EST": "normaltid for den nordamerikanske østkysten", "ACST": "sentralaustralsk normaltid", "BT": "bhutansk tid", "HEPM": "sommertid for Saint-Pierre-et-Miquelon", "SAST": "sørafrikansk tid", "ADT": "atlanterhavskystlig sommertid", "TMST": "turkmensk sommertid", "HENOMX": "sommertid for nordvestlige Mexico", "AKST": "alaskisk normaltid", "OEZ": "østeuropeisk normaltid", "TMT": "turkmensk normaltid", "ARST": "argentinsk sommertid", "UYT": "uruguayansk normaltid", "IST": "indisk tid", "WESZ": "vesteuropeisk sommertid", "MYT": "malaysisk tid", "AST": "atlanterhavskystlig standardtid", "EAT": "østafrikansk tid", "JST": "japansk normaltid", "ART": "argentinsk normaltid", "HEPMX": "sommertid for den meksikanske Stillehavskysten", "HADT": "sommertid for Hawaii og Aleutene", "WEZ": "vesteuropeisk normaltid", "EDT": "sommertid for den nordamerikanske østkysten", "NZDT": "newzealandsk sommertid", "JDT": "japansk sommertid", "HKT": "normaltid for Hongkong", "AEST": "østaustralsk normaltid"}, + } +} + +// Locale returns the current translators string locale +func (nb *nb_SJ) Locale() string { + return nb.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nb_SJ' +func (nb *nb_SJ) PluralsCardinal() []locales.PluralRule { + return nb.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nb_SJ' +func (nb *nb_SJ) PluralsOrdinal() []locales.PluralRule { + return nb.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nb_SJ' +func (nb *nb_SJ) PluralsRange() []locales.PluralRule { + return nb.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nb_SJ' +func (nb *nb_SJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nb_SJ' +func (nb *nb_SJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nb_SJ' +func (nb *nb_SJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nb *nb_SJ) MonthAbbreviated(month time.Month) string { + return nb.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nb *nb_SJ) MonthsAbbreviated() []string { + return nb.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nb *nb_SJ) MonthNarrow(month time.Month) string { + return nb.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nb *nb_SJ) MonthsNarrow() []string { + return nb.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nb *nb_SJ) MonthWide(month time.Month) string { + return nb.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nb *nb_SJ) MonthsWide() []string { + return nb.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nb *nb_SJ) WeekdayAbbreviated(weekday time.Weekday) string { + return nb.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nb *nb_SJ) WeekdaysAbbreviated() []string { + return nb.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nb *nb_SJ) WeekdayNarrow(weekday time.Weekday) string { + return nb.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nb *nb_SJ) WeekdaysNarrow() []string { + return nb.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nb *nb_SJ) WeekdayShort(weekday time.Weekday) string { + return nb.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nb *nb_SJ) WeekdaysShort() []string { + return nb.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nb *nb_SJ) WeekdayWide(weekday time.Weekday) string { + return nb.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nb *nb_SJ) WeekdaysWide() []string { + return nb.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nb_SJ' and handles both Whole and Real numbers based on 'v' +func (nb *nb_SJ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nb_SJ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nb *nb_SJ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nb.percentSuffix...) + + b = append(b, nb.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nb_SJ' +func (nb *nb_SJ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nb.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nb_SJ' +// in accounting notation. +func (nb *nb_SJ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nb.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nb.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nb.group) - 1; j >= 0; j-- { + b = append(b, nb.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyNegativePrefix[j]) + } + + for j := len(nb.minus) - 1; j >= 0; j-- { + b = append(b, nb.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nb.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nb.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nb.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nb_SJ' +func (nb *nb_SJ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nb_SJ' +func (nb *nb_SJ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nb_SJ' +func (nb *nb_SJ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nb_SJ' +func (nb *nb_SJ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nb.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nb.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nb_SJ' +func (nb *nb_SJ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nb_SJ' +func (nb *nb_SJ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nb_SJ' +func (nb *nb_SJ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nb_SJ' +func (nb *nb_SJ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nb.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nb.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nb.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nb_SJ/nb_SJ_test.go b/vendor/github.com/go-playground/locales/nb_SJ/nb_SJ_test.go new file mode 100644 index 0000000000..ed39f21dde --- /dev/null +++ b/vendor/github.com/go-playground/locales/nb_SJ/nb_SJ_test.go @@ -0,0 +1,1120 @@ +package nb_SJ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nb_SJ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nd/nd.go b/vendor/github.com/go-playground/locales/nd/nd.go new file mode 100644 index 0000000000..dbeb75f504 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nd/nd.go @@ -0,0 +1,523 @@ +package nd + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nd struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nd' locale +func New() locales.Translator { + return &nd{ + locale: "nd", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Zib", "Nhlo", "Mbi", "Mab", "Nkw", "Nhla", "Ntu", "Ncw", "Mpan", "Mfu", "Lwe", "Mpal"}, + monthsNarrow: []string{"", "Z", "N", "M", "M", "N", "N", "N", "N", "M", "M", "L", "M"}, + monthsWide: []string{"", "Zibandlela", "Nhlolanja", "Mbimbitho", "Mabasa", "Nkwenkwezi", "Nhlangula", "Ntulikazi", "Ncwabakazi", "Mpandula", "Mfumfu", "Lwezi", "Mpalakazi"}, + daysAbbreviated: []string{"Son", "Mvu", "Sib", "Sit", "Sin", "Sih", "Mgq"}, + daysNarrow: []string{"S", "M", "S", "S", "S", "S", "M"}, + daysWide: []string{"Sonto", "Mvulo", "Sibili", "Sithathu", "Sine", "Sihlanu", "Mgqibelo"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"UKristo angakabuyi", "Ukristo ebuyile"}, + timezones: map[string]string{"HNPM": "HNPM", "HAST": "HAST", "CAT": "CAT", "SGT": "SGT", "ACWST": "ACWST", "ACWDT": "ACWDT", "WARST": "WARST", "TMT": "TMT", "ACST": "ACST", "BOT": "BOT", "JST": "JST", "WART": "WART", "MST": "MST", "COT": "COT", "∅∅∅": "∅∅∅", "HNCU": "HNCU", "WIT": "WIT", "EST": "EST", "EDT": "EDT", "AKDT": "AKDT", "HNPMX": "HNPMX", "GYT": "GYT", "IST": "IST", "NZDT": "NZDT", "MESZ": "MESZ", "AEST": "AEST", "GFT": "GFT", "WIB": "WIB", "AWST": "AWST", "CHADT": "CHADT", "NZST": "NZST", "ARST": "ARST", "AWDT": "AWDT", "PST": "PST", "UYT": "UYT", "UYST": "UYST", "SAST": "SAST", "ECT": "ECT", "HKT": "HKT", "HEPMX": "HEPMX", "HADT": "HADT", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "AEDT": "AEDT", "WITA": "WITA", "AKST": "AKST", "LHDT": "LHDT", "HECU": "HECU", "CDT": "CDT", "WAST": "WAST", "HENOMX": "HENOMX", "MYT": "MYT", "WAT": "WAT", "HAT": "HAT", "HEPM": "HEPM", "VET": "VET", "WESZ": "WESZ", "TMST": "TMST", "COST": "COST", "ADT": "ADT", "HKST": "HKST", "CST": "CST", "PDT": "PDT", "MEZ": "MEZ", "GMT": "GMT", "CLT": "CLT", "JDT": "JDT", "OESZ": "OESZ", "WEZ": "WEZ", "CLST": "CLST", "HNEG": "HNEG", "ACDT": "ACDT", "HNT": "HNT", "ChST": "ChST", "LHST": "LHST", "CHAST": "CHAST", "HNOG": "HNOG", "HEOG": "HEOG", "MDT": "MDT", "BT": "BT", "SRT": "SRT", "EAT": "EAT", "OEZ": "OEZ", "AST": "AST", "ART": "ART"}, + } +} + +// Locale returns the current translators string locale +func (nd *nd) Locale() string { + return nd.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nd' +func (nd *nd) PluralsCardinal() []locales.PluralRule { + return nd.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nd' +func (nd *nd) PluralsOrdinal() []locales.PluralRule { + return nd.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nd' +func (nd *nd) PluralsRange() []locales.PluralRule { + return nd.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nd' +func (nd *nd) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nd' +func (nd *nd) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nd' +func (nd *nd) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nd *nd) MonthAbbreviated(month time.Month) string { + return nd.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nd *nd) MonthsAbbreviated() []string { + return nd.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nd *nd) MonthNarrow(month time.Month) string { + return nd.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nd *nd) MonthsNarrow() []string { + return nd.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nd *nd) MonthWide(month time.Month) string { + return nd.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nd *nd) MonthsWide() []string { + return nd.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nd *nd) WeekdayAbbreviated(weekday time.Weekday) string { + return nd.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nd *nd) WeekdaysAbbreviated() []string { + return nd.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nd *nd) WeekdayNarrow(weekday time.Weekday) string { + return nd.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nd *nd) WeekdaysNarrow() []string { + return nd.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nd *nd) WeekdayShort(weekday time.Weekday) string { + return nd.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nd *nd) WeekdaysShort() []string { + return nd.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nd *nd) WeekdayWide(weekday time.Weekday) string { + return nd.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nd *nd) WeekdaysWide() []string { + return nd.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nd' and handles both Whole and Real numbers based on 'v' +func (nd *nd) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nd' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nd *nd) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nd' +func (nd *nd) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nd.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, nd.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nd.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nd' +// in accounting notation. +func (nd *nd) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nd.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, nd.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nd.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nd.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nd' +func (nd *nd) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nd' +func (nd *nd) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nd.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nd' +func (nd *nd) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nd.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nd' +func (nd *nd) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nd.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nd.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nd' +func (nd *nd) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nd' +func (nd *nd) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nd' +func (nd *nd) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nd' +func (nd *nd) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nd.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nd/nd_test.go b/vendor/github.com/go-playground/locales/nd/nd_test.go new file mode 100644 index 0000000000..cf23cb3f08 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nd/nd_test.go @@ -0,0 +1,1120 @@ +package nd + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nd" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nd_ZW/nd_ZW.go b/vendor/github.com/go-playground/locales/nd_ZW/nd_ZW.go new file mode 100644 index 0000000000..6e0a03974b --- /dev/null +++ b/vendor/github.com/go-playground/locales/nd_ZW/nd_ZW.go @@ -0,0 +1,523 @@ +package nd_ZW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nd_ZW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nd_ZW' locale +func New() locales.Translator { + return &nd_ZW{ + locale: "nd_ZW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Zib", "Nhlo", "Mbi", "Mab", "Nkw", "Nhla", "Ntu", "Ncw", "Mpan", "Mfu", "Lwe", "Mpal"}, + monthsNarrow: []string{"", "Z", "N", "M", "M", "N", "N", "N", "N", "M", "M", "L", "M"}, + monthsWide: []string{"", "Zibandlela", "Nhlolanja", "Mbimbitho", "Mabasa", "Nkwenkwezi", "Nhlangula", "Ntulikazi", "Ncwabakazi", "Mpandula", "Mfumfu", "Lwezi", "Mpalakazi"}, + daysAbbreviated: []string{"Son", "Mvu", "Sib", "Sit", "Sin", "Sih", "Mgq"}, + daysNarrow: []string{"S", "M", "S", "S", "S", "S", "M"}, + daysWide: []string{"Sonto", "Mvulo", "Sibili", "Sithathu", "Sine", "Sihlanu", "Mgqibelo"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"UKristo angakabuyi", "Ukristo ebuyile"}, + timezones: map[string]string{"TMST": "TMST", "ARST": "ARST", "ACST": "ACST", "COT": "COT", "HEEG": "HEEG", "GYT": "GYT", "AST": "AST", "WESZ": "WESZ", "WAT": "WAT", "BT": "BT", "HAST": "HAST", "WARST": "WARST", "TMT": "TMT", "HNNOMX": "HNNOMX", "HNCU": "HNCU", "ACWST": "ACWST", "ACWDT": "ACWDT", "ART": "ART", "ChST": "ChST", "PDT": "PDT", "HNOG": "HNOG", "GMT": "GMT", "CDT": "CDT", "CHADT": "CHADT", "LHST": "LHST", "CST": "CST", "AWDT": "AWDT", "WITA": "WITA", "AWST": "AWST", "SRT": "SRT", "EAT": "EAT", "WIB": "WIB", "SGT": "SGT", "PST": "PST", "NZDT": "NZDT", "ACDT": "ACDT", "LHDT": "LHDT", "WART": "WART", "AKDT": "AKDT", "AKST": "AKST", "BOT": "BOT", "ADT": "ADT", "EST": "EST", "HKT": "HKT", "COST": "COST", "GFT": "GFT", "NZST": "NZST", "JDT": "JDT", "UYT": "UYT", "SAST": "SAST", "∅∅∅": "∅∅∅", "AEST": "AEST", "MST": "MST", "MDT": "MDT", "WAST": "WAST", "AEDT": "AEDT", "UYST": "UYST", "HNPM": "HNPM", "HEOG": "HEOG", "WEZ": "WEZ", "CLT": "CLT", "CLST": "CLST", "HAT": "HAT", "VET": "VET", "JST": "JST", "EDT": "EDT", "HNT": "HNT", "HECU": "HECU", "WIT": "WIT", "HADT": "HADT", "MESZ": "MESZ", "OEZ": "OEZ", "OESZ": "OESZ", "HENOMX": "HENOMX", "HEPM": "HEPM", "HEPMX": "HEPMX", "ECT": "ECT", "CAT": "CAT", "MEZ": "MEZ", "HKST": "HKST", "HNEG": "HNEG", "HNPMX": "HNPMX", "CHAST": "CHAST", "IST": "IST", "MYT": "MYT"}, + } +} + +// Locale returns the current translators string locale +func (nd *nd_ZW) Locale() string { + return nd.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nd_ZW' +func (nd *nd_ZW) PluralsCardinal() []locales.PluralRule { + return nd.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nd_ZW' +func (nd *nd_ZW) PluralsOrdinal() []locales.PluralRule { + return nd.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nd_ZW' +func (nd *nd_ZW) PluralsRange() []locales.PluralRule { + return nd.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nd_ZW' +func (nd *nd_ZW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nd_ZW' +func (nd *nd_ZW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nd_ZW' +func (nd *nd_ZW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nd *nd_ZW) MonthAbbreviated(month time.Month) string { + return nd.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nd *nd_ZW) MonthsAbbreviated() []string { + return nd.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nd *nd_ZW) MonthNarrow(month time.Month) string { + return nd.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nd *nd_ZW) MonthsNarrow() []string { + return nd.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nd *nd_ZW) MonthWide(month time.Month) string { + return nd.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nd *nd_ZW) MonthsWide() []string { + return nd.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nd *nd_ZW) WeekdayAbbreviated(weekday time.Weekday) string { + return nd.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nd *nd_ZW) WeekdaysAbbreviated() []string { + return nd.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nd *nd_ZW) WeekdayNarrow(weekday time.Weekday) string { + return nd.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nd *nd_ZW) WeekdaysNarrow() []string { + return nd.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nd *nd_ZW) WeekdayShort(weekday time.Weekday) string { + return nd.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nd *nd_ZW) WeekdaysShort() []string { + return nd.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nd *nd_ZW) WeekdayWide(weekday time.Weekday) string { + return nd.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nd *nd_ZW) WeekdaysWide() []string { + return nd.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nd_ZW' and handles both Whole and Real numbers based on 'v' +func (nd *nd_ZW) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nd_ZW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nd *nd_ZW) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nd_ZW' +func (nd *nd_ZW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nd.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, nd.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nd.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nd_ZW' +// in accounting notation. +func (nd *nd_ZW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nd.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nd.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nd.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, nd.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nd.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nd.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nd_ZW' +func (nd *nd_ZW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nd_ZW' +func (nd *nd_ZW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nd.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nd_ZW' +func (nd *nd_ZW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nd.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nd_ZW' +func (nd *nd_ZW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nd.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nd.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nd_ZW' +func (nd *nd_ZW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nd_ZW' +func (nd *nd_ZW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nd_ZW' +func (nd *nd_ZW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nd_ZW' +func (nd *nd_ZW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nd.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nd.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nd.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nd_ZW/nd_ZW_test.go b/vendor/github.com/go-playground/locales/nd_ZW/nd_ZW_test.go new file mode 100644 index 0000000000..489606415c --- /dev/null +++ b/vendor/github.com/go-playground/locales/nd_ZW/nd_ZW_test.go @@ -0,0 +1,1120 @@ +package nd_ZW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nd_ZW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nds/nds.go b/vendor/github.com/go-playground/locales/nds/nds.go new file mode 100644 index 0000000000..0a83bbca1e --- /dev/null +++ b/vendor/github.com/go-playground/locales/nds/nds.go @@ -0,0 +1,576 @@ +package nds + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nds struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nds' locale +func New() locales.Translator { + return &nds{ + locale: "nds", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januaar", "Februaar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktover", "November", "Dezember"}, + daysAbbreviated: []string{"Sü.", "Ma.", "Di.", "Mi.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysWide: []string{"Sünndag", "Maandag", "Dingsdag", "Middeweken", "Dunnersdag", "Freedag", "Sünnavend"}, + periodsAbbreviated: []string{"vm", "nm"}, + periodsWide: []string{"vm", "nm"}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"vC", "nC"}, + erasWide: []string{"vör Christus", "na Christus"}, + timezones: map[string]string{"∅∅∅": "∅∅∅", "LHDT": "LHDT", "SGT": "SGT", "BOT": "BOT", "WESZ": "Westeuropääsch Summertiet", "ART": "ART", "WIB": "Westindoneesch Tiet", "TMT": "TMT", "ACDT": "Zentraalaustraalsch Summertiet", "WIT": "Oostindoneesch Tiet", "PDT": "Noordamerikaansch Pazifik-Summertiet", "IST": "Indien-Tiet", "COT": "COT", "SAST": "Söödafrikaansch Tiet", "CHAST": "CHAST", "JDT": "Japaansch Summertiet", "HEOG": "HEOG", "GMT": "Gröönwisch-Welttiet", "EDT": "Noordamerikaansch oosten Summertiet", "ACST": "Zentraalaustraalsch Standardtiet", "HEEG": "HEEG", "AWST": "Westaustraalsch Standardtiet", "ACWDT": "Westzentraalaustraalsch Summertiet", "NZST": "NZST", "WAT": "Westafrikaansch Standardtiet", "HEPMX": "HEPMX", "AWDT": "Westaustraalsch Summertiet", "HNOG": "HNOG", "WEZ": "Westeuropääsch Standardtiet", "HAT": "HAT", "AKST": "AKST", "HNPMX": "HNPMX", "HECU": "HECU", "MESZ": "Zentraaleuropääsch Summertiet", "WAST": "Westafrikaansch Summertiet", "BT": "BT", "EAT": "Oostafrikaansch Tiet", "HNPM": "HNPM", "CDT": "Noordamerikaansch zentraal Summertiet", "WART": "WART", "CHADT": "CHADT", "AST": "Noordamerikaansch Atlantik-Standardtiet", "OEZ": "Oosteuropääsch Standardtiet", "ARST": "ARST", "HENOMX": "HENOMX", "GFT": "GFT", "CST": "Noordamerikaansch zentraal Standardtiet", "PST": "Noordamerikaansch Pazifik-Standardtiet", "CLST": "CLST", "EST": "Noordamerikaansch oosten Standardtiet", "COST": "COST", "TMST": "TMST", "UYST": "UYST", "LHST": "LHST", "GYT": "GYT", "HAST": "HAST", "CAT": "Zentraalafrikaansch Tiet", "NZDT": "NZDT", "ADT": "Noordamerikaansch Atlantik-Summertiet", "MDT": "MDT", "WITA": "Indoneesch Zentraaltiet", "HADT": "HADT", "WARST": "WARST", "HNT": "HNT", "HNEG": "HNEG", "AEST": "Oostaustraalsch Standardtiet", "ECT": "ECT", "MYT": "MYT", "HKST": "HKST", "AKDT": "AKDT", "UYT": "UYT", "HEPM": "HEPM", "SRT": "SRT", "HNCU": "HNCU", "CLT": "CLT", "MST": "MST", "HNNOMX": "HNNOMX", "ChST": "ChST", "ACWST": "Westzentraalaustraalsch Standardtiet", "MEZ": "Zentraaleuropääsch Standardtiet", "VET": "VET", "JST": "Japaansch Standardtiet", "OESZ": "Oosteuropääsch Summertiet", "HKT": "HKT", "AEDT": "Oostaustraalsch Summertiet"}, + } +} + +// Locale returns the current translators string locale +func (nds *nds) Locale() string { + return nds.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nds' +func (nds *nds) PluralsCardinal() []locales.PluralRule { + return nds.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nds' +func (nds *nds) PluralsOrdinal() []locales.PluralRule { + return nds.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nds' +func (nds *nds) PluralsRange() []locales.PluralRule { + return nds.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nds' +func (nds *nds) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nds' +func (nds *nds) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nds' +func (nds *nds) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nds *nds) MonthAbbreviated(month time.Month) string { + return nds.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nds *nds) MonthsAbbreviated() []string { + return nds.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nds *nds) MonthNarrow(month time.Month) string { + return nds.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nds *nds) MonthsNarrow() []string { + return nds.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nds *nds) MonthWide(month time.Month) string { + return nds.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nds *nds) MonthsWide() []string { + return nds.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nds *nds) WeekdayAbbreviated(weekday time.Weekday) string { + return nds.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nds *nds) WeekdaysAbbreviated() []string { + return nds.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nds *nds) WeekdayNarrow(weekday time.Weekday) string { + return nds.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nds *nds) WeekdaysNarrow() []string { + return nds.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nds *nds) WeekdayShort(weekday time.Weekday) string { + return nds.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nds *nds) WeekdaysShort() []string { + return nds.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nds *nds) WeekdayWide(weekday time.Weekday) string { + return nds.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nds *nds) WeekdaysWide() []string { + return nds.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nds' and handles both Whole and Real numbers based on 'v' +func (nds *nds) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nds' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nds *nds) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nds.percentSuffix...) + + b = append(b, nds.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nds' +func (nds *nds) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nds.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nds.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nds.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nds' +// in accounting notation. +func (nds *nds) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nds.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nds.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nds.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nds.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nds.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nds' +func (nds *nds) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nds' +func (nds *nds) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nds' +func (nds *nds) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nds' +func (nds *nds) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nds.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nds' +func (nds *nds) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nds' +func (nds *nds) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nds' +func (nds *nds) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nds' +func (nds *nds) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := nds.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nds/nds_test.go b/vendor/github.com/go-playground/locales/nds/nds_test.go new file mode 100644 index 0000000000..a4e2afac20 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nds/nds_test.go @@ -0,0 +1,1120 @@ +package nds + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nds" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nds_DE/nds_DE.go b/vendor/github.com/go-playground/locales/nds_DE/nds_DE.go new file mode 100644 index 0000000000..90a852cd4f --- /dev/null +++ b/vendor/github.com/go-playground/locales/nds_DE/nds_DE.go @@ -0,0 +1,576 @@ +package nds_DE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nds_DE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nds_DE' locale +func New() locales.Translator { + return &nds_DE{ + locale: "nds_DE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januaar", "Februaar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktover", "November", "Dezember"}, + daysAbbreviated: []string{"Sü.", "Ma.", "Di.", "Mi.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysWide: []string{"Sünndag", "Maandag", "Dingsdag", "Middeweken", "Dunnersdag", "Freedag", "Sünnavend"}, + periodsAbbreviated: []string{"vm", "nm"}, + periodsWide: []string{"vm", "nm"}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"vC", "nC"}, + erasWide: []string{"vör Christus", "na Christus"}, + timezones: map[string]string{"HEEG": "HEEG", "ACWDT": "Westzentraalaustraalsch Summertiet", "ARST": "ARST", "AEDT": "Oostaustraalsch Summertiet", "HNPMX": "HNPMX", "EAT": "Oostafrikaansch Tiet", "HNCU": "HNCU", "OESZ": "Oosteuropääsch Summertiet", "MEZ": "Zentraaleuropääsch Standardtiet", "CHADT": "CHADT", "AST": "Noordamerikaansch Atlantik-Standardtiet", "OEZ": "Oosteuropääsch Standardtiet", "WAST": "Westafrikaansch Summertiet", "EDT": "Noordamerikaansch oosten Summertiet", "HKT": "HKT", "WITA": "Indoneesch Zentraaltiet", "HECU": "HECU", "WIB": "Westindoneesch Tiet", "CDT": "Noordamerikaansch zentraal Summertiet", "WESZ": "Westeuropääsch Summertiet", "WAT": "Westafrikaansch Standardtiet", "ChST": "ChST", "HEPM": "HEPM", "CST": "Noordamerikaansch zentraal Standardtiet", "VET": "VET", "SRT": "SRT", "HADT": "HADT", "IST": "Indien-Tiet", "TMST": "TMST", "GYT": "GYT", "AWDT": "Westaustraalsch Summertiet", "SGT": "SGT", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "UYT": "UYT", "UYST": "UYST", "LHST": "LHST", "CAT": "Zentraalafrikaansch Tiet", "CLT": "CLT", "HNOG": "HNOG", "MYT": "MYT", "TMT": "TMT", "HKST": "HKST", "HAT": "HAT", "HNPM": "HNPM", "CLST": "CLST", "WARST": "WARST", "MST": "Noordamerikaansch Barg-Standardtiet", "JST": "Japaansch Standardtiet", "JDT": "Japaansch Summertiet", "ADT": "Noordamerikaansch Atlantik-Summertiet", "LHDT": "LHDT", "PDT": "Noordamerikaansch Pazifik-Summertiet", "WEZ": "Westeuropääsch Standardtiet", "EST": "Noordamerikaansch oosten Standardtiet", "ACDT": "Zentraalaustraalsch Summertiet", "AKST": "AKST", "AEST": "Oostaustraalsch Standardtiet", "MDT": "Noordamerikaansch Barg-Summertiet", "AKDT": "AKDT", "AWST": "Westaustraalsch Standardtiet", "HAST": "HAST", "ART": "ART", "HNEG": "HNEG", "ECT": "ECT", "ACWST": "Westzentraalaustraalsch Standardtiet", "WIT": "Oostindoneesch Tiet", "MESZ": "Zentraaleuropääsch Summertiet", "WART": "WART", "COT": "COT", "COST": "COST", "BT": "BT", "SAST": "Söödafrikaansch Tiet", "HEPMX": "HEPMX", "HEOG": "HEOG", "ACST": "Zentraalaustraalsch Standardtiet", "BOT": "BOT", "PST": "Noordamerikaansch Pazifik-Standardtiet", "NZST": "NZST", "NZDT": "NZDT", "HNNOMX": "HNNOMX", "HNT": "HNT", "GFT": "GFT", "CHAST": "CHAST", "GMT": "Gröönwisch-Welttiet"}, + } +} + +// Locale returns the current translators string locale +func (nds *nds_DE) Locale() string { + return nds.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nds_DE' +func (nds *nds_DE) PluralsCardinal() []locales.PluralRule { + return nds.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nds_DE' +func (nds *nds_DE) PluralsOrdinal() []locales.PluralRule { + return nds.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nds_DE' +func (nds *nds_DE) PluralsRange() []locales.PluralRule { + return nds.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nds_DE' +func (nds *nds_DE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nds_DE' +func (nds *nds_DE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nds_DE' +func (nds *nds_DE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nds *nds_DE) MonthAbbreviated(month time.Month) string { + return nds.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nds *nds_DE) MonthsAbbreviated() []string { + return nds.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nds *nds_DE) MonthNarrow(month time.Month) string { + return nds.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nds *nds_DE) MonthsNarrow() []string { + return nds.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nds *nds_DE) MonthWide(month time.Month) string { + return nds.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nds *nds_DE) MonthsWide() []string { + return nds.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nds *nds_DE) WeekdayAbbreviated(weekday time.Weekday) string { + return nds.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nds *nds_DE) WeekdaysAbbreviated() []string { + return nds.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nds *nds_DE) WeekdayNarrow(weekday time.Weekday) string { + return nds.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nds *nds_DE) WeekdaysNarrow() []string { + return nds.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nds *nds_DE) WeekdayShort(weekday time.Weekday) string { + return nds.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nds *nds_DE) WeekdaysShort() []string { + return nds.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nds *nds_DE) WeekdayWide(weekday time.Weekday) string { + return nds.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nds *nds_DE) WeekdaysWide() []string { + return nds.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nds_DE' and handles both Whole and Real numbers based on 'v' +func (nds *nds_DE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nds_DE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nds *nds_DE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nds.percentSuffix...) + + b = append(b, nds.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nds_DE' +func (nds *nds_DE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nds.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nds.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nds.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nds_DE' +// in accounting notation. +func (nds *nds_DE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nds.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nds.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nds.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nds.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nds.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nds_DE' +func (nds *nds_DE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nds_DE' +func (nds *nds_DE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nds_DE' +func (nds *nds_DE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nds_DE' +func (nds *nds_DE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nds.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nds_DE' +func (nds *nds_DE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nds_DE' +func (nds *nds_DE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nds_DE' +func (nds *nds_DE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nds_DE' +func (nds *nds_DE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := nds.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nds_DE/nds_DE_test.go b/vendor/github.com/go-playground/locales/nds_DE/nds_DE_test.go new file mode 100644 index 0000000000..39061716d8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nds_DE/nds_DE_test.go @@ -0,0 +1,1120 @@ +package nds_DE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nds_DE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nds_NL/nds_NL.go b/vendor/github.com/go-playground/locales/nds_NL/nds_NL.go new file mode 100644 index 0000000000..38a0fa69d7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nds_NL/nds_NL.go @@ -0,0 +1,576 @@ +package nds_NL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nds_NL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nds_NL' locale +func New() locales.Translator { + return &nds_NL{ + locale: "nds_NL", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan.", "Feb.", "März", "Apr.", "Mai", "Juni", "Juli", "Aug.", "Sep.", "Okt.", "Nov.", "Dez."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januaar", "Februaar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktover", "November", "Dezember"}, + daysAbbreviated: []string{"Sü.", "Ma.", "Di.", "Mi.", "Du.", "Fr.", "Sa."}, + daysNarrow: []string{"S", "M", "D", "M", "D", "F", "S"}, + daysWide: []string{"Sünndag", "Maandag", "Dingsdag", "Middeweken", "Dunnersdag", "Freedag", "Sünnavend"}, + periodsAbbreviated: []string{"vm", "nm"}, + periodsWide: []string{"vm", "nm"}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"vC", "nC"}, + erasWide: []string{"vör Christus", "na Christus"}, + timezones: map[string]string{"HECU": "HECU", "CHADT": "CHADT", "HAST": "HAST", "ACWDT": "Westzentraalaustraalsch Summertiet", "AEDT": "Oostaustraalsch Summertiet", "GMT": "Gröönwisch-Welttiet", "TMT": "TMT", "ARST": "ARST", "HNNOMX": "HNNOMX", "LHST": "LHST", "GYT": "GYT", "HNEG": "HNEG", "AKDT": "AKDT", "ChST": "ChST", "UYST": "UYST", "NZDT": "NZDT", "WESZ": "Westeuropääsch Summertiet", "WAST": "Westafrikaansch Summertiet", "HEPM": "HEPM", "LHDT": "LHDT", "CST": "Noordamerikaansch zentraal Standardtiet", "ACWST": "Westzentraalaustraalsch Standardtiet", "WART": "WART", "WARST": "WARST", "HENOMX": "HENOMX", "UYT": "UYT", "JST": "Japaansch Standardtiet", "WEZ": "Westeuropääsch Standardtiet", "HNT": "HNT", "ACST": "Zentraalaustraalsch Standardtiet", "MDT": "Noordamerikaansch Barg-Summertiet", "PDT": "Noordamerikaansch Pazifik-Summertiet", "IST": "Indien-Tiet", "VET": "VET", "AST": "Noordamerikaansch Atlantik-Standardtiet", "OEZ": "Oosteuropääsch Standardtiet", "WAT": "Westafrikaansch Standardtiet", "WIT": "Oostindoneesch Tiet", "NZST": "NZST", "ADT": "Noordamerikaansch Atlantik-Summertiet", "HKT": "HKT", "WITA": "Indoneesch Zentraaltiet", "SRT": "SRT", "CDT": "Noordamerikaansch zentraal Summertiet", "AWST": "Westaustraalsch Standardtiet", "HEPMX": "HEPMX", "HADT": "HADT", "EST": "Noordamerikaansch oosten Standardtiet", "HKST": "HKST", "∅∅∅": "∅∅∅", "HEOG": "HEOG", "ART": "ART", "JDT": "Japaansch Summertiet", "GFT": "GFT", "HNPM": "HNPM", "HNPMX": "HNPMX", "WIB": "Westindoneesch Tiet", "SGT": "SGT", "PST": "Noordamerikaansch Pazifik-Standardtiet", "ECT": "ECT", "ACDT": "Zentraalaustraalsch Summertiet", "COST": "COST", "AKST": "AKST", "HNOG": "HNOG", "COT": "COT", "HNCU": "HNCU", "AWDT": "Westaustraalsch Summertiet", "CAT": "Zentraalafrikaansch Tiet", "MESZ": "Zentraaleuropääsch Summertiet", "CLT": "CLT", "EDT": "Noordamerikaansch oosten Summertiet", "CHAST": "CHAST", "BOT": "BOT", "OESZ": "Oosteuropääsch Summertiet", "CLST": "CLST", "HAT": "HAT", "BT": "BT", "AEST": "Oostaustraalsch Standardtiet", "MST": "Noordamerikaansch Barg-Standardtiet", "SAST": "Söödafrikaansch Tiet", "EAT": "Oostafrikaansch Tiet", "MEZ": "Zentraaleuropääsch Standardtiet", "MYT": "MYT", "TMST": "TMST", "HEEG": "HEEG"}, + } +} + +// Locale returns the current translators string locale +func (nds *nds_NL) Locale() string { + return nds.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nds_NL' +func (nds *nds_NL) PluralsCardinal() []locales.PluralRule { + return nds.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nds_NL' +func (nds *nds_NL) PluralsOrdinal() []locales.PluralRule { + return nds.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nds_NL' +func (nds *nds_NL) PluralsRange() []locales.PluralRule { + return nds.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nds_NL' +func (nds *nds_NL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nds_NL' +func (nds *nds_NL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nds_NL' +func (nds *nds_NL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nds *nds_NL) MonthAbbreviated(month time.Month) string { + return nds.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nds *nds_NL) MonthsAbbreviated() []string { + return nds.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nds *nds_NL) MonthNarrow(month time.Month) string { + return nds.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nds *nds_NL) MonthsNarrow() []string { + return nds.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nds *nds_NL) MonthWide(month time.Month) string { + return nds.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nds *nds_NL) MonthsWide() []string { + return nds.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nds *nds_NL) WeekdayAbbreviated(weekday time.Weekday) string { + return nds.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nds *nds_NL) WeekdaysAbbreviated() []string { + return nds.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nds *nds_NL) WeekdayNarrow(weekday time.Weekday) string { + return nds.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nds *nds_NL) WeekdaysNarrow() []string { + return nds.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nds *nds_NL) WeekdayShort(weekday time.Weekday) string { + return nds.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nds *nds_NL) WeekdaysShort() []string { + return nds.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nds *nds_NL) WeekdayWide(weekday time.Weekday) string { + return nds.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nds *nds_NL) WeekdaysWide() []string { + return nds.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nds_NL' and handles both Whole and Real numbers based on 'v' +func (nds *nds_NL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nds_NL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nds *nds_NL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nds.percentSuffix...) + + b = append(b, nds.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nds_NL' +func (nds *nds_NL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nds.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nds.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nds.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nds.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nds_NL' +// in accounting notation. +func (nds *nds_NL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nds.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nds.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nds.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nds.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nds.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nds.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nds.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nds_NL' +func (nds *nds_NL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nds_NL' +func (nds *nds_NL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nds_NL' +func (nds *nds_NL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nds_NL' +func (nds *nds_NL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nds.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nds.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nds_NL' +func (nds *nds_NL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nds_NL' +func (nds *nds_NL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nds_NL' +func (nds *nds_NL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nds_NL' +func (nds *nds_NL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x4b, 0x6c, 0x6f, 0x63, 0x6b}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nds.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := nds.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nds_NL/nds_NL_test.go b/vendor/github.com/go-playground/locales/nds_NL/nds_NL_test.go new file mode 100644 index 0000000000..5bb346dcf4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nds_NL/nds_NL_test.go @@ -0,0 +1,1120 @@ +package nds_NL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nds_NL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ne/ne.go b/vendor/github.com/go-playground/locales/ne/ne.go new file mode 100644 index 0000000000..bb3c9d6fa2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ne/ne.go @@ -0,0 +1,620 @@ +package ne + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ne struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ne' locale +func New() locales.Translator { + return &ne{ + locale: "ne", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "नेरू", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मे", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"}, + monthsNarrow: []string{"", "१", "२", "३", "४", "५", "६", "७", "८", "९", "१०", "११", "१२"}, + monthsWide: []string{"", "जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मई", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"}, + daysAbbreviated: []string{"आइत", "सोम", "मङ्गल", "बुध", "बिहि", "शुक्र", "शनि"}, + daysNarrow: []string{"आ", "सो", "म", "बु", "बि", "शु", "श"}, + daysShort: []string{"आइत", "सोम", "मङ्गल", "बुध", "बिहि", "शुक्र", "शनि"}, + daysWide: []string{"आइतबार", "सोमबार", "मङ्गलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार"}, + periodsAbbreviated: []string{"पूर्वाह्न", "अपराह्न"}, + periodsNarrow: []string{"पूर्वाह्न", "अपराह्न"}, + periodsWide: []string{"पूर्वाह्न", "अपराह्न"}, + erasAbbreviated: []string{"ईसा पूर्व", "सन्"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ईसा पूर्व", "सन्"}, + timezones: map[string]string{"COST": "कोलम्बियाली ग्रीष्मकालीन समय", "BT": "भुटानी समय", "CST": "केन्द्रीय मानक समय", "HNOG": "पश्चिमी ग्रीनल्यान्डको मानक समय", "ADT": "एट्लान्टिक दिवा समय", "AWST": "पश्चिमी अस्ट्रेलिया मानक समय", "CHAST": "चाथाम मानक समय", "CLT": "चिली मानक समय", "HKST": "हङकङ ग्रीष्मकालीन समय", "COT": "कोलम्बियाली मानक समय", "HNT": "न्यूफाउनडल्यान्डको मानक समय", "UYT": "उरूग्वे मानक समय", "WIB": "पश्चिमी इन्डोनेशिया समय", "TMST": "तुर्कमेनिस्तान ग्रीष्मकालीन मानक समय", "ACWDT": "केन्द्रीय पश्चिमी अस्ट्रेलिया दिवा समय", "VET": "भेनेज्युएला समय", "TMT": "तुर्कमेनिस्तान मानक समय", "GFT": "फ्रेन्च ग्वाना समय", "AKST": "अलस्काको मानक समय", "HNPM": "सेन्ट पियर्रे र मिक्युलोनको मानक समय", "GYT": "गुयाना समय", "HECU": "क्यूबाको दिवा समय", "CHADT": "चाथाम दिवा समय", "PDT": "प्यासिफिक दिवा समय", "LHST": "लर्ड हावे मानक समय", "HEPMX": "मेक्सिकन प्यासिफिक दिवा समय", "SRT": "सुरिनामा समय", "HNCU": "क्यूबाको मानक समय", "CDT": "केन्द्रीय दिवा समय", "HEOG": "पश्चिमी ग्रीनल्यान्डको ग्रीष्मकालीन समय", "MYT": "मलेसिया समय", "EDT": "पूर्वी दिवा समय", "HKT": "हङकङ मानक समय", "WITA": "केन्द्रीय इन्डोनेशिया समय", "ECT": "ईक्वोडोर समय", "MESZ": "केन्द्रीय युरोपेली ग्रीष्मकालीन समय", "ART": "अर्जेनटिनी मानक समय", "AWDT": "पश्चिमी अस्ट्रेलिया दिवा समय", "SGT": "सिंगापुर मानक समय", "BOT": "बोलिभिया समय", "ACWST": "केन्द्रीय पश्चिमी अस्ट्रेलिया मानक समय", "WART": "पश्चिमी अर्जेनटिनी मानक समय", "ACST": "केन्द्रीय अस्ट्रेलिया मानक समय", "HAT": "न्यूफाउनल्यान्डको दिवा समय", "HEEG": "पूर्वी ग्रीनल्यान्डको ग्रीष्मकालीन समय", "AEST": "पूर्वी अस्ट्रेलिया मानक समय", "UYST": "उरुग्वे ग्रीष्मकालीन समय", "NZST": "न्यूजिल्यान्ड मानक समय", "OESZ": "पूर्वी युरोपेली ग्रीष्मकालीन समय", "HENOMX": "उत्तर पश्चिम मेक्सिकोको दिवा समय", "AKDT": "अलस्काको दिवा समय", "MST": "हिमाली मानक समय", "HNPMX": "मेक्सिकन प्यासिफिक मानक समय", "WIT": "पूर्वी इन्डोनेशिया समय", "HEPM": "सेन्ट पियर्रे र मिक्युलोनको दिवा समय", "MEZ": "केन्द्रीय युरोपेली मानक समय", "WEZ": "पश्चिमी युरोपेली मानक समय", "HADT": "हवाई-एलुटियन दिवा समय", "CAT": "केन्द्रीय अफ्रिकी समय", "AST": "एट्लान्टिक मानक समय", "JDT": "जापान दिवा समय", "CLST": "चिली ग्रीष्मकालीन समय", "OEZ": "पूर्वी युरोपेली मानक समय", "ACDT": "केन्द्रीय अस्ट्रेलिया दिवा समय", "HNNOMX": "उत्तर पश्चिम मेक्सिकोको मानक समय", "AEDT": "पूर्वी अस्ट्रेलिया दिवा समय", "ChST": "चामोर्रो मानक समय", "IST": "भारतीय मानक समय", "WARST": "पश्चिमी अर्जेनटिनी ग्रीष्मकालीन समय", "WAST": "पश्चिम अफ्रिकी ग्रीष्मकालीन समय", "MDT": "हिमाली दिवा समय", "LHDT": "लर्ड हावे दिवा समय", "HAST": "हवाई-एलुटियन मानक समय", "WESZ": "युरोपेली ग्रीष्मकालीन समय", "PST": "प्यासिफिक मानक समय", "JST": "जापान मानक समय", "ARST": "अर्जेनटिनी ग्रीष्मकालीन समय", "WAT": "पश्चिम अफ्रिकी मानक समय", "EST": "पूर्वी मानक समय", "SAST": "दक्षिण अफ्रिकी समय", "EAT": "पूर्वी अफ्रिकी समय", "HNEG": "पूर्वी ग्रीनल्यान्डको मानक समय", "∅∅∅": "∅∅∅", "NZDT": "न्यूजिल्यान्ड दिवा समय", "GMT": "ग्रीनविच मिन समय"}, + } +} + +// Locale returns the current translators string locale +func (ne *ne) Locale() string { + return ne.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ne' +func (ne *ne) PluralsCardinal() []locales.PluralRule { + return ne.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ne' +func (ne *ne) PluralsOrdinal() []locales.PluralRule { + return ne.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ne' +func (ne *ne) PluralsRange() []locales.PluralRule { + return ne.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ne' +func (ne *ne) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ne' +func (ne *ne) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 1 && n <= 4 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ne' +func (ne *ne) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ne.CardinalPluralRule(num1, v1) + end := ne.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ne *ne) MonthAbbreviated(month time.Month) string { + return ne.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ne *ne) MonthsAbbreviated() []string { + return ne.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ne *ne) MonthNarrow(month time.Month) string { + return ne.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ne *ne) MonthsNarrow() []string { + return ne.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ne *ne) MonthWide(month time.Month) string { + return ne.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ne *ne) MonthsWide() []string { + return ne.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ne *ne) WeekdayAbbreviated(weekday time.Weekday) string { + return ne.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ne *ne) WeekdaysAbbreviated() []string { + return ne.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ne *ne) WeekdayNarrow(weekday time.Weekday) string { + return ne.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ne *ne) WeekdaysNarrow() []string { + return ne.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ne *ne) WeekdayShort(weekday time.Weekday) string { + return ne.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ne *ne) WeekdaysShort() []string { + return ne.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ne *ne) WeekdayWide(weekday time.Weekday) string { + return ne.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ne *ne) WeekdaysWide() []string { + return ne.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ne' and handles both Whole and Real numbers based on 'v' +func (ne *ne) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ne' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ne *ne) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ne.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ne' +func (ne *ne) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ne.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ne.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ne' +// in accounting notation. +func (ne *ne) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ne.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyNegativePrefix[j]) + } + + b = append(b, ne.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ne.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ne' +func (ne *ne) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ne' +func (ne *ne) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ne' +func (ne *ne) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ne' +func (ne *ne) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ne.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ne' +func (ne *ne) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ne' +func (ne *ne) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ne' +func (ne *ne) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ne' +func (ne *ne) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ne.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ne/ne_test.go b/vendor/github.com/go-playground/locales/ne/ne_test.go new file mode 100644 index 0000000000..52401cde14 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ne/ne_test.go @@ -0,0 +1,1120 @@ +package ne + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ne" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ne_IN/ne_IN.go b/vendor/github.com/go-playground/locales/ne_IN/ne_IN.go new file mode 100644 index 0000000000..d2466db655 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ne_IN/ne_IN.go @@ -0,0 +1,658 @@ +package ne_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ne_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ne_IN' locale +func New() locales.Translator { + return &ne_IN{ + locale: "ne_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मे", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"}, + monthsNarrow: []string{"", "१", "२", "३", "४", "५", "६", "७", "८", "९", "१०", "११", "१२"}, + monthsWide: []string{"", "जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मई", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"}, + daysAbbreviated: []string{"आइत", "सोम", "मङ्गल", "बुध", "बिहि", "शुक्र", "शनि"}, + daysNarrow: []string{"आ", "सो", "म", "बु", "बि", "शु", "श"}, + daysShort: []string{"आइत", "सोम", "मङ्गल", "बुध", "बिहि", "शुक्र", "शनि"}, + daysWide: []string{"आइतबार", "सोमबार", "मङ्गलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार"}, + periodsAbbreviated: []string{"पूर्वाह्न", "अपराह्न"}, + periodsNarrow: []string{"पूर्वाह्न", "अपराह्न"}, + periodsWide: []string{"पूर्वाह्न", "अपराह्न"}, + erasAbbreviated: []string{"ईसा पूर्व", "सन्"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ईसा पूर्व", "सन्"}, + timezones: map[string]string{"CLST": "चिली ग्रीष्मकालीन समय", "ACST": "केन्द्रीय अस्ट्रेलिया मानक समय", "HAT": "न्यूफाउनल्यान्डको दिवा समय", "AEDT": "पूर्वी अस्ट्रेलिया दिवा समय", "SRT": "सुरिनामा समय", "WIB": "पश्चिमी इन्डोनेशिया समय", "TMT": "तुर्कमेनिस्तान मानक समय", "HNNOMX": "उत्तर पश्चिम मेक्सिकोको मानक समय", "CDT": "केन्द्रीय दिवा समय", "∅∅∅": "ब्राजिलीया ग्रीष्मकालीन समय", "AWST": "पश्चिमी अस्ट्रेलिया मानक समय", "VET": "भेनेज्युएला समय", "JST": "जापान मानक समय", "WART": "पश्चिमी अर्जेनटिनी मानक समय", "EAT": "पूर्वी अफ्रिकी समय", "CST": "केन्द्रीय मानक समय", "ART": "अर्जेनटिनी मानक समय", "HADT": "हवाई-एलुटियन दिवा समय", "ACWDT": "केन्द्रीय पश्चिमी अस्ट्रेलिया दिवा समय", "BT": "भुटानी समय", "AEST": "पूर्वी अस्ट्रेलिया मानक समय", "AWDT": "पश्चिमी अस्ट्रेलिया दिवा समय", "ECT": "ईक्वोडोर समय", "CLT": "चिली मानक समय", "HNOG": "पश्चिमी ग्रीनल्यान्डको मानक समय", "WAT": "पश्चिम अफ्रिकी मानक समय", "EST": "पूर्वी मानक समय", "HAST": "हवाई-एलुटियन मानक समय", "MEZ": "केन्द्रीय युरोपेली मानक समय", "JDT": "जापान दिवा समय", "HEOG": "पश्चिमी ग्रीनल्यान्डको ग्रीष्मकालीन समय", "GYT": "गुयाना समय", "ARST": "अर्जेनटिनी ग्रीष्मकालीन समय", "EDT": "पूर्वी दिवा समय", "PDT": "प्यासिफिक दिवा समय", "NZDT": "न्यूजिल्यान्ड दिवा समय", "MESZ": "केन्द्रीय युरोपेली ग्रीष्मकालीन समय", "AST": "एट्लान्टिक मानक समय", "WEZ": "पश्चिमी युरोपेली मानक समय", "WESZ": "युरोपेली ग्रीष्मकालीन समय", "HNPM": "सेन्ट पियर्रे र मिक्युलोनको मानक समय", "NZST": "न्यूजिल्यान्ड मानक समय", "TMST": "तुर्कमेनिस्तान ग्रीष्मकालीन मानक समय", "HEPM": "सेन्ट पियर्रे र मिक्युलोनको दिवा समय", "SAST": "दक्षिण अफ्रिकी समय", "WIT": "पूर्वी इन्डोनेशिया समय", "BOT": "बोलिभिया समय", "HENOMX": "उत्तर पश्चिम मेक्सिकोको दिवा समय", "HNT": "न्यूफाउनडल्यान्डको मानक समय", "ACWST": "केन्द्रीय पश्चिमी अस्ट्रेलिया मानक समय", "HEEG": "पूर्वी ग्रीनल्यान्डको ग्रीष्मकालीन समय", "GFT": "फ्रेन्च ग्वाना समय", "AKDT": "अलस्काको दिवा समय", "HNPMX": "मेक्सिकन प्यासिफिक मानक समय", "HECU": "क्यूबाको दिवा समय", "WAST": "पश्चिम अफ्रिकी ग्रीष्मकालीन समय", "HKST": "हङकङ ग्रीष्मकालीन समय", "UYST": "उरुग्वे ग्रीष्मकालीन समय", "LHDT": "लर्ड हावे दिवा समय", "HEPMX": "मेक्सिकन प्यासिफिक दिवा समय", "HNCU": "क्यूबाको मानक समय", "CHAST": "चाथाम मानक समय", "WARST": "पश्चिमी अर्जेनटिनी ग्रीष्मकालीन समय", "ADT": "एट्लान्टिक दिवा समय", "OESZ": "पूर्वी युरोपेली ग्रीष्मकालीन समय", "CAT": "केन्द्रीय अफ्रिकी समय", "MDT": "MDT", "HNEG": "पूर्वी ग्रीनल्यान्डको मानक समय", "WITA": "केन्द्रीय इन्डोनेशिया समय", "IST": "भारतीय मानक समय", "COST": "कोलम्बियाली ग्रीष्मकालीन समय", "UYT": "उरूग्वे मानक समय", "LHST": "लर्ड हावे मानक समय", "COT": "कोलम्बियाली मानक समय", "AKST": "अलस्काको मानक समय", "PST": "प्यासिफिक मानक समय", "MYT": "मलेसिया समय", "GMT": "ग्रीनविच मिन समय", "MST": "MST", "HKT": "हङकङ मानक समय", "ACDT": "केन्द्रीय अस्ट्रेलिया दिवा समय", "CHADT": "चाथाम दिवा समय", "SGT": "सिंगापुर मानक समय", "OEZ": "पूर्वी युरोपेली मानक समय", "ChST": "चामोर्रो मानक समय"}, + } +} + +// Locale returns the current translators string locale +func (ne *ne_IN) Locale() string { + return ne.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ne_IN' +func (ne *ne_IN) PluralsCardinal() []locales.PluralRule { + return ne.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ne_IN' +func (ne *ne_IN) PluralsOrdinal() []locales.PluralRule { + return ne.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ne_IN' +func (ne *ne_IN) PluralsRange() []locales.PluralRule { + return ne.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ne_IN' +func (ne *ne_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ne_IN' +func (ne *ne_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 1 && n <= 4 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ne_IN' +func (ne *ne_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ne.CardinalPluralRule(num1, v1) + end := ne.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ne *ne_IN) MonthAbbreviated(month time.Month) string { + return ne.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ne *ne_IN) MonthsAbbreviated() []string { + return ne.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ne *ne_IN) MonthNarrow(month time.Month) string { + return ne.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ne *ne_IN) MonthsNarrow() []string { + return ne.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ne *ne_IN) MonthWide(month time.Month) string { + return ne.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ne *ne_IN) MonthsWide() []string { + return ne.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ne *ne_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return ne.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ne *ne_IN) WeekdaysAbbreviated() []string { + return ne.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ne *ne_IN) WeekdayNarrow(weekday time.Weekday) string { + return ne.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ne *ne_IN) WeekdaysNarrow() []string { + return ne.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ne *ne_IN) WeekdayShort(weekday time.Weekday) string { + return ne.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ne *ne_IN) WeekdaysShort() []string { + return ne.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ne *ne_IN) WeekdayWide(weekday time.Weekday) string { + return ne.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ne *ne_IN) WeekdaysWide() []string { + return ne.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ne_IN' and handles both Whole and Real numbers based on 'v' +func (ne *ne_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ne_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ne *ne_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ne.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ne_IN' +func (ne *ne_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ne.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ne.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ne_IN' +// in accounting notation. +func (ne *ne_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ne.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyNegativePrefix[j]) + } + + b = append(b, ne.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ne.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ne_IN' +func (ne *ne_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ne_IN' +func (ne *ne_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ne_IN' +func (ne *ne_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ne_IN' +func (ne *ne_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ne.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ne_IN' +func (ne *ne_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ne.periodsAbbreviated[0]...) + } else { + b = append(b, ne.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ne_IN' +func (ne *ne_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ne.periodsAbbreviated[0]...) + } else { + b = append(b, ne.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ne_IN' +func (ne *ne_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ne.periodsAbbreviated[0]...) + } else { + b = append(b, ne.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ne_IN' +func (ne *ne_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ne.periodsAbbreviated[0]...) + } else { + b = append(b, ne.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ne.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ne_IN/ne_IN_test.go b/vendor/github.com/go-playground/locales/ne_IN/ne_IN_test.go new file mode 100644 index 0000000000..19faa4f874 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ne_IN/ne_IN_test.go @@ -0,0 +1,1120 @@ +package ne_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ne_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ne_NP/ne_NP.go b/vendor/github.com/go-playground/locales/ne_NP/ne_NP.go new file mode 100644 index 0000000000..936664e6e5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ne_NP/ne_NP.go @@ -0,0 +1,620 @@ +package ne_NP + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ne_NP struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ne_NP' locale +func New() locales.Translator { + return &ne_NP{ + locale: "ne_NP", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मे", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"}, + monthsNarrow: []string{"", "१", "२", "३", "४", "५", "६", "७", "८", "९", "१०", "११", "१२"}, + monthsWide: []string{"", "जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मई", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"}, + daysAbbreviated: []string{"आइत", "सोम", "मङ्गल", "बुध", "बिहि", "शुक्र", "शनि"}, + daysNarrow: []string{"आ", "सो", "म", "बु", "बि", "शु", "श"}, + daysShort: []string{"आइत", "सोम", "मङ्गल", "बुध", "बिहि", "शुक्र", "शनि"}, + daysWide: []string{"आइतबार", "सोमबार", "मङ्गलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार"}, + periodsAbbreviated: []string{"पूर्वाह्न", "अपराह्न"}, + periodsNarrow: []string{"पूर्वाह्न", "अपराह्न"}, + periodsWide: []string{"पूर्वाह्न", "अपराह्न"}, + erasAbbreviated: []string{"ईसा पूर्व", "सन्"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ईसा पूर्व", "सन्"}, + timezones: map[string]string{"AKST": "अलस्काको मानक समय", "HNPM": "सेन्ट पियर्रे र मिक्युलोनको मानक समय", "HAST": "हवाई-एलुटियन मानक समय", "PST": "प्यासिफिक मानक समय", "WAT": "पश्चिम अफ्रिकी मानक समय", "HNEG": "पूर्वी ग्रीनल्यान्डको मानक समय", "MYT": "मलेसिया समय", "CLST": "चिली ग्रीष्मकालीन समय", "HKST": "हङकङ ग्रीष्मकालीन समय", "EDT": "पूर्वी दिवा समय", "WIT": "पूर्वी इन्डोनेशिया समय", "BOT": "बोलिभिया समय", "IST": "भारतीय मानक समय", "MDT": "MDT", "EST": "पूर्वी मानक समय", "ACDT": "केन्द्रीय अस्ट्रेलिया दिवा समय", "HENOMX": "उत्तर पश्चिम मेक्सिकोको दिवा समय", "COT": "कोलम्बियाली मानक समय", "OEZ": "पूर्वी युरोपेली मानक समय", "ARST": "अर्जेनटिनी ग्रीष्मकालीन समय", "COST": "कोलम्बियाली ग्रीष्मकालीन समय", "UYT": "उरूग्वे मानक समय", "TMST": "तुर्कमेनिस्तान ग्रीष्मकालीन मानक समय", "HEPMX": "मेक्सिकन प्यासिफिक दिवा समय", "CDT": "केन्द्रीय दिवा समय", "AWDT": "पश्चिमी अस्ट्रेलिया दिवा समय", "CHAST": "चाथाम मानक समय", "SGT": "सिंगापुर मानक समय", "AEST": "पूर्वी अस्ट्रेलिया मानक समय", "HEPM": "सेन्ट पियर्रे र मिक्युलोनको दिवा समय", "LHDT": "लर्ड हावे दिवा समय", "WIB": "पश्चिमी इन्डोनेशिया समय", "HNNOMX": "उत्तर पश्चिम मेक्सिकोको मानक समय", "WITA": "केन्द्रीय इन्डोनेशिया समय", "HAT": "न्यूफाउनल्यान्डको दिवा समय", "AKDT": "अलस्काको दिवा समय", "HNPMX": "मेक्सिकन प्यासिफिक मानक समय", "PDT": "प्यासिफिक दिवा समय", "NZDT": "न्यूजिल्यान्ड दिवा समय", "ACST": "केन्द्रीय अस्ट्रेलिया मानक समय", "BT": "भुटानी समय", "EAT": "पूर्वी अफ्रिकी समय", "HECU": "क्यूबाको दिवा समय", "CHADT": "चाथाम दिवा समय", "NZST": "न्यूजिल्यान्ड मानक समय", "WESZ": "युरोपेली ग्रीष्मकालीन समय", "AEDT": "पूर्वी अस्ट्रेलिया दिवा समय", "GYT": "गुयाना समय", "JST": "जापान मानक समय", "MEZ": "केन्द्रीय युरोपेली मानक समय", "GFT": "फ्रेन्च ग्वाना समय", "UYST": "उरुग्वे ग्रीष्मकालीन समय", "HADT": "हवाई-एलुटियन दिवा समय", "OESZ": "पूर्वी युरोपेली ग्रीष्मकालीन समय", "TMT": "तुर्कमेनिस्तान मानक समय", "MST": "MST", "AST": "एट्लान्टिक मानक समय", "HKT": "हङकङ मानक समय", "SAST": "दक्षिण अफ्रिकी समय", "LHST": "लर्ड हावे मानक समय", "ECT": "ईक्वोडोर समय", "WEZ": "पश्चिमी युरोपेली मानक समय", "WART": "पश्चिमी अर्जेनटिनी मानक समय", "HEOG": "पश्चिमी ग्रीनल्यान्डको ग्रीष्मकालीन समय", "CST": "केन्द्रीय मानक समय", "VET": "भेनेज्युएला समय", "GMT": "ग्रीनविच मिन समय", "WARST": "पश्चिमी अर्जेनटिनी ग्रीष्मकालीन समय", "ChST": "चामोर्रो मानक समय", "ACWST": "केन्द्रीय पश्चिमी अस्ट्रेलिया मानक समय", "ACWDT": "केन्द्रीय पश्चिमी अस्ट्रेलिया दिवा समय", "CAT": "केन्द्रीय अफ्रिकी समय", "MESZ": "केन्द्रीय युरोपेली ग्रीष्मकालीन समय", "SRT": "सुरिनामा समय", "HNCU": "क्यूबाको मानक समय", "WAST": "पश्चिम अफ्रिकी ग्रीष्मकालीन समय", "HEEG": "पूर्वी ग्रीनल्यान्डको ग्रीष्मकालीन समय", "HNT": "न्यूफाउनडल्यान्डको मानक समय", "JDT": "जापान दिवा समय", "CLT": "चिली मानक समय", "ADT": "एट्लान्टिक दिवा समय", "ART": "अर्जेनटिनी मानक समय", "∅∅∅": "अमेजन ग्रीष्मकालीन समय", "HNOG": "पश्चिमी ग्रीनल्यान्डको मानक समय", "AWST": "पश्चिमी अस्ट्रेलिया मानक समय"}, + } +} + +// Locale returns the current translators string locale +func (ne *ne_NP) Locale() string { + return ne.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ne_NP' +func (ne *ne_NP) PluralsCardinal() []locales.PluralRule { + return ne.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ne_NP' +func (ne *ne_NP) PluralsOrdinal() []locales.PluralRule { + return ne.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ne_NP' +func (ne *ne_NP) PluralsRange() []locales.PluralRule { + return ne.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ne_NP' +func (ne *ne_NP) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ne_NP' +func (ne *ne_NP) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 1 && n <= 4 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ne_NP' +func (ne *ne_NP) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ne.CardinalPluralRule(num1, v1) + end := ne.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ne *ne_NP) MonthAbbreviated(month time.Month) string { + return ne.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ne *ne_NP) MonthsAbbreviated() []string { + return ne.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ne *ne_NP) MonthNarrow(month time.Month) string { + return ne.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ne *ne_NP) MonthsNarrow() []string { + return ne.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ne *ne_NP) MonthWide(month time.Month) string { + return ne.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ne *ne_NP) MonthsWide() []string { + return ne.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ne *ne_NP) WeekdayAbbreviated(weekday time.Weekday) string { + return ne.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ne *ne_NP) WeekdaysAbbreviated() []string { + return ne.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ne *ne_NP) WeekdayNarrow(weekday time.Weekday) string { + return ne.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ne *ne_NP) WeekdaysNarrow() []string { + return ne.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ne *ne_NP) WeekdayShort(weekday time.Weekday) string { + return ne.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ne *ne_NP) WeekdaysShort() []string { + return ne.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ne *ne_NP) WeekdayWide(weekday time.Weekday) string { + return ne.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ne *ne_NP) WeekdaysWide() []string { + return ne.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ne_NP' and handles both Whole and Real numbers based on 'v' +func (ne *ne_NP) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ne_NP' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ne *ne_NP) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ne.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ne_NP' +func (ne *ne_NP) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ne.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ne.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ne.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ne_NP' +// in accounting notation. +func (ne *ne_NP) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ne.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ne.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ne.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyNegativePrefix[j]) + } + + b = append(b, ne.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ne.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ne.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ne.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ne_NP' +func (ne *ne_NP) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ne_NP' +func (ne *ne_NP) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ne_NP' +func (ne *ne_NP) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ne_NP' +func (ne *ne_NP) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ne.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, ne.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ne_NP' +func (ne *ne_NP) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ne_NP' +func (ne *ne_NP) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ne_NP' +func (ne *ne_NP) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ne_NP' +func (ne *ne_NP) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ne.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ne.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ne.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ne_NP/ne_NP_test.go b/vendor/github.com/go-playground/locales/ne_NP/ne_NP_test.go new file mode 100644 index 0000000000..cc31a6bb2a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ne_NP/ne_NP_test.go @@ -0,0 +1,1120 @@ +package ne_NP + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ne_NP" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nl/nl.go b/vendor/github.com/go-playground/locales/nl/nl.go new file mode 100644 index 0000000000..0cec181dc7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl/nl.go @@ -0,0 +1,604 @@ +package nl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nl' locale +func New() locales.Translator { + return &nl{ + locale: "nl", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "C$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJ$", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SI$", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysNarrow: []string{"Z", "M", "D", "W", "D", "V", "Z"}, + daysShort: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysWide: []string{"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"HKST": "Hongkongse zomertijd", "COST": "Colombiaanse zomertijd", "HNCU": "Cubaanse standaardtijd", "CHAST": "Chatham-standaardtijd", "CHADT": "Chatham-zomertijd", "JST": "Japanse standaardtijd", "WESZ": "West-Europese zomertijd", "TMST": "Turkmeense zomertijd", "HNT": "Newfoundland-standaardtijd", "AKDT": "Alaska-zomertijd", "ECT": "Ecuadoraanse tijd", "NZDT": "Nieuw-Zeelandse zomertijd", "MEZ": "Midden-Europese standaardtijd", "HEPMX": "Mexicaanse Pacific-zomertijd", "HNPMX": "Mexicaanse Pacific-standaardtijd", "EAT": "Oost-Afrikaanse tijd", "PDT": "Pacific-zomertijd", "HAST": "Hawaii-Aleoetische standaardtijd", "HADT": "Hawaii-Aleoetische zomertijd", "CLST": "Chileense zomertijd", "WITA": "Centraal-Indonesische tijd", "SGT": "Singaporese standaardtijd", "ACWDT": "Midden-Australische westelijke zomertijd", "MESZ": "Midden-Europese zomertijd", "ART": "Argentijnse standaardtijd", "HNPM": "Saint Pierre en Miquelon-standaardtijd", "ChST": "Chamorro-tijd", "GYT": "Guyaanse tijd", "PST": "Pacific-standaardtijd", "OESZ": "Oost-Europese zomertijd", "HNNOMX": "Noordwest-Mexicaanse standaardtijd", "BT": "Bhutaanse tijd", "HNEG": "Oost-Groenlandse standaardtijd", "VET": "Venezolaanse tijd", "MYT": "Maleisische tijd", "WAT": "West-Afrikaanse standaardtijd", "HENOMX": "Noordwest-Mexicaanse zomertijd", "AKST": "Alaska-standaardtijd", "HEPM": "Saint Pierre en Miquelon-zomertijd", "IST": "Indiase tijd", "MST": "Macause standaardtijd", "ARST": "Argentijnse zomertijd", "AEDT": "Oost-Australische zomertijd", "SAST": "Zuid-Afrikaanse tijd", "CDT": "Central-zomertijd", "CAT": "Centraal-Afrikaanse tijd", "AST": "Atlantic-standaardtijd", "CLT": "Chileense standaardtijd", "EDT": "Eastern-zomertijd", "LHDT": "Lord Howe-eilandse zomertijd", "UYST": "Uruguayaanse zomertijd", "∅∅∅": "Braziliaanse zomertijd", "AWST": "West-Australische standaardtijd", "AWDT": "West-Australische zomertijd", "BOT": "Boliviaanse tijd", "GMT": "Greenwich Mean Time", "HAT": "Newfoundland-zomertijd", "WEZ": "West-Europese standaardtijd", "WART": "West-Argentijnse standaardtijd", "HEOG": "West-Groenlandse zomertijd", "HEEG": "Oost-Groenlandse zomertijd", "GFT": "Frans-Guyaanse tijd", "HECU": "Cubaanse zomertijd", "OEZ": "Oost-Europese standaardtijd", "HNOG": "West-Groenlandse standaardtijd", "MDT": "Macause zomertijd", "WAST": "West-Afrikaanse zomertijd", "HKT": "Hongkongse standaardtijd", "ADT": "Atlantic-zomertijd", "TMT": "Turkmeense standaardtijd", "COT": "Colombiaanse standaardtijd", "UYT": "Uruguayaanse standaardtijd", "ACWST": "Midden-Australische westelijke standaardtijd", "NZST": "Nieuw-Zeelandse standaardtijd", "LHST": "Lord Howe-eilandse standaardtijd", "WIB": "West-Indonesische tijd", "JDT": "Japanse zomertijd", "ACST": "Midden-Australische standaardtijd", "ACDT": "Midden-Australische zomertijd", "SRT": "Surinaamse tijd", "CST": "Central-standaardtijd", "WIT": "Oost-Indonesische tijd", "WARST": "West-Argentijnse zomertijd", "EST": "Eastern-standaardtijd", "AEST": "Oost-Australische standaardtijd"}, + } +} + +// Locale returns the current translators string locale +func (nl *nl) Locale() string { + return nl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nl' +func (nl *nl) PluralsCardinal() []locales.PluralRule { + return nl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nl' +func (nl *nl) PluralsOrdinal() []locales.PluralRule { + return nl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nl' +func (nl *nl) PluralsRange() []locales.PluralRule { + return nl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nl' +func (nl *nl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nl' +func (nl *nl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nl' +func (nl *nl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := nl.CardinalPluralRule(num1, v1) + end := nl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nl *nl) MonthAbbreviated(month time.Month) string { + return nl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nl *nl) MonthsAbbreviated() []string { + return nl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nl *nl) MonthNarrow(month time.Month) string { + return nl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nl *nl) MonthsNarrow() []string { + return nl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nl *nl) MonthWide(month time.Month) string { + return nl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nl *nl) MonthsWide() []string { + return nl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nl *nl) WeekdayAbbreviated(weekday time.Weekday) string { + return nl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nl *nl) WeekdaysAbbreviated() []string { + return nl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nl *nl) WeekdayNarrow(weekday time.Weekday) string { + return nl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nl *nl) WeekdaysNarrow() []string { + return nl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nl *nl) WeekdayShort(weekday time.Weekday) string { + return nl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nl *nl) WeekdaysShort() []string { + return nl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nl *nl) WeekdayWide(weekday time.Weekday) string { + return nl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nl *nl) WeekdaysWide() []string { + return nl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nl' and handles both Whole and Real numbers based on 'v' +func (nl *nl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nl *nl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nl.percentSuffix...) + + b = append(b, nl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nl' +func (nl *nl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nl' +// in accounting notation. +func (nl *nl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nl' +func (nl *nl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nl' +func (nl *nl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nl' +func (nl *nl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nl' +func (nl *nl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nl' +func (nl *nl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nl' +func (nl *nl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nl' +func (nl *nl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nl' +func (nl *nl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nl/nl_test.go b/vendor/github.com/go-playground/locales/nl/nl_test.go new file mode 100644 index 0000000000..5ce8df5310 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl/nl_test.go @@ -0,0 +1,1120 @@ +package nl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nl_AW/nl_AW.go b/vendor/github.com/go-playground/locales/nl_AW/nl_AW.go new file mode 100644 index 0000000000..b51c158469 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_AW/nl_AW.go @@ -0,0 +1,604 @@ +package nl_AW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nl_AW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nl_AW' locale +func New() locales.Translator { + return &nl_AW{ + locale: "nl_AW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "Afl.", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysNarrow: []string{"Z", "M", "D", "W", "D", "V", "Z"}, + daysShort: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysWide: []string{"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"AKDT": "Alaska-zomertijd", "ChST": "Chamorro-tijd", "HAST": "Hawaii-Aleoetische standaardtijd", "EST": "Eastern-standaardtijd", "WIT": "Oost-Indonesische tijd", "WARST": "West-Argentijnse zomertijd", "HEOG": "West-Groenlandse zomertijd", "PST": "Pacific-standaardtijd", "ECT": "Ecuadoraanse tijd", "WEZ": "West-Europese standaardtijd", "GMT": "Greenwich Mean Time", "HKT": "Hongkongse standaardtijd", "HNNOMX": "Noordwest-Mexicaanse standaardtijd", "MDT": "Mountain-zomertijd", "UYT": "Uruguayaanse standaardtijd", "HEEG": "Oost-Groenlandse zomertijd", "GYT": "Guyaanse tijd", "WESZ": "West-Europese zomertijd", "SRT": "Surinaamse tijd", "ART": "Argentijnse standaardtijd", "COST": "Colombiaanse zomertijd", "HNT": "Newfoundland-standaardtijd", "∅∅∅": "Acre-zomertijd", "PDT": "Pacific-zomertijd", "TMST": "Turkmeense zomertijd", "HKST": "Hongkongse zomertijd", "HEPMX": "Mexicaanse Pacific-zomertijd", "HNCU": "Cubaanse standaardtijd", "CHADT": "Chatham-zomertijd", "CHAST": "Chatham-standaardtijd", "HAT": "Newfoundland-zomertijd", "CDT": "Central-zomertijd", "SGT": "Singaporese standaardtijd", "WITA": "Centraal-Indonesische tijd", "EAT": "Oost-Afrikaanse tijd", "CAT": "Centraal-Afrikaanse tijd", "WIB": "West-Indonesische tijd", "CST": "Central-standaardtijd", "BOT": "Boliviaanse tijd", "OESZ": "Oost-Europese zomertijd", "WART": "West-Argentijnse standaardtijd", "HEPM": "Saint Pierre en Miquelon-zomertijd", "HNPMX": "Mexicaanse Pacific-standaardtijd", "SAST": "Zuid-Afrikaanse tijd", "ARST": "Argentijnse zomertijd", "WAST": "West-Afrikaanse zomertijd", "MST": "Mountain-standaardtijd", "HNPM": "Saint Pierre en Miquelon-standaardtijd", "HECU": "Cubaanse zomertijd", "AWDT": "West-Australische zomertijd", "ACWST": "Midden-Australische westelijke standaardtijd", "COT": "Colombiaanse standaardtijd", "ACDT": "Midden-Australische zomertijd", "AEDT": "Oost-Australische zomertijd", "EDT": "Eastern-zomertijd", "VET": "Venezolaanse tijd", "JST": "Japanse standaardtijd", "CLST": "Chileense zomertijd", "WAT": "West-Afrikaanse standaardtijd", "JDT": "Japanse zomertijd", "MESZ": "Midden-Europese zomertijd", "ADT": "Atlantic-zomertijd", "IST": "Indiase tijd", "OEZ": "Oost-Europese standaardtijd", "UYST": "Uruguayaanse zomertijd", "AWST": "West-Australische standaardtijd", "HADT": "Hawaii-Aleoetische zomertijd", "LHST": "Lord Howe-eilandse standaardtijd", "NZDT": "Nieuw-Zeelandse zomertijd", "LHDT": "Lord Howe-eilandse zomertijd", "ACWDT": "Midden-Australische westelijke zomertijd", "MEZ": "Midden-Europese standaardtijd", "HNOG": "West-Groenlandse standaardtijd", "HENOMX": "Noordwest-Mexicaanse zomertijd", "BT": "Bhutaanse tijd", "GFT": "Frans-Guyaanse tijd", "MYT": "Maleisische tijd", "CLT": "Chileense standaardtijd", "ACST": "Midden-Australische standaardtijd", "AEST": "Oost-Australische standaardtijd", "AKST": "Alaska-standaardtijd", "TMT": "Turkmeense standaardtijd", "HNEG": "Oost-Groenlandse standaardtijd", "NZST": "Nieuw-Zeelandse standaardtijd", "AST": "Atlantic-standaardtijd"}, + } +} + +// Locale returns the current translators string locale +func (nl *nl_AW) Locale() string { + return nl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nl_AW' +func (nl *nl_AW) PluralsCardinal() []locales.PluralRule { + return nl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nl_AW' +func (nl *nl_AW) PluralsOrdinal() []locales.PluralRule { + return nl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nl_AW' +func (nl *nl_AW) PluralsRange() []locales.PluralRule { + return nl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nl_AW' +func (nl *nl_AW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nl_AW' +func (nl *nl_AW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nl_AW' +func (nl *nl_AW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := nl.CardinalPluralRule(num1, v1) + end := nl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nl *nl_AW) MonthAbbreviated(month time.Month) string { + return nl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nl *nl_AW) MonthsAbbreviated() []string { + return nl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nl *nl_AW) MonthNarrow(month time.Month) string { + return nl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nl *nl_AW) MonthsNarrow() []string { + return nl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nl *nl_AW) MonthWide(month time.Month) string { + return nl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nl *nl_AW) MonthsWide() []string { + return nl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nl *nl_AW) WeekdayAbbreviated(weekday time.Weekday) string { + return nl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nl *nl_AW) WeekdaysAbbreviated() []string { + return nl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nl *nl_AW) WeekdayNarrow(weekday time.Weekday) string { + return nl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nl *nl_AW) WeekdaysNarrow() []string { + return nl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nl *nl_AW) WeekdayShort(weekday time.Weekday) string { + return nl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nl *nl_AW) WeekdaysShort() []string { + return nl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nl *nl_AW) WeekdayWide(weekday time.Weekday) string { + return nl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nl *nl_AW) WeekdaysWide() []string { + return nl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nl_AW' and handles both Whole and Real numbers based on 'v' +func (nl *nl_AW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nl_AW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nl *nl_AW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nl.percentSuffix...) + + b = append(b, nl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nl_AW' +func (nl *nl_AW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nl_AW' +// in accounting notation. +func (nl *nl_AW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nl_AW' +func (nl *nl_AW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nl_AW' +func (nl *nl_AW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nl_AW' +func (nl *nl_AW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nl_AW' +func (nl *nl_AW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nl_AW' +func (nl *nl_AW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nl_AW' +func (nl *nl_AW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nl_AW' +func (nl *nl_AW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nl_AW' +func (nl *nl_AW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nl_AW/nl_AW_test.go b/vendor/github.com/go-playground/locales/nl_AW/nl_AW_test.go new file mode 100644 index 0000000000..77bacd0d6c --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_AW/nl_AW_test.go @@ -0,0 +1,1120 @@ +package nl_AW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nl_AW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nl_BE/nl_BE.go b/vendor/github.com/go-playground/locales/nl_BE/nl_BE.go new file mode 100644 index 0000000000..39cfe46228 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_BE/nl_BE.go @@ -0,0 +1,600 @@ +package nl_BE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nl_BE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nl_BE' locale +func New() locales.Translator { + return &nl_BE{ + locale: "nl_BE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysNarrow: []string{"Z", "M", "D", "W", "D", "V", "Z"}, + daysShort: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysWide: []string{"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"HAT": "Newfoundland-zomertijd", "AEST": "Oost-Australische standaardtijd", "HNCU": "Cubaanse standaardtijd", "WIT": "Oost-Indonesische tijd", "CHADT": "Chatham-zomertijd", "PST": "Pacific-standaardtijd", "JDT": "Japanse zomertijd", "OEZ": "Oost-Europese standaardtijd", "WAT": "West-Afrikaanse standaardtijd", "WITA": "Centraal-Indonesische tijd", "UYT": "Uruguayaanse standaardtijd", "GYT": "Guyaanse tijd", "CST": "Central-standaardtijd", "HADT": "Hawaii-Aleoetische zomertijd", "WESZ": "West-Europese zomertijd", "MDT": "Macause zomertijd", "ACWDT": "Midden-Australische westelijke zomertijd", "SRT": "Surinaamse tijd", "CHAST": "Chatham-standaardtijd", "MYT": "Maleisische tijd", "ACDT": "Midden-Australische zomertijd", "TMST": "Turkmeense zomertijd", "EDT": "Eastern-zomertijd", "HNPMX": "Mexicaanse Pacific-standaardtijd", "AWST": "West-Australische standaardtijd", "WARST": "West-Argentijnse zomertijd", "CLST": "Chileense zomertijd", "HENOMX": "Noordwest-Mexicaanse zomertijd", "AEDT": "Oost-Australische zomertijd", "HEPMX": "Mexicaanse Pacific-zomertijd", "GMT": "Greenwich Mean Time", "ADT": "Atlantic-zomertijd", "ACST": "Midden-Australische standaardtijd", "AKDT": "Alaska-zomertijd", "WIB": "West-Indonesische tijd", "SGT": "Singaporese standaardtijd", "JST": "Japanse standaardtijd", "EST": "Eastern-standaardtijd", "TMT": "Turkmeense standaardtijd", "MST": "Macause standaardtijd", "ARST": "Argentijnse zomertijd", "∅∅∅": "Acre-zomertijd", "BT": "Bhutaanse tijd", "HNPM": "Saint Pierre en Miquelon-standaardtijd", "HEOG": "West-Groenlandse zomertijd", "AST": "Atlantic-standaardtijd", "OESZ": "Oost-Europese zomertijd", "ECT": "Ecuadoraanse tijd", "NZDT": "Nieuw-Zeelandse zomertijd", "WEZ": "West-Europese standaardtijd", "HNOG": "West-Groenlandse standaardtijd", "MEZ": "Midden-Europese standaardtijd", "AKST": "Alaska-standaardtijd", "EAT": "Oost-Afrikaanse tijd", "CDT": "Central-zomertijd", "PDT": "Pacific-zomertijd", "NZST": "Nieuw-Zeelandse standaardtijd", "CAT": "Centraal-Afrikaanse tijd", "VET": "Venezolaanse tijd", "HEPM": "Saint Pierre en Miquelon-zomertijd", "LHDT": "Lord Howe-eilandse zomertijd", "HECU": "Cubaanse zomertijd", "BOT": "Boliviaanse tijd", "HAST": "Hawaii-Aleoetische standaardtijd", "COT": "Colombiaanse standaardtijd", "HNEG": "Oost-Groenlandse standaardtijd", "WAST": "West-Afrikaanse zomertijd", "ChST": "Chamorro-tijd", "UYST": "Uruguayaanse zomertijd", "AWDT": "West-Australische zomertijd", "ACWST": "Midden-Australische westelijke standaardtijd", "WART": "West-Argentijnse standaardtijd", "CLT": "Chileense standaardtijd", "HEEG": "Oost-Groenlandse zomertijd", "IST": "Indiase tijd", "COST": "Colombiaanse zomertijd", "MESZ": "Midden-Europese zomertijd", "HNNOMX": "Noordwest-Mexicaanse standaardtijd", "HKST": "Hongkongse zomertijd", "HNT": "Newfoundland-standaardtijd", "GFT": "Frans-Guyaanse tijd", "SAST": "Zuid-Afrikaanse tijd", "LHST": "Lord Howe-eilandse standaardtijd", "ART": "Argentijnse standaardtijd", "HKT": "Hongkongse standaardtijd"}, + } +} + +// Locale returns the current translators string locale +func (nl *nl_BE) Locale() string { + return nl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nl_BE' +func (nl *nl_BE) PluralsCardinal() []locales.PluralRule { + return nl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nl_BE' +func (nl *nl_BE) PluralsOrdinal() []locales.PluralRule { + return nl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nl_BE' +func (nl *nl_BE) PluralsRange() []locales.PluralRule { + return nl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nl_BE' +func (nl *nl_BE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nl_BE' +func (nl *nl_BE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nl_BE' +func (nl *nl_BE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := nl.CardinalPluralRule(num1, v1) + end := nl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nl *nl_BE) MonthAbbreviated(month time.Month) string { + return nl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nl *nl_BE) MonthsAbbreviated() []string { + return nl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nl *nl_BE) MonthNarrow(month time.Month) string { + return nl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nl *nl_BE) MonthsNarrow() []string { + return nl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nl *nl_BE) MonthWide(month time.Month) string { + return nl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nl *nl_BE) MonthsWide() []string { + return nl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nl *nl_BE) WeekdayAbbreviated(weekday time.Weekday) string { + return nl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nl *nl_BE) WeekdaysAbbreviated() []string { + return nl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nl *nl_BE) WeekdayNarrow(weekday time.Weekday) string { + return nl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nl *nl_BE) WeekdaysNarrow() []string { + return nl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nl *nl_BE) WeekdayShort(weekday time.Weekday) string { + return nl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nl *nl_BE) WeekdaysShort() []string { + return nl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nl *nl_BE) WeekdayWide(weekday time.Weekday) string { + return nl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nl *nl_BE) WeekdaysWide() []string { + return nl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nl_BE' and handles both Whole and Real numbers based on 'v' +func (nl *nl_BE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nl_BE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nl *nl_BE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nl.percentSuffix...) + + b = append(b, nl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nl_BE' +func (nl *nl_BE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nl_BE' +// in accounting notation. +func (nl *nl_BE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nl_BE' +func (nl *nl_BE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nl_BE' +func (nl *nl_BE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nl_BE' +func (nl *nl_BE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nl_BE' +func (nl *nl_BE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nl_BE' +func (nl *nl_BE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nl_BE' +func (nl *nl_BE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nl_BE' +func (nl *nl_BE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nl_BE' +func (nl *nl_BE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nl_BE/nl_BE_test.go b/vendor/github.com/go-playground/locales/nl_BE/nl_BE_test.go new file mode 100644 index 0000000000..584cc643e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_BE/nl_BE_test.go @@ -0,0 +1,1120 @@ +package nl_BE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nl_BE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nl_BQ/nl_BQ.go b/vendor/github.com/go-playground/locales/nl_BQ/nl_BQ.go new file mode 100644 index 0000000000..61ed573175 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_BQ/nl_BQ.go @@ -0,0 +1,604 @@ +package nl_BQ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nl_BQ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nl_BQ' locale +func New() locales.Translator { + return &nl_BQ{ + locale: "nl_BQ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysNarrow: []string{"Z", "M", "D", "W", "D", "V", "Z"}, + daysShort: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysWide: []string{"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"WIB": "West-Indonesische tijd", "CST": "Central-standaardtijd", "SGT": "Singaporese standaardtijd", "CAT": "Centraal-Afrikaanse tijd", "ACWDT": "Midden-Australische westelijke zomertijd", "ACDT": "Midden-Australische zomertijd", "SRT": "Surinaamse tijd", "ACST": "Midden-Australische standaardtijd", "AEDT": "Oost-Australische zomertijd", "WITA": "Centraal-Indonesische tijd", "AKDT": "Alaska-zomertijd", "CDT": "Central-zomertijd", "HEPMX": "Mexicaanse Pacific-zomertijd", "HECU": "Cubaanse zomertijd", "WART": "West-Argentijnse standaardtijd", "HEOG": "West-Groenlandse zomertijd", "WEZ": "West-Europese standaardtijd", "MST": "Macause standaardtijd", "EDT": "Eastern-zomertijd", "SAST": "Zuid-Afrikaanse tijd", "HNNOMX": "Noordwest-Mexicaanse standaardtijd", "JDT": "Japanse zomertijd", "HKT": "Hongkongse standaardtijd", "JST": "Japanse standaardtijd", "BT": "Bhutaanse tijd", "HAT": "Newfoundland-zomertijd", "UYST": "Uruguayaanse zomertijd", "NZDT": "Nieuw-Zeelandse zomertijd", "HNOG": "West-Groenlandse standaardtijd", "AST": "Atlantic-standaardtijd", "OEZ": "Oost-Europese standaardtijd", "LHST": "Lord Howe-eilandse standaardtijd", "HNPMX": "Mexicaanse Pacific-standaardtijd", "AWST": "West-Australische standaardtijd", "CLST": "Chileense zomertijd", "WESZ": "West-Europese zomertijd", "ART": "Argentijnse standaardtijd", "COT": "Colombiaanse standaardtijd", "HNT": "Newfoundland-standaardtijd", "∅∅∅": "Azoren-zomertijd", "GFT": "Frans-Guyaanse tijd", "GMT": "Greenwich Mean Time", "HENOMX": "Noordwest-Mexicaanse zomertijd", "HAST": "Hawaii-Aleoetische standaardtijd", "CHAST": "Chatham-standaardtijd", "ACWST": "Midden-Australische westelijke standaardtijd", "MYT": "Maleisische tijd", "ARST": "Argentijnse zomertijd", "EST": "Eastern-standaardtijd", "AKST": "Alaska-standaardtijd", "GYT": "Guyaanse tijd", "BOT": "Boliviaanse tijd", "IST": "Indiase tijd", "MESZ": "Midden-Europese zomertijd", "WARST": "West-Argentijnse zomertijd", "WAT": "West-Afrikaanse standaardtijd", "HNPM": "Saint Pierre en Miquelon-standaardtijd", "WIT": "Oost-Indonesische tijd", "NZST": "Nieuw-Zeelandse standaardtijd", "HNCU": "Cubaanse standaardtijd", "ECT": "Ecuadoraanse tijd", "HKST": "Hongkongse zomertijd", "COST": "Colombiaanse zomertijd", "HEEG": "Oost-Groenlandse zomertijd", "LHDT": "Lord Howe-eilandse zomertijd", "HADT": "Hawaii-Aleoetische zomertijd", "VET": "Venezolaanse tijd", "OESZ": "Oost-Europese zomertijd", "TMT": "Turkmeense standaardtijd", "AWDT": "West-Australische zomertijd", "PDT": "Pacific-zomertijd", "WAST": "West-Afrikaanse zomertijd", "PST": "Pacific-standaardtijd", "MEZ": "Midden-Europese standaardtijd", "CLT": "Chileense standaardtijd", "TMST": "Turkmeense zomertijd", "MDT": "Macause zomertijd", "HNEG": "Oost-Groenlandse standaardtijd", "AEST": "Oost-Australische standaardtijd", "UYT": "Uruguayaanse standaardtijd", "CHADT": "Chatham-zomertijd", "HEPM": "Saint Pierre en Miquelon-zomertijd", "ADT": "Atlantic-zomertijd", "ChST": "Chamorro-tijd", "EAT": "Oost-Afrikaanse tijd"}, + } +} + +// Locale returns the current translators string locale +func (nl *nl_BQ) Locale() string { + return nl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nl_BQ' +func (nl *nl_BQ) PluralsCardinal() []locales.PluralRule { + return nl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nl_BQ' +func (nl *nl_BQ) PluralsOrdinal() []locales.PluralRule { + return nl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nl_BQ' +func (nl *nl_BQ) PluralsRange() []locales.PluralRule { + return nl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nl_BQ' +func (nl *nl_BQ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nl_BQ' +func (nl *nl_BQ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nl_BQ' +func (nl *nl_BQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := nl.CardinalPluralRule(num1, v1) + end := nl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nl *nl_BQ) MonthAbbreviated(month time.Month) string { + return nl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nl *nl_BQ) MonthsAbbreviated() []string { + return nl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nl *nl_BQ) MonthNarrow(month time.Month) string { + return nl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nl *nl_BQ) MonthsNarrow() []string { + return nl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nl *nl_BQ) MonthWide(month time.Month) string { + return nl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nl *nl_BQ) MonthsWide() []string { + return nl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nl *nl_BQ) WeekdayAbbreviated(weekday time.Weekday) string { + return nl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nl *nl_BQ) WeekdaysAbbreviated() []string { + return nl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nl *nl_BQ) WeekdayNarrow(weekday time.Weekday) string { + return nl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nl *nl_BQ) WeekdaysNarrow() []string { + return nl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nl *nl_BQ) WeekdayShort(weekday time.Weekday) string { + return nl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nl *nl_BQ) WeekdaysShort() []string { + return nl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nl *nl_BQ) WeekdayWide(weekday time.Weekday) string { + return nl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nl *nl_BQ) WeekdaysWide() []string { + return nl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nl_BQ' and handles both Whole and Real numbers based on 'v' +func (nl *nl_BQ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nl_BQ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nl *nl_BQ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nl.percentSuffix...) + + b = append(b, nl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nl_BQ' +func (nl *nl_BQ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nl_BQ' +// in accounting notation. +func (nl *nl_BQ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nl_BQ' +func (nl *nl_BQ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nl_BQ' +func (nl *nl_BQ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nl_BQ' +func (nl *nl_BQ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nl_BQ' +func (nl *nl_BQ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nl_BQ' +func (nl *nl_BQ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nl_BQ' +func (nl *nl_BQ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nl_BQ' +func (nl *nl_BQ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nl_BQ' +func (nl *nl_BQ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nl_BQ/nl_BQ_test.go b/vendor/github.com/go-playground/locales/nl_BQ/nl_BQ_test.go new file mode 100644 index 0000000000..fc9b52fc35 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_BQ/nl_BQ_test.go @@ -0,0 +1,1120 @@ +package nl_BQ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nl_BQ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nl_CW/nl_CW.go b/vendor/github.com/go-playground/locales/nl_CW/nl_CW.go new file mode 100644 index 0000000000..a9b99504db --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_CW/nl_CW.go @@ -0,0 +1,604 @@ +package nl_CW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nl_CW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nl_CW' locale +func New() locales.Translator { + return &nl_CW{ + locale: "nl_CW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "NAf.", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysNarrow: []string{"Z", "M", "D", "W", "D", "V", "Z"}, + daysShort: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysWide: []string{"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"EST": "Eastern-standaardtijd", "SRT": "Surinaamse tijd", "MDT": "Macause zomertijd", "HNNOMX": "Noordwest-Mexicaanse standaardtijd", "ChST": "Chamorro-tijd", "JDT": "Japanse zomertijd", "OESZ": "Oost-Europese zomertijd", "HEOG": "West-Groenlandse zomertijd", "TMT": "Turkmeense standaardtijd", "SGT": "Singaporese standaardtijd", "GMT": "Greenwich Mean Time", "MYT": "Maleisische tijd", "ACDT": "Midden-Australische zomertijd", "WITA": "Centraal-Indonesische tijd", "HEPMX": "Mexicaanse Pacific-zomertijd", "BOT": "Boliviaanse tijd", "ACWST": "Midden-Australische westelijke standaardtijd", "HNOG": "West-Groenlandse standaardtijd", "WAST": "West-Afrikaanse zomertijd", "AEST": "Oost-Australische standaardtijd", "HAST": "Hawaii-Aleoetische standaardtijd", "UYST": "Uruguayaanse zomertijd", "HEPM": "Saint Pierre en Miquelon-zomertijd", "EAT": "Oost-Afrikaanse tijd", "HNPM": "Saint Pierre en Miquelon-standaardtijd", "CST": "Central-standaardtijd", "HADT": "Hawaii-Aleoetische zomertijd", "COST": "Colombiaanse zomertijd", "HEEG": "Oost-Groenlandse zomertijd", "GFT": "Frans-Guyaanse tijd", "UYT": "Uruguayaanse standaardtijd", "LHDT": "Lord Howe-eilandse zomertijd", "WIB": "West-Indonesische tijd", "PST": "Pacific-standaardtijd", "JST": "Japanse standaardtijd", "WARST": "West-Argentijnse zomertijd", "MST": "Macause standaardtijd", "AEDT": "Oost-Australische zomertijd", "MEZ": "Midden-Europese standaardtijd", "CDT": "Central-zomertijd", "OEZ": "Oost-Europese standaardtijd", "GYT": "Guyaanse tijd", "HNCU": "Cubaanse standaardtijd", "PDT": "Pacific-zomertijd", "ECT": "Ecuadoraanse tijd", "NZST": "Nieuw-Zeelandse standaardtijd", "AKST": "Alaska-standaardtijd", "WEZ": "West-Europese standaardtijd", "WART": "West-Argentijnse standaardtijd", "CLST": "Chileense zomertijd", "HENOMX": "Noordwest-Mexicaanse zomertijd", "HAT": "Newfoundland-zomertijd", "BT": "Bhutaanse tijd", "HECU": "Cubaanse zomertijd", "NZDT": "Nieuw-Zeelandse zomertijd", "ADT": "Atlantic-zomertijd", "EDT": "Eastern-zomertijd", "COT": "Colombiaanse standaardtijd", "CAT": "Centraal-Afrikaanse tijd", "VET": "Venezolaanse tijd", "AST": "Atlantic-standaardtijd", "WIT": "Oost-Indonesische tijd", "AWST": "West-Australische standaardtijd", "∅∅∅": "Acre-zomertijd", "CHADT": "Chatham-zomertijd", "TMST": "Turkmeense zomertijd", "HKT": "Hongkongse standaardtijd", "HKST": "Hongkongse zomertijd", "HNEG": "Oost-Groenlandse standaardtijd", "ACWDT": "Midden-Australische westelijke zomertijd", "SAST": "Zuid-Afrikaanse tijd", "AWDT": "West-Australische zomertijd", "CHAST": "Chatham-standaardtijd", "IST": "Indiase tijd", "MESZ": "Midden-Europese zomertijd", "WESZ": "West-Europese zomertijd", "ART": "Argentijnse standaardtijd", "WAT": "West-Afrikaanse standaardtijd", "HNT": "Newfoundland-standaardtijd", "AKDT": "Alaska-zomertijd", "LHST": "Lord Howe-eilandse standaardtijd", "HNPMX": "Mexicaanse Pacific-standaardtijd", "CLT": "Chileense standaardtijd", "ARST": "Argentijnse zomertijd", "ACST": "Midden-Australische standaardtijd"}, + } +} + +// Locale returns the current translators string locale +func (nl *nl_CW) Locale() string { + return nl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nl_CW' +func (nl *nl_CW) PluralsCardinal() []locales.PluralRule { + return nl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nl_CW' +func (nl *nl_CW) PluralsOrdinal() []locales.PluralRule { + return nl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nl_CW' +func (nl *nl_CW) PluralsRange() []locales.PluralRule { + return nl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nl_CW' +func (nl *nl_CW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nl_CW' +func (nl *nl_CW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nl_CW' +func (nl *nl_CW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := nl.CardinalPluralRule(num1, v1) + end := nl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nl *nl_CW) MonthAbbreviated(month time.Month) string { + return nl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nl *nl_CW) MonthsAbbreviated() []string { + return nl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nl *nl_CW) MonthNarrow(month time.Month) string { + return nl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nl *nl_CW) MonthsNarrow() []string { + return nl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nl *nl_CW) MonthWide(month time.Month) string { + return nl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nl *nl_CW) MonthsWide() []string { + return nl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nl *nl_CW) WeekdayAbbreviated(weekday time.Weekday) string { + return nl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nl *nl_CW) WeekdaysAbbreviated() []string { + return nl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nl *nl_CW) WeekdayNarrow(weekday time.Weekday) string { + return nl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nl *nl_CW) WeekdaysNarrow() []string { + return nl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nl *nl_CW) WeekdayShort(weekday time.Weekday) string { + return nl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nl *nl_CW) WeekdaysShort() []string { + return nl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nl *nl_CW) WeekdayWide(weekday time.Weekday) string { + return nl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nl *nl_CW) WeekdaysWide() []string { + return nl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nl_CW' and handles both Whole and Real numbers based on 'v' +func (nl *nl_CW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nl_CW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nl *nl_CW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nl.percentSuffix...) + + b = append(b, nl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nl_CW' +func (nl *nl_CW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nl_CW' +// in accounting notation. +func (nl *nl_CW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nl_CW' +func (nl *nl_CW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nl_CW' +func (nl *nl_CW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nl_CW' +func (nl *nl_CW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nl_CW' +func (nl *nl_CW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nl_CW' +func (nl *nl_CW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nl_CW' +func (nl *nl_CW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nl_CW' +func (nl *nl_CW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nl_CW' +func (nl *nl_CW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nl_CW/nl_CW_test.go b/vendor/github.com/go-playground/locales/nl_CW/nl_CW_test.go new file mode 100644 index 0000000000..dd86e21de0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_CW/nl_CW_test.go @@ -0,0 +1,1120 @@ +package nl_CW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nl_CW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nl_NL/nl_NL.go b/vendor/github.com/go-playground/locales/nl_NL/nl_NL.go new file mode 100644 index 0000000000..6ad7bf8950 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_NL/nl_NL.go @@ -0,0 +1,604 @@ +package nl_NL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nl_NL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nl_NL' locale +func New() locales.Translator { + return &nl_NL{ + locale: "nl_NL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysNarrow: []string{"Z", "M", "D", "W", "D", "V", "Z"}, + daysShort: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysWide: []string{"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"MDT": "Macause zomertijd", "HNNOMX": "Noordwest-Mexicaanse standaardtijd", "ChST": "Chamorro-tijd", "AWDT": "West-Australische zomertijd", "CHADT": "Chatham-zomertijd", "HADT": "Hawaii-Aleoetische zomertijd", "JST": "Japanse standaardtijd", "WIT": "Oost-Indonesische tijd", "∅∅∅": "Amazone-zomertijd", "WARST": "West-Argentijnse zomertijd", "MST": "Macause standaardtijd", "EDT": "Eastern-zomertijd", "AKST": "Alaska-standaardtijd", "ACWDT": "Midden-Australische westelijke zomertijd", "ARST": "Argentijnse zomertijd", "WIB": "West-Indonesische tijd", "AWST": "West-Australische standaardtijd", "AST": "Atlantic-standaardtijd", "HNCU": "Cubaanse standaardtijd", "HAT": "Newfoundland-zomertijd", "SGT": "Singaporese standaardtijd", "CAT": "Centraal-Afrikaanse tijd", "HKT": "Hongkongse standaardtijd", "HNEG": "Oost-Groenlandse standaardtijd", "AKDT": "Alaska-zomertijd", "HEPM": "Saint Pierre en Miquelon-zomertijd", "NZDT": "Nieuw-Zeelandse zomertijd", "EST": "Eastern-standaardtijd", "TMST": "Turkmeense zomertijd", "ART": "Argentijnse standaardtijd", "HENOMX": "Noordwest-Mexicaanse zomertijd", "HEPMX": "Mexicaanse Pacific-zomertijd", "CDT": "Central-zomertijd", "ECT": "Ecuadoraanse tijd", "WESZ": "West-Europese zomertijd", "HEEG": "Oost-Groenlandse zomertijd", "AEST": "Oost-Australische standaardtijd", "ACDT": "Midden-Australische zomertijd", "HNT": "Newfoundland-standaardtijd", "COT": "Colombiaanse standaardtijd", "BT": "Bhutaanse tijd", "WITA": "Centraal-Indonesische tijd", "SRT": "Surinaamse tijd", "GYT": "Guyaanse tijd", "HECU": "Cubaanse zomertijd", "PST": "Pacific-standaardtijd", "MEZ": "Midden-Europese standaardtijd", "MYT": "Maleisische tijd", "WAT": "West-Afrikaanse standaardtijd", "HNPM": "Saint Pierre en Miquelon-standaardtijd", "LHST": "Lord Howe-eilandse standaardtijd", "LHDT": "Lord Howe-eilandse zomertijd", "HNPMX": "Mexicaanse Pacific-standaardtijd", "IST": "Indiase tijd", "MESZ": "Midden-Europese zomertijd", "WEZ": "West-Europese standaardtijd", "CLT": "Chileense standaardtijd", "HEOG": "West-Groenlandse zomertijd", "TMT": "Turkmeense standaardtijd", "WAST": "West-Afrikaanse zomertijd", "UYST": "Uruguayaanse zomertijd", "ACWST": "Midden-Australische westelijke standaardtijd", "NZST": "Nieuw-Zeelandse standaardtijd", "EAT": "Oost-Afrikaanse tijd", "CST": "Central-standaardtijd", "SAST": "Zuid-Afrikaanse tijd", "ACST": "Midden-Australische standaardtijd", "GFT": "Frans-Guyaanse tijd", "BOT": "Boliviaanse tijd", "CHAST": "Chatham-standaardtijd", "ADT": "Atlantic-zomertijd", "AEDT": "Oost-Australische zomertijd", "VET": "Venezolaanse tijd", "OEZ": "Oost-Europese standaardtijd", "UYT": "Uruguayaanse standaardtijd", "PDT": "Pacific-zomertijd", "HAST": "Hawaii-Aleoetische standaardtijd", "HNOG": "West-Groenlandse standaardtijd", "GMT": "Greenwich Mean Time", "WART": "West-Argentijnse standaardtijd", "CLST": "Chileense zomertijd", "HKST": "Hongkongse zomertijd", "COST": "Colombiaanse zomertijd", "JDT": "Japanse zomertijd", "OESZ": "Oost-Europese zomertijd"}, + } +} + +// Locale returns the current translators string locale +func (nl *nl_NL) Locale() string { + return nl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nl_NL' +func (nl *nl_NL) PluralsCardinal() []locales.PluralRule { + return nl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nl_NL' +func (nl *nl_NL) PluralsOrdinal() []locales.PluralRule { + return nl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nl_NL' +func (nl *nl_NL) PluralsRange() []locales.PluralRule { + return nl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nl_NL' +func (nl *nl_NL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nl_NL' +func (nl *nl_NL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nl_NL' +func (nl *nl_NL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := nl.CardinalPluralRule(num1, v1) + end := nl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nl *nl_NL) MonthAbbreviated(month time.Month) string { + return nl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nl *nl_NL) MonthsAbbreviated() []string { + return nl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nl *nl_NL) MonthNarrow(month time.Month) string { + return nl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nl *nl_NL) MonthsNarrow() []string { + return nl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nl *nl_NL) MonthWide(month time.Month) string { + return nl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nl *nl_NL) MonthsWide() []string { + return nl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nl *nl_NL) WeekdayAbbreviated(weekday time.Weekday) string { + return nl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nl *nl_NL) WeekdaysAbbreviated() []string { + return nl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nl *nl_NL) WeekdayNarrow(weekday time.Weekday) string { + return nl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nl *nl_NL) WeekdaysNarrow() []string { + return nl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nl *nl_NL) WeekdayShort(weekday time.Weekday) string { + return nl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nl *nl_NL) WeekdaysShort() []string { + return nl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nl *nl_NL) WeekdayWide(weekday time.Weekday) string { + return nl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nl *nl_NL) WeekdaysWide() []string { + return nl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nl_NL' and handles both Whole and Real numbers based on 'v' +func (nl *nl_NL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nl_NL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nl *nl_NL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nl.percentSuffix...) + + b = append(b, nl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nl_NL' +func (nl *nl_NL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nl_NL' +// in accounting notation. +func (nl *nl_NL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nl_NL' +func (nl *nl_NL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nl_NL' +func (nl *nl_NL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nl_NL' +func (nl *nl_NL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nl_NL' +func (nl *nl_NL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nl_NL' +func (nl *nl_NL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nl_NL' +func (nl *nl_NL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nl_NL' +func (nl *nl_NL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nl_NL' +func (nl *nl_NL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nl_NL/nl_NL_test.go b/vendor/github.com/go-playground/locales/nl_NL/nl_NL_test.go new file mode 100644 index 0000000000..63fbdf3ec4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_NL/nl_NL_test.go @@ -0,0 +1,1120 @@ +package nl_NL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nl_NL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nl_SR/nl_SR.go b/vendor/github.com/go-playground/locales/nl_SR/nl_SR.go new file mode 100644 index 0000000000..b2f6cddc79 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_SR/nl_SR.go @@ -0,0 +1,604 @@ +package nl_SR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nl_SR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nl_SR' locale +func New() locales.Translator { + return &nl_SR{ + locale: "nl_SR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "$", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysNarrow: []string{"Z", "M", "D", "W", "D", "V", "Z"}, + daysShort: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysWide: []string{"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"JDT": "Japanse zomertijd", "HKST": "Hongkongse zomertijd", "GYT": "Guyaanse tijd", "HNCU": "Cubaanse standaardtijd", "HECU": "Cubaanse zomertijd", "OEZ": "Oost-Europese standaardtijd", "HNOG": "West-Groenlandse standaardtijd", "WIB": "West-Indonesische tijd", "HAST": "Hawaii-Aleoetische standaardtijd", "WESZ": "West-Europese zomertijd", "MYT": "Maleisische tijd", "ART": "Argentijnse standaardtijd", "COT": "Colombiaanse standaardtijd", "HNNOMX": "Noordwest-Mexicaanse standaardtijd", "AWDT": "West-Australische zomertijd", "ACST": "Midden-Australische standaardtijd", "LHST": "Lord Howe-eilandse standaardtijd", "LHDT": "Lord Howe-eilandse zomertijd", "HNPMX": "Mexicaanse Pacific-standaardtijd", "∅∅∅": "Azoren-zomertijd", "ADT": "Atlantic-zomertijd", "AKDT": "Alaska-zomertijd", "GFT": "Frans-Guyaanse tijd", "SAST": "Zuid-Afrikaanse tijd", "CHAST": "Chatham-standaardtijd", "PDT": "Pacific-zomertijd", "HADT": "Hawaii-Aleoetische zomertijd", "WARST": "West-Argentijnse zomertijd", "WAST": "West-Afrikaanse zomertijd", "AEDT": "Oost-Australische zomertijd", "UYT": "Uruguayaanse standaardtijd", "CHADT": "Chatham-zomertijd", "CAT": "Centraal-Afrikaanse tijd", "ACWDT": "Midden-Australische westelijke zomertijd", "WEZ": "West-Europese standaardtijd", "HEEG": "Oost-Groenlandse zomertijd", "HEPMX": "Mexicaanse Pacific-zomertijd", "SRT": "Surinaamse tijd", "BOT": "Boliviaanse tijd", "PST": "Pacific-standaardtijd", "GMT": "Greenwich Mean Time", "HEOG": "West-Groenlandse zomertijd", "BT": "Bhutaanse tijd", "EAT": "Oost-Afrikaanse tijd", "SGT": "Singaporese standaardtijd", "ACWST": "Midden-Australische westelijke standaardtijd", "AKST": "Alaska-standaardtijd", "CST": "Central-standaardtijd", "CLT": "Chileense standaardtijd", "MST": "Macause standaardtijd", "MDT": "Macause zomertijd", "EDT": "Eastern-zomertijd", "HENOMX": "Noordwest-Mexicaanse zomertijd", "CDT": "Central-zomertijd", "WIT": "Oost-Indonesische tijd", "WART": "West-Argentijnse standaardtijd", "COST": "Colombiaanse zomertijd", "HNPM": "Saint Pierre en Miquelon-standaardtijd", "ACDT": "Midden-Australische zomertijd", "HEPM": "Saint Pierre en Miquelon-zomertijd", "HNT": "Newfoundland-standaardtijd", "AWST": "West-Australische standaardtijd", "ECT": "Ecuadoraanse tijd", "IST": "Indiase tijd", "NZST": "Nieuw-Zeelandse standaardtijd", "AST": "Atlantic-standaardtijd", "OESZ": "Oost-Europese zomertijd", "TMST": "Turkmeense zomertijd", "HNEG": "Oost-Groenlandse standaardtijd", "NZDT": "Nieuw-Zeelandse zomertijd", "MESZ": "Midden-Europese zomertijd", "WAT": "West-Afrikaanse standaardtijd", "UYST": "Uruguayaanse zomertijd", "VET": "Venezolaanse tijd", "JST": "Japanse standaardtijd", "ARST": "Argentijnse zomertijd", "HAT": "Newfoundland-zomertijd", "AEST": "Oost-Australische standaardtijd", "MEZ": "Midden-Europese standaardtijd", "CLST": "Chileense zomertijd", "TMT": "Turkmeense standaardtijd", "EST": "Eastern-standaardtijd", "HKT": "Hongkongse standaardtijd", "WITA": "Centraal-Indonesische tijd", "ChST": "Chamorro-tijd"}, + } +} + +// Locale returns the current translators string locale +func (nl *nl_SR) Locale() string { + return nl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nl_SR' +func (nl *nl_SR) PluralsCardinal() []locales.PluralRule { + return nl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nl_SR' +func (nl *nl_SR) PluralsOrdinal() []locales.PluralRule { + return nl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nl_SR' +func (nl *nl_SR) PluralsRange() []locales.PluralRule { + return nl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nl_SR' +func (nl *nl_SR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nl_SR' +func (nl *nl_SR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nl_SR' +func (nl *nl_SR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := nl.CardinalPluralRule(num1, v1) + end := nl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nl *nl_SR) MonthAbbreviated(month time.Month) string { + return nl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nl *nl_SR) MonthsAbbreviated() []string { + return nl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nl *nl_SR) MonthNarrow(month time.Month) string { + return nl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nl *nl_SR) MonthsNarrow() []string { + return nl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nl *nl_SR) MonthWide(month time.Month) string { + return nl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nl *nl_SR) MonthsWide() []string { + return nl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nl *nl_SR) WeekdayAbbreviated(weekday time.Weekday) string { + return nl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nl *nl_SR) WeekdaysAbbreviated() []string { + return nl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nl *nl_SR) WeekdayNarrow(weekday time.Weekday) string { + return nl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nl *nl_SR) WeekdaysNarrow() []string { + return nl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nl *nl_SR) WeekdayShort(weekday time.Weekday) string { + return nl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nl *nl_SR) WeekdaysShort() []string { + return nl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nl *nl_SR) WeekdayWide(weekday time.Weekday) string { + return nl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nl *nl_SR) WeekdaysWide() []string { + return nl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nl_SR' and handles both Whole and Real numbers based on 'v' +func (nl *nl_SR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nl_SR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nl *nl_SR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nl.percentSuffix...) + + b = append(b, nl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nl_SR' +func (nl *nl_SR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nl_SR' +// in accounting notation. +func (nl *nl_SR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nl_SR' +func (nl *nl_SR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nl_SR' +func (nl *nl_SR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nl_SR' +func (nl *nl_SR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nl_SR' +func (nl *nl_SR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nl_SR' +func (nl *nl_SR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nl_SR' +func (nl *nl_SR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nl_SR' +func (nl *nl_SR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nl_SR' +func (nl *nl_SR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nl_SR/nl_SR_test.go b/vendor/github.com/go-playground/locales/nl_SR/nl_SR_test.go new file mode 100644 index 0000000000..b4b7d8f988 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_SR/nl_SR_test.go @@ -0,0 +1,1120 @@ +package nl_SR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nl_SR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nl_SX/nl_SX.go b/vendor/github.com/go-playground/locales/nl_SX/nl_SX.go new file mode 100644 index 0000000000..463bb50fa0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_SX/nl_SX.go @@ -0,0 +1,604 @@ +package nl_SX + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nl_SX struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nl_SX' locale +func New() locales.Translator { + return &nl_SX{ + locale: "nl_SX", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "NAf.", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysNarrow: []string{"Z", "M", "D", "W", "D", "V", "Z"}, + daysShort: []string{"zo", "ma", "di", "wo", "do", "vr", "za"}, + daysWide: []string{"zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"v.Chr.", "n.Chr."}, + erasNarrow: []string{"v.C.", "n.C."}, + erasWide: []string{"voor Christus", "na Christus"}, + timezones: map[string]string{"AWST": "West-Australische standaardtijd", "ADT": "Atlantic-zomertijd", "MST": "Macause standaardtijd", "UYT": "Uruguayaanse standaardtijd", "∅∅∅": "Braziliaanse zomertijd", "IST": "Indiase tijd", "ACWST": "Midden-Australische westelijke standaardtijd", "HNOG": "West-Groenlandse standaardtijd", "ARST": "Argentijnse zomertijd", "COT": "Colombiaanse standaardtijd", "HECU": "Cubaanse zomertijd", "EST": "Eastern-standaardtijd", "EDT": "Eastern-zomertijd", "HNEG": "Oost-Groenlandse standaardtijd", "AEST": "Oost-Australische standaardtijd", "SRT": "Surinaamse tijd", "EAT": "Oost-Afrikaanse tijd", "WITA": "Centraal-Indonesische tijd", "ChST": "Chamorro-tijd", "HADT": "Hawaii-Aleoetische zomertijd", "MEZ": "Midden-Europese standaardtijd", "OESZ": "Oost-Europese zomertijd", "HKT": "Hongkongse standaardtijd", "ACST": "Midden-Australische standaardtijd", "ACDT": "Midden-Australische zomertijd", "UYST": "Uruguayaanse zomertijd", "HEPM": "Saint Pierre en Miquelon-zomertijd", "CHADT": "Chatham-zomertijd", "HAST": "Hawaii-Aleoetische standaardtijd", "WAT": "West-Afrikaanse standaardtijd", "COST": "Colombiaanse zomertijd", "HEEG": "Oost-Groenlandse zomertijd", "HEPMX": "Mexicaanse Pacific-zomertijd", "SGT": "Singaporese standaardtijd", "WEZ": "West-Europese standaardtijd", "CAT": "Centraal-Afrikaanse tijd", "JDT": "Japanse zomertijd", "GFT": "Frans-Guyaanse tijd", "HNCU": "Cubaanse standaardtijd", "WESZ": "West-Europese zomertijd", "GMT": "Greenwich Mean Time", "LHST": "Lord Howe-eilandse standaardtijd", "LHDT": "Lord Howe-eilandse zomertijd", "CDT": "Central-zomertijd", "CHAST": "Chatham-standaardtijd", "PST": "Pacific-standaardtijd", "PDT": "Pacific-zomertijd", "WAST": "West-Afrikaanse zomertijd", "HNNOMX": "Noordwest-Mexicaanse standaardtijd", "VET": "Venezolaanse tijd", "HEOG": "West-Groenlandse zomertijd", "AST": "Atlantic-standaardtijd", "MDT": "Macause zomertijd", "HNT": "Newfoundland-standaardtijd", "GYT": "Guyaanse tijd", "CST": "Central-standaardtijd", "WIT": "Oost-Indonesische tijd", "NZDT": "Nieuw-Zeelandse zomertijd", "JST": "Japanse standaardtijd", "WARST": "West-Argentijnse zomertijd", "ART": "Argentijnse standaardtijd", "ECT": "Ecuadoraanse tijd", "NZST": "Nieuw-Zeelandse standaardtijd", "CLT": "Chileense standaardtijd", "CLST": "Chileense zomertijd", "OEZ": "Oost-Europese standaardtijd", "TMT": "Turkmeense standaardtijd", "HKST": "Hongkongse zomertijd", "BT": "Bhutaanse tijd", "HNPM": "Saint Pierre en Miquelon-standaardtijd", "SAST": "Zuid-Afrikaanse tijd", "ACWDT": "Midden-Australische westelijke zomertijd", "HENOMX": "Noordwest-Mexicaanse zomertijd", "AKST": "Alaska-standaardtijd", "WIB": "West-Indonesische tijd", "HAT": "Newfoundland-zomertijd", "AEDT": "Oost-Australische zomertijd", "AWDT": "West-Australische zomertijd", "BOT": "Boliviaanse tijd", "MESZ": "Midden-Europese zomertijd", "MYT": "Maleisische tijd", "WART": "West-Argentijnse standaardtijd", "TMST": "Turkmeense zomertijd", "AKDT": "Alaska-zomertijd", "HNPMX": "Mexicaanse Pacific-standaardtijd"}, + } +} + +// Locale returns the current translators string locale +func (nl *nl_SX) Locale() string { + return nl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nl_SX' +func (nl *nl_SX) PluralsCardinal() []locales.PluralRule { + return nl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nl_SX' +func (nl *nl_SX) PluralsOrdinal() []locales.PluralRule { + return nl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nl_SX' +func (nl *nl_SX) PluralsRange() []locales.PluralRule { + return nl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nl_SX' +func (nl *nl_SX) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nl_SX' +func (nl *nl_SX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nl_SX' +func (nl *nl_SX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := nl.CardinalPluralRule(num1, v1) + end := nl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nl *nl_SX) MonthAbbreviated(month time.Month) string { + return nl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nl *nl_SX) MonthsAbbreviated() []string { + return nl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nl *nl_SX) MonthNarrow(month time.Month) string { + return nl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nl *nl_SX) MonthsNarrow() []string { + return nl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nl *nl_SX) MonthWide(month time.Month) string { + return nl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nl *nl_SX) MonthsWide() []string { + return nl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nl *nl_SX) WeekdayAbbreviated(weekday time.Weekday) string { + return nl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nl *nl_SX) WeekdaysAbbreviated() []string { + return nl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nl *nl_SX) WeekdayNarrow(weekday time.Weekday) string { + return nl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nl *nl_SX) WeekdaysNarrow() []string { + return nl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nl *nl_SX) WeekdayShort(weekday time.Weekday) string { + return nl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nl *nl_SX) WeekdaysShort() []string { + return nl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nl *nl_SX) WeekdayWide(weekday time.Weekday) string { + return nl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nl *nl_SX) WeekdaysWide() []string { + return nl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nl_SX' and handles both Whole and Real numbers based on 'v' +func (nl *nl_SX) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nl_SX' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nl *nl_SX) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nl.percentSuffix...) + + b = append(b, nl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nl_SX' +func (nl *nl_SX) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nl_SX' +// in accounting notation. +func (nl *nl_SX) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nl.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nl.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nl_SX' +func (nl *nl_SX) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nl_SX' +func (nl *nl_SX) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nl_SX' +func (nl *nl_SX) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nl_SX' +func (nl *nl_SX) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nl_SX' +func (nl *nl_SX) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nl_SX' +func (nl *nl_SX) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nl_SX' +func (nl *nl_SX) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nl_SX' +func (nl *nl_SX) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nl_SX/nl_SX_test.go b/vendor/github.com/go-playground/locales/nl_SX/nl_SX_test.go new file mode 100644 index 0000000000..a84896c50e --- /dev/null +++ b/vendor/github.com/go-playground/locales/nl_SX/nl_SX_test.go @@ -0,0 +1,1120 @@ +package nl_SX + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nl_SX" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nmg/nmg.go b/vendor/github.com/go-playground/locales/nmg/nmg.go new file mode 100644 index 0000000000..1f78ff4d00 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nmg/nmg.go @@ -0,0 +1,570 @@ +package nmg + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nmg struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nmg' locale +func New() locales.Translator { + return &nmg{ + locale: "nmg", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ng1", "ng2", "ng3", "ng4", "ng5", "ng6", "ng7", "ng8", "ng9", "ng10", "ng11", "kris"}, + monthsWide: []string{"", "ngwɛn matáhra", "ngwɛn ńmba", "ngwɛn ńlal", "ngwɛn ńna", "ngwɛn ńtan", "ngwɛn ńtuó", "ngwɛn hɛmbuɛrí", "ngwɛn lɔmbi", "ngwɛn rɛbvuâ", "ngwɛn wum", "ngwɛn wum navǔr", "krísimin"}, + daysAbbreviated: []string{"sɔ́n", "mɔ́n", "smb", "sml", "smn", "mbs", "sas"}, + daysNarrow: []string{"s", "m", "s", "s", "s", "m", "s"}, + daysWide: []string{"sɔ́ndɔ", "mɔ́ndɔ", "sɔ́ndɔ mafú mába", "sɔ́ndɔ mafú málal", "sɔ́ndɔ mafú mána", "mabágá má sukul", "sásadi"}, + periodsAbbreviated: []string{"maná", "kugú"}, + periodsWide: []string{"maná", "kugú"}, + erasAbbreviated: []string{"BL", "PB"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Bó Lahlɛ̄", "Pfiɛ Burī"}, + timezones: map[string]string{"AST": "AST", "HNPMX": "HNPMX", "SGT": "SGT", "CAT": "CAT", "CLT": "CLT", "SRT": "SRT", "HEOG": "HEOG", "OESZ": "OESZ", "AEST": "AEST", "AEDT": "AEDT", "AKDT": "AKDT", "HNCU": "HNCU", "WIT": "WIT", "MYT": "MYT", "IST": "IST", "MDT": "MDT", "HKST": "HKST", "COT": "COT", "OEZ": "OEZ", "MST": "MST", "HNPM": "HNPM", "CHADT": "CHADT", "ECT": "ECT", "MESZ": "MESZ", "JST": "JST", "CLST": "CLST", "WAST": "WAST", "HKT": "HKT", "HNNOMX": "HNNOMX", "HEEG": "HEEG", "EAT": "EAT", "CDT": "CDT", "CHAST": "CHAST", "TMST": "TMST", "HADT": "HADT", "NZDT": "NZDT", "ACWST": "ACWST", "HAST": "HAST", "LHDT": "LHDT", "ARST": "ARST", "HNOG": "HNOG", "COST": "COST", "∅∅∅": "∅∅∅", "WIB": "WIB", "PDT": "PDT", "GMT": "GMT", "BT": "BT", "HNT": "HNT", "HNEG": "HNEG", "BOT": "BOT", "JDT": "JDT", "WARST": "WARST", "ACDT": "ACDT", "GFT": "GFT", "HECU": "HECU", "AWST": "AWST", "NZST": "NZST", "TMT": "TMT", "ADT": "ADT", "WESZ": "WESZ", "EDT": "EDT", "AKST": "AKST", "WART": "WART", "HEPMX": "HEPMX", "MEZ": "MEZ", "SAST": "SAST", "ChST": "ChST", "CST": "CST", "WEZ": "WEZ", "EST": "EST", "UYT": "UYT", "ART": "ART", "ACST": "ACST", "HENOMX": "HENOMX", "HAT": "HAT", "WITA": "WITA", "UYST": "UYST", "HEPM": "HEPM", "LHST": "LHST", "WAT": "WAT", "AWDT": "AWDT", "PST": "PST", "ACWDT": "ACWDT", "VET": "VET", "GYT": "GYT"}, + } +} + +// Locale returns the current translators string locale +func (nmg *nmg) Locale() string { + return nmg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nmg' +func (nmg *nmg) PluralsCardinal() []locales.PluralRule { + return nmg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nmg' +func (nmg *nmg) PluralsOrdinal() []locales.PluralRule { + return nmg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nmg' +func (nmg *nmg) PluralsRange() []locales.PluralRule { + return nmg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nmg' +func (nmg *nmg) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nmg' +func (nmg *nmg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nmg' +func (nmg *nmg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nmg *nmg) MonthAbbreviated(month time.Month) string { + return nmg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nmg *nmg) MonthsAbbreviated() []string { + return nmg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nmg *nmg) MonthNarrow(month time.Month) string { + return nmg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nmg *nmg) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nmg *nmg) MonthWide(month time.Month) string { + return nmg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nmg *nmg) MonthsWide() []string { + return nmg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nmg *nmg) WeekdayAbbreviated(weekday time.Weekday) string { + return nmg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nmg *nmg) WeekdaysAbbreviated() []string { + return nmg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nmg *nmg) WeekdayNarrow(weekday time.Weekday) string { + return nmg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nmg *nmg) WeekdaysNarrow() []string { + return nmg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nmg *nmg) WeekdayShort(weekday time.Weekday) string { + return nmg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nmg *nmg) WeekdaysShort() []string { + return nmg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nmg *nmg) WeekdayWide(weekday time.Weekday) string { + return nmg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nmg *nmg) WeekdaysWide() []string { + return nmg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nmg' and handles both Whole and Real numbers based on 'v' +func (nmg *nmg) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nmg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nmg.group) - 1; j >= 0; j-- { + b = append(b, nmg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nmg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nmg' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nmg *nmg) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nmg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nmg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nmg.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nmg' +func (nmg *nmg) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nmg.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nmg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nmg.group) - 1; j >= 0; j-- { + b = append(b, nmg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nmg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nmg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nmg.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nmg' +// in accounting notation. +func (nmg *nmg) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nmg.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nmg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nmg.group) - 1; j >= 0; j-- { + b = append(b, nmg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nmg.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nmg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nmg.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nmg.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nmg' +func (nmg *nmg) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nmg' +func (nmg *nmg) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nmg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nmg' +func (nmg *nmg) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nmg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nmg' +func (nmg *nmg) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nmg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nmg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nmg' +func (nmg *nmg) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nmg' +func (nmg *nmg) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nmg' +func (nmg *nmg) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nmg' +func (nmg *nmg) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nmg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nmg/nmg_test.go b/vendor/github.com/go-playground/locales/nmg/nmg_test.go new file mode 100644 index 0000000000..4b83074585 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nmg/nmg_test.go @@ -0,0 +1,1120 @@ +package nmg + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nmg" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nmg_CM/nmg_CM.go b/vendor/github.com/go-playground/locales/nmg_CM/nmg_CM.go new file mode 100644 index 0000000000..ac5133e0ab --- /dev/null +++ b/vendor/github.com/go-playground/locales/nmg_CM/nmg_CM.go @@ -0,0 +1,570 @@ +package nmg_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nmg_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nmg_CM' locale +func New() locales.Translator { + return &nmg_CM{ + locale: "nmg_CM", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ng1", "ng2", "ng3", "ng4", "ng5", "ng6", "ng7", "ng8", "ng9", "ng10", "ng11", "kris"}, + monthsWide: []string{"", "ngwɛn matáhra", "ngwɛn ńmba", "ngwɛn ńlal", "ngwɛn ńna", "ngwɛn ńtan", "ngwɛn ńtuó", "ngwɛn hɛmbuɛrí", "ngwɛn lɔmbi", "ngwɛn rɛbvuâ", "ngwɛn wum", "ngwɛn wum navǔr", "krísimin"}, + daysAbbreviated: []string{"sɔ́n", "mɔ́n", "smb", "sml", "smn", "mbs", "sas"}, + daysNarrow: []string{"s", "m", "s", "s", "s", "m", "s"}, + daysWide: []string{"sɔ́ndɔ", "mɔ́ndɔ", "sɔ́ndɔ mafú mába", "sɔ́ndɔ mafú málal", "sɔ́ndɔ mafú mána", "mabágá má sukul", "sásadi"}, + periodsAbbreviated: []string{"maná", "kugú"}, + periodsWide: []string{"maná", "kugú"}, + erasAbbreviated: []string{"BL", "PB"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Bó Lahlɛ̄", "Pfiɛ Burī"}, + timezones: map[string]string{"OEZ": "OEZ", "OESZ": "OESZ", "HNPMX": "HNPMX", "PDT": "PDT", "WART": "WART", "WARST": "WARST", "ACST": "ACST", "CHADT": "CHADT", "CAT": "CAT", "ACWDT": "ACWDT", "PST": "PST", "ACWST": "ACWST", "VET": "VET", "HNOG": "HNOG", "TMT": "TMT", "HNPM": "HNPM", "HNCU": "HNCU", "ECT": "ECT", "MEZ": "MEZ", "COT": "COT", "HNNOMX": "HNNOMX", "AKDT": "AKDT", "AEDT": "AEDT", "∅∅∅": "∅∅∅", "CST": "CST", "CHAST": "CHAST", "EAT": "EAT", "CDT": "CDT", "CLST": "CLST", "MYT": "MYT", "HENOMX": "HENOMX", "WITA": "WITA", "SGT": "SGT", "ADT": "ADT", "WEZ": "WEZ", "HNT": "HNT", "WIT": "WIT", "BOT": "BOT", "CLT": "CLT", "HEOG": "HEOG", "GMT": "GMT", "UYST": "UYST", "HECU": "HECU", "WIB": "WIB", "WAST": "WAST", "HKST": "HKST", "HEEG": "HEEG", "BT": "BT", "HAT": "HAT", "ChST": "ChST", "LHDT": "LHDT", "MDT": "MDT", "HKT": "HKT", "UYT": "UYT", "HAST": "HAST", "MESZ": "MESZ", "ARST": "ARST", "ACDT": "ACDT", "COST": "COST", "AEST": "AEST", "IST": "IST", "JST": "JST", "ART": "ART", "MST": "MST", "WAT": "WAT", "EDT": "EDT", "HNEG": "HNEG", "NZST": "NZST", "NZDT": "NZDT", "TMST": "TMST", "HEPM": "HEPM", "JDT": "JDT", "GFT": "GFT", "AKST": "AKST", "HEPMX": "HEPMX", "AWST": "AWST", "AST": "AST", "HADT": "HADT", "WESZ": "WESZ", "EST": "EST", "LHST": "LHST", "GYT": "GYT", "AWDT": "AWDT", "SAST": "SAST", "SRT": "SRT"}, + } +} + +// Locale returns the current translators string locale +func (nmg *nmg_CM) Locale() string { + return nmg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nmg_CM' +func (nmg *nmg_CM) PluralsCardinal() []locales.PluralRule { + return nmg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nmg_CM' +func (nmg *nmg_CM) PluralsOrdinal() []locales.PluralRule { + return nmg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nmg_CM' +func (nmg *nmg_CM) PluralsRange() []locales.PluralRule { + return nmg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nmg_CM' +func (nmg *nmg_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nmg_CM' +func (nmg *nmg_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nmg_CM' +func (nmg *nmg_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nmg *nmg_CM) MonthAbbreviated(month time.Month) string { + return nmg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nmg *nmg_CM) MonthsAbbreviated() []string { + return nmg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nmg *nmg_CM) MonthNarrow(month time.Month) string { + return nmg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nmg *nmg_CM) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nmg *nmg_CM) MonthWide(month time.Month) string { + return nmg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nmg *nmg_CM) MonthsWide() []string { + return nmg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nmg *nmg_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return nmg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nmg *nmg_CM) WeekdaysAbbreviated() []string { + return nmg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nmg *nmg_CM) WeekdayNarrow(weekday time.Weekday) string { + return nmg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nmg *nmg_CM) WeekdaysNarrow() []string { + return nmg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nmg *nmg_CM) WeekdayShort(weekday time.Weekday) string { + return nmg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nmg *nmg_CM) WeekdaysShort() []string { + return nmg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nmg *nmg_CM) WeekdayWide(weekday time.Weekday) string { + return nmg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nmg *nmg_CM) WeekdaysWide() []string { + return nmg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nmg_CM' and handles both Whole and Real numbers based on 'v' +func (nmg *nmg_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nmg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nmg.group) - 1; j >= 0; j-- { + b = append(b, nmg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nmg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nmg_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nmg *nmg_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nmg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nmg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nmg.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nmg_CM' +func (nmg *nmg_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nmg.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nmg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nmg.group) - 1; j >= 0; j-- { + b = append(b, nmg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nmg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nmg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nmg.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nmg_CM' +// in accounting notation. +func (nmg *nmg_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nmg.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nmg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nmg.group) - 1; j >= 0; j-- { + b = append(b, nmg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, nmg.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nmg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nmg.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nmg.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nmg_CM' +func (nmg *nmg_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nmg_CM' +func (nmg *nmg_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nmg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nmg_CM' +func (nmg *nmg_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nmg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nmg_CM' +func (nmg *nmg_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nmg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nmg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nmg_CM' +func (nmg *nmg_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nmg_CM' +func (nmg *nmg_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nmg_CM' +func (nmg *nmg_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nmg_CM' +func (nmg *nmg_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nmg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nmg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nmg_CM/nmg_CM_test.go b/vendor/github.com/go-playground/locales/nmg_CM/nmg_CM_test.go new file mode 100644 index 0000000000..61ebc1d554 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nmg_CM/nmg_CM_test.go @@ -0,0 +1,1120 @@ +package nmg_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nmg_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nn/nn.go b/vendor/github.com/go-playground/locales/nn/nn.go new file mode 100644 index 0000000000..5dd9e3a61f --- /dev/null +++ b/vendor/github.com/go-playground/locales/nn/nn.go @@ -0,0 +1,609 @@ +package nn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nn' locale +func New() locales.Translator { + return &nn{ + locale: "nn", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "kr", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mars", "apr.", "mai", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"}, + daysAbbreviated: []string{"sø.", "må.", "ty.", "on.", "to.", "fr.", "la."}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sø.", "må.", "ty.", "on.", "to.", "fr.", "la."}, + daysWide: []string{"søndag", "måndag", "tysdag", "onsdag", "torsdag", "fredag", "laurdag"}, + periodsAbbreviated: []string{"f.m.", "e.m."}, + periodsNarrow: []string{"f.m.", "e.m."}, + periodsWide: []string{"formiddag", "ettermiddag"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"f.Kr.", "e.Kr."}, + timezones: map[string]string{"MDT": "MDT", "HEPM": "HEPM", "HEPMX": "HEPMX", "WIB": "WIB", "CHAST": "CHAST", "IST": "IST", "ACWST": "vest-sentralaustralsk standardtid", "AST": "AST", "ART": "ART", "AKST": "AKST", "HEOG": "HEOG", "COT": "COT", "HNPMX": "HNPMX", "MYT": "MYT", "WAT": "vestafrikansk standardtid", "WAST": "vestafrikansk sommartid", "HNT": "HNT", "HNCU": "HNCU", "HADT": "HADT", "ECT": "ECT", "ACWDT": "vest-sentralaustralsk sommartid", "NZDT": "NZDT", "HEEG": "HEEG", "LHDT": "LHDT", "HECU": "HECU", "CAT": "sentralafrikansk tid", "VET": "VET", "MST": "MST", "EST": "EST", "SAST": "sørafrikansk tid", "SRT": "SRT", "CHADT": "CHADT", "ACST": "sentralaustralsk standardtid", "HENOMX": "HENOMX", "AEST": "austaustralsk standardtid", "AEDT": "austaustralsk sommartid", "MESZ": "sentraleuropeisk sommartid", "OEZ": "austeuropeisk standardtid", "ARST": "ARST", "EDT": "EDT", "MEZ": "sentraleuropeisk standardtid", "WEZ": "vesteuropeisk standardtid", "CLST": "CLST", "HAT": "HAT", "WITA": "WITA", "ChST": "ChST", "EAT": "austafrikansk tid", "JST": "JST", "OESZ": "austeuropeisk sommartid", "COST": "COST", "HNNOMX": "HNNOMX", "BT": "BT", "UYT": "UYT", "AWDT": "vestaustralsk sommartid", "SGT": "SGT", "PDT": "PDT", "GMT": "greenwich middeltid", "JDT": "JDT", "HKST": "HKST", "GFT": "GFT", "HAST": "HAST", "WART": "WART", "CLT": "CLT", "UYST": "UYST", "HNPM": "HNPM", "LHST": "LHST", "BOT": "BOT", "NZST": "NZST", "HNOG": "HNOG", "ACDT": "sentralaustralsk sommartid", "HNEG": "HNEG", "AKDT": "AKDT", "CDT": "CDT", "WIT": "WIT", "AWST": "vestaustralsk standardtid", "ADT": "ADT", "WESZ": "vesteuropeisk sommartid", "TMT": "TMT", "TMST": "TMST", "HKT": "HKT", "PST": "PST", "∅∅∅": "∅∅∅", "WARST": "WARST", "GYT": "GYT", "CST": "CST"}, + } +} + +// Locale returns the current translators string locale +func (nn *nn) Locale() string { + return nn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nn' +func (nn *nn) PluralsCardinal() []locales.PluralRule { + return nn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nn' +func (nn *nn) PluralsOrdinal() []locales.PluralRule { + return nn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nn' +func (nn *nn) PluralsRange() []locales.PluralRule { + return nn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nn' +func (nn *nn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nn' +func (nn *nn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nn' +func (nn *nn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nn *nn) MonthAbbreviated(month time.Month) string { + return nn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nn *nn) MonthsAbbreviated() []string { + return nn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nn *nn) MonthNarrow(month time.Month) string { + return nn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nn *nn) MonthsNarrow() []string { + return nn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nn *nn) MonthWide(month time.Month) string { + return nn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nn *nn) MonthsWide() []string { + return nn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nn *nn) WeekdayAbbreviated(weekday time.Weekday) string { + return nn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nn *nn) WeekdaysAbbreviated() []string { + return nn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nn *nn) WeekdayNarrow(weekday time.Weekday) string { + return nn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nn *nn) WeekdaysNarrow() []string { + return nn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nn *nn) WeekdayShort(weekday time.Weekday) string { + return nn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nn *nn) WeekdaysShort() []string { + return nn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nn *nn) WeekdayWide(weekday time.Weekday) string { + return nn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nn *nn) WeekdaysWide() []string { + return nn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nn' and handles both Whole and Real numbers based on 'v' +func (nn *nn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nn.group) - 1; j >= 0; j-- { + b = append(b, nn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nn.minus) - 1; j >= 0; j-- { + b = append(b, nn.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nn *nn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nn.minus) - 1; j >= 0; j-- { + b = append(b, nn.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nn.percentSuffix...) + + b = append(b, nn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nn' +func (nn *nn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nn.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nn.group) - 1; j >= 0; j-- { + b = append(b, nn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nn.minus) - 1; j >= 0; j-- { + b = append(b, nn.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nn.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nn' +// in accounting notation. +func (nn *nn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nn.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nn.group) - 1; j >= 0; j-- { + b = append(b, nn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(nn.minus) - 1; j >= 0; j-- { + b = append(b, nn.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nn.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nn.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nn' +func (nn *nn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nn' +func (nn *nn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nn' +func (nn *nn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nn' +func (nn *nn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nn' +func (nn *nn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nn' +func (nn *nn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nn' +func (nn *nn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nn' +func (nn *nn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x6b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nn/nn_test.go b/vendor/github.com/go-playground/locales/nn/nn_test.go new file mode 100644 index 0000000000..2f7d74e3b0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nn/nn_test.go @@ -0,0 +1,1120 @@ +package nn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nn_NO/nn_NO.go b/vendor/github.com/go-playground/locales/nn_NO/nn_NO.go new file mode 100644 index 0000000000..22a5cbb4ec --- /dev/null +++ b/vendor/github.com/go-playground/locales/nn_NO/nn_NO.go @@ -0,0 +1,609 @@ +package nn_NO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nn_NO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nn_NO' locale +func New() locales.Translator { + return &nn_NO{ + locale: "nn_NO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mars", "apr.", "mai", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "des."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember"}, + daysAbbreviated: []string{"sø.", "må.", "ty.", "on.", "to.", "fr.", "la."}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sø.", "må.", "ty.", "on.", "to.", "fr.", "la."}, + daysWide: []string{"søndag", "måndag", "tysdag", "onsdag", "torsdag", "fredag", "laurdag"}, + periodsAbbreviated: []string{"f.m.", "e.m."}, + periodsNarrow: []string{"f.m.", "e.m."}, + periodsWide: []string{"formiddag", "ettermiddag"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"f.Kr.", "e.Kr."}, + timezones: map[string]string{"CLT": "CLT", "COST": "COST", "AEST": "austaustralsk standardtid", "WITA": "WITA", "SRT": "SRT", "CDT": "CDT", "PDT": "PDT", "HADT": "HADT", "CLST": "CLST", "WESZ": "vesteuropeisk sommartid", "WAST": "vestafrikansk sommartid", "EDT": "EDT", "MST": "MST", "SAST": "sørafrikansk tid", "SGT": "SGT", "HAST": "HAST", "JDT": "JDT", "GYT": "GYT", "CHADT": "CHADT", "ECT": "ECT", "MYT": "MYT", "AST": "AST", "WIT": "WIT", "CAT": "sentralafrikansk tid", "WARST": "WARST", "HEOG": "HEOG", "HKST": "HKST", "ACST": "sentralaustralsk standardtid", "COT": "COT", "AKDT": "AKDT", "HECU": "HECU", "HNOG": "HNOG", "HAT": "HAT", "AEDT": "austaustralsk sommartid", "UYT": "UYT", "HEPM": "HEPM", "EAT": "austafrikansk tid", "HENOMX": "HENOMX", "CST": "CST", "EST": "EST", "MDT": "MDT", "AWST": "vestaustralsk standardtid", "PST": "PST", "HEEG": "HEEG", "ChST": "ChST", "BOT": "BOT", "ADT": "ADT", "ACDT": "sentralaustralsk sommartid", "AWDT": "vestaustralsk sommartid", "CHAST": "CHAST", "JST": "JST", "WAT": "vestafrikansk standardtid", "∅∅∅": "∅∅∅", "BT": "BT", "UYST": "UYST", "NZST": "NZST", "OESZ": "austeuropeisk sommartid", "GFT": "GFT", "AKST": "AKST", "HNPM": "HNPM", "LHST": "LHST", "LHDT": "LHDT", "HEPMX": "HEPMX", "MESZ": "sentraleuropeisk sommartid", "WEZ": "vesteuropeisk standardtid", "ART": "ART", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "WIB": "WIB", "ACWDT": "vest-sentralaustralsk sommartid", "WART": "WART", "TMT": "TMT", "ARST": "ARST", "NZDT": "NZDT", "ACWST": "vest-sentralaustralsk standardtid", "HNT": "HNT", "GMT": "greenwich middeltid", "OEZ": "austeuropeisk standardtid", "TMST": "TMST", "HKT": "HKT", "HNEG": "HNEG", "HNCU": "HNCU", "IST": "IST", "MEZ": "sentraleuropeisk standardtid", "VET": "VET"}, + } +} + +// Locale returns the current translators string locale +func (nn *nn_NO) Locale() string { + return nn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nn_NO' +func (nn *nn_NO) PluralsCardinal() []locales.PluralRule { + return nn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nn_NO' +func (nn *nn_NO) PluralsOrdinal() []locales.PluralRule { + return nn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nn_NO' +func (nn *nn_NO) PluralsRange() []locales.PluralRule { + return nn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nn_NO' +func (nn *nn_NO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nn_NO' +func (nn *nn_NO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nn_NO' +func (nn *nn_NO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nn *nn_NO) MonthAbbreviated(month time.Month) string { + return nn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nn *nn_NO) MonthsAbbreviated() []string { + return nn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nn *nn_NO) MonthNarrow(month time.Month) string { + return nn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nn *nn_NO) MonthsNarrow() []string { + return nn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nn *nn_NO) MonthWide(month time.Month) string { + return nn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nn *nn_NO) MonthsWide() []string { + return nn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nn *nn_NO) WeekdayAbbreviated(weekday time.Weekday) string { + return nn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nn *nn_NO) WeekdaysAbbreviated() []string { + return nn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nn *nn_NO) WeekdayNarrow(weekday time.Weekday) string { + return nn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nn *nn_NO) WeekdaysNarrow() []string { + return nn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nn *nn_NO) WeekdayShort(weekday time.Weekday) string { + return nn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nn *nn_NO) WeekdaysShort() []string { + return nn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nn *nn_NO) WeekdayWide(weekday time.Weekday) string { + return nn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nn *nn_NO) WeekdaysWide() []string { + return nn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nn_NO' and handles both Whole and Real numbers based on 'v' +func (nn *nn_NO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nn.group) - 1; j >= 0; j-- { + b = append(b, nn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nn.minus) - 1; j >= 0; j-- { + b = append(b, nn.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nn_NO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nn *nn_NO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nn.minus) - 1; j >= 0; j-- { + b = append(b, nn.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nn.percentSuffix...) + + b = append(b, nn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nn_NO' +func (nn *nn_NO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nn.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nn.group) - 1; j >= 0; j-- { + b = append(b, nn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(nn.minus) - 1; j >= 0; j-- { + b = append(b, nn.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, nn.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nn_NO' +// in accounting notation. +func (nn *nn_NO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nn.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(nn.group) - 1; j >= 0; j-- { + b = append(b, nn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(nn.minus) - 1; j >= 0; j-- { + b = append(b, nn.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nn.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, nn.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nn_NO' +func (nn *nn_NO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nn_NO' +func (nn *nn_NO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nn_NO' +func (nn *nn_NO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nn_NO' +func (nn *nn_NO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, nn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nn_NO' +func (nn *nn_NO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nn_NO' +func (nn *nn_NO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nn_NO' +func (nn *nn_NO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nn_NO' +func (nn *nn_NO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x6b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nn_NO/nn_NO_test.go b/vendor/github.com/go-playground/locales/nn_NO/nn_NO_test.go new file mode 100644 index 0000000000..15cf9522b1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nn_NO/nn_NO_test.go @@ -0,0 +1,1120 @@ +package nn_NO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nn_NO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nnh/nnh.go b/vendor/github.com/go-playground/locales/nnh/nnh.go new file mode 100644 index 0000000000..eeca591262 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nnh/nnh.go @@ -0,0 +1,489 @@ +package nnh + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nnh struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nnh' locale +func New() locales.Translator { + return &nnh{ + locale: "nnh", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "saŋ tsetsɛ̀ɛ lùm", "saŋ kàg ngwóŋ", "saŋ lepyè shúm", "saŋ cÿó", "saŋ tsɛ̀ɛ cÿó", "saŋ njÿoláʼ", "saŋ tyɛ̀b tyɛ̀b mbʉ̀ŋ", "saŋ mbʉ̀ŋ", "saŋ ngwɔ̀ʼ mbÿɛ", "saŋ tàŋa tsetsáʼ", "saŋ mejwoŋó", "saŋ lùm"}, + monthsWide: []string{"", "saŋ tsetsɛ̀ɛ lùm", "saŋ kàg ngwóŋ", "saŋ lepyè shúm", "saŋ cÿó", "saŋ tsɛ̀ɛ cÿó", "saŋ njÿoláʼ", "saŋ tyɛ̀b tyɛ̀b mbʉ̀ŋ", "saŋ mbʉ̀ŋ", "saŋ ngwɔ̀ʼ mbÿɛ", "saŋ tàŋa tsetsáʼ", "saŋ mejwoŋó", "saŋ lùm"}, + daysAbbreviated: []string{"lyɛʼɛ́ sẅíŋtè", "mvfò lyɛ̌ʼ", "mbɔ́ɔntè mvfò lyɛ̌ʼ", "tsètsɛ̀ɛ lyɛ̌ʼ", "mbɔ́ɔntè tsetsɛ̀ɛ lyɛ̌ʼ", "mvfò màga lyɛ̌ʼ", "màga lyɛ̌ʼ"}, + daysShort: []string{"lyɛʼɛ́ sẅíŋtè", "mvfò lyɛ̌ʼ", "mbɔ́ɔntè mvfò lyɛ̌ʼ", "tsètsɛ̀ɛ lyɛ̌ʼ", "mbɔ́ɔntè tsetsɛ̀ɛ lyɛ̌ʼ", "mvfò màga lyɛ̌ʼ", "màga lyɛ̌ʼ"}, + daysWide: []string{"lyɛʼɛ́ sẅíŋtè", "mvfò lyɛ̌ʼ", "mbɔ́ɔntè mvfò lyɛ̌ʼ", "tsètsɛ̀ɛ lyɛ̌ʼ", "mbɔ́ɔntè tsetsɛ̀ɛ lyɛ̌ʼ", "mvfò màga lyɛ̌ʼ", "màga lyɛ̌ʼ"}, + periodsAbbreviated: []string{"mbaʼámbaʼ", "ncwònzém"}, + periodsWide: []string{"mbaʼámbaʼ", "ncwònzém"}, + erasAbbreviated: []string{"m.z.Y.", "m.g.n.Y."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"mé zyé Yěsô", "mé gÿo ńzyé Yěsô"}, + timezones: map[string]string{"HNT": "HNT", "AEDT": "AEDT", "HNPMX": "HNPMX", "AWDT": "AWDT", "WITA": "WITA", "LHDT": "LHDT", "HAST": "HAST", "NZDT": "NZDT", "CAT": "CAT", "COST": "COST", "HAT": "HAT", "HNPM": "HNPM", "HNCU": "HNCU", "AWST": "AWST", "HKT": "HKT", "MYT": "MYT", "WAT": "WAT", "HEEG": "HEEG", "ChST": "ChST", "NZST": "NZST", "ACWST": "ACWST", "MESZ": "MESZ", "BT": "BT", "GFT": "GFT", "WIB": "WIB", "WIT": "WIT", "HNNOMX": "HNNOMX", "MST": "MST", "HEPMX": "HEPMX", "GYT": "GYT", "OEZ": "OEZ", "HEPM": "HEPM", "BOT": "BOT", "IST": "IST", "WART": "WART", "HEOG": "HEOG", "CHAST": "CHAST", "CHADT": "CHADT", "VET": "VET", "CST": "CST", "CDT": "CDT", "PST": "PST", "MEZ": "MEZ", "ACDT": "ACDT", "WAST": "WAST", "ACST": "ACST", "HENOMX": "HENOMX", "HADT": "HADT", "ACWDT": "ACWDT", "OESZ": "OESZ", "ART": "ART", "ARST": "ARST", "AKST": "AKST", "EAT": "EAT", "SGT": "SGT", "COT": "COT", "JDT": "JDT", "GMT": "GMT", "WEZ": "WEZ", "EST": "EST", "ADT": "ADT", "TMT": "TMT", "AEST": "AEST", "SRT": "SRT", "LHST": "LHST", "CLST": "CLST", "AST": "AST", "UYST": "UYST", "JST": "JST", "ECT": "ECT", "PDT": "PDT", "WARST": "WARST", "HNEG": "HNEG", "AKDT": "AKDT", "UYT": "UYT", "SAST": "SAST", "HECU": "HECU", "TMST": "TMST", "EDT": "EDT", "HKST": "HKST", "∅∅∅": "∅∅∅", "MDT": "MDT", "CLT": "CLT", "HNOG": "HNOG", "WESZ": "WESZ"}, + } +} + +// Locale returns the current translators string locale +func (nnh *nnh) Locale() string { + return nnh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nnh' +func (nnh *nnh) PluralsCardinal() []locales.PluralRule { + return nnh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nnh' +func (nnh *nnh) PluralsOrdinal() []locales.PluralRule { + return nnh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nnh' +func (nnh *nnh) PluralsRange() []locales.PluralRule { + return nnh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nnh' +func (nnh *nnh) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nnh' +func (nnh *nnh) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nnh' +func (nnh *nnh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nnh *nnh) MonthAbbreviated(month time.Month) string { + return nnh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nnh *nnh) MonthsAbbreviated() []string { + return nnh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nnh *nnh) MonthNarrow(month time.Month) string { + return nnh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nnh *nnh) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nnh *nnh) MonthWide(month time.Month) string { + return nnh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nnh *nnh) MonthsWide() []string { + return nnh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nnh *nnh) WeekdayAbbreviated(weekday time.Weekday) string { + return nnh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nnh *nnh) WeekdaysAbbreviated() []string { + return nnh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nnh *nnh) WeekdayNarrow(weekday time.Weekday) string { + return nnh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nnh *nnh) WeekdaysNarrow() []string { + return nnh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nnh *nnh) WeekdayShort(weekday time.Weekday) string { + return nnh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nnh *nnh) WeekdaysShort() []string { + return nnh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nnh *nnh) WeekdayWide(weekday time.Weekday) string { + return nnh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nnh *nnh) WeekdaysWide() []string { + return nnh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nnh' and handles both Whole and Real numbers based on 'v' +func (nnh *nnh) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nnh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nnh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nnh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nnh' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nnh *nnh) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nnh' +func (nnh *nnh) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nnh.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nnh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nnh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nnh.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nnh.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, nnh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nnh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nnh' +// in accounting notation. +func (nnh *nnh) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nnh.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nnh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nnh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nnh.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, nnh.currencyNegativePrefix[j]) + } + + b = append(b, nnh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nnh.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nnh.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nnh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nnh' +func (nnh *nnh) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nnh' +func (nnh *nnh) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nnh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nnh' +func (nnh *nnh) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x6c, 0x79, 0xc9, 0x9b}...) + b = append(b, []byte{0xcc, 0x8c, 0xca, 0xbc, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6e, 0x61}...) + b = append(b, []byte{0x20}...) + b = append(b, nnh.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nnh' +func (nnh *nnh) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nnh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0x2c, 0x20, 0x6c, 0x79, 0xc9, 0x9b}...) + b = append(b, []byte{0xcc, 0x8c, 0xca, 0xbc, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6e, 0x61}...) + b = append(b, []byte{0x20}...) + b = append(b, nnh.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nnh' +func (nnh *nnh) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nnh' +func (nnh *nnh) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nnh' +func (nnh *nnh) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nnh' +func (nnh *nnh) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nnh/nnh_test.go b/vendor/github.com/go-playground/locales/nnh/nnh_test.go new file mode 100644 index 0000000000..ca05ac530c --- /dev/null +++ b/vendor/github.com/go-playground/locales/nnh/nnh_test.go @@ -0,0 +1,1120 @@ +package nnh + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nnh" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nnh_CM/nnh_CM.go b/vendor/github.com/go-playground/locales/nnh_CM/nnh_CM.go new file mode 100644 index 0000000000..6574fa8658 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nnh_CM/nnh_CM.go @@ -0,0 +1,489 @@ +package nnh_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nnh_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nnh_CM' locale +func New() locales.Translator { + return &nnh_CM{ + locale: "nnh_CM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "saŋ tsetsɛ̀ɛ lùm", "saŋ kàg ngwóŋ", "saŋ lepyè shúm", "saŋ cÿó", "saŋ tsɛ̀ɛ cÿó", "saŋ njÿoláʼ", "saŋ tyɛ̀b tyɛ̀b mbʉ̀ŋ", "saŋ mbʉ̀ŋ", "saŋ ngwɔ̀ʼ mbÿɛ", "saŋ tàŋa tsetsáʼ", "saŋ mejwoŋó", "saŋ lùm"}, + monthsWide: []string{"", "saŋ tsetsɛ̀ɛ lùm", "saŋ kàg ngwóŋ", "saŋ lepyè shúm", "saŋ cÿó", "saŋ tsɛ̀ɛ cÿó", "saŋ njÿoláʼ", "saŋ tyɛ̀b tyɛ̀b mbʉ̀ŋ", "saŋ mbʉ̀ŋ", "saŋ ngwɔ̀ʼ mbÿɛ", "saŋ tàŋa tsetsáʼ", "saŋ mejwoŋó", "saŋ lùm"}, + daysAbbreviated: []string{"lyɛʼɛ́ sẅíŋtè", "mvfò lyɛ̌ʼ", "mbɔ́ɔntè mvfò lyɛ̌ʼ", "tsètsɛ̀ɛ lyɛ̌ʼ", "mbɔ́ɔntè tsetsɛ̀ɛ lyɛ̌ʼ", "mvfò màga lyɛ̌ʼ", "màga lyɛ̌ʼ"}, + daysShort: []string{"lyɛʼɛ́ sẅíŋtè", "mvfò lyɛ̌ʼ", "mbɔ́ɔntè mvfò lyɛ̌ʼ", "tsètsɛ̀ɛ lyɛ̌ʼ", "mbɔ́ɔntè tsetsɛ̀ɛ lyɛ̌ʼ", "mvfò màga lyɛ̌ʼ", "màga lyɛ̌ʼ"}, + daysWide: []string{"lyɛʼɛ́ sẅíŋtè", "mvfò lyɛ̌ʼ", "mbɔ́ɔntè mvfò lyɛ̌ʼ", "tsètsɛ̀ɛ lyɛ̌ʼ", "mbɔ́ɔntè tsetsɛ̀ɛ lyɛ̌ʼ", "mvfò màga lyɛ̌ʼ", "màga lyɛ̌ʼ"}, + periodsAbbreviated: []string{"mbaʼámbaʼ", "ncwònzém"}, + periodsWide: []string{"mbaʼámbaʼ", "ncwònzém"}, + erasAbbreviated: []string{"m.z.Y.", "m.g.n.Y."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"mé zyé Yěsô", "mé gÿo ńzyé Yěsô"}, + timezones: map[string]string{"HKT": "HKT", "ACDT": "ACDT", "JDT": "JDT", "WESZ": "WESZ", "ART": "ART", "EST": "EST", "MYT": "MYT", "CDT": "CDT", "CHAST": "CHAST", "CHADT": "CHADT", "HAST": "HAST", "MEZ": "MEZ", "CLT": "CLT", "BT": "BT", "AKST": "AKST", "AEDT": "AEDT", "HEPM": "HEPM", "BOT": "BOT", "COT": "COT", "ChST": "ChST", "LHDT": "LHDT", "OESZ": "OESZ", "HKST": "HKST", "ACST": "ACST", "MESZ": "MESZ", "WARST": "WARST", "ARST": "ARST", "CLST": "CLST", "HEOG": "HEOG", "COST": "COST", "MDT": "MDT", "SAST": "SAST", "WIT": "WIT", "WART": "WART", "HECU": "HECU", "IST": "IST", "WAST": "WAST", "HENOMX": "HENOMX", "HAT": "HAT", "WITA": "WITA", "HEPMX": "HEPMX", "GYT": "GYT", "ADT": "ADT", "OEZ": "OEZ", "GMT": "GMT", "HNEG": "HNEG", "∅∅∅": "∅∅∅", "PST": "PST", "ACWST": "ACWST", "JST": "JST", "WAT": "WAT", "EDT": "EDT", "TMST": "TMST", "UYT": "UYT", "UYST": "UYST", "LHST": "LHST", "AWST": "AWST", "TMT": "TMT", "AEST": "AEST", "SRT": "SRT", "CST": "CST", "NZDT": "NZDT", "WEZ": "WEZ", "HNOG": "HNOG", "HNT": "HNT", "HEEG": "HEEG", "ECT": "ECT", "HADT": "HADT", "HNNOMX": "HNNOMX", "HNPM": "HNPM", "SGT": "SGT", "AST": "AST", "GFT": "GFT", "MST": "MST", "EAT": "EAT", "HNCU": "HNCU", "WIB": "WIB", "PDT": "PDT", "VET": "VET", "NZST": "NZST", "AKDT": "AKDT", "HNPMX": "HNPMX", "AWDT": "AWDT", "CAT": "CAT", "ACWDT": "ACWDT"}, + } +} + +// Locale returns the current translators string locale +func (nnh *nnh_CM) Locale() string { + return nnh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nnh_CM' +func (nnh *nnh_CM) PluralsCardinal() []locales.PluralRule { + return nnh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nnh_CM' +func (nnh *nnh_CM) PluralsOrdinal() []locales.PluralRule { + return nnh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nnh_CM' +func (nnh *nnh_CM) PluralsRange() []locales.PluralRule { + return nnh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nnh_CM' +func (nnh *nnh_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nnh_CM' +func (nnh *nnh_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nnh_CM' +func (nnh *nnh_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nnh *nnh_CM) MonthAbbreviated(month time.Month) string { + return nnh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nnh *nnh_CM) MonthsAbbreviated() []string { + return nnh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nnh *nnh_CM) MonthNarrow(month time.Month) string { + return nnh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nnh *nnh_CM) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nnh *nnh_CM) MonthWide(month time.Month) string { + return nnh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nnh *nnh_CM) MonthsWide() []string { + return nnh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nnh *nnh_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return nnh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nnh *nnh_CM) WeekdaysAbbreviated() []string { + return nnh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nnh *nnh_CM) WeekdayNarrow(weekday time.Weekday) string { + return nnh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nnh *nnh_CM) WeekdaysNarrow() []string { + return nnh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nnh *nnh_CM) WeekdayShort(weekday time.Weekday) string { + return nnh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nnh *nnh_CM) WeekdaysShort() []string { + return nnh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nnh *nnh_CM) WeekdayWide(weekday time.Weekday) string { + return nnh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nnh *nnh_CM) WeekdaysWide() []string { + return nnh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nnh_CM' and handles both Whole and Real numbers based on 'v' +func (nnh *nnh_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nnh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nnh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nnh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nnh_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nnh *nnh_CM) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nnh_CM' +func (nnh *nnh_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nnh.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nnh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nnh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nnh.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nnh.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, nnh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nnh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nnh_CM' +// in accounting notation. +func (nnh *nnh_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nnh.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nnh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nnh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nnh.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, nnh.currencyNegativePrefix[j]) + } + + b = append(b, nnh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(nnh.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, nnh.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nnh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nnh_CM' +func (nnh *nnh_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nnh_CM' +func (nnh *nnh_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nnh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nnh_CM' +func (nnh *nnh_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x6c, 0x79, 0xc9, 0x9b}...) + b = append(b, []byte{0xcc, 0x8c, 0xca, 0xbc, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6e, 0x61}...) + b = append(b, []byte{0x20}...) + b = append(b, nnh.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nnh_CM' +func (nnh *nnh_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nnh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0x2c, 0x20, 0x6c, 0x79, 0xc9, 0x9b}...) + b = append(b, []byte{0xcc, 0x8c, 0xca, 0xbc, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x6e, 0x61}...) + b = append(b, []byte{0x20}...) + b = append(b, nnh.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nnh_CM' +func (nnh *nnh_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nnh_CM' +func (nnh *nnh_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nnh_CM' +func (nnh *nnh_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nnh_CM' +func (nnh *nnh_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nnh_CM/nnh_CM_test.go b/vendor/github.com/go-playground/locales/nnh_CM/nnh_CM_test.go new file mode 100644 index 0000000000..58d4d94d26 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nnh_CM/nnh_CM_test.go @@ -0,0 +1,1120 @@ +package nnh_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nnh_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nus/nus.go b/vendor/github.com/go-playground/locales/nus/nus.go new file mode 100644 index 0000000000..eebb0f2b3d --- /dev/null +++ b/vendor/github.com/go-playground/locales/nus/nus.go @@ -0,0 +1,614 @@ +package nus + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nus struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nus' locale +func New() locales.Translator { + return &nus{ + locale: "nus", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GB£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "£", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Tiop", "Pɛt", "Duɔ̱ɔ̱", "Guak", "Duä", "Kor", "Pay", "Thoo", "Tɛɛ", "Laa", "Kur", "Tid"}, + monthsNarrow: []string{"", "T", "P", "D", "G", "D", "K", "P", "T", "T", "L", "K", "T"}, + monthsWide: []string{"", "Tiop thar pɛt", "Pɛt", "Duɔ̱ɔ̱ŋ", "Guak", "Duät", "Kornyoot", "Pay yie̱tni", "Tho̱o̱r", "Tɛɛr", "Laath", "Kur", "Tio̱p in di̱i̱t"}, + daysAbbreviated: []string{"Cäŋ", "Jiec", "Rɛw", "Diɔ̱k", "Ŋuaan", "Dhieec", "Bäkɛl"}, + daysNarrow: []string{"C", "J", "R", "D", "Ŋ", "D", "B"}, + daysWide: []string{"Cäŋ kuɔth", "Jiec la̱t", "Rɛw lätni", "Diɔ̱k lätni", "Ŋuaan lätni", "Dhieec lätni", "Bäkɛl lätni"}, + periodsAbbreviated: []string{"RW", "TŊ"}, + periodsWide: []string{"RW", "TŊ"}, + erasAbbreviated: []string{"AY", "ƐY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"A ka̱n Yecu ni dap", "Ɛ ca Yecu dap"}, + timezones: map[string]string{"HNPMX": "HNPMX", "HEOG": "HEOG", "EST": "EST", "SRT": "SRT", "HECU": "HECU", "ACWST": "ACWST", "NZST": "NZST", "MDT": "MDT", "ARST": "ARST", "COST": "COST", "MEZ": "MEZ", "HKST": "HKST", "WITA": "WITA", "AEDT": "AEDT", "SGT": "SGT", "ECT": "ECT", "JST": "JST", "AEST": "AEST", "COT": "COT", "GYT": "GYT", "CDT": "CDT", "NZDT": "NZDT", "MYT": "MYT", "WART": "WART", "WESZ": "WESZ", "EDT": "EDT", "WIB": "WIB", "HAST": "HAST", "WEZ": "WEZ", "TMT": "TMT", "SAST": "SAST", "PST": "PST", "PDT": "PDT", "HEEG": "HEEG", "ChST": "ChST", "WARST": "WARST", "TMST": "TMST", "HNEG": "HNEG", "AKST": "AKST", "HNPM": "HNPM", "ART": "ART", "ACST": "ACST", "HEPM": "HEPM", "UYST": "UYST", "HEPMX": "HEPMX", "AWDT": "AWDT", "AST": "AST", "GMT": "GMT", "MST": "MST", "WAT": "WAT", "HAT": "HAT", "AWST": "AWST", "MESZ": "MESZ", "ADT": "ADT", "BOT": "BOT", "ACWDT": "ACWDT", "HNNOMX": "HNNOMX", "HNT": "HNT", "GFT": "GFT", "OESZ": "OESZ", "∅∅∅": "∅∅∅", "HNCU": "HNCU", "CST": "CST", "CHAST": "CHAST", "CHADT": "CHADT", "HADT": "HADT", "HNOG": "HNOG", "HKT": "HKT", "AKDT": "AKDT", "UYT": "UYT", "LHDT": "LHDT", "EAT": "EAT", "WIT": "WIT", "CAT": "CAT", "HENOMX": "HENOMX", "LHST": "LHST", "CLT": "CLT", "CLST": "CLST", "ACDT": "ACDT", "BT": "BT", "IST": "IST", "VET": "VET", "JDT": "JDT", "OEZ": "OEZ", "WAST": "WAST"}, + } +} + +// Locale returns the current translators string locale +func (nus *nus) Locale() string { + return nus.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nus' +func (nus *nus) PluralsCardinal() []locales.PluralRule { + return nus.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nus' +func (nus *nus) PluralsOrdinal() []locales.PluralRule { + return nus.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nus' +func (nus *nus) PluralsRange() []locales.PluralRule { + return nus.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nus' +func (nus *nus) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nus' +func (nus *nus) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nus' +func (nus *nus) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nus *nus) MonthAbbreviated(month time.Month) string { + return nus.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nus *nus) MonthsAbbreviated() []string { + return nus.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nus *nus) MonthNarrow(month time.Month) string { + return nus.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nus *nus) MonthsNarrow() []string { + return nus.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nus *nus) MonthWide(month time.Month) string { + return nus.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nus *nus) MonthsWide() []string { + return nus.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nus *nus) WeekdayAbbreviated(weekday time.Weekday) string { + return nus.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nus *nus) WeekdaysAbbreviated() []string { + return nus.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nus *nus) WeekdayNarrow(weekday time.Weekday) string { + return nus.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nus *nus) WeekdaysNarrow() []string { + return nus.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nus *nus) WeekdayShort(weekday time.Weekday) string { + return nus.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nus *nus) WeekdaysShort() []string { + return nus.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nus *nus) WeekdayWide(weekday time.Weekday) string { + return nus.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nus *nus) WeekdaysWide() []string { + return nus.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nus' and handles both Whole and Real numbers based on 'v' +func (nus *nus) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nus.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nus.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nus.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nus' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nus *nus) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nus.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nus.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nus.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nus' +func (nus *nus) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nus.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nus.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nus.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, nus.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nus.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nus' +// in accounting notation. +func (nus *nus) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nus.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nus.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nus.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, nus.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nus.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nus.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nus' +func (nus *nus) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nus' +func (nus *nus) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nus.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nus' +func (nus *nus) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nus.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nus' +func (nus *nus) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nus.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nus.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nus' +func (nus *nus) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, nus.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, nus.periodsAbbreviated[0]...) + } else { + b = append(b, nus.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nus' +func (nus *nus) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, nus.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nus.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, nus.periodsAbbreviated[0]...) + } else { + b = append(b, nus.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nus' +func (nus *nus) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, nus.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nus.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, nus.periodsAbbreviated[0]...) + } else { + b = append(b, nus.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nus' +func (nus *nus) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := nus.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, nus.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nus.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, nus.periodsAbbreviated[0]...) + } else { + b = append(b, nus.periodsAbbreviated[1]...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nus/nus_test.go b/vendor/github.com/go-playground/locales/nus/nus_test.go new file mode 100644 index 0000000000..327437e14d --- /dev/null +++ b/vendor/github.com/go-playground/locales/nus/nus_test.go @@ -0,0 +1,1120 @@ +package nus + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nus" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nus_SS/nus_SS.go b/vendor/github.com/go-playground/locales/nus_SS/nus_SS.go new file mode 100644 index 0000000000..921d6e2f94 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nus_SS/nus_SS.go @@ -0,0 +1,614 @@ +package nus_SS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nus_SS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nus_SS' locale +func New() locales.Translator { + return &nus_SS{ + locale: "nus_SS", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Tiop", "Pɛt", "Duɔ̱ɔ̱", "Guak", "Duä", "Kor", "Pay", "Thoo", "Tɛɛ", "Laa", "Kur", "Tid"}, + monthsNarrow: []string{"", "T", "P", "D", "G", "D", "K", "P", "T", "T", "L", "K", "T"}, + monthsWide: []string{"", "Tiop thar pɛt", "Pɛt", "Duɔ̱ɔ̱ŋ", "Guak", "Duät", "Kornyoot", "Pay yie̱tni", "Tho̱o̱r", "Tɛɛr", "Laath", "Kur", "Tio̱p in di̱i̱t"}, + daysAbbreviated: []string{"Cäŋ", "Jiec", "Rɛw", "Diɔ̱k", "Ŋuaan", "Dhieec", "Bäkɛl"}, + daysNarrow: []string{"C", "J", "R", "D", "Ŋ", "D", "B"}, + daysWide: []string{"Cäŋ kuɔth", "Jiec la̱t", "Rɛw lätni", "Diɔ̱k lätni", "Ŋuaan lätni", "Dhieec lätni", "Bäkɛl lätni"}, + periodsAbbreviated: []string{"RW", "TŊ"}, + periodsWide: []string{"RW", "TŊ"}, + erasAbbreviated: []string{"AY", "ƐY"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"A ka̱n Yecu ni dap", "Ɛ ca Yecu dap"}, + timezones: map[string]string{"NZDT": "NZDT", "JST": "JST", "CLST": "CLST", "ACWST": "ACWST", "NZST": "NZST", "WIB": "WIB", "VET": "VET", "CLT": "CLT", "ACST": "ACST", "HNCU": "HNCU", "PST": "PST", "PDT": "PDT", "HADT": "HADT", "LHST": "LHST", "GYT": "GYT", "WIT": "WIT", "AWST": "AWST", "SGT": "SGT", "OESZ": "OESZ", "WAST": "WAST", "COST": "COST", "HEEG": "HEEG", "OEZ": "OEZ", "AWDT": "AWDT", "HECU": "HECU", "CHAST": "CHAST", "CAT": "CAT", "TMT": "TMT", "MST": "MST", "ARST": "ARST", "HNPMX": "HNPMX", "MYT": "MYT", "ART": "ART", "BT": "BT", "HAST": "HAST", "SRT": "SRT", "HEOG": "HEOG", "AKST": "AKST", "AEST": "AEST", "UYT": "UYT", "EST": "EST", "HKST": "HKST", "JDT": "JDT", "HNOG": "HNOG", "WART": "WART", "WAT": "WAT", "HAT": "HAT", "HEPMX": "HEPMX", "ADT": "ADT", "WESZ": "WESZ", "WARST": "WARST", "MDT": "MDT", "ECT": "ECT", "IST": "IST", "ACWDT": "ACWDT", "HKT": "HKT", "EAT": "EAT", "CST": "CST", "CDT": "CDT", "HNT": "HNT", "GFT": "GFT", "WITA": "WITA", "UYST": "UYST", "∅∅∅": "∅∅∅", "MESZ": "MESZ", "WEZ": "WEZ", "GMT": "GMT", "TMST": "TMST", "HNEG": "HNEG", "AKDT": "AKDT", "AEDT": "AEDT", "ChST": "ChST", "MEZ": "MEZ", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "HNPM": "HNPM", "HEPM": "HEPM", "BOT": "BOT", "AST": "AST", "EDT": "EDT", "COT": "COT", "CHADT": "CHADT", "SAST": "SAST", "LHDT": "LHDT"}, + } +} + +// Locale returns the current translators string locale +func (nus *nus_SS) Locale() string { + return nus.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nus_SS' +func (nus *nus_SS) PluralsCardinal() []locales.PluralRule { + return nus.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nus_SS' +func (nus *nus_SS) PluralsOrdinal() []locales.PluralRule { + return nus.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nus_SS' +func (nus *nus_SS) PluralsRange() []locales.PluralRule { + return nus.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nus_SS' +func (nus *nus_SS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nus_SS' +func (nus *nus_SS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nus_SS' +func (nus *nus_SS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nus *nus_SS) MonthAbbreviated(month time.Month) string { + return nus.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nus *nus_SS) MonthsAbbreviated() []string { + return nus.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nus *nus_SS) MonthNarrow(month time.Month) string { + return nus.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nus *nus_SS) MonthsNarrow() []string { + return nus.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nus *nus_SS) MonthWide(month time.Month) string { + return nus.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nus *nus_SS) MonthsWide() []string { + return nus.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nus *nus_SS) WeekdayAbbreviated(weekday time.Weekday) string { + return nus.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nus *nus_SS) WeekdaysAbbreviated() []string { + return nus.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nus *nus_SS) WeekdayNarrow(weekday time.Weekday) string { + return nus.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nus *nus_SS) WeekdaysNarrow() []string { + return nus.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nus *nus_SS) WeekdayShort(weekday time.Weekday) string { + return nus.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nus *nus_SS) WeekdaysShort() []string { + return nus.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nus *nus_SS) WeekdayWide(weekday time.Weekday) string { + return nus.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nus *nus_SS) WeekdaysWide() []string { + return nus.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nus_SS' and handles both Whole and Real numbers based on 'v' +func (nus *nus_SS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nus.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nus.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nus.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nus_SS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nus *nus_SS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nus.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, nus.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, nus.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nus_SS' +func (nus *nus_SS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nus.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nus.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nus.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, nus.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nus.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nus_SS' +// in accounting notation. +func (nus *nus_SS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nus.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nus.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nus.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, nus.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nus.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, nus.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nus_SS' +func (nus *nus_SS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nus_SS' +func (nus *nus_SS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nus.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nus_SS' +func (nus *nus_SS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nus.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nus_SS' +func (nus *nus_SS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nus.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nus.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nus_SS' +func (nus *nus_SS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, nus.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, nus.periodsAbbreviated[0]...) + } else { + b = append(b, nus.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nus_SS' +func (nus *nus_SS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, nus.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nus.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, nus.periodsAbbreviated[0]...) + } else { + b = append(b, nus.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nus_SS' +func (nus *nus_SS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, nus.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nus.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, nus.periodsAbbreviated[0]...) + } else { + b = append(b, nus.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nus_SS' +func (nus *nus_SS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := nus.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, nus.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nus.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, nus.periodsAbbreviated[0]...) + } else { + b = append(b, nus.periodsAbbreviated[1]...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nus_SS/nus_SS_test.go b/vendor/github.com/go-playground/locales/nus_SS/nus_SS_test.go new file mode 100644 index 0000000000..b57b0524bf --- /dev/null +++ b/vendor/github.com/go-playground/locales/nus_SS/nus_SS_test.go @@ -0,0 +1,1120 @@ +package nus_SS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nus_SS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nyn/nyn.go b/vendor/github.com/go-playground/locales/nyn/nyn.go new file mode 100644 index 0000000000..7976dee601 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nyn/nyn.go @@ -0,0 +1,515 @@ +package nyn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nyn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nyn' locale +func New() locales.Translator { + return &nyn{ + locale: "nyn", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "USh", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "KBZ", "KBR", "KST", "KKN", "KTN", "KMK", "KMS", "KMN", "KMW", "KKM", "KNK", "KNB"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Okwokubanza", "Okwakabiri", "Okwakashatu", "Okwakana", "Okwakataana", "Okwamukaaga", "Okwamushanju", "Okwamunaana", "Okwamwenda", "Okwaikumi", "Okwaikumi na kumwe", "Okwaikumi na ibiri"}, + daysAbbreviated: []string{"SAN", "ORK", "OKB", "OKS", "OKN", "OKT", "OMK"}, + daysNarrow: []string{"S", "K", "R", "S", "N", "T", "M"}, + daysWide: []string{"Sande", "Orwokubanza", "Orwakabiri", "Orwakashatu", "Orwakana", "Orwakataano", "Orwamukaaga"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kurisito Atakaijire", "Kurisito Yaijire"}, + timezones: map[string]string{"HECU": "HECU", "WART": "WART", "CLT": "CLT", "ChST": "ChST", "BT": "BT", "HEEG": "HEEG", "∅∅∅": "∅∅∅", "HNOG": "HNOG", "MST": "MST", "HNPMX": "HNPMX", "SRT": "SRT", "CHAST": "CHAST", "ACWST": "ACWST", "CLST": "CLST", "HEPM": "HEPM", "SGT": "SGT", "NZST": "NZST", "NZDT": "NZDT", "AST": "AST", "WESZ": "WESZ", "TMT": "TMT", "AKST": "AKST", "WAT": "WAT", "WAST": "WAST", "AEDT": "AEDT", "SAST": "SAST", "IST": "IST", "OESZ": "OESZ", "MYT": "MYT", "ARST": "ARST", "WITA": "WITA", "BOT": "BOT", "PDT": "PDT", "MESZ": "MESZ", "WEZ": "WEZ", "ART": "ART", "HKT": "HKT", "CST": "CST", "AWST": "AWST", "JDT": "JDT", "EST": "EST", "HAT": "HAT", "UYT": "UYT", "LHDT": "LHDT", "HEPMX": "HEPMX", "HNCU": "HNCU", "WIB": "WIB", "ACWDT": "ACWDT", "HENOMX": "HENOMX", "OEZ": "OEZ", "HNPM": "HNPM", "LHST": "LHST", "GYT": "GYT", "GMT": "GMT", "AKDT": "AKDT", "AEST": "AEST", "CHADT": "CHADT", "VET": "VET", "EDT": "EDT", "EAT": "EAT", "CDT": "CDT", "WARST": "WARST", "HKST": "HKST", "HNNOMX": "HNNOMX", "HNT": "HNT", "HEOG": "HEOG", "COT": "COT", "GFT": "GFT", "JST": "JST", "ADT": "ADT", "ACST": "ACST", "HNEG": "HNEG", "WIT": "WIT", "HADT": "HADT", "TMST": "TMST", "COST": "COST", "UYST": "UYST", "AWDT": "AWDT", "HAST": "HAST", "ECT": "ECT", "MEZ": "MEZ", "ACDT": "ACDT", "PST": "PST", "CAT": "CAT", "MDT": "MDT"}, + } +} + +// Locale returns the current translators string locale +func (nyn *nyn) Locale() string { + return nyn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nyn' +func (nyn *nyn) PluralsCardinal() []locales.PluralRule { + return nyn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nyn' +func (nyn *nyn) PluralsOrdinal() []locales.PluralRule { + return nyn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nyn' +func (nyn *nyn) PluralsRange() []locales.PluralRule { + return nyn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nyn' +func (nyn *nyn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nyn' +func (nyn *nyn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nyn' +func (nyn *nyn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nyn *nyn) MonthAbbreviated(month time.Month) string { + return nyn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nyn *nyn) MonthsAbbreviated() []string { + return nyn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nyn *nyn) MonthNarrow(month time.Month) string { + return nyn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nyn *nyn) MonthsNarrow() []string { + return nyn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nyn *nyn) MonthWide(month time.Month) string { + return nyn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nyn *nyn) MonthsWide() []string { + return nyn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nyn *nyn) WeekdayAbbreviated(weekday time.Weekday) string { + return nyn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nyn *nyn) WeekdaysAbbreviated() []string { + return nyn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nyn *nyn) WeekdayNarrow(weekday time.Weekday) string { + return nyn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nyn *nyn) WeekdaysNarrow() []string { + return nyn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nyn *nyn) WeekdayShort(weekday time.Weekday) string { + return nyn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nyn *nyn) WeekdaysShort() []string { + return nyn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nyn *nyn) WeekdayWide(weekday time.Weekday) string { + return nyn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nyn *nyn) WeekdaysWide() []string { + return nyn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nyn' and handles both Whole and Real numbers based on 'v' +func (nyn *nyn) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nyn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nyn *nyn) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nyn' +func (nyn *nyn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nyn.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nyn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nyn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, nyn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nyn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nyn' +// in accounting notation. +func (nyn *nyn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nyn.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nyn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nyn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, nyn.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nyn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nyn' +func (nyn *nyn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nyn' +func (nyn *nyn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nyn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nyn' +func (nyn *nyn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nyn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nyn' +func (nyn *nyn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nyn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nyn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nyn' +func (nyn *nyn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nyn' +func (nyn *nyn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nyn' +func (nyn *nyn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nyn' +func (nyn *nyn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nyn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nyn/nyn_test.go b/vendor/github.com/go-playground/locales/nyn/nyn_test.go new file mode 100644 index 0000000000..9c77419a48 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nyn/nyn_test.go @@ -0,0 +1,1120 @@ +package nyn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nyn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/nyn_UG/nyn_UG.go b/vendor/github.com/go-playground/locales/nyn_UG/nyn_UG.go new file mode 100644 index 0000000000..4b2f9ca579 --- /dev/null +++ b/vendor/github.com/go-playground/locales/nyn_UG/nyn_UG.go @@ -0,0 +1,515 @@ +package nyn_UG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type nyn_UG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'nyn_UG' locale +func New() locales.Translator { + return &nyn_UG{ + locale: "nyn_UG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "KBZ", "KBR", "KST", "KKN", "KTN", "KMK", "KMS", "KMN", "KMW", "KKM", "KNK", "KNB"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Okwokubanza", "Okwakabiri", "Okwakashatu", "Okwakana", "Okwakataana", "Okwamukaaga", "Okwamushanju", "Okwamunaana", "Okwamwenda", "Okwaikumi", "Okwaikumi na kumwe", "Okwaikumi na ibiri"}, + daysAbbreviated: []string{"SAN", "ORK", "OKB", "OKS", "OKN", "OKT", "OMK"}, + daysNarrow: []string{"S", "K", "R", "S", "N", "T", "M"}, + daysWide: []string{"Sande", "Orwokubanza", "Orwakabiri", "Orwakashatu", "Orwakana", "Orwakataano", "Orwamukaaga"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kurisito Atakaijire", "Kurisito Yaijire"}, + timezones: map[string]string{"HEEG": "HEEG", "HECU": "HECU", "ART": "ART", "HNNOMX": "HNNOMX", "ACST": "ACST", "HNT": "HNT", "GFT": "GFT", "WIB": "WIB", "CHAST": "CHAST", "IST": "IST", "WEZ": "WEZ", "GMT": "GMT", "ARST": "ARST", "EST": "EST", "HEPM": "HEPM", "HNCU": "HNCU", "∅∅∅": "∅∅∅", "ACWDT": "ACWDT", "MYT": "MYT", "WARST": "WARST", "WAST": "WAST", "CDT": "CDT", "HADT": "HADT", "ACDT": "ACDT", "HEPMX": "HEPMX", "BOT": "BOT", "MESZ": "MESZ", "ADT": "ADT", "TMST": "TMST", "GYT": "GYT", "HAST": "HAST", "NZDT": "NZDT", "ECT": "ECT", "ACWST": "ACWST", "CAT": "CAT", "PST": "PST", "PDT": "PDT", "TMT": "TMT", "MST": "MST", "COT": "COT", "COST": "COST", "AWST": "AWST", "MEZ": "MEZ", "ChST": "ChST", "JST": "JST", "JDT": "JDT", "SRT": "SRT", "SAST": "SAST", "NZST": "NZST", "AKST": "AKST", "OESZ": "OESZ", "CLT": "CLT", "HNEG": "HNEG", "HNPM": "HNPM", "SGT": "SGT", "CHADT": "CHADT", "HEOG": "HEOG", "WAT": "WAT", "HENOMX": "HENOMX", "WITA": "WITA", "UYST": "UYST", "LHDT": "LHDT", "WESZ": "WESZ", "WART": "WART", "HNPMX": "HNPMX", "EDT": "EDT", "HAT": "HAT", "EAT": "EAT", "VET": "VET", "MDT": "MDT", "HKST": "HKST", "AKDT": "AKDT", "UYT": "UYT", "LHST": "LHST", "OEZ": "OEZ", "CLST": "CLST", "AST": "AST", "HKT": "HKT", "AEDT": "AEDT", "WIT": "WIT", "AWDT": "AWDT", "BT": "BT", "AEST": "AEST", "CST": "CST", "HNOG": "HNOG"}, + } +} + +// Locale returns the current translators string locale +func (nyn *nyn_UG) Locale() string { + return nyn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'nyn_UG' +func (nyn *nyn_UG) PluralsCardinal() []locales.PluralRule { + return nyn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'nyn_UG' +func (nyn *nyn_UG) PluralsOrdinal() []locales.PluralRule { + return nyn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'nyn_UG' +func (nyn *nyn_UG) PluralsRange() []locales.PluralRule { + return nyn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nyn_UG' +func (nyn *nyn_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nyn_UG' +func (nyn *nyn_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nyn_UG' +func (nyn *nyn_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (nyn *nyn_UG) MonthAbbreviated(month time.Month) string { + return nyn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (nyn *nyn_UG) MonthsAbbreviated() []string { + return nyn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (nyn *nyn_UG) MonthNarrow(month time.Month) string { + return nyn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (nyn *nyn_UG) MonthsNarrow() []string { + return nyn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (nyn *nyn_UG) MonthWide(month time.Month) string { + return nyn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (nyn *nyn_UG) MonthsWide() []string { + return nyn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (nyn *nyn_UG) WeekdayAbbreviated(weekday time.Weekday) string { + return nyn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (nyn *nyn_UG) WeekdaysAbbreviated() []string { + return nyn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (nyn *nyn_UG) WeekdayNarrow(weekday time.Weekday) string { + return nyn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (nyn *nyn_UG) WeekdaysNarrow() []string { + return nyn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (nyn *nyn_UG) WeekdayShort(weekday time.Weekday) string { + return nyn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (nyn *nyn_UG) WeekdaysShort() []string { + return nyn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (nyn *nyn_UG) WeekdayWide(weekday time.Weekday) string { + return nyn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (nyn *nyn_UG) WeekdaysWide() []string { + return nyn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'nyn_UG' and handles both Whole and Real numbers based on 'v' +func (nyn *nyn_UG) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'nyn_UG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (nyn *nyn_UG) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nyn_UG' +func (nyn *nyn_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nyn.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nyn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nyn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, nyn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nyn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nyn_UG' +// in accounting notation. +func (nyn *nyn_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := nyn.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, nyn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, nyn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, nyn.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, nyn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'nyn_UG' +func (nyn *nyn_UG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'nyn_UG' +func (nyn *nyn_UG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nyn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'nyn_UG' +func (nyn *nyn_UG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nyn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'nyn_UG' +func (nyn *nyn_UG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, nyn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, nyn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'nyn_UG' +func (nyn *nyn_UG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'nyn_UG' +func (nyn *nyn_UG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'nyn_UG' +func (nyn *nyn_UG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'nyn_UG' +func (nyn *nyn_UG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, nyn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := nyn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/nyn_UG/nyn_UG_test.go b/vendor/github.com/go-playground/locales/nyn_UG/nyn_UG_test.go new file mode 100644 index 0000000000..3ad50282ab --- /dev/null +++ b/vendor/github.com/go-playground/locales/nyn_UG/nyn_UG_test.go @@ -0,0 +1,1120 @@ +package nyn_UG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "nyn_UG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/om/om.go b/vendor/github.com/go-playground/locales/om/om.go new file mode 100644 index 0000000000..d7e962fb45 --- /dev/null +++ b/vendor/github.com/go-playground/locales/om/om.go @@ -0,0 +1,631 @@ +package om + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type om struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'om' locale +func New() locales.Translator { + return &om{ + locale: "om", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "Br", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Ama", "Gur", "Bit", "Elb", "Cam", "Wax", "Ado", "Hag", "Ful", "Onk", "Sad", "Mud"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Amajjii", "Guraandhala", "Bitooteessa", "Elba", "Caamsa", "Waxabajjii", "Adooleessa", "Hagayya", "Fuulbana", "Onkololeessa", "Sadaasa", "Muddee"}, + daysAbbreviated: []string{"Dil", "Wix", "Qib", "Rob", "Kam", "Jim", "San"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Dil", "Wix", "Qib", "Rob", "Kam", "Jim", "San"}, + daysWide: []string{"Dilbata", "Wiixata", "Qibxata", "Roobii", "Kamiisa", "Jimaata", "Sanbata"}, + periodsAbbreviated: []string{"WD", "WB"}, + periodsNarrow: []string{"WD", "WB"}, + periodsWide: []string{"WD", "WB"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"AEST": "AEST", "HNCU": "HNCU", "AWDT": "AWDT", "WESZ": "WESZ", "TMT": "TMT", "WAT": "WAT", "HKT": "HKT", "HNT": "HNT", "WIB": "WIB", "AWST": "AWST", "COST": "COST", "HENOMX": "HENOMX", "GFT": "GFT", "AKDT": "AKDT", "SRT": "SRT", "GYT": "GYT", "ADT": "ADT", "TMST": "TMST", "WIT": "WIT", "EDT": "EDT", "HKST": "HKST", "ACST": "ACST", "HEEG": "HEEG", "MDT": "MDT", "HEPM": "HEPM", "EAT": "EAT", "CHADT": "CHADT", "HAST": "HAST", "ACWDT": "ACWDT", "NZST": "NZST", "MEZ": "MEZ", "VET": "VET", "JST": "JST", "OEZ": "OEZ", "CAT": "CAT", "WARST": "WARST", "AST": "AST", "WAST": "WAST", "ChST": "ChST", "UYT": "UYT", "UYST": "UYST", "PDT": "PDT", "HEOG": "HEOG", "OESZ": "OESZ", "GMT": "GMT", "ACDT": "ACDT", "COT": "COT", "HAT": "HAT", "HNEG": "HNEG", "HEPMX": "HEPMX", "CST": "CST", "WART": "WART", "EST": "EST", "∅∅∅": "∅∅∅", "PST": "PST", "CLST": "CLST", "CHAST": "CHAST", "SGT": "SGT", "NZDT": "NZDT", "CLT": "CLT", "AKST": "AKST", "LHDT": "LHDT", "MESZ": "MESZ", "JDT": "JDT", "HNOG": "HNOG", "WEZ": "WEZ", "ARST": "ARST", "BT": "BT", "MST": "MST", "WITA": "WITA", "SAST": "SAST", "HECU": "HECU", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "IST": "IST", "MYT": "MYT", "ART": "ART", "HNPM": "HNPM", "CDT": "CDT", "ECT": "ECT", "AEDT": "AEDT", "LHST": "LHST", "BOT": "BOT", "HADT": "HADT", "ACWST": "ACWST"}, + } +} + +// Locale returns the current translators string locale +func (om *om) Locale() string { + return om.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'om' +func (om *om) PluralsCardinal() []locales.PluralRule { + return om.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'om' +func (om *om) PluralsOrdinal() []locales.PluralRule { + return om.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'om' +func (om *om) PluralsRange() []locales.PluralRule { + return om.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'om' +func (om *om) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'om' +func (om *om) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'om' +func (om *om) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (om *om) MonthAbbreviated(month time.Month) string { + return om.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (om *om) MonthsAbbreviated() []string { + return om.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (om *om) MonthNarrow(month time.Month) string { + return om.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (om *om) MonthsNarrow() []string { + return om.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (om *om) MonthWide(month time.Month) string { + return om.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (om *om) MonthsWide() []string { + return om.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (om *om) WeekdayAbbreviated(weekday time.Weekday) string { + return om.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (om *om) WeekdaysAbbreviated() []string { + return om.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (om *om) WeekdayNarrow(weekday time.Weekday) string { + return om.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (om *om) WeekdaysNarrow() []string { + return om.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (om *om) WeekdayShort(weekday time.Weekday) string { + return om.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (om *om) WeekdaysShort() []string { + return om.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (om *om) WeekdayWide(weekday time.Weekday) string { + return om.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (om *om) WeekdaysWide() []string { + return om.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'om' and handles both Whole and Real numbers based on 'v' +func (om *om) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'om' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (om *om) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, om.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'om' +func (om *om) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := om.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, om.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'om' +// in accounting notation. +func (om *om) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := om.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, om.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, om.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'om' +func (om *om) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'om' +func (om *om) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, om.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'om' +func (om *om) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, om.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'om' +func (om *om) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, om.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, om.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'om' +func (om *om) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, om.periodsAbbreviated[0]...) + } else { + b = append(b, om.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'om' +func (om *om) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, om.periodsAbbreviated[0]...) + } else { + b = append(b, om.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'om' +func (om *om) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, om.periodsAbbreviated[0]...) + } else { + b = append(b, om.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'om' +func (om *om) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, om.periodsAbbreviated[0]...) + } else { + b = append(b, om.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := om.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/om/om_test.go b/vendor/github.com/go-playground/locales/om/om_test.go new file mode 100644 index 0000000000..9c1e3dce80 --- /dev/null +++ b/vendor/github.com/go-playground/locales/om/om_test.go @@ -0,0 +1,1120 @@ +package om + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "om" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/om_ET/om_ET.go b/vendor/github.com/go-playground/locales/om_ET/om_ET.go new file mode 100644 index 0000000000..c28bb73019 --- /dev/null +++ b/vendor/github.com/go-playground/locales/om_ET/om_ET.go @@ -0,0 +1,631 @@ +package om_ET + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type om_ET struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'om_ET' locale +func New() locales.Translator { + return &om_ET{ + locale: "om_ET", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Ama", "Gur", "Bit", "Elb", "Cam", "Wax", "Ado", "Hag", "Ful", "Onk", "Sad", "Mud"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Amajjii", "Guraandhala", "Bitooteessa", "Elba", "Caamsa", "Waxabajjii", "Adooleessa", "Hagayya", "Fuulbana", "Onkololeessa", "Sadaasa", "Muddee"}, + daysAbbreviated: []string{"Dil", "Wix", "Qib", "Rob", "Kam", "Jim", "San"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Dil", "Wix", "Qib", "Rob", "Kam", "Jim", "San"}, + daysWide: []string{"Dilbata", "Wiixata", "Qibxata", "Roobii", "Kamiisa", "Jimaata", "Sanbata"}, + periodsAbbreviated: []string{"WD", "WB"}, + periodsNarrow: []string{"WD", "WB"}, + periodsWide: []string{"WD", "WB"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"CLST": "CLST", "LHDT": "LHDT", "HEPMX": "HEPMX", "GYT": "GYT", "AWDT": "AWDT", "CLT": "CLT", "VET": "VET", "MEZ": "MEZ", "EDT": "EDT", "COT": "COT", "AKDT": "AKDT", "ChST": "ChST", "MESZ": "MESZ", "WART": "WART", "AST": "AST", "MDT": "MDT", "UYST": "UYST", "NZST": "NZST", "ARST": "ARST", "ACST": "ACST", "AEST": "AEST", "LHST": "LHST", "SGT": "SGT", "OESZ": "OESZ", "MYT": "MYT", "HAT": "HAT", "ART": "ART", "HNT": "HNT", "PDT": "PDT", "HAST": "HAST", "ECT": "ECT", "ACWST": "ACWST", "WEZ": "WEZ", "HNNOMX": "HNNOMX", "HNEG": "HNEG", "HNPMX": "HNPMX", "HECU": "HECU", "BOT": "BOT", "CHAST": "CHAST", "CHADT": "CHADT", "TMT": "TMT", "AKST": "AKST", "PST": "PST", "IST": "IST", "WAST": "WAST", "ACDT": "ACDT", "GFT": "GFT", "SAST": "SAST", "AWST": "AWST", "HKST": "HKST", "WIT": "WIT", "TMST": "TMST", "AEDT": "AEDT", "SRT": "SRT", "CST": "CST", "JST": "JST", "WARST": "WARST", "HNOG": "HNOG", "HEEG": "HEEG", "BT": "BT", "UYT": "UYT", "JDT": "JDT", "WESZ": "WESZ", "ADT": "ADT", "EST": "EST", "CDT": "CDT", "NZDT": "NZDT", "WAT": "WAT", "COST": "COST", "CAT": "CAT", "MST": "MST", "HKT": "HKT", "HEPM": "HEPM", "∅∅∅": "∅∅∅", "HNCU": "HNCU", "WIB": "WIB", "ACWDT": "ACWDT", "HENOMX": "HENOMX", "WITA": "WITA", "HEOG": "HEOG", "HNPM": "HNPM", "EAT": "EAT", "HADT": "HADT", "OEZ": "OEZ", "GMT": "GMT"}, + } +} + +// Locale returns the current translators string locale +func (om *om_ET) Locale() string { + return om.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'om_ET' +func (om *om_ET) PluralsCardinal() []locales.PluralRule { + return om.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'om_ET' +func (om *om_ET) PluralsOrdinal() []locales.PluralRule { + return om.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'om_ET' +func (om *om_ET) PluralsRange() []locales.PluralRule { + return om.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'om_ET' +func (om *om_ET) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'om_ET' +func (om *om_ET) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'om_ET' +func (om *om_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (om *om_ET) MonthAbbreviated(month time.Month) string { + return om.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (om *om_ET) MonthsAbbreviated() []string { + return om.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (om *om_ET) MonthNarrow(month time.Month) string { + return om.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (om *om_ET) MonthsNarrow() []string { + return om.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (om *om_ET) MonthWide(month time.Month) string { + return om.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (om *om_ET) MonthsWide() []string { + return om.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (om *om_ET) WeekdayAbbreviated(weekday time.Weekday) string { + return om.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (om *om_ET) WeekdaysAbbreviated() []string { + return om.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (om *om_ET) WeekdayNarrow(weekday time.Weekday) string { + return om.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (om *om_ET) WeekdaysNarrow() []string { + return om.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (om *om_ET) WeekdayShort(weekday time.Weekday) string { + return om.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (om *om_ET) WeekdaysShort() []string { + return om.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (om *om_ET) WeekdayWide(weekday time.Weekday) string { + return om.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (om *om_ET) WeekdaysWide() []string { + return om.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'om_ET' and handles both Whole and Real numbers based on 'v' +func (om *om_ET) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'om_ET' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (om *om_ET) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, om.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'om_ET' +func (om *om_ET) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := om.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, om.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'om_ET' +// in accounting notation. +func (om *om_ET) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := om.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, om.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, om.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'om_ET' +func (om *om_ET) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'om_ET' +func (om *om_ET) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, om.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'om_ET' +func (om *om_ET) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, om.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'om_ET' +func (om *om_ET) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, om.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, om.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'om_ET' +func (om *om_ET) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, om.periodsAbbreviated[0]...) + } else { + b = append(b, om.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'om_ET' +func (om *om_ET) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, om.periodsAbbreviated[0]...) + } else { + b = append(b, om.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'om_ET' +func (om *om_ET) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, om.periodsAbbreviated[0]...) + } else { + b = append(b, om.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'om_ET' +func (om *om_ET) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, om.periodsAbbreviated[0]...) + } else { + b = append(b, om.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := om.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/om_ET/om_ET_test.go b/vendor/github.com/go-playground/locales/om_ET/om_ET_test.go new file mode 100644 index 0000000000..f1977b807a --- /dev/null +++ b/vendor/github.com/go-playground/locales/om_ET/om_ET_test.go @@ -0,0 +1,1120 @@ +package om_ET + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "om_ET" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/om_KE/om_KE.go b/vendor/github.com/go-playground/locales/om_KE/om_KE.go new file mode 100644 index 0000000000..022d985747 --- /dev/null +++ b/vendor/github.com/go-playground/locales/om_KE/om_KE.go @@ -0,0 +1,593 @@ +package om_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type om_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'om_KE' locale +func New() locales.Translator { + return &om_KE{ + locale: "om_KE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Ama", "Gur", "Bit", "Elb", "Cam", "Wax", "Ado", "Hag", "Ful", "Onk", "Sad", "Mud"}, + monthsNarrow: []string{"", "A", "G", "B", "E", "C", "W", "A", "H", "F", "O", "S", "M"}, + monthsWide: []string{"", "Amajjii", "Guraandhala", "Bitooteessa", "Elba", "Caamsa", "Waxabajjii", "Adooleessa", "Hagayya", "Fuulbana", "Onkololeessa", "Sadaasa", "Muddee"}, + daysAbbreviated: []string{"Dil", "Wix", "Qib", "Rob", "Kam", "Jim", "San"}, + daysNarrow: []string{"D", "W", "Q", "R", "K", "J", "S"}, + daysShort: []string{"Dil", "Wix", "Qib", "Rob", "Kam", "Jim", "San"}, + daysWide: []string{"Dilbata", "Wiixata", "Qibxata", "Roobii", "Kamiisa", "Jimaata", "Sanbata"}, + periodsAbbreviated: []string{"WD", "WB"}, + periodsNarrow: []string{"WD", "WB"}, + periodsWide: []string{"WD", "WB"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNCU": "HNCU", "AWST": "AWST", "PST": "PST", "EDT": "EDT", "HKT": "HKT", "AKDT": "AKDT", "ChST": "ChST", "UYST": "UYST", "SRT": "SRT", "HECU": "HECU", "WIB": "WIB", "TMT": "TMT", "GFT": "GFT", "HNPM": "HNPM", "LHDT": "LHDT", "TMST": "TMST", "MDT": "MDT", "ART": "ART", "WAT": "WAT", "AEST": "AEST", "UYT": "UYT", "WIT": "WIT", "HAST": "HAST", "IST": "IST", "MYT": "MYT", "OESZ": "OESZ", "GMT": "GMT", "HNT": "HNT", "ECT": "ECT", "WAST": "WAST", "EAT": "EAT", "CDT": "CDT", "NZDT": "NZDT", "HEOG": "HEOG", "OEZ": "OEZ", "HEPM": "HEPM", "BOT": "BOT", "NZST": "NZST", "MESZ": "MESZ", "WEZ": "WEZ", "ACST": "ACST", "ACDT": "ACDT", "COT": "COT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "CHAST": "CHAST", "HADT": "HADT", "BT": "BT", "PDT": "PDT", "JST": "JST", "MST": "MST", "SAST": "SAST", "∅∅∅": "∅∅∅", "AWDT": "AWDT", "MEZ": "MEZ", "WARST": "WARST", "CLST": "CLST", "HAT": "HAT", "ACWST": "ACWST", "VET": "VET", "WESZ": "WESZ", "EST": "EST", "HEEG": "HEEG", "AEDT": "AEDT", "CAT": "CAT", "WITA": "WITA", "AKST": "AKST", "HNPMX": "HNPMX", "CST": "CST", "CHADT": "CHADT", "ACWDT": "ACWDT", "CLT": "CLT", "HNOG": "HNOG", "HNEG": "HNEG", "SGT": "SGT", "HEPMX": "HEPMX", "JDT": "JDT", "AST": "AST", "LHST": "LHST", "WART": "WART", "ADT": "ADT", "ARST": "ARST", "HKST": "HKST", "COST": "COST", "GYT": "GYT"}, + } +} + +// Locale returns the current translators string locale +func (om *om_KE) Locale() string { + return om.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'om_KE' +func (om *om_KE) PluralsCardinal() []locales.PluralRule { + return om.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'om_KE' +func (om *om_KE) PluralsOrdinal() []locales.PluralRule { + return om.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'om_KE' +func (om *om_KE) PluralsRange() []locales.PluralRule { + return om.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'om_KE' +func (om *om_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'om_KE' +func (om *om_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'om_KE' +func (om *om_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (om *om_KE) MonthAbbreviated(month time.Month) string { + return om.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (om *om_KE) MonthsAbbreviated() []string { + return om.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (om *om_KE) MonthNarrow(month time.Month) string { + return om.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (om *om_KE) MonthsNarrow() []string { + return om.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (om *om_KE) MonthWide(month time.Month) string { + return om.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (om *om_KE) MonthsWide() []string { + return om.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (om *om_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return om.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (om *om_KE) WeekdaysAbbreviated() []string { + return om.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (om *om_KE) WeekdayNarrow(weekday time.Weekday) string { + return om.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (om *om_KE) WeekdaysNarrow() []string { + return om.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (om *om_KE) WeekdayShort(weekday time.Weekday) string { + return om.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (om *om_KE) WeekdaysShort() []string { + return om.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (om *om_KE) WeekdayWide(weekday time.Weekday) string { + return om.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (om *om_KE) WeekdaysWide() []string { + return om.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'om_KE' and handles both Whole and Real numbers based on 'v' +func (om *om_KE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'om_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (om *om_KE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, om.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'om_KE' +func (om *om_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := om.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, om.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, om.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'om_KE' +// in accounting notation. +func (om *om_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := om.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, om.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, om.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, om.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, om.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'om_KE' +func (om *om_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'om_KE' +func (om *om_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, om.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'om_KE' +func (om *om_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, om.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'om_KE' +func (om *om_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, om.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, om.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'om_KE' +func (om *om_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'om_KE' +func (om *om_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'om_KE' +func (om *om_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'om_KE' +func (om *om_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, om.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, om.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := om.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/om_KE/om_KE_test.go b/vendor/github.com/go-playground/locales/om_KE/om_KE_test.go new file mode 100644 index 0000000000..8947392935 --- /dev/null +++ b/vendor/github.com/go-playground/locales/om_KE/om_KE_test.go @@ -0,0 +1,1120 @@ +package om_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "om_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/or/or.go b/vendor/github.com/go-playground/locales/or/or.go new file mode 100644 index 0000000000..7ca0e1b8ab --- /dev/null +++ b/vendor/github.com/go-playground/locales/or/or.go @@ -0,0 +1,648 @@ +package or + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type or struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'or' locale +func New() locales.Translator { + return &or{ + locale: "or", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ଜାନୁଆରୀ", "ଫେବୃଆରୀ", "ମାର୍ଚ୍ଚ", "ଅପ୍ରେଲ", "ମଇ", "ଜୁନ", "ଜୁଲାଇ", "ଅଗଷ୍ଟ", "ସେପ୍ଟେମ୍ବର", "ଅକ୍ଟୋବର", "ନଭେମ୍ବର", "ଡିସେମ୍ବର"}, + monthsNarrow: []string{"", "ଜା", "ଫେ", "ମା", "ଅ", "ମଇ", "ଜୁ", "ଜୁ", "ଅ", "ସେ", "ଅ", "ନ", "ଡି"}, + monthsWide: []string{"", "ଜାନୁଆରୀ", "ଫେବୃଆରୀ", "ମାର୍ଚ୍ଚ", "ଅପ୍ରେଲ", "ମଇ", "ଜୁନ", "ଜୁଲାଇ", "ଅଗଷ୍ଟ", "ସେପ୍ଟେମ୍ବର", "ଅକ୍ଟୋବର", "ନଭେମ୍ବର", "ଡିସେମ୍ବର"}, + daysAbbreviated: []string{"ରବି", "ସୋମ", "ମଙ୍ଗଳ", "ବୁଧ", "ଗୁରୁ", "ଶୁକ୍ର", "ଶନି"}, + daysNarrow: []string{"ର", "ସୋ", "ମ", "ବୁ", "ଗୁ", "ଶୁ", "ଶ"}, + daysWide: []string{"ରବିବାର", "ସୋମବାର", "ମଙ୍ଗଳବାର", "ବୁଧବାର", "ଗୁରୁବାର", "ଶୁକ୍ରବାର", "ଶନିବାର"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"am", "pm"}, + timezones: map[string]string{"ACDT": "ACDT", "ACWDT": "ACWDT", "HNPMX": "HNPMX", "SAST": "SAST", "SGT": "SGT", "ACST": "ACST", "MDT": "MDT", "HEPM": "HEPM", "WESZ": "WESZ", "HNOG": "HNOG", "OESZ": "OESZ", "ART": "ART", "NZDT": "NZDT", "MESZ": "MESZ", "WEZ": "WEZ", "EAT": "EAT", "VET": "VET", "CLT": "CLT", "TMST": "TMST", "HEEG": "HEEG", "AKST": "AKST", "UYT": "UYT", "HNCU": "HNCU", "CAT": "CAT", "HEOG": "HEOG", "AST": "AST", "HNEG": "HNEG", "MST": "MST", "UYST": "UYST", "IST": "IST", "WAT": "WAT", "HENOMX": "HENOMX", "CHADT": "CHADT", "AWDT": "AWDT", "PST": "PST", "JDT": "JDT", "HNNOMX": "HNNOMX", "WITA": "WITA", "HECU": "HECU", "HAT": "HAT", "AEST": "AEST", "GFT": "GFT", "AKDT": "AKDT", "JST": "JST", "EDT": "EDT", "∅∅∅": "∅∅∅", "BT": "BT", "GMT": "GMT", "WART": "WART", "ADT": "ADT", "WIT": "WIT", "CHAST": "CHAST", "WARST": "WARST", "EST": "EST", "ChST": "ChST", "HEPMX": "HEPMX", "AWST": "AWST", "ACWST": "ACWST", "TMT": "TMT", "ARST": "ARST", "LHDT": "LHDT", "GYT": "GYT", "CST": "CST", "PDT": "PDT", "OEZ": "OEZ", "WAST": "WAST", "COT": "COT", "HNT": "HNT", "WIB": "WIB", "BOT": "BOT", "HADT": "HADT", "MYT": "MYT", "HKT": "HKT", "SRT": "SRT", "LHST": "LHST", "NZST": "NZST", "HKST": "HKST", "COST": "COST", "ECT": "ECT", "CDT": "CDT", "CLST": "CLST", "MEZ": "MEZ", "AEDT": "AEDT", "HNPM": "HNPM", "HAST": "HAST"}, + } +} + +// Locale returns the current translators string locale +func (or *or) Locale() string { + return or.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'or' +func (or *or) PluralsCardinal() []locales.PluralRule { + return or.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'or' +func (or *or) PluralsOrdinal() []locales.PluralRule { + return or.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'or' +func (or *or) PluralsRange() []locales.PluralRule { + return or.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'or' +func (or *or) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'or' +func (or *or) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'or' +func (or *or) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (or *or) MonthAbbreviated(month time.Month) string { + return or.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (or *or) MonthsAbbreviated() []string { + return or.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (or *or) MonthNarrow(month time.Month) string { + return or.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (or *or) MonthsNarrow() []string { + return or.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (or *or) MonthWide(month time.Month) string { + return or.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (or *or) MonthsWide() []string { + return or.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (or *or) WeekdayAbbreviated(weekday time.Weekday) string { + return or.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (or *or) WeekdaysAbbreviated() []string { + return or.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (or *or) WeekdayNarrow(weekday time.Weekday) string { + return or.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (or *or) WeekdaysNarrow() []string { + return or.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (or *or) WeekdayShort(weekday time.Weekday) string { + return or.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (or *or) WeekdaysShort() []string { + return or.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (or *or) WeekdayWide(weekday time.Weekday) string { + return or.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (or *or) WeekdaysWide() []string { + return or.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'or' and handles both Whole and Real numbers based on 'v' +func (or *or) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, or.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, or.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, or.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'or' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (or *or) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, or.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, or.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, or.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'or' +func (or *or) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := or.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, or.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, or.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(or.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, or.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, or.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, or.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'or' +// in accounting notation. +func (or *or) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := or.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, or.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, or.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(or.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, or.currencyNegativePrefix[j]) + } + + b = append(b, or.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(or.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, or.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, or.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'or' +func (or *or) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'or' +func (or *or) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, or.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'or' +func (or *or) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, or.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'or' +func (or *or) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, or.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, or.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'or' +func (or *or) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, or.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, or.periodsAbbreviated[0]...) + } else { + b = append(b, or.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'or' +func (or *or) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, or.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, or.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, or.periodsAbbreviated[0]...) + } else { + b = append(b, or.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'or' +func (or *or) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, or.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, or.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, or.periodsAbbreviated[0]...) + } else { + b = append(b, or.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'or' +func (or *or) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, or.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, or.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, or.periodsAbbreviated[0]...) + } else { + b = append(b, or.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := or.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/or/or_test.go b/vendor/github.com/go-playground/locales/or/or_test.go new file mode 100644 index 0000000000..0d57e29ded --- /dev/null +++ b/vendor/github.com/go-playground/locales/or/or_test.go @@ -0,0 +1,1120 @@ +package or + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "or" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/or_IN/or_IN.go b/vendor/github.com/go-playground/locales/or_IN/or_IN.go new file mode 100644 index 0000000000..5be6f8e526 --- /dev/null +++ b/vendor/github.com/go-playground/locales/or_IN/or_IN.go @@ -0,0 +1,648 @@ +package or_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type or_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'or_IN' locale +func New() locales.Translator { + return &or_IN{ + locale: "or_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ଜାନୁଆରୀ", "ଫେବୃଆରୀ", "ମାର୍ଚ୍ଚ", "ଅପ୍ରେଲ", "ମଇ", "ଜୁନ", "ଜୁଲାଇ", "ଅଗଷ୍ଟ", "ସେପ୍ଟେମ୍ବର", "ଅକ୍ଟୋବର", "ନଭେମ୍ବର", "ଡିସେମ୍ବର"}, + monthsNarrow: []string{"", "ଜା", "ଫେ", "ମା", "ଅ", "ମଇ", "ଜୁ", "ଜୁ", "ଅ", "ସେ", "ଅ", "ନ", "ଡି"}, + monthsWide: []string{"", "ଜାନୁଆରୀ", "ଫେବୃଆରୀ", "ମାର୍ଚ୍ଚ", "ଅପ୍ରେଲ", "ମଇ", "ଜୁନ", "ଜୁଲାଇ", "ଅଗଷ୍ଟ", "ସେପ୍ଟେମ୍ବର", "ଅକ୍ଟୋବର", "ନଭେମ୍ବର", "ଡିସେମ୍ବର"}, + daysAbbreviated: []string{"ରବି", "ସୋମ", "ମଙ୍ଗଳ", "ବୁଧ", "ଗୁରୁ", "ଶୁକ୍ର", "ଶନି"}, + daysNarrow: []string{"ର", "ସୋ", "ମ", "ବୁ", "ଗୁ", "ଶୁ", "ଶ"}, + daysWide: []string{"ରବିବାର", "ସୋମବାର", "ମଙ୍ଗଳବାର", "ବୁଧବାର", "ଗୁରୁବାର", "ଶୁକ୍ରବାର", "ଶନିବାର"}, + periodsAbbreviated: []string{"am", "pm"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"am", "pm"}, + timezones: map[string]string{"OESZ": "OESZ", "CLST": "CLST", "TMST": "TMST", "COST": "COST", "HEEG": "HEEG", "ACWDT": "ACWDT", "NZST": "NZST", "CAT": "CAT", "WEZ": "WEZ", "ADT": "ADT", "HNPM": "HNPM", "WIT": "WIT", "PST": "PST", "NZDT": "NZDT", "JST": "JST", "HAST": "HAST", "ARST": "ARST", "WAT": "WAT", "HENOMX": "HENOMX", "ACST": "ACST", "SRT": "SRT", "TMT": "TMT", "HKST": "HKST", "COT": "COT", "ECT": "ECT", "IST": "IST", "AST": "AST", "AKDT": "AKDT", "AWST": "AWST", "MESZ": "MESZ", "MYT": "MYT", "AEDT": "AEDT", "HNPMX": "HNPMX", "HEOG": "HEOG", "ACDT": "ACDT", "UYT": "UYT", "HEPMX": "HEPMX", "HADT": "HADT", "MEZ": "MEZ", "∅∅∅": "∅∅∅", "WITA": "WITA", "UYST": "UYST", "GYT": "GYT", "PDT": "PDT", "MDT": "MDT", "SGT": "SGT", "OEZ": "OEZ", "WESZ": "WESZ", "CLT": "CLT", "EDT": "EDT", "CDT": "CDT", "CHADT": "CHADT", "ACWST": "ACWST", "GMT": "GMT", "MST": "MST", "HNT": "HNT", "HAT": "HAT", "BT": "BT", "AWDT": "AWDT", "VET": "VET", "EST": "EST", "HKT": "HKT", "WAST": "WAST", "HNCU": "HNCU", "HECU": "HECU", "WIB": "WIB", "CST": "CST", "BOT": "BOT", "HNOG": "HNOG", "WARST": "WARST", "HNEG": "HNEG", "HEPM": "HEPM", "ChST": "ChST", "CHAST": "CHAST", "WART": "WART", "SAST": "SAST", "EAT": "EAT", "JDT": "JDT", "ART": "ART", "AEST": "AEST", "GFT": "GFT", "LHST": "LHST", "LHDT": "LHDT", "HNNOMX": "HNNOMX", "AKST": "AKST"}, + } +} + +// Locale returns the current translators string locale +func (or *or_IN) Locale() string { + return or.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'or_IN' +func (or *or_IN) PluralsCardinal() []locales.PluralRule { + return or.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'or_IN' +func (or *or_IN) PluralsOrdinal() []locales.PluralRule { + return or.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'or_IN' +func (or *or_IN) PluralsRange() []locales.PluralRule { + return or.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'or_IN' +func (or *or_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'or_IN' +func (or *or_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'or_IN' +func (or *or_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (or *or_IN) MonthAbbreviated(month time.Month) string { + return or.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (or *or_IN) MonthsAbbreviated() []string { + return or.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (or *or_IN) MonthNarrow(month time.Month) string { + return or.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (or *or_IN) MonthsNarrow() []string { + return or.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (or *or_IN) MonthWide(month time.Month) string { + return or.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (or *or_IN) MonthsWide() []string { + return or.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (or *or_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return or.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (or *or_IN) WeekdaysAbbreviated() []string { + return or.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (or *or_IN) WeekdayNarrow(weekday time.Weekday) string { + return or.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (or *or_IN) WeekdaysNarrow() []string { + return or.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (or *or_IN) WeekdayShort(weekday time.Weekday) string { + return or.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (or *or_IN) WeekdaysShort() []string { + return or.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (or *or_IN) WeekdayWide(weekday time.Weekday) string { + return or.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (or *or_IN) WeekdaysWide() []string { + return or.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'or_IN' and handles both Whole and Real numbers based on 'v' +func (or *or_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, or.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, or.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, or.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'or_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (or *or_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, or.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, or.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, or.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'or_IN' +func (or *or_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := or.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, or.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, or.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(or.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, or.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, or.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, or.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'or_IN' +// in accounting notation. +func (or *or_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := or.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, or.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, or.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(or.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, or.currencyNegativePrefix[j]) + } + + b = append(b, or.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(or.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, or.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, or.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'or_IN' +func (or *or_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'or_IN' +func (or *or_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, or.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'or_IN' +func (or *or_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, or.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'or_IN' +func (or *or_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, or.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, or.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'or_IN' +func (or *or_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, or.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, or.periodsAbbreviated[0]...) + } else { + b = append(b, or.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'or_IN' +func (or *or_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, or.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, or.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, or.periodsAbbreviated[0]...) + } else { + b = append(b, or.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'or_IN' +func (or *or_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, or.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, or.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, or.periodsAbbreviated[0]...) + } else { + b = append(b, or.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'or_IN' +func (or *or_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, or.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, or.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, or.periodsAbbreviated[0]...) + } else { + b = append(b, or.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := or.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/or_IN/or_IN_test.go b/vendor/github.com/go-playground/locales/or_IN/or_IN_test.go new file mode 100644 index 0000000000..4bae01cde2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/or_IN/or_IN_test.go @@ -0,0 +1,1120 @@ +package or_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "or_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/os/os.go b/vendor/github.com/go-playground/locales/os/os.go new file mode 100644 index 0000000000..2b2b8613d7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/os/os.go @@ -0,0 +1,615 @@ +package os + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type os struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'os' locale +func New() locales.Translator { + return &os{ + locale: "os", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "₾", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "янв.", "фев.", "мар.", "апр.", "майы", "июны", "июлы", "авг.", "сен.", "окт.", "ноя.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "январы", "февралы", "мартъийы", "апрелы", "майы", "июны", "июлы", "августы", "сентябры", "октябры", "ноябры", "декабры"}, + daysAbbreviated: []string{"хцб", "крс", "дцг", "ӕрт", "цпр", "мрб", "сбт"}, + daysNarrow: []string{"Х", "К", "Д", "Ӕ", "Ц", "М", "С"}, + daysWide: []string{"хуыцаубон", "къуырисӕр", "дыццӕг", "ӕртыццӕг", "цыппӕрӕм", "майрӕмбон", "сабат"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"ӕмбисбоны размӕ", "ӕмбисбоны фӕстӕ"}, + erasAbbreviated: []string{"н.д.а.", "н.д."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ACWST": "ACWST", "MESZ": "Астӕуккаг Европӕйаг сӕрдыгон рӕстӕг", "VET": "VET", "GYT": "GYT", "∅∅∅": "∅∅∅", "COST": "COST", "HNPM": "HNPM", "SGT": "SGT", "ECT": "ECT", "OEZ": "Скӕсӕн Европӕйаг стандартон рӕстӕг", "ACST": "ACST", "COT": "COT", "JST": "JST", "ACDT": "ACDT", "WIB": "WIB", "WIT": "WIT", "AWDT": "AWDT", "CHADT": "CHADT", "HECU": "HECU", "PST": "PST", "CAT": "CAT", "HNOG": "HNOG", "TMST": "TMST", "HNT": "HNT", "ChST": "ChST", "UYST": "UYST", "AST": "AST", "SRT": "SRT", "PDT": "PDT", "IST": "IST", "MST": "MST", "WAT": "WAT", "AEDT": "AEDT", "WITA": "WITA", "UYT": "UYT", "HNEG": "HNEG", "EAT": "EAT", "NZST": "NZST", "WEZ": "Ныгъуылӕн Европӕйаг стандартон рӕстӕг", "GMT": "Гринвичы рӕстӕмбис рӕстӕг", "WART": "WART", "CLST": "CLST", "HEOG": "HEOG", "LHDT": "LHDT", "HAST": "HAST", "OESZ": "Скӕсӕн Европӕйаг сӕрдыгон рӕстӕг", "MYT": "MYT", "ARST": "ARST", "WAST": "WAST", "HKT": "HKT", "HKST": "HKST", "HEPMX": "HEPMX", "MEZ": "Астӕуккаг Европӕйаг стандартон рӕстӕг", "WESZ": "Ныгъуылӕн Европӕйаг сӕрдыгон рӕстӕг", "WARST": "WARST", "AKDT": "AKDT", "AEST": "AEST", "LHST": "LHST", "JDT": "JDT", "AKST": "AKST", "GFT": "GFT", "SAST": "SAST", "CDT": "CDT", "BOT": "BOT", "ACWDT": "ACWDT", "HNNOMX": "HNNOMX", "HEPM": "HEPM", "CST": "CST", "CHAST": "CHAST", "NZDT": "NZDT", "EST": "EST", "HENOMX": "HENOMX", "HNCU": "HNCU", "ADT": "ADT", "CLT": "CLT", "ART": "ART", "EDT": "EDT", "HEEG": "HEEG", "AWST": "AWST", "HNPMX": "HNPMX", "HADT": "HADT", "TMT": "TMT", "MDT": "MDT", "BT": "BT", "HAT": "HAT"}, + } +} + +// Locale returns the current translators string locale +func (os *os) Locale() string { + return os.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'os' +func (os *os) PluralsCardinal() []locales.PluralRule { + return os.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'os' +func (os *os) PluralsOrdinal() []locales.PluralRule { + return os.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'os' +func (os *os) PluralsRange() []locales.PluralRule { + return os.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'os' +func (os *os) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'os' +func (os *os) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'os' +func (os *os) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (os *os) MonthAbbreviated(month time.Month) string { + return os.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (os *os) MonthsAbbreviated() []string { + return os.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (os *os) MonthNarrow(month time.Month) string { + return os.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (os *os) MonthsNarrow() []string { + return os.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (os *os) MonthWide(month time.Month) string { + return os.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (os *os) MonthsWide() []string { + return os.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (os *os) WeekdayAbbreviated(weekday time.Weekday) string { + return os.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (os *os) WeekdaysAbbreviated() []string { + return os.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (os *os) WeekdayNarrow(weekday time.Weekday) string { + return os.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (os *os) WeekdaysNarrow() []string { + return os.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (os *os) WeekdayShort(weekday time.Weekday) string { + return os.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (os *os) WeekdaysShort() []string { + return os.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (os *os) WeekdayWide(weekday time.Weekday) string { + return os.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (os *os) WeekdaysWide() []string { + return os.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'os' and handles both Whole and Real numbers based on 'v' +func (os *os) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'os' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (os *os) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, os.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'os' +func (os *os) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := os.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, os.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'os' +// in accounting notation. +func (os *os) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := os.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyNegativePrefix[j]) + } + + b = append(b, os.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, os.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'os' +func (os *os) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'os' +func (os *os) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'os' +func (os *os) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'os' +func (os *os) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, os.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'os' +func (os *os) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'os' +func (os *os) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'os' +func (os *os) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'os' +func (os *os) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := os.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/os/os_test.go b/vendor/github.com/go-playground/locales/os/os_test.go new file mode 100644 index 0000000000..3a139e8c9d --- /dev/null +++ b/vendor/github.com/go-playground/locales/os/os_test.go @@ -0,0 +1,1120 @@ +package os + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "os" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/os_GE/os_GE.go b/vendor/github.com/go-playground/locales/os_GE/os_GE.go new file mode 100644 index 0000000000..a449b07241 --- /dev/null +++ b/vendor/github.com/go-playground/locales/os_GE/os_GE.go @@ -0,0 +1,615 @@ +package os_GE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type os_GE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'os_GE' locale +func New() locales.Translator { + return &os_GE{ + locale: "os_GE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "янв.", "фев.", "мар.", "апр.", "майы", "июны", "июлы", "авг.", "сен.", "окт.", "ноя.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "январы", "февралы", "мартъийы", "апрелы", "майы", "июны", "июлы", "августы", "сентябры", "октябры", "ноябры", "декабры"}, + daysAbbreviated: []string{"хцб", "крс", "дцг", "ӕрт", "цпр", "мрб", "сбт"}, + daysNarrow: []string{"Х", "К", "Д", "Ӕ", "Ц", "М", "С"}, + daysWide: []string{"хуыцаубон", "къуырисӕр", "дыццӕг", "ӕртыццӕг", "цыппӕрӕм", "майрӕмбон", "сабат"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"ӕмбисбоны размӕ", "ӕмбисбоны фӕстӕ"}, + erasAbbreviated: []string{"н.д.а.", "н.д."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"MDT": "MDT", "HNPMX": "HNPMX", "SRT": "SRT", "MESZ": "Астӕуккаг Европӕйаг сӕрдыгон рӕстӕг", "VET": "VET", "WITA": "WITA", "HNPM": "HNPM", "HEPM": "HEPM", "AWST": "AWST", "ACWDT": "ACWDT", "WARST": "WARST", "AEST": "AEST", "HNT": "HNT", "LHDT": "LHDT", "WESZ": "Ныгъуылӕн Европӕйаг сӕрдыгон рӕстӕг", "TMST": "TMST", "ACST": "ACST", "BT": "BT", "UYST": "UYST", "JST": "JST", "TMT": "TMT", "GFT": "GFT", "LHST": "LHST", "EAT": "EAT", "ADT": "ADT", "HKST": "HKST", "OEZ": "Скӕсӕн Европӕйаг стандартон рӕстӕг", "AWDT": "AWDT", "CHAST": "CHAST", "NZST": "NZST", "IST": "IST", "HEOG": "HEOG", "AST": "AST", "COST": "COST", "∅∅∅": "∅∅∅", "HECU": "HECU", "MYT": "MYT", "MST": "MST", "WAT": "WAT", "PDT": "PDT", "GYT": "GYT", "BOT": "BOT", "CAT": "CAT", "CLT": "CLT", "HEPMX": "HEPMX", "CST": "CST", "WIT": "WIT", "CHADT": "CHADT", "HADT": "HADT", "ECT": "ECT", "ChST": "ChST", "HNCU": "HNCU", "AEDT": "AEDT", "SGT": "SGT", "ACWST": "ACWST", "NZDT": "NZDT", "HKT": "HKT", "WAST": "WAST", "EDT": "EDT", "HAT": "HAT", "CDT": "CDT", "CLST": "CLST", "HNOG": "HNOG", "OESZ": "Скӕсӕн Европӕйаг сӕрдыгон рӕстӕг", "HENOMX": "HENOMX", "AKDT": "AKDT", "WIB": "WIB", "HAST": "HAST", "JDT": "JDT", "WART": "WART", "AKST": "AKST", "SAST": "SAST", "PST": "PST", "ARST": "ARST", "HEEG": "HEEG", "EST": "EST", "ACDT": "ACDT", "UYT": "UYT", "MEZ": "Астӕуккаг Европӕйаг стандартон рӕстӕг", "ART": "ART", "HNNOMX": "HNNOMX", "COT": "COT", "HNEG": "HNEG", "WEZ": "Ныгъуылӕн Европӕйаг стандартон рӕстӕг", "GMT": "Гринвичы рӕстӕмбис рӕстӕг"}, + } +} + +// Locale returns the current translators string locale +func (os *os_GE) Locale() string { + return os.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'os_GE' +func (os *os_GE) PluralsCardinal() []locales.PluralRule { + return os.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'os_GE' +func (os *os_GE) PluralsOrdinal() []locales.PluralRule { + return os.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'os_GE' +func (os *os_GE) PluralsRange() []locales.PluralRule { + return os.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'os_GE' +func (os *os_GE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'os_GE' +func (os *os_GE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'os_GE' +func (os *os_GE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (os *os_GE) MonthAbbreviated(month time.Month) string { + return os.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (os *os_GE) MonthsAbbreviated() []string { + return os.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (os *os_GE) MonthNarrow(month time.Month) string { + return os.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (os *os_GE) MonthsNarrow() []string { + return os.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (os *os_GE) MonthWide(month time.Month) string { + return os.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (os *os_GE) MonthsWide() []string { + return os.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (os *os_GE) WeekdayAbbreviated(weekday time.Weekday) string { + return os.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (os *os_GE) WeekdaysAbbreviated() []string { + return os.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (os *os_GE) WeekdayNarrow(weekday time.Weekday) string { + return os.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (os *os_GE) WeekdaysNarrow() []string { + return os.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (os *os_GE) WeekdayShort(weekday time.Weekday) string { + return os.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (os *os_GE) WeekdaysShort() []string { + return os.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (os *os_GE) WeekdayWide(weekday time.Weekday) string { + return os.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (os *os_GE) WeekdaysWide() []string { + return os.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'os_GE' and handles both Whole and Real numbers based on 'v' +func (os *os_GE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'os_GE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (os *os_GE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, os.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'os_GE' +func (os *os_GE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := os.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, os.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'os_GE' +// in accounting notation. +func (os *os_GE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := os.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyNegativePrefix[j]) + } + + b = append(b, os.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, os.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'os_GE' +func (os *os_GE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'os_GE' +func (os *os_GE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'os_GE' +func (os *os_GE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'os_GE' +func (os *os_GE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, os.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'os_GE' +func (os *os_GE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'os_GE' +func (os *os_GE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'os_GE' +func (os *os_GE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'os_GE' +func (os *os_GE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := os.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/os_GE/os_GE_test.go b/vendor/github.com/go-playground/locales/os_GE/os_GE_test.go new file mode 100644 index 0000000000..022c8810f9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/os_GE/os_GE_test.go @@ -0,0 +1,1120 @@ +package os_GE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "os_GE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/os_RU/os_RU.go b/vendor/github.com/go-playground/locales/os_RU/os_RU.go new file mode 100644 index 0000000000..3f7c126afb --- /dev/null +++ b/vendor/github.com/go-playground/locales/os_RU/os_RU.go @@ -0,0 +1,615 @@ +package os_RU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type os_RU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'os_RU' locale +func New() locales.Translator { + return &os_RU{ + locale: "os_RU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "₽", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "янв.", "фев.", "мар.", "апр.", "майы", "июны", "июлы", "авг.", "сен.", "окт.", "ноя.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "январы", "февралы", "мартъийы", "апрелы", "майы", "июны", "июлы", "августы", "сентябры", "октябры", "ноябры", "декабры"}, + daysAbbreviated: []string{"хцб", "крс", "дцг", "ӕрт", "цпр", "мрб", "сбт"}, + daysNarrow: []string{"Х", "К", "Д", "Ӕ", "Ц", "М", "С"}, + daysWide: []string{"хуыцаубон", "къуырисӕр", "дыццӕг", "ӕртыццӕг", "цыппӕрӕм", "майрӕмбон", "сабат"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"ӕмбисбоны размӕ", "ӕмбисбоны фӕстӕ"}, + erasAbbreviated: []string{"н.д.а.", "н.д."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"VET": "VET", "JST": "JST", "JDT": "JDT", "GFT": "GFT", "WITA": "WITA", "HECU": "HECU", "WIT": "WIT", "WEZ": "Ныгъуылӕн Европӕйаг стандартон рӕстӕг", "AEST": "AEST", "UYST": "UYST", "HNPMX": "HNPMX", "ACDT": "ACDT", "ACWDT": "ACWDT", "CHADT": "CHADT", "OEZ": "Скӕсӕн Европӕйаг стандартон рӕстӕг", "MYT": "MYT", "ART": "ART", "ARST": "ARST", "BT": "BT", "AKST": "AKST", "HEPMX": "HEPMX", "NZDT": "NZDT", "WESZ": "Ныгъуылӕн Европӕйаг сӕрдыгон рӕстӕг", "WART": "WART", "MDT": "MDT", "∅∅∅": "∅∅∅", "AEDT": "AEDT", "ADT": "ADT", "WARST": "WARST", "HNNOMX": "HNNOMX", "PST": "PST", "OESZ": "Скӕсӕн Европӕйаг сӕрдыгон рӕстӕг", "HNCU": "HNCU", "EAT": "EAT", "NZST": "NZST", "HEOG": "HEOG", "HKT": "HKT", "WAT": "WAT", "AKDT": "AKDT", "MEZ": "Астӕуккаг Европӕйаг стандартон рӕстӕг", "MST": "MST", "HAST": "HAST", "ECT": "ECT", "BOT": "BOT", "GMT": "Гринвичы рӕстӕмбис рӕстӕг", "ChST": "ChST", "LHST": "LHST", "SGT": "SGT", "WIB": "WIB", "AWST": "AWST", "ACWST": "ACWST", "COST": "COST", "HNT": "HNT", "SRT": "SRT", "HEPM": "HEPM", "CLST": "CLST", "EST": "EST", "COT": "COT", "ACST": "ACST", "TMST": "TMST", "EDT": "EDT", "HKST": "HKST", "HNPM": "HNPM", "HNOG": "HNOG", "GYT": "GYT", "CST": "CST", "HADT": "HADT", "HNEG": "HNEG", "PDT": "PDT", "CLT": "CLT", "SAST": "SAST", "CDT": "CDT", "AWDT": "AWDT", "IST": "IST", "MESZ": "Астӕуккаг Европӕйаг сӕрдыгон рӕстӕг", "WAST": "WAST", "HENOMX": "HENOMX", "LHDT": "LHDT", "AST": "AST", "CHAST": "CHAST", "CAT": "CAT", "TMT": "TMT", "HAT": "HAT", "HEEG": "HEEG", "UYT": "UYT"}, + } +} + +// Locale returns the current translators string locale +func (os *os_RU) Locale() string { + return os.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'os_RU' +func (os *os_RU) PluralsCardinal() []locales.PluralRule { + return os.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'os_RU' +func (os *os_RU) PluralsOrdinal() []locales.PluralRule { + return os.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'os_RU' +func (os *os_RU) PluralsRange() []locales.PluralRule { + return os.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'os_RU' +func (os *os_RU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'os_RU' +func (os *os_RU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'os_RU' +func (os *os_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (os *os_RU) MonthAbbreviated(month time.Month) string { + return os.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (os *os_RU) MonthsAbbreviated() []string { + return os.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (os *os_RU) MonthNarrow(month time.Month) string { + return os.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (os *os_RU) MonthsNarrow() []string { + return os.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (os *os_RU) MonthWide(month time.Month) string { + return os.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (os *os_RU) MonthsWide() []string { + return os.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (os *os_RU) WeekdayAbbreviated(weekday time.Weekday) string { + return os.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (os *os_RU) WeekdaysAbbreviated() []string { + return os.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (os *os_RU) WeekdayNarrow(weekday time.Weekday) string { + return os.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (os *os_RU) WeekdaysNarrow() []string { + return os.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (os *os_RU) WeekdayShort(weekday time.Weekday) string { + return os.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (os *os_RU) WeekdaysShort() []string { + return os.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (os *os_RU) WeekdayWide(weekday time.Weekday) string { + return os.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (os *os_RU) WeekdaysWide() []string { + return os.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'os_RU' and handles both Whole and Real numbers based on 'v' +func (os *os_RU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'os_RU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (os *os_RU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, os.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'os_RU' +func (os *os_RU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := os.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, os.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, os.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'os_RU' +// in accounting notation. +func (os *os_RU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := os.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, os.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(os.group) - 1; j >= 0; j-- { + b = append(b, os.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyNegativePrefix[j]) + } + + b = append(b, os.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(os.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, os.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, os.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'os_RU' +func (os *os_RU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'os_RU' +func (os *os_RU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'os_RU' +func (os *os_RU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'os_RU' +func (os *os_RU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, os.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, os.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb0, 0xd0, 0xb7}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'os_RU' +func (os *os_RU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'os_RU' +func (os *os_RU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'os_RU' +func (os *os_RU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'os_RU' +func (os *os_RU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, os.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, os.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := os.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/os_RU/os_RU_test.go b/vendor/github.com/go-playground/locales/os_RU/os_RU_test.go new file mode 100644 index 0000000000..4304bcea19 --- /dev/null +++ b/vendor/github.com/go-playground/locales/os_RU/os_RU_test.go @@ -0,0 +1,1120 @@ +package os_RU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "os_RU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pa/pa.go b/vendor/github.com/go-playground/locales/pa/pa.go new file mode 100644 index 0000000000..853f7a0569 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa/pa.go @@ -0,0 +1,653 @@ +package pa + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pa struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pa' locale +func New() locales.Translator { + return &pa{ + locale: "pa", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "р.", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ਜਨ", "ਫ਼ਰ", "ਮਾਰਚ", "ਅਪ੍ਰੈ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾ", "ਅਗ", "ਸਤੰ", "ਅਕਤੂ", "ਨਵੰ", "ਦਸੰ"}, + monthsNarrow: []string{"", "ਜ", "ਫ਼", "ਮਾ", "ਅ", "ਮ", "ਜੂ", "ਜੁ", "ਅ", "ਸ", "ਅ", "ਨ", "ਦ"}, + monthsWide: []string{"", "ਜਨਵਰੀ", "ਫ਼ਰਵਰੀ", "ਮਾਰਚ", "ਅਪ੍ਰੈਲ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾਈ", "ਅਗਸਤ", "ਸਤੰਬਰ", "ਅਕਤੂਬਰ", "ਨਵੰਬਰ", "ਦਸੰਬਰ"}, + daysAbbreviated: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗਲ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕਰ", "ਸ਼ਨਿੱਚਰ"}, + daysNarrow: []string{"ਐ", "ਸੋ", "ਮੰ", "ਬੁੱ", "ਵੀ", "ਸ਼ੁੱ", "ਸ਼"}, + daysShort: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕ", "ਸ਼ਨਿੱ"}, + daysWide: []string{"ਐਤਵਾਰ", "ਸੋਮਵਾਰ", "ਮੰਗਲਵਾਰ", "ਬੁੱਧਵਾਰ", "ਵੀਰਵਾਰ", "ਸ਼ੁੱਕਰਵਾਰ", "ਸ਼ਨਿੱਚਰਵਾਰ"}, + periodsAbbreviated: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + periodsNarrow: []string{"ਸ.", "ਸ਼."}, + periodsWide: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + erasAbbreviated: []string{"ਈ. ਪੂ.", "ਸੰਨ"}, + erasNarrow: []string{"ਈ.ਪੂ.", "ਸੰਨ"}, + erasWide: []string{"ਈਸਵੀ ਪੂਰਵ", "ਈਸਵੀ ਸੰਨ"}, + timezones: map[string]string{"WESZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HAT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "LHST": "ਲੌਰਡ ਹੋਵੇ ਮਿਆਰੀ ਵੇਲਾ", "CLT": "ਚਿਲੀ ਮਿਆਰੀ ਵੇਲਾ", "CLST": "ਚਿਲੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "OEZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "UYST": "ਉਰੂਗਵੇ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HEPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WIB": "ਪੱਛਮੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "HNOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "VET": "ਵੈਨੇਜ਼ੂਏਲਾ ਵੇਲਾ", "BT": "ਭੂਟਾਨ ਵੇਲਾ", "AWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ECT": "ਇਕਵੇਡੋਰ ਵੇਲਾ", "HADT": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ACWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "COST": "ਕੋਲੰਬੀਆ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HECU": "ਕਿਊਬਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "JST": "ਜਪਾਨ ਮਿਆਰੀ ਵੇਲਾ", "WARST": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ARST": "ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HKT": "ਹਾਂਗ ਕਾਂਗ ਮਿਆਰੀ ਵੇਲਾ", "UYT": "ਉਰੂਗਵੇ ਮਿਆਰੀ ਵੇਲਾ", "GYT": "ਗੁਯਾਨਾ ਵੇਲਾ", "ACWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "OESZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WEZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "ACDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "AKDT": "ਅਲਾਸਕਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "CHADT": "ਚੈਥਮ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HEEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AEST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "CHAST": "ਚੈਥਮ ਮਿਆਰੀ ਵੇਲਾ", "MEZ": "ਮੱਧ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "ART": "ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "SRT": "ਸੂਰੀਨਾਮ ਵੇਲਾ", "EAT": "ਪੂਰਬੀ ਅਫਰੀਕਾ ਵੇਲਾ", "HAST": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਮਿਆਰੀ ਵੇਲਾ", "WAST": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "EST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "EDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HKST": "ਹਾਂਗ ਕਾਂਗ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HNT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "HEOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AEDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNCU": "ਕਿਊਬਾ ਮਿਆਰੀ ਵੇਲਾ", "CAT": "ਕੇਂਦਰੀ ਅਫਰੀਕਾ ਵੇਲਾ", "NZDT": "ਨਿਊਜ਼ੀਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WART": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "WAT": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "MST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਮਾਉਂਟੇਨ ਮਿਆਰੀ ਵੇਲਾ", "BOT": "ਬੋਲੀਵੀਆ ਵੇਲਾ", "CST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "WIT": "ਪੂਰਬੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "JDT": "ਜਪਾਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ACST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "∅∅∅": "ਪੇਰੂ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "GFT": "ਫ੍ਰੈਂਚ ਗੁਏਨਾ ਵੇਲਾ", "AKST": "ਅਲਾਸਕਾ ਮਿਆਰੀ ਵੇਲਾ", "MDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਮਾਉਂਟੇਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "TMT": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਮਿਆਰੀ ਵੇਲਾ", "HEPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "SGT": "ਸਿੰਗਾਪੁਰ ਮਿਆਰੀ ਵੇਲਾ", "NZST": "ਨਿਊਜ਼ੀਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "WITA": "ਮੱਧ ਇੰਡੋਨੇਸ਼ੀਆਈ ਵੇਲਾ", "CDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "IST": "ਭਾਰਤੀ ਮਿਆਰੀ ਵੇਲਾ", "MESZ": "ਮੱਧ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ADT": "ਅਟਲਾਂਟਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNNOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਮਿਆਰੀ ਵੇਲਾ", "HNPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਮਿਆਰੀ ਵੇਲਾ", "LHDT": "ਲੌਰਡ ਹੋਵੇ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "PST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "PDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "MYT": "ਮਲੇਸ਼ੀਆ ਵੇਲਾ", "TMST": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AST": "ਅਟਲਾਂਟਿਕ ਮਿਆਰੀ ਵੇਲਾ", "GMT": "ਗ੍ਰੀਨਵਿਚ ਮੀਨ ਵੇਲਾ", "COT": "ਕੋਲੰਬੀਆ ਮਿਆਰੀ ਵੇਲਾ", "HENOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ChST": "ਚਾਮੋਰੋ ਮਿਆਰੀ ਵੇਲਾ", "SAST": "ਦੱਖਣੀ ਅਫ਼ਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "HNPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ"}, + } +} + +// Locale returns the current translators string locale +func (pa *pa) Locale() string { + return pa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pa' +func (pa *pa) PluralsCardinal() []locales.PluralRule { + return pa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pa' +func (pa *pa) PluralsOrdinal() []locales.PluralRule { + return pa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pa' +func (pa *pa) PluralsRange() []locales.PluralRule { + return pa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pa' +func (pa *pa) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pa' +func (pa *pa) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pa' +func (pa *pa) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pa.CardinalPluralRule(num1, v1) + end := pa.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pa *pa) MonthAbbreviated(month time.Month) string { + return pa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pa *pa) MonthsAbbreviated() []string { + return pa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pa *pa) MonthNarrow(month time.Month) string { + return pa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pa *pa) MonthsNarrow() []string { + return pa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pa *pa) MonthWide(month time.Month) string { + return pa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pa *pa) MonthsWide() []string { + return pa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pa *pa) WeekdayAbbreviated(weekday time.Weekday) string { + return pa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pa *pa) WeekdaysAbbreviated() []string { + return pa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pa *pa) WeekdayNarrow(weekday time.Weekday) string { + return pa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pa *pa) WeekdaysNarrow() []string { + return pa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pa *pa) WeekdayShort(weekday time.Weekday) string { + return pa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pa *pa) WeekdaysShort() []string { + return pa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pa *pa) WeekdayWide(weekday time.Weekday) string { + return pa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pa *pa) WeekdaysWide() []string { + return pa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pa' and handles both Whole and Real numbers based on 'v' +func (pa *pa) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pa' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pa *pa) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pa.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pa' +func (pa *pa) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pa' +// in accounting notation. +func (pa *pa) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pa.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pa' +func (pa *pa) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pa' +func (pa *pa) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pa' +func (pa *pa) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pa' +func (pa *pa) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pa' +func (pa *pa) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pa' +func (pa *pa) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pa' +func (pa *pa) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pa' +func (pa *pa) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pa/pa_test.go b/vendor/github.com/go-playground/locales/pa/pa_test.go new file mode 100644 index 0000000000..36933ba706 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa/pa_test.go @@ -0,0 +1,1120 @@ +package pa + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pa" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pa_Arab/pa_Arab.go b/vendor/github.com/go-playground/locales/pa_Arab/pa_Arab.go new file mode 100644 index 0000000000..50424d70c1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa_Arab/pa_Arab.go @@ -0,0 +1,643 @@ +package pa_Arab + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pa_Arab struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pa_Arab' locale +func New() locales.Translator { + return &pa_Arab{ + locale: "pa_Arab", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "‎-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "ر", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "ਜਨ", "ਫ਼ਰ", "ਮਾਰਚ", "ਅਪ੍ਰੈ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾ", "ਅਗ", "ਸਤੰ", "ਅਕਤੂ", "ਨਵੰ", "ਦਸੰ"}, + monthsNarrow: []string{"", "ਜ", "ਫ਼", "ਮਾ", "ਅ", "ਮ", "ਜੂ", "ਜੁ", "ਅ", "ਸ", "ਅ", "ਨ", "ਦ"}, + monthsWide: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئ", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗਲ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕਰ", "ਸ਼ਨਿੱਚਰ"}, + daysNarrow: []string{"ਐ", "ਸੋ", "ਮੰ", "ਬੁੱ", "ਵੀ", "ਸ਼ੁੱ", "ਸ਼"}, + daysShort: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕ", "ਸ਼ਨਿੱ"}, + daysWide: []string{"اتوار", "پیر", "منگل", "بُدھ", "جمعرات", "جمعہ", "ہفتہ"}, + periodsAbbreviated: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + periodsNarrow: []string{"ਸ.", "ਸ਼."}, + periodsWide: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + erasAbbreviated: []string{"ايساپورو", "سں"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ايساپورو", "سں"}, + timezones: map[string]string{"WITA": "ਮੱਧ ਇੰਡੋਨੇਸ਼ੀਆਈ ਵੇਲਾ", "HNPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "BOT": "ਬੋਲੀਵੀਆ ਵੇਲਾ", "NZST": "ਨਿਊਜ਼ੀਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "VET": "ਵੈਨੇਜ਼ੂਏਲਾ ਵੇਲਾ", "AKST": "ਅਲਾਸਕਾ ਮਿਆਰੀ ਵੇਲਾ", "HNT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "AEDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਮਿਆਰੀ ਵੇਲਾ", "HEPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HENOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "TMT": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਮਿਆਰੀ ਵੇਲਾ", "CST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "CHAST": "ਚੈਥਮ ਮਿਆਰੀ ਵੇਲਾ", "PDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WEZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "HKT": "ਹਾਂਗ ਕਾਂਗ ਮਿਆਰੀ ਵੇਲਾ", "UYT": "ਉਰੂਗਵੇ ਮਿਆਰੀ ਵੇਲਾ", "HADT": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CAT": "ਕੇਂਦਰੀ ਅਫਰੀਕਾ ਵੇਲਾ", "MEZ": "ਮੱਧ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "MDT": "ਮਕਾਉ ਗਰਮੀ-ਰੁੱਤ ਸਮਾਂ", "BT": "ਭੂਟਾਨ ਵੇਲਾ", "UYST": "ਉਰੂਗਵੇ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "EDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ART": "ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "WAT": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "ACST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "HNEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "GFT": "ਫ੍ਰੈਂਚ ਗੁਏਨਾ ਵੇਲਾ", "CHADT": "ਚੈਥਮ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "NZDT": "ਨਿਊਜ਼ੀਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CLT": "ਚਿਲੀ ਮਿਆਰੀ ਵੇਲਾ", "AWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WART": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "HKST": "ਹਾਂਗ ਕਾਂਗ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ACDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "COST": "ਕੋਲੰਬੀਆ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AKDT": "ਅਲਾਸਕਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "GYT": "ਗੁਯਾਨਾ ਵੇਲਾ", "HNCU": "ਕਿਊਬਾ ਮਿਆਰੀ ਵੇਲਾ", "WIB": "ਪੱਛਮੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "OEZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "JDT": "ਜਪਾਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HEOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ChST": "ਚਾਮੋਰੋ ਮਿਆਰੀ ਵੇਲਾ", "HECU": "ਕਿਊਬਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "PST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "WESZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "MST": "ਮਕਾਉ ਮਿਆਰੀ ਸਮਾਂ", "HAT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "EAT": "ਪੂਰਬੀ ਅਫਰੀਕਾ ਵੇਲਾ", "MESZ": "ਮੱਧ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "MYT": "ਮਲੇਸ਼ੀਆ ਵੇਲਾ", "EST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "HEEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "JST": "ਜਪਾਨ ਮਿਆਰੀ ਵੇਲਾ", "OESZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ARST": "ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AEST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "SAST": "ਦੱਖਣੀ ਅਫ਼ਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "WIT": "ਪੂਰਬੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "ACWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "CLST": "ਚਿਲੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WAST": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ECT": "ਇਕਵੇਡੋਰ ਵੇਲਾ", "WARST": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "∅∅∅": "∅∅∅", "IST": "ਭਾਰਤੀ ਮਿਆਰੀ ਵੇਲਾ", "ACWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNNOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਮਿਆਰੀ ਵੇਲਾ", "TMST": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "LHST": "ਲੌਰਡ ਹੋਵੇ ਮਿਆਰੀ ਵੇਲਾ", "SRT": "ਸੂਰੀਨਾਮ ਵੇਲਾ", "SGT": "ਸਿੰਗਾਪੁਰ ਮਿਆਰੀ ਵੇਲਾ", "HAST": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਮਿਆਰੀ ਵੇਲਾ", "GMT": "ਗ੍ਰੀਨਵਿਚ ਮੀਨ ਵੇਲਾ", "ADT": "ਅਟਲਾਂਟਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "COT": "ਕੋਲੰਬੀਆ ਮਿਆਰੀ ਵੇਲਾ", "HEPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "LHDT": "ਲੌਰਡ ਹੋਵੇ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AST": "ਅਟਲਾਂਟਿਕ ਮਿਆਰੀ ਵੇਲਾ"}, + } +} + +// Locale returns the current translators string locale +func (pa *pa_Arab) Locale() string { + return pa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pa_Arab' +func (pa *pa_Arab) PluralsCardinal() []locales.PluralRule { + return pa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pa_Arab' +func (pa *pa_Arab) PluralsOrdinal() []locales.PluralRule { + return pa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pa_Arab' +func (pa *pa_Arab) PluralsRange() []locales.PluralRule { + return pa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pa_Arab' +func (pa *pa_Arab) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pa_Arab' +func (pa *pa_Arab) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pa_Arab' +func (pa *pa_Arab) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pa.CardinalPluralRule(num1, v1) + end := pa.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pa *pa_Arab) MonthAbbreviated(month time.Month) string { + return pa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pa *pa_Arab) MonthsAbbreviated() []string { + return pa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pa *pa_Arab) MonthNarrow(month time.Month) string { + return pa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pa *pa_Arab) MonthsNarrow() []string { + return pa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pa *pa_Arab) MonthWide(month time.Month) string { + return pa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pa *pa_Arab) MonthsWide() []string { + return pa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pa *pa_Arab) WeekdayAbbreviated(weekday time.Weekday) string { + return pa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pa *pa_Arab) WeekdaysAbbreviated() []string { + return pa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pa *pa_Arab) WeekdayNarrow(weekday time.Weekday) string { + return pa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pa *pa_Arab) WeekdaysNarrow() []string { + return pa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pa *pa_Arab) WeekdayShort(weekday time.Weekday) string { + return pa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pa *pa_Arab) WeekdaysShort() []string { + return pa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pa *pa_Arab) WeekdayWide(weekday time.Weekday) string { + return pa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pa *pa_Arab) WeekdaysWide() []string { + return pa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pa_Arab' and handles both Whole and Real numbers based on 'v' +func (pa *pa_Arab) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(pa.minus) - 1; j >= 0; j-- { + b = append(b, pa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pa_Arab' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pa *pa_Arab) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(pa.minus) - 1; j >= 0; j-- { + b = append(b, pa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pa.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pa_Arab' +func (pa *pa_Arab) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 8 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(pa.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, pa.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(pa.minus) - 1; j >= 0; j-- { + b = append(b, pa.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pa.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pa_Arab' +// in accounting notation. +func (pa *pa_Arab) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 8 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(pa.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, pa.currencyNegativePrefix[j]) + } + + for j := len(pa.minus) - 1; j >= 0; j-- { + b = append(b, pa.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(pa.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, pa.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, pa.currencyNegativeSuffix...) + } else { + + b = append(b, pa.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pa_Arab' +func (pa *pa_Arab) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pa_Arab' +func (pa *pa_Arab) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pa_Arab' +func (pa *pa_Arab) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pa_Arab' +func (pa *pa_Arab) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pa_Arab' +func (pa *pa_Arab) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pa_Arab' +func (pa *pa_Arab) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pa_Arab' +func (pa *pa_Arab) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pa_Arab' +func (pa *pa_Arab) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pa_Arab/pa_Arab_test.go b/vendor/github.com/go-playground/locales/pa_Arab/pa_Arab_test.go new file mode 100644 index 0000000000..c2979f38c9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa_Arab/pa_Arab_test.go @@ -0,0 +1,1120 @@ +package pa_Arab + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pa_Arab" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pa_Arab_PK/pa_Arab_PK.go b/vendor/github.com/go-playground/locales/pa_Arab_PK/pa_Arab_PK.go new file mode 100644 index 0000000000..19edad0f72 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa_Arab_PK/pa_Arab_PK.go @@ -0,0 +1,653 @@ +package pa_Arab_PK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pa_Arab_PK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pa_Arab_PK' locale +func New() locales.Translator { + return &pa_Arab_PK{ + locale: "pa_Arab_PK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ਜਨ", "ਫ਼ਰ", "ਮਾਰਚ", "ਅਪ੍ਰੈ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾ", "ਅਗ", "ਸਤੰ", "ਅਕਤੂ", "ਨਵੰ", "ਦਸੰ"}, + monthsNarrow: []string{"", "ਜ", "ਫ਼", "ਮਾ", "ਅ", "ਮ", "ਜੂ", "ਜੁ", "ਅ", "ਸ", "ਅ", "ਨ", "ਦ"}, + monthsWide: []string{"", "ਜਨਵਰੀ", "ਫ਼ਰਵਰੀ", "ਮਾਰਚ", "ਅਪ੍ਰੈਲ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾਈ", "ਅਗਸਤ", "ਸਤੰਬਰ", "ਅਕਤੂਬਰ", "ਨਵੰਬਰ", "ਦਸੰਬਰ"}, + daysAbbreviated: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗਲ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕਰ", "ਸ਼ਨਿੱਚਰ"}, + daysNarrow: []string{"ਐ", "ਸੋ", "ਮੰ", "ਬੁੱ", "ਵੀ", "ਸ਼ੁੱ", "ਸ਼"}, + daysShort: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕ", "ਸ਼ਨਿੱ"}, + daysWide: []string{"ਐਤਵਾਰ", "ਸੋਮਵਾਰ", "ਮੰਗਲਵਾਰ", "ਬੁੱਧਵਾਰ", "ਵੀਰਵਾਰ", "ਸ਼ੁੱਕਰਵਾਰ", "ਸ਼ਨਿੱਚਰਵਾਰ"}, + periodsAbbreviated: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + periodsNarrow: []string{"ਸ.", "ਸ਼."}, + periodsWide: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + erasAbbreviated: []string{"ਈ. ਪੂ.", "ਸੰਨ"}, + erasNarrow: []string{"ਈ.ਪੂ.", "ਸੰਨ"}, + erasWide: []string{"ਈਸਵੀ ਪੂਰਵ", "ਈਸਵੀ ਸੰਨ"}, + timezones: map[string]string{"CLT": "ਚਿਲੀ ਮਿਆਰੀ ਵੇਲਾ", "HEOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AST": "ਅਟਲਾਂਟਿਕ ਮਿਆਰੀ ਵੇਲਾ", "HNEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "UYT": "ਉਰੂਗਵੇ ਮਿਆਰੀ ਵੇਲਾ", "HNPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "SGT": "ਸਿੰਗਾਪੁਰ ਮਿਆਰੀ ਵੇਲਾ", "ACWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AEST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "SRT": "ਸੂਰੀਨਾਮ ਵੇਲਾ", "CST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "CAT": "ਕੇਂਦਰੀ ਅਫਰੀਕਾ ਵੇਲਾ", "IST": "ਭਾਰਤੀ ਮਿਆਰੀ ਵੇਲਾ", "NZST": "ਨਿਊਜ਼ੀਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "BT": "ਭੂਟਾਨ ਵੇਲਾ", "AKST": "ਅਲਾਸਕਾ ਮਿਆਰੀ ਵੇਲਾ", "MEZ": "ਮੱਧ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "COST": "ਕੋਲੰਬੀਆ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ACST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "HNT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "HAT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "MDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਮਾਉਂਟੇਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "GYT": "ਗੁਯਾਨਾ ਵੇਲਾ", "MESZ": "ਮੱਧ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "GFT": "ਫ੍ਰੈਂਚ ਗੁਏਨਾ ਵੇਲਾ", "WESZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "EDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HKST": "ਹਾਂਗ ਕਾਂਗ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HENOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "SAST": "ਦੱਖਣੀ ਅਫ਼ਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "HEPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CLST": "ਚਿਲੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "GMT": "ਗ੍ਰੀਨਵਿਚ ਮੀਨ ਵੇਲਾ", "TMST": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WAT": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "AKDT": "ਅਲਾਸਕਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WIB": "ਪੱਛਮੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "WIT": "ਪੂਰਬੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "CHAST": "ਚੈਥਮ ਮਿਆਰੀ ਵੇਲਾ", "ADT": "ਅਟਲਾਂਟਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WAST": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HNPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਮਿਆਰੀ ਵੇਲਾ", "OESZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "MYT": "ਮਲੇਸ਼ੀਆ ਵੇਲਾ", "TMT": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਮਿਆਰੀ ਵੇਲਾ", "ART": "ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "ACDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "COT": "ਕੋਲੰਬੀਆ ਮਿਆਰੀ ਵੇਲਾ", "LHST": "ਲੌਰਡ ਹੋਵੇ ਮਿਆਰੀ ਵੇਲਾ", "BOT": "ਬੋਲੀਵੀਆ ਵੇਲਾ", "NZDT": "ਨਿਊਜ਼ੀਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "OEZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "WARST": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "VET": "ਵੈਨੇਜ਼ੂਏਲਾ ਵੇਲਾ", "JST": "ਜਪਾਨ ਮਿਆਰੀ ਵੇਲਾ", "∅∅∅": "∅∅∅", "WITA": "ਮੱਧ ਇੰਡੋਨੇਸ਼ੀਆਈ ਵੇਲਾ", "CDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "PST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "PDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "EAT": "ਪੂਰਬੀ ਅਫਰੀਕਾ ਵੇਲਾ", "JDT": "ਜਪਾਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WEZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "HEEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AEDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HAST": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਮਿਆਰੀ ਵੇਲਾ", "ECT": "ਇਕਵੇਡੋਰ ਵੇਲਾ", "CHADT": "ਚੈਥਮ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ARST": "ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "EST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "HNNOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਮਿਆਰੀ ਵੇਲਾ", "WART": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "MST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਮਾਉਂਟੇਨ ਮਿਆਰੀ ਵੇਲਾ", "HEPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "LHDT": "ਲੌਰਡ ਹੋਵੇ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "HADT": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "HKT": "ਹਾਂਗ ਕਾਂਗ ਮਿਆਰੀ ਵੇਲਾ", "ChST": "ਚਾਮੋਰੋ ਮਿਆਰੀ ਵੇਲਾ", "UYST": "ਉਰੂਗਵੇ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HNCU": "ਕਿਊਬਾ ਮਿਆਰੀ ਵੇਲਾ", "HECU": "ਕਿਊਬਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ACWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ"}, + } +} + +// Locale returns the current translators string locale +func (pa *pa_Arab_PK) Locale() string { + return pa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pa_Arab_PK' +func (pa *pa_Arab_PK) PluralsCardinal() []locales.PluralRule { + return pa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pa_Arab_PK' +func (pa *pa_Arab_PK) PluralsOrdinal() []locales.PluralRule { + return pa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pa_Arab_PK' +func (pa *pa_Arab_PK) PluralsRange() []locales.PluralRule { + return pa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pa.CardinalPluralRule(num1, v1) + end := pa.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pa *pa_Arab_PK) MonthAbbreviated(month time.Month) string { + return pa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pa *pa_Arab_PK) MonthsAbbreviated() []string { + return pa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pa *pa_Arab_PK) MonthNarrow(month time.Month) string { + return pa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pa *pa_Arab_PK) MonthsNarrow() []string { + return pa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pa *pa_Arab_PK) MonthWide(month time.Month) string { + return pa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pa *pa_Arab_PK) MonthsWide() []string { + return pa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pa *pa_Arab_PK) WeekdayAbbreviated(weekday time.Weekday) string { + return pa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pa *pa_Arab_PK) WeekdaysAbbreviated() []string { + return pa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pa *pa_Arab_PK) WeekdayNarrow(weekday time.Weekday) string { + return pa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pa *pa_Arab_PK) WeekdaysNarrow() []string { + return pa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pa *pa_Arab_PK) WeekdayShort(weekday time.Weekday) string { + return pa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pa *pa_Arab_PK) WeekdaysShort() []string { + return pa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pa *pa_Arab_PK) WeekdayWide(weekday time.Weekday) string { + return pa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pa *pa_Arab_PK) WeekdaysWide() []string { + return pa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pa_Arab_PK' and handles both Whole and Real numbers based on 'v' +func (pa *pa_Arab_PK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pa_Arab_PK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pa *pa_Arab_PK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pa.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pa_Arab_PK' +// in accounting notation. +func (pa *pa_Arab_PK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pa.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pa_Arab_PK' +func (pa *pa_Arab_PK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pa_Arab_PK/pa_Arab_PK_test.go b/vendor/github.com/go-playground/locales/pa_Arab_PK/pa_Arab_PK_test.go new file mode 100644 index 0000000000..248330b2fd --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa_Arab_PK/pa_Arab_PK_test.go @@ -0,0 +1,1120 @@ +package pa_Arab_PK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pa_Arab_PK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pa_Guru/pa_Guru.go b/vendor/github.com/go-playground/locales/pa_Guru/pa_Guru.go new file mode 100644 index 0000000000..69b82fd57a --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa_Guru/pa_Guru.go @@ -0,0 +1,653 @@ +package pa_Guru + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pa_Guru struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pa_Guru' locale +func New() locales.Translator { + return &pa_Guru{ + locale: "pa_Guru", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ਜਨ", "ਫ਼ਰ", "ਮਾਰਚ", "ਅਪ੍ਰੈ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾ", "ਅਗ", "ਸਤੰ", "ਅਕਤੂ", "ਨਵੰ", "ਦਸੰ"}, + monthsNarrow: []string{"", "ਜ", "ਫ਼", "ਮਾ", "ਅ", "ਮ", "ਜੂ", "ਜੁ", "ਅ", "ਸ", "ਅ", "ਨ", "ਦ"}, + monthsWide: []string{"", "ਜਨਵਰੀ", "ਫ਼ਰਵਰੀ", "ਮਾਰਚ", "ਅਪ੍ਰੈਲ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾਈ", "ਅਗਸਤ", "ਸਤੰਬਰ", "ਅਕਤੂਬਰ", "ਨਵੰਬਰ", "ਦਸੰਬਰ"}, + daysAbbreviated: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗਲ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕਰ", "ਸ਼ਨਿੱਚਰ"}, + daysNarrow: []string{"ਐ", "ਸੋ", "ਮੰ", "ਬੁੱ", "ਵੀ", "ਸ਼ੁੱ", "ਸ਼"}, + daysShort: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕ", "ਸ਼ਨਿੱ"}, + daysWide: []string{"ਐਤਵਾਰ", "ਸੋਮਵਾਰ", "ਮੰਗਲਵਾਰ", "ਬੁੱਧਵਾਰ", "ਵੀਰਵਾਰ", "ਸ਼ੁੱਕਰਵਾਰ", "ਸ਼ਨਿੱਚਰਵਾਰ"}, + periodsAbbreviated: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + periodsNarrow: []string{"ਸ.", "ਸ਼."}, + periodsWide: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + erasAbbreviated: []string{"ਈ. ਪੂ.", "ਸੰਨ"}, + erasNarrow: []string{"ਈ.ਪੂ.", "ਸੰਨ"}, + erasWide: []string{"ਈਸਵੀ ਪੂਰਵ", "ਈਸਵੀ ਸੰਨ"}, + timezones: map[string]string{"UYST": "ਉਰੂਗਵੇ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "CDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "IST": "ਭਾਰਤੀ ਮਿਆਰੀ ਵੇਲਾ", "WAST": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "GFT": "ਫ੍ਰੈਂਚ ਗੁਏਨਾ ਵੇਲਾ", "LHDT": "ਲੌਰਡ ਹੋਵੇ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CHADT": "ਚੈਥਮ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WART": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "MST": "ਮਕਾਉ ਮਿਆਰੀ ਸਮਾਂ", "HNEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "AEDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "UYT": "ਉਰੂਗਵੇ ਮਿਆਰੀ ਵੇਲਾ", "SAST": "ਦੱਖਣੀ ਅਫ਼ਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "WARST": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HEPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNCU": "ਕਿਊਬਾ ਮਿਆਰੀ ਵੇਲਾ", "WIB": "ਪੱਛਮੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "WIT": "ਪੂਰਬੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "NZST": "ਨਿਊਜ਼ੀਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "WEZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "ARST": "ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "EST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "HNNOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਮਿਆਰੀ ਵੇਲਾ", "∅∅∅": "ਪੇਰੂ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "NZDT": "ਨਿਊਜ਼ੀਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "OESZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "GMT": "ਗ੍ਰੀਨਵਿਚ ਮੀਨ ਵੇਲਾ", "ChST": "ਚਾਮੋਰੋ ਮਿਆਰੀ ਵੇਲਾ", "AWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "HADT": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "MESZ": "ਮੱਧ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "CLST": "ਚਿਲੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "TMT": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਮਿਆਰੀ ਵੇਲਾ", "EDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "LHST": "ਲੌਰਡ ਹੋਵੇ ਮਿਆਰੀ ਵੇਲਾ", "SRT": "ਸੂਰੀਨਾਮ ਵੇਲਾ", "MEZ": "ਮੱਧ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "MYT": "ਮਲੇਸ਼ੀਆ ਵੇਲਾ", "ACDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "COT": "ਕੋਲੰਬੀਆ ਮਿਆਰੀ ਵੇਲਾ", "HNT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "GYT": "ਗੁਯਾਨਾ ਵੇਲਾ", "EAT": "ਪੂਰਬੀ ਅਫਰੀਕਾ ਵੇਲਾ", "CST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "CAT": "ਕੇਂਦਰੀ ਅਫਰੀਕਾ ਵੇਲਾ", "JDT": "ਜਪਾਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ART": "ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "HAT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "PDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "PST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "HAST": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਮਿਆਰੀ ਵੇਲਾ", "CLT": "ਚਿਲੀ ਮਿਆਰੀ ਵੇਲਾ", "MDT": "ਮਕਾਉ ਗਰਮੀ-ਰੁੱਤ ਸਮਾਂ", "HKST": "ਹਾਂਗ ਕਾਂਗ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "COST": "ਕੋਲੰਬੀਆ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HENOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ECT": "ਇਕਵੇਡੋਰ ਵੇਲਾ", "HNOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "TMST": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ACST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "ACWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "VET": "ਵੈਨੇਜ਼ੂਏਲਾ ਵੇਲਾ", "WESZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "BT": "ਭੂਟਾਨ ਵੇਲਾ", "WITA": "ਮੱਧ ਇੰਡੋਨੇਸ਼ੀਆਈ ਵੇਲਾ", "AKDT": "ਅਲਾਸਕਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "BOT": "ਬੋਲੀਵੀਆ ਵੇਲਾ", "HEOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AEST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "HEPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ACWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "OEZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "HKT": "ਹਾਂਗ ਕਾਂਗ ਮਿਆਰੀ ਵੇਲਾ", "HEEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HNPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "AST": "ਅਟਲਾਂਟਿਕ ਮਿਆਰੀ ਵੇਲਾ", "SGT": "ਸਿੰਗਾਪੁਰ ਮਿਆਰੀ ਵੇਲਾ", "JST": "ਜਪਾਨ ਮਿਆਰੀ ਵੇਲਾ", "ADT": "ਅਟਲਾਂਟਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WAT": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "AKST": "ਅਲਾਸਕਾ ਮਿਆਰੀ ਵੇਲਾ", "HNPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਮਿਆਰੀ ਵੇਲਾ", "HECU": "ਕਿਊਬਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CHAST": "ਚੈਥਮ ਮਿਆਰੀ ਵੇਲਾ"}, + } +} + +// Locale returns the current translators string locale +func (pa *pa_Guru) Locale() string { + return pa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pa_Guru' +func (pa *pa_Guru) PluralsCardinal() []locales.PluralRule { + return pa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pa_Guru' +func (pa *pa_Guru) PluralsOrdinal() []locales.PluralRule { + return pa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pa_Guru' +func (pa *pa_Guru) PluralsRange() []locales.PluralRule { + return pa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pa_Guru' +func (pa *pa_Guru) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pa_Guru' +func (pa *pa_Guru) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pa_Guru' +func (pa *pa_Guru) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pa.CardinalPluralRule(num1, v1) + end := pa.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pa *pa_Guru) MonthAbbreviated(month time.Month) string { + return pa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pa *pa_Guru) MonthsAbbreviated() []string { + return pa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pa *pa_Guru) MonthNarrow(month time.Month) string { + return pa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pa *pa_Guru) MonthsNarrow() []string { + return pa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pa *pa_Guru) MonthWide(month time.Month) string { + return pa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pa *pa_Guru) MonthsWide() []string { + return pa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pa *pa_Guru) WeekdayAbbreviated(weekday time.Weekday) string { + return pa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pa *pa_Guru) WeekdaysAbbreviated() []string { + return pa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pa *pa_Guru) WeekdayNarrow(weekday time.Weekday) string { + return pa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pa *pa_Guru) WeekdaysNarrow() []string { + return pa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pa *pa_Guru) WeekdayShort(weekday time.Weekday) string { + return pa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pa *pa_Guru) WeekdaysShort() []string { + return pa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pa *pa_Guru) WeekdayWide(weekday time.Weekday) string { + return pa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pa *pa_Guru) WeekdaysWide() []string { + return pa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pa_Guru' and handles both Whole and Real numbers based on 'v' +func (pa *pa_Guru) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pa_Guru' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pa *pa_Guru) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pa.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pa_Guru' +func (pa *pa_Guru) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pa_Guru' +// in accounting notation. +func (pa *pa_Guru) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pa.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pa_Guru' +func (pa *pa_Guru) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pa_Guru' +func (pa *pa_Guru) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pa_Guru' +func (pa *pa_Guru) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pa_Guru' +func (pa *pa_Guru) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pa_Guru' +func (pa *pa_Guru) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pa_Guru' +func (pa *pa_Guru) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pa_Guru' +func (pa *pa_Guru) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pa_Guru' +func (pa *pa_Guru) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pa_Guru/pa_Guru_test.go b/vendor/github.com/go-playground/locales/pa_Guru/pa_Guru_test.go new file mode 100644 index 0000000000..d33a9c6d18 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa_Guru/pa_Guru_test.go @@ -0,0 +1,1120 @@ +package pa_Guru + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pa_Guru" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pa_Guru_IN/pa_Guru_IN.go b/vendor/github.com/go-playground/locales/pa_Guru_IN/pa_Guru_IN.go new file mode 100644 index 0000000000..cae6691aab --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa_Guru_IN/pa_Guru_IN.go @@ -0,0 +1,653 @@ +package pa_Guru_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pa_Guru_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pa_Guru_IN' locale +func New() locales.Translator { + return &pa_Guru_IN{ + locale: "pa_Guru_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ਜਨ", "ਫ਼ਰ", "ਮਾਰਚ", "ਅਪ੍ਰੈ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾ", "ਅਗ", "ਸਤੰ", "ਅਕਤੂ", "ਨਵੰ", "ਦਸੰ"}, + monthsNarrow: []string{"", "ਜ", "ਫ਼", "ਮਾ", "ਅ", "ਮ", "ਜੂ", "ਜੁ", "ਅ", "ਸ", "ਅ", "ਨ", "ਦ"}, + monthsWide: []string{"", "ਜਨਵਰੀ", "ਫ਼ਰਵਰੀ", "ਮਾਰਚ", "ਅਪ੍ਰੈਲ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾਈ", "ਅਗਸਤ", "ਸਤੰਬਰ", "ਅਕਤੂਬਰ", "ਨਵੰਬਰ", "ਦਸੰਬਰ"}, + daysAbbreviated: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗਲ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕਰ", "ਸ਼ਨਿੱਚਰ"}, + daysNarrow: []string{"ਐ", "ਸੋ", "ਮੰ", "ਬੁੱ", "ਵੀ", "ਸ਼ੁੱ", "ਸ਼"}, + daysShort: []string{"ਐਤ", "ਸੋਮ", "ਮੰਗ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕ", "ਸ਼ਨਿੱ"}, + daysWide: []string{"ਐਤਵਾਰ", "ਸੋਮਵਾਰ", "ਮੰਗਲਵਾਰ", "ਬੁੱਧਵਾਰ", "ਵੀਰਵਾਰ", "ਸ਼ੁੱਕਰਵਾਰ", "ਸ਼ਨਿੱਚਰਵਾਰ"}, + periodsAbbreviated: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + periodsNarrow: []string{"ਸ.", "ਸ਼."}, + periodsWide: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."}, + erasAbbreviated: []string{"ਈ. ਪੂ.", "ਸੰਨ"}, + erasNarrow: []string{"ਈ.ਪੂ.", "ਸੰਨ"}, + erasWide: []string{"ਈਸਵੀ ਪੂਰਵ", "ਈਸਵੀ ਸੰਨ"}, + timezones: map[string]string{"TMST": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HAT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CHADT": "ਚੈਥਮ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ChST": "ਚਾਮੋਰੋ ਮਿਆਰੀ ਵੇਲਾ", "SRT": "ਸੂਰੀਨਾਮ ਵੇਲਾ", "ECT": "ਇਕਵੇਡੋਰ ਵੇਲਾ", "MST": "ਮਕਾਉ ਮਿਆਰੀ ਸਮਾਂ", "ARST": "ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "EDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "NZST": "ਨਿਊਜ਼ੀਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "NZDT": "ਨਿਊਜ਼ੀਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HEOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "LHST": "ਲੌਰਡ ਹੋਵੇ ਮਿਆਰੀ ਵੇਲਾ", "HADT": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HNPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਮਿਆਰੀ ਵੇਲਾ", "CDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "MEZ": "ਮੱਧ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "LHDT": "ਲੌਰਡ ਹੋਵੇ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "AWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "AWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "BOT": "ਬੋਲੀਵੀਆ ਵੇਲਾ", "CLST": "ਚਿਲੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "MYT": "ਮਲੇਸ਼ੀਆ ਵੇਲਾ", "AKDT": "ਅਲਾਸਕਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "IST": "ਭਾਰਤੀ ਮਿਆਰੀ ਵੇਲਾ", "HECU": "ਕਿਊਬਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HAST": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਮਿਆਰੀ ਵੇਲਾ", "ACWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WAT": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "HKST": "ਹਾਂਗ ਕਾਂਗ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ACST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "COST": "ਕੋਲੰਬੀਆ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HNCU": "ਕਿਊਬਾ ਮਿਆਰੀ ਵੇਲਾ", "OEZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "MDT": "ਮਕਾਉ ਗਰਮੀ-ਰੁੱਤ ਸਮਾਂ", "ART": "ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "PST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "PDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ACWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "HNT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "AKST": "ਅਲਾਸਕਾ ਮਿਆਰੀ ਵੇਲਾ", "HNPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "BT": "ਭੂਟਾਨ ਵੇਲਾ", "HEPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "GMT": "ਗ੍ਰੀਨਵਿਚ ਮੀਨ ਵੇਲਾ", "TMT": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਮਿਆਰੀ ਵੇਲਾ", "HENOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "COT": "ਕੋਲੰਬੀਆ ਮਿਆਰੀ ਵੇਲਾ", "∅∅∅": "ਪੇਰੂ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WITA": "ਮੱਧ ਇੰਡੋਨੇਸ਼ੀਆਈ ਵੇਲਾ", "CHAST": "ਚੈਥਮ ਮਿਆਰੀ ਵੇਲਾ", "MESZ": "ਮੱਧ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WART": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "ADT": "ਅਟਲਾਂਟਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ACDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "EST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "GFT": "ਫ੍ਰੈਂਚ ਗੁਏਨਾ ਵੇਲਾ", "WIT": "ਪੂਰਬੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "CAT": "ਕੇਂਦਰੀ ਅਫਰੀਕਾ ਵੇਲਾ", "VET": "ਵੈਨੇਜ਼ੂਏਲਾ ਵੇਲਾ", "JDT": "ਜਪਾਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AST": "ਅਟਲਾਂਟਿਕ ਮਿਆਰੀ ਵੇਲਾ", "GYT": "ਗੁਯਾਨਾ ਵੇਲਾ", "SGT": "ਸਿੰਗਾਪੁਰ ਮਿਆਰੀ ਵੇਲਾ", "SAST": "ਦੱਖਣੀ ਅਫ਼ਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "WARST": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HNOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "HNEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "UYST": "ਉਰੂਗਵੇ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "EAT": "ਪੂਰਬੀ ਅਫਰੀਕਾ ਵੇਲਾ", "CLT": "ਚਿਲੀ ਮਿਆਰੀ ਵੇਲਾ", "AEST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "UYT": "ਉਰੂਗਵੇ ਮਿਆਰੀ ਵੇਲਾ", "WAST": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HKT": "ਹਾਂਗ ਕਾਂਗ ਮਿਆਰੀ ਵੇਲਾ", "HNNOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਮਿਆਰੀ ਵੇਲਾ", "HEEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "AEDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "OESZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WEZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "WESZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HEPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "WIB": "ਪੱਛਮੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "JST": "ਜਪਾਨ ਮਿਆਰੀ ਵੇਲਾ"}, + } +} + +// Locale returns the current translators string locale +func (pa *pa_Guru_IN) Locale() string { + return pa.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pa_Guru_IN' +func (pa *pa_Guru_IN) PluralsCardinal() []locales.PluralRule { + return pa.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pa_Guru_IN' +func (pa *pa_Guru_IN) PluralsOrdinal() []locales.PluralRule { + return pa.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pa_Guru_IN' +func (pa *pa_Guru_IN) PluralsRange() []locales.PluralRule { + return pa.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pa.CardinalPluralRule(num1, v1) + end := pa.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pa *pa_Guru_IN) MonthAbbreviated(month time.Month) string { + return pa.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pa *pa_Guru_IN) MonthsAbbreviated() []string { + return pa.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pa *pa_Guru_IN) MonthNarrow(month time.Month) string { + return pa.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pa *pa_Guru_IN) MonthsNarrow() []string { + return pa.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pa *pa_Guru_IN) MonthWide(month time.Month) string { + return pa.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pa *pa_Guru_IN) MonthsWide() []string { + return pa.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pa *pa_Guru_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return pa.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pa *pa_Guru_IN) WeekdaysAbbreviated() []string { + return pa.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pa *pa_Guru_IN) WeekdayNarrow(weekday time.Weekday) string { + return pa.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pa *pa_Guru_IN) WeekdaysNarrow() []string { + return pa.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pa *pa_Guru_IN) WeekdayShort(weekday time.Weekday) string { + return pa.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pa *pa_Guru_IN) WeekdaysShort() []string { + return pa.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pa *pa_Guru_IN) WeekdayWide(weekday time.Weekday) string { + return pa.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pa *pa_Guru_IN) WeekdaysWide() []string { + return pa.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pa_Guru_IN' and handles both Whole and Real numbers based on 'v' +func (pa *pa_Guru_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pa_Guru_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pa *pa_Guru_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pa.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pa.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pa_Guru_IN' +// in accounting notation. +func (pa *pa_Guru_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pa.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pa.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, pa.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pa.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pa.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pa.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pa.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pa_Guru_IN' +func (pa *pa_Guru_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pa.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pa.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pa.periodsAbbreviated[0]...) + } else { + b = append(b, pa.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pa.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pa_Guru_IN/pa_Guru_IN_test.go b/vendor/github.com/go-playground/locales/pa_Guru_IN/pa_Guru_IN_test.go new file mode 100644 index 0000000000..2ac60eef49 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pa_Guru_IN/pa_Guru_IN_test.go @@ -0,0 +1,1120 @@ +package pa_Guru_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pa_Guru_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pl/pl.go b/vendor/github.com/go-playground/locales/pl/pl.go new file mode 100644 index 0000000000..8ab9fa60f4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pl/pl.go @@ -0,0 +1,636 @@ +package pl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pl' locale +func New() locales.Translator { + return &pl{ + locale: "pl", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "zł", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "sty", "lut", "mar", "kwi", "maj", "cze", "lip", "sie", "wrz", "paź", "lis", "gru"}, + monthsNarrow: []string{"", "s", "l", "m", "k", "m", "c", "l", "s", "w", "p", "l", "g"}, + monthsWide: []string{"", "stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}, + daysAbbreviated: []string{"niedz.", "pon.", "wt.", "śr.", "czw.", "pt.", "sob."}, + daysNarrow: []string{"n", "p", "w", "ś", "c", "p", "s"}, + daysShort: []string{"nie", "pon", "wto", "śro", "czw", "pią", "sob"}, + daysWide: []string{"niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"p.n.e.", "n.e."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"przed naszą erą", "naszej ery"}, + timezones: map[string]string{"HNCU": "Kuba (czas standardowy)", "EST": "Czas wschodnioamerykański standardowy", "HEEG": "Grenlandia Wschodnia (czas letni)", "WITA": "Indonezja Środkowa", "CHAST": "Chatham (czas standardowy)", "HEOG": "Grenlandia Zachodnia (czas letni)", "TMT": "Turkmenistan (czas standardowy)", "ART": "Argentyna (czas standardowy)", "ChST": "Czamorro", "HEPMX": "Meksyk (czas pacyficzny letni)", "GYT": "Gujana", "CST": "Czas środkowoamerykański standardowy", "PDT": "Czas pacyficzny letni", "CAT": "Czas środkowoafrykański", "MESZ": "Czas środkowoeuropejski letni", "ACDT": "Czas środkowoaustralijski letni", "MDT": "Czas górski letni", "HNEG": "Grenlandia Wschodnia (czas standardowy)", "SRT": "Surinam", "AWDT": "Czas zachodnioaustralijski letni", "OEZ": "Czas wschodnioeuropejski standardowy", "COT": "Kolumbia (czas standardowy)", "AKST": "Alaska (czas standardowy)", "CHADT": "Chatham (czas letni)", "ACWST": "Czas środkowo-zachodnioaustralijski standardowy", "BT": "Bhutan", "SAST": "Czas południowoafrykański", "HEPM": "Saint-Pierre i Miquelon (czas letni)", "NZDT": "Nowa Zelandia (czas letni)", "TMST": "Turkmenistan (czas letni)", "UYT": "Urugwaj (czas standardowy)", "GFT": "Gujana Francuska", "BOT": "Boliwia", "HAST": "Hawaje-Aleuty (czas standardowy)", "AST": "Czas atlantycki standardowy", "CLT": "Chile (czas standardowy)", "ARST": "Argentyna (czas letni)", "AEDT": "Czas wschodnioaustralijski letni", "MST": "Czas górski standardowy", "LHST": "Lord Howe (czas standardowy)", "HECU": "Kuba (czas letni)", "WIB": "Indonezja Zachodnia", "WART": "Argentyna Zachodnia (czas standardowy)", "AKDT": "Alaska (czas letni)", "∅∅∅": "Azory (czas letni)", "ECT": "Ekwador", "IST": "Czas indyjski", "GMT": "Czas uniwersalny", "CLST": "Chile (czas letni)", "WAST": "Czas zachodnioafrykański letni", "HKT": "Hongkong (czas standardowy)", "LHDT": "Lord Howe (czas letni)", "HNT": "Nowa Fundlandia (czas standardowy)", "SGT": "Singapur", "ACWDT": "Czas środkowo-zachodnioaustralijski letni", "OESZ": "Czas wschodnioeuropejski letni", "HNNOMX": "Meksyk Północno-Zachodni (czas standardowy)", "HAT": "Nowa Fundlandia (czas letni)", "HNPMX": "Meksyk (czas pacyficzny standardowy)", "JST": "Japonia (czas standardowy)", "HKST": "Hongkong (czas letni)", "ACST": "Czas środkowoaustralijski standardowy", "UYST": "Urugwaj (czas letni)", "AWST": "Czas zachodnioaustralijski standardowy", "ADT": "Czas atlantycki letni", "WEZ": "Czas zachodnioeuropejski standardowy", "WESZ": "Czas zachodnioeuropejski letni", "WARST": "Argentyna Zachodnia (czas letni)", "HNOG": "Grenlandia Zachodnia (czas standardowy)", "EDT": "Czas wschodnioamerykański letni", "AEST": "Czas wschodnioaustralijski standardowy", "COST": "Kolumbia (czas letni)", "WAT": "Czas zachodnioafrykański standardowy", "HADT": "Hawaje-Aleuty (czas letni)", "PST": "Czas pacyficzny standardowy", "VET": "Wenezuela", "JDT": "Japonia (czas letni)", "MYT": "Malezja", "WIT": "Indonezja Wschodnia", "CDT": "Czas środkowoamerykański letni", "NZST": "Nowa Zelandia (czas standardowy)", "HENOMX": "Meksyk Północno-Zachodni (czas letni)", "EAT": "Czas wschodnioafrykański", "MEZ": "Czas środkowoeuropejski standardowy", "HNPM": "Saint-Pierre i Miquelon (czas standardowy)"}, + } +} + +// Locale returns the current translators string locale +func (pl *pl) Locale() string { + return pl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pl' +func (pl *pl) PluralsCardinal() []locales.PluralRule { + return pl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pl' +func (pl *pl) PluralsOrdinal() []locales.PluralRule { + return pl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pl' +func (pl *pl) PluralsRange() []locales.PluralRule { + return pl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pl' +func (pl *pl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && i != 1 && iMod10 >= 0 && iMod10 <= 1) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 12 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pl' +func (pl *pl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pl' +func (pl *pl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pl.CardinalPluralRule(num1, v1) + end := pl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pl *pl) MonthAbbreviated(month time.Month) string { + return pl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pl *pl) MonthsAbbreviated() []string { + return pl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pl *pl) MonthNarrow(month time.Month) string { + return pl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pl *pl) MonthsNarrow() []string { + return pl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pl *pl) MonthWide(month time.Month) string { + return pl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pl *pl) MonthsWide() []string { + return pl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pl *pl) WeekdayAbbreviated(weekday time.Weekday) string { + return pl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pl *pl) WeekdaysAbbreviated() []string { + return pl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pl *pl) WeekdayNarrow(weekday time.Weekday) string { + return pl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pl *pl) WeekdaysNarrow() []string { + return pl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pl *pl) WeekdayShort(weekday time.Weekday) string { + return pl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pl *pl) WeekdaysShort() []string { + return pl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pl *pl) WeekdayWide(weekday time.Weekday) string { + return pl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pl *pl) WeekdaysWide() []string { + return pl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pl' and handles both Whole and Real numbers based on 'v' +func (pl *pl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pl.group) - 1; j >= 0; j-- { + b = append(b, pl.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pl *pl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pl' +func (pl *pl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pl.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pl.group) - 1; j >= 0; j-- { + b = append(b, pl.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, pl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pl' +// in accounting notation. +func (pl *pl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pl.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pl.group) - 1; j >= 0; j-- { + b = append(b, pl.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, pl.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, pl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pl' +func (pl *pl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pl' +func (pl *pl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pl' +func (pl *pl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pl' +func (pl *pl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pl' +func (pl *pl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pl' +func (pl *pl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pl' +func (pl *pl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pl' +func (pl *pl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pl/pl_test.go b/vendor/github.com/go-playground/locales/pl/pl_test.go new file mode 100644 index 0000000000..b3c0fbff0b --- /dev/null +++ b/vendor/github.com/go-playground/locales/pl/pl_test.go @@ -0,0 +1,1120 @@ +package pl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pl_PL/pl_PL.go b/vendor/github.com/go-playground/locales/pl_PL/pl_PL.go new file mode 100644 index 0000000000..4a2ee08a3f --- /dev/null +++ b/vendor/github.com/go-playground/locales/pl_PL/pl_PL.go @@ -0,0 +1,636 @@ +package pl_PL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pl_PL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pl_PL' locale +func New() locales.Translator { + return &pl_PL{ + locale: "pl_PL", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "sty", "lut", "mar", "kwi", "maj", "cze", "lip", "sie", "wrz", "paź", "lis", "gru"}, + monthsNarrow: []string{"", "s", "l", "m", "k", "m", "c", "l", "s", "w", "p", "l", "g"}, + monthsWide: []string{"", "stycznia", "lutego", "marca", "kwietnia", "maja", "czerwca", "lipca", "sierpnia", "września", "października", "listopada", "grudnia"}, + daysAbbreviated: []string{"niedz.", "pon.", "wt.", "śr.", "czw.", "pt.", "sob."}, + daysNarrow: []string{"n", "p", "w", "ś", "c", "p", "s"}, + daysShort: []string{"nie", "pon", "wto", "śro", "czw", "pią", "sob"}, + daysWide: []string{"niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"p.n.e.", "n.e."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"przed naszą erą", "naszej ery"}, + timezones: map[string]string{"CST": "Czas środkowoamerykański standardowy", "ECT": "Ekwador", "GYT": "Gujana", "ACWDT": "Czas środkowo-zachodnioaustralijski letni", "ACDT": "Czas środkowoaustralijski letni", "HNPMX": "Meksyk (czas pacyficzny standardowy)", "EAT": "Czas wschodnioafrykański", "CDT": "Czas środkowoamerykański letni", "BOT": "Boliwia", "CHAST": "Chatham (czas standardowy)", "HNCU": "Kuba (czas standardowy)", "AWST": "Czas zachodnioaustralijski standardowy", "OESZ": "Czas wschodnioeuropejski letni", "TMST": "Turkmenistan (czas letni)", "EDT": "Czas wschodnioamerykański letni", "HAT": "Nowa Fundlandia (czas letni)", "WITA": "Indonezja Środkowa", "HEPMX": "Meksyk (czas pacyficzny letni)", "AWDT": "Czas zachodnioaustralijski letni", "JDT": "Japonia (czas letni)", "ADT": "Czas atlantycki letni", "WEZ": "Czas zachodnioeuropejski standardowy", "MYT": "Malezja", "WARST": "Argentyna Zachodnia (czas letni)", "TMT": "Turkmenistan (czas standardowy)", "ACST": "Czas środkowoaustralijski standardowy", "HEPM": "Saint-Pierre i Miquelon (czas letni)", "NZST": "Nowa Zelandia (czas standardowy)", "JST": "Japonia (czas standardowy)", "∅∅∅": "Czas amazoński letni", "MEZ": "Czas środkowoeuropejski standardowy", "HKST": "Hongkong (czas letni)", "CHADT": "Chatham (czas letni)", "IST": "Czas indyjski", "ARST": "Argentyna (czas letni)", "HKT": "Hongkong (czas standardowy)", "COT": "Kolumbia (czas standardowy)", "HNT": "Nowa Fundlandia (czas standardowy)", "HECU": "Kuba (czas letni)", "WIB": "Indonezja Zachodnia", "PDT": "Czas pacyficzny letni", "HNOG": "Grenlandia Zachodnia (czas standardowy)", "HNEG": "Grenlandia Wschodnia (czas standardowy)", "OEZ": "Czas wschodnioeuropejski standardowy", "COST": "Kolumbia (czas letni)", "HEEG": "Grenlandia Wschodnia (czas letni)", "AEDT": "Czas wschodnioaustralijski letni", "LHST": "Lord Howe (czas standardowy)", "VET": "Wenezuela", "HNNOMX": "Meksyk Północno-Zachodni (czas standardowy)", "AKST": "Alaska (czas standardowy)", "ChST": "Czamorro", "CLT": "Chile (czas standardowy)", "CLST": "Chile (czas letni)", "AEST": "Czas wschodnioaustralijski standardowy", "UYT": "Urugwaj (czas standardowy)", "UYST": "Urugwaj (czas letni)", "HNPM": "Saint-Pierre i Miquelon (czas standardowy)", "HADT": "Hawaje-Aleuty (czas letni)", "NZDT": "Nowa Zelandia (czas letni)", "SRT": "Surinam", "WART": "Argentyna Zachodnia (czas standardowy)", "CAT": "Czas środkowoafrykański", "MESZ": "Czas środkowoeuropejski letni", "GMT": "Czas uniwersalny", "ART": "Argentyna (czas standardowy)", "WAST": "Czas zachodnioafrykański letni", "AKDT": "Alaska (czas letni)", "WIT": "Indonezja Wschodnia", "ACWST": "Czas środkowo-zachodnioaustralijski standardowy", "WESZ": "Czas zachodnioeuropejski letni", "MDT": "MDT", "EST": "Czas wschodnioamerykański standardowy", "WAT": "Czas zachodnioafrykański standardowy", "SAST": "Czas południowoafrykański", "HEOG": "Grenlandia Zachodnia (czas letni)", "AST": "Czas atlantycki standardowy", "HENOMX": "Meksyk Północno-Zachodni (czas letni)", "BT": "Bhutan", "SGT": "Singapur", "PST": "Czas pacyficzny standardowy", "GFT": "Gujana Francuska", "LHDT": "Lord Howe (czas letni)", "HAST": "Hawaje-Aleuty (czas standardowy)", "MST": "MST"}, + } +} + +// Locale returns the current translators string locale +func (pl *pl_PL) Locale() string { + return pl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pl_PL' +func (pl *pl_PL) PluralsCardinal() []locales.PluralRule { + return pl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pl_PL' +func (pl *pl_PL) PluralsOrdinal() []locales.PluralRule { + return pl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pl_PL' +func (pl *pl_PL) PluralsRange() []locales.PluralRule { + return pl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pl_PL' +func (pl *pl_PL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + iMod10 := i % 10 + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && i != 1 && iMod10 >= 0 && iMod10 <= 1) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 12 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pl_PL' +func (pl *pl_PL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pl_PL' +func (pl *pl_PL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pl.CardinalPluralRule(num1, v1) + end := pl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pl *pl_PL) MonthAbbreviated(month time.Month) string { + return pl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pl *pl_PL) MonthsAbbreviated() []string { + return pl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pl *pl_PL) MonthNarrow(month time.Month) string { + return pl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pl *pl_PL) MonthsNarrow() []string { + return pl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pl *pl_PL) MonthWide(month time.Month) string { + return pl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pl *pl_PL) MonthsWide() []string { + return pl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pl *pl_PL) WeekdayAbbreviated(weekday time.Weekday) string { + return pl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pl *pl_PL) WeekdaysAbbreviated() []string { + return pl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pl *pl_PL) WeekdayNarrow(weekday time.Weekday) string { + return pl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pl *pl_PL) WeekdaysNarrow() []string { + return pl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pl *pl_PL) WeekdayShort(weekday time.Weekday) string { + return pl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pl *pl_PL) WeekdaysShort() []string { + return pl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pl *pl_PL) WeekdayWide(weekday time.Weekday) string { + return pl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pl *pl_PL) WeekdaysWide() []string { + return pl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pl_PL' and handles both Whole and Real numbers based on 'v' +func (pl *pl_PL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pl.group) - 1; j >= 0; j-- { + b = append(b, pl.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pl_PL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pl *pl_PL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pl_PL' +func (pl *pl_PL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pl.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pl.group) - 1; j >= 0; j-- { + b = append(b, pl.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pl.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, pl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pl_PL' +// in accounting notation. +func (pl *pl_PL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pl.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pl.group) - 1; j >= 0; j-- { + b = append(b, pl.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, pl.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, pl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pl_PL' +func (pl *pl_PL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pl_PL' +func (pl *pl_PL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pl_PL' +func (pl *pl_PL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pl_PL' +func (pl *pl_PL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, pl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pl_PL' +func (pl *pl_PL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pl_PL' +func (pl *pl_PL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pl_PL' +func (pl *pl_PL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pl_PL' +func (pl *pl_PL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pl_PL/pl_PL_test.go b/vendor/github.com/go-playground/locales/pl_PL/pl_PL_test.go new file mode 100644 index 0000000000..1460e546ad --- /dev/null +++ b/vendor/github.com/go-playground/locales/pl_PL/pl_PL_test.go @@ -0,0 +1,1120 @@ +package pl_PL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pl_PL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/prg/prg.go b/vendor/github.com/go-playground/locales/prg/prg.go new file mode 100644 index 0000000000..9096a7f967 --- /dev/null +++ b/vendor/github.com/go-playground/locales/prg/prg.go @@ -0,0 +1,611 @@ +package prg + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type prg struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'prg' locale +func New() locales.Translator { + return &prg{ + locale: "prg", + pluralsCardinal: []locales.PluralRule{1, 2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "rag", "was", "pūl", "sak", "zal", "sīm", "līp", "dag", "sil", "spa", "lap", "sal"}, + monthsNarrow: []string{"", "R", "W", "P", "S", "Z", "S", "L", "D", "S", "S", "L", "S"}, + monthsWide: []string{"", "rags", "wassarins", "pūlis", "sakkis", "zallaws", "sīmenis", "līpa", "daggis", "sillins", "spallins", "lapkrūtis", "sallaws"}, + daysAbbreviated: []string{"nad", "pan", "wis", "pus", "ket", "pēn", "sab"}, + daysNarrow: []string{"N", "P", "W", "P", "K", "P", "S"}, + daysWide: []string{"nadīli", "panadīli", "wisasīdis", "pussisawaiti", "ketwirtiks", "pēntniks", "sabattika"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"ankstāinan", "pa pussideinan"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"AEDT": "AEDT", "WIT": "WIT", "CAT": "CAT", "CLST": "CLST", "HNPMX": "HNPMX", "HAST": "HAST", "HEPMX": "HEPMX", "HNCU": "HNCU", "ECT": "ECT", "WARST": "WARST", "HNPM": "HNPM", "HECU": "HECU", "HADT": "HADT", "ADT": "Atlāntiska daggas kerdā", "OESZ": "Dēiniskas Eurōpas daggas kerdā", "NZST": "NZST", "WESZ": "Wakkariskas Eurōpas daggas kerdā", "WART": "WART", "TMT": "TMT", "HEOG": "HEOG", "HKT": "HKT", "COST": "COST", "HEEG": "HEEG", "AKDT": "AKDT", "ChST": "ChST", "LHST": "LHST", "SGT": "SGT", "MDT": "MDT", "EST": "Dēiniskas Amērikas zēimas kerdā", "IST": "IST", "OEZ": "Dēiniskas Eurōpas zēimas kerdā", "AST": "Atlāntiska zēimas kerdā", "EDT": "Dēiniskas Amērikas daggas kerdā", "∅∅∅": "∅∅∅", "WITA": "WITA", "AWDT": "AWDT", "ACWST": "ACWST", "MEZ": "Centrālas Eurōpas zēimas kerdā", "JST": "JST", "MYT": "MYT", "HNOG": "HNOG", "HENOMX": "HENOMX", "AKST": "AKST", "HEPM": "HEPM", "PST": "Pacīfiskas Amērikas zēimas kerdā", "PDT": "Pacīfiskas Amērikas daggas kerdā", "ARST": "ARST", "BT": "BT", "HNEG": "HNEG", "AEST": "AEST", "UYST": "UYST", "AWST": "AWST", "CHADT": "CHADT", "WEZ": "Wakkariskas Eurōpas zēimas kerdā", "TMST": "TMST", "GFT": "GFT", "NZDT": "NZDT", "VET": "VET", "CLT": "CLT", "SAST": "SAST", "WIB": "WIB", "CST": "Centrālas Amērikas zēimas kerdā", "BOT": "BOT", "ART": "ART", "HAT": "HAT", "CDT": "Centrālas Amērikas daggas kerdā", "CHAST": "CHAST", "MST": "MST", "WAT": "WAT", "WAST": "WAST", "HNT": "HNT", "GMT": "Greenwich kerdā", "HKST": "HKST", "SRT": "SRT", "ACWDT": "ACWDT", "MESZ": "Centrālas Eurōpas daggas kerdā", "JDT": "JDT", "EAT": "EAT", "ACST": "ACST", "ACDT": "ACDT", "COT": "COT", "HNNOMX": "HNNOMX", "UYT": "UYT", "LHDT": "LHDT", "GYT": "GYT"}, + } +} + +// Locale returns the current translators string locale +func (prg *prg) Locale() string { + return prg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'prg' +func (prg *prg) PluralsCardinal() []locales.PluralRule { + return prg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'prg' +func (prg *prg) PluralsOrdinal() []locales.PluralRule { + return prg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'prg' +func (prg *prg) PluralsRange() []locales.PluralRule { + return prg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'prg' +func (prg *prg) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + f := locales.F(n, v) + nMod100 := math.Mod(n, 100) + nMod10 := math.Mod(n, 10) + fMod10 := f % 10 + fMod100 := f % 100 + + if (nMod10 == 0) || (nMod100 >= 11 && nMod100 <= 19) || (v == 2 && fMod100 >= 11 && fMod100 <= 19) { + return locales.PluralRuleZero + } else if (nMod10 == 1 && nMod100 != 11) || (v == 2 && fMod10 == 1 && fMod100 != 11) || (v != 2 && fMod10 == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'prg' +func (prg *prg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'prg' +func (prg *prg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (prg *prg) MonthAbbreviated(month time.Month) string { + return prg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (prg *prg) MonthsAbbreviated() []string { + return prg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (prg *prg) MonthNarrow(month time.Month) string { + return prg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (prg *prg) MonthsNarrow() []string { + return prg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (prg *prg) MonthWide(month time.Month) string { + return prg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (prg *prg) MonthsWide() []string { + return prg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (prg *prg) WeekdayAbbreviated(weekday time.Weekday) string { + return prg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (prg *prg) WeekdaysAbbreviated() []string { + return prg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (prg *prg) WeekdayNarrow(weekday time.Weekday) string { + return prg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (prg *prg) WeekdaysNarrow() []string { + return prg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (prg *prg) WeekdayShort(weekday time.Weekday) string { + return prg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (prg *prg) WeekdaysShort() []string { + return prg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (prg *prg) WeekdayWide(weekday time.Weekday) string { + return prg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (prg *prg) WeekdaysWide() []string { + return prg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'prg' and handles both Whole and Real numbers based on 'v' +func (prg *prg) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, prg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(prg.group) - 1; j >= 0; j-- { + b = append(b, prg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, prg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'prg' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (prg *prg) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, prg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, prg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, prg.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'prg' +func (prg *prg) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := prg.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, prg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(prg.group) - 1; j >= 0; j-- { + b = append(b, prg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, prg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, prg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, prg.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'prg' +// in accounting notation. +func (prg *prg) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := prg.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, prg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(prg.group) - 1; j >= 0; j-- { + b = append(b, prg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, prg.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, prg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, prg.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, prg.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'prg' +func (prg *prg) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'prg' +func (prg *prg) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x20, 0x73, 0x74}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'prg' +func (prg *prg) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0x6d, 0x65, 0x74, 0x74, 0x61, 0x73}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, prg.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'prg' +func (prg *prg) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, prg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0x6d, 0x65, 0x74, 0x74, 0x61, 0x73}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, prg.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'prg' +func (prg *prg) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, prg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'prg' +func (prg *prg) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, prg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, prg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'prg' +func (prg *prg) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, prg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, prg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'prg' +func (prg *prg) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, prg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, prg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := prg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/prg/prg_test.go b/vendor/github.com/go-playground/locales/prg/prg_test.go new file mode 100644 index 0000000000..7d3fa6a8ab --- /dev/null +++ b/vendor/github.com/go-playground/locales/prg/prg_test.go @@ -0,0 +1,1120 @@ +package prg + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "prg" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/prg_001/prg_001.go b/vendor/github.com/go-playground/locales/prg_001/prg_001.go new file mode 100644 index 0000000000..4e60e46b3f --- /dev/null +++ b/vendor/github.com/go-playground/locales/prg_001/prg_001.go @@ -0,0 +1,611 @@ +package prg_001 + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type prg_001 struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'prg_001' locale +func New() locales.Translator { + return &prg_001{ + locale: "prg_001", + pluralsCardinal: []locales.PluralRule{1, 2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "rag", "was", "pūl", "sak", "zal", "sīm", "līp", "dag", "sil", "spa", "lap", "sal"}, + monthsNarrow: []string{"", "R", "W", "P", "S", "Z", "S", "L", "D", "S", "S", "L", "S"}, + monthsWide: []string{"", "rags", "wassarins", "pūlis", "sakkis", "zallaws", "sīmenis", "līpa", "daggis", "sillins", "spallins", "lapkrūtis", "sallaws"}, + daysAbbreviated: []string{"nad", "pan", "wis", "pus", "ket", "pēn", "sab"}, + daysNarrow: []string{"N", "P", "W", "P", "K", "P", "S"}, + daysWide: []string{"nadīli", "panadīli", "wisasīdis", "pussisawaiti", "ketwirtiks", "pēntniks", "sabattika"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsWide: []string{"ankstāinan", "pa pussideinan"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"MESZ": "Centrālas Eurōpas daggas kerdā", "AEDT": "AEDT", "WITA": "WITA", "NZST": "NZST", "TMT": "TMT", "CHADT": "CHADT", "HEOG": "HEOG", "WAST": "WAST", "ACST": "ACST", "AKST": "AKST", "CDT": "Centrālas Amērikas daggas kerdā", "WIT": "WIT", "PST": "Pacīfiskas Amērikas zēimas kerdā", "EDT": "Dēiniskas Amērikas daggas kerdā", "HNEG": "HNEG", "ChST": "ChST", "HNCU": "HNCU", "MST": "MST", "HNPM": "HNPM", "GYT": "GYT", "HECU": "HECU", "BOT": "BOT", "PDT": "Pacīfiskas Amērikas daggas kerdā", "MDT": "MDT", "EST": "Dēiniskas Amērikas zēimas kerdā", "HKT": "HKT", "WIB": "WIB", "MYT": "MYT", "ACDT": "ACDT", "HENOMX": "HENOMX", "HNT": "HNT", "SRT": "SRT", "SAST": "SAST", "∅∅∅": "∅∅∅", "IST": "IST", "MEZ": "Centrālas Eurōpas zēimas kerdā", "WARST": "WARST", "ADT": "Atlāntiska daggas kerdā", "BT": "BT", "AKDT": "AKDT", "HEPM": "HEPM", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "CST": "Centrālas Amērikas zēimas kerdā", "CHAST": "CHAST", "GMT": "Greenwich kerdā", "OEZ": "Dēiniskas Eurōpas zēimas kerdā", "LHST": "LHST", "SGT": "SGT", "HADT": "HADT", "OESZ": "Dēiniskas Eurōpas daggas kerdā", "WAT": "WAT", "HKST": "HKST", "COT": "COT", "GFT": "GFT", "UYST": "UYST", "LHDT": "LHDT", "AWDT": "AWDT", "NZDT": "NZDT", "CLST": "CLST", "WEZ": "Wakkariskas Eurōpas zēimas kerdā", "ART": "ART", "HNNOMX": "HNNOMX", "HAT": "HAT", "AEST": "AEST", "ECT": "ECT", "JST": "JST", "JDT": "JDT", "WART": "WART", "HNOG": "HNOG", "UYT": "UYT", "HAST": "HAST", "CLT": "CLT", "AST": "Atlāntiska zēimas kerdā", "COST": "COST", "ACWDT": "ACWDT", "ARST": "ARST", "CAT": "CAT", "WESZ": "Wakkariskas Eurōpas daggas kerdā", "AWST": "AWST", "ACWST": "ACWST", "VET": "VET", "TMST": "TMST", "HEEG": "HEEG", "EAT": "EAT"}, + } +} + +// Locale returns the current translators string locale +func (prg *prg_001) Locale() string { + return prg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'prg_001' +func (prg *prg_001) PluralsCardinal() []locales.PluralRule { + return prg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'prg_001' +func (prg *prg_001) PluralsOrdinal() []locales.PluralRule { + return prg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'prg_001' +func (prg *prg_001) PluralsRange() []locales.PluralRule { + return prg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'prg_001' +func (prg *prg_001) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + f := locales.F(n, v) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + fMod100 := f % 100 + fMod10 := f % 10 + + if (nMod10 == 0) || (nMod100 >= 11 && nMod100 <= 19) || (v == 2 && fMod100 >= 11 && fMod100 <= 19) { + return locales.PluralRuleZero + } else if (nMod10 == 1 && nMod100 != 11) || (v == 2 && fMod10 == 1 && fMod100 != 11) || (v != 2 && fMod10 == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'prg_001' +func (prg *prg_001) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'prg_001' +func (prg *prg_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (prg *prg_001) MonthAbbreviated(month time.Month) string { + return prg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (prg *prg_001) MonthsAbbreviated() []string { + return prg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (prg *prg_001) MonthNarrow(month time.Month) string { + return prg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (prg *prg_001) MonthsNarrow() []string { + return prg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (prg *prg_001) MonthWide(month time.Month) string { + return prg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (prg *prg_001) MonthsWide() []string { + return prg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (prg *prg_001) WeekdayAbbreviated(weekday time.Weekday) string { + return prg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (prg *prg_001) WeekdaysAbbreviated() []string { + return prg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (prg *prg_001) WeekdayNarrow(weekday time.Weekday) string { + return prg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (prg *prg_001) WeekdaysNarrow() []string { + return prg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (prg *prg_001) WeekdayShort(weekday time.Weekday) string { + return prg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (prg *prg_001) WeekdaysShort() []string { + return prg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (prg *prg_001) WeekdayWide(weekday time.Weekday) string { + return prg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (prg *prg_001) WeekdaysWide() []string { + return prg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'prg_001' and handles both Whole and Real numbers based on 'v' +func (prg *prg_001) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, prg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(prg.group) - 1; j >= 0; j-- { + b = append(b, prg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, prg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'prg_001' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (prg *prg_001) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, prg.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, prg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, prg.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'prg_001' +func (prg *prg_001) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := prg.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, prg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(prg.group) - 1; j >= 0; j-- { + b = append(b, prg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, prg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, prg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, prg.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'prg_001' +// in accounting notation. +func (prg *prg_001) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := prg.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, prg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(prg.group) - 1; j >= 0; j-- { + b = append(b, prg.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, prg.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, prg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, prg.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, prg.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'prg_001' +func (prg *prg_001) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'prg_001' +func (prg *prg_001) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x20, 0x73, 0x74}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'prg_001' +func (prg *prg_001) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0x6d, 0x65, 0x74, 0x74, 0x61, 0x73}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, prg.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'prg_001' +func (prg *prg_001) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, prg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0x6d, 0x65, 0x74, 0x74, 0x61, 0x73}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, prg.monthsWide[t.Month()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'prg_001' +func (prg *prg_001) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, prg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'prg_001' +func (prg *prg_001) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, prg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, prg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'prg_001' +func (prg *prg_001) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, prg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, prg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'prg_001' +func (prg *prg_001) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, prg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, prg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := prg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/prg_001/prg_001_test.go b/vendor/github.com/go-playground/locales/prg_001/prg_001_test.go new file mode 100644 index 0000000000..a45fd505ad --- /dev/null +++ b/vendor/github.com/go-playground/locales/prg_001/prg_001_test.go @@ -0,0 +1,1120 @@ +package prg_001 + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "prg_001" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ps/ps.go b/vendor/github.com/go-playground/locales/ps/ps.go new file mode 100644 index 0000000000..d1fb73cf91 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ps/ps.go @@ -0,0 +1,590 @@ +package ps + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ps struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ps' locale +func New() locales.Translator { + return &ps{ + locale: "ps", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: "٫", + group: "٬", + minus: "‎-‎", + percent: "٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "؋", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سپتمبر", "اکتوبر", "نومبر", "دسمبر"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سپتمبر", "اکتوبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + daysShort: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + daysWide: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + periodsAbbreviated: []string{"غ.م.", "غ.و."}, + periodsNarrow: []string{"غ.م.", "غ.و."}, + periodsWide: []string{"غ.م.", "غ.و."}, + erasAbbreviated: []string{"له میلاد وړاندې", "م."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"له میلاد څخه وړاندې", "له میلاد څخه وروسته"}, + timezones: map[string]string{"HAT": "HAT", "HNEG": "HNEG", "CST": "CST", "AWDT": "AWDT", "CAT": "CAT", "BOT": "BOT", "MDT": "MDT", "EST": "EST", "COT": "COT", "HNT": "HNT", "AEDT": "AEDT", "UYT": "UYT", "HECU": "HECU", "ECT": "ECT", "OEZ": "OEZ", "∅∅∅": "∅∅∅", "AKDT": "AKDT", "HNCU": "HNCU", "WIT": "WIT", "WEZ": "د لودیځې اروپا معیاري وخت", "TMST": "TMST", "WAT": "WAT", "HENOMX": "HENOMX", "GFT": "GFT", "SRT": "SRT", "MESZ": "MESZ", "JDT": "JDT", "WART": "WART", "GMT": "گرينويچ وخت", "HEEG": "HEEG", "LHDT": "LHDT", "HEPMX": "HEPMX", "PST": "PST", "HAST": "HAST", "ACWDT": "ACWDT", "NZST": "NZST", "WARST": "WARST", "COST": "COST", "AKST": "AKST", "WIB": "WIB", "AST": "AST", "TMT": "TMT", "HNPMX": "HNPMX", "GYT": "GYT", "VET": "VET", "CLT": "CLT", "EDT": "EDT", "IST": "IST", "WAST": "WAST", "HKST": "HKST", "ACST": "ACST", "ACWST": "ACWST", "HEOG": "HEOG", "ARST": "ARST", "UYST": "UYST", "LHST": "LHST", "CHADT": "CHADT", "SGT": "SGT", "HKT": "HKT", "WITA": "WITA", "HEPM": "HEPM", "EAT": "EAT", "NZDT": "NZDT", "HNOG": "HNOG", "ADT": "ADT", "ACDT": "ACDT", "BT": "BT", "CHAST": "CHAST", "SAST": "SAST", "CDT": "CDT", "ART": "ART", "AEST": "AEST", "HNPM": "HNPM", "AWST": "AWST", "PDT": "PDT", "HNNOMX": "HNNOMX", "ChST": "ChST", "HADT": "HADT", "JST": "JST", "WESZ": "د لودیځې اورپا د اوړي وخت", "MST": "MST", "MEZ": "MEZ", "OESZ": "OESZ", "MYT": "MYT", "CLST": "CLST"}, + } +} + +// Locale returns the current translators string locale +func (ps *ps) Locale() string { + return ps.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ps' +func (ps *ps) PluralsCardinal() []locales.PluralRule { + return ps.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ps' +func (ps *ps) PluralsOrdinal() []locales.PluralRule { + return ps.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ps' +func (ps *ps) PluralsRange() []locales.PluralRule { + return ps.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ps' +func (ps *ps) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ps' +func (ps *ps) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ps' +func (ps *ps) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ps *ps) MonthAbbreviated(month time.Month) string { + return ps.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ps *ps) MonthsAbbreviated() []string { + return ps.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ps *ps) MonthNarrow(month time.Month) string { + return ps.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ps *ps) MonthsNarrow() []string { + return ps.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ps *ps) MonthWide(month time.Month) string { + return ps.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ps *ps) MonthsWide() []string { + return ps.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ps *ps) WeekdayAbbreviated(weekday time.Weekday) string { + return ps.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ps *ps) WeekdaysAbbreviated() []string { + return ps.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ps *ps) WeekdayNarrow(weekday time.Weekday) string { + return ps.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ps *ps) WeekdaysNarrow() []string { + return ps.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ps *ps) WeekdayShort(weekday time.Weekday) string { + return ps.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ps *ps) WeekdaysShort() []string { + return ps.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ps *ps) WeekdayWide(weekday time.Weekday) string { + return ps.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ps *ps) WeekdaysWide() []string { + return ps.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ps' and handles both Whole and Real numbers based on 'v' +func (ps *ps) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 9 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ps.decimal) - 1; j >= 0; j-- { + b = append(b, ps.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ps.group) - 1; j >= 0; j-- { + b = append(b, ps.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ps.minus) - 1; j >= 0; j-- { + b = append(b, ps.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ps' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ps *ps) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ps.decimal) - 1; j >= 0; j-- { + b = append(b, ps.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ps.minus) - 1; j >= 0; j-- { + b = append(b, ps.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ps.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ps' +func (ps *ps) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ps.currencies[currency] + l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ps.decimal) - 1; j >= 0; j-- { + b = append(b, ps.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ps.group) - 1; j >= 0; j-- { + b = append(b, ps.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ps.minus) - 1; j >= 0; j-- { + b = append(b, ps.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ps.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ps.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ps' +// in accounting notation. +func (ps *ps) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ps.currencies[currency] + l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ps.decimal) - 1; j >= 0; j-- { + b = append(b, ps.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ps.group) - 1; j >= 0; j-- { + b = append(b, ps.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ps.minus) - 1; j >= 0; j-- { + b = append(b, ps.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ps.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ps.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ps.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ps' +func (ps *ps) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ps' +func (ps *ps) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ps.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ps' +func (ps *ps) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xd8, 0xaf, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) + b = append(b, ps.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ps' +func (ps *ps) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ps.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) + b = append(b, ps.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ps' +func (ps *ps) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ps.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ps' +func (ps *ps) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ps.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ps.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ps' +func (ps *ps) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ps.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ps.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ps' +func (ps *ps) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ps.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ps.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := ps.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ps/ps_test.go b/vendor/github.com/go-playground/locales/ps/ps_test.go new file mode 100644 index 0000000000..2540466531 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ps/ps_test.go @@ -0,0 +1,1120 @@ +package ps + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ps" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ps_AF/ps_AF.go b/vendor/github.com/go-playground/locales/ps_AF/ps_AF.go new file mode 100644 index 0000000000..a903dd26d1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ps_AF/ps_AF.go @@ -0,0 +1,590 @@ +package ps_AF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ps_AF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ps_AF' locale +func New() locales.Translator { + return &ps_AF{ + locale: "ps_AF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: "٫", + group: "٬", + minus: "‎-‎", + percent: "٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سپتمبر", "اکتوبر", "نومبر", "دسمبر"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "جنوري", "فبروري", "مارچ", "اپریل", "مۍ", "جون", "جولای", "اګست", "سپتمبر", "اکتوبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + daysShort: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + daysWide: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + periodsAbbreviated: []string{"غ.م.", "غ.و."}, + periodsNarrow: []string{"غ.م.", "غ.و."}, + periodsWide: []string{"غ.م.", "غ.و."}, + erasAbbreviated: []string{"له میلاد وړاندې", "م."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"له میلاد څخه وړاندې", "له میلاد څخه وروسته"}, + timezones: map[string]string{"SAST": "SAST", "MYT": "MYT", "CLST": "CLST", "AST": "AST", "TMST": "TMST", "HNPMX": "HNPMX", "VET": "VET", "WAST": "WAST", "EST": "EST", "HEEG": "HEEG", "SRT": "SRT", "WIT": "WIT", "CHAST": "CHAST", "NZST": "NZST", "HEOG": "HEOG", "HNEG": "HNEG", "BT": "BT", "HNPM": "HNPM", "EAT": "EAT", "BOT": "BOT", "CLT": "CLT", "OESZ": "OESZ", "MST": "MST", "GYT": "GYT", "CHADT": "CHADT", "PST": "PST", "MEZ": "MEZ", "ARST": "ARST", "HNT": "HNT", "HAT": "HAT", "WITA": "WITA", "∅∅∅": "∅∅∅", "LHDT": "LHDT", "WIB": "WIB", "ECT": "ECT", "CAT": "CAT", "WARST": "WARST", "AKDT": "AKDT", "ChST": "ChST", "UYT": "UYT", "LHST": "LHST", "PDT": "PDT", "NZDT": "NZDT", "WEZ": "د لودیځې اروپا معیاري وخت", "GMT": "گرينويچ وخت", "MDT": "MDT", "ACST": "ACST", "AWST": "AWST", "AWDT": "AWDT", "ACWDT": "ACWDT", "ADT": "ADT", "TMT": "TMT", "COST": "COST", "AEDT": "AEDT", "HEPM": "HEPM", "HECU": "HECU", "SGT": "SGT", "HAST": "HAST", "WESZ": "د لودیځې اورپا د اوړي وخت", "ART": "ART", "HEPMX": "HEPMX", "IST": "IST", "HNOG": "HNOG", "HENOMX": "HENOMX", "AKST": "AKST", "HKST": "HKST", "HNNOMX": "HNNOMX", "GFT": "GFT", "HNCU": "HNCU", "CDT": "CDT", "HADT": "HADT", "JDT": "JDT", "WART": "WART", "MESZ": "MESZ", "OEZ": "OEZ", "EDT": "EDT", "ACDT": "ACDT", "COT": "COT", "UYST": "UYST", "CST": "CST", "ACWST": "ACWST", "HKT": "HKT", "WAT": "WAT", "AEST": "AEST", "JST": "JST"}, + } +} + +// Locale returns the current translators string locale +func (ps *ps_AF) Locale() string { + return ps.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ps_AF' +func (ps *ps_AF) PluralsCardinal() []locales.PluralRule { + return ps.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ps_AF' +func (ps *ps_AF) PluralsOrdinal() []locales.PluralRule { + return ps.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ps_AF' +func (ps *ps_AF) PluralsRange() []locales.PluralRule { + return ps.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ps_AF' +func (ps *ps_AF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ps_AF' +func (ps *ps_AF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ps_AF' +func (ps *ps_AF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ps *ps_AF) MonthAbbreviated(month time.Month) string { + return ps.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ps *ps_AF) MonthsAbbreviated() []string { + return ps.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ps *ps_AF) MonthNarrow(month time.Month) string { + return ps.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ps *ps_AF) MonthsNarrow() []string { + return ps.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ps *ps_AF) MonthWide(month time.Month) string { + return ps.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ps *ps_AF) MonthsWide() []string { + return ps.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ps *ps_AF) WeekdayAbbreviated(weekday time.Weekday) string { + return ps.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ps *ps_AF) WeekdaysAbbreviated() []string { + return ps.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ps *ps_AF) WeekdayNarrow(weekday time.Weekday) string { + return ps.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ps *ps_AF) WeekdaysNarrow() []string { + return ps.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ps *ps_AF) WeekdayShort(weekday time.Weekday) string { + return ps.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ps *ps_AF) WeekdaysShort() []string { + return ps.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ps *ps_AF) WeekdayWide(weekday time.Weekday) string { + return ps.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ps *ps_AF) WeekdaysWide() []string { + return ps.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ps_AF' and handles both Whole and Real numbers based on 'v' +func (ps *ps_AF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 9 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ps.decimal) - 1; j >= 0; j-- { + b = append(b, ps.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ps.group) - 1; j >= 0; j-- { + b = append(b, ps.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ps.minus) - 1; j >= 0; j-- { + b = append(b, ps.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ps_AF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ps *ps_AF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 11 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ps.decimal) - 1; j >= 0; j-- { + b = append(b, ps.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ps.minus) - 1; j >= 0; j-- { + b = append(b, ps.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ps.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ps_AF' +func (ps *ps_AF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ps.currencies[currency] + l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ps.decimal) - 1; j >= 0; j-- { + b = append(b, ps.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ps.group) - 1; j >= 0; j-- { + b = append(b, ps.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ps.minus) - 1; j >= 0; j-- { + b = append(b, ps.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ps.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ps.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ps_AF' +// in accounting notation. +func (ps *ps_AF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ps.currencies[currency] + l := len(s) + len(symbol) + 11 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(ps.decimal) - 1; j >= 0; j-- { + b = append(b, ps.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ps.group) - 1; j >= 0; j-- { + b = append(b, ps.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(ps.minus) - 1; j >= 0; j-- { + b = append(b, ps.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ps.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ps.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ps.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ps_AF' +func (ps *ps_AF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ps_AF' +func (ps *ps_AF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ps.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ps_AF' +func (ps *ps_AF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0xd8, 0xaf, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) + b = append(b, ps.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ps_AF' +func (ps *ps_AF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ps.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd8, 0xaf, 0x20}...) + b = append(b, ps.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ps_AF' +func (ps *ps_AF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ps.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ps_AF' +func (ps *ps_AF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ps.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ps.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ps_AF' +func (ps *ps_AF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ps.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ps.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ps_AF' +func (ps *ps_AF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ps.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ps.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := ps.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ps_AF/ps_AF_test.go b/vendor/github.com/go-playground/locales/ps_AF/ps_AF_test.go new file mode 100644 index 0000000000..c7c36af1f4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ps_AF/ps_AF_test.go @@ -0,0 +1,1120 @@ +package ps_AF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ps_AF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt/pt.go b/vendor/github.com/go-playground/locales/pt/pt.go new file mode 100644 index 0000000000..b89454ea04 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt/pt.go @@ -0,0 +1,612 @@ +package pt + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt' locale +func New() locales.Translator { + return &pt{ + locale: "pt", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "Esc.", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"∅∅∅": "Horário de Verão dos Açores", "AWDT": "Horário de Verão da Austrália Ocidental", "GMT": "Horário do Meridiano de Greenwich", "AKDT": "Horário de Verão do Alasca", "UYT": "Horário Padrão do Uruguai", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "HKT": "Horário Padrão de Hong Kong", "LHST": "Horário Padrão de Lord Howe", "AWST": "Horário Padrão da Austrália Ocidental", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "MYT": "Horário da Malásia", "WARST": "Horário de Verão da Argentina Ocidental", "TMT": "Horário Padrão do Turcomenistão", "ARST": "Horário de Verão da Argentina", "AKST": "Horário Padrão do Alasca", "SAST": "Horário da África do Sul", "GYT": "Horário da Guiana", "JST": "Horário Padrão do Japão", "NZST": "Horário Padrão da Nova Zelândia", "MESZ": "Horário de Verão da Europa Central", "WEZ": "Horário Padrão da Europa Ocidental", "EDT": "Horário de Verão Oriental", "HAT": "Horário de Verão de Terra Nova", "ChST": "Horário de Chamorro", "HNPMX": "Horário Padrão do Pacífico do México", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "HEEG": "Horário de Verão da Groelândia Oriental", "COST": "Horário de Verão da Colômbia", "HNNOMX": "Horário Padrão do Noroeste do México", "HECU": "Horário de Verão de Cuba", "ECT": "Horário do Equador", "WART": "Horário Padrão da Argentina Ocidental", "MDT": "Horário de Verão de Macau", "WAST": "Horário de Verão da África Ocidental", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "AST": "Horário Padrão do Atlântico", "OEZ": "Horário Padrão da Europa Oriental", "ACST": "Horário Padrão da Austrália Central", "HNEG": "Horário Padrão da Groelândia Oriental", "CAT": "Horário da África Central", "CLST": "Horário de Verão do Chile", "ADT": "Horário de Verão do Atlântico", "UYST": "Horário de Verão do Uruguai", "BT": "Horário do Butão", "VET": "Horário da Venezuela", "CLT": "Horário Padrão do Chile", "AEDT": "Horário de Verão da Austrália Oriental", "MEZ": "Horário Padrão da Europa Central", "OESZ": "Horário de Verão da Europa Oriental", "TMST": "Horário de Verão do Turcomenistão", "MST": "Horário Padrão de Macau", "CST": "Horário Padrão Central", "IST": "Horário Padrão da Índia", "HNOG": "Horário Padrão da Groenlândia Ocidental", "ACDT": "Horário de Verão da Austrália Central", "WITA": "Horário da Indonésia Central", "AEST": "Horário Padrão da Austrália Oriental", "SRT": "Horário do Suriname", "CHAST": "Horário Padrão de Chatham", "HKST": "Horário de Verão de Hong Kong", "SGT": "Horário Padrão de Cingapura", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "JDT": "Horário de Verão do Japão", "WESZ": "Horário de Verão da Europa Ocidental", "EST": "Horário Padrão Oriental", "HEPMX": "Horário de Verão do Pacífico do México", "HNCU": "Horário Padrão de Cuba", "CDT": "Horário de Verão Central", "COT": "Horário Padrão da Colômbia", "HENOMX": "Horário de Verão do Noroeste do México", "BOT": "Horário da Bolívia", "WAT": "Horário Padrão da África Ocidental", "EAT": "Horário da África Oriental", "WIB": "Horário da Indonésia Ocidental", "CHADT": "Horário de Verão de Chatham", "PDT": "Horário de Verão do Pacífico", "NZDT": "Horário de Verão da Nova Zelândia", "HEOG": "Horário de Verão da Groenlândia Ocidental", "ART": "Horário Padrão da Argentina", "HNT": "Horário Padrão de Terra Nova", "LHDT": "Horário de Verão de Lord Howe", "WIT": "Horário da Indonésia Oriental", "PST": "Horário Padrão do Pacífico", "GFT": "Horário da Guiana Francesa"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt' +func (pt *pt) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt' +func (pt *pt) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt' +func (pt *pt) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt' +func (pt *pt) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt' +func (pt *pt) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt' +func (pt *pt) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt' and handles both Whole and Real numbers based on 'v' +func (pt *pt) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt' +func (pt *pt) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt' +// in accounting notation. +func (pt *pt) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt' +func (pt *pt) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt' +func (pt *pt) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt' +func (pt *pt) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt' +func (pt *pt) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt' +func (pt *pt) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt' +func (pt *pt) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt' +func (pt *pt) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt' +func (pt *pt) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt/pt_test.go b/vendor/github.com/go-playground/locales/pt/pt_test.go new file mode 100644 index 0000000000..b20c726fd0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt/pt_test.go @@ -0,0 +1,1120 @@ +package pt + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_AO/pt_AO.go b/vendor/github.com/go-playground/locales/pt_AO/pt_AO.go new file mode 100644 index 0000000000..7be3e23629 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_AO/pt_AO.go @@ -0,0 +1,612 @@ +package pt_AO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_AO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_AO' locale +func New() locales.Translator { + return &pt_AO{ + locale: "pt_AO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "Kz", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"AST": "Horário Padrão do Atlântico", "GMT": "Horário do Meridiano de Greenwich", "MST": "Horário Padrão de Macau", "ARST": "Horário de Verão da Argentina", "GYT": "Horário da Guiana", "WIB": "Horário da Indonésia Ocidental", "CHADT": "Horário de Verão de Chatham", "MEZ": "Horário Padrão da Europa Central", "UYT": "Horário Padrão do Uruguai", "SAST": "Horário da África do Sul", "LHST": "Horário Padrão de Lord Howe", "HEPMX": "Horário de Verão do Pacífico do México", "AWST": "Horário Padrão da Austrália Ocidental", "COT": "Horário Padrão da Colômbia", "TMST": "Horário de Verão do Turcomenistão", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "HNPMX": "Horário Padrão do Pacífico do México", "HNCU": "Horário Padrão de Cuba", "MESZ": "Horário de Verão da Europa Central", "COST": "Horário de Verão da Colômbia", "WITA": "Horário da Indonésia Central", "HEOG": "Horário de Verão da Groenlândia Ocidental", "ART": "Horário Padrão da Argentina", "ACDT": "Horário de Verão da Austrália Central", "WIT": "Horário da Indonésia Oriental", "IST": "Horário Padrão da Índia", "NZDT": "Horário de Verão da Nova Zelândia", "CLST": "Horário de Verão do Chile", "HNEG": "Horário Padrão da Groelândia Oriental", "HEEG": "Horário de Verão da Groelândia Oriental", "GFT": "Horário da Guiana Francesa", "ChST": "Horário de Chamorro", "∅∅∅": "Horário de Verão de Brasília", "ECT": "Horário do Equador", "VET": "Horário da Venezuela", "MYT": "Horário da Malásia", "BOT": "Horário da Bolívia", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "TMT": "Horário Padrão do Turcomenistão", "HKST": "Horário de Verão de Hong Kong", "CST": "Horário Padrão Central", "CAT": "Horário da África Central", "JDT": "Horário de Verão do Japão", "WART": "Horário Padrão da Argentina Ocidental", "EST": "Horário Padrão Oriental", "HNT": "Horário Padrão de Terra Nova", "EAT": "Horário da África Oriental", "HECU": "Horário de Verão de Cuba", "CDT": "Horário de Verão Central", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "AEST": "Horário Padrão da Austrália Oriental", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "WESZ": "Horário de Verão da Europa Ocidental", "WAT": "Horário Padrão da África Ocidental", "HENOMX": "Horário de Verão do Noroeste do México", "SRT": "Horário do Suriname", "CHAST": "Horário Padrão de Chatham", "PST": "Horário Padrão do Pacífico", "PDT": "Horário de Verão do Pacífico", "WEZ": "Horário Padrão da Europa Ocidental", "UYST": "Horário de Verão do Uruguai", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "LHDT": "Horário de Verão de Lord Howe", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "OEZ": "Horário Padrão da Europa Oriental", "HAT": "Horário de Verão de Terra Nova", "AEDT": "Horário de Verão da Austrália Oriental", "SGT": "Horário Padrão de Cingapura", "HNOG": "Horário Padrão da Groenlândia Ocidental", "AKDT": "Horário de Verão do Alasca", "EDT": "Horário de Verão Oriental", "ACST": "Horário Padrão da Austrália Central", "BT": "Horário do Butão", "WARST": "Horário de Verão da Argentina Ocidental", "CLT": "Horário Padrão do Chile", "ADT": "Horário de Verão do Atlântico", "MDT": "Horário de Verão de Macau", "NZST": "Horário Padrão da Nova Zelândia", "OESZ": "Horário de Verão da Europa Oriental", "WAST": "Horário de Verão da África Ocidental", "AKST": "Horário Padrão do Alasca", "AWDT": "Horário de Verão da Austrália Ocidental", "JST": "Horário Padrão do Japão", "HKT": "Horário Padrão de Hong Kong", "HNNOMX": "Horário Padrão do Noroeste do México"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_AO) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_AO' +func (pt *pt_AO) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_AO' +func (pt *pt_AO) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_AO' +func (pt *pt_AO) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_AO' +func (pt *pt_AO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_AO' +func (pt *pt_AO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_AO' +func (pt *pt_AO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_AO) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_AO) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_AO) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_AO) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_AO) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_AO) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_AO) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_AO) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_AO) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_AO) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_AO) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_AO) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_AO) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_AO) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_AO' and handles both Whole and Real numbers based on 'v' +func (pt *pt_AO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_AO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_AO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_AO' +func (pt *pt_AO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_AO' +// in accounting notation. +func (pt *pt_AO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_AO' +func (pt *pt_AO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_AO' +func (pt *pt_AO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_AO' +func (pt *pt_AO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_AO' +func (pt *pt_AO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_AO' +func (pt *pt_AO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_AO' +func (pt *pt_AO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_AO' +func (pt *pt_AO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_AO' +func (pt *pt_AO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_AO/pt_AO_test.go b/vendor/github.com/go-playground/locales/pt_AO/pt_AO_test.go new file mode 100644 index 0000000000..1f814f895f --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_AO/pt_AO_test.go @@ -0,0 +1,1120 @@ +package pt_AO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_AO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_BR/pt_BR.go b/vendor/github.com/go-playground/locales/pt_BR/pt_BR.go new file mode 100644 index 0000000000..8e6d02f1da --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_BR/pt_BR.go @@ -0,0 +1,612 @@ +package pt_BR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_BR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_BR' locale +func New() locales.Translator { + return &pt_BR{ + locale: "pt_BR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"JDT": "Horário de Verão do Japão", "AST": "Horário Padrão do Atlântico", "ARST": "Horário de Verão da Argentina", "SRT": "Horário do Suriname", "CDT": "Horário de Verão Central", "NZDT": "Horário de Verão da Nova Zelândia", "ACST": "Horário Padrão da Austrália Central", "HNNOMX": "Horário Padrão do Noroeste do México", "LHST": "Horário Padrão de Lord Howe", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "WART": "Horário Padrão da Argentina Ocidental", "HEPMX": "Horário de Verão do Pacífico do México", "WARST": "Horário de Verão da Argentina Ocidental", "BT": "Horário do Butão", "HAT": "Horário de Verão de Terra Nova", "UYT": "Horário Padrão do Uruguai", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "TMST": "Horário de Verão do Turcomenistão", "WAT": "Horário Padrão da África Ocidental", "GFT": "Horário da Guiana Francesa", "PST": "Horário Padrão do Pacífico", "CAT": "Horário da África Central", "HNT": "Horário Padrão de Terra Nova", "AKST": "Horário Padrão do Alasca", "CST": "Horário Padrão Central", "AEDT": "Horário de Verão da Austrália Oriental", "EAT": "Horário da África Oriental", "ACDT": "Horário de Verão da Austrália Central", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "HKST": "Horário de Verão de Hong Kong", "COT": "Horário Padrão da Colômbia", "GYT": "Horário da Guiana", "AWST": "Horário Padrão da Austrália Ocidental", "BOT": "Horário da Bolívia", "AKDT": "Horário de Verão do Alasca", "HNCU": "Horário Padrão de Cuba", "EDT": "Horário de Verão Oriental", "HECU": "Horário de Verão de Cuba", "WESZ": "Horário de Verão da Europa Ocidental", "HKT": "Horário Padrão de Hong Kong", "HNEG": "Horário Padrão da Groelândia Oriental", "WITA": "Horário da Indonésia Central", "ChST": "Horário de Chamorro", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "PDT": "Horário de Verão do Pacífico", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "SGT": "Horário Padrão de Cingapura", "ECT": "Horário do Equador", "CLT": "Horário Padrão do Chile", "∅∅∅": "Horário de Verão do Acre", "UYST": "Horário de Verão do Uruguai", "CHAST": "Horário Padrão de Chatham", "SAST": "Horário da África do Sul", "WAST": "Horário de Verão da África Ocidental", "COST": "Horário de Verão da Colômbia", "HNPMX": "Horário Padrão do Pacífico do México", "WIB": "Horário da Indonésia Ocidental", "HEOG": "Horário de Verão da Groenlândia Ocidental", "OESZ": "Horário de Verão da Europa Oriental", "AEST": "Horário Padrão da Austrália Oriental", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "LHDT": "Horário de Verão de Lord Howe", "IST": "Horário Padrão da Índia", "NZST": "Horário Padrão da Nova Zelândia", "MESZ": "Horário de Verão da Europa Central", "ADT": "Horário de Verão do Atlântico", "MYT": "Horário da Malásia", "WIT": "Horário da Indonésia Oriental", "AWDT": "Horário de Verão da Austrália Ocidental", "CHADT": "Horário de Verão de Chatham", "TMT": "Horário Padrão do Turcomenistão", "OEZ": "Horário Padrão da Europa Oriental", "GMT": "Horário do Meridiano de Greenwich", "HENOMX": "Horário de Verão do Noroeste do México", "HEEG": "Horário de Verão da Groelândia Oriental", "MEZ": "Horário Padrão da Europa Central", "VET": "Horário da Venezuela", "CLST": "Horário de Verão do Chile", "HNOG": "Horário Padrão da Groenlândia Ocidental", "WEZ": "Horário Padrão da Europa Ocidental", "ART": "Horário Padrão da Argentina", "EST": "Horário Padrão Oriental", "MST": "Horário Padrão da Montanha", "MDT": "Horário de Verão da Montanha", "JST": "Horário Padrão do Japão"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_BR) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_BR' +func (pt *pt_BR) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_BR' +func (pt *pt_BR) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_BR' +func (pt *pt_BR) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_BR' +func (pt *pt_BR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_BR' +func (pt *pt_BR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_BR' +func (pt *pt_BR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_BR) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_BR) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_BR) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_BR) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_BR) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_BR) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_BR) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_BR) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_BR) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_BR) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_BR) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_BR) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_BR) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_BR) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_BR' and handles both Whole and Real numbers based on 'v' +func (pt *pt_BR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_BR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_BR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_BR' +func (pt *pt_BR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_BR' +// in accounting notation. +func (pt *pt_BR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_BR' +func (pt *pt_BR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_BR' +func (pt *pt_BR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_BR' +func (pt *pt_BR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_BR' +func (pt *pt_BR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_BR' +func (pt *pt_BR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_BR' +func (pt *pt_BR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_BR' +func (pt *pt_BR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_BR' +func (pt *pt_BR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_BR/pt_BR_test.go b/vendor/github.com/go-playground/locales/pt_BR/pt_BR_test.go new file mode 100644 index 0000000000..f132e02c00 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_BR/pt_BR_test.go @@ -0,0 +1,1120 @@ +package pt_BR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_BR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_CH/pt_CH.go b/vendor/github.com/go-playground/locales/pt_CH/pt_CH.go new file mode 100644 index 0000000000..3345214720 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_CH/pt_CH.go @@ -0,0 +1,612 @@ +package pt_CH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_CH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_CH' locale +func New() locales.Translator { + return &pt_CH{ + locale: "pt_CH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"SAST": "Horário da África do Sul", "HECU": "Horário de Verão de Cuba", "WARST": "Horário de Verão da Argentina Ocidental", "HNT": "Horário Padrão de Terra Nova", "AWDT": "Horário de Verão da Austrália Ocidental", "AST": "Horário Padrão do Atlântico", "MDT": "Horário de Verão de Macau", "WITA": "Horário da Indonésia Central", "ChST": "Horário de Chamorro", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "HNCU": "Horário Padrão de Cuba", "MYT": "Horário da Malásia", "MST": "Horário Padrão de Macau", "ART": "Horário Padrão da Argentina", "HKST": "Horário de Verão de Hong Kong", "HEEG": "Horário de Verão da Groelândia Oriental", "GYT": "Horário da Guiana", "CST": "Horário Padrão Central", "PST": "Horário Padrão do Pacífico", "HAT": "Horário de Verão de Terra Nova", "AEST": "Horário Padrão da Austrália Oriental", "UYST": "Horário de Verão do Uruguai", "WIB": "Horário da Indonésia Ocidental", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "WAT": "Horário Padrão da África Ocidental", "EDT": "Horário de Verão Oriental", "HNEG": "Horário Padrão da Groelândia Oriental", "WART": "Horário Padrão da Argentina Ocidental", "WESZ": "Horário de Verão da Europa Ocidental", "ARST": "Horário de Verão da Argentina", "AKDT": "Horário de Verão do Alasca", "LHDT": "Horário de Verão de Lord Howe", "SGT": "Horário Padrão de Cingapura", "NZST": "Horário Padrão da Nova Zelândia", "VET": "Horário da Venezuela", "OEZ": "Horário Padrão da Europa Oriental", "ACST": "Horário Padrão da Austrália Central", "COT": "Horário Padrão da Colômbia", "WIT": "Horário da Indonésia Oriental", "JST": "Horário Padrão do Japão", "GMT": "Horário do Meridiano de Greenwich", "AEDT": "Horário de Verão da Austrália Oriental", "IST": "Horário Padrão da Índia", "HEOG": "Horário de Verão da Groenlândia Ocidental", "HENOMX": "Horário de Verão do Noroeste do México", "CDT": "Horário de Verão Central", "CLT": "Horário Padrão do Chile", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "MESZ": "Horário de Verão da Europa Central", "TMST": "Horário de Verão do Turcomenistão", "HKT": "Horário Padrão de Hong Kong", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "BOT": "Horário da Bolívia", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "JDT": "Horário de Verão do Japão", "TMT": "Horário Padrão do Turcomenistão", "ACDT": "Horário de Verão da Austrália Central", "BT": "Horário do Butão", "GFT": "Horário da Guiana Francesa", "HEPMX": "Horário de Verão do Pacífico do México", "EAT": "Horário da África Oriental", "CHADT": "Horário de Verão de Chatham", "ECT": "Horário do Equador", "PDT": "Horário de Verão do Pacífico", "WEZ": "Horário Padrão da Europa Ocidental", "WAST": "Horário de Verão da África Ocidental", "CHAST": "Horário Padrão de Chatham", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "OESZ": "Horário de Verão da Europa Oriental", "COST": "Horário de Verão da Colômbia", "HNNOMX": "Horário Padrão do Noroeste do México", "LHST": "Horário Padrão de Lord Howe", "SRT": "Horário do Suriname", "CAT": "Horário da África Central", "CLST": "Horário de Verão do Chile", "HNOG": "Horário Padrão da Groenlândia Ocidental", "ADT": "Horário de Verão do Atlântico", "EST": "Horário Padrão Oriental", "UYT": "Horário Padrão do Uruguai", "∅∅∅": "Horário de Verão dos Açores", "HNPMX": "Horário Padrão do Pacífico do México", "AWST": "Horário Padrão da Austrália Ocidental", "NZDT": "Horário de Verão da Nova Zelândia", "MEZ": "Horário Padrão da Europa Central", "AKST": "Horário Padrão do Alasca"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_CH) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_CH' +func (pt *pt_CH) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_CH' +func (pt *pt_CH) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_CH' +func (pt *pt_CH) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_CH' +func (pt *pt_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_CH' +func (pt *pt_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_CH' +func (pt *pt_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_CH) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_CH) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_CH) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_CH) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_CH) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_CH) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_CH) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_CH) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_CH) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_CH) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_CH) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_CH) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_CH) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_CH) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_CH' and handles both Whole and Real numbers based on 'v' +func (pt *pt_CH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_CH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_CH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_CH' +func (pt *pt_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_CH' +// in accounting notation. +func (pt *pt_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_CH' +func (pt *pt_CH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_CH' +func (pt *pt_CH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_CH' +func (pt *pt_CH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_CH' +func (pt *pt_CH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_CH' +func (pt *pt_CH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_CH' +func (pt *pt_CH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_CH' +func (pt *pt_CH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_CH' +func (pt *pt_CH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_CH/pt_CH_test.go b/vendor/github.com/go-playground/locales/pt_CH/pt_CH_test.go new file mode 100644 index 0000000000..f54eaa48dc --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_CH/pt_CH_test.go @@ -0,0 +1,1120 @@ +package pt_CH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_CH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_CV/pt_CV.go b/vendor/github.com/go-playground/locales/pt_CV/pt_CV.go new file mode 100644 index 0000000000..3c58329e47 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_CV/pt_CV.go @@ -0,0 +1,612 @@ +package pt_CV + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_CV struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_CV' locale +func New() locales.Translator { + return &pt_CV{ + locale: "pt_CV", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "\u200b", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "\u200bPTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"COT": "Horário Padrão da Colômbia", "UYT": "Horário Padrão do Uruguai", "WIB": "Horário da Indonésia Ocidental", "CHADT": "Horário de Verão de Chatham", "OESZ": "Horário de Verão da Europa Oriental", "HENOMX": "Horário de Verão do Noroeste do México", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "AST": "Horário Padrão do Atlântico", "TMT": "Horário Padrão do Turcomenistão", "AEDT": "Horário de Verão da Austrália Oriental", "SAST": "Horário da África do Sul", "LHST": "Horário Padrão de Lord Howe", "HECU": "Horário de Verão de Cuba", "PDT": "Horário de Verão do Pacífico", "WART": "Horário Padrão da Argentina Ocidental", "EST": "Horário Padrão Oriental", "ACDT": "Horário de Verão da Austrália Central", "AKST": "Horário Padrão do Alasca", "LHDT": "Horário de Verão de Lord Howe", "HEPMX": "Horário de Verão do Pacífico do México", "GMT": "Horário do Meridiano de Greenwich", "WAST": "Horário de Verão da África Ocidental", "UYST": "Horário de Verão do Uruguai", "SGT": "Horário Padrão de Cingapura", "CAT": "Horário da África Central", "OEZ": "Horário Padrão da Europa Oriental", "HKST": "Horário de Verão de Hong Kong", "WITA": "Horário da Indonésia Central", "HNPMX": "Horário Padrão do Pacífico do México", "ECT": "Horário do Equador", "VET": "Horário da Venezuela", "GFT": "Horário da Guiana Francesa", "MDT": "Horário de Verão da Montanha", "PST": "Horário Padrão do Pacífico", "HKT": "Horário Padrão de Hong Kong", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "WIT": "Horário da Indonésia Oriental", "CHAST": "Horário Padrão de Chatham", "CLT": "Horário Padrão do Chile", "ACST": "Horário Padrão da Austrália Central", "BT": "Horário do Butão", "CDT": "Horário de Verão Central", "WESZ": "Horário de Verão da Europa Ocidental", "AKDT": "Horário de Verão do Alasca", "EAT": "Horário da África Oriental", "IST": "Horário Padrão da Índia", "WARST": "Horário de Verão da Argentina Ocidental", "ART": "Horário Padrão da Argentina", "HNT": "Horário Padrão de Terra Nova", "BOT": "Horário da Bolívia", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "WEZ": "Horário Padrão da Europa Ocidental", "MYT": "Horário da Malásia", "EDT": "Horário de Verão Oriental", "HEEG": "Horário de Verão da Groelândia Oriental", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "AEST": "Horário Padrão da Austrália Oriental", "AWDT": "Horário de Verão da Austrália Ocidental", "NZST": "Horário Padrão da Nova Zelândia", "MESZ": "Horário de Verão da Europa Central", "ARST": "Horário de Verão da Argentina", "COST": "Horário de Verão da Colômbia", "HAT": "Horário de Verão de Terra Nova", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "CLST": "Horário de Verão do Chile", "TMST": "Horário de Verão do Turcomenistão", "MEZ": "Horário Padrão da Europa Central", "WAT": "Horário Padrão da África Ocidental", "HNEG": "Horário Padrão da Groelândia Oriental", "GYT": "Horário da Guiana", "CST": "Horário Padrão Central", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "HNCU": "Horário Padrão de Cuba", "AWST": "Horário Padrão da Austrália Ocidental", "NZDT": "Horário de Verão da Nova Zelândia", "HNNOMX": "Horário Padrão do Noroeste do México", "∅∅∅": "Horário de Verão do Acre", "MST": "Horário Padrão da Montanha", "ChST": "Horário de Chamorro", "SRT": "Horário do Suriname", "JST": "Horário Padrão do Japão", "JDT": "Horário de Verão do Japão", "HNOG": "Horário Padrão da Groenlândia Ocidental", "HEOG": "Horário de Verão da Groenlândia Ocidental", "ADT": "Horário de Verão do Atlântico"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_CV) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_CV' +func (pt *pt_CV) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_CV' +func (pt *pt_CV) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_CV' +func (pt *pt_CV) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_CV' +func (pt *pt_CV) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_CV' +func (pt *pt_CV) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_CV' +func (pt *pt_CV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_CV) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_CV) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_CV) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_CV) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_CV) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_CV) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_CV) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_CV) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_CV) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_CV) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_CV) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_CV) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_CV) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_CV) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_CV' and handles both Whole and Real numbers based on 'v' +func (pt *pt_CV) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_CV' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_CV) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_CV' +func (pt *pt_CV) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_CV' +// in accounting notation. +func (pt *pt_CV) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_CV' +func (pt *pt_CV) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_CV' +func (pt *pt_CV) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_CV' +func (pt *pt_CV) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_CV' +func (pt *pt_CV) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_CV' +func (pt *pt_CV) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_CV' +func (pt *pt_CV) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_CV' +func (pt *pt_CV) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_CV' +func (pt *pt_CV) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_CV/pt_CV_test.go b/vendor/github.com/go-playground/locales/pt_CV/pt_CV_test.go new file mode 100644 index 0000000000..7ee953abd6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_CV/pt_CV_test.go @@ -0,0 +1,1120 @@ +package pt_CV + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_CV" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_GQ/pt_GQ.go b/vendor/github.com/go-playground/locales/pt_GQ/pt_GQ.go new file mode 100644 index 0000000000..85a7c9afa0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_GQ/pt_GQ.go @@ -0,0 +1,612 @@ +package pt_GQ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_GQ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_GQ' locale +func New() locales.Translator { + return &pt_GQ{ + locale: "pt_GQ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"HNCU": "Horário Padrão de Cuba", "GMT": "Horário do Meridiano de Greenwich", "WART": "Horário Padrão da Argentina Ocidental", "MDT": "Horário de Verão de Macau", "HKT": "Horário Padrão de Hong Kong", "HKST": "Horário de Verão de Hong Kong", "HNPMX": "Horário Padrão do Pacífico do México", "GYT": "Horário da Guiana", "PST": "Horário Padrão do Pacífico", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "ADT": "Horário de Verão do Atlântico", "ACST": "Horário Padrão da Austrália Central", "WITA": "Horário da Indonésia Central", "AWST": "Horário Padrão da Austrália Ocidental", "CHADT": "Horário de Verão de Chatham", "NZST": "Horário Padrão da Nova Zelândia", "OESZ": "Horário de Verão da Europa Oriental", "TMST": "Horário de Verão do Turcomenistão", "EDT": "Horário de Verão Oriental", "HNT": "Horário Padrão de Terra Nova", "SAST": "Horário da África do Sul", "IST": "Horário Padrão da Índia", "MEZ": "Horário Padrão da Europa Central", "WEZ": "Horário Padrão da Europa Ocidental", "EST": "Horário Padrão Oriental", "LHDT": "Horário de Verão de Lord Howe", "SRT": "Horário do Suriname", "AWDT": "Horário de Verão da Austrália Ocidental", "CHAST": "Horário Padrão de Chatham", "AEST": "Horário Padrão da Austrália Oriental", "CST": "Horário Padrão Central", "BT": "Horário do Butão", "TMT": "Horário Padrão do Turcomenistão", "AEDT": "Horário de Verão da Austrália Oriental", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "HECU": "Horário de Verão de Cuba", "ECT": "Horário do Equador", "JST": "Horário Padrão do Japão", "JDT": "Horário de Verão do Japão", "AST": "Horário Padrão do Atlântico", "HEOG": "Horário de Verão da Groenlândia Ocidental", "HENOMX": "Horário de Verão do Noroeste do México", "UYT": "Horário Padrão do Uruguai", "UYST": "Horário de Verão do Uruguai", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "MST": "Horário Padrão de Macau", "WAST": "Horário de Verão da África Ocidental", "COT": "Horário Padrão da Colômbia", "ACDT": "Horário de Verão da Austrália Central", "ART": "Horário Padrão da Argentina", "HNEG": "Horário Padrão da Groelândia Oriental", "GFT": "Horário da Guiana Francesa", "LHST": "Horário Padrão de Lord Howe", "CAT": "Horário da África Central", "MESZ": "Horário de Verão da Europa Central", "OEZ": "Horário Padrão da Europa Oriental", "CLT": "Horário Padrão do Chile", "∅∅∅": "Horário de Verão dos Açores", "WIB": "Horário da Indonésia Ocidental", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "NZDT": "Horário de Verão da Nova Zelândia", "WESZ": "Horário de Verão da Europa Ocidental", "EAT": "Horário da África Oriental", "WIT": "Horário da Indonésia Oriental", "ARST": "Horário de Verão da Argentina", "COST": "Horário de Verão da Colômbia", "HNNOMX": "Horário Padrão do Noroeste do México", "HEEG": "Horário de Verão da Groelândia Oriental", "HEPMX": "Horário de Verão do Pacífico do México", "PDT": "Horário de Verão do Pacífico", "VET": "Horário da Venezuela", "CLST": "Horário de Verão do Chile", "HNOG": "Horário Padrão da Groenlândia Ocidental", "SGT": "Horário Padrão de Cingapura", "WAT": "Horário Padrão da África Ocidental", "HAT": "Horário de Verão de Terra Nova", "AKDT": "Horário de Verão do Alasca", "ChST": "Horário de Chamorro", "CDT": "Horário de Verão Central", "BOT": "Horário da Bolívia", "MYT": "Horário da Malásia", "WARST": "Horário de Verão da Argentina Ocidental", "AKST": "Horário Padrão do Alasca"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_GQ) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_GQ' +func (pt *pt_GQ) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_GQ' +func (pt *pt_GQ) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_GQ' +func (pt *pt_GQ) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_GQ' +func (pt *pt_GQ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_GQ' +func (pt *pt_GQ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_GQ' +func (pt *pt_GQ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_GQ) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_GQ) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_GQ) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_GQ) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_GQ) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_GQ) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_GQ) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_GQ) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_GQ) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_GQ) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_GQ) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_GQ) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_GQ) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_GQ) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_GQ' and handles both Whole and Real numbers based on 'v' +func (pt *pt_GQ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_GQ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_GQ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_GQ' +func (pt *pt_GQ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_GQ' +// in accounting notation. +func (pt *pt_GQ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_GQ' +func (pt *pt_GQ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_GQ' +func (pt *pt_GQ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_GQ' +func (pt *pt_GQ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_GQ' +func (pt *pt_GQ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_GQ' +func (pt *pt_GQ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_GQ' +func (pt *pt_GQ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_GQ' +func (pt *pt_GQ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_GQ' +func (pt *pt_GQ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_GQ/pt_GQ_test.go b/vendor/github.com/go-playground/locales/pt_GQ/pt_GQ_test.go new file mode 100644 index 0000000000..487729c030 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_GQ/pt_GQ_test.go @@ -0,0 +1,1120 @@ +package pt_GQ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_GQ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_GW/pt_GW.go b/vendor/github.com/go-playground/locales/pt_GW/pt_GW.go new file mode 100644 index 0000000000..8df0428657 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_GW/pt_GW.go @@ -0,0 +1,612 @@ +package pt_GW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_GW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_GW' locale +func New() locales.Translator { + return &pt_GW{ + locale: "pt_GW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"CLST": "Horário de Verão do Chile", "AST": "Horário Padrão do Atlântico", "CDT": "Horário de Verão Central", "AWST": "Horário Padrão da Austrália Ocidental", "ADT": "Horário de Verão do Atlântico", "WIT": "Horário da Indonésia Oriental", "AWDT": "Horário de Verão da Austrália Ocidental", "BOT": "Horário da Bolívia", "HNOG": "Horário Padrão da Groenlândia Ocidental", "HNNOMX": "Horário Padrão do Noroeste do México", "BT": "Horário do Butão", "ChST": "Horário de Chamorro", "EST": "Horário Padrão Oriental", "COT": "Horário Padrão da Colômbia", "HENOMX": "Horário de Verão do Noroeste do México", "SRT": "Horário do Suriname", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "HNCU": "Horário Padrão de Cuba", "CST": "Horário Padrão Central", "HEOG": "Horário de Verão da Groenlândia Ocidental", "WEZ": "Horário Padrão da Europa Ocidental", "MST": "Horário Padrão de Macau", "ACST": "Horário Padrão da Austrália Central", "UYT": "Horário Padrão do Uruguai", "LHST": "Horário Padrão de Lord Howe", "SAST": "Horário da África do Sul", "EAT": "Horário da África Oriental", "NZDT": "Horário de Verão da Nova Zelândia", "JST": "Horário Padrão do Japão", "WARST": "Horário de Verão da Argentina Ocidental", "HNEG": "Horário Padrão da Groelândia Oriental", "HEEG": "Horário de Verão da Groelândia Oriental", "WITA": "Horário da Indonésia Central", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "ART": "Horário Padrão da Argentina", "AKDT": "Horário de Verão do Alasca", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "HNPMX": "Horário Padrão do Pacífico do México", "SGT": "Horário Padrão de Cingapura", "NZST": "Horário Padrão da Nova Zelândia", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "WART": "Horário Padrão da Argentina Ocidental", "CLT": "Horário Padrão do Chile", "UYST": "Horário de Verão do Uruguai", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "MEZ": "Horário Padrão da Europa Central", "OEZ": "Horário Padrão da Europa Oriental", "WAST": "Horário de Verão da África Ocidental", "HKST": "Horário de Verão de Hong Kong", "COST": "Horário de Verão da Colômbia", "ECT": "Horário do Equador", "CAT": "Horário da África Central", "JDT": "Horário de Verão do Japão", "WESZ": "Horário de Verão da Europa Ocidental", "WIB": "Horário da Indonésia Ocidental", "CHAST": "Horário Padrão de Chatham", "ARST": "Horário de Verão da Argentina", "ACDT": "Horário de Verão da Austrália Central", "AEDT": "Horário de Verão da Austrália Oriental", "AKST": "Horário Padrão do Alasca", "LHDT": "Horário de Verão de Lord Howe", "∅∅∅": "Horário de Verão do Amazonas", "MESZ": "Horário de Verão da Europa Central", "MYT": "Horário da Malásia", "OESZ": "Horário de Verão da Europa Oriental", "EDT": "Horário de Verão Oriental", "GFT": "Horário da Guiana Francesa", "HEPMX": "Horário de Verão do Pacífico do México", "GYT": "Horário da Guiana", "CHADT": "Horário de Verão de Chatham", "PDT": "Horário de Verão do Pacífico", "GMT": "Horário do Meridiano de Greenwich", "TMST": "Horário de Verão do Turcomenistão", "HNT": "Horário Padrão de Terra Nova", "AEST": "Horário Padrão da Austrália Oriental", "TMT": "Horário Padrão do Turcomenistão", "MDT": "Horário de Verão de Macau", "WAT": "Horário Padrão da África Ocidental", "HAT": "Horário de Verão de Terra Nova", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "PST": "Horário Padrão do Pacífico", "IST": "Horário Padrão da Índia", "VET": "Horário da Venezuela", "HKT": "Horário Padrão de Hong Kong", "HECU": "Horário de Verão de Cuba"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_GW) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_GW' +func (pt *pt_GW) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_GW' +func (pt *pt_GW) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_GW' +func (pt *pt_GW) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_GW' +func (pt *pt_GW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_GW' +func (pt *pt_GW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_GW' +func (pt *pt_GW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_GW) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_GW) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_GW) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_GW) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_GW) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_GW) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_GW) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_GW) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_GW) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_GW) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_GW) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_GW) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_GW) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_GW) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_GW' and handles both Whole and Real numbers based on 'v' +func (pt *pt_GW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_GW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_GW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_GW' +func (pt *pt_GW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_GW' +// in accounting notation. +func (pt *pt_GW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_GW' +func (pt *pt_GW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_GW' +func (pt *pt_GW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_GW' +func (pt *pt_GW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_GW' +func (pt *pt_GW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_GW' +func (pt *pt_GW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_GW' +func (pt *pt_GW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_GW' +func (pt *pt_GW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_GW' +func (pt *pt_GW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_GW/pt_GW_test.go b/vendor/github.com/go-playground/locales/pt_GW/pt_GW_test.go new file mode 100644 index 0000000000..ac3d93a71e --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_GW/pt_GW_test.go @@ -0,0 +1,1120 @@ +package pt_GW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_GW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_LU/pt_LU.go b/vendor/github.com/go-playground/locales/pt_LU/pt_LU.go new file mode 100644 index 0000000000..8c400c7955 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_LU/pt_LU.go @@ -0,0 +1,612 @@ +package pt_LU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_LU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_LU' locale +func New() locales.Translator { + return &pt_LU{ + locale: "pt_LU", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "F", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"ACWST": "Horário Padrão da Austrália Centro-Ocidental", "NZST": "Horário Padrão da Nova Zelândia", "GMT": "Horário do Meridiano de Greenwich", "MYT": "Horário da Malásia", "ART": "Horário Padrão da Argentina", "HAT": "Horário de Verão de Terra Nova", "AEST": "Horário Padrão da Austrália Oriental", "HECU": "Horário de Verão de Cuba", "HENOMX": "Horário de Verão do Noroeste do México", "∅∅∅": "Horário de Verão do Acre", "LHST": "Horário Padrão de Lord Howe", "AWST": "Horário Padrão da Austrália Ocidental", "HNPMX": "Horário Padrão do Pacífico do México", "VET": "Horário da Venezuela", "WARST": "Horário de Verão da Argentina Ocidental", "COT": "Horário Padrão da Colômbia", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "ACDT": "Horário de Verão da Austrália Central", "CHADT": "Horário de Verão de Chatham", "AST": "Horário Padrão do Atlântico", "ADT": "Horário de Verão do Atlântico", "WAST": "Horário de Verão da África Ocidental", "ChST": "Horário de Chamorro", "SAST": "Horário da África do Sul", "HEPMX": "Horário de Verão do Pacífico do México", "PST": "Horário Padrão do Pacífico", "HNOG": "Horário Padrão da Groenlândia Ocidental", "HNT": "Horário Padrão de Terra Nova", "HEEG": "Horário de Verão da Groelândia Oriental", "EAT": "Horário da África Oriental", "HKT": "Horário Padrão de Hong Kong", "ACST": "Horário Padrão da Austrália Central", "BOT": "Horário da Bolívia", "CLST": "Horário de Verão do Chile", "EDT": "Horário de Verão Oriental", "CDT": "Horário de Verão Central", "SGT": "Horário Padrão de Cingapura", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "WITA": "Horário da Indonésia Central", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "GYT": "Horário da Guiana", "TMST": "Horário de Verão do Turcomenistão", "COST": "Horário de Verão da Colômbia", "HNNOMX": "Horário Padrão do Noroeste do México", "WIT": "Horário da Indonésia Oriental", "CHAST": "Horário Padrão de Chatham", "MEZ": "Horário Padrão da Europa Central", "ARST": "Horário de Verão da Argentina", "BT": "Horário do Butão", "AEDT": "Horário de Verão da Austrália Oriental", "WART": "Horário Padrão da Argentina Ocidental", "JST": "Horário Padrão do Japão", "HEOG": "Horário de Verão da Groenlândia Ocidental", "TMT": "Horário Padrão do Turcomenistão", "MST": "Horário Padrão da Montanha", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "SRT": "Horário do Suriname", "UYT": "Horário Padrão do Uruguai", "LHDT": "Horário de Verão de Lord Howe", "AWDT": "Horário de Verão da Austrália Ocidental", "PDT": "Horário de Verão do Pacífico", "ECT": "Horário do Equador", "HNEG": "Horário Padrão da Groelândia Oriental", "GFT": "Horário da Guiana Francesa", "MDT": "Horário de Verão da Montanha", "HKST": "Horário de Verão de Hong Kong", "WEZ": "Horário Padrão da Europa Ocidental", "EST": "Horário Padrão Oriental", "CAT": "Horário da África Central", "IST": "Horário Padrão da Índia", "OESZ": "Horário de Verão da Europa Oriental", "MESZ": "Horário de Verão da Europa Central", "WAT": "Horário Padrão da África Ocidental", "WIB": "Horário da Indonésia Ocidental", "JDT": "Horário de Verão do Japão", "AKST": "Horário Padrão do Alasca", "AKDT": "Horário de Verão do Alasca", "UYST": "Horário de Verão do Uruguai", "CLT": "Horário Padrão do Chile", "OEZ": "Horário Padrão da Europa Oriental", "WESZ": "Horário de Verão da Europa Ocidental", "HNCU": "Horário Padrão de Cuba", "CST": "Horário Padrão Central", "NZDT": "Horário de Verão da Nova Zelândia"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_LU) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_LU' +func (pt *pt_LU) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_LU' +func (pt *pt_LU) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_LU' +func (pt *pt_LU) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_LU' +func (pt *pt_LU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_LU' +func (pt *pt_LU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_LU' +func (pt *pt_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_LU) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_LU) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_LU) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_LU) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_LU) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_LU) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_LU) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_LU) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_LU) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_LU) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_LU) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_LU) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_LU) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_LU) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_LU' and handles both Whole and Real numbers based on 'v' +func (pt *pt_LU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_LU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_LU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_LU' +func (pt *pt_LU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_LU' +// in accounting notation. +func (pt *pt_LU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_LU' +func (pt *pt_LU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_LU' +func (pt *pt_LU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_LU' +func (pt *pt_LU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_LU' +func (pt *pt_LU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_LU' +func (pt *pt_LU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_LU' +func (pt *pt_LU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_LU' +func (pt *pt_LU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_LU' +func (pt *pt_LU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_LU/pt_LU_test.go b/vendor/github.com/go-playground/locales/pt_LU/pt_LU_test.go new file mode 100644 index 0000000000..9b3dfc45e6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_LU/pt_LU_test.go @@ -0,0 +1,1120 @@ +package pt_LU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_LU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_MO/pt_MO.go b/vendor/github.com/go-playground/locales/pt_MO/pt_MO.go new file mode 100644 index 0000000000..1fe987805f --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_MO/pt_MO.go @@ -0,0 +1,650 @@ +package pt_MO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_MO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_MO' locale +func New() locales.Translator { + return &pt_MO{ + locale: "pt_MO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP$", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"MESZ": "Horário de Verão da Europa Central", "MYT": "Horário da Malásia", "TMST": "Horário de Verão do Turcomenistão", "HEEG": "Horário de Verão da Groelândia Oriental", "ChST": "Horário de Chamorro", "AWDT": "Horário de Verão da Austrália Ocidental", "SGT": "Horário Padrão de Cingapura", "VET": "Horário da Venezuela", "EAT": "Horário da África Oriental", "HKST": "Horário de Verão de Hong Kong", "LHST": "Horário Padrão de Lord Howe", "CHAST": "Horário Padrão de Chatham", "PST": "Horário Padrão do Pacífico", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "HAT": "Horário de Verão de Terra Nova", "BT": "Horário do Butão", "HNCU": "Horário Padrão de Cuba", "BOT": "Horário da Bolívia", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "HKT": "Horário Padrão de Hong Kong", "AEST": "Horário Padrão da Austrália Oriental", "JDT": "Horário de Verão do Japão", "WEZ": "Horário Padrão da Europa Ocidental", "WESZ": "Horário de Verão da Europa Ocidental", "WART": "Horário Padrão da Argentina Ocidental", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "WIB": "Horário da Indonésia Ocidental", "CDT": "Horário de Verão Central", "NZDT": "Horário de Verão da Nova Zelândia", "HNOG": "Horário Padrão da Groenlândia Ocidental", "EDT": "Horário de Verão Oriental", "COST": "Horário de Verão da Colômbia", "AKST": "Horário Padrão do Alasca", "OESZ": "Horário de Verão da Europa Oriental", "CLT": "Horário Padrão do Chile", "EST": "Horário Padrão Oriental", "HNT": "Horário Padrão de Terra Nova", "WITA": "Horário da Indonésia Central", "SRT": "Horário do Suriname", "∅∅∅": "Horário de Verão de Brasília", "AWST": "Horário Padrão da Austrália Ocidental", "HEOG": "Horário de Verão da Groenlândia Ocidental", "ARST": "Horário de Verão da Argentina", "HNNOMX": "Horário Padrão do Noroeste do México", "ACST": "Horário Padrão da Austrália Central", "CHADT": "Horário de Verão de Chatham", "MEZ": "Horário Padrão da Europa Central", "WAT": "Horário Padrão da África Ocidental", "UYT": "Horário Padrão do Uruguai", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "HEPMX": "Horário de Verão do Pacífico do México", "HECU": "Horário de Verão de Cuba", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "CLST": "Horário de Verão do Chile", "LHDT": "Horário de Verão de Lord Howe", "HNPMX": "Horário Padrão do Pacífico do México", "WARST": "Horário de Verão da Argentina Ocidental", "AST": "Horário Padrão do Atlântico", "HNEG": "Horário Padrão da Groelândia Oriental", "AEDT": "Horário de Verão da Austrália Oriental", "PDT": "Horário de Verão do Pacífico", "IST": "Horário Padrão da Índia", "TMT": "Horário Padrão do Turcomenistão", "AKDT": "Horário de Verão do Alasca", "UYST": "Horário de Verão do Uruguai", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "ADT": "Horário de Verão do Atlântico", "MST": "Horário Padrão de Macau", "WAST": "Horário de Verão da África Ocidental", "ACDT": "Horário de Verão da Austrália Central", "WIT": "Horário da Indonésia Oriental", "NZST": "Horário Padrão da Nova Zelândia", "GMT": "Horário do Meridiano de Greenwich", "ART": "Horário Padrão da Argentina", "MDT": "Horário de Verão de Macau", "COT": "Horário Padrão da Colômbia", "SAST": "Horário da África do Sul", "CST": "Horário Padrão Central", "ECT": "Horário do Equador", "OEZ": "Horário Padrão da Europa Oriental", "HENOMX": "Horário de Verão do Noroeste do México", "GFT": "Horário da Guiana Francesa", "GYT": "Horário da Guiana", "CAT": "Horário da África Central", "JST": "Horário Padrão do Japão"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_MO) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_MO' +func (pt *pt_MO) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_MO' +func (pt *pt_MO) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_MO' +func (pt *pt_MO) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_MO' +func (pt *pt_MO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_MO' +func (pt *pt_MO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_MO' +func (pt *pt_MO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_MO) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_MO) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_MO) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_MO) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_MO) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_MO) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_MO) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_MO) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_MO) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_MO) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_MO) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_MO) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_MO) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_MO) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_MO' and handles both Whole and Real numbers based on 'v' +func (pt *pt_MO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_MO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_MO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_MO' +func (pt *pt_MO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_MO' +// in accounting notation. +func (pt *pt_MO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_MO' +func (pt *pt_MO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_MO' +func (pt *pt_MO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_MO' +func (pt *pt_MO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_MO' +func (pt *pt_MO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_MO' +func (pt *pt_MO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pt.periodsAbbreviated[0]...) + } else { + b = append(b, pt.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_MO' +func (pt *pt_MO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pt.periodsAbbreviated[0]...) + } else { + b = append(b, pt.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_MO' +func (pt *pt_MO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pt.periodsAbbreviated[0]...) + } else { + b = append(b, pt.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_MO' +func (pt *pt_MO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, pt.periodsAbbreviated[0]...) + } else { + b = append(b, pt.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_MO/pt_MO_test.go b/vendor/github.com/go-playground/locales/pt_MO/pt_MO_test.go new file mode 100644 index 0000000000..f1206eb395 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_MO/pt_MO_test.go @@ -0,0 +1,1120 @@ +package pt_MO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_MO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_MZ/pt_MZ.go b/vendor/github.com/go-playground/locales/pt_MZ/pt_MZ.go new file mode 100644 index 0000000000..d9a5488709 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_MZ/pt_MZ.go @@ -0,0 +1,612 @@ +package pt_MZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_MZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_MZ' locale +func New() locales.Translator { + return &pt_MZ{ + locale: "pt_MZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MTn", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"ADT": "Horário de Verão do Atlântico", "EST": "Horário Padrão Oriental", "EDT": "Horário de Verão Oriental", "COT": "Horário Padrão da Colômbia", "SGT": "Horário Padrão de Cingapura", "ECT": "Horário do Equador", "PST": "Horário Padrão do Pacífico", "PDT": "Horário de Verão do Pacífico", "HNPMX": "Horário Padrão do Pacífico do México", "HEPMX": "Horário de Verão do Pacífico do México", "SAST": "Horário da África do Sul", "WIB": "Horário da Indonésia Ocidental", "BOT": "Horário da Bolívia", "HEOG": "Horário de Verão da Groenlândia Ocidental", "HNNOMX": "Horário Padrão do Noroeste do México", "∅∅∅": "Horário de Verão de Brasília", "CHADT": "Horário de Verão de Chatham", "NZDT": "Horário de Verão da Nova Zelândia", "ACDT": "Horário de Verão da Austrália Central", "CLST": "Horário de Verão do Chile", "AST": "Horário Padrão do Atlântico", "HKST": "Horário de Verão de Hong Kong", "AEDT": "Horário de Verão da Austrália Oriental", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "JST": "Horário Padrão do Japão", "WARST": "Horário de Verão da Argentina Ocidental", "CLT": "Horário Padrão do Chile", "ChST": "Horário de Chamorro", "HNEG": "Horário Padrão da Groelândia Oriental", "AKDT": "Horário de Verão do Alasca", "LHDT": "Horário de Verão de Lord Howe", "WEZ": "Horário Padrão da Europa Ocidental", "WESZ": "Horário de Verão da Europa Ocidental", "ARST": "Horário de Verão da Argentina", "WAST": "Horário de Verão da África Ocidental", "IST": "Horário Padrão da Índia", "WAT": "Horário Padrão da África Ocidental", "UYT": "Horário Padrão do Uruguai", "COST": "Horário de Verão da Colômbia", "HAT": "Horário de Verão de Terra Nova", "UYST": "Horário de Verão do Uruguai", "LHST": "Horário Padrão de Lord Howe", "CAT": "Horário da África Central", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "JDT": "Horário de Verão do Japão", "MDT": "Horário de Verão de Macau", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "HNCU": "Horário Padrão de Cuba", "NZST": "Horário Padrão da Nova Zelândia", "VET": "Horário da Venezuela", "WART": "Horário Padrão da Argentina Ocidental", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "HNOG": "Horário Padrão da Groenlândia Ocidental", "SRT": "Horário do Suriname", "AWDT": "Horário de Verão da Austrália Ocidental", "HKT": "Horário Padrão de Hong Kong", "HNT": "Horário Padrão de Terra Nova", "HEEG": "Horário de Verão da Groelândia Oriental", "GFT": "Horário da Guiana Francesa", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "HECU": "Horário de Verão de Cuba", "AWST": "Horário Padrão da Austrália Ocidental", "TMT": "Horário Padrão do Turcomenistão", "ACST": "Horário Padrão da Austrália Central", "MYT": "Horário da Malásia", "GYT": "Horário da Guiana", "EAT": "Horário da África Oriental", "WIT": "Horário da Indonésia Oriental", "GMT": "Horário do Meridiano de Greenwich", "ART": "Horário Padrão da Argentina", "AEST": "Horário Padrão da Austrália Oriental", "CST": "Horário Padrão Central", "MESZ": "Horário de Verão da Europa Central", "OEZ": "Horário Padrão da Europa Oriental", "OESZ": "Horário de Verão da Europa Oriental", "MEZ": "Horário Padrão da Europa Central", "BT": "Horário do Butão", "WITA": "Horário da Indonésia Central", "AKST": "Horário Padrão do Alasca", "CDT": "Horário de Verão Central", "CHAST": "Horário Padrão de Chatham", "TMST": "Horário de Verão do Turcomenistão", "MST": "Horário Padrão de Macau", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "HENOMX": "Horário de Verão do Noroeste do México"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_MZ) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_MZ' +func (pt *pt_MZ) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_MZ' +func (pt *pt_MZ) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_MZ' +func (pt *pt_MZ) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_MZ' +func (pt *pt_MZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_MZ' +func (pt *pt_MZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_MZ' +func (pt *pt_MZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_MZ) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_MZ) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_MZ) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_MZ) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_MZ) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_MZ) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_MZ) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_MZ) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_MZ) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_MZ) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_MZ) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_MZ) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_MZ) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_MZ) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_MZ' and handles both Whole and Real numbers based on 'v' +func (pt *pt_MZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_MZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_MZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_MZ' +func (pt *pt_MZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_MZ' +// in accounting notation. +func (pt *pt_MZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_MZ' +func (pt *pt_MZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_MZ' +func (pt *pt_MZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_MZ' +func (pt *pt_MZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_MZ' +func (pt *pt_MZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_MZ' +func (pt *pt_MZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_MZ' +func (pt *pt_MZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_MZ' +func (pt *pt_MZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_MZ' +func (pt *pt_MZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_MZ/pt_MZ_test.go b/vendor/github.com/go-playground/locales/pt_MZ/pt_MZ_test.go new file mode 100644 index 0000000000..e4cc81950a --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_MZ/pt_MZ_test.go @@ -0,0 +1,1120 @@ +package pt_MZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_MZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_PT/pt_PT.go b/vendor/github.com/go-playground/locales/pt_PT/pt_PT.go new file mode 100644 index 0000000000..03540cad57 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_PT/pt_PT.go @@ -0,0 +1,623 @@ +package pt_PT + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_PT struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_PT' locale +func New() locales.Translator { + return &pt_PT{ + locale: "pt_PT", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "\u200b", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"domingo", "segunda", "terça", "quarta", "quinta", "sexta", "sábado"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"da manhã", "da tarde"}, + erasAbbreviated: []string{"a.E.C.", "E.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"EST": "Hora padrão Oriental", "LHST": "Hora padrão de Lord Howe", "AWST": "Hora padrão da Austrália Ocidental", "NZDT": "Hora de verão da Nova Zelândia", "WEZ": "Hora padrão da Europa Ocidental", "WESZ": "Hora de verão da Europa Ocidental", "ART": "Hora padrão da Argentina", "ARST": "Hora de verão da Argentina", "HNPMX": "Hora padrão do Pacífico Mexicano", "HENOMX": "Hora de verão do Noroeste do México", "ChST": "Hora padrão do Chamorro", "GYT": "Hora da Guiana", "WIB": "Hora da Indonésia Ocidental", "NZST": "Hora padrão da Nova Zelândia", "WARST": "Hora de verão da Argentina Ocidental", "WAST": "Hora de verão da África Ocidental", "AEDT": "Hora de verão da Austrália Oriental", "UYST": "Hora de verão do Uruguai", "AWDT": "Hora de verão da Austrália Ocidental", "PDT": "Hora de verão do Pacífico", "VET": "Hora da Venezuela", "WAT": "Hora padrão da África Ocidental", "HNNOMX": "Hora padrão do Noroeste do México", "AEST": "Hora padrão da Austrália Oriental", "AKDT": "Hora de verão do Alasca", "SRT": "Hora do Suriname", "CHAST": "Hora padrão do Chatham", "ECT": "Hora do Equador", "ACWDT": "Hora de verão da Austrália Central Ocidental", "MEZ": "Hora padrão da Europa Central", "TMT": "Hora padrão do Turquemenistão", "WITA": "Hora da Indonésia Central", "ADT": "Hora de verão do Atlântico", "TMST": "Hora de verão do Turquemenistão", "ACDT": "Hora de verão da Austrália Central", "HNPM": "Hora padrão de São Pedro e Miquelão", "JST": "Hora padrão do Japão", "MDT": "Hora de verão de Macau", "HECU": "Hora de verão de Cuba", "ACST": "Hora padrão da Austrália Central", "CDT": "Hora de verão Central", "∅∅∅": "Hora de verão do Amazonas", "WART": "Hora padrão da Argentina Ocidental", "COST": "Hora de verão da Colômbia", "UYT": "Hora padrão do Uruguai", "BOT": "Hora da Bolívia", "HAST": "Hora padrão do Havai e Aleutas", "SAST": "Hora da África do Sul", "CST": "Hora padrão Central", "LHDT": "Hora de verão de Lord Howe", "HNCU": "Hora padrão de Cuba", "SGT": "Hora padrão de Singapura", "HADT": "Hora de verão do Havai e Aleutas", "CAT": "Hora da África Central", "ACWST": "Hora padrão da Austrália Central Ocidental", "AST": "Hora padrão do Atlântico", "OEZ": "Hora padrão da Europa Oriental", "GMT": "Hora de Greenwich", "CLT": "Hora padrão do Chile", "HKT": "Hora padrão de Hong Kong", "HKST": "Hora de verão de Hong Kong", "JDT": "Hora de verão do Japão", "MST": "Hora padrão de Macau", "COT": "Hora padrão da Colômbia", "HNEG": "Hora padrão da Gronelândia Oriental", "MYT": "Hora da Malásia", "AKST": "Hora padrão do Alasca", "HEPM": "Hora de verão de São Pedro e Miquelão", "HEPMX": "Hora de verão do Pacífico Mexicano", "EAT": "Hora da África Oriental", "HNT": "Hora padrão da Terra Nova", "HAT": "Hora de verão da Terra Nova", "CHADT": "Hora de verão do Chatham", "PST": "Hora padrão do Pacífico", "CLST": "Hora de verão do Chile", "HNOG": "Hora padrão da Gronelândia Ocidental", "HEOG": "Hora de verão da Gronelândia Ocidental", "OESZ": "Hora de verão da Europa Oriental", "GFT": "Hora da Guiana Francesa", "IST": "Hora padrão da Índia", "MESZ": "Hora de verão da Europa Central", "EDT": "Hora de verão Oriental", "BT": "Hora do Butão", "HEEG": "Hora de verão da Gronelândia Oriental", "WIT": "Hora da Indonésia Oriental"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_PT) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_PT' +func (pt *pt_PT) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_PT' +func (pt *pt_PT) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_PT' +func (pt *pt_PT) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_PT' +func (pt *pt_PT) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_PT' +func (pt *pt_PT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_PT' +func (pt *pt_PT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_PT) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_PT) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_PT) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_PT) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_PT) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_PT) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_PT) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_PT) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_PT) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_PT) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_PT) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_PT) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_PT) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_PT) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_PT' and handles both Whole and Real numbers based on 'v' +func (pt *pt_PT) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pt.group) - 1; j >= 0; j-- { + b = append(b, pt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_PT' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_PT) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_PT' +func (pt *pt_PT) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pt.group) - 1; j >= 0; j-- { + b = append(b, pt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, pt.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_PT' +// in accounting notation. +func (pt *pt_PT) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(pt.group) - 1; j >= 0; j-- { + b = append(b, pt.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, pt.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, pt.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_PT' +func (pt *pt_PT) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_PT' +func (pt *pt_PT) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_PT' +func (pt *pt_PT) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_PT' +func (pt *pt_PT) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_PT' +func (pt *pt_PT) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_PT' +func (pt *pt_PT) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_PT' +func (pt *pt_PT) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_PT' +func (pt *pt_PT) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_PT/pt_PT_test.go b/vendor/github.com/go-playground/locales/pt_PT/pt_PT_test.go new file mode 100644 index 0000000000..e2e057d88f --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_PT/pt_PT_test.go @@ -0,0 +1,1120 @@ +package pt_PT + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_PT" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_ST/pt_ST.go b/vendor/github.com/go-playground/locales/pt_ST/pt_ST.go new file mode 100644 index 0000000000..30cd725d8b --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_ST/pt_ST.go @@ -0,0 +1,612 @@ +package pt_ST + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_ST struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_ST' locale +func New() locales.Translator { + return &pt_ST{ + locale: "pt_ST", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "Db", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"HEOG": "Horário de Verão da Groenlândia Ocidental", "ADT": "Horário de Verão do Atlântico", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "CAT": "Horário da África Central", "WITA": "Horário da Indonésia Central", "GYT": "Horário da Guiana", "HKST": "Horário de Verão de Hong Kong", "NZDT": "Horário de Verão da Nova Zelândia", "TMT": "Horário Padrão do Turcomenistão", "ACDT": "Horário de Verão da Austrália Central", "EAT": "Horário da África Oriental", "AWST": "Horário Padrão da Austrália Ocidental", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "OEZ": "Horário Padrão da Europa Oriental", "COST": "Horário de Verão da Colômbia", "HNNOMX": "Horário Padrão do Noroeste do México", "HENOMX": "Horário de Verão do Noroeste do México", "AKDT": "Horário de Verão do Alasca", "∅∅∅": "Horário de Verão de Brasília", "CST": "Horário Padrão Central", "GMT": "Horário do Meridiano de Greenwich", "HNPMX": "Horário Padrão do Pacífico do México", "WIT": "Horário da Indonésia Oriental", "PST": "Horário Padrão do Pacífico", "HAT": "Horário de Verão de Terra Nova", "AEDT": "Horário de Verão da Austrália Oriental", "UYT": "Horário Padrão do Uruguai", "JDT": "Horário de Verão do Japão", "WAT": "Horário Padrão da África Ocidental", "TMST": "Horário de Verão do Turcomenistão", "SRT": "Horário do Suriname", "MESZ": "Horário de Verão da Europa Central", "MYT": "Horário da Malásia", "WAST": "Horário de Verão da África Ocidental", "GFT": "Horário da Guiana Francesa", "CLT": "Horário Padrão do Chile", "ARST": "Horário de Verão da Argentina", "WEZ": "Horário Padrão da Europa Ocidental", "WART": "Horário Padrão da Argentina Ocidental", "COT": "Horário Padrão da Colômbia", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "CDT": "Horário de Verão Central", "AWDT": "Horário de Verão da Austrália Ocidental", "HNEG": "Horário Padrão da Groelândia Oriental", "ECT": "Horário do Equador", "ACST": "Horário Padrão da Austrália Central", "BT": "Horário do Butão", "AKST": "Horário Padrão do Alasca", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "JST": "Horário Padrão do Japão", "MEZ": "Horário Padrão da Europa Central", "HNOG": "Horário Padrão da Groenlândia Ocidental", "EST": "Horário Padrão Oriental", "AEST": "Horário Padrão da Austrália Oriental", "UYST": "Horário de Verão do Uruguai", "WIB": "Horário da Indonésia Ocidental", "SGT": "Horário Padrão de Cingapura", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "AST": "Horário Padrão do Atlântico", "MDT": "Horário de Verão de Macau", "HKT": "Horário Padrão de Hong Kong", "HEEG": "Horário de Verão da Groelândia Oriental", "CHADT": "Horário de Verão de Chatham", "PDT": "Horário de Verão do Pacífico", "MST": "Horário Padrão de Macau", "LHST": "Horário Padrão de Lord Howe", "LHDT": "Horário de Verão de Lord Howe", "HEPMX": "Horário de Verão do Pacífico do México", "CHAST": "Horário Padrão de Chatham", "OESZ": "Horário de Verão da Europa Oriental", "IST": "Horário Padrão da Índia", "VET": "Horário da Venezuela", "WESZ": "Horário de Verão da Europa Ocidental", "EDT": "Horário de Verão Oriental", "HNT": "Horário Padrão de Terra Nova", "HECU": "Horário de Verão de Cuba", "BOT": "Horário da Bolívia", "WARST": "Horário de Verão da Argentina Ocidental", "CLST": "Horário de Verão do Chile", "ART": "Horário Padrão da Argentina", "ChST": "Horário de Chamorro", "SAST": "Horário da África do Sul", "HNCU": "Horário Padrão de Cuba", "NZST": "Horário Padrão da Nova Zelândia"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_ST) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_ST' +func (pt *pt_ST) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_ST' +func (pt *pt_ST) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_ST' +func (pt *pt_ST) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_ST' +func (pt *pt_ST) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_ST' +func (pt *pt_ST) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_ST' +func (pt *pt_ST) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_ST) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_ST) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_ST) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_ST) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_ST) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_ST) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_ST) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_ST) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_ST) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_ST) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_ST) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_ST) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_ST) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_ST) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_ST' and handles both Whole and Real numbers based on 'v' +func (pt *pt_ST) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_ST' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_ST) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_ST' +func (pt *pt_ST) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_ST' +// in accounting notation. +func (pt *pt_ST) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_ST' +func (pt *pt_ST) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_ST' +func (pt *pt_ST) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_ST' +func (pt *pt_ST) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_ST' +func (pt *pt_ST) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_ST' +func (pt *pt_ST) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_ST' +func (pt *pt_ST) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_ST' +func (pt *pt_ST) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_ST' +func (pt *pt_ST) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_ST/pt_ST_test.go b/vendor/github.com/go-playground/locales/pt_ST/pt_ST_test.go new file mode 100644 index 0000000000..6952690cf3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_ST/pt_ST_test.go @@ -0,0 +1,1120 @@ +package pt_ST + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_ST" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/pt_TL/pt_TL.go b/vendor/github.com/go-playground/locales/pt_TL/pt_TL.go new file mode 100644 index 0000000000..e55edb20fa --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_TL/pt_TL.go @@ -0,0 +1,612 @@ +package pt_TL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type pt_TL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'pt_TL' locale +func New() locales.Translator { + return &pt_TL{ + locale: "pt_TL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "jan", "fev", "mar", "abr", "mai", "jun", "jul", "ago", "set", "out", "nov", "dez"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"}, + daysAbbreviated: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysNarrow: []string{"D", "S", "T", "Q", "Q", "S", "S"}, + daysShort: []string{"dom", "seg", "ter", "qua", "qui", "sex", "sáb"}, + daysWide: []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"a.C.", "d.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"antes de Cristo", "depois de Cristo"}, + timezones: map[string]string{"NZST": "Horário Padrão da Nova Zelândia", "MESZ": "Horário de Verão da Europa Central", "JDT": "Horário de Verão do Japão", "COST": "Horário de Verão da Colômbia", "IST": "Horário Padrão da Índia", "HEPMX": "Horário de Verão do Pacífico do México", "GYT": "Horário da Guiana", "EAT": "Horário da África Oriental", "VET": "Horário da Venezuela", "HNOG": "Horário Padrão da Groenlândia Ocidental", "HEPM": "Horário de Verão de Saint Pierre e Miquelon", "HKT": "Horário Padrão de Hong Kong", "SGT": "Horário Padrão de Cingapura", "HNPMX": "Horário Padrão do Pacífico do México", "CAT": "Horário da África Central", "MEZ": "Horário Padrão da Europa Central", "OEZ": "Horário Padrão da Europa Oriental", "GFT": "Horário da Guiana Francesa", "HNPM": "Horário Padrão de Saint Pierre e Miquelon", "∅∅∅": "Horário de Verão dos Açores", "HNCU": "Horário Padrão de Cuba", "CDT": "Horário de Verão Central", "CHADT": "Horário de Verão de Chatham", "TMT": "Horário Padrão do Turcomenistão", "BT": "Horário do Butão", "WITA": "Horário da Indonésia Central", "HEEG": "Horário de Verão da Groelândia Oriental", "NZDT": "Horário de Verão da Nova Zelândia", "EDT": "Horário de Verão Oriental", "HNT": "Horário Padrão de Terra Nova", "HNEG": "Horário Padrão da Groelândia Oriental", "ACWDT": "Horário de Verão da Austrália Centro-Ocidental", "ECT": "Horário do Equador", "WART": "Horário Padrão da Argentina Ocidental", "HEOG": "Horário de Verão da Groenlândia Ocidental", "AST": "Horário Padrão do Atlântico", "WEZ": "Horário Padrão da Europa Ocidental", "WESZ": "Horário de Verão da Europa Ocidental", "WAST": "Horário de Verão da África Ocidental", "BOT": "Horário da Bolívia", "SRT": "Horário do Suriname", "HECU": "Horário de Verão de Cuba", "WIB": "Horário da Indonésia Ocidental", "AWST": "Horário Padrão da Austrália Ocidental", "PDT": "Horário de Verão do Pacífico", "TMST": "Horário de Verão do Turcomenistão", "MST": "Horário Padrão da Montanha", "MYT": "Horário da Malásia", "AKST": "Horário Padrão do Alasca", "LHDT": "Horário de Verão de Lord Howe", "OESZ": "Horário de Verão da Europa Oriental", "EST": "Horário Padrão Oriental", "HNNOMX": "Horário Padrão do Noroeste do México", "UYST": "Horário de Verão do Uruguai", "AWDT": "Horário de Verão da Austrália Ocidental", "WAT": "Horário Padrão da África Ocidental", "ACDT": "Horário de Verão da Austrália Central", "CST": "Horário Padrão Central", "AEDT": "Horário de Verão da Austrália Oriental", "CHAST": "Horário Padrão de Chatham", "MDT": "Horário de Verão da Montanha", "SAST": "Horário da África do Sul", "WIT": "Horário da Indonésia Oriental", "PST": "Horário Padrão do Pacífico", "JST": "Horário Padrão do Japão", "HKST": "Horário de Verão de Hong Kong", "ACST": "Horário Padrão da Austrália Central", "HENOMX": "Horário de Verão do Noroeste do México", "AKDT": "Horário de Verão do Alasca", "CLST": "Horário de Verão do Chile", "ADT": "Horário de Verão do Atlântico", "ART": "Horário Padrão da Argentina", "ARST": "Horário de Verão da Argentina", "CLT": "Horário Padrão do Chile", "ChST": "Horário de Chamorro", "UYT": "Horário Padrão do Uruguai", "LHST": "Horário Padrão de Lord Howe", "HAST": "Horário Padrão do Havaí e Ilhas Aleutas", "HADT": "Horário de Verão do Havaí e Ilhas Aleutas", "ACWST": "Horário Padrão da Austrália Centro-Ocidental", "WARST": "Horário de Verão da Argentina Ocidental", "AEST": "Horário Padrão da Austrália Oriental", "COT": "Horário Padrão da Colômbia", "HAT": "Horário de Verão de Terra Nova", "GMT": "Horário do Meridiano de Greenwich"}, + } +} + +// Locale returns the current translators string locale +func (pt *pt_TL) Locale() string { + return pt.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'pt_TL' +func (pt *pt_TL) PluralsCardinal() []locales.PluralRule { + return pt.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_TL' +func (pt *pt_TL) PluralsOrdinal() []locales.PluralRule { + return pt.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'pt_TL' +func (pt *pt_TL) PluralsRange() []locales.PluralRule { + return pt.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_TL' +func (pt *pt_TL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 2 && n != 2 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_TL' +func (pt *pt_TL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_TL' +func (pt *pt_TL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := pt.CardinalPluralRule(num1, v1) + end := pt.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (pt *pt_TL) MonthAbbreviated(month time.Month) string { + return pt.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (pt *pt_TL) MonthsAbbreviated() []string { + return pt.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (pt *pt_TL) MonthNarrow(month time.Month) string { + return pt.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (pt *pt_TL) MonthsNarrow() []string { + return pt.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (pt *pt_TL) MonthWide(month time.Month) string { + return pt.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (pt *pt_TL) MonthsWide() []string { + return pt.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (pt *pt_TL) WeekdayAbbreviated(weekday time.Weekday) string { + return pt.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (pt *pt_TL) WeekdaysAbbreviated() []string { + return pt.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (pt *pt_TL) WeekdayNarrow(weekday time.Weekday) string { + return pt.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (pt *pt_TL) WeekdaysNarrow() []string { + return pt.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (pt *pt_TL) WeekdayShort(weekday time.Weekday) string { + return pt.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (pt *pt_TL) WeekdaysShort() []string { + return pt.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (pt *pt_TL) WeekdayWide(weekday time.Weekday) string { + return pt.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (pt *pt_TL) WeekdaysWide() []string { + return pt.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'pt_TL' and handles both Whole and Real numbers based on 'v' +func (pt *pt_TL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'pt_TL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (pt *pt_TL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, pt.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_TL' +func (pt *pt_TL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, pt.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_TL' +// in accounting notation. +func (pt *pt_TL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := pt.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, pt.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, pt.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, pt.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, pt.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, pt.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'pt_TL' +func (pt *pt_TL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'pt_TL' +func (pt *pt_TL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'pt_TL' +func (pt *pt_TL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'pt_TL' +func (pt *pt_TL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, pt.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, pt.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'pt_TL' +func (pt *pt_TL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'pt_TL' +func (pt *pt_TL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'pt_TL' +func (pt *pt_TL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'pt_TL' +func (pt *pt_TL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, pt.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, pt.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := pt.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/pt_TL/pt_TL_test.go b/vendor/github.com/go-playground/locales/pt_TL/pt_TL_test.go new file mode 100644 index 0000000000..b8e1cde86c --- /dev/null +++ b/vendor/github.com/go-playground/locales/pt_TL/pt_TL_test.go @@ -0,0 +1,1120 @@ +package pt_TL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "pt_TL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/qu/qu.go b/vendor/github.com/go-playground/locales/qu/qu.go new file mode 100644 index 0000000000..59233aa409 --- /dev/null +++ b/vendor/github.com/go-playground/locales/qu/qu.go @@ -0,0 +1,598 @@ +package qu + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type qu struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'qu' locale +func New() locales.Translator { + return &qu{ + locale: "qu", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "S/", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Qul", "Hat", "Pau", "Ayr", "Aym", "Int", "Ant", "Qha", "Uma", "Kan", "Aya", "Kap"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Qulla puquy", "Hatun puquy", "Pauqar waray", "Ayriwa", "Aymuray", "Inti raymi", "Anta Sitwa", "Qhapaq Sitwa", "Uma raymi", "Kantaray", "Ayamarqʼa", "Kapaq Raymi"}, + daysAbbreviated: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, + daysWide: []string{"Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"SGT": "SGT", "GMT": "GMT", "HNPMX": "HNPMX", "WITA": "WITA", "AKDT": "AKDT", "HEPM": "HEPM", "SRT": "SRT", "AWST": "AWST", "MEZ": "MEZ", "EDT": "EDT", "HNT": "HNT", "HNPM": "HNPM", "AWDT": "AWDT", "HADT": "HADT", "NZDT": "NZDT", "OESZ": "OESZ", "AEST": "AEST", "AKST": "AKST", "PDT": "PDT", "WEZ": "WEZ", "HENOMX": "HENOMX", "HNOG": "HNOG", "ARST": "ARST", "HKT": "HKT", "PST": "PST", "NZST": "NZST", "CAT": "CAT", "COT": "COT", "GFT": "GFT", "UYT": "UYT", "GYT": "GYT", "WIB": "WIB", "WIT": "WIT", "MYT": "MYT", "CLT": "CLT", "∅∅∅": "∅∅∅", "WESZ": "WESZ", "HKST": "HKST", "IST": "IST", "ACWDT": "ACWDT", "TMT": "TMT", "HNCU": "HNCU", "EST": "EST", "ChST": "ChST", "HEPMX": "HEPMX", "ECT": "ECT", "WARST": "WARST", "MST": "MST", "UYST": "UYST", "ACWST": "ACWST", "OEZ": "OEZ", "AEDT": "AEDT", "LHDT": "LHDT", "CHADT": "CHADT", "MESZ": "MESZ", "HEOG": "HEOG", "COST": "COST", "ACDT": "ACDT", "BT": "BT", "EAT": "EAT", "ART": "ART", "WAST": "WAST", "WART": "WART", "ADT": "ADT", "WAT": "WAT", "HEEG": "HEEG", "LHST": "LHST", "HECU": "HECU", "VET": "VET", "JDT": "JDT", "HAST": "HAST", "MDT": "MDT", "HNNOMX": "HNNOMX", "ACST": "ACST", "SAST": "SAST", "CDT": "CDT", "CLST": "CLST", "TMST": "TMST", "HAT": "HAT", "HNEG": "HNEG", "CST": "CST", "BOT": "BOT", "CHAST": "CHAST", "JST": "JST", "AST": "AST"}, + } +} + +// Locale returns the current translators string locale +func (qu *qu) Locale() string { + return qu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'qu' +func (qu *qu) PluralsCardinal() []locales.PluralRule { + return qu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'qu' +func (qu *qu) PluralsOrdinal() []locales.PluralRule { + return qu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'qu' +func (qu *qu) PluralsRange() []locales.PluralRule { + return qu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'qu' +func (qu *qu) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'qu' +func (qu *qu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'qu' +func (qu *qu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (qu *qu) MonthAbbreviated(month time.Month) string { + return qu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (qu *qu) MonthsAbbreviated() []string { + return qu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (qu *qu) MonthNarrow(month time.Month) string { + return qu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (qu *qu) MonthsNarrow() []string { + return qu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (qu *qu) MonthWide(month time.Month) string { + return qu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (qu *qu) MonthsWide() []string { + return qu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (qu *qu) WeekdayAbbreviated(weekday time.Weekday) string { + return qu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (qu *qu) WeekdaysAbbreviated() []string { + return qu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (qu *qu) WeekdayNarrow(weekday time.Weekday) string { + return qu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (qu *qu) WeekdaysNarrow() []string { + return qu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (qu *qu) WeekdayShort(weekday time.Weekday) string { + return qu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (qu *qu) WeekdaysShort() []string { + return qu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (qu *qu) WeekdayWide(weekday time.Weekday) string { + return qu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (qu *qu) WeekdaysWide() []string { + return qu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'qu' and handles both Whole and Real numbers based on 'v' +func (qu *qu) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'qu' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (qu *qu) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, qu.percentSuffix...) + + b = append(b, qu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'qu' +func (qu *qu) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := qu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, qu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'qu' +// in accounting notation. +func (qu *qu) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := qu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyNegativePrefix[j]) + } + + b = append(b, qu.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, qu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'qu' +func (qu *qu) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'qu' +func (qu *qu) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'qu' +func (qu *qu) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'qu' +func (qu *qu) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, qu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'qu' +func (qu *qu) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'qu' +func (qu *qu) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'qu' +func (qu *qu) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'qu' +func (qu *qu) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := qu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/qu/qu_test.go b/vendor/github.com/go-playground/locales/qu/qu_test.go new file mode 100644 index 0000000000..5a7f5f12f5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/qu/qu_test.go @@ -0,0 +1,1120 @@ +package qu + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "qu" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/qu_BO/qu_BO.go b/vendor/github.com/go-playground/locales/qu_BO/qu_BO.go new file mode 100644 index 0000000000..60eb134513 --- /dev/null +++ b/vendor/github.com/go-playground/locales/qu_BO/qu_BO.go @@ -0,0 +1,598 @@ +package qu_BO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type qu_BO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'qu_BO' locale +func New() locales.Translator { + return &qu_BO{ + locale: "qu_BO", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "Bs", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Qul", "Hat", "Pau", "Ayr", "Aym", "Int", "Ant", "Qha", "Uma", "Kan", "Aya", "Kap"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Qulla puquy", "Hatun puquy", "Pauqar waray", "Ayriwa", "Aymuray", "Inti raymi", "Anta Sitwa", "Qhapaq Sitwa", "Uma raymi", "Kantaray", "Ayamarqʼa", "Kapaq Raymi"}, + daysAbbreviated: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, + daysWide: []string{"Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"CDT": "CDT", "ACDT": "ACDT", "HEPMX": "HEPMX", "CST": "CST", "UYT": "UYT", "SAST": "SAST", "AWDT": "AWDT", "IST": "IST", "EDT": "EDT", "COT": "COT", "∅∅∅": "∅∅∅", "AEST": "AEST", "WEZ": "WEZ", "ARST": "ARST", "LHDT": "LHDT", "HNCU": "HNCU", "CHADT": "CHADT", "HAST": "HAST", "GMT": "GMT", "ACST": "ACST", "HNNOMX": "HNNOMX", "LHST": "LHST", "WIB": "WIB", "NZST": "NZST", "HNEG": "HNEG", "WITA": "WITA", "MST": "MST", "HENOMX": "HENOMX", "AEDT": "AEDT", "ACWDT": "ACWDT", "HADT": "HADT", "ACWST": "ACWST", "MESZ": "MESZ", "HEOG": "HEOG", "WESZ": "WESZ", "HAT": "HAT", "AKST": "AKST", "MDT": "MDT", "TMST": "TMST", "HKT": "HKT", "MEZ": "MEZ", "PDT": "PDT", "WART": "WART", "CLT": "CLT", "UYST": "UYST", "SRT": "SRT", "BOT": "BOT", "SGT": "SGT", "CLST": "CLST", "OESZ": "OESZ", "HNOG": "HNOG", "WAST": "WAST", "HEEG": "HEEG", "HNPM": "HNPM", "HEPM": "HEPM", "HECU": "HECU", "PST": "PST", "WAT": "WAT", "COST": "COST", "AKDT": "AKDT", "ChST": "ChST", "ECT": "ECT", "NZDT": "NZDT", "JST": "JST", "OEZ": "OEZ", "BT": "BT", "GYT": "GYT", "WIT": "WIT", "WARST": "WARST", "AST": "AST", "MYT": "MYT", "EST": "EST", "HKST": "HKST", "GFT": "GFT", "EAT": "EAT", "VET": "VET", "CHAST": "CHAST", "CAT": "CAT", "JDT": "JDT", "ADT": "ADT", "TMT": "TMT", "HNT": "HNT", "HNPMX": "HNPMX", "AWST": "AWST", "ART": "ART"}, + } +} + +// Locale returns the current translators string locale +func (qu *qu_BO) Locale() string { + return qu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'qu_BO' +func (qu *qu_BO) PluralsCardinal() []locales.PluralRule { + return qu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'qu_BO' +func (qu *qu_BO) PluralsOrdinal() []locales.PluralRule { + return qu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'qu_BO' +func (qu *qu_BO) PluralsRange() []locales.PluralRule { + return qu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'qu_BO' +func (qu *qu_BO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'qu_BO' +func (qu *qu_BO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'qu_BO' +func (qu *qu_BO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (qu *qu_BO) MonthAbbreviated(month time.Month) string { + return qu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (qu *qu_BO) MonthsAbbreviated() []string { + return qu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (qu *qu_BO) MonthNarrow(month time.Month) string { + return qu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (qu *qu_BO) MonthsNarrow() []string { + return qu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (qu *qu_BO) MonthWide(month time.Month) string { + return qu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (qu *qu_BO) MonthsWide() []string { + return qu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (qu *qu_BO) WeekdayAbbreviated(weekday time.Weekday) string { + return qu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (qu *qu_BO) WeekdaysAbbreviated() []string { + return qu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (qu *qu_BO) WeekdayNarrow(weekday time.Weekday) string { + return qu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (qu *qu_BO) WeekdaysNarrow() []string { + return qu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (qu *qu_BO) WeekdayShort(weekday time.Weekday) string { + return qu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (qu *qu_BO) WeekdaysShort() []string { + return qu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (qu *qu_BO) WeekdayWide(weekday time.Weekday) string { + return qu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (qu *qu_BO) WeekdaysWide() []string { + return qu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'qu_BO' and handles both Whole and Real numbers based on 'v' +func (qu *qu_BO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'qu_BO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (qu *qu_BO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, qu.percentSuffix...) + + b = append(b, qu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'qu_BO' +func (qu *qu_BO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := qu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, qu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'qu_BO' +// in accounting notation. +func (qu *qu_BO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := qu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyNegativePrefix[j]) + } + + b = append(b, qu.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, qu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'qu_BO' +func (qu *qu_BO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'qu_BO' +func (qu *qu_BO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'qu_BO' +func (qu *qu_BO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'qu_BO' +func (qu *qu_BO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, qu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'qu_BO' +func (qu *qu_BO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'qu_BO' +func (qu *qu_BO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'qu_BO' +func (qu *qu_BO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'qu_BO' +func (qu *qu_BO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := qu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/qu_BO/qu_BO_test.go b/vendor/github.com/go-playground/locales/qu_BO/qu_BO_test.go new file mode 100644 index 0000000000..f2fc59f50b --- /dev/null +++ b/vendor/github.com/go-playground/locales/qu_BO/qu_BO_test.go @@ -0,0 +1,1120 @@ +package qu_BO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "qu_BO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/qu_EC/qu_EC.go b/vendor/github.com/go-playground/locales/qu_EC/qu_EC.go new file mode 100644 index 0000000000..a38748864c --- /dev/null +++ b/vendor/github.com/go-playground/locales/qu_EC/qu_EC.go @@ -0,0 +1,598 @@ +package qu_EC + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type qu_EC struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'qu_EC' locale +func New() locales.Translator { + return &qu_EC{ + locale: "qu_EC", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Qul", "Hat", "Pau", "Ayr", "Aym", "Int", "Ant", "Qha", "Uma", "Kan", "Aya", "Kap"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Qulla puquy", "Hatun puquy", "Pauqar waray", "Ayriwa", "Aymuray", "Inti raymi", "Anta Sitwa", "Qhapaq Sitwa", "Uma raymi", "Kantaray", "Ayamarqʼa", "Kapaq Raymi"}, + daysAbbreviated: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, + daysWide: []string{"Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"CST": "CST", "CDT": "CDT", "ECT": "ECT", "VET": "VET", "MYT": "MYT", "TMST": "TMST", "MST": "MST", "HKST": "HKST", "CHAST": "CHAST", "MEZ": "MEZ", "MESZ": "MESZ", "HNOG": "HNOG", "ART": "ART", "HEEG": "HEEG", "WIT": "WIT", "AST": "AST", "MDT": "MDT", "WAT": "WAT", "HEOG": "HEOG", "COT": "COT", "ChST": "ChST", "ACST": "ACST", "GFT": "GFT", "HEPMX": "HEPMX", "AWDT": "AWDT", "HAT": "HAT", "UYT": "UYT", "HADT": "HADT", "∅∅∅": "∅∅∅", "ADT": "ADT", "OEZ": "OEZ", "WESZ": "WESZ", "TMT": "TMT", "SRT": "SRT", "AWST": "AWST", "ACWDT": "ACWDT", "NZDT": "NZDT", "ARST": "ARST", "HNEG": "HNEG", "WITA": "WITA", "EAT": "EAT", "AEDT": "AEDT", "HECU": "HECU", "CHADT": "CHADT", "OESZ": "OESZ", "CLT": "CLT", "CLST": "CLST", "COST": "COST", "HENOMX": "HENOMX", "HNT": "HNT", "GYT": "GYT", "HAST": "HAST", "WEZ": "WEZ", "EDT": "EDT", "HKT": "HKT", "AKST": "AKST", "HNPMX": "HNPMX", "LHST": "LHST", "LHDT": "LHDT", "HNCU": "HNCU", "SGT": "SGT", "PDT": "PDT", "SAST": "SAST", "PST": "PST", "ACWST": "ACWST", "NZST": "NZST", "EST": "EST", "ACDT": "ACDT", "HEPM": "HEPM", "JST": "JST", "BT": "BT", "AEST": "AEST", "BOT": "BOT", "UYST": "UYST", "HNPM": "HNPM", "IST": "IST", "JDT": "JDT", "GMT": "GMT", "WART": "WART", "WARST": "WARST", "AKDT": "AKDT", "WIB": "WIB", "CAT": "CAT", "WAST": "WAST", "HNNOMX": "HNNOMX"}, + } +} + +// Locale returns the current translators string locale +func (qu *qu_EC) Locale() string { + return qu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'qu_EC' +func (qu *qu_EC) PluralsCardinal() []locales.PluralRule { + return qu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'qu_EC' +func (qu *qu_EC) PluralsOrdinal() []locales.PluralRule { + return qu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'qu_EC' +func (qu *qu_EC) PluralsRange() []locales.PluralRule { + return qu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'qu_EC' +func (qu *qu_EC) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'qu_EC' +func (qu *qu_EC) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'qu_EC' +func (qu *qu_EC) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (qu *qu_EC) MonthAbbreviated(month time.Month) string { + return qu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (qu *qu_EC) MonthsAbbreviated() []string { + return qu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (qu *qu_EC) MonthNarrow(month time.Month) string { + return qu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (qu *qu_EC) MonthsNarrow() []string { + return qu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (qu *qu_EC) MonthWide(month time.Month) string { + return qu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (qu *qu_EC) MonthsWide() []string { + return qu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (qu *qu_EC) WeekdayAbbreviated(weekday time.Weekday) string { + return qu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (qu *qu_EC) WeekdaysAbbreviated() []string { + return qu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (qu *qu_EC) WeekdayNarrow(weekday time.Weekday) string { + return qu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (qu *qu_EC) WeekdaysNarrow() []string { + return qu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (qu *qu_EC) WeekdayShort(weekday time.Weekday) string { + return qu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (qu *qu_EC) WeekdaysShort() []string { + return qu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (qu *qu_EC) WeekdayWide(weekday time.Weekday) string { + return qu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (qu *qu_EC) WeekdaysWide() []string { + return qu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'qu_EC' and handles both Whole and Real numbers based on 'v' +func (qu *qu_EC) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'qu_EC' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (qu *qu_EC) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, qu.percentSuffix...) + + b = append(b, qu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'qu_EC' +func (qu *qu_EC) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := qu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, qu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'qu_EC' +// in accounting notation. +func (qu *qu_EC) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := qu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyNegativePrefix[j]) + } + + b = append(b, qu.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, qu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'qu_EC' +func (qu *qu_EC) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'qu_EC' +func (qu *qu_EC) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'qu_EC' +func (qu *qu_EC) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'qu_EC' +func (qu *qu_EC) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, qu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'qu_EC' +func (qu *qu_EC) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'qu_EC' +func (qu *qu_EC) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'qu_EC' +func (qu *qu_EC) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'qu_EC' +func (qu *qu_EC) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := qu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/qu_EC/qu_EC_test.go b/vendor/github.com/go-playground/locales/qu_EC/qu_EC_test.go new file mode 100644 index 0000000000..3017fbf8ae --- /dev/null +++ b/vendor/github.com/go-playground/locales/qu_EC/qu_EC_test.go @@ -0,0 +1,1120 @@ +package qu_EC + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "qu_EC" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/qu_PE/qu_PE.go b/vendor/github.com/go-playground/locales/qu_PE/qu_PE.go new file mode 100644 index 0000000000..bbe260c15b --- /dev/null +++ b/vendor/github.com/go-playground/locales/qu_PE/qu_PE.go @@ -0,0 +1,598 @@ +package qu_PE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type qu_PE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'qu_PE' locale +func New() locales.Translator { + return &qu_PE{ + locale: "qu_PE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Qul", "Hat", "Pau", "Ayr", "Aym", "Int", "Ant", "Qha", "Uma", "Kan", "Aya", "Kap"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Qulla puquy", "Hatun puquy", "Pauqar waray", "Ayriwa", "Aymuray", "Inti raymi", "Anta Sitwa", "Qhapaq Sitwa", "Uma raymi", "Kantaray", "Ayamarqʼa", "Kapaq Raymi"}, + daysAbbreviated: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, + daysNarrow: []string{"D", "L", "M", "X", "J", "V", "S"}, + daysShort: []string{"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"}, + daysWide: []string{"Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNCU": "HNCU", "CAT": "CAT", "JDT": "JDT", "TMST": "TMST", "HNT": "HNT", "AEST": "AEST", "EST": "EST", "BOT": "BOT", "JST": "JST", "MESZ": "MESZ", "MYT": "MYT", "CLST": "CLST", "WIT": "WIT", "IST": "IST", "VET": "VET", "WEZ": "WEZ", "HNNOMX": "HNNOMX", "HNPM": "HNPM", "PST": "PST", "HAST": "HAST", "ECT": "ECT", "OEZ": "OEZ", "ACST": "ACST", "∅∅∅": "∅∅∅", "AEDT": "AEDT", "EDT": "EDT", "ChST": "ChST", "HECU": "HECU", "GFT": "GFT", "LHST": "LHST", "SRT": "SRT", "EAT": "EAT", "HNOG": "HNOG", "ARST": "ARST", "WAT": "WAT", "WAST": "WAST", "AWST": "AWST", "PDT": "PDT", "HADT": "HADT", "HKT": "HKT", "COST": "COST", "UYST": "UYST", "HEPMX": "HEPMX", "ACDT": "ACDT", "BT": "BT", "CHADT": "CHADT", "WESZ": "WESZ", "ADT": "ADT", "MDT": "MDT", "HENOMX": "HENOMX", "TMT": "TMT", "ART": "ART", "WITA": "WITA", "AKST": "AKST", "NZDT": "NZDT", "GMT": "GMT", "WART": "WART", "MST": "MST", "CST": "CST", "CHAST": "CHAST", "ACWDT": "ACWDT", "HEEG": "HEEG", "AKDT": "AKDT", "HNPMX": "HNPMX", "CDT": "CDT", "WIB": "WIB", "OESZ": "OESZ", "HEOG": "HEOG", "HKST": "HKST", "GYT": "GYT", "SGT": "SGT", "NZST": "NZST", "COT": "COT", "HAT": "HAT", "HNEG": "HNEG", "AWDT": "AWDT", "WARST": "WARST", "AST": "AST", "HEPM": "HEPM", "ACWST": "ACWST", "MEZ": "MEZ", "CLT": "CLT", "SAST": "SAST", "UYT": "UYT", "LHDT": "LHDT"}, + } +} + +// Locale returns the current translators string locale +func (qu *qu_PE) Locale() string { + return qu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'qu_PE' +func (qu *qu_PE) PluralsCardinal() []locales.PluralRule { + return qu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'qu_PE' +func (qu *qu_PE) PluralsOrdinal() []locales.PluralRule { + return qu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'qu_PE' +func (qu *qu_PE) PluralsRange() []locales.PluralRule { + return qu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'qu_PE' +func (qu *qu_PE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'qu_PE' +func (qu *qu_PE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'qu_PE' +func (qu *qu_PE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (qu *qu_PE) MonthAbbreviated(month time.Month) string { + return qu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (qu *qu_PE) MonthsAbbreviated() []string { + return qu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (qu *qu_PE) MonthNarrow(month time.Month) string { + return qu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (qu *qu_PE) MonthsNarrow() []string { + return qu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (qu *qu_PE) MonthWide(month time.Month) string { + return qu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (qu *qu_PE) MonthsWide() []string { + return qu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (qu *qu_PE) WeekdayAbbreviated(weekday time.Weekday) string { + return qu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (qu *qu_PE) WeekdaysAbbreviated() []string { + return qu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (qu *qu_PE) WeekdayNarrow(weekday time.Weekday) string { + return qu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (qu *qu_PE) WeekdaysNarrow() []string { + return qu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (qu *qu_PE) WeekdayShort(weekday time.Weekday) string { + return qu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (qu *qu_PE) WeekdaysShort() []string { + return qu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (qu *qu_PE) WeekdayWide(weekday time.Weekday) string { + return qu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (qu *qu_PE) WeekdaysWide() []string { + return qu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'qu_PE' and handles both Whole and Real numbers based on 'v' +func (qu *qu_PE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'qu_PE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (qu *qu_PE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, qu.percentSuffix...) + + b = append(b, qu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'qu_PE' +func (qu *qu_PE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := qu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, qu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, qu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'qu_PE' +// in accounting notation. +func (qu *qu_PE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := qu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, qu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, qu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyNegativePrefix[j]) + } + + b = append(b, qu.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(qu.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, qu.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, qu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'qu_PE' +func (qu *qu_PE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'qu_PE' +func (qu *qu_PE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'qu_PE' +func (qu *qu_PE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'qu_PE' +func (qu *qu_PE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, qu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, qu.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'qu_PE' +func (qu *qu_PE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'qu_PE' +func (qu *qu_PE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'qu_PE' +func (qu *qu_PE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'qu_PE' +func (qu *qu_PE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, qu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, qu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := qu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/qu_PE/qu_PE_test.go b/vendor/github.com/go-playground/locales/qu_PE/qu_PE_test.go new file mode 100644 index 0000000000..fa203dae18 --- /dev/null +++ b/vendor/github.com/go-playground/locales/qu_PE/qu_PE_test.go @@ -0,0 +1,1120 @@ +package qu_PE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "qu_PE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rm/rm.go b/vendor/github.com/go-playground/locales/rm/rm.go new file mode 100644 index 0000000000..1c2103b37c --- /dev/null +++ b/vendor/github.com/go-playground/locales/rm/rm.go @@ -0,0 +1,619 @@ +package rm + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rm struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rm' locale +func New() locales.Translator { + return &rm{ + locale: "rm", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: "’", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "schan.", "favr.", "mars", "avr.", "matg", "zercl.", "fan.", "avust", "sett.", "oct.", "nov.", "dec."}, + monthsNarrow: []string{"", "S", "F", "M", "A", "M", "Z", "F", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "schaner", "favrer", "mars", "avrigl", "matg", "zercladur", "fanadur", "avust", "settember", "october", "november", "december"}, + daysAbbreviated: []string{"du", "gli", "ma", "me", "gie", "ve", "so"}, + daysNarrow: []string{"D", "G", "M", "M", "G", "V", "S"}, + daysShort: []string{"du", "gli", "ma", "me", "gie", "ve", "so"}, + daysWide: []string{"dumengia", "glindesdi", "mardi", "mesemna", "gievgia", "venderdi", "sonda"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. Cr.", "s. Cr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"avant Cristus", "suenter Cristus"}, + timezones: map[string]string{"LHST": "LHST", "ACWST": "ACWST", "JDT": "JDT", "AEDT": "AEDT", "AKST": "AKST", "HEPMX": "HEPMX", "MEZ": "MEZ", "HENOMX": "HENOMX", "UYT": "UYT", "GYT": "GYT", "EAT": "EAT", "HECU": "HECU", "WAT": "WAT", "HNNOMX": "HNNOMX", "HAT": "HAT", "ChST": "ChST", "SGT": "SGT", "MESZ": "MESZ", "VET": "VET", "HEOG": "HEOG", "ART": "ART", "WITA": "WITA", "AKDT": "AKDT", "UYST": "UYST", "SAST": "SAST", "WIB": "WIB", "AWDT": "AWDT", "CAT": "CAT", "HNOG": "HNOG", "ADT": "ADT", "MST": "MST", "HNCU": "HNCU", "CST": "CST", "IST": "IST", "AST": "AST", "OEZ": "OEZ", "EST": "EST", "WIT": "WIT", "HKST": "HKST", "PST": "PST", "ACWDT": "ACWDT", "WARST": "WARST", "HNPMX": "HNPMX", "PDT": "PDT", "HAST": "HAST", "NZST": "NZST", "COT": "COT", "CHAST": "CHAST", "ACST": "ACST", "GFT": "GFT", "CHADT": "CHADT", "JST": "JST", "TMST": "TMST", "MDT": "MDT", "ARST": "ARST", "EDT": "EDT", "ACDT": "ACDT", "HEPM": "HEPM", "CDT": "CDT", "NZDT": "NZDT", "CLT": "CLT", "OESZ": "OESZ", "COST": "COST", "HEEG": "HEEG", "HNPM": "HNPM", "HADT": "HADT", "WEZ": "WEZ", "WAST": "WAST", "BT": "BT", "LHDT": "LHDT", "AWST": "AWST", "BOT": "BOT", "ECT": "ECT", "GMT": "GMT", "CLST": "CLST", "HKT": "HKT", "HNEG": "HNEG", "SRT": "SRT", "∅∅∅": "∅∅∅", "MYT": "MYT", "WART": "WART", "WESZ": "WESZ", "TMT": "TMT", "HNT": "HNT", "AEST": "AEST"}, + } +} + +// Locale returns the current translators string locale +func (rm *rm) Locale() string { + return rm.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rm' +func (rm *rm) PluralsCardinal() []locales.PluralRule { + return rm.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rm' +func (rm *rm) PluralsOrdinal() []locales.PluralRule { + return rm.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rm' +func (rm *rm) PluralsRange() []locales.PluralRule { + return rm.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rm' +func (rm *rm) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rm' +func (rm *rm) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rm' +func (rm *rm) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rm *rm) MonthAbbreviated(month time.Month) string { + return rm.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rm *rm) MonthsAbbreviated() []string { + return rm.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rm *rm) MonthNarrow(month time.Month) string { + return rm.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rm *rm) MonthsNarrow() []string { + return rm.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rm *rm) MonthWide(month time.Month) string { + return rm.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rm *rm) MonthsWide() []string { + return rm.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rm *rm) WeekdayAbbreviated(weekday time.Weekday) string { + return rm.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rm *rm) WeekdaysAbbreviated() []string { + return rm.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rm *rm) WeekdayNarrow(weekday time.Weekday) string { + return rm.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rm *rm) WeekdaysNarrow() []string { + return rm.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rm *rm) WeekdayShort(weekday time.Weekday) string { + return rm.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rm *rm) WeekdaysShort() []string { + return rm.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rm *rm) WeekdayWide(weekday time.Weekday) string { + return rm.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rm *rm) WeekdaysWide() []string { + return rm.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rm' and handles both Whole and Real numbers based on 'v' +func (rm *rm) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(rm.group) - 1; j >= 0; j-- { + b = append(b, rm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(rm.minus) - 1; j >= 0; j-- { + b = append(b, rm.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rm' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rm *rm) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rm.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(rm.minus) - 1; j >= 0; j-- { + b = append(b, rm.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, rm.percentSuffix...) + + b = append(b, rm.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rm' +func (rm *rm) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rm.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(rm.group) - 1; j >= 0; j-- { + b = append(b, rm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(rm.minus) - 1; j >= 0; j-- { + b = append(b, rm.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, rm.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rm' +// in accounting notation. +func (rm *rm) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rm.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(rm.group) - 1; j >= 0; j-- { + b = append(b, rm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(rm.minus) - 1; j >= 0; j-- { + b = append(b, rm.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, rm.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, rm.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rm' +func (rm *rm) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rm' +func (rm *rm) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rm' +func (rm *rm) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = append(b, rm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rm' +func (rm *rm) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, rm.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0x69, 0x6c, 0x73}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = append(b, rm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rm' +func (rm *rm) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rm' +func (rm *rm) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rm' +func (rm *rm) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rm' +func (rm *rm) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rm.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rm/rm_test.go b/vendor/github.com/go-playground/locales/rm/rm_test.go new file mode 100644 index 0000000000..1321e760c4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rm/rm_test.go @@ -0,0 +1,1120 @@ +package rm + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rm" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rm_CH/rm_CH.go b/vendor/github.com/go-playground/locales/rm_CH/rm_CH.go new file mode 100644 index 0000000000..edbee5bfc0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rm_CH/rm_CH.go @@ -0,0 +1,619 @@ +package rm_CH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rm_CH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rm_CH' locale +func New() locales.Translator { + return &rm_CH{ + locale: "rm_CH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: "’", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "schan.", "favr.", "mars", "avr.", "matg", "zercl.", "fan.", "avust", "sett.", "oct.", "nov.", "dec."}, + monthsNarrow: []string{"", "S", "F", "M", "A", "M", "Z", "F", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "schaner", "favrer", "mars", "avrigl", "matg", "zercladur", "fanadur", "avust", "settember", "october", "november", "december"}, + daysAbbreviated: []string{"du", "gli", "ma", "me", "gie", "ve", "so"}, + daysNarrow: []string{"D", "G", "M", "M", "G", "V", "S"}, + daysShort: []string{"du", "gli", "ma", "me", "gie", "ve", "so"}, + daysWide: []string{"dumengia", "glindesdi", "mardi", "mesemna", "gievgia", "venderdi", "sonda"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"av. Cr.", "s. Cr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"avant Cristus", "suenter Cristus"}, + timezones: map[string]string{"WIT": "WIT", "AWDT": "AWDT", "ECT": "ECT", "MEZ": "MEZ", "TMT": "TMT", "HAT": "HAT", "LHDT": "LHDT", "CDT": "CDT", "CST": "CST", "SGT": "SGT", "BOT": "BOT", "MYT": "MYT", "WAT": "WAT", "EDT": "EDT", "HNCU": "HNCU", "NZST": "NZST", "WART": "WART", "CLST": "CLST", "HNEG": "HNEG", "AEST": "AEST", "HECU": "HECU", "CHADT": "CHADT", "ACWST": "ACWST", "ACST": "ACST", "HADT": "HADT", "ADT": "ADT", "HKT": "HKT", "HEEG": "HEEG", "AKDT": "AKDT", "UYST": "UYST", "ARST": "ARST", "SAST": "SAST", "GYT": "GYT", "HNPM": "HNPM", "PST": "PST", "IST": "IST", "VET": "VET", "AST": "AST", "TMST": "TMST", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "WAST": "WAST", "COST": "COST", "ChST": "ChST", "LHST": "LHST", "HEPMX": "HEPMX", "NZDT": "NZDT", "JDT": "JDT", "OEZ": "OEZ", "UYT": "UYT", "WIB": "WIB", "AEDT": "AEDT", "JST": "JST", "GMT": "GMT", "WARST": "WARST", "MDT": "MDT", "EST": "EST", "BT": "BT", "CAT": "CAT", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "SRT": "SRT", "AKST": "AKST", "GFT": "GFT", "EAT": "EAT", "PDT": "PDT", "ART": "ART", "HKST": "HKST", "ACDT": "ACDT", "WEZ": "WEZ", "HNT": "HNT", "AWST": "AWST", "COT": "COT", "CHAST": "CHAST", "HAST": "HAST", "ACWDT": "ACWDT", "WESZ": "WESZ", "CLT": "CLT", "MST": "MST", "MESZ": "MESZ", "OESZ": "OESZ", "HNOG": "HNOG", "HEOG": "HEOG", "WITA": "WITA", "HEPM": "HEPM"}, + } +} + +// Locale returns the current translators string locale +func (rm *rm_CH) Locale() string { + return rm.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rm_CH' +func (rm *rm_CH) PluralsCardinal() []locales.PluralRule { + return rm.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rm_CH' +func (rm *rm_CH) PluralsOrdinal() []locales.PluralRule { + return rm.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rm_CH' +func (rm *rm_CH) PluralsRange() []locales.PluralRule { + return rm.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rm_CH' +func (rm *rm_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rm_CH' +func (rm *rm_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rm_CH' +func (rm *rm_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rm *rm_CH) MonthAbbreviated(month time.Month) string { + return rm.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rm *rm_CH) MonthsAbbreviated() []string { + return rm.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rm *rm_CH) MonthNarrow(month time.Month) string { + return rm.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rm *rm_CH) MonthsNarrow() []string { + return rm.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rm *rm_CH) MonthWide(month time.Month) string { + return rm.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rm *rm_CH) MonthsWide() []string { + return rm.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rm *rm_CH) WeekdayAbbreviated(weekday time.Weekday) string { + return rm.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rm *rm_CH) WeekdaysAbbreviated() []string { + return rm.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rm *rm_CH) WeekdayNarrow(weekday time.Weekday) string { + return rm.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rm *rm_CH) WeekdaysNarrow() []string { + return rm.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rm *rm_CH) WeekdayShort(weekday time.Weekday) string { + return rm.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rm *rm_CH) WeekdaysShort() []string { + return rm.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rm *rm_CH) WeekdayWide(weekday time.Weekday) string { + return rm.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rm *rm_CH) WeekdaysWide() []string { + return rm.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rm_CH' and handles both Whole and Real numbers based on 'v' +func (rm *rm_CH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(rm.group) - 1; j >= 0; j-- { + b = append(b, rm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(rm.minus) - 1; j >= 0; j-- { + b = append(b, rm.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rm_CH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rm *rm_CH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rm.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(rm.minus) - 1; j >= 0; j-- { + b = append(b, rm.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, rm.percentSuffix...) + + b = append(b, rm.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rm_CH' +func (rm *rm_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rm.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(rm.group) - 1; j >= 0; j-- { + b = append(b, rm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(rm.minus) - 1; j >= 0; j-- { + b = append(b, rm.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, rm.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rm_CH' +// in accounting notation. +func (rm *rm_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rm.currencies[currency] + l := len(s) + len(symbol) + 6 + 3*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(rm.group) - 1; j >= 0; j-- { + b = append(b, rm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(rm.minus) - 1; j >= 0; j-- { + b = append(b, rm.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, rm.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, rm.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rm_CH' +func (rm *rm_CH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rm_CH' +func (rm *rm_CH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rm_CH' +func (rm *rm_CH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = append(b, rm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rm_CH' +func (rm *rm_CH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, rm.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20, 0x69, 0x6c, 0x73}...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x61}...) + b = append(b, []byte{0x20}...) + b = append(b, rm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rm_CH' +func (rm *rm_CH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rm_CH' +func (rm *rm_CH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rm_CH' +func (rm *rm_CH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rm_CH' +func (rm *rm_CH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rm.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rm.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rm.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rm_CH/rm_CH_test.go b/vendor/github.com/go-playground/locales/rm_CH/rm_CH_test.go new file mode 100644 index 0000000000..4f19d7aede --- /dev/null +++ b/vendor/github.com/go-playground/locales/rm_CH/rm_CH_test.go @@ -0,0 +1,1120 @@ +package rm_CH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rm_CH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rn/rn.go b/vendor/github.com/go-playground/locales/rn/rn.go new file mode 100644 index 0000000000..393cc95aab --- /dev/null +++ b/vendor/github.com/go-playground/locales/rn/rn.go @@ -0,0 +1,559 @@ +package rn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rn' locale +func New() locales.Translator { + return &rn{ + locale: "rn", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "FBu", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "Mut.", "Gas.", "Wer.", "Mat.", "Gic.", "Kam.", "Nya.", "Kan.", "Nze.", "Ukw.", "Ugu.", "Uku."}, + monthsWide: []string{"", "Nzero", "Ruhuhuma", "Ntwarante", "Ndamukiza", "Rusama", "Ruheshi", "Mukakaro", "Nyandagaro", "Nyakanga", "Gitugutu", "Munyonyo", "Kigarama"}, + daysAbbreviated: []string{"cu.", "mbe.", "kab.", "gtu.", "kan.", "gnu.", "gnd."}, + daysWide: []string{"Ku w’indwi", "Ku wa mbere", "Ku wa kabiri", "Ku wa gatatu", "Ku wa kane", "Ku wa gatanu", "Ku wa gatandatu"}, + periodsAbbreviated: []string{"Z.MU.", "Z.MW."}, + periodsWide: []string{"Z.MU.", "Z.MW."}, + erasAbbreviated: []string{"Mb.Y.", "Ny.Y"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbere ya Yezu", "Nyuma ya Yezu"}, + timezones: map[string]string{"GFT": "GFT", "UYT": "UYT", "CDT": "CDT", "BOT": "BOT", "IST": "IST", "MESZ": "MESZ", "CLST": "CLST", "UYST": "UYST", "HECU": "HECU", "VET": "VET", "CLT": "CLT", "MDT": "MDT", "EDT": "EDT", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "HEPMX": "HEPMX", "WIB": "WIB", "MEZ": "MEZ", "ACST": "ACST", "AKDT": "AKDT", "AKST": "AKST", "ChST": "ChST", "SAST": "SAST", "PST": "PST", "WART": "WART", "ADT": "ADT", "WEZ": "WEZ", "HEEG": "HEEG", "AEDT": "AEDT", "SRT": "SRT", "HNPMX": "HNPMX", "CST": "CST", "PDT": "PDT", "GMT": "GMT", "WARST": "WARST", "ART": "ART", "HKT": "HKT", "ACDT": "ACDT", "GYT": "GYT", "SGT": "SGT", "CAT": "CAT", "JDT": "JDT", "TMST": "TMST", "OESZ": "OESZ", "ARST": "ARST", "HKST": "HKST", "HNT": "HNT", "HEPM": "HEPM", "LHDT": "LHDT", "HADT": "HADT", "OEZ": "OEZ", "LHST": "LHST", "HNOG": "HNOG", "TMT": "TMT", "MST": "MST", "WAT": "WAT", "WITA": "WITA", "EAT": "EAT", "WIT": "WIT", "∅∅∅": "∅∅∅", "AEST": "AEST", "HNPM": "HNPM", "NZDT": "NZDT", "HEOG": "HEOG", "COT": "COT", "HNEG": "HNEG", "CHAST": "CHAST", "CHADT": "CHADT", "ACWST": "ACWST", "HAT": "HAT", "AWST": "AWST", "HAST": "HAST", "MYT": "MYT", "AST": "AST", "WAST": "WAST", "ECT": "ECT", "NZST": "NZST", "ACWDT": "ACWDT", "HNCU": "HNCU", "AWDT": "AWDT", "EST": "EST", "COST": "COST", "BT": "BT", "JST": "JST", "WESZ": "WESZ"}, + } +} + +// Locale returns the current translators string locale +func (rn *rn) Locale() string { + return rn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rn' +func (rn *rn) PluralsCardinal() []locales.PluralRule { + return rn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rn' +func (rn *rn) PluralsOrdinal() []locales.PluralRule { + return rn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rn' +func (rn *rn) PluralsRange() []locales.PluralRule { + return rn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rn' +func (rn *rn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rn' +func (rn *rn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rn' +func (rn *rn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rn *rn) MonthAbbreviated(month time.Month) string { + return rn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rn *rn) MonthsAbbreviated() []string { + return rn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rn *rn) MonthNarrow(month time.Month) string { + return rn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rn *rn) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rn *rn) MonthWide(month time.Month) string { + return rn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rn *rn) MonthsWide() []string { + return rn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rn *rn) WeekdayAbbreviated(weekday time.Weekday) string { + return rn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rn *rn) WeekdaysAbbreviated() []string { + return rn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rn *rn) WeekdayNarrow(weekday time.Weekday) string { + return rn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rn *rn) WeekdaysNarrow() []string { + return rn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rn *rn) WeekdayShort(weekday time.Weekday) string { + return rn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rn *rn) WeekdaysShort() []string { + return rn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rn *rn) WeekdayWide(weekday time.Weekday) string { + return rn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rn *rn) WeekdaysWide() []string { + return rn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rn' and handles both Whole and Real numbers based on 'v' +func (rn *rn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rn *rn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, rn.percentSuffix...) + + b = append(b, rn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rn' +func (rn *rn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rn.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rn' +// in accounting notation. +func (rn *rn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rn.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, rn.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rn' +func (rn *rn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rn' +func (rn *rn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rn' +func (rn *rn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rn' +func (rn *rn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, rn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rn' +func (rn *rn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rn' +func (rn *rn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rn' +func (rn *rn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rn' +func (rn *rn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rn/rn_test.go b/vendor/github.com/go-playground/locales/rn/rn_test.go new file mode 100644 index 0000000000..f722624b61 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rn/rn_test.go @@ -0,0 +1,1120 @@ +package rn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rn_BI/rn_BI.go b/vendor/github.com/go-playground/locales/rn_BI/rn_BI.go new file mode 100644 index 0000000000..a02587ed93 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rn_BI/rn_BI.go @@ -0,0 +1,559 @@ +package rn_BI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rn_BI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rn_BI' locale +func New() locales.Translator { + return &rn_BI{ + locale: "rn_BI", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "Mut.", "Gas.", "Wer.", "Mat.", "Gic.", "Kam.", "Nya.", "Kan.", "Nze.", "Ukw.", "Ugu.", "Uku."}, + monthsWide: []string{"", "Nzero", "Ruhuhuma", "Ntwarante", "Ndamukiza", "Rusama", "Ruheshi", "Mukakaro", "Nyandagaro", "Nyakanga", "Gitugutu", "Munyonyo", "Kigarama"}, + daysAbbreviated: []string{"cu.", "mbe.", "kab.", "gtu.", "kan.", "gnu.", "gnd."}, + daysWide: []string{"Ku w’indwi", "Ku wa mbere", "Ku wa kabiri", "Ku wa gatatu", "Ku wa kane", "Ku wa gatanu", "Ku wa gatandatu"}, + periodsAbbreviated: []string{"Z.MU.", "Z.MW."}, + periodsWide: []string{"Z.MU.", "Z.MW."}, + erasAbbreviated: []string{"Mb.Y.", "Ny.Y"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Mbere ya Yezu", "Nyuma ya Yezu"}, + timezones: map[string]string{"OEZ": "OEZ", "WEZ": "WEZ", "SAST": "SAST", "SRT": "SRT", "CAT": "CAT", "EDT": "EDT", "HAT": "HAT", "GFT": "GFT", "UYT": "UYT", "LHST": "LHST", "HNPMX": "HNPMX", "WIT": "WIT", "AWST": "AWST", "ACWDT": "ACWDT", "MESZ": "MESZ", "HNOG": "HNOG", "WESZ": "WESZ", "LHDT": "LHDT", "EAT": "EAT", "MEZ": "MEZ", "HNT": "HNT", "CDT": "CDT", "CHADT": "CHADT", "ACWST": "ACWST", "VET": "VET", "MST": "MST", "ARST": "ARST", "COT": "COT", "HENOMX": "HENOMX", "AEST": "AEST", "UYST": "UYST", "HNPM": "HNPM", "ECT": "ECT", "WART": "WART", "TMT": "TMT", "ACST": "ACST", "BT": "BT", "HNCU": "HNCU", "IST": "IST", "HEOG": "HEOG", "CLT": "CLT", "CLST": "CLST", "HNNOMX": "HNNOMX", "HNEG": "HNEG", "GYT": "GYT", "SGT": "SGT", "AST": "AST", "AKDT": "AKDT", "CST": "CST", "PDT": "PDT", "COST": "COST", "HEEG": "HEEG", "HEPMX": "HEPMX", "CHAST": "CHAST", "PST": "PST", "AKST": "AKST", "HECU": "HECU", "EST": "EST", "JST": "JST", "WARST": "WARST", "MDT": "MDT", "HKST": "HKST", "ACDT": "ACDT", "HAST": "HAST", "HADT": "HADT", "OESZ": "OESZ", "GMT": "GMT", "ART": "ART", "AEDT": "AEDT", "WIB": "WIB", "BOT": "BOT", "MYT": "MYT", "HKT": "HKT", "∅∅∅": "∅∅∅", "HEPM": "HEPM", "AWDT": "AWDT", "NZST": "NZST", "NZDT": "NZDT", "JDT": "JDT", "ADT": "ADT", "TMST": "TMST", "WAT": "WAT", "WAST": "WAST", "WITA": "WITA", "ChST": "ChST"}, + } +} + +// Locale returns the current translators string locale +func (rn *rn_BI) Locale() string { + return rn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rn_BI' +func (rn *rn_BI) PluralsCardinal() []locales.PluralRule { + return rn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rn_BI' +func (rn *rn_BI) PluralsOrdinal() []locales.PluralRule { + return rn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rn_BI' +func (rn *rn_BI) PluralsRange() []locales.PluralRule { + return rn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rn_BI' +func (rn *rn_BI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rn_BI' +func (rn *rn_BI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rn_BI' +func (rn *rn_BI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rn *rn_BI) MonthAbbreviated(month time.Month) string { + return rn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rn *rn_BI) MonthsAbbreviated() []string { + return rn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rn *rn_BI) MonthNarrow(month time.Month) string { + return rn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rn *rn_BI) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rn *rn_BI) MonthWide(month time.Month) string { + return rn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rn *rn_BI) MonthsWide() []string { + return rn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rn *rn_BI) WeekdayAbbreviated(weekday time.Weekday) string { + return rn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rn *rn_BI) WeekdaysAbbreviated() []string { + return rn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rn *rn_BI) WeekdayNarrow(weekday time.Weekday) string { + return rn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rn *rn_BI) WeekdaysNarrow() []string { + return rn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rn *rn_BI) WeekdayShort(weekday time.Weekday) string { + return rn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rn *rn_BI) WeekdaysShort() []string { + return rn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rn *rn_BI) WeekdayWide(weekday time.Weekday) string { + return rn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rn *rn_BI) WeekdaysWide() []string { + return rn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rn_BI' and handles both Whole and Real numbers based on 'v' +func (rn *rn_BI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rn_BI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rn *rn_BI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, rn.percentSuffix...) + + b = append(b, rn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rn_BI' +func (rn *rn_BI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rn.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rn_BI' +// in accounting notation. +func (rn *rn_BI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rn.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, rn.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rn_BI' +func (rn *rn_BI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rn_BI' +func (rn *rn_BI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rn_BI' +func (rn *rn_BI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rn_BI' +func (rn *rn_BI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, rn.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rn_BI' +func (rn *rn_BI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rn_BI' +func (rn *rn_BI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rn_BI' +func (rn *rn_BI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rn_BI' +func (rn *rn_BI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rn_BI/rn_BI_test.go b/vendor/github.com/go-playground/locales/rn_BI/rn_BI_test.go new file mode 100644 index 0000000000..d7ca1bc329 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rn_BI/rn_BI_test.go @@ -0,0 +1,1120 @@ +package rn_BI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rn_BI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ro/ro.go b/vendor/github.com/go-playground/locales/ro/ro.go new file mode 100644 index 0000000000..b851f984cf --- /dev/null +++ b/vendor/github.com/go-playground/locales/ro/ro.go @@ -0,0 +1,624 @@ +package ro + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ro struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ro' locale +func New() locales.Translator { + return &ro{ + locale: "ro", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "ian.", "feb.", "mar.", "apr.", "mai", "iun.", "iul.", "aug.", "sept.", "oct.", "nov.", "dec."}, + monthsNarrow: []string{"", "I", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"}, + daysAbbreviated: []string{"dum.", "lun.", "mar.", "mie.", "joi", "vin.", "sâm."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"du.", "lu.", "ma.", "mi.", "joi", "vi.", "sâ."}, + daysWide: []string{"duminică", "luni", "marți", "miercuri", "joi", "vineri", "sâmbătă"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"î.Hr.", "d.Hr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"înainte de Hristos", "după Hristos"}, + timezones: map[string]string{"WEZ": "Ora standard a Europei de Vest", "GMT": "Ora de Greenwhich", "MST": "MST", "SAST": "Ora Africii Meridionale", "CST": "Ora standard centrală nord-americană", "AST": "Ora standard în zona Atlantic nord-americană", "CAT": "Ora Africii Centrale", "ADT": "Ora de vară în zona Atlantic nord-americană", "ACDT": "Ora de vară a Australiei Centrale", "SRT": "Ora Surinamului", "SGT": "Ora din Singapore", "HAST": "Ora standard din Hawaii-Aleutine", "PDT": "Ora de vară în zona Pacific nord-americană", "HAT": "Ora de vară din Newfoundland", "HNEG": "Ora standard a Groenlandei orientale", "HNPM": "Ora standard din Saint-Pierre și Miquelon", "HECU": "Ora de vară a Cubei", "∅∅∅": "Ora de vară a Brasiliei", "HNT": "Ora standard din Newfoundland", "ChST": "Ora din Chamorro", "LHST": "Ora standard din Lord Howe", "NZST": "Ora standard a Noii Zeelande", "TMT": "Ora standard din Turkmenistan", "WESZ": "Ora de vară a Europei de Vest", "WAT": "Ora standard a Africii Occidentale", "WITA": "Ora Indoneziei Centrale", "EAT": "Ora Africii Orientale", "CHADT": "Ora de vară din Chatham", "MYT": "Ora din Malaysia", "HKST": "Ora de vară din Hong Kong", "LHDT": "Ora de vară din Lord Howe", "MEZ": "Ora standard a Europei Centrale", "CLT": "Ora standard din Chile", "HNNOMX": "Ora standard a Mexicului de nord-vest", "AEDT": "Ora de vară a Australiei Orientale", "CHAST": "Ora standard din Chatham", "WAST": "Ora de vară a Africii Occidentale", "AKST": "Ora standard din Alaska", "WIB": "Ora Indoneziei de Vest", "ARST": "Ora de vară a Argentinei", "JST": "Ora standard a Japoniei", "JDT": "Ora de vară a Japoniei", "TMST": "Ora de vară din Turkmenistan", "MDT": "MDT", "GFT": "Ora din Guyana Franceză", "GYT": "Ora din Guyana", "ACWST": "Ora standard a Australiei Central Occidentale", "ACWDT": "Ora de vară a Australiei Central Occidentale", "IST": "Ora Indiei", "HKT": "Ora standard din Hong Kong", "COST": "Ora de vară a Columbiei", "HENOMX": "Ora de vară a Mexicului de nord-vest", "BT": "Ora Bhutanului", "HNCU": "Ora standard a Cubei", "HEOG": "Ora de vară a Groenlandei occidentale", "OESZ": "Ora de vară a Europei de Est", "EDT": "Ora de vară orientală nord-americană", "WIT": "Ora Indoneziei de Est", "WART": "Ora standard a Argentinei Occidentale", "ACST": "Ora standard a Australiei Centrale", "COT": "Ora standard a Columbiei", "HEEG": "Ora de vară a Groenlandei orientale", "HEPM": "Ora de vară din Saint-Pierre și Miquelon", "HEPMX": "Ora de vară a zonei Pacific mexicane", "BOT": "Ora Boliviei", "ART": "Ora standard a Argentinei", "AEST": "Ora standard a Australiei Orientale", "UYST": "Ora de vară a Uruguayului", "CDT": "Ora de vară centrală nord-americană", "PST": "Ora standard în zona Pacific nord-americană", "HADT": "Ora de vară din Hawaii-Aleutine", "MESZ": "Ora de vară a Europei Centrale", "VET": "Ora Venezuelei", "EST": "Ora standard orientală nord-americană", "HNPMX": "Ora standard a zonei Pacific mexicane", "AWST": "Ora standard a Australiei Occidentale", "AWDT": "Ora de vară a Australiei Occidentale", "WARST": "Ora de vară a Argentinei Occidentale", "CLST": "Ora de vară din Chile", "HNOG": "Ora standard a Groenlandei occidentale", "OEZ": "Ora standard a Europei de Est", "AKDT": "Ora de vară din Alaska", "UYT": "Ora standard a Uruguayului", "ECT": "Ora Ecuadorului", "NZDT": "Ora de vară a Noii Zeelande"}, + } +} + +// Locale returns the current translators string locale +func (ro *ro) Locale() string { + return ro.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ro' +func (ro *ro) PluralsCardinal() []locales.PluralRule { + return ro.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ro' +func (ro *ro) PluralsOrdinal() []locales.PluralRule { + return ro.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ro' +func (ro *ro) PluralsRange() []locales.PluralRule { + return ro.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ro' +func (ro *ro) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + nMod100 := math.Mod(n, 100) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if (v != 0) || (n == 0) || (n != 1 && nMod100 >= 1 && nMod100 <= 19) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ro' +func (ro *ro) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ro' +func (ro *ro) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ro.CardinalPluralRule(num1, v1) + end := ro.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ro *ro) MonthAbbreviated(month time.Month) string { + return ro.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ro *ro) MonthsAbbreviated() []string { + return ro.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ro *ro) MonthNarrow(month time.Month) string { + return ro.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ro *ro) MonthsNarrow() []string { + return ro.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ro *ro) MonthWide(month time.Month) string { + return ro.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ro *ro) MonthsWide() []string { + return ro.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ro *ro) WeekdayAbbreviated(weekday time.Weekday) string { + return ro.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ro *ro) WeekdaysAbbreviated() []string { + return ro.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ro *ro) WeekdayNarrow(weekday time.Weekday) string { + return ro.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ro *ro) WeekdaysNarrow() []string { + return ro.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ro *ro) WeekdayShort(weekday time.Weekday) string { + return ro.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ro *ro) WeekdaysShort() []string { + return ro.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ro *ro) WeekdayWide(weekday time.Weekday) string { + return ro.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ro *ro) WeekdaysWide() []string { + return ro.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ro' and handles both Whole and Real numbers based on 'v' +func (ro *ro) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ro' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ro *ro) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ro.percentSuffix...) + + b = append(b, ro.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ro' +func (ro *ro) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ro.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ro.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ro.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ro' +// in accounting notation. +func (ro *ro) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ro.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ro.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ro.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ro.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ro.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ro' +func (ro *ro) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ro' +func (ro *ro) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ro' +func (ro *ro) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ro' +func (ro *ro) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ro.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ro' +func (ro *ro) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ro' +func (ro *ro) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ro' +func (ro *ro) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ro' +func (ro *ro) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ro.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ro/ro_test.go b/vendor/github.com/go-playground/locales/ro/ro_test.go new file mode 100644 index 0000000000..658f82a7cb --- /dev/null +++ b/vendor/github.com/go-playground/locales/ro/ro_test.go @@ -0,0 +1,1120 @@ +package ro + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ro" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ro_MD/ro_MD.go b/vendor/github.com/go-playground/locales/ro_MD/ro_MD.go new file mode 100644 index 0000000000..2b01290132 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ro_MD/ro_MD.go @@ -0,0 +1,624 @@ +package ro_MD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ro_MD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ro_MD' locale +func New() locales.Translator { + return &ro_MD{ + locale: "ro_MD", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "L", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "ian.", "feb.", "mar.", "apr.", "mai", "iun.", "iul.", "aug.", "sept.", "oct.", "nov.", "dec."}, + monthsNarrow: []string{"", "I", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"}, + daysAbbreviated: []string{"Dum", "Lun", "Mar", "Mie", "Joi", "Vin", "Sâm"}, + daysNarrow: []string{"D", "L", "Ma", "Mi", "J", "V", "S"}, + daysShort: []string{"Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sâ"}, + daysWide: []string{"duminică", "luni", "marți", "miercuri", "joi", "vineri", "sâmbătă"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"", ""}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"WESZ": "Ora de vară a Europei de Vest", "AEST": "Ora standard a Australiei Orientale", "HECU": "Ora de vară a Cubei", "CDT": "Ora de vară centrală nord-americană", "COST": "Ora de vară a Columbiei", "SGT": "Ora din Singapore", "ACWST": "Ora standard a Australiei Central Occidentale", "MESZ": "Ora de vară a Europei Centrale", "OEZ": "Ora standard a Europei de Est", "WIB": "Ora Indoneziei de Vest", "AEDT": "Ora de vară a Australiei Orientale", "MDT": "Ora de vară în zona montană nord-americană", "GFT": "Ora din Guyana Franceză", "LHST": "Ora standard din Lord Howe", "HNOG": "Ora standard a Groenlandei occidentale", "HENOMX": "Ora de vară a Mexicului de nord-vest", "HEPMX": "Ora de vară a zonei Pacific mexicane", "PST": "Ora standard în zona Pacific nord-americană", "GMT": "Ora de Greenwhich", "TMST": "Ora de vară din Turkmenistan", "UYST": "Ora de vară a Uruguayului", "HNNOMX": "Ora standard a Mexicului de nord-vest", "HEEG": "Ora de vară a Groenlandei orientale", "MST": "Ora standard în zona montană nord-americană", "NZST": "Ora standard a Noii Zeelande", "ACDT": "Ora de vară a Australiei Centrale", "HKT": "Ora standard din Hong Kong", "AKDT": "Ora de vară din Alaska", "HNPMX": "Ora standard a zonei Pacific mexicane", "HNCU": "Ora standard a Cubei", "PDT": "Ora de vară în zona Pacific nord-americană", "ECT": "Ora Ecuadorului", "WEZ": "Ora standard a Europei de Vest", "WAT": "Ora standard a Africii Occidentale", "ART": "Ora standard a Argentinei", "WARST": "Ora de vară a Argentinei Occidentale", "HNPM": "Ora standard din Saint-Pierre și Miquelon", "GYT": "Ora din Guyana", "JDT": "Ora de vară a Japoniei", "ADT": "Ora de vară în zona Atlantic nord-americană", "MYT": "Ora din Malaysia", "CLT": "Ora standard din Chile", "WITA": "Ora Indoneziei Centrale", "BOT": "Ora Boliviei", "HAST": "Ora standard din Hawaii-Aleutine", "HEOG": "Ora de vară a Groenlandei occidentale", "AST": "Ora standard în zona Atlantic nord-americană", "WART": "Ora standard a Argentinei Occidentale", "SRT": "Ora Surinamului", "CLST": "Ora de vară din Chile", "TMT": "Ora standard din Turkmenistan", "BT": "Ora Bhutanului", "HEPM": "Ora de vară din Saint-Pierre și Miquelon", "CHAST": "Ora standard din Chatham", "NZDT": "Ora de vară a Noii Zeelande", "JST": "Ora standard a Japoniei", "COT": "Ora standard a Columbiei", "EDT": "Ora de vară orientală nord-americană", "HKST": "Ora de vară din Hong Kong", "ACST": "Ora standard a Australiei Centrale", "LHDT": "Ora de vară din Lord Howe", "WIT": "Ora Indoneziei de Est", "AWST": "Ora standard a Australiei Occidentale", "AWDT": "Ora de vară a Australiei Occidentale", "EST": "Ora standard orientală nord-americană", "OESZ": "Ora de vară a Europei de Est", "CHADT": "Ora de vară din Chatham", "ChST": "Ora din Chamorro", "SAST": "Ora Africii Meridionale", "∅∅∅": "Ora de vară Acre", "UYT": "Ora standard a Uruguayului", "CST": "Ora standard centrală nord-americană", "CAT": "Ora Africii Centrale", "ACWDT": "Ora de vară a Australiei Central Occidentale", "MEZ": "Ora standard a Europei Centrale", "WAST": "Ora de vară a Africii Occidentale", "HNEG": "Ora standard a Groenlandei orientale", "EAT": "Ora Africii Orientale", "IST": "Ora Indiei", "VET": "Ora Venezuelei", "HAT": "Ora de vară din Newfoundland", "AKST": "Ora standard din Alaska", "HADT": "Ora de vară din Hawaii-Aleutine", "ARST": "Ora de vară a Argentinei", "HNT": "Ora standard din Newfoundland"}, + } +} + +// Locale returns the current translators string locale +func (ro *ro_MD) Locale() string { + return ro.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ro_MD' +func (ro *ro_MD) PluralsCardinal() []locales.PluralRule { + return ro.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ro_MD' +func (ro *ro_MD) PluralsOrdinal() []locales.PluralRule { + return ro.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ro_MD' +func (ro *ro_MD) PluralsRange() []locales.PluralRule { + return ro.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ro_MD' +func (ro *ro_MD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + nMod100 := math.Mod(n, 100) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if (v != 0) || (n == 0) || (n != 1 && nMod100 >= 1 && nMod100 <= 19) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ro_MD' +func (ro *ro_MD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ro_MD' +func (ro *ro_MD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ro.CardinalPluralRule(num1, v1) + end := ro.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ro *ro_MD) MonthAbbreviated(month time.Month) string { + return ro.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ro *ro_MD) MonthsAbbreviated() []string { + return ro.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ro *ro_MD) MonthNarrow(month time.Month) string { + return ro.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ro *ro_MD) MonthsNarrow() []string { + return ro.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ro *ro_MD) MonthWide(month time.Month) string { + return ro.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ro *ro_MD) MonthsWide() []string { + return ro.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ro *ro_MD) WeekdayAbbreviated(weekday time.Weekday) string { + return ro.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ro *ro_MD) WeekdaysAbbreviated() []string { + return ro.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ro *ro_MD) WeekdayNarrow(weekday time.Weekday) string { + return ro.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ro *ro_MD) WeekdaysNarrow() []string { + return ro.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ro *ro_MD) WeekdayShort(weekday time.Weekday) string { + return ro.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ro *ro_MD) WeekdaysShort() []string { + return ro.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ro *ro_MD) WeekdayWide(weekday time.Weekday) string { + return ro.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ro *ro_MD) WeekdaysWide() []string { + return ro.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ro_MD' and handles both Whole and Real numbers based on 'v' +func (ro *ro_MD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ro_MD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ro *ro_MD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ro.percentSuffix...) + + b = append(b, ro.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ro_MD' +func (ro *ro_MD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ro.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ro.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ro.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ro_MD' +// in accounting notation. +func (ro *ro_MD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ro.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ro.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ro.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ro.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ro.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ro_MD' +func (ro *ro_MD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ro_MD' +func (ro *ro_MD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ro_MD' +func (ro *ro_MD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ro_MD' +func (ro *ro_MD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ro.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ro_MD' +func (ro *ro_MD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ro_MD' +func (ro *ro_MD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ro_MD' +func (ro *ro_MD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ro_MD' +func (ro *ro_MD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ro.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ro_MD/ro_MD_test.go b/vendor/github.com/go-playground/locales/ro_MD/ro_MD_test.go new file mode 100644 index 0000000000..40b766f807 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ro_MD/ro_MD_test.go @@ -0,0 +1,1120 @@ +package ro_MD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ro_MD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ro_RO/ro_RO.go b/vendor/github.com/go-playground/locales/ro_RO/ro_RO.go new file mode 100644 index 0000000000..1ae87c2b51 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ro_RO/ro_RO.go @@ -0,0 +1,624 @@ +package ro_RO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ro_RO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ro_RO' locale +func New() locales.Translator { + return &ro_RO{ + locale: "ro_RO", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "ian.", "feb.", "mar.", "apr.", "mai", "iun.", "iul.", "aug.", "sept.", "oct.", "nov.", "dec."}, + monthsNarrow: []string{"", "I", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"}, + daysAbbreviated: []string{"dum.", "lun.", "mar.", "mie.", "joi", "vin.", "sâm."}, + daysNarrow: []string{"D", "L", "M", "M", "J", "V", "S"}, + daysShort: []string{"du.", "lu.", "ma.", "mi.", "joi", "vi.", "sâ."}, + daysWide: []string{"duminică", "luni", "marți", "miercuri", "joi", "vineri", "sâmbătă"}, + periodsAbbreviated: []string{"a.m.", "p.m."}, + periodsNarrow: []string{"a.m.", "p.m."}, + periodsWide: []string{"a.m.", "p.m."}, + erasAbbreviated: []string{"î.Hr.", "d.Hr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"înainte de Hristos", "după Hristos"}, + timezones: map[string]string{"HAT": "Ora de vară din Newfoundland", "GFT": "Ora din Guyana Franceză", "ACWST": "Ora standard a Australiei Central Occidentale", "TMT": "Ora standard din Turkmenistan", "TMST": "Ora de vară din Turkmenistan", "WAT": "Ora standard a Africii Occidentale", "COT": "Ora standard a Columbiei", "HNEG": "Ora standard a Groenlandei orientale", "SGT": "Ora din Singapore", "NZST": "Ora standard a Noii Zeelande", "VET": "Ora Venezuelei", "EST": "Ora standard orientală nord-americană", "UYT": "Ora standard a Uruguayului", "AWST": "Ora standard a Australiei Occidentale", "AWDT": "Ora de vară a Australiei Occidentale", "CHAST": "Ora standard din Chatham", "CLST": "Ora de vară din Chile", "HKT": "Ora standard din Hong Kong", "HAST": "Ora standard din Hawaii-Aleutine", "CAT": "Ora Africii Centrale", "JST": "Ora standard a Japoniei", "ChST": "Ora din Chamorro", "CST": "Ora standard centrală nord-americană", "ACWDT": "Ora de vară a Australiei Central Occidentale", "CLT": "Ora standard din Chile", "ADT": "Ora de vară în zona Atlantic nord-americană", "OEZ": "Ora standard a Europei de Est", "ARST": "Ora de vară a Argentinei", "HNNOMX": "Ora standard a Mexicului de nord-vest", "WART": "Ora standard a Argentinei Occidentale", "HEOG": "Ora de vară a Groenlandei occidentale", "MEZ": "Ora standard a Europei Centrale", "MST": "MST", "ACDT": "Ora de vară a Australiei Centrale", "HEEG": "Ora de vară a Groenlandei orientale", "HEPM": "Ora de vară din Saint-Pierre și Miquelon", "HECU": "Ora de vară a Cubei", "WEZ": "Ora standard a Europei de Vest", "AEDT": "Ora de vară a Australiei Orientale", "SRT": "Ora Surinamului", "BOT": "Ora Boliviei", "HADT": "Ora de vară din Hawaii-Aleutine", "WAST": "Ora de vară a Africii Occidentale", "∅∅∅": "Ora de vară Acre", "WITA": "Ora Indoneziei Centrale", "WIB": "Ora Indoneziei de Vest", "WIT": "Ora Indoneziei de Est", "COST": "Ora de vară a Columbiei", "HNPMX": "Ora standard a zonei Pacific mexicane", "LHST": "Ora standard din Lord Howe", "HNCU": "Ora standard a Cubei", "OESZ": "Ora de vară a Europei de Est", "EDT": "Ora de vară orientală nord-americană", "CDT": "Ora de vară centrală nord-americană", "BT": "Ora Bhutanului", "HNT": "Ora standard din Newfoundland", "NZDT": "Ora de vară a Noii Zeelande", "MYT": "Ora din Malaysia", "WARST": "Ora de vară a Argentinei Occidentale", "HNOG": "Ora standard a Groenlandei occidentale", "MDT": "MDT", "ART": "Ora standard a Argentinei", "JDT": "Ora de vară a Japoniei", "GMT": "Ora de Greenwhich", "AEST": "Ora standard a Australiei Orientale", "AKST": "Ora standard din Alaska", "LHDT": "Ora de vară din Lord Howe", "GYT": "Ora din Guyana", "AKDT": "Ora de vară din Alaska", "UYST": "Ora de vară a Uruguayului", "EAT": "Ora Africii Orientale", "ECT": "Ora Ecuadorului", "HENOMX": "Ora de vară a Mexicului de nord-vest", "ACST": "Ora standard a Australiei Centrale", "HNPM": "Ora standard din Saint-Pierre și Miquelon", "SAST": "Ora Africii Meridionale", "PST": "Ora standard în zona Pacific nord-americană", "PDT": "Ora de vară în zona Pacific nord-americană", "IST": "Ora Indiei", "MESZ": "Ora de vară a Europei Centrale", "WESZ": "Ora de vară a Europei de Vest", "AST": "Ora standard în zona Atlantic nord-americană", "HKST": "Ora de vară din Hong Kong", "HEPMX": "Ora de vară a zonei Pacific mexicane", "CHADT": "Ora de vară din Chatham"}, + } +} + +// Locale returns the current translators string locale +func (ro *ro_RO) Locale() string { + return ro.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ro_RO' +func (ro *ro_RO) PluralsCardinal() []locales.PluralRule { + return ro.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ro_RO' +func (ro *ro_RO) PluralsOrdinal() []locales.PluralRule { + return ro.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ro_RO' +func (ro *ro_RO) PluralsRange() []locales.PluralRule { + return ro.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ro_RO' +func (ro *ro_RO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + nMod100 := math.Mod(n, 100) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if (v != 0) || (n == 0) || (n != 1 && nMod100 >= 1 && nMod100 <= 19) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ro_RO' +func (ro *ro_RO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ro_RO' +func (ro *ro_RO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ro.CardinalPluralRule(num1, v1) + end := ro.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ro *ro_RO) MonthAbbreviated(month time.Month) string { + return ro.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ro *ro_RO) MonthsAbbreviated() []string { + return ro.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ro *ro_RO) MonthNarrow(month time.Month) string { + return ro.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ro *ro_RO) MonthsNarrow() []string { + return ro.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ro *ro_RO) MonthWide(month time.Month) string { + return ro.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ro *ro_RO) MonthsWide() []string { + return ro.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ro *ro_RO) WeekdayAbbreviated(weekday time.Weekday) string { + return ro.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ro *ro_RO) WeekdaysAbbreviated() []string { + return ro.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ro *ro_RO) WeekdayNarrow(weekday time.Weekday) string { + return ro.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ro *ro_RO) WeekdaysNarrow() []string { + return ro.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ro *ro_RO) WeekdayShort(weekday time.Weekday) string { + return ro.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ro *ro_RO) WeekdaysShort() []string { + return ro.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ro *ro_RO) WeekdayWide(weekday time.Weekday) string { + return ro.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ro *ro_RO) WeekdaysWide() []string { + return ro.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ro_RO' and handles both Whole and Real numbers based on 'v' +func (ro *ro_RO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ro_RO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ro *ro_RO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ro.percentSuffix...) + + b = append(b, ro.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ro_RO' +func (ro *ro_RO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ro.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ro.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ro.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ro.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ro_RO' +// in accounting notation. +func (ro *ro_RO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ro.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ro.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ro.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ro.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ro.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ro.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ro.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ro_RO' +func (ro *ro_RO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ro_RO' +func (ro *ro_RO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ro_RO' +func (ro *ro_RO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ro_RO' +func (ro *ro_RO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ro.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ro.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ro_RO' +func (ro *ro_RO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ro_RO' +func (ro *ro_RO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ro_RO' +func (ro *ro_RO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ro_RO' +func (ro *ro_RO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ro.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ro.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ro.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ro_RO/ro_RO_test.go b/vendor/github.com/go-playground/locales/ro_RO/ro_RO_test.go new file mode 100644 index 0000000000..a914c7ab55 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ro_RO/ro_RO_test.go @@ -0,0 +1,1120 @@ +package ro_RO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ro_RO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rof/rof.go b/vendor/github.com/go-playground/locales/rof/rof.go new file mode 100644 index 0000000000..99d8d98e41 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rof/rof.go @@ -0,0 +1,517 @@ +package rof + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rof struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rof' locale +func New() locales.Translator { + return &rof{ + locale: "rof", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12"}, + monthsNarrow: []string{"", "K", "K", "K", "K", "T", "S", "S", "N", "T", "I", "I", "I"}, + monthsWide: []string{"", "Mweri wa kwanza", "Mweri wa kaili", "Mweri wa katatu", "Mweri wa kaana", "Mweri wa tanu", "Mweri wa sita", "Mweri wa saba", "Mweri wa nane", "Mweri wa tisa", "Mweri wa ikumi", "Mweri wa ikumi na moja", "Mweri wa ikumi na mbili"}, + daysAbbreviated: []string{"Ijp", "Ijt", "Ijn", "Ijtn", "Alh", "Iju", "Ijm"}, + daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"}, + daysWide: []string{"Ijumapili", "Ijumatatu", "Ijumanne", "Ijumatano", "Alhamisi", "Ijumaa", "Ijumamosi"}, + periodsAbbreviated: []string{"kang’ama", "kingoto"}, + periodsWide: []string{"kang’ama", "kingoto"}, + erasAbbreviated: []string{"KM", "BM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Mayesu", "Baada ya Mayesu"}, + timezones: map[string]string{"HEOG": "HEOG", "EDT": "EDT", "HECU": "HECU", "HAST": "HAST", "SGT": "SGT", "UYT": "UYT", "COT": "COT", "AEST": "AEST", "GYT": "GYT", "HKT": "HKT", "HAT": "HAT", "ADT": "ADT", "HNT": "HNT", "AEDT": "AEDT", "ChST": "ChST", "ACWDT": "ACWDT", "MDT": "MDT", "NZST": "NZST", "CLT": "CLT", "HEEG": "HEEG", "UYST": "UYST", "SAST": "SAST", "HNPMX": "HNPMX", "HNCU": "HNCU", "CHADT": "CHADT", "JDT": "JDT", "HNOG": "HNOG", "TMT": "TMT", "HKST": "HKST", "ACDT": "ACDT", "GFT": "GFT", "IST": "IST", "VET": "VET", "AKDT": "AKDT", "GMT": "GMT", "CST": "CST", "WESZ": "WESZ", "TMST": "TMST", "WAT": "WAT", "HNPM": "HNPM", "BOT": "BOT", "ACWST": "ACWST", "NZDT": "NZDT", "MEZ": "MEZ", "OESZ": "OESZ", "WIB": "WIB", "ECT": "ECT", "ART": "ART", "ARST": "ARST", "ACST": "ACST", "BT": "BT", "WITA": "WITA", "LHDT": "LHDT", "WEZ": "WEZ", "MST": "MST", "AWST": "AWST", "HADT": "HADT", "MYT": "MYT", "EAT": "EAT", "WIT": "WIT", "MESZ": "MESZ", "WART": "WART", "OEZ": "OEZ", "COST": "COST", "HNEG": "HNEG", "AKST": "AKST", "AWDT": "AWDT", "CHAST": "CHAST", "HEPM": "HEPM", "LHST": "LHST", "CAT": "CAT", "JST": "JST", "PST": "PST", "PDT": "PDT", "WARST": "WARST", "HNNOMX": "HNNOMX", "SRT": "SRT", "CDT": "CDT", "∅∅∅": "∅∅∅", "WAST": "WAST", "EST": "EST", "HENOMX": "HENOMX", "HEPMX": "HEPMX", "CLST": "CLST", "AST": "AST"}, + } +} + +// Locale returns the current translators string locale +func (rof *rof) Locale() string { + return rof.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rof' +func (rof *rof) PluralsCardinal() []locales.PluralRule { + return rof.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rof' +func (rof *rof) PluralsOrdinal() []locales.PluralRule { + return rof.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rof' +func (rof *rof) PluralsRange() []locales.PluralRule { + return rof.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rof' +func (rof *rof) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rof' +func (rof *rof) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rof' +func (rof *rof) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rof *rof) MonthAbbreviated(month time.Month) string { + return rof.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rof *rof) MonthsAbbreviated() []string { + return rof.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rof *rof) MonthNarrow(month time.Month) string { + return rof.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rof *rof) MonthsNarrow() []string { + return rof.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rof *rof) MonthWide(month time.Month) string { + return rof.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rof *rof) MonthsWide() []string { + return rof.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rof *rof) WeekdayAbbreviated(weekday time.Weekday) string { + return rof.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rof *rof) WeekdaysAbbreviated() []string { + return rof.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rof *rof) WeekdayNarrow(weekday time.Weekday) string { + return rof.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rof *rof) WeekdaysNarrow() []string { + return rof.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rof *rof) WeekdayShort(weekday time.Weekday) string { + return rof.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rof *rof) WeekdaysShort() []string { + return rof.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rof *rof) WeekdayWide(weekday time.Weekday) string { + return rof.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rof *rof) WeekdaysWide() []string { + return rof.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rof' and handles both Whole and Real numbers based on 'v' +func (rof *rof) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rof' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rof *rof) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rof' +func (rof *rof) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rof.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rof.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rof.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, rof.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rof.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rof' +// in accounting notation. +func (rof *rof) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rof.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rof.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rof.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, rof.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rof.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rof' +func (rof *rof) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rof' +func (rof *rof) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rof.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rof' +func (rof *rof) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rof.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rof' +func (rof *rof) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, rof.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rof.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rof' +func (rof *rof) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rof.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rof' +func (rof *rof) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rof.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rof.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rof' +func (rof *rof) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rof.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rof.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rof' +func (rof *rof) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rof.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rof.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rof.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rof/rof_test.go b/vendor/github.com/go-playground/locales/rof/rof_test.go new file mode 100644 index 0000000000..2dbf16d210 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rof/rof_test.go @@ -0,0 +1,1120 @@ +package rof + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rof" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rof_TZ/rof_TZ.go b/vendor/github.com/go-playground/locales/rof_TZ/rof_TZ.go new file mode 100644 index 0000000000..b21c18ecdb --- /dev/null +++ b/vendor/github.com/go-playground/locales/rof_TZ/rof_TZ.go @@ -0,0 +1,517 @@ +package rof_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rof_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rof_TZ' locale +func New() locales.Translator { + return &rof_TZ{ + locale: "rof_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12"}, + monthsNarrow: []string{"", "K", "K", "K", "K", "T", "S", "S", "N", "T", "I", "I", "I"}, + monthsWide: []string{"", "Mweri wa kwanza", "Mweri wa kaili", "Mweri wa katatu", "Mweri wa kaana", "Mweri wa tanu", "Mweri wa sita", "Mweri wa saba", "Mweri wa nane", "Mweri wa tisa", "Mweri wa ikumi", "Mweri wa ikumi na moja", "Mweri wa ikumi na mbili"}, + daysAbbreviated: []string{"Ijp", "Ijt", "Ijn", "Ijtn", "Alh", "Iju", "Ijm"}, + daysNarrow: []string{"2", "3", "4", "5", "6", "7", "1"}, + daysWide: []string{"Ijumapili", "Ijumatatu", "Ijumanne", "Ijumatano", "Alhamisi", "Ijumaa", "Ijumamosi"}, + periodsAbbreviated: []string{"kang’ama", "kingoto"}, + periodsWide: []string{"kang’ama", "kingoto"}, + erasAbbreviated: []string{"KM", "BM"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Mayesu", "Baada ya Mayesu"}, + timezones: map[string]string{"WAT": "WAT", "EDT": "EDT", "AEST": "AEST", "WIB": "WIB", "HAST": "HAST", "VET": "VET", "HKT": "HKT", "SGT": "SGT", "PST": "PST", "NZST": "NZST", "CHAST": "CHAST", "HADT": "HADT", "CAT": "CAT", "MDT": "MDT", "HAT": "HAT", "AEDT": "AEDT", "EAT": "EAT", "WARST": "WARST", "ACST": "ACST", "AKST": "AKST", "UYST": "UYST", "IST": "IST", "CLT": "CLT", "ADT": "ADT", "OEZ": "OEZ", "ART": "ART", "EST": "EST", "COST": "COST", "HEPM": "HEPM", "AWST": "AWST", "MYT": "MYT", "HNOG": "HNOG", "MST": "MST", "PDT": "PDT", "JST": "JST", "OESZ": "OESZ", "ACWDT": "ACWDT", "HNEG": "HNEG", "WITA": "WITA", "SRT": "SRT", "LHDT": "LHDT", "CST": "CST", "BOT": "BOT", "ACWST": "ACWST", "WART": "WART", "HNPM": "HNPM", "GYT": "GYT", "HECU": "HECU", "JDT": "JDT", "AST": "AST", "WESZ": "WESZ", "BT": "BT", "AKDT": "AKDT", "ChST": "ChST", "GMT": "GMT", "ECT": "ECT", "ACDT": "ACDT", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "HNT": "HNT", "GFT": "GFT", "HNPMX": "HNPMX", "AWDT": "AWDT", "HEOG": "HEOG", "TMST": "TMST", "ARST": "ARST", "CHADT": "CHADT", "NZDT": "NZDT", "MESZ": "MESZ", "CLST": "CLST", "HKST": "HKST", "SAST": "SAST", "LHST": "LHST", "WEZ": "WEZ", "WAST": "WAST", "COT": "COT", "HEEG": "HEEG", "HEPMX": "HEPMX", "HNNOMX": "HNNOMX", "UYT": "UYT", "HNCU": "HNCU", "CDT": "CDT", "WIT": "WIT", "MEZ": "MEZ", "TMT": "TMT"}, + } +} + +// Locale returns the current translators string locale +func (rof *rof_TZ) Locale() string { + return rof.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rof_TZ' +func (rof *rof_TZ) PluralsCardinal() []locales.PluralRule { + return rof.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rof_TZ' +func (rof *rof_TZ) PluralsOrdinal() []locales.PluralRule { + return rof.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rof_TZ' +func (rof *rof_TZ) PluralsRange() []locales.PluralRule { + return rof.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rof_TZ' +func (rof *rof_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rof_TZ' +func (rof *rof_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rof_TZ' +func (rof *rof_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rof *rof_TZ) MonthAbbreviated(month time.Month) string { + return rof.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rof *rof_TZ) MonthsAbbreviated() []string { + return rof.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rof *rof_TZ) MonthNarrow(month time.Month) string { + return rof.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rof *rof_TZ) MonthsNarrow() []string { + return rof.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rof *rof_TZ) MonthWide(month time.Month) string { + return rof.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rof *rof_TZ) MonthsWide() []string { + return rof.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rof *rof_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return rof.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rof *rof_TZ) WeekdaysAbbreviated() []string { + return rof.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rof *rof_TZ) WeekdayNarrow(weekday time.Weekday) string { + return rof.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rof *rof_TZ) WeekdaysNarrow() []string { + return rof.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rof *rof_TZ) WeekdayShort(weekday time.Weekday) string { + return rof.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rof *rof_TZ) WeekdaysShort() []string { + return rof.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rof *rof_TZ) WeekdayWide(weekday time.Weekday) string { + return rof.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rof *rof_TZ) WeekdaysWide() []string { + return rof.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rof_TZ' and handles both Whole and Real numbers based on 'v' +func (rof *rof_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rof_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rof *rof_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rof_TZ' +func (rof *rof_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rof.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rof.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rof.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, rof.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rof.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rof_TZ' +// in accounting notation. +func (rof *rof_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rof.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rof.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rof.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, rof.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rof.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rof_TZ' +func (rof *rof_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rof_TZ' +func (rof *rof_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rof.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rof_TZ' +func (rof *rof_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rof.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rof_TZ' +func (rof *rof_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, rof.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rof.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rof_TZ' +func (rof *rof_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rof.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rof_TZ' +func (rof *rof_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rof.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rof.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rof_TZ' +func (rof *rof_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rof.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rof.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rof_TZ' +func (rof *rof_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rof.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rof.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rof.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rof_TZ/rof_TZ_test.go b/vendor/github.com/go-playground/locales/rof_TZ/rof_TZ_test.go new file mode 100644 index 0000000000..9e52d50c05 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rof_TZ/rof_TZ_test.go @@ -0,0 +1,1120 @@ +package rof_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rof_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/root/root.go b/vendor/github.com/go-playground/locales/root/root.go new file mode 100644 index 0000000000..ed27465b13 --- /dev/null +++ b/vendor/github.com/go-playground/locales/root/root.go @@ -0,0 +1,410 @@ +package root + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type root struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'root' locale +func New() locales.Translator { + return &root{ + locale: "root", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "Kz", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "$", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "KM", "BAN", "$", "৳", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "$", "$", "Bs", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "$", "BTN", "BUK", "P", "BYB", "р.", "BYR", "$", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "$", "CNX", "CN¥", "$", "COU", "₡", "CSD", "CSK", "$", "$", "CVE", "CYP", "Kč", "DDM", "DEM", "DJF", "kr", "$", "DZD", "ECS", "ECV", "EEK", "E£", "ERN", "ESA", "ESB", "₧", "ETB", "€", "FIM", "$", "£", "FRF", "£", "GEK", "₾", "GHC", "GHS", "£", "GMD", "FG", "GNS", "GQE", "GRD", "Q", "GWE", "GWP", "$", "HK$", "L", "HRD", "kn", "HTG", "Ft", "Rp", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "kr", "ITL", "$", "JOD", "JP¥", "KES", "KGS", "៛", "CF", "₩", "KRH", "KRO", "₩", "KWD", "$", "₸", "₭", "L£", "Rs", "$", "LSL", "Lt", "LTT", "LUC", "LUF", "LUL", "Ls", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "Ar", "MGF", "MKD", "MKN", "MLF", "K", "₮", "MOP", "MRO", "MTL", "MTP", "Rs", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "RM", "MZE", "MZM", "MZN", "$", "₦", "NIC", "C$", "NLG", "kr", "Rs", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "₱", "Rs", "zł", "PLZ", "PTE", "₲", "QAR", "RHD", "ROL", "lei", "RSD", "₽", "р.", "RF", "SAR", "$", "SCR", "SDD", "SDG", "SDP", "kr", "$", "£", "SIT", "SKK", "SLL", "SOS", "$", "SRG", "£", "Db", "SUR", "SVC", "£", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "T$", "TPE", "TRL", "₺", "$", "NT$", "TZS", "₴", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "$", "UZS", "VEB", "Bs", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "R", "ZMK", "ZK", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "M01", "M02", "M03", "M04", "M05", "M06", "M07", "M08", "M09", "M10", "M11", "M12"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysWide: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"", ""}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"UYST": "UYST", "SGT": "SGT", "HEOG": "HEOG", "OEZ": "OEZ", "ARST": "ARST", "ACDT": "ACDT", "AKST": "AKST", "CAT": "CAT", "HNCU": "HNCU", "CDT": "CDT", "BOT": "BOT", "ACST": "ACST", "COST": "COST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "UYT": "UYT", "MESZ": "MESZ", "CLT": "CLT", "ADT": "ADT", "HNPMX": "HNPMX", "WIT": "WIT", "IST": "IST", "WEZ": "WEZ", "WAT": "WAT", "JDT": "JDT", "OESZ": "OESZ", "WESZ": "WESZ", "COT": "COT", "BT": "BT", "HAT": "HAT", "AWST": "AWST", "CHADT": "CHADT", "HKT": "HKT", "AEDT": "AEDT", "ACWDT": "ACWDT", "NZDT": "NZDT", "TMT": "TMT", "TMST": "TMST", "ChST": "ChST", "HNPM": "HNPM", "HEPMX": "HEPMX", "MEZ": "MEZ", "HECU": "HECU", "SAST": "SAST", "WIB": "WIB", "EST": "EST", "CLST": "CLST", "AST": "AST", "CST": "CST", "PDT": "PDT", "NZST": "NZST", "HNEG": "HNEG", "HEEG": "HEEG", "AKDT": "AKDT", "AEST": "AEST", "GYT": "GYT", "HKST": "HKST", "MST": "MST", "HEPM": "HEPM", "ECT": "ECT", "ACWST": "ACWST", "MDT": "MDT", "PST": "PST", "JST": "JST", "WART": "WART", "WARST": "WARST", "HNOG": "HNOG", "GMT": "GMT", "ART": "ART", "GFT": "GFT", "WITA": "WITA", "SRT": "SRT", "CHAST": "CHAST", "HAST": "HAST", "EDT": "EDT", "∅∅∅": "∅∅∅", "EAT": "EAT", "HADT": "HADT", "MYT": "MYT", "WAST": "WAST", "HNT": "HNT", "LHST": "LHST", "LHDT": "LHDT", "AWDT": "AWDT", "VET": "VET"}, + } +} + +// Locale returns the current translators string locale +func (root *root) Locale() string { + return root.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'root' +func (root *root) PluralsCardinal() []locales.PluralRule { + return root.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'root' +func (root *root) PluralsOrdinal() []locales.PluralRule { + return root.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'root' +func (root *root) PluralsRange() []locales.PluralRule { + return root.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'root' +func (root *root) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'root' +func (root *root) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'root' +func (root *root) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (root *root) MonthAbbreviated(month time.Month) string { + return root.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (root *root) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (root *root) MonthNarrow(month time.Month) string { + return root.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (root *root) MonthsNarrow() []string { + return root.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (root *root) MonthWide(month time.Month) string { + return root.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (root *root) MonthsWide() []string { + return root.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (root *root) WeekdayAbbreviated(weekday time.Weekday) string { + return root.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (root *root) WeekdaysAbbreviated() []string { + return root.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (root *root) WeekdayNarrow(weekday time.Weekday) string { + return root.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (root *root) WeekdaysNarrow() []string { + return root.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (root *root) WeekdayShort(weekday time.Weekday) string { + return root.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (root *root) WeekdaysShort() []string { + return root.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (root *root) WeekdayWide(weekday time.Weekday) string { + return root.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (root *root) WeekdaysWide() []string { + return root.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'root' and handles both Whole and Real numbers based on 'v' +func (root *root) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'root' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (root *root) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'root' +func (root *root) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := root.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'root' +// in accounting notation. +func (root *root) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := root.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtDateShort returns the short date representation of 't' for 'root' +func (root *root) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'root' +func (root *root) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, root.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'root' +func (root *root) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, root.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'root' +func (root *root) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, root.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, root.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'root' +func (root *root) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, root.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'root' +func (root *root) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, root.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, root.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'root' +func (root *root) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, root.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, root.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'root' +func (root *root) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, root.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, root.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := root.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/root/root_test.go b/vendor/github.com/go-playground/locales/root/root_test.go new file mode 100644 index 0000000000..f4d0429d94 --- /dev/null +++ b/vendor/github.com/go-playground/locales/root/root_test.go @@ -0,0 +1,1120 @@ +package root + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "root" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ru/ru.go b/vendor/github.com/go-playground/locales/ru/ru.go new file mode 100644 index 0000000000..13430f3612 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru/ru.go @@ -0,0 +1,631 @@ +package ru + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ru struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ru' locale +func New() locales.Translator { + return &ru{ + locale: "ru", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "₽", "р.", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "ТМТ", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "₴", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "февр.", "мар.", "апр.", "мая", "июн.", "июл.", "авг.", "сент.", "окт.", "нояб.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"}, + daysAbbreviated: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysShort: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"}, + periodsAbbreviated: []string{"ДП", "ПП"}, + periodsNarrow: []string{"ДП", "ПП"}, + periodsWide: []string{"ДП", "ПП"}, + erasAbbreviated: []string{"до н. э.", "н. э."}, + erasNarrow: []string{"до н.э.", "н.э."}, + erasWide: []string{"до Рождества Христова", "от Рождества Христова"}, + timezones: map[string]string{"JDT": "Япония, летнее время", "UYT": "Уругвай, стандартное время", "JST": "Япония, стандартное время", "EST": "Восточная Америка, стандартное время", "EDT": "Восточная Америка, летнее время", "SRT": "Суринам", "AWST": "Западная Австралия, стандартное время", "NZST": "Новая Зеландия, стандартное время", "CLST": "Чили, летнее время", "ARST": "Аргентина, летнее время", "WAT": "Западная Африка, стандартное время", "ACST": "Центральная Австралия, стандартное время", "PST": "Тихоокеанское стандартное время", "PDT": "Тихоокеанское летнее время", "ACWST": "Центральная Австралия, западное стандартное время", "CLT": "Чили, стандартное время", "ADT": "Атлантическое летнее время", "MST": "Макао, стандартное время", "SAST": "Южная Африка", "EAT": "Восточная Африка", "CDT": "Центральная Америка, летнее время", "CHAST": "Чатем, стандартное время", "AKST": "Аляска, стандартное время", "AST": "Атлантическое стандартное время", "WESZ": "Западная Европа, летнее время", "GFT": "Французская Гвиана", "AKDT": "Аляска, летнее время", "UYST": "Уругвай, летнее время", "HNPM": "Сен-Пьер и Микелон, стандартное время", "LHST": "Лорд-Хау, стандартное время", "WART": "Западная Аргентина, стандартное время", "HEEG": "Восточная Гренландия, летнее время", "WEZ": "Западная Европа, стандартное время", "MYT": "Малайзия", "AEDT": "Восточная Австралия, летнее время", "CAT": "Центральная Африка", "HNOG": "Западная Гренландия, стандартное время", "WAST": "Западная Африка, летнее время", "MESZ": "Центральная Европа, летнее время", "GMT": "Среднее время по Гринвичу", "HAT": "Ньюфаундленд, летнее время", "HEPM": "Сен-Пьер и Микелон, летнее время", "WIB": "Западная Индонезия", "AWDT": "Западная Австралия, летнее время", "HNNOMX": "Северо-западное мексиканское стандартное время", "ART": "Аргентина, стандартное время", "HKST": "Гонконг, летнее время", "COT": "Колумбия, стандартное время", "HENOMX": "Северо-западное мексиканское летнее время", "AEST": "Восточная Австралия, стандартное время", "ECT": "Эквадор", "HAST": "Гавайско-алеутское стандартное время", "ACDT": "Центральная Австралия, летнее время", "HNT": "Ньюфаундленд, стандартное время", "ChST": "Чаморро", "LHDT": "Лорд-Хау, летнее время", "ACWDT": "Центральная Австралия, западное летнее время", "OEZ": "Восточная Европа, стандартное время", "∅∅∅": "Бразилия, летнее время", "IST": "Индия", "NZDT": "Новая Зеландия, летнее время", "MEZ": "Центральная Европа, стандартное время", "OESZ": "Восточная Европа, летнее время", "HNEG": "Восточная Гренландия, стандарное время", "CST": "Центральная Америка, стандартное время", "WIT": "Восточная Индонезия", "WITA": "Центральная Индонезия", "HECU": "Куба, летнее время", "HEPMX": "Тихоокеанское мексиканское летнее время", "SGT": "Сингапур", "TMT": "Туркмения, стандартное время", "VET": "Венесуэла", "COST": "Колумбия, летнее время", "HNPMX": "Тихоокеанское мексиканское стандартное время", "CHADT": "Чатем, летнее время", "HADT": "Гавайско-алеутское летнее время", "MDT": "Макао, летнее время", "BT": "Бутан", "GYT": "Гайана", "HNCU": "Куба, стандартное время", "WARST": "Западная Аргентина, летнее время", "TMST": "Туркмения, летнее время", "HKT": "Гонконг, стандартное время", "BOT": "Боливия", "HEOG": "Западная Гренландия, летнее время"}, + } +} + +// Locale returns the current translators string locale +func (ru *ru) Locale() string { + return ru.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ru' +func (ru *ru) PluralsCardinal() []locales.PluralRule { + return ru.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ru' +func (ru *ru) PluralsOrdinal() []locales.PluralRule { + return ru.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ru' +func (ru *ru) PluralsRange() []locales.PluralRule { + return ru.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ru' +func (ru *ru) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ru' +func (ru *ru) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ru' +func (ru *ru) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ru.CardinalPluralRule(num1, v1) + end := ru.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ru *ru) MonthAbbreviated(month time.Month) string { + return ru.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ru *ru) MonthsAbbreviated() []string { + return ru.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ru *ru) MonthNarrow(month time.Month) string { + return ru.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ru *ru) MonthsNarrow() []string { + return ru.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ru *ru) MonthWide(month time.Month) string { + return ru.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ru *ru) MonthsWide() []string { + return ru.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ru *ru) WeekdayAbbreviated(weekday time.Weekday) string { + return ru.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ru *ru) WeekdaysAbbreviated() []string { + return ru.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ru *ru) WeekdayNarrow(weekday time.Weekday) string { + return ru.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ru *ru) WeekdaysNarrow() []string { + return ru.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ru *ru) WeekdayShort(weekday time.Weekday) string { + return ru.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ru *ru) WeekdaysShort() []string { + return ru.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ru *ru) WeekdayWide(weekday time.Weekday) string { + return ru.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ru *ru) WeekdaysWide() []string { + return ru.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ru' and handles both Whole and Real numbers based on 'v' +func (ru *ru) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ru' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ru *ru) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ru.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ru' +func (ru *ru) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ru.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ru' +// in accounting notation. +func (ru *ru) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ru.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ru.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ru.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ru' +func (ru *ru) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ru' +func (ru *ru) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ru' +func (ru *ru) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ru' +func (ru *ru) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ru.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ru' +func (ru *ru) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ru' +func (ru *ru) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ru' +func (ru *ru) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ru' +func (ru *ru) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ru.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ru/ru_test.go b/vendor/github.com/go-playground/locales/ru/ru_test.go new file mode 100644 index 0000000000..eb86634519 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru/ru_test.go @@ -0,0 +1,1120 @@ +package ru + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ru" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ru_BY/ru_BY.go b/vendor/github.com/go-playground/locales/ru_BY/ru_BY.go new file mode 100644 index 0000000000..0345e26a0f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_BY/ru_BY.go @@ -0,0 +1,631 @@ +package ru_BY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ru_BY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ru_BY' locale +func New() locales.Translator { + return &ru_BY{ + locale: "ru_BY", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "Br", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "февр.", "мар.", "апр.", "мая", "июн.", "июл.", "авг.", "сент.", "окт.", "нояб.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"}, + daysAbbreviated: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysShort: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"}, + periodsAbbreviated: []string{"ДП", "ПП"}, + periodsNarrow: []string{"ДП", "ПП"}, + periodsWide: []string{"ДП", "ПП"}, + erasAbbreviated: []string{"до н. э.", "н. э."}, + erasNarrow: []string{"до н.э.", "н.э."}, + erasWide: []string{"до Рождества Христова", "от Рождества Христова"}, + timezones: map[string]string{"HNPMX": "Тихоокеанское мексиканское стандартное время", "AWST": "Западная Австралия, стандартное время", "OESZ": "Восточная Европа, летнее время", "AEDT": "Восточная Австралия, летнее время", "UYST": "Уругвай, летнее время", "LHST": "Лорд-Хау, стандартное время", "JDT": "Япония, летнее время", "ART": "Аргентина, стандартное время", "ACDT": "Центральная Австралия, летнее время", "HENOMX": "Северо-западное мексиканское летнее время", "SRT": "Суринам", "AWDT": "Западная Австралия, летнее время", "SGT": "Сингапур", "CAT": "Центральная Африка", "EDT": "Восточная Америка, летнее время", "LHDT": "Лорд-Хау, летнее время", "HNCU": "Куба, стандартное время", "WARST": "Западная Аргентина, летнее время", "CLT": "Чили, стандартное время", "AST": "Атлантическое стандартное время", "OEZ": "Восточная Европа, стандартное время", "WAT": "Западная Африка, стандартное время", "HKST": "Гонконг, летнее время", "AKDT": "Аляска, летнее время", "∅∅∅": "Азорские о-ва, летнее время", "NZST": "Новая Зеландия, стандартное время", "TMT": "Туркмения, стандартное время", "MEZ": "Центральная Европа, стандартное время", "HEOG": "Западная Гренландия, летнее время", "TMST": "Туркмения, летнее время", "EST": "Восточная Америка, стандартное время", "HKT": "Гонконг, стандартное время", "BOT": "Боливия", "MESZ": "Центральная Европа, летнее время", "MYT": "Малайзия", "ChST": "Чаморро", "HECU": "Куба, летнее время", "IST": "Индия", "NZDT": "Новая Зеландия, летнее время", "JST": "Япония, стандартное время", "HAT": "Ньюфаундленд, летнее время", "GFT": "Французская Гвиана", "CST": "Центральная Америка, стандартное время", "CLST": "Чили, летнее время", "ACST": "Центральная Австралия, стандартное время", "AEST": "Восточная Австралия, стандартное время", "CHADT": "Чатем, летнее время", "ECT": "Эквадор", "ACWST": "Центральная Австралия, западное стандартное время", "WART": "Западная Аргентина, стандартное время", "MST": "Макао, стандартное время", "BT": "Бутан", "UYT": "Уругвай, стандартное время", "WIB": "Западная Индонезия", "WIT": "Восточная Индонезия", "PST": "Тихоокеанское стандартное время", "HNOG": "Западная Гренландия, стандартное время", "GMT": "Среднее время по Гринвичу", "MDT": "Макао, летнее время", "HEEG": "Восточная Гренландия, летнее время", "HADT": "Гавайско-алеутское летнее время", "ADT": "Атлантическое летнее время", "HNT": "Ньюфаундленд, стандартное время", "SAST": "Южная Африка", "CDT": "Центральная Америка, летнее время", "WEZ": "Западная Европа, стандартное время", "WAST": "Западная Африка, летнее время", "HNEG": "Восточная Гренландия, стандарное время", "VET": "Венесуэла", "HNPM": "Сен-Пьер и Микелон, стандартное время", "HEPM": "Сен-Пьер и Микелон, летнее время", "EAT": "Восточная Африка", "CHAST": "Чатем, стандартное время", "PDT": "Тихоокеанское летнее время", "HAST": "Гавайско-алеутское стандартное время", "ACWDT": "Центральная Австралия, западное летнее время", "ARST": "Аргентина, летнее время", "WITA": "Центральная Индонезия", "HEPMX": "Тихоокеанское мексиканское летнее время", "GYT": "Гайана", "WESZ": "Западная Европа, летнее время", "COT": "Колумбия, стандартное время", "COST": "Колумбия, летнее время", "HNNOMX": "Северо-западное мексиканское стандартное время", "AKST": "Аляска, стандартное время"}, + } +} + +// Locale returns the current translators string locale +func (ru *ru_BY) Locale() string { + return ru.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ru_BY' +func (ru *ru_BY) PluralsCardinal() []locales.PluralRule { + return ru.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ru_BY' +func (ru *ru_BY) PluralsOrdinal() []locales.PluralRule { + return ru.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ru_BY' +func (ru *ru_BY) PluralsRange() []locales.PluralRule { + return ru.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ru_BY' +func (ru *ru_BY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ru_BY' +func (ru *ru_BY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ru_BY' +func (ru *ru_BY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ru.CardinalPluralRule(num1, v1) + end := ru.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ru *ru_BY) MonthAbbreviated(month time.Month) string { + return ru.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ru *ru_BY) MonthsAbbreviated() []string { + return ru.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ru *ru_BY) MonthNarrow(month time.Month) string { + return ru.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ru *ru_BY) MonthsNarrow() []string { + return ru.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ru *ru_BY) MonthWide(month time.Month) string { + return ru.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ru *ru_BY) MonthsWide() []string { + return ru.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ru *ru_BY) WeekdayAbbreviated(weekday time.Weekday) string { + return ru.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ru *ru_BY) WeekdaysAbbreviated() []string { + return ru.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ru *ru_BY) WeekdayNarrow(weekday time.Weekday) string { + return ru.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ru *ru_BY) WeekdaysNarrow() []string { + return ru.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ru *ru_BY) WeekdayShort(weekday time.Weekday) string { + return ru.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ru *ru_BY) WeekdaysShort() []string { + return ru.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ru *ru_BY) WeekdayWide(weekday time.Weekday) string { + return ru.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ru *ru_BY) WeekdaysWide() []string { + return ru.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ru_BY' and handles both Whole and Real numbers based on 'v' +func (ru *ru_BY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ru_BY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ru *ru_BY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ru.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ru_BY' +func (ru *ru_BY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ru.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ru_BY' +// in accounting notation. +func (ru *ru_BY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ru.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ru.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ru.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ru_BY' +func (ru *ru_BY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ru_BY' +func (ru *ru_BY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ru_BY' +func (ru *ru_BY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ru_BY' +func (ru *ru_BY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ru.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ru_BY' +func (ru *ru_BY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ru_BY' +func (ru *ru_BY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ru_BY' +func (ru *ru_BY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ru_BY' +func (ru *ru_BY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ru.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ru_BY/ru_BY_test.go b/vendor/github.com/go-playground/locales/ru_BY/ru_BY_test.go new file mode 100644 index 0000000000..42f42d57c0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_BY/ru_BY_test.go @@ -0,0 +1,1120 @@ +package ru_BY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ru_BY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ru_KG/ru_KG.go b/vendor/github.com/go-playground/locales/ru_KG/ru_KG.go new file mode 100644 index 0000000000..ff747b0d17 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_KG/ru_KG.go @@ -0,0 +1,631 @@ +package ru_KG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ru_KG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ru_KG' locale +func New() locales.Translator { + return &ru_KG{ + locale: "ru_KG", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "сом", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "февр.", "мар.", "апр.", "мая", "июн.", "июл.", "авг.", "сент.", "окт.", "нояб.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"}, + daysAbbreviated: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysShort: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"}, + periodsAbbreviated: []string{"ДП", "ПП"}, + periodsNarrow: []string{"ДП", "ПП"}, + periodsWide: []string{"ДП", "ПП"}, + erasAbbreviated: []string{"до н. э.", "н. э."}, + erasNarrow: []string{"до н.э.", "н.э."}, + erasWide: []string{"до Рождества Христова", "от Рождества Христова"}, + timezones: map[string]string{"SRT": "Суринам", "SAST": "Южная Африка", "CLT": "Чили, стандартное время", "HNEG": "Восточная Гренландия, стандарное время", "∅∅∅": "Акри летнее время", "AKST": "Аляска, стандартное время", "ChST": "Чаморро", "HNPMX": "Тихоокеанское мексиканское стандартное время", "LHST": "Лорд-Хау, стандартное время", "HECU": "Куба, летнее время", "AWDT": "Западная Австралия, летнее время", "TMT": "Туркмения, стандартное время", "ACDT": "Центральная Австралия, летнее время", "HNPM": "Сен-Пьер и Микелон, стандартное время", "JDT": "Япония, летнее время", "WAST": "Западная Африка, летнее время", "UYT": "Уругвай, стандартное время", "HEOG": "Западная Гренландия, летнее время", "ECT": "Эквадор", "MESZ": "Центральная Европа, летнее время", "EST": "Восточная Америка, стандартное время", "HENOMX": "Северо-западное мексиканское летнее время", "HEPM": "Сен-Пьер и Микелон, летнее время", "VET": "Венесуэла", "ARST": "Аргентина, летнее время", "ACST": "Центральная Австралия, стандартное время", "WIT": "Восточная Индонезия", "CHAST": "Чатем, стандартное время", "NZST": "Новая Зеландия, стандартное время", "MDT": "Макао, летнее время", "HKST": "Гонконг, летнее время", "GFT": "Французская Гвиана", "WART": "Западная Аргентина, стандартное время", "ADT": "Атлантическое летнее время", "OEZ": "Восточная Европа, стандартное время", "OESZ": "Восточная Европа, летнее время", "MST": "Макао, стандартное время", "WITA": "Центральная Индонезия", "UYST": "Уругвай, летнее время", "WARST": "Западная Аргентина, летнее время", "AEST": "Восточная Австралия, стандартное время", "AWST": "Западная Австралия, стандартное время", "GYT": "Гайана", "SGT": "Сингапур", "PST": "Тихоокеанское стандартное время", "GMT": "Среднее время по Гринвичу", "MYT": "Малайзия", "ART": "Аргентина, стандартное время", "WAT": "Западная Африка, стандартное время", "HAT": "Ньюфаундленд, летнее время", "PDT": "Тихоокеанское летнее время", "IST": "Индия", "EAT": "Восточная Африка", "HNCU": "Куба, стандартное время", "CHADT": "Чатем, летнее время", "WESZ": "Западная Европа, летнее время", "HNOG": "Западная Гренландия, стандартное время", "EDT": "Восточная Америка, летнее время", "COT": "Колумбия, стандартное время", "HNT": "Ньюфаундленд, стандартное время", "JST": "Япония, стандартное время", "ACWDT": "Центральная Австралия, западное летнее время", "CLST": "Чили, летнее время", "AST": "Атлантическое стандартное время", "HNNOMX": "Северо-западное мексиканское стандартное время", "BOT": "Боливия", "ACWST": "Центральная Австралия, западное стандартное время", "LHDT": "Лорд-Хау, летнее время", "CST": "Центральная Америка, стандартное время", "HEPMX": "Тихоокеанское мексиканское летнее время", "HAST": "Гавайско-алеутское стандартное время", "MEZ": "Центральная Европа, стандартное время", "WEZ": "Западная Европа, стандартное время", "TMST": "Туркмения, летнее время", "HEEG": "Восточная Гренландия, летнее время", "BT": "Бутан", "AEDT": "Восточная Австралия, летнее время", "HADT": "Гавайско-алеутское летнее время", "NZDT": "Новая Зеландия, летнее время", "CAT": "Центральная Африка", "HKT": "Гонконг, стандартное время", "COST": "Колумбия, летнее время", "AKDT": "Аляска, летнее время", "WIB": "Западная Индонезия", "CDT": "Центральная Америка, летнее время"}, + } +} + +// Locale returns the current translators string locale +func (ru *ru_KG) Locale() string { + return ru.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ru_KG' +func (ru *ru_KG) PluralsCardinal() []locales.PluralRule { + return ru.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ru_KG' +func (ru *ru_KG) PluralsOrdinal() []locales.PluralRule { + return ru.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ru_KG' +func (ru *ru_KG) PluralsRange() []locales.PluralRule { + return ru.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ru_KG' +func (ru *ru_KG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + iMod10 := i % 10 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ru_KG' +func (ru *ru_KG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ru_KG' +func (ru *ru_KG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ru.CardinalPluralRule(num1, v1) + end := ru.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ru *ru_KG) MonthAbbreviated(month time.Month) string { + return ru.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ru *ru_KG) MonthsAbbreviated() []string { + return ru.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ru *ru_KG) MonthNarrow(month time.Month) string { + return ru.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ru *ru_KG) MonthsNarrow() []string { + return ru.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ru *ru_KG) MonthWide(month time.Month) string { + return ru.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ru *ru_KG) MonthsWide() []string { + return ru.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ru *ru_KG) WeekdayAbbreviated(weekday time.Weekday) string { + return ru.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ru *ru_KG) WeekdaysAbbreviated() []string { + return ru.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ru *ru_KG) WeekdayNarrow(weekday time.Weekday) string { + return ru.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ru *ru_KG) WeekdaysNarrow() []string { + return ru.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ru *ru_KG) WeekdayShort(weekday time.Weekday) string { + return ru.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ru *ru_KG) WeekdaysShort() []string { + return ru.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ru *ru_KG) WeekdayWide(weekday time.Weekday) string { + return ru.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ru *ru_KG) WeekdaysWide() []string { + return ru.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ru_KG' and handles both Whole and Real numbers based on 'v' +func (ru *ru_KG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ru_KG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ru *ru_KG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ru.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ru_KG' +func (ru *ru_KG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ru.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ru_KG' +// in accounting notation. +func (ru *ru_KG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ru.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ru.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ru.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ru_KG' +func (ru *ru_KG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ru_KG' +func (ru *ru_KG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ru_KG' +func (ru *ru_KG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ru_KG' +func (ru *ru_KG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ru.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ru_KG' +func (ru *ru_KG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ru_KG' +func (ru *ru_KG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ru_KG' +func (ru *ru_KG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ru_KG' +func (ru *ru_KG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ru.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ru_KG/ru_KG_test.go b/vendor/github.com/go-playground/locales/ru_KG/ru_KG_test.go new file mode 100644 index 0000000000..ec991858e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_KG/ru_KG_test.go @@ -0,0 +1,1120 @@ +package ru_KG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ru_KG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ru_KZ/ru_KZ.go b/vendor/github.com/go-playground/locales/ru_KZ/ru_KZ.go new file mode 100644 index 0000000000..1d7e0de439 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_KZ/ru_KZ.go @@ -0,0 +1,631 @@ +package ru_KZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ru_KZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ru_KZ' locale +func New() locales.Translator { + return &ru_KZ{ + locale: "ru_KZ", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "₸", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "февр.", "мар.", "апр.", "мая", "июн.", "июл.", "авг.", "сент.", "окт.", "нояб.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"}, + daysAbbreviated: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysShort: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"}, + periodsAbbreviated: []string{"ДП", "ПП"}, + periodsNarrow: []string{"ДП", "ПП"}, + periodsWide: []string{"ДП", "ПП"}, + erasAbbreviated: []string{"до н. э.", "н. э."}, + erasNarrow: []string{"до н.э.", "н.э."}, + erasWide: []string{"до Рождества Христова", "от Рождества Христова"}, + timezones: map[string]string{"ACDT": "Центральная Австралия, летнее время", "CDT": "Центральная Америка, летнее время", "WEZ": "Западная Европа, стандартное время", "WESZ": "Западная Европа, летнее время", "AEST": "Восточная Австралия, стандартное время", "ACWST": "Центральная Австралия, западное стандартное время", "EST": "Восточная Америка, стандартное время", "MESZ": "Центральная Европа, летнее время", "VET": "Венесуэла", "CLT": "Чили, стандартное время", "HAT": "Ньюфаундленд, летнее время", "UYST": "Уругвай, летнее время", "HEPM": "Сен-Пьер и Микелон, летнее время", "BOT": "Боливия", "HAST": "Гавайско-алеутское стандартное время", "HEEG": "Восточная Гренландия, летнее время", "NZDT": "Новая Зеландия, летнее время", "HKST": "Гонконг, летнее время", "JDT": "Япония, летнее время", "WART": "Западная Аргентина, стандартное время", "HNPMX": "Тихоокеанское мексиканское стандартное время", "CHADT": "Чатем, летнее время", "PST": "Тихоокеанское стандартное время", "MYT": "Малайзия", "ACST": "Центральная Австралия, стандартное время", "HNPM": "Сен-Пьер и Микелон, стандартное время", "LHST": "Лорд-Хау, стандартное время", "SRT": "Суринам", "ACWDT": "Центральная Австралия, западное летнее время", "AST": "Атлантическое стандартное время", "HKT": "Гонконг, стандартное время", "AKST": "Аляска, стандартное время", "HADT": "Гавайско-алеутское летнее время", "GMT": "Среднее время по Гринвичу", "COST": "Колумбия, летнее время", "UYT": "Уругвай, стандартное время", "TMT": "Туркмения, стандартное время", "ARST": "Аргентина, летнее время", "ChST": "Чаморро", "CST": "Центральная Америка, стандартное время", "OEZ": "Восточная Европа, стандартное время", "HNNOMX": "Северо-западное мексиканское стандартное время", "HENOMX": "Северо-западное мексиканское летнее время", "SAST": "Южная Африка", "GYT": "Гайана", "WIB": "Западная Индонезия", "∅∅∅": "Амазонка, летнее время", "HEOG": "Западная Гренландия, летнее время", "EDT": "Восточная Америка, летнее время", "GFT": "Французская Гвиана", "WIT": "Восточная Индонезия", "SGT": "Сингапур", "TMST": "Туркмения, летнее время", "MEZ": "Центральная Европа, стандартное время", "OESZ": "Восточная Европа, летнее время", "WARST": "Западная Аргентина, летнее время", "MDT": "Макао, летнее время", "WAT": "Западная Африка, стандартное время", "HNT": "Ньюфаундленд, стандартное время", "CHAST": "Чатем, стандартное время", "CAT": "Центральная Африка", "HNEG": "Восточная Гренландия, стандарное время", "HECU": "Куба, летнее время", "BT": "Бутан", "WITA": "Центральная Индонезия", "EAT": "Восточная Африка", "AWST": "Западная Австралия, стандартное время", "AWDT": "Западная Австралия, летнее время", "WAST": "Западная Африка, летнее время", "PDT": "Тихоокеанское летнее время", "ART": "Аргентина, стандартное время", "NZST": "Новая Зеландия, стандартное время", "JST": "Япония, стандартное время", "CLST": "Чили, летнее время", "MST": "Макао, стандартное время", "COT": "Колумбия, стандартное время", "AKDT": "Аляска, летнее время", "ECT": "Эквадор", "IST": "Индия", "AEDT": "Восточная Австралия, летнее время", "HEPMX": "Тихоокеанское мексиканское летнее время", "LHDT": "Лорд-Хау, летнее время", "HNCU": "Куба, стандартное время", "HNOG": "Западная Гренландия, стандартное время", "ADT": "Атлантическое летнее время"}, + } +} + +// Locale returns the current translators string locale +func (ru *ru_KZ) Locale() string { + return ru.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ru_KZ' +func (ru *ru_KZ) PluralsCardinal() []locales.PluralRule { + return ru.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ru_KZ' +func (ru *ru_KZ) PluralsOrdinal() []locales.PluralRule { + return ru.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ru_KZ' +func (ru *ru_KZ) PluralsRange() []locales.PluralRule { + return ru.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ru_KZ' +func (ru *ru_KZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ru_KZ' +func (ru *ru_KZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ru_KZ' +func (ru *ru_KZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ru.CardinalPluralRule(num1, v1) + end := ru.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ru *ru_KZ) MonthAbbreviated(month time.Month) string { + return ru.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ru *ru_KZ) MonthsAbbreviated() []string { + return ru.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ru *ru_KZ) MonthNarrow(month time.Month) string { + return ru.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ru *ru_KZ) MonthsNarrow() []string { + return ru.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ru *ru_KZ) MonthWide(month time.Month) string { + return ru.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ru *ru_KZ) MonthsWide() []string { + return ru.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ru *ru_KZ) WeekdayAbbreviated(weekday time.Weekday) string { + return ru.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ru *ru_KZ) WeekdaysAbbreviated() []string { + return ru.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ru *ru_KZ) WeekdayNarrow(weekday time.Weekday) string { + return ru.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ru *ru_KZ) WeekdaysNarrow() []string { + return ru.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ru *ru_KZ) WeekdayShort(weekday time.Weekday) string { + return ru.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ru *ru_KZ) WeekdaysShort() []string { + return ru.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ru *ru_KZ) WeekdayWide(weekday time.Weekday) string { + return ru.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ru *ru_KZ) WeekdaysWide() []string { + return ru.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ru_KZ' and handles both Whole and Real numbers based on 'v' +func (ru *ru_KZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ru_KZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ru *ru_KZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ru.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ru_KZ' +func (ru *ru_KZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ru.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ru_KZ' +// in accounting notation. +func (ru *ru_KZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ru.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ru.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ru.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ru_KZ' +func (ru *ru_KZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ru_KZ' +func (ru *ru_KZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ru_KZ' +func (ru *ru_KZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ru_KZ' +func (ru *ru_KZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ru.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ru_KZ' +func (ru *ru_KZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ru_KZ' +func (ru *ru_KZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ru_KZ' +func (ru *ru_KZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ru_KZ' +func (ru *ru_KZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ru.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ru_KZ/ru_KZ_test.go b/vendor/github.com/go-playground/locales/ru_KZ/ru_KZ_test.go new file mode 100644 index 0000000000..4883fb0ada --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_KZ/ru_KZ_test.go @@ -0,0 +1,1120 @@ +package ru_KZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ru_KZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ru_MD/ru_MD.go b/vendor/github.com/go-playground/locales/ru_MD/ru_MD.go new file mode 100644 index 0000000000..e30730a0ab --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_MD/ru_MD.go @@ -0,0 +1,631 @@ +package ru_MD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ru_MD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ru_MD' locale +func New() locales.Translator { + return &ru_MD{ + locale: "ru_MD", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "L", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "февр.", "мар.", "апр.", "мая", "июн.", "июл.", "авг.", "сент.", "окт.", "нояб.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"}, + daysAbbreviated: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysShort: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"}, + periodsAbbreviated: []string{"ДП", "ПП"}, + periodsNarrow: []string{"ДП", "ПП"}, + periodsWide: []string{"ДП", "ПП"}, + erasAbbreviated: []string{"до н. э.", "н. э."}, + erasNarrow: []string{"до н.э.", "н.э."}, + erasWide: []string{"до Рождества Христова", "от Рождества Христова"}, + timezones: map[string]string{"AWDT": "Западная Австралия, летнее время", "BOT": "Боливия", "NZDT": "Новая Зеландия, летнее время", "OESZ": "Восточная Европа, летнее время", "TMT": "Туркмения, стандартное время", "WAST": "Западная Африка, летнее время", "HKST": "Гонконг, летнее время", "ChST": "Чаморро", "CST": "Центральная Америка, стандартное время", "IST": "Индия", "OEZ": "Восточная Европа, стандартное время", "GYT": "Гайана", "∅∅∅": "Акри летнее время", "SGT": "Сингапур", "ACWDT": "Центральная Австралия, западное летнее время", "HNEG": "Восточная Гренландия, стандарное время", "LHST": "Лорд-Хау, стандартное время", "LHDT": "Лорд-Хау, летнее время", "EAT": "Восточная Африка", "WIB": "Западная Индонезия", "PDT": "Тихоокеанское летнее время", "MEZ": "Центральная Европа, стандартное время", "WESZ": "Западная Европа, летнее время", "HNT": "Ньюфаундленд, стандартное время", "HENOMX": "Северо-западное мексиканское летнее время", "HNCU": "Куба, стандартное время", "ACWST": "Центральная Австралия, западное стандартное время", "MYT": "Малайзия", "AKDT": "Аляска, летнее время", "HADT": "Гавайско-алеутское летнее время", "GMT": "Среднее время по Гринвичу", "COT": "Колумбия, стандартное время", "WIT": "Восточная Индонезия", "CLST": "Чили, летнее время", "EDT": "Восточная Америка, летнее время", "HNPM": "Сен-Пьер и Микелон, стандартное время", "MDT": "Горное летнее время (США)", "UYT": "Уругвай, стандартное время", "HNPMX": "Тихоокеанское мексиканское стандартное время", "ECT": "Эквадор", "HEEG": "Восточная Гренландия, летнее время", "HAT": "Ньюфаундленд, летнее время", "UYST": "Уругвай, летнее время", "CHAST": "Чатем, стандартное время", "PST": "Тихоокеанское стандартное время", "MESZ": "Центральная Европа, летнее время", "CLT": "Чили, стандартное время", "BT": "Бутан", "HEPM": "Сен-Пьер и Микелон, летнее время", "SRT": "Суринам", "AEST": "Восточная Австралия, стандартное время", "AWST": "Западная Австралия, стандартное время", "TMST": "Туркмения, летнее время", "ARST": "Аргентина, летнее время", "AEDT": "Восточная Австралия, летнее время", "VET": "Венесуэла", "JST": "Япония, стандартное время", "HEOG": "Западная Гренландия, летнее время", "ACDT": "Центральная Австралия, летнее время", "COST": "Колумбия, летнее время", "CHADT": "Чатем, летнее время", "WAT": "Западная Африка, стандартное время", "JDT": "Япония, летнее время", "HECU": "Куба, летнее время", "HAST": "Гавайско-алеутское стандартное время", "CAT": "Центральная Африка", "WART": "Западная Аргентина, стандартное время", "HNOG": "Западная Гренландия, стандартное время", "ART": "Аргентина, стандартное время", "HKT": "Гонконг, стандартное время", "HEPMX": "Тихоокеанское мексиканское летнее время", "AKST": "Аляска, стандартное время", "SAST": "Южная Африка", "CDT": "Центральная Америка, летнее время", "WARST": "Западная Аргентина, летнее время", "AST": "Атлантическое стандартное время", "WEZ": "Западная Европа, стандартное время", "EST": "Восточная Америка, стандартное время", "WITA": "Центральная Индонезия", "HNNOMX": "Северо-западное мексиканское стандартное время", "GFT": "Французская Гвиана", "NZST": "Новая Зеландия, стандартное время", "ADT": "Атлантическое летнее время", "ACST": "Центральная Австралия, стандартное время", "MST": "Горное стандартное время (США)"}, + } +} + +// Locale returns the current translators string locale +func (ru *ru_MD) Locale() string { + return ru.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ru_MD' +func (ru *ru_MD) PluralsCardinal() []locales.PluralRule { + return ru.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ru_MD' +func (ru *ru_MD) PluralsOrdinal() []locales.PluralRule { + return ru.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ru_MD' +func (ru *ru_MD) PluralsRange() []locales.PluralRule { + return ru.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ru_MD' +func (ru *ru_MD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + iMod10 := i % 10 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ru_MD' +func (ru *ru_MD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ru_MD' +func (ru *ru_MD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ru.CardinalPluralRule(num1, v1) + end := ru.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ru *ru_MD) MonthAbbreviated(month time.Month) string { + return ru.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ru *ru_MD) MonthsAbbreviated() []string { + return ru.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ru *ru_MD) MonthNarrow(month time.Month) string { + return ru.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ru *ru_MD) MonthsNarrow() []string { + return ru.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ru *ru_MD) MonthWide(month time.Month) string { + return ru.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ru *ru_MD) MonthsWide() []string { + return ru.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ru *ru_MD) WeekdayAbbreviated(weekday time.Weekday) string { + return ru.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ru *ru_MD) WeekdaysAbbreviated() []string { + return ru.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ru *ru_MD) WeekdayNarrow(weekday time.Weekday) string { + return ru.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ru *ru_MD) WeekdaysNarrow() []string { + return ru.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ru *ru_MD) WeekdayShort(weekday time.Weekday) string { + return ru.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ru *ru_MD) WeekdaysShort() []string { + return ru.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ru *ru_MD) WeekdayWide(weekday time.Weekday) string { + return ru.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ru *ru_MD) WeekdaysWide() []string { + return ru.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ru_MD' and handles both Whole and Real numbers based on 'v' +func (ru *ru_MD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ru_MD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ru *ru_MD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ru.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ru_MD' +func (ru *ru_MD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ru.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ru_MD' +// in accounting notation. +func (ru *ru_MD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ru.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ru.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ru.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ru_MD' +func (ru *ru_MD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ru_MD' +func (ru *ru_MD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ru_MD' +func (ru *ru_MD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ru_MD' +func (ru *ru_MD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ru.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ru_MD' +func (ru *ru_MD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ru_MD' +func (ru *ru_MD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ru_MD' +func (ru *ru_MD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ru_MD' +func (ru *ru_MD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ru.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ru_MD/ru_MD_test.go b/vendor/github.com/go-playground/locales/ru_MD/ru_MD_test.go new file mode 100644 index 0000000000..2a97711ee3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_MD/ru_MD_test.go @@ -0,0 +1,1120 @@ +package ru_MD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ru_MD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ru_RU/ru_RU.go b/vendor/github.com/go-playground/locales/ru_RU/ru_RU.go new file mode 100644 index 0000000000..906ff0aac3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_RU/ru_RU.go @@ -0,0 +1,631 @@ +package ru_RU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ru_RU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ru_RU' locale +func New() locales.Translator { + return &ru_RU{ + locale: "ru_RU", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "февр.", "мар.", "апр.", "мая", "июн.", "июл.", "авг.", "сент.", "окт.", "нояб.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"}, + daysAbbreviated: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysShort: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"}, + periodsAbbreviated: []string{"ДП", "ПП"}, + periodsNarrow: []string{"ДП", "ПП"}, + periodsWide: []string{"ДП", "ПП"}, + erasAbbreviated: []string{"до н. э.", "н. э."}, + erasNarrow: []string{"до н.э.", "н.э."}, + erasWide: []string{"до Рождества Христова", "от Рождества Христова"}, + timezones: map[string]string{"HEPM": "Сен-Пьер и Микелон, летнее время", "UYT": "Уругвай, стандартное время", "WESZ": "Западная Европа, летнее время", "HNOG": "Западная Гренландия, стандартное время", "BT": "Бутан", "WAT": "Западная Африка, стандартное время", "AEDT": "Восточная Австралия, летнее время", "ChST": "Чаморро", "CST": "Центральная Америка, стандартное время", "AST": "Атлантическое стандартное время", "HKST": "Гонконг, летнее время", "HNNOMX": "Северо-западное мексиканское стандартное время", "HENOMX": "Северо-западное мексиканское летнее время", "GFT": "Французская Гвиана", "WITA": "Центральная Индонезия", "AKST": "Аляска, стандартное время", "∅∅∅": "Азорские о-ва, летнее время", "NZDT": "Новая Зеландия, летнее время", "MYT": "Малайзия", "CLST": "Чили, летнее время", "OESZ": "Восточная Европа, летнее время", "MDT": "Макао, летнее время", "VET": "Венесуэла", "TMT": "Туркмения, стандартное время", "HAT": "Ньюфаундленд, летнее время", "GYT": "Гайана", "HECU": "Куба, летнее время", "CLT": "Чили, стандартное время", "WAST": "Западная Африка, летнее время", "CHADT": "Чатем, летнее время", "PDT": "Тихоокеанское летнее время", "OEZ": "Восточная Европа, стандартное время", "SRT": "Суринам", "WARST": "Западная Аргентина, летнее время", "ACDT": "Центральная Австралия, летнее время", "CAT": "Центральная Африка", "ART": "Аргентина, стандартное время", "AEST": "Восточная Австралия, стандартное время", "EAT": "Восточная Африка", "HNCU": "Куба, стандартное время", "BOT": "Боливия", "HNT": "Ньюфаундленд, стандартное время", "SAST": "Южная Африка", "SGT": "Сингапур", "JDT": "Япония, летнее время", "ADT": "Атлантическое летнее время", "TMST": "Туркмения, летнее время", "EST": "Восточная Америка, стандартное время", "COT": "Колумбия, стандартное время", "WIB": "Западная Индонезия", "CHAST": "Чатем, стандартное время", "WART": "Западная Аргентина, стандартное время", "ARST": "Аргентина, летнее время", "HAST": "Гавайско-алеутское стандартное время", "ECT": "Эквадор", "JST": "Япония, стандартное время", "PST": "Тихоокеанское стандартное время", "NZST": "Новая Зеландия, стандартное время", "IST": "Индия", "MEZ": "Центральная Европа, стандартное время", "MESZ": "Центральная Европа, летнее время", "HNPMX": "Тихоокеанское мексиканское стандартное время", "CDT": "Центральная Америка, летнее время", "AWST": "Западная Австралия, стандартное время", "HNEG": "Восточная Гренландия, стандарное время", "WEZ": "Западная Европа, стандартное время", "HEOG": "Западная Гренландия, летнее время", "HKT": "Гонконг, стандартное время", "COST": "Колумбия, летнее время", "AKDT": "Аляска, летнее время", "LHDT": "Лорд-Хау, летнее время", "AWDT": "Западная Австралия, летнее время", "ACWST": "Центральная Австралия, западное стандартное время", "HNPM": "Сен-Пьер и Микелон, стандартное время", "HADT": "Гавайско-алеутское летнее время", "MST": "Макао, стандартное время", "EDT": "Восточная Америка, летнее время", "HEEG": "Восточная Гренландия, летнее время", "UYST": "Уругвай, летнее время", "HEPMX": "Тихоокеанское мексиканское летнее время", "LHST": "Лорд-Хау, стандартное время", "WIT": "Восточная Индонезия", "ACWDT": "Центральная Австралия, западное летнее время", "GMT": "Среднее время по Гринвичу", "ACST": "Центральная Австралия, стандартное время"}, + } +} + +// Locale returns the current translators string locale +func (ru *ru_RU) Locale() string { + return ru.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ru_RU' +func (ru *ru_RU) PluralsCardinal() []locales.PluralRule { + return ru.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ru_RU' +func (ru *ru_RU) PluralsOrdinal() []locales.PluralRule { + return ru.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ru_RU' +func (ru *ru_RU) PluralsRange() []locales.PluralRule { + return ru.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ru_RU' +func (ru *ru_RU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ru_RU' +func (ru *ru_RU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ru_RU' +func (ru *ru_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ru.CardinalPluralRule(num1, v1) + end := ru.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ru *ru_RU) MonthAbbreviated(month time.Month) string { + return ru.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ru *ru_RU) MonthsAbbreviated() []string { + return ru.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ru *ru_RU) MonthNarrow(month time.Month) string { + return ru.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ru *ru_RU) MonthsNarrow() []string { + return ru.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ru *ru_RU) MonthWide(month time.Month) string { + return ru.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ru *ru_RU) MonthsWide() []string { + return ru.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ru *ru_RU) WeekdayAbbreviated(weekday time.Weekday) string { + return ru.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ru *ru_RU) WeekdaysAbbreviated() []string { + return ru.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ru *ru_RU) WeekdayNarrow(weekday time.Weekday) string { + return ru.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ru *ru_RU) WeekdaysNarrow() []string { + return ru.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ru *ru_RU) WeekdayShort(weekday time.Weekday) string { + return ru.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ru *ru_RU) WeekdaysShort() []string { + return ru.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ru *ru_RU) WeekdayWide(weekday time.Weekday) string { + return ru.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ru *ru_RU) WeekdaysWide() []string { + return ru.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ru_RU' and handles both Whole and Real numbers based on 'v' +func (ru *ru_RU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ru_RU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ru *ru_RU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ru.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ru_RU' +func (ru *ru_RU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ru.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ru_RU' +// in accounting notation. +func (ru *ru_RU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ru.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ru.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ru.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ru_RU' +func (ru *ru_RU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ru_RU' +func (ru *ru_RU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ru_RU' +func (ru *ru_RU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ru_RU' +func (ru *ru_RU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ru.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ru_RU' +func (ru *ru_RU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ru_RU' +func (ru *ru_RU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ru_RU' +func (ru *ru_RU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ru_RU' +func (ru *ru_RU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ru.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ru_RU/ru_RU_test.go b/vendor/github.com/go-playground/locales/ru_RU/ru_RU_test.go new file mode 100644 index 0000000000..caa025917e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_RU/ru_RU_test.go @@ -0,0 +1,1281 @@ +package ru_RU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ru_RU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + { + expected: locales.PluralRuleOther, + }, + } + + rules := trans.PluralsRange() + expected := 4 + if len(rules) != expected { + t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + { + expected: locales.PluralRuleOther, + }, + } + + rules := trans.PluralsOrdinal() + expected := 1 + if len(rules) != expected { + t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + { + expected: locales.PluralRuleOne, + }, + { + expected: locales.PluralRuleFew, + }, + { + expected: locales.PluralRuleMany, + }, + { + expected: locales.PluralRuleOther, + }, + } + + rules := trans.PluralsCardinal() + expected := 4 + if len(rules) != expected { + t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + { + num1: 1, + v1: 1, + num2: 2, + v2: 2, + expected: locales.PluralRuleOther, + }, + { + num1: 1, + v1: 0, + num2: 2, + v2: 0, + expected: locales.PluralRuleFew, + }, + { + num1: 1, + v1: 0, + num2: 21, + v2: 0, + expected: locales.PluralRuleOne, + }, + { + num1: 1, + v1: 0, + num2: 5, + v2: 0, + expected: locales.PluralRuleMany, + }, + { + num1: 1, + v1: 0, + num2: 10, + v2: 0, + expected: locales.PluralRuleMany, + }, + { + num1: 1, + v1: 0, + num2: 10.0, + v2: 1, + expected: locales.PluralRuleOther, + }, + { + num1: 2, + v1: 0, + num2: 21, + v2: 0, + expected: locales.PluralRuleOne, + }, + { + num1: 2, + v1: 0, + num2: 22, + v2: 0, + expected: locales.PluralRuleFew, + }, + { + num1: 2, + v1: 0, + num2: 5, + v2: 0, + expected: locales.PluralRuleMany, + }, + { + num1: 2, + v1: 0, + num2: 10, + v2: 1, + expected: locales.PluralRuleOther, + }, + { + num1: 0, + v1: 0, + num2: 1, + v2: 0, + expected: locales.PluralRuleOne, + }, + { + num1: 0, + v1: 0, + num2: 2, + v2: 0, + expected: locales.PluralRuleFew, + }, + { + num1: 0, + v1: 0, + num2: 5, + v2: 0, + expected: locales.PluralRuleMany, + }, + { + num1: 0, + v1: 0, + num2: 10, + v2: 1, + expected: locales.PluralRuleOther, + }, + { + num1: 0.0, + v1: 1, + num2: 1, + v2: 0, + expected: locales.PluralRuleOne, + }, + { + num1: 0.0, + v1: 1, + num2: 2, + v2: 0, + expected: locales.PluralRuleFew, + }, + { + num1: 0.0, + v1: 1, + num2: 5, + v2: 0, + expected: locales.PluralRuleMany, + }, + { + num1: 0.0, + v1: 1, + num2: 10.0, + v2: 1, + expected: locales.PluralRuleOther, + }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + { + num: 1, + v: 0, + expected: locales.PluralRuleOther, + }, + { + num: 2, + v: 0, + expected: locales.PluralRuleOther, + }, + { + num: 3, + v: 0, + expected: locales.PluralRuleOther, + }, + { + num: 4, + v: 0, + expected: locales.PluralRuleOther, + }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + { + num: 1, + v: 0, + expected: locales.PluralRuleOne, + }, + { + num: 21, + v: 0, + expected: locales.PluralRuleOne, + }, + { + num: 31, + v: 0, + expected: locales.PluralRuleOne, + }, + { + num: 2, + v: 0, + expected: locales.PluralRuleFew, + }, + { + num: 3, + v: 0, + expected: locales.PluralRuleFew, + }, + { + num: 22, + v: 0, + expected: locales.PluralRuleFew, + }, + { + num: 23, + v: 0, + expected: locales.PluralRuleFew, + }, + { + num: 0, + v: 0, + expected: locales.PluralRuleMany, + }, + { + num: 5, + v: 0, + expected: locales.PluralRuleMany, + }, + { + num: 11, + v: 0, + expected: locales.PluralRuleMany, + }, + { + num: 100, + v: 0, + expected: locales.PluralRuleMany, + }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 0, + expected: "вс", + }, + { + idx: 1, + expected: "пн", + }, + { + idx: 2, + expected: "вт", + }, + { + idx: 3, + expected: "ср", + }, + { + idx: 4, + expected: "чт", + }, + { + idx: 5, + expected: "пт", + }, + { + idx: 6, + expected: "сб", + }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 0, + expected: "вс", + }, + { + idx: 1, + expected: "пн", + }, + { + idx: 2, + expected: "вт", + }, + { + idx: 3, + expected: "ср", + }, + { + idx: 4, + expected: "чт", + }, + { + idx: 5, + expected: "пт", + }, + { + idx: 6, + expected: "сб", + }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 0, + expected: "вс", + }, + { + idx: 1, + expected: "пн", + }, + { + idx: 2, + expected: "вт", + }, + { + idx: 3, + expected: "ср", + }, + { + idx: 4, + expected: "чт", + }, + { + idx: 5, + expected: "пт", + }, + { + idx: 6, + expected: "сб", + }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 0, + expected: "воскресенье", + }, + { + idx: 1, + expected: "понедельник", + }, + { + idx: 2, + expected: "вторник", + }, + { + idx: 3, + expected: "среда", + }, + { + idx: 4, + expected: "четверг", + }, + { + idx: 5, + expected: "пятница", + }, + { + idx: 6, + expected: "суббота", + }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 1, + expected: "янв.", + }, + { + idx: 2, + expected: "февр.", + }, + { + idx: 3, + expected: "мар.", + }, + { + idx: 4, + expected: "апр.", + }, + { + idx: 5, + expected: "мая", + }, + { + idx: 6, + expected: "июн.", + }, + { + idx: 7, + expected: "июл.", + }, + { + idx: 8, + expected: "авг.", + }, + { + idx: 9, + expected: "сент.", + }, + { + idx: 10, + expected: "окт.", + }, + { + idx: 11, + expected: "нояб.", + }, + { + idx: 12, + expected: "дек.", + }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 1, + expected: "Я", + }, + { + idx: 2, + expected: "Ф", + }, + { + idx: 3, + expected: "М", + }, + { + idx: 4, + expected: "А", + }, + { + idx: 5, + expected: "М", + }, + { + idx: 6, + expected: "И", + }, + { + idx: 7, + expected: "И", + }, + { + idx: 8, + expected: "А", + }, + { + idx: 9, + expected: "С", + }, + { + idx: 10, + expected: "О", + }, + { + idx: 11, + expected: "Н", + }, + { + idx: 12, + expected: "Д", + }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + { + idx: 1, + expected: "января", + }, + { + idx: 2, + expected: "февраля", + }, + { + idx: 3, + expected: "марта", + }, + { + idx: 4, + expected: "апреля", + }, + { + idx: 5, + expected: "мая", + }, + { + idx: 6, + expected: "июня", + }, + { + idx: 7, + expected: "июля", + }, + { + idx: 8, + expected: "августа", + }, + { + idx: 9, + expected: "сентября", + }, + { + idx: 10, + expected: "октября", + }, + { + idx: 11, + expected: "ноября", + }, + { + idx: 12, + expected: "декабря", + }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + loc, err := time.LoadLocation("America/Toronto") + if err != nil { + t.Errorf("Expected '' Got '%s'", err) + } + + fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + expected: "9:05:01 Восточная Америка, стандартное время", + }, + { + t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + expected: "20:05:01 OTHER", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + loc, err := time.LoadLocation("America/Toronto") + if err != nil { + t.Errorf("Expected '' Got '%s'", err) + } + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + expected: "9:05:01 EST", + }, + { + t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + expected: "20:05:01 EST", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + expected: "9:05:01", + }, + { + t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + expected: "20:05:01", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + expected: "9:05", + }, + { + t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + expected: "20:05", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "среда, 3 февраля 2016 г.", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "3 февраля 2016 г.", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "3 февр. 2016 г.", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + { + t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "03.02.2016", // date format changed from v29 dd.MM.yy to v30 dd.MM.y so adjusted test for new CLDR data + }, + { + t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + expected: "03.02.500", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + { + num: 1123456.5643, + v: 2, + expected: "1 123 456,56", + }, + { + num: 1123456.5643, + v: 1, + expected: "1 123 456,6", + }, + { + num: 221123456.5643, + v: 3, + expected: "221 123 456,564", + }, + { + num: -221123456.5643, + v: 3, + expected: "-221 123 456,564", + }, + { + num: -221123456.5643, + v: 3, + expected: "-221 123 456,564", + }, + { + num: 0, + v: 2, + expected: "0,00", + }, + { + num: -0, + v: 2, + expected: "0,00", + }, + { + num: -0, + v: 2, + expected: "0,00", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + { + num: 1123456.5643, + v: 2, + currency: currency.USD, + expected: "1 123 456,56 USD", + }, + { + num: 1123456.5643, + v: 1, + currency: currency.USD, + expected: "1 123 456,60 USD", + }, + { + num: 221123456.5643, + v: 3, + currency: currency.USD, + expected: "221 123 456,564 USD", + }, + { + num: -221123456.5643, + v: 3, + currency: currency.USD, + expected: "-221 123 456,564 USD", + }, + { + num: -221123456.5643, + v: 3, + currency: currency.CAD, + expected: "-221 123 456,564 CAD", + }, + { + num: 0, + v: 2, + currency: currency.USD, + expected: "0,00 USD", + }, + { + num: -0, + v: 2, + currency: currency.USD, + expected: "0,00 USD", + }, + { + num: -0, + v: 2, + currency: currency.CAD, + expected: "0,00 CAD", + }, + { + num: 1.23, + v: 0, + currency: currency.USD, + expected: "1,00 USD", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + { + num: 1123456.5643, + v: 2, + currency: currency.USD, + expected: "1 123 456,56 USD", + }, + { + num: 1123456.5643, + v: 1, + currency: currency.USD, + expected: "1 123 456,60 USD", + }, + { + num: 221123456.5643, + v: 3, + currency: currency.USD, + expected: "221 123 456,564 USD", + }, + { + num: -221123456.5643, + v: 3, + currency: currency.USD, + expected: "-221 123 456,564 USD", + }, + { + num: -221123456.5643, + v: 3, + currency: currency.CAD, + expected: "-221 123 456,564 CAD", + }, + { + num: -0, + v: 2, + currency: currency.USD, + expected: "0,00 USD", + }, + { + num: -0, + v: 2, + currency: currency.CAD, + expected: "0,00 CAD", + }, + { + num: 1.23, + v: 0, + currency: currency.USD, + expected: "1,00 USD", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + { + num: 15, + v: 0, + expected: "15%", + }, + { + num: 15, + v: 2, + expected: "15,00%", + }, + { + num: 434.45, + v: 0, + expected: "434%", + }, + { + num: 34.4, + v: 2, + expected: "34,40%", + }, + { + num: -34, + v: 0, + expected: "-34%", + }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ru_UA/ru_UA.go b/vendor/github.com/go-playground/locales/ru_UA/ru_UA.go new file mode 100644 index 0000000000..11a5791675 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_UA/ru_UA.go @@ -0,0 +1,647 @@ +package ru_UA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ru_UA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ru_UA' locale +func New() locales.Translator { + return &ru_UA{ + locale: "ru_UA", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв.", "февр.", "мар.", "апр.", "мая", "июн.", "июл.", "авг.", "сент.", "окт.", "нояб.", "дек."}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"}, + daysAbbreviated: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysShort: []string{"вс", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"до н. э.", "н. э."}, + erasNarrow: []string{"до н.э.", "н.э."}, + erasWide: []string{"до Рождества Христова", "от Рождества Христова"}, + timezones: map[string]string{"BT": "Бутан", "GFT": "Французская Гвиана", "AKST": "Аляска, стандартное время", "TMT": "Туркмения, стандартное время", "ART": "Аргентина, стандартное время", "ARST": "Аргентина, летнее время", "HKT": "Гонконг, стандартное время", "EAT": "Восточная Африка", "OEZ": "Восточная Европа, стандартное время", "WAST": "Западная Африка, летнее время", "WESZ": "Западная Европа, летнее время", "HNEG": "Восточная Гренландия, стандарное время", "BOT": "Боливия", "CAT": "Центральная Африка", "AST": "Атлантическое стандартное время", "WIB": "Западная Индонезия", "AWST": "Западная Австралия, стандартное время", "AWDT": "Западная Австралия, летнее время", "NZDT": "Новая Зеландия, летнее время", "WART": "Западная Аргентина, стандартное время", "ChST": "Чаморро", "SAST": "Южная Африка", "HEPMX": "Тихоокеанское мексиканское летнее время", "WIT": "Восточная Индонезия", "HAST": "Гавайско-алеутское стандартное время", "ECT": "Эквадор", "MYT": "Малайзия", "HNPM": "Сен-Пьер и Микелон, стандартное время", "∅∅∅": "Азорские о-ва, летнее время", "HECU": "Куба, летнее время", "HKST": "Гонконг, летнее время", "HNT": "Ньюфаундленд, стандартное время", "HNCU": "Куба, стандартное время", "SGT": "Сингапур", "PDT": "Тихоокеанское летнее время", "LHDT": "Лорд-Хау, летнее время", "WEZ": "Западная Европа, стандартное время", "TMST": "Туркмения, летнее время", "HNPMX": "Тихоокеанское мексиканское стандартное время", "EST": "Восточная Америка, стандартное время", "COT": "Колумбия, стандартное время", "ACST": "Центральная Австралия, стандартное время", "HENOMX": "Северо-западное мексиканское летнее время", "HEEG": "Восточная Гренландия, летнее время", "AEDT": "Восточная Австралия, летнее время", "PST": "Тихоокеанское стандартное время", "NZST": "Новая Зеландия, стандартное время", "EDT": "Восточная Америка, летнее время", "IST": "Индия", "ACWST": "Центральная Австралия, западное стандартное время", "JST": "Япония, стандартное время", "HNOG": "Западная Гренландия, стандартное время", "HEOG": "Западная Гренландия, летнее время", "UYST": "Уругвай, летнее время", "LHST": "Лорд-Хау, стандартное время", "CHAST": "Чатем, стандартное время", "WARST": "Западная Аргентина, летнее время", "MST": "Макао, стандартное время", "HAT": "Ньюфаундленд, летнее время", "ACWDT": "Центральная Австралия, западное летнее время", "COST": "Колумбия, летнее время", "SRT": "Суринам", "CST": "Центральная Америка, стандартное время", "CDT": "Центральная Америка, летнее время", "AEST": "Восточная Австралия, стандартное время", "CHADT": "Чатем, летнее время", "JDT": "Япония, летнее время", "MDT": "Макао, летнее время", "CLT": "Чили, стандартное время", "OESZ": "Восточная Европа, летнее время", "AKDT": "Аляска, летнее время", "GYT": "Гайана", "HADT": "Гавайско-алеутское летнее время", "MEZ": "Центральная Европа, стандартное время", "WAT": "Западная Африка, стандартное время", "ACDT": "Центральная Австралия, летнее время", "HNNOMX": "Северо-западное мексиканское стандартное время", "WITA": "Центральная Индонезия", "UYT": "Уругвай, стандартное время", "MESZ": "Центральная Европа, летнее время", "CLST": "Чили, летнее время", "GMT": "Среднее время по Гринвичу", "HEPM": "Сен-Пьер и Микелон, летнее время", "VET": "Венесуэла", "ADT": "Атлантическое летнее время"}, + } +} + +// Locale returns the current translators string locale +func (ru *ru_UA) Locale() string { + return ru.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ru_UA' +func (ru *ru_UA) PluralsCardinal() []locales.PluralRule { + return ru.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ru_UA' +func (ru *ru_UA) PluralsOrdinal() []locales.PluralRule { + return ru.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ru_UA' +func (ru *ru_UA) PluralsRange() []locales.PluralRule { + return ru.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ru_UA' +func (ru *ru_UA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ru_UA' +func (ru *ru_UA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ru_UA' +func (ru *ru_UA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ru.CardinalPluralRule(num1, v1) + end := ru.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ru *ru_UA) MonthAbbreviated(month time.Month) string { + return ru.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ru *ru_UA) MonthsAbbreviated() []string { + return ru.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ru *ru_UA) MonthNarrow(month time.Month) string { + return ru.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ru *ru_UA) MonthsNarrow() []string { + return ru.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ru *ru_UA) MonthWide(month time.Month) string { + return ru.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ru *ru_UA) MonthsWide() []string { + return ru.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ru *ru_UA) WeekdayAbbreviated(weekday time.Weekday) string { + return ru.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ru *ru_UA) WeekdaysAbbreviated() []string { + return ru.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ru *ru_UA) WeekdayNarrow(weekday time.Weekday) string { + return ru.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ru *ru_UA) WeekdaysNarrow() []string { + return ru.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ru *ru_UA) WeekdayShort(weekday time.Weekday) string { + return ru.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ru *ru_UA) WeekdaysShort() []string { + return ru.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ru *ru_UA) WeekdayWide(weekday time.Weekday) string { + return ru.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ru *ru_UA) WeekdaysWide() []string { + return ru.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ru_UA' and handles both Whole and Real numbers based on 'v' +func (ru *ru_UA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ru_UA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ru *ru_UA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ru.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ru_UA' +func (ru *ru_UA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ru.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, ru.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ru_UA' +// in accounting notation. +func (ru *ru_UA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ru.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ru.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ru.group) - 1; j >= 0; j-- { + b = append(b, ru.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ru.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ru.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ru.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, ru.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ru_UA' +func (ru *ru_UA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ru_UA' +func (ru *ru_UA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ru_UA' +func (ru *ru_UA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ru_UA' +func (ru *ru_UA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ru.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ru.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd0, 0xb3}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ru_UA' +func (ru *ru_UA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ru_UA' +func (ru *ru_UA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ru_UA' +func (ru *ru_UA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ru_UA' +func (ru *ru_UA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ru.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ru.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ru.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ru_UA/ru_UA_test.go b/vendor/github.com/go-playground/locales/ru_UA/ru_UA_test.go new file mode 100644 index 0000000000..1c4c07eb9d --- /dev/null +++ b/vendor/github.com/go-playground/locales/ru_UA/ru_UA_test.go @@ -0,0 +1,1120 @@ +package ru_UA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ru_UA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rules.go b/vendor/github.com/go-playground/locales/rules.go new file mode 100644 index 0000000000..9202900149 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rules.go @@ -0,0 +1,293 @@ +package locales + +import ( + "strconv" + "time" + + "github.com/go-playground/locales/currency" +) + +// // ErrBadNumberValue is returned when the number passed for +// // plural rule determination cannot be parsed +// type ErrBadNumberValue struct { +// NumberValue string +// InnerError error +// } + +// // Error returns ErrBadNumberValue error string +// func (e *ErrBadNumberValue) Error() string { +// return fmt.Sprintf("Invalid Number Value '%s' %s", e.NumberValue, e.InnerError) +// } + +// var _ error = new(ErrBadNumberValue) + +// PluralRule denotes the type of plural rules +type PluralRule int + +// PluralRule's +const ( + PluralRuleUnknown PluralRule = iota + PluralRuleZero // zero + PluralRuleOne // one - singular + PluralRuleTwo // two - dual + PluralRuleFew // few - paucal + PluralRuleMany // many - also used for fractions if they have a separate class + PluralRuleOther // other - required—general plural form—also used if the language only has a single form +) + +const ( + pluralsString = "UnknownZeroOneTwoFewManyOther" +) + +// Translator encapsulates an instance of a locale +// NOTE: some values are returned as a []byte just in case the caller +// wishes to add more and can help avoid allocations; otherwise just cast as string +type Translator interface { + + // The following Functions are for overriding, debugging or developing + // with a Translator Locale + + // Locale returns the string value of the translator + Locale() string + + // returns an array of cardinal plural rules associated + // with this translator + PluralsCardinal() []PluralRule + + // returns an array of ordinal plural rules associated + // with this translator + PluralsOrdinal() []PluralRule + + // returns an array of range plural rules associated + // with this translator + PluralsRange() []PluralRule + + // returns the cardinal PluralRule given 'num' and digits/precision of 'v' for locale + CardinalPluralRule(num float64, v uint64) PluralRule + + // returns the ordinal PluralRule given 'num' and digits/precision of 'v' for locale + OrdinalPluralRule(num float64, v uint64) PluralRule + + // returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for locale + RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) PluralRule + + // returns the locales abbreviated month given the 'month' provided + MonthAbbreviated(month time.Month) string + + // returns the locales abbreviated months + MonthsAbbreviated() []string + + // returns the locales narrow month given the 'month' provided + MonthNarrow(month time.Month) string + + // returns the locales narrow months + MonthsNarrow() []string + + // returns the locales wide month given the 'month' provided + MonthWide(month time.Month) string + + // returns the locales wide months + MonthsWide() []string + + // returns the locales abbreviated weekday given the 'weekday' provided + WeekdayAbbreviated(weekday time.Weekday) string + + // returns the locales abbreviated weekdays + WeekdaysAbbreviated() []string + + // returns the locales narrow weekday given the 'weekday' provided + WeekdayNarrow(weekday time.Weekday) string + + // WeekdaysNarrowreturns the locales narrow weekdays + WeekdaysNarrow() []string + + // returns the locales short weekday given the 'weekday' provided + WeekdayShort(weekday time.Weekday) string + + // returns the locales short weekdays + WeekdaysShort() []string + + // returns the locales wide weekday given the 'weekday' provided + WeekdayWide(weekday time.Weekday) string + + // returns the locales wide weekdays + WeekdaysWide() []string + + // The following Functions are common Formatting functionsfor the Translator's Locale + + // returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v' + FmtNumber(num float64, v uint64) string + + // returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v' + // NOTE: 'num' passed into FmtPercent is assumed to be in percent already + FmtPercent(num float64, v uint64) string + + // returns the currency representation of 'num' with digits/precision of 'v' for locale + FmtCurrency(num float64, v uint64, currency currency.Type) string + + // returns the currency representation of 'num' with digits/precision of 'v' for locale + // in accounting notation. + FmtAccounting(num float64, v uint64, currency currency.Type) string + + // returns the short date representation of 't' for locale + FmtDateShort(t time.Time) string + + // returns the medium date representation of 't' for locale + FmtDateMedium(t time.Time) string + + // returns the long date representation of 't' for locale + FmtDateLong(t time.Time) string + + // returns the full date representation of 't' for locale + FmtDateFull(t time.Time) string + + // returns the short time representation of 't' for locale + FmtTimeShort(t time.Time) string + + // returns the medium time representation of 't' for locale + FmtTimeMedium(t time.Time) string + + // returns the long time representation of 't' for locale + FmtTimeLong(t time.Time) string + + // returns the full time representation of 't' for locale + FmtTimeFull(t time.Time) string +} + +// String returns the string value of PluralRule +func (p PluralRule) String() string { + + switch p { + case PluralRuleZero: + return pluralsString[7:11] + case PluralRuleOne: + return pluralsString[11:14] + case PluralRuleTwo: + return pluralsString[14:17] + case PluralRuleFew: + return pluralsString[17:20] + case PluralRuleMany: + return pluralsString[20:24] + case PluralRuleOther: + return pluralsString[24:] + default: + return pluralsString[:7] + } +} + +// +// Precision Notes: +// +// must specify a precision >= 0, and here is why https://play.golang.org/p/LyL90U0Vyh +// +// v := float64(3.141) +// i := float64(int64(v)) +// +// fmt.Println(v - i) +// +// or +// +// s := strconv.FormatFloat(v-i, 'f', -1, 64) +// fmt.Println(s) +// +// these will not print what you'd expect: 0.14100000000000001 +// and so this library requires a precision to be specified, or +// inaccurate plural rules could be applied. +// +// +// +// n - absolute value of the source number (integer and decimals). +// i - integer digits of n. +// v - number of visible fraction digits in n, with trailing zeros. +// w - number of visible fraction digits in n, without trailing zeros. +// f - visible fractional digits in n, with trailing zeros. +// t - visible fractional digits in n, without trailing zeros. +// +// +// Func(num float64, v uint64) // v = digits/precision and prevents -1 as a special case as this can lead to very unexpected behaviour, see precision note's above. +// +// n := math.Abs(num) +// i := int64(n) +// v := v +// +// +// w := strconv.FormatFloat(num-float64(i), 'f', int(v), 64) // then parse backwards on string until no more zero's.... +// f := strconv.FormatFloat(n, 'f', int(v), 64) // then turn everything after decimal into an int64 +// t := strconv.FormatFloat(n, 'f', int(v), 64) // then parse backwards on string until no more zero's.... +// +// +// +// General Inclusion Rules +// - v will always be available inherently +// - all require n +// - w requires i +// + +// W returns the number of visible fraction digits in N, without trailing zeros. +func W(n float64, v uint64) (w int64) { + + s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64) + + // with either be '0' or '0.xxxx', so if 1 then w will be zero + // otherwise need to parse + if len(s) != 1 { + + s = s[2:] + end := len(s) + 1 + + for i := end; i >= 0; i-- { + if s[i] != '0' { + end = i + 1 + break + } + } + + w = int64(len(s[:end])) + } + + return +} + +// F returns the visible fractional digits in N, with trailing zeros. +func F(n float64, v uint64) (f int64) { + + s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64) + + // with either be '0' or '0.xxxx', so if 1 then f will be zero + // otherwise need to parse + if len(s) != 1 { + + // ignoring error, because it can't fail as we generated + // the string internally from a real number + f, _ = strconv.ParseInt(s[2:], 10, 64) + } + + return +} + +// T returns the visible fractional digits in N, without trailing zeros. +func T(n float64, v uint64) (t int64) { + + s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64) + + // with either be '0' or '0.xxxx', so if 1 then t will be zero + // otherwise need to parse + if len(s) != 1 { + + s = s[2:] + end := len(s) + 1 + + for i := end; i >= 0; i-- { + if s[i] != '0' { + end = i + 1 + break + } + } + + // ignoring error, because it can't fail as we generated + // the string internally from a real number + t, _ = strconv.ParseInt(s[:end], 10, 64) + } + + return +} diff --git a/vendor/github.com/go-playground/locales/rw/rw.go b/vendor/github.com/go-playground/locales/rw/rw.go new file mode 100644 index 0000000000..c83fa2f576 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rw/rw.go @@ -0,0 +1,595 @@ +package rw + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rw struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rw' locale +func New() locales.Translator { + return &rw{ + locale: "rw", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "mut.", "gas.", "wer.", "mat.", "gic.", "kam.", "nya.", "kan.", "nze.", "ukw.", "ugu.", "uku."}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Mutarama", "Gashyantare", "Werurwe", "Mata", "Gicuransi", "Kamena", "Nyakanga", "Kanama", "Nzeli", "Ukwakira", "Ugushyingo", "Ukuboza"}, + daysAbbreviated: []string{"cyu.", "mbe.", "kab.", "gtu.", "kan.", "gnu.", "gnd."}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"cyu.", "mbe.", "kab.", "gtu.", "kan.", "gnu.", "gnd."}, + daysWide: []string{"Ku cyumweru", "Kuwa mbere", "Kuwa kabiri", "Kuwa gatatu", "Kuwa kane", "Kuwa gatanu", "Kuwa gatandatu"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"BCE", "CE"}, + timezones: map[string]string{"ECT": "ECT", "WARST": "WARST", "UYST": "UYST", "HNPMX": "HNPMX", "EAT": "EAT", "CST": "CST", "ACWST": "ACWST", "WAST": "WAST", "EDT": "EDT", "ACDT": "ACDT", "NZDT": "NZDT", "VET": "VET", "AST": "AST", "ADT": "ADT", "WEZ": "WEZ", "WESZ": "WESZ", "ACST": "ACST", "GFT": "GFT", "WITA": "WITA", "GYT": "GYT", "CHADT": "CHADT", "GMT": "GMT", "MYT": "MYT", "TMST": "TMST", "ACWDT": "ACWDT", "CLST": "CLST", "HEOG": "HEOG", "EST": "EST", "ChST": "ChST", "SAST": "SAST", "SRT": "SRT", "BOT": "BOT", "HNT": "HNT", "JST": "JST", "ART": "ART", "HKST": "HKST", "BT": "BT", "HAT": "HAT", "HNEG": "HNEG", "UYT": "UYT", "LHDT": "LHDT", "CHAST": "CHAST", "OEZ": "OEZ", "HNNOMX": "HNNOMX", "HNPM": "HNPM", "OESZ": "OESZ", "COST": "COST", "AEST": "AEST", "IST": "IST", "∅∅∅": "∅∅∅", "MEZ": "MEZ", "CLT": "CLT", "MST": "MST", "HKT": "HKT", "AWST": "AWST", "PST": "PST", "MDT": "MDT", "HEPM": "HEPM", "HEPMX": "HEPMX", "HNCU": "HNCU", "WIT": "WIT", "SGT": "SGT", "NZST": "NZST", "HNOG": "HNOG", "WAT": "WAT", "AEDT": "AEDT", "LHST": "LHST", "WIB": "WIB", "AWDT": "AWDT", "CAT": "CAT", "MESZ": "MESZ", "JDT": "JDT", "WART": "WART", "TMT": "TMT", "COT": "COT", "HENOMX": "HENOMX", "HEEG": "HEEG", "ARST": "ARST", "HECU": "HECU", "CDT": "CDT", "PDT": "PDT", "HAST": "HAST", "HADT": "HADT", "AKST": "AKST", "AKDT": "AKDT"}, + } +} + +// Locale returns the current translators string locale +func (rw *rw) Locale() string { + return rw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rw' +func (rw *rw) PluralsCardinal() []locales.PluralRule { + return rw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rw' +func (rw *rw) PluralsOrdinal() []locales.PluralRule { + return rw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rw' +func (rw *rw) PluralsRange() []locales.PluralRule { + return rw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rw' +func (rw *rw) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rw' +func (rw *rw) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rw' +func (rw *rw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rw *rw) MonthAbbreviated(month time.Month) string { + return rw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rw *rw) MonthsAbbreviated() []string { + return rw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rw *rw) MonthNarrow(month time.Month) string { + return rw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rw *rw) MonthsNarrow() []string { + return rw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rw *rw) MonthWide(month time.Month) string { + return rw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rw *rw) MonthsWide() []string { + return rw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rw *rw) WeekdayAbbreviated(weekday time.Weekday) string { + return rw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rw *rw) WeekdaysAbbreviated() []string { + return rw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rw *rw) WeekdayNarrow(weekday time.Weekday) string { + return rw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rw *rw) WeekdaysNarrow() []string { + return rw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rw *rw) WeekdayShort(weekday time.Weekday) string { + return rw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rw *rw) WeekdaysShort() []string { + return rw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rw *rw) WeekdayWide(weekday time.Weekday) string { + return rw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rw *rw) WeekdaysWide() []string { + return rw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rw' and handles both Whole and Real numbers based on 'v' +func (rw *rw) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rw' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rw *rw) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, rw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rw' +func (rw *rw) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(rw.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, rw.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, rw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rw' +// in accounting notation. +func (rw *rw) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(rw.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, rw.currencyNegativePrefix[j]) + } + + b = append(b, rw.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(rw.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, rw.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rw' +func (rw *rw) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rw' +func (rw *rw) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, rw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rw' +func (rw *rw) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, rw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rw' +func (rw *rw) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, rw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, rw.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rw' +func (rw *rw) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rw' +func (rw *rw) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rw' +func (rw *rw) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rw' +func (rw *rw) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rw/rw_test.go b/vendor/github.com/go-playground/locales/rw/rw_test.go new file mode 100644 index 0000000000..4dae61cbe4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rw/rw_test.go @@ -0,0 +1,1120 @@ +package rw + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rw" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rw_RW/rw_RW.go b/vendor/github.com/go-playground/locales/rw_RW/rw_RW.go new file mode 100644 index 0000000000..2f10cee3f7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rw_RW/rw_RW.go @@ -0,0 +1,595 @@ +package rw_RW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rw_RW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rw_RW' locale +func New() locales.Translator { + return &rw_RW{ + locale: "rw_RW", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "mut.", "gas.", "wer.", "mat.", "gic.", "kam.", "nya.", "kan.", "nze.", "ukw.", "ugu.", "uku."}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Mutarama", "Gashyantare", "Werurwe", "Mata", "Gicuransi", "Kamena", "Nyakanga", "Kanama", "Nzeli", "Ukwakira", "Ugushyingo", "Ukuboza"}, + daysAbbreviated: []string{"cyu.", "mbe.", "kab.", "gtu.", "kan.", "gnu.", "gnd."}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"cyu.", "mbe.", "kab.", "gtu.", "kan.", "gnu.", "gnd."}, + daysWide: []string{"Ku cyumweru", "Kuwa mbere", "Kuwa kabiri", "Kuwa gatatu", "Kuwa kane", "Kuwa gatanu", "Kuwa gatandatu"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BCE", "CE"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"BCE", "CE"}, + timezones: map[string]string{"AWST": "AWST", "NZDT": "NZDT", "MESZ": "MESZ", "ADT": "ADT", "WAST": "WAST", "CST": "CST", "WIB": "WIB", "NZST": "NZST", "UYT": "UYT", "PST": "PST", "CAT": "CAT", "IST": "IST", "CLT": "CLT", "HEOG": "HEOG", "HKT": "HKT", "AKST": "AKST", "GMT": "GMT", "HNOG": "HNOG", "HAT": "HAT", "HEEG": "HEEG", "AEST": "AEST", "UYST": "UYST", "SAST": "SAST", "MST": "MST", "ChST": "ChST", "CDT": "CDT", "AWDT": "AWDT", "WAT": "WAT", "MDT": "MDT", "HADT": "HADT", "VET": "VET", "MYT": "MYT", "OEZ": "OEZ", "OESZ": "OESZ", "ECT": "ECT", "WARST": "WARST", "EDT": "EDT", "BT": "BT", "HNT": "HNT", "∅∅∅": "∅∅∅", "HEPMX": "HEPMX", "CHAST": "CHAST", "CHADT": "CHADT", "PDT": "PDT", "HAST": "HAST", "EST": "EST", "HEPM": "HEPM", "AKDT": "AKDT", "WESZ": "WESZ", "ARST": "ARST", "COT": "COT", "COST": "COST", "AEDT": "AEDT", "CLST": "CLST", "MEZ": "MEZ", "HNPM": "HNPM", "ACWDT": "ACWDT", "HENOMX": "HENOMX", "WITA": "WITA", "HECU": "HECU", "WIT": "WIT", "JDT": "JDT", "HNNOMX": "HNNOMX", "HNPMX": "HNPMX", "EAT": "EAT", "WEZ": "WEZ", "ACDT": "ACDT", "SRT": "SRT", "LHDT": "LHDT", "GYT": "GYT", "HNCU": "HNCU", "BOT": "BOT", "ACWST": "ACWST", "TMT": "TMT", "TMST": "TMST", "LHST": "LHST", "ACST": "ACST", "HKST": "HKST", "SGT": "SGT", "JST": "JST", "WART": "WART", "AST": "AST", "ART": "ART", "HNEG": "HNEG", "GFT": "GFT"}, + } +} + +// Locale returns the current translators string locale +func (rw *rw_RW) Locale() string { + return rw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rw_RW' +func (rw *rw_RW) PluralsCardinal() []locales.PluralRule { + return rw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rw_RW' +func (rw *rw_RW) PluralsOrdinal() []locales.PluralRule { + return rw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rw_RW' +func (rw *rw_RW) PluralsRange() []locales.PluralRule { + return rw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rw_RW' +func (rw *rw_RW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rw_RW' +func (rw *rw_RW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rw_RW' +func (rw *rw_RW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rw *rw_RW) MonthAbbreviated(month time.Month) string { + return rw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rw *rw_RW) MonthsAbbreviated() []string { + return rw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rw *rw_RW) MonthNarrow(month time.Month) string { + return rw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rw *rw_RW) MonthsNarrow() []string { + return rw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rw *rw_RW) MonthWide(month time.Month) string { + return rw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rw *rw_RW) MonthsWide() []string { + return rw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rw *rw_RW) WeekdayAbbreviated(weekday time.Weekday) string { + return rw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rw *rw_RW) WeekdaysAbbreviated() []string { + return rw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rw *rw_RW) WeekdayNarrow(weekday time.Weekday) string { + return rw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rw *rw_RW) WeekdaysNarrow() []string { + return rw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rw *rw_RW) WeekdayShort(weekday time.Weekday) string { + return rw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rw *rw_RW) WeekdaysShort() []string { + return rw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rw *rw_RW) WeekdayWide(weekday time.Weekday) string { + return rw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rw *rw_RW) WeekdaysWide() []string { + return rw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rw_RW' and handles both Whole and Real numbers based on 'v' +func (rw *rw_RW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rw_RW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rw *rw_RW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, rw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rw_RW' +func (rw *rw_RW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(rw.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, rw.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, rw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rw_RW' +// in accounting notation. +func (rw *rw_RW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(rw.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, rw.currencyNegativePrefix[j]) + } + + b = append(b, rw.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(rw.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, rw.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rw_RW' +func (rw *rw_RW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rw_RW' +func (rw *rw_RW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, rw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rw_RW' +func (rw *rw_RW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, rw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rw_RW' +func (rw *rw_RW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, rw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, rw.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rw_RW' +func (rw *rw_RW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rw_RW' +func (rw *rw_RW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rw_RW' +func (rw *rw_RW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rw_RW' +func (rw *rw_RW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rw_RW/rw_RW_test.go b/vendor/github.com/go-playground/locales/rw_RW/rw_RW_test.go new file mode 100644 index 0000000000..5556fab39c --- /dev/null +++ b/vendor/github.com/go-playground/locales/rw_RW/rw_RW_test.go @@ -0,0 +1,1120 @@ +package rw_RW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rw_RW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rwk/rwk.go b/vendor/github.com/go-playground/locales/rwk/rwk.go new file mode 100644 index 0000000000..4ff56d846f --- /dev/null +++ b/vendor/github.com/go-playground/locales/rwk/rwk.go @@ -0,0 +1,512 @@ +package rwk + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rwk struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rwk' locale +func New() locales.Translator { + return &rwk{ + locale: "rwk", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprilyi", "Mei", "Junyi", "Julyai", "Agusti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Jumapilyi", "Jumatatuu", "Jumanne", "Jumatanu", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"utuko", "kyiukonyi"}, + periodsWide: []string{"utuko", "kyiukonyi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristu", "Baada ya Kristu"}, + timezones: map[string]string{"AKDT": "AKDT", "ACWST": "ACWST", "VET": "VET", "WARST": "WARST", "HNOG": "HNOG", "MDT": "MDT", "HEEG": "HEEG", "PDT": "PDT", "MEZ": "MEZ", "MST": "MST", "UYT": "UYT", "WIT": "WIT", "AWST": "AWST", "HAST": "HAST", "WEZ": "WEZ", "ART": "ART", "HAT": "HAT", "WITA": "WITA", "WIB": "WIB", "ECT": "ECT", "JDT": "JDT", "COT": "COT", "HNT": "HNT", "HNPM": "HNPM", "BOT": "BOT", "MYT": "MYT", "HNNOMX": "HNNOMX", "AKST": "AKST", "AEST": "AEST", "AEDT": "AEDT", "PST": "PST", "HADT": "HADT", "HEPM": "HEPM", "SAST": "SAST", "GYT": "GYT", "AWDT": "AWDT", "IST": "IST", "EDT": "EDT", "HKT": "HKT", "GMT": "GMT", "HEPMX": "HEPMX", "CAT": "CAT", "JST": "JST", "ARST": "ARST", "HKST": "HKST", "BT": "BT", "HNPMX": "HNPMX", "SRT": "SRT", "CST": "CST", "MESZ": "MESZ", "CLT": "CLT", "HEOG": "HEOG", "AST": "AST", "ADT": "ADT", "TMST": "TMST", "ACST": "ACST", "ACDT": "ACDT", "CHADT": "CHADT", "SGT": "SGT", "NZST": "NZST", "CLST": "CLST", "OEZ": "OEZ", "WAST": "WAST", "WART": "WART", "HENOMX": "HENOMX", "LHST": "LHST", "LHDT": "LHDT", "EAT": "EAT", "ACWDT": "ACWDT", "EST": "EST", "ChST": "ChST", "UYST": "UYST", "CDT": "CDT", "COST": "COST", "HNCU": "HNCU", "CHAST": "CHAST", "∅∅∅": "∅∅∅", "NZDT": "NZDT", "OESZ": "OESZ", "WESZ": "WESZ", "TMT": "TMT", "WAT": "WAT", "HNEG": "HNEG", "GFT": "GFT", "HECU": "HECU"}, + } +} + +// Locale returns the current translators string locale +func (rwk *rwk) Locale() string { + return rwk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rwk' +func (rwk *rwk) PluralsCardinal() []locales.PluralRule { + return rwk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rwk' +func (rwk *rwk) PluralsOrdinal() []locales.PluralRule { + return rwk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rwk' +func (rwk *rwk) PluralsRange() []locales.PluralRule { + return rwk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rwk' +func (rwk *rwk) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rwk' +func (rwk *rwk) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rwk' +func (rwk *rwk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rwk *rwk) MonthAbbreviated(month time.Month) string { + return rwk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rwk *rwk) MonthsAbbreviated() []string { + return rwk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rwk *rwk) MonthNarrow(month time.Month) string { + return rwk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rwk *rwk) MonthsNarrow() []string { + return rwk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rwk *rwk) MonthWide(month time.Month) string { + return rwk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rwk *rwk) MonthsWide() []string { + return rwk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rwk *rwk) WeekdayAbbreviated(weekday time.Weekday) string { + return rwk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rwk *rwk) WeekdaysAbbreviated() []string { + return rwk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rwk *rwk) WeekdayNarrow(weekday time.Weekday) string { + return rwk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rwk *rwk) WeekdaysNarrow() []string { + return rwk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rwk *rwk) WeekdayShort(weekday time.Weekday) string { + return rwk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rwk *rwk) WeekdaysShort() []string { + return rwk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rwk *rwk) WeekdayWide(weekday time.Weekday) string { + return rwk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rwk *rwk) WeekdaysWide() []string { + return rwk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rwk' and handles both Whole and Real numbers based on 'v' +func (rwk *rwk) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rwk' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rwk *rwk) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rwk' +func (rwk *rwk) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rwk.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rwk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rwk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rwk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rwk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rwk' +// in accounting notation. +func (rwk *rwk) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rwk.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rwk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rwk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, rwk.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rwk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rwk' +func (rwk *rwk) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rwk' +func (rwk *rwk) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rwk.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rwk' +func (rwk *rwk) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rwk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rwk' +func (rwk *rwk) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, rwk.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rwk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rwk' +func (rwk *rwk) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rwk' +func (rwk *rwk) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rwk' +func (rwk *rwk) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rwk' +func (rwk *rwk) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rwk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rwk/rwk_test.go b/vendor/github.com/go-playground/locales/rwk/rwk_test.go new file mode 100644 index 0000000000..f84387f748 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rwk/rwk_test.go @@ -0,0 +1,1120 @@ +package rwk + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rwk" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/rwk_TZ/rwk_TZ.go b/vendor/github.com/go-playground/locales/rwk_TZ/rwk_TZ.go new file mode 100644 index 0000000000..5051f56464 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rwk_TZ/rwk_TZ.go @@ -0,0 +1,512 @@ +package rwk_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type rwk_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'rwk_TZ' locale +func New() locales.Translator { + return &rwk_TZ{ + locale: "rwk_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprilyi", "Mei", "Junyi", "Julyai", "Agusti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Jumapilyi", "Jumatatuu", "Jumanne", "Jumatanu", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"utuko", "kyiukonyi"}, + periodsWide: []string{"utuko", "kyiukonyi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristu", "Baada ya Kristu"}, + timezones: map[string]string{"JST": "JST", "WAST": "WAST", "AKDT": "AKDT", "ChST": "ChST", "HNPM": "HNPM", "HEPM": "HEPM", "HNPMX": "HNPMX", "HECU": "HECU", "∅∅∅": "∅∅∅", "WEZ": "WEZ", "TMST": "TMST", "WITA": "WITA", "SAST": "SAST", "ECT": "ECT", "ACST": "ACST", "COST": "COST", "UYST": "UYST", "CHADT": "CHADT", "PST": "PST", "HAST": "HAST", "CAT": "CAT", "JDT": "JDT", "MST": "MST", "HAT": "HAT", "HADT": "HADT", "WESZ": "WESZ", "TMT": "TMT", "HKST": "HKST", "AEDT": "AEDT", "CHAST": "CHAST", "VET": "VET", "HNNOMX": "HNNOMX", "WIB": "WIB", "CST": "CST", "NZDT": "NZDT", "CLT": "CLT", "ART": "ART", "EST": "EST", "AEST": "AEST", "GYT": "GYT", "MESZ": "MESZ", "AWST": "AWST", "MEZ": "MEZ", "OEZ": "OEZ", "EDT": "EDT", "UYT": "UYT", "HEPMX": "HEPMX", "CDT": "CDT", "SGT": "SGT", "ACWDT": "ACWDT", "NZST": "NZST", "WARST": "WARST", "LHDT": "LHDT", "PDT": "PDT", "IST": "IST", "HNOG": "HNOG", "ADT": "ADT", "WART": "WART", "SRT": "SRT", "EAT": "EAT", "OESZ": "OESZ", "COT": "COT", "HENOMX": "HENOMX", "HNCU": "HNCU", "WIT": "WIT", "ACWST": "ACWST", "MYT": "MYT", "CLST": "CLST", "HKT": "HKT", "HNT": "HNT", "GFT": "GFT", "AST": "AST", "ACDT": "ACDT", "BT": "BT", "HEEG": "HEEG", "AWDT": "AWDT", "HEOG": "HEOG", "GMT": "GMT", "MDT": "MDT", "WAT": "WAT", "HNEG": "HNEG", "AKST": "AKST", "BOT": "BOT", "ARST": "ARST", "LHST": "LHST"}, + } +} + +// Locale returns the current translators string locale +func (rwk *rwk_TZ) Locale() string { + return rwk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'rwk_TZ' +func (rwk *rwk_TZ) PluralsCardinal() []locales.PluralRule { + return rwk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'rwk_TZ' +func (rwk *rwk_TZ) PluralsOrdinal() []locales.PluralRule { + return rwk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'rwk_TZ' +func (rwk *rwk_TZ) PluralsRange() []locales.PluralRule { + return rwk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'rwk_TZ' +func (rwk *rwk_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'rwk_TZ' +func (rwk *rwk_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'rwk_TZ' +func (rwk *rwk_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (rwk *rwk_TZ) MonthAbbreviated(month time.Month) string { + return rwk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (rwk *rwk_TZ) MonthsAbbreviated() []string { + return rwk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (rwk *rwk_TZ) MonthNarrow(month time.Month) string { + return rwk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (rwk *rwk_TZ) MonthsNarrow() []string { + return rwk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (rwk *rwk_TZ) MonthWide(month time.Month) string { + return rwk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (rwk *rwk_TZ) MonthsWide() []string { + return rwk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (rwk *rwk_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return rwk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (rwk *rwk_TZ) WeekdaysAbbreviated() []string { + return rwk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (rwk *rwk_TZ) WeekdayNarrow(weekday time.Weekday) string { + return rwk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (rwk *rwk_TZ) WeekdaysNarrow() []string { + return rwk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (rwk *rwk_TZ) WeekdayShort(weekday time.Weekday) string { + return rwk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (rwk *rwk_TZ) WeekdaysShort() []string { + return rwk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (rwk *rwk_TZ) WeekdayWide(weekday time.Weekday) string { + return rwk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (rwk *rwk_TZ) WeekdaysWide() []string { + return rwk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'rwk_TZ' and handles both Whole and Real numbers based on 'v' +func (rwk *rwk_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'rwk_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (rwk *rwk_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rwk.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rwk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rwk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, rwk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rwk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'rwk_TZ' +// in accounting notation. +func (rwk *rwk_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := rwk.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, rwk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, rwk.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, rwk.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, rwk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rwk.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rwk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, rwk.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, rwk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'rwk_TZ' +func (rwk *rwk_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, rwk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := rwk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/rwk_TZ/rwk_TZ_test.go b/vendor/github.com/go-playground/locales/rwk_TZ/rwk_TZ_test.go new file mode 100644 index 0000000000..ec16107479 --- /dev/null +++ b/vendor/github.com/go-playground/locales/rwk_TZ/rwk_TZ_test.go @@ -0,0 +1,1120 @@ +package rwk_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "rwk_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sah/sah.go b/vendor/github.com/go-playground/locales/sah/sah.go new file mode 100644 index 0000000000..695a965609 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sah/sah.go @@ -0,0 +1,579 @@ +package sah + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sah struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sah' locale +func New() locales.Translator { + return &sah{ + locale: "sah", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "₽", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Тохс", "Олун", "Клн", "Мсу", "Ыам", "Бэс", "Отй", "Атр", "Блҕ", "Алт", "Сэт", "Ахс"}, + monthsNarrow: []string{"", "Т", "О", "К", "М", "Ы", "Б", "О", "А", "Б", "А", "С", "А"}, + monthsWide: []string{"", "Тохсунньу", "Олунньу", "Кулун тутар", "Муус устар", "Ыам ыйын", "Бэс ыйын", "От ыйын", "Атырдьых ыйын", "Балаҕан ыйын", "Алтынньы", "Сэтинньи", "ахсынньы"}, + daysAbbreviated: []string{"бс", "бн", "оп", "сэ", "чп", "бэ", "сб"}, + daysNarrow: []string{"Б", "Б", "О", "С", "Ч", "Б", "С"}, + daysShort: []string{"бс", "бн", "оп", "сэ", "чп", "бэ", "сб"}, + daysWide: []string{"баскыһыанньа", "бэнидиэнньик", "оптуорунньук", "сэрэдэ", "чэппиэр", "Бээтиҥсэ", "субуота"}, + periodsAbbreviated: []string{"ЭИ", "ЭК"}, + periodsNarrow: []string{"ЭИ", "ЭК"}, + periodsWide: []string{"ЭИ", "ЭК"}, + erasAbbreviated: []string{"б. э. и.", "б. э"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"б. э. и.", "б. э"}, + timezones: map[string]string{"HKT": "HKT", "ACDT": "Киин Австралия сайыҥҥы кэмэ", "SAST": "SAST", "ECT": "ECT", "PDT": "PDT", "HAST": "HAST", "CAT": "CAT", "HEEG": "HEEG", "GFT": "GFT", "UYST": "UYST", "HEPM": "HEPM", "∅∅∅": "∅∅∅", "CLT": "CLT", "OEZ": "OEZ", "HAT": "HAT", "HEPMX": "HEPMX", "HNPMX": "HNPMX", "WIT": "WIT", "ACWDT": "ACWDT", "COT": "COT", "HENOMX": "HENOMX", "HNCU": "HNCU", "JST": "Дьоппуон сүрүн кэмэ", "BT": "BT", "LHDT": "LHDT", "TMT": "TMT", "TMST": "TMST", "ARST": "ARST", "ChST": "ChST", "WIB": "WIB", "AWST": "Арҕаа Австралия сүрүн кэмэ", "AWDT": "Арҕаа Австралия сайыҥҥы кэмэ", "ACWST": "ACWST", "HADT": "HADT", "MESZ": "MESZ", "WEZ": "WEZ", "WITA": "WITA", "AEST": "Илин Австралия сүрүн кэмэ", "MEZ": "MEZ", "CLST": "CLST", "MYT": "MYT", "WAST": "WAST", "MST": "MST", "MDT": "MDT", "EST": "EST", "EDT": "EDT", "CDT": "CDT", "NZST": "Саҥа Сэйлэнд сүрүн кэмэ", "WARST": "WARST", "HEOG": "HEOG", "HNT": "HNT", "WART": "WART", "HNPM": "HNPM", "LHST": "LHST", "CHADT": "CHADT", "JDT": "Дьоппуон сайыҥҥы кэмэ", "HNNOMX": "HNNOMX", "AEDT": "Илин Австралия сайыҥҥы кэмэ", "NZDT": "Саҥа Сэйлэнд сайыҥҥы кэмэ", "WESZ": "WESZ", "ACST": "Киин Австралия сүрүн кэмэ", "AKST": "AKST", "CHAST": "CHAST", "OESZ": "OESZ", "GMT": "GMT", "AKDT": "AKDT", "SGT": "SGT", "ART": "ART", "WAT": "WAT", "HKST": "HKST", "UYT": "UYT", "SRT": "SRT", "GYT": "GYT", "EAT": "EAT", "PST": "PST", "AST": "AST", "ADT": "ADT", "HECU": "HECU", "IST": "Ииндийэ сүрүн кэмэ", "VET": "VET", "HNOG": "HNOG", "CST": "CST", "BOT": "BOT", "COST": "COST", "HNEG": "HNEG"}, + } +} + +// Locale returns the current translators string locale +func (sah *sah) Locale() string { + return sah.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sah' +func (sah *sah) PluralsCardinal() []locales.PluralRule { + return sah.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sah' +func (sah *sah) PluralsOrdinal() []locales.PluralRule { + return sah.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sah' +func (sah *sah) PluralsRange() []locales.PluralRule { + return sah.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sah' +func (sah *sah) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sah' +func (sah *sah) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sah' +func (sah *sah) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sah *sah) MonthAbbreviated(month time.Month) string { + return sah.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sah *sah) MonthsAbbreviated() []string { + return sah.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sah *sah) MonthNarrow(month time.Month) string { + return sah.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sah *sah) MonthsNarrow() []string { + return sah.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sah *sah) MonthWide(month time.Month) string { + return sah.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sah *sah) MonthsWide() []string { + return sah.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sah *sah) WeekdayAbbreviated(weekday time.Weekday) string { + return sah.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sah *sah) WeekdaysAbbreviated() []string { + return sah.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sah *sah) WeekdayNarrow(weekday time.Weekday) string { + return sah.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sah *sah) WeekdaysNarrow() []string { + return sah.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sah *sah) WeekdayShort(weekday time.Weekday) string { + return sah.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sah *sah) WeekdaysShort() []string { + return sah.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sah *sah) WeekdayWide(weekday time.Weekday) string { + return sah.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sah *sah) WeekdaysWide() []string { + return sah.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sah' and handles both Whole and Real numbers based on 'v' +func (sah *sah) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sah.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sah.group) - 1; j >= 0; j-- { + b = append(b, sah.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sah.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sah' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sah *sah) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sah.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sah.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sah.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sah' +func (sah *sah) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sah.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sah.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sah.group) - 1; j >= 0; j-- { + b = append(b, sah.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sah.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sah.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sah.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sah' +// in accounting notation. +func (sah *sah) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sah.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sah.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sah.group) - 1; j >= 0; j-- { + b = append(b, sah.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sah.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sah.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sah.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sah.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sah' +func (sah *sah) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sah' +func (sah *sah) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, sah.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sah' +func (sah *sah) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, sah.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sah' +func (sah *sah) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd1, 0x81, 0xd1, 0x8b, 0xd0, 0xbb}...) + b = append(b, []byte{0x20}...) + b = append(b, sah.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd0, 0xba, 0xd2, 0xaf, 0xd0, 0xbd, 0xd1, 0x8d}...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, sah.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sah' +func (sah *sah) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sah.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sah' +func (sah *sah) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sah.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sah.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sah' +func (sah *sah) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sah.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sah.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sah' +func (sah *sah) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sah.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sah.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sah.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sah/sah_test.go b/vendor/github.com/go-playground/locales/sah/sah_test.go new file mode 100644 index 0000000000..75f65b05d9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sah/sah_test.go @@ -0,0 +1,1120 @@ +package sah + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sah" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sah_RU/sah_RU.go b/vendor/github.com/go-playground/locales/sah_RU/sah_RU.go new file mode 100644 index 0000000000..497e3175b9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sah_RU/sah_RU.go @@ -0,0 +1,579 @@ +package sah_RU + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sah_RU struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sah_RU' locale +func New() locales.Translator { + return &sah_RU{ + locale: "sah_RU", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Тохс", "Олун", "Клн", "Мсу", "Ыам", "Бэс", "Отй", "Атр", "Блҕ", "Алт", "Сэт", "Ахс"}, + monthsNarrow: []string{"", "Т", "О", "К", "М", "Ы", "Б", "О", "А", "Б", "А", "С", "А"}, + monthsWide: []string{"", "Тохсунньу", "Олунньу", "Кулун тутар", "Муус устар", "Ыам ыйын", "Бэс ыйын", "От ыйын", "Атырдьых ыйын", "Балаҕан ыйын", "Алтынньы", "Сэтинньи", "ахсынньы"}, + daysAbbreviated: []string{"бс", "бн", "оп", "сэ", "чп", "бэ", "сб"}, + daysNarrow: []string{"Б", "Б", "О", "С", "Ч", "Б", "С"}, + daysShort: []string{"бс", "бн", "оп", "сэ", "чп", "бэ", "сб"}, + daysWide: []string{"баскыһыанньа", "бэнидиэнньик", "оптуорунньук", "сэрэдэ", "чэппиэр", "Бээтиҥсэ", "субуота"}, + periodsAbbreviated: []string{"ЭИ", "ЭК"}, + periodsNarrow: []string{"ЭИ", "ЭК"}, + periodsWide: []string{"ЭИ", "ЭК"}, + erasAbbreviated: []string{"б. э. и.", "б. э"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"б. э. и.", "б. э"}, + timezones: map[string]string{"WITA": "WITA", "SRT": "SRT", "HKST": "HKST", "HENOMX": "HENOMX", "HNT": "HNT", "CST": "CST", "ACWST": "ACWST", "WAST": "WAST", "WIB": "WIB", "AWST": "Арҕаа Австралия сүрүн кэмэ", "BOT": "BOT", "OESZ": "OESZ", "HAT": "HAT", "HECU": "HECU", "MESZ": "MESZ", "ART": "ART", "CLT": "CLT", "AST": "AST", "WESZ": "WESZ", "GFT": "GFT", "HEPMX": "HEPMX", "HNCU": "HNCU", "HADT": "HADT", "∅∅∅": "∅∅∅", "SGT": "SGT", "VET": "VET", "COST": "COST", "HNNOMX": "HNNOMX", "AKDT": "AKDT", "HAST": "HAST", "MEZ": "MEZ", "ChST": "ChST", "UYST": "UYST", "CHADT": "CHADT", "PST": "PST", "JDT": "Дьоппуон сайыҥҥы кэмэ", "JST": "Дьоппуон сүрүн кэмэ", "ACST": "Киин Австралия сүрүн кэмэ", "BT": "BT", "AEDT": "Илин Австралия сайыҥҥы кэмэ", "UYT": "UYT", "NZST": "Саҥа Сэйлэнд сүрүн кэмэ", "NZDT": "Саҥа Сэйлэнд сайыҥҥы кэмэ", "GMT": "GMT", "ARST": "ARST", "PDT": "PDT", "HNOG": "HNOG", "EST": "EST", "AEST": "Илин Австралия сүрүн кэмэ", "WIT": "WIT", "CHAST": "CHAST", "CAT": "CAT", "WEZ": "WEZ", "ACDT": "Киин Австралия сайыҥҥы кэмэ", "HNEG": "HNEG", "HEEG": "HEEG", "HEPM": "HEPM", "MST": "MST", "HKT": "HKT", "WART": "WART", "WARST": "WARST", "TMT": "TMT", "AKST": "AKST", "LHST": "LHST", "HNPMX": "HNPMX", "IST": "Ииндийэ сүрүн кэмэ", "ACWDT": "ACWDT", "LHDT": "LHDT", "CDT": "CDT", "ADT": "ADT", "MYT": "MYT", "ECT": "ECT", "CLST": "CLST", "COT": "COT", "HNPM": "HNPM", "GYT": "GYT", "AWDT": "Арҕаа Австралия сайыҥҥы кэмэ", "HEOG": "HEOG", "EDT": "EDT", "MDT": "MDT", "WAT": "WAT", "SAST": "SAST", "EAT": "EAT", "OEZ": "OEZ", "TMST": "TMST"}, + } +} + +// Locale returns the current translators string locale +func (sah *sah_RU) Locale() string { + return sah.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sah_RU' +func (sah *sah_RU) PluralsCardinal() []locales.PluralRule { + return sah.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sah_RU' +func (sah *sah_RU) PluralsOrdinal() []locales.PluralRule { + return sah.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sah_RU' +func (sah *sah_RU) PluralsRange() []locales.PluralRule { + return sah.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sah_RU' +func (sah *sah_RU) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sah_RU' +func (sah *sah_RU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sah_RU' +func (sah *sah_RU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sah *sah_RU) MonthAbbreviated(month time.Month) string { + return sah.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sah *sah_RU) MonthsAbbreviated() []string { + return sah.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sah *sah_RU) MonthNarrow(month time.Month) string { + return sah.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sah *sah_RU) MonthsNarrow() []string { + return sah.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sah *sah_RU) MonthWide(month time.Month) string { + return sah.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sah *sah_RU) MonthsWide() []string { + return sah.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sah *sah_RU) WeekdayAbbreviated(weekday time.Weekday) string { + return sah.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sah *sah_RU) WeekdaysAbbreviated() []string { + return sah.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sah *sah_RU) WeekdayNarrow(weekday time.Weekday) string { + return sah.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sah *sah_RU) WeekdaysNarrow() []string { + return sah.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sah *sah_RU) WeekdayShort(weekday time.Weekday) string { + return sah.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sah *sah_RU) WeekdaysShort() []string { + return sah.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sah *sah_RU) WeekdayWide(weekday time.Weekday) string { + return sah.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sah *sah_RU) WeekdaysWide() []string { + return sah.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sah_RU' and handles both Whole and Real numbers based on 'v' +func (sah *sah_RU) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sah.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sah.group) - 1; j >= 0; j-- { + b = append(b, sah.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sah.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sah_RU' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sah *sah_RU) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sah.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sah.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sah.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sah_RU' +func (sah *sah_RU) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sah.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sah.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sah.group) - 1; j >= 0; j-- { + b = append(b, sah.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sah.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sah.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sah.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sah_RU' +// in accounting notation. +func (sah *sah_RU) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sah.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sah.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sah.group) - 1; j >= 0; j-- { + b = append(b, sah.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sah.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sah.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sah.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sah.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sah_RU' +func (sah *sah_RU) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sah_RU' +func (sah *sah_RU) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, sah.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sah_RU' +func (sah *sah_RU) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, sah.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sah_RU' +func (sah *sah_RU) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd1, 0x81, 0xd1, 0x8b, 0xd0, 0xbb}...) + b = append(b, []byte{0x20}...) + b = append(b, sah.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd0, 0xba, 0xd2, 0xaf, 0xd0, 0xbd, 0xd1, 0x8d}...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, sah.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sah_RU' +func (sah *sah_RU) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sah.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sah_RU' +func (sah *sah_RU) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sah.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sah.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sah_RU' +func (sah *sah_RU) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sah.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sah.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sah_RU' +func (sah *sah_RU) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sah.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sah.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sah.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sah_RU/sah_RU_test.go b/vendor/github.com/go-playground/locales/sah_RU/sah_RU_test.go new file mode 100644 index 0000000000..bc71db3f15 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sah_RU/sah_RU_test.go @@ -0,0 +1,1120 @@ +package sah_RU + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sah_RU" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/saq/saq.go b/vendor/github.com/go-playground/locales/saq/saq.go new file mode 100644 index 0000000000..d3bad1d510 --- /dev/null +++ b/vendor/github.com/go-playground/locales/saq/saq.go @@ -0,0 +1,525 @@ +package saq + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type saq struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'saq' locale +func New() locales.Translator { + return &saq{ + locale: "saq", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Obo", "Waa", "Oku", "Ong", "Ime", "Ile", "Sap", "Isi", "Saa", "Tom", "Tob", "Tow"}, + monthsNarrow: []string{"", "O", "W", "O", "O", "I", "I", "S", "I", "S", "T", "T", "T"}, + monthsWide: []string{"", "Lapa le obo", "Lapa le waare", "Lapa le okuni", "Lapa le ong’wan", "Lapa le imet", "Lapa le ile", "Lapa le sapa", "Lapa le isiet", "Lapa le saal", "Lapa le tomon", "Lapa le tomon obo", "Lapa le tomon waare"}, + daysAbbreviated: []string{"Are", "Kun", "Ong", "Ine", "Ile", "Sap", "Kwe"}, + daysNarrow: []string{"A", "K", "O", "I", "I", "S", "K"}, + daysWide: []string{"Mderot ee are", "Mderot ee kuni", "Mderot ee ong’wan", "Mderot ee inet", "Mderot ee ile", "Mderot ee sapa", "Mderot ee kwe"}, + periodsAbbreviated: []string{"Tesiran", "Teipa"}, + periodsWide: []string{"Tesiran", "Teipa"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Christo", "Baada ya Christo"}, + timezones: map[string]string{"AWDT": "AWDT", "HAST": "HAST", "NZDT": "NZDT", "TMST": "TMST", "MYT": "MYT", "HNOG": "HNOG", "WIB": "WIB", "PST": "PST", "IST": "IST", "JST": "JST", "MEZ": "MEZ", "GFT": "GFT", "HEPMX": "HEPMX", "VET": "VET", "ADT": "ADT", "HENOMX": "HENOMX", "HNT": "HNT", "HNPM": "HNPM", "WAST": "WAST", "HNNOMX": "HNNOMX", "AEST": "AEST", "AKST": "AKST", "SAST": "SAST", "LHDT": "LHDT", "HNEG": "HNEG", "SGT": "SGT", "SRT": "SRT", "ARST": "ARST", "CAT": "CAT", "WARST": "WARST", "CLST": "CLST", "∅∅∅": "∅∅∅", "WITA": "WITA", "AKDT": "AKDT", "UYST": "UYST", "CDT": "CDT", "HKST": "HKST", "WAT": "WAT", "HAT": "HAT", "MESZ": "MESZ", "WART": "WART", "OESZ": "OESZ", "HKT": "HKT", "HADT": "HADT", "EDT": "EDT", "ACDT": "ACDT", "AEDT": "AEDT", "MDT": "MDT", "HECU": "HECU", "CST": "CST", "CHADT": "CHADT", "JDT": "JDT", "CLT": "CLT", "OEZ": "OEZ", "UYT": "UYT", "GYT": "GYT", "WIT": "WIT", "CHAST": "CHAST", "NZST": "NZST", "EST": "EST", "ACST": "ACST", "HEEG": "HEEG", "BOT": "BOT", "ACWST": "ACWST", "WEZ": "WEZ", "TMT": "TMT", "BT": "BT", "MST": "MST", "ChST": "ChST", "LHST": "LHST", "HNCU": "HNCU", "HNPMX": "HNPMX", "AWST": "AWST", "PDT": "PDT", "ACWDT": "ACWDT", "GMT": "GMT", "ART": "ART", "HEPM": "HEPM", "EAT": "EAT", "WESZ": "WESZ", "HEOG": "HEOG", "AST": "AST", "ECT": "ECT", "COT": "COT", "COST": "COST"}, + } +} + +// Locale returns the current translators string locale +func (saq *saq) Locale() string { + return saq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'saq' +func (saq *saq) PluralsCardinal() []locales.PluralRule { + return saq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'saq' +func (saq *saq) PluralsOrdinal() []locales.PluralRule { + return saq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'saq' +func (saq *saq) PluralsRange() []locales.PluralRule { + return saq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'saq' +func (saq *saq) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'saq' +func (saq *saq) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'saq' +func (saq *saq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (saq *saq) MonthAbbreviated(month time.Month) string { + return saq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (saq *saq) MonthsAbbreviated() []string { + return saq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (saq *saq) MonthNarrow(month time.Month) string { + return saq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (saq *saq) MonthsNarrow() []string { + return saq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (saq *saq) MonthWide(month time.Month) string { + return saq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (saq *saq) MonthsWide() []string { + return saq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (saq *saq) WeekdayAbbreviated(weekday time.Weekday) string { + return saq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (saq *saq) WeekdaysAbbreviated() []string { + return saq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (saq *saq) WeekdayNarrow(weekday time.Weekday) string { + return saq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (saq *saq) WeekdaysNarrow() []string { + return saq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (saq *saq) WeekdayShort(weekday time.Weekday) string { + return saq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (saq *saq) WeekdaysShort() []string { + return saq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (saq *saq) WeekdayWide(weekday time.Weekday) string { + return saq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (saq *saq) WeekdaysWide() []string { + return saq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'saq' and handles both Whole and Real numbers based on 'v' +func (saq *saq) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'saq' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (saq *saq) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'saq' +func (saq *saq) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := saq.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, saq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, saq.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, saq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, saq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'saq' +// in accounting notation. +func (saq *saq) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := saq.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, saq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, saq.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, saq.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, saq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, saq.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'saq' +func (saq *saq) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'saq' +func (saq *saq) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, saq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'saq' +func (saq *saq) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, saq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'saq' +func (saq *saq) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, saq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, saq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'saq' +func (saq *saq) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, saq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'saq' +func (saq *saq) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, saq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, saq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'saq' +func (saq *saq) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, saq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, saq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'saq' +func (saq *saq) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, saq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, saq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := saq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/saq/saq_test.go b/vendor/github.com/go-playground/locales/saq/saq_test.go new file mode 100644 index 0000000000..8b056b4a46 --- /dev/null +++ b/vendor/github.com/go-playground/locales/saq/saq_test.go @@ -0,0 +1,1120 @@ +package saq + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "saq" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/saq_KE/saq_KE.go b/vendor/github.com/go-playground/locales/saq_KE/saq_KE.go new file mode 100644 index 0000000000..8a1a0ea6ec --- /dev/null +++ b/vendor/github.com/go-playground/locales/saq_KE/saq_KE.go @@ -0,0 +1,525 @@ +package saq_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type saq_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'saq_KE' locale +func New() locales.Translator { + return &saq_KE{ + locale: "saq_KE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Obo", "Waa", "Oku", "Ong", "Ime", "Ile", "Sap", "Isi", "Saa", "Tom", "Tob", "Tow"}, + monthsNarrow: []string{"", "O", "W", "O", "O", "I", "I", "S", "I", "S", "T", "T", "T"}, + monthsWide: []string{"", "Lapa le obo", "Lapa le waare", "Lapa le okuni", "Lapa le ong’wan", "Lapa le imet", "Lapa le ile", "Lapa le sapa", "Lapa le isiet", "Lapa le saal", "Lapa le tomon", "Lapa le tomon obo", "Lapa le tomon waare"}, + daysAbbreviated: []string{"Are", "Kun", "Ong", "Ine", "Ile", "Sap", "Kwe"}, + daysNarrow: []string{"A", "K", "O", "I", "I", "S", "K"}, + daysWide: []string{"Mderot ee are", "Mderot ee kuni", "Mderot ee ong’wan", "Mderot ee inet", "Mderot ee ile", "Mderot ee sapa", "Mderot ee kwe"}, + periodsAbbreviated: []string{"Tesiran", "Teipa"}, + periodsWide: []string{"Tesiran", "Teipa"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Christo", "Baada ya Christo"}, + timezones: map[string]string{"AEST": "AEST", "HNPM": "HNPM", "AWST": "AWST", "SGT": "SGT", "ECT": "ECT", "ACWST": "ACWST", "WART": "WART", "ACDT": "ACDT", "WEZ": "WEZ", "JST": "JST", "HECU": "HECU", "NZST": "NZST", "SAST": "SAST", "AKDT": "AKDT", "HAST": "HAST", "VET": "VET", "AST": "AST", "ART": "ART", "PST": "PST", "HEOG": "HEOG", "ARST": "ARST", "MDT": "MDT", "ACST": "ACST", "AKST": "AKST", "ChST": "ChST", "UYST": "UYST", "GYT": "GYT", "WIB": "WIB", "MST": "MST", "OEZ": "OEZ", "MESZ": "MESZ", "GFT": "GFT", "HNCU": "HNCU", "IST": "IST", "ADT": "ADT", "HNT": "HNT", "WESZ": "WESZ", "WARST": "WARST", "EDT": "EDT", "BT": "BT", "HNEG": "HNEG", "∅∅∅": "∅∅∅", "UYT": "UYT", "LHST": "LHST", "HEPMX": "HEPMX", "AWDT": "AWDT", "HNNOMX": "HNNOMX", "MYT": "MYT", "TMST": "TMST", "JDT": "JDT", "CST": "CST", "HNOG": "HNOG", "HEPM": "HEPM", "EST": "EST", "HENOMX": "HENOMX", "PDT": "PDT", "CAT": "CAT", "MEZ": "MEZ", "OESZ": "OESZ", "WAST": "WAST", "HKST": "HKST", "HAT": "HAT", "HEEG": "HEEG", "ACWDT": "ACWDT", "GMT": "GMT", "WAT": "WAT", "HNPMX": "HNPMX", "BOT": "BOT", "HADT": "HADT", "LHDT": "LHDT", "COT": "COT", "SRT": "SRT", "EAT": "EAT", "WIT": "WIT", "NZDT": "NZDT", "CLT": "CLT", "CLST": "CLST", "HKT": "HKT", "AEDT": "AEDT", "TMT": "TMT", "COST": "COST", "CDT": "CDT", "CHAST": "CHAST", "CHADT": "CHADT", "WITA": "WITA"}, + } +} + +// Locale returns the current translators string locale +func (saq *saq_KE) Locale() string { + return saq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'saq_KE' +func (saq *saq_KE) PluralsCardinal() []locales.PluralRule { + return saq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'saq_KE' +func (saq *saq_KE) PluralsOrdinal() []locales.PluralRule { + return saq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'saq_KE' +func (saq *saq_KE) PluralsRange() []locales.PluralRule { + return saq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'saq_KE' +func (saq *saq_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'saq_KE' +func (saq *saq_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'saq_KE' +func (saq *saq_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (saq *saq_KE) MonthAbbreviated(month time.Month) string { + return saq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (saq *saq_KE) MonthsAbbreviated() []string { + return saq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (saq *saq_KE) MonthNarrow(month time.Month) string { + return saq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (saq *saq_KE) MonthsNarrow() []string { + return saq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (saq *saq_KE) MonthWide(month time.Month) string { + return saq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (saq *saq_KE) MonthsWide() []string { + return saq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (saq *saq_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return saq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (saq *saq_KE) WeekdaysAbbreviated() []string { + return saq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (saq *saq_KE) WeekdayNarrow(weekday time.Weekday) string { + return saq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (saq *saq_KE) WeekdaysNarrow() []string { + return saq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (saq *saq_KE) WeekdayShort(weekday time.Weekday) string { + return saq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (saq *saq_KE) WeekdaysShort() []string { + return saq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (saq *saq_KE) WeekdayWide(weekday time.Weekday) string { + return saq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (saq *saq_KE) WeekdaysWide() []string { + return saq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'saq_KE' and handles both Whole and Real numbers based on 'v' +func (saq *saq_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'saq_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (saq *saq_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'saq_KE' +func (saq *saq_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := saq.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, saq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, saq.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, saq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, saq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'saq_KE' +// in accounting notation. +func (saq *saq_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := saq.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, saq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, saq.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, saq.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, saq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, saq.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'saq_KE' +func (saq *saq_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'saq_KE' +func (saq *saq_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, saq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'saq_KE' +func (saq *saq_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, saq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'saq_KE' +func (saq *saq_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, saq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, saq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'saq_KE' +func (saq *saq_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, saq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'saq_KE' +func (saq *saq_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, saq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, saq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'saq_KE' +func (saq *saq_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, saq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, saq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'saq_KE' +func (saq *saq_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, saq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, saq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := saq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/saq_KE/saq_KE_test.go b/vendor/github.com/go-playground/locales/saq_KE/saq_KE_test.go new file mode 100644 index 0000000000..aa3e08d489 --- /dev/null +++ b/vendor/github.com/go-playground/locales/saq_KE/saq_KE_test.go @@ -0,0 +1,1120 @@ +package saq_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "saq_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sbp/sbp.go b/vendor/github.com/go-playground/locales/sbp/sbp.go new file mode 100644 index 0000000000..cfc4894fbf --- /dev/null +++ b/vendor/github.com/go-playground/locales/sbp/sbp.go @@ -0,0 +1,566 @@ +package sbp + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sbp struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sbp' locale +func New() locales.Translator { + return &sbp{ + locale: "sbp", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Mup", "Mwi", "Msh", "Mun", "Mag", "Muj", "Msp", "Mpg", "Mye", "Mok", "Mus", "Muh"}, + monthsWide: []string{"", "Mupalangulwa", "Mwitope", "Mushende", "Munyi", "Mushende Magali", "Mujimbi", "Mushipepo", "Mupuguto", "Munyense", "Mokhu", "Musongandembwe", "Muhaano"}, + daysAbbreviated: []string{"Mul", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"M", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Mulungu", "Jumatatu", "Jumanne", "Jumatano", "Alahamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"Lwamilawu", "Pashamihe"}, + periodsWide: []string{"Lwamilawu", "Pashamihe"}, + erasAbbreviated: []string{"AK", "PK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Ashanali uKilisito", "Pamwandi ya Kilisto"}, + timezones: map[string]string{"LHST": "LHST", "TMT": "TMT", "HAT": "HAT", "GFT": "GFT", "SRT": "SRT", "WESZ": "WESZ", "ARST": "ARST", "AKST": "AKST", "AEST": "AEST", "SAST": "SAST", "CHAST": "CHAST", "ACWST": "ACWST", "WITA": "WITA", "HNPM": "HNPM", "HEPMX": "HEPMX", "ECT": "ECT", "CLST": "CLST", "HNNOMX": "HNNOMX", "HNOG": "HNOG", "TMST": "TMST", "ART": "ART", "HNPMX": "HNPMX", "AWDT": "AWDT", "PDT": "PDT", "VET": "VET", "OESZ": "OESZ", "WIB": "WIB", "CDT": "CDT", "NZST": "NZST", "HKST": "HKST", "ACDT": "ACDT", "HNEG": "HNEG", "AKDT": "AKDT", "MDT": "MDT", "NZDT": "NZDT", "HENOMX": "HENOMX", "HECU": "HECU", "CST": "CST", "CHADT": "CHADT", "AEDT": "AEDT", "AWST": "AWST", "SGT": "SGT", "MEZ": "MEZ", "MESZ": "MESZ", "OEZ": "OEZ", "WAST": "WAST", "∅∅∅": "∅∅∅", "HEPM": "HEPM", "GYT": "GYT", "HAST": "HAST", "JDT": "JDT", "HEOG": "HEOG", "AST": "AST", "WAT": "WAT", "EST": "EST", "COST": "COST", "UYT": "UYT", "HNCU": "HNCU", "MYT": "MYT", "CAT": "CAT", "ADT": "ADT", "WART": "WART", "HEEG": "HEEG", "MST": "MST", "ChST": "ChST", "BOT": "BOT", "PST": "PST", "HKT": "HKT", "EAT": "EAT", "IST": "IST", "ACWDT": "ACWDT", "JST": "JST", "WIT": "WIT", "CLT": "CLT", "WEZ": "WEZ", "EDT": "EDT", "BT": "BT", "HNT": "HNT", "UYST": "UYST", "LHDT": "LHDT", "ACST": "ACST", "COT": "COT", "HADT": "HADT", "GMT": "GMT", "WARST": "WARST"}, + } +} + +// Locale returns the current translators string locale +func (sbp *sbp) Locale() string { + return sbp.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sbp' +func (sbp *sbp) PluralsCardinal() []locales.PluralRule { + return sbp.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sbp' +func (sbp *sbp) PluralsOrdinal() []locales.PluralRule { + return sbp.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sbp' +func (sbp *sbp) PluralsRange() []locales.PluralRule { + return sbp.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sbp' +func (sbp *sbp) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sbp' +func (sbp *sbp) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sbp' +func (sbp *sbp) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sbp *sbp) MonthAbbreviated(month time.Month) string { + return sbp.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sbp *sbp) MonthsAbbreviated() []string { + return sbp.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sbp *sbp) MonthNarrow(month time.Month) string { + return sbp.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sbp *sbp) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sbp *sbp) MonthWide(month time.Month) string { + return sbp.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sbp *sbp) MonthsWide() []string { + return sbp.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sbp *sbp) WeekdayAbbreviated(weekday time.Weekday) string { + return sbp.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sbp *sbp) WeekdaysAbbreviated() []string { + return sbp.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sbp *sbp) WeekdayNarrow(weekday time.Weekday) string { + return sbp.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sbp *sbp) WeekdaysNarrow() []string { + return sbp.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sbp *sbp) WeekdayShort(weekday time.Weekday) string { + return sbp.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sbp *sbp) WeekdaysShort() []string { + return sbp.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sbp *sbp) WeekdayWide(weekday time.Weekday) string { + return sbp.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sbp *sbp) WeekdaysWide() []string { + return sbp.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sbp' and handles both Whole and Real numbers based on 'v' +func (sbp *sbp) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sbp.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sbp.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sbp.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sbp' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sbp *sbp) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sbp.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sbp.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sbp.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sbp' +func (sbp *sbp) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sbp.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sbp.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sbp.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sbp.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sbp.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sbp' +// in accounting notation. +func (sbp *sbp) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sbp.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sbp.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sbp.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sbp.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sbp.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sbp' +func (sbp *sbp) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sbp' +func (sbp *sbp) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sbp.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sbp' +func (sbp *sbp) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sbp.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sbp' +func (sbp *sbp) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sbp.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sbp.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sbp' +func (sbp *sbp) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sbp' +func (sbp *sbp) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sbp' +func (sbp *sbp) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sbp' +func (sbp *sbp) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sbp.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sbp/sbp_test.go b/vendor/github.com/go-playground/locales/sbp/sbp_test.go new file mode 100644 index 0000000000..ffd3ca626e --- /dev/null +++ b/vendor/github.com/go-playground/locales/sbp/sbp_test.go @@ -0,0 +1,1120 @@ +package sbp + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sbp" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sbp_TZ/sbp_TZ.go b/vendor/github.com/go-playground/locales/sbp_TZ/sbp_TZ.go new file mode 100644 index 0000000000..31481bbda6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sbp_TZ/sbp_TZ.go @@ -0,0 +1,566 @@ +package sbp_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sbp_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sbp_TZ' locale +func New() locales.Translator { + return &sbp_TZ{ + locale: "sbp_TZ", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Mup", "Mwi", "Msh", "Mun", "Mag", "Muj", "Msp", "Mpg", "Mye", "Mok", "Mus", "Muh"}, + monthsWide: []string{"", "Mupalangulwa", "Mwitope", "Mushende", "Munyi", "Mushende Magali", "Mujimbi", "Mushipepo", "Mupuguto", "Munyense", "Mokhu", "Musongandembwe", "Muhaano"}, + daysAbbreviated: []string{"Mul", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"M", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Mulungu", "Jumatatu", "Jumanne", "Jumatano", "Alahamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"Lwamilawu", "Pashamihe"}, + periodsWide: []string{"Lwamilawu", "Pashamihe"}, + erasAbbreviated: []string{"AK", "PK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Ashanali uKilisito", "Pamwandi ya Kilisto"}, + timezones: map[string]string{"CDT": "CDT", "AWDT": "AWDT", "NZST": "NZST", "CLST": "CLST", "EST": "EST", "ChST": "ChST", "WIB": "WIB", "CST": "CST", "HADT": "HADT", "LHST": "LHST", "HEPMX": "HEPMX", "ADT": "ADT", "TMST": "TMST", "OESZ": "OESZ", "NZDT": "NZDT", "HNOG": "HNOG", "EDT": "EDT", "COT": "COT", "AKDT": "AKDT", "AEST": "AEST", "MEZ": "MEZ", "WESZ": "WESZ", "WARST": "WARST", "ART": "ART", "WAT": "WAT", "PST": "PST", "AST": "AST", "CHAST": "CHAST", "CAT": "CAT", "ACWDT": "ACWDT", "JST": "JST", "EAT": "EAT", "HNCU": "HNCU", "HEEG": "HEEG", "HNPM": "HNPM", "HKST": "HKST", "HNT": "HNT", "HEOG": "HEOG", "ARST": "ARST", "ACST": "ACST", "AEDT": "AEDT", "WIT": "WIT", "SGT": "SGT", "HNNOMX": "HNNOMX", "BT": "BT", "WITA": "WITA", "HNPMX": "HNPMX", "CLT": "CLT", "HKT": "HKT", "JDT": "JDT", "UYT": "UYT", "HEPM": "HEPM", "PDT": "PDT", "IST": "IST", "OEZ": "OEZ", "WEZ": "WEZ", "GMT": "GMT", "TMT": "TMT", "HENOMX": "HENOMX", "LHDT": "LHDT", "CHADT": "CHADT", "VET": "VET", "SRT": "SRT", "MST": "MST", "AKST": "AKST", "SAST": "SAST", "GYT": "GYT", "HAST": "HAST", "ECT": "ECT", "ACDT": "ACDT", "HNEG": "HNEG", "UYST": "UYST", "MESZ": "MESZ", "WART": "WART", "BOT": "BOT", "MYT": "MYT", "MDT": "MDT", "WAST": "WAST", "HAT": "HAT", "HECU": "HECU", "∅∅∅": "∅∅∅", "COST": "COST", "GFT": "GFT", "AWST": "AWST", "ACWST": "ACWST"}, + } +} + +// Locale returns the current translators string locale +func (sbp *sbp_TZ) Locale() string { + return sbp.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sbp_TZ' +func (sbp *sbp_TZ) PluralsCardinal() []locales.PluralRule { + return sbp.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sbp_TZ' +func (sbp *sbp_TZ) PluralsOrdinal() []locales.PluralRule { + return sbp.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sbp_TZ' +func (sbp *sbp_TZ) PluralsRange() []locales.PluralRule { + return sbp.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sbp_TZ' +func (sbp *sbp_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sbp_TZ' +func (sbp *sbp_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sbp_TZ' +func (sbp *sbp_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sbp *sbp_TZ) MonthAbbreviated(month time.Month) string { + return sbp.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sbp *sbp_TZ) MonthsAbbreviated() []string { + return sbp.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sbp *sbp_TZ) MonthNarrow(month time.Month) string { + return sbp.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sbp *sbp_TZ) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sbp *sbp_TZ) MonthWide(month time.Month) string { + return sbp.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sbp *sbp_TZ) MonthsWide() []string { + return sbp.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sbp *sbp_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return sbp.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sbp *sbp_TZ) WeekdaysAbbreviated() []string { + return sbp.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sbp *sbp_TZ) WeekdayNarrow(weekday time.Weekday) string { + return sbp.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sbp *sbp_TZ) WeekdaysNarrow() []string { + return sbp.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sbp *sbp_TZ) WeekdayShort(weekday time.Weekday) string { + return sbp.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sbp *sbp_TZ) WeekdaysShort() []string { + return sbp.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sbp *sbp_TZ) WeekdayWide(weekday time.Weekday) string { + return sbp.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sbp *sbp_TZ) WeekdaysWide() []string { + return sbp.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sbp_TZ' and handles both Whole and Real numbers based on 'v' +func (sbp *sbp_TZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sbp.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sbp.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sbp.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sbp_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sbp *sbp_TZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sbp.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sbp.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sbp.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sbp.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sbp.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sbp.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sbp.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sbp.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sbp_TZ' +// in accounting notation. +func (sbp *sbp_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sbp.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sbp.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sbp.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sbp.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sbp.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sbp.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sbp.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sbp.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sbp.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sbp_TZ' +func (sbp *sbp_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sbp.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sbp.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sbp_TZ/sbp_TZ_test.go b/vendor/github.com/go-playground/locales/sbp_TZ/sbp_TZ_test.go new file mode 100644 index 0000000000..f7fe2c0833 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sbp_TZ/sbp_TZ_test.go @@ -0,0 +1,1120 @@ +package sbp_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sbp_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/se/se.go b/vendor/github.com/go-playground/locales/se/se.go new file mode 100644 index 0000000000..d9850c99a3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/se/se.go @@ -0,0 +1,609 @@ +package se + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type se struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'se' locale +func New() locales.Translator { + return &se{ + locale: "se", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "Dkr", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GB£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "Ikr", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "kr", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "Skr", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ođđj", "guov", "njuk", "cuo", "mies", "geas", "suoi", "borg", "čakč", "golg", "skáb", "juov"}, + monthsNarrow: []string{"", "O", "G", "N", "C", "M", "G", "S", "B", "Č", "G", "S", "J"}, + monthsWide: []string{"", "ođđajagemánnu", "guovvamánnu", "njukčamánnu", "cuoŋománnu", "miessemánnu", "geassemánnu", "suoidnemánnu", "borgemánnu", "čakčamánnu", "golggotmánnu", "skábmamánnu", "juovlamánnu"}, + daysAbbreviated: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"}, + daysNarrow: []string{"S", "V", "M", "G", "D", "B", "L"}, + daysShort: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"}, + daysWide: []string{"sotnabeaivi", "vuossárga", "maŋŋebárga", "gaskavahkku", "duorasdat", "bearjadat", "lávvardat"}, + periodsAbbreviated: []string{"i.b.", "e.b."}, + periodsNarrow: []string{"i.b.", "e.b."}, + periodsWide: []string{"iđitbeaivet", "eahketbeaivet"}, + erasAbbreviated: []string{"o.Kr.", "m.Kr."}, + erasNarrow: []string{"ooá", "oá"}, + erasWide: []string{"ovdal Kristtusa", "maŋŋel Kristtusa"}, + timezones: map[string]string{"HADT": "HADT", "CLT": "CLT", "ART": "ART", "HEEG": "HEEG", "CDT": "CDT", "WIT": "WIT", "NZST": "NZST", "AST": "AST", "COT": "COT", "UYST": "UYST", "GYT": "GYT", "SGT": "SGT", "MST": "MST", "ACST": "ACST", "HEPM": "HEPM", "CHAST": "CHAST", "MESZ": "gaska-Eurohpá geassiáigi", "HNEG": "HNEG", "HEPMX": "HEPMX", "HAST": "HAST", "OEZ": "nuorti-Eurohpá dábálašáigi", "HKT": "HKT", "HNNOMX": "HNNOMX", "UYT": "UYT", "LHDT": "LHDT", "ACWDT": "ACWDT", "WEZ": "oarje-Eurohpá dábálašáigi", "WART": "WART", "WARST": "WARST", "HEOG": "HEOG", "ACWST": "ACWST", "∅∅∅": "∅∅∅", "GMT": "Greenwich gaskka áigi", "TMST": "TMST", "SAST": "SAST", "HNPMX": "HNPMX", "AWDT": "AWDT", "CAT": "CAT", "WESZ": "oarje-Eurohpá geassiáigi", "EDT": "EDT", "COST": "COST", "BT": "BT", "CHADT": "CHADT", "GFT": "GFT", "AEDT": "AEDT", "ChST": "ChST", "IST": "IST", "NZDT": "NZDT", "MDT": "MDT", "ARST": "ARST", "HNT": "HNT", "HAT": "HAT", "WIB": "WIB", "PST": "PST", "JST": "JST", "JDT": "JDT", "CLST": "CLST", "WAT": "WAT", "AKDT": "AKDT", "PDT": "PDT", "OESZ": "nuorti-Eurohpá geassiáigi", "AEST": "AEST", "HNCU": "HNCU", "AWST": "AWST", "ECT": "ECT", "VET": "VET", "EST": "EST", "HKST": "HKST", "ACDT": "ACDT", "CST": "CST", "HNPM": "HNPM", "LHST": "LHST", "MEZ": "gaska-Eurohpá dábálašáigi", "ADT": "ADT", "HNOG": "HNOG", "WAST": "WAST", "HENOMX": "HENOMX", "AKST": "AKST", "HECU": "HECU", "BOT": "BOT", "MYT": "MYT", "TMT": "TMT", "SRT": "SRT", "EAT": "EAT", "WITA": "WITA"}, + } +} + +// Locale returns the current translators string locale +func (se *se) Locale() string { + return se.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'se' +func (se *se) PluralsCardinal() []locales.PluralRule { + return se.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'se' +func (se *se) PluralsOrdinal() []locales.PluralRule { + return se.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'se' +func (se *se) PluralsRange() []locales.PluralRule { + return se.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'se' +func (se *se) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'se' +func (se *se) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'se' +func (se *se) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (se *se) MonthAbbreviated(month time.Month) string { + return se.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (se *se) MonthsAbbreviated() []string { + return se.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (se *se) MonthNarrow(month time.Month) string { + return se.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (se *se) MonthsNarrow() []string { + return se.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (se *se) MonthWide(month time.Month) string { + return se.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (se *se) MonthsWide() []string { + return se.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (se *se) WeekdayAbbreviated(weekday time.Weekday) string { + return se.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (se *se) WeekdaysAbbreviated() []string { + return se.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (se *se) WeekdayNarrow(weekday time.Weekday) string { + return se.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (se *se) WeekdaysNarrow() []string { + return se.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (se *se) WeekdayShort(weekday time.Weekday) string { + return se.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (se *se) WeekdaysShort() []string { + return se.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (se *se) WeekdayWide(weekday time.Weekday) string { + return se.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (se *se) WeekdaysWide() []string { + return se.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'se' and handles both Whole and Real numbers based on 'v' +func (se *se) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'se' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (se *se) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, se.percentSuffix...) + + b = append(b, se.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'se' +func (se *se) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := se.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, se.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, se.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'se' +// in accounting notation. +func (se *se) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := se.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, se.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, se.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, se.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'se' +func (se *se) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'se' +func (se *se) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'se' +func (se *se) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'se' +func (se *se) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, se.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'se' +func (se *se) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'se' +func (se *se) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'se' +func (se *se) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'se' +func (se *se) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := se.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/se/se_test.go b/vendor/github.com/go-playground/locales/se/se_test.go new file mode 100644 index 0000000000..504c8cc424 --- /dev/null +++ b/vendor/github.com/go-playground/locales/se/se_test.go @@ -0,0 +1,1120 @@ +package se + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "se" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/se_FI/se_FI.go b/vendor/github.com/go-playground/locales/se_FI/se_FI.go new file mode 100644 index 0000000000..b7f4b21a89 --- /dev/null +++ b/vendor/github.com/go-playground/locales/se_FI/se_FI.go @@ -0,0 +1,609 @@ +package se_FI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type se_FI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'se_FI' locale +func New() locales.Translator { + return &se_FI{ + locale: "se_FI", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ođđj", "guov", "njuk", "cuo", "mies", "geas", "suoi", "borg", "čakč", "golg", "skáb", "juov"}, + monthsNarrow: []string{"", "O", "G", "N", "C", "M", "G", "S", "B", "Č", "G", "S", "J"}, + monthsWide: []string{"", "ođđajagemánnu", "guovvamánnu", "njukčamánnu", "cuoŋománnu", "miessemánnu", "geassemánnu", "suoidnemánnu", "borgemánnu", "čakčamánnu", "golggotmánnu", "skábmamánnu", "juovlamánnu"}, + daysAbbreviated: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"}, + daysNarrow: []string{"S", "M", "D", "G", "D", "B", "L"}, + daysShort: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"}, + daysWide: []string{"sotnabeaivi", "vuossárgga", "maŋŋebárgga", "gaskavahku", "duorastaga", "bearjadaga", "lávvardaga"}, + periodsAbbreviated: []string{"i.b.", "e.b."}, + periodsNarrow: []string{"i.b.", "e.b."}, + periodsWide: []string{"iđitbeaivet", "eahketbeaivet"}, + erasAbbreviated: []string{"o.Kr.", "m.Kr."}, + erasNarrow: []string{"ooá", "oá"}, + erasWide: []string{"ovdal Kristtusa", "maŋŋel Kristtusa"}, + timezones: map[string]string{"ACDT": "ACDT", "AEST": "AEST", "CHADT": "CHADT", "HADT": "HADT", "OEZ": "nuorti-Eurohpá dábálašáigi", "MDT": "MDT", "ART": "ART", "WAT": "WAT", "HEPMX": "HEPMX", "ACWDT": "ACWDT", "JDT": "JDT", "HNOG": "HNOG", "HENOMX": "HENOMX", "PDT": "PDT", "ARST": "ARST", "HECU": "HECU", "NZST": "NZST", "GFT": "GFT", "AKDT": "AKDT", "CST": "CST", "WIT": "WIT", "UYST": "UYST", "HNPM": "HNPM", "SGT": "SGT", "BOT": "BOT", "HAST": "HAST", "WARST": "WARST", "CLT": "CLT", "HEOG": "HEOG", "CDT": "CDT", "CAT": "CAT", "JST": "JST", "WART": "WART", "WESZ": "oarje-Eurohpá geassiáigi", "SAST": "SAST", "GMT": "Greenwich gaskka áigi", "EST": "EST", "HKT": "HKT", "HNT": "HNT", "WITA": "WITA", "LHST": "LHST", "EAT": "EAT", "IST": "IST", "MESZ": "gaska-Eurohpá geassiáigi", "ADT": "ADT", "TMST": "TMST", "HKST": "HKST", "UYT": "UYT", "MST": "MST", "COT": "COT", "CHAST": "CHAST", "∅∅∅": "∅∅∅", "ACWST": "ACWST", "NZDT": "NZDT", "VET": "VET", "MYT": "MYT", "AKST": "AKST", "GYT": "GYT", "MEZ": "gaska-Eurohpá dábálašáigi", "COST": "COST", "AEDT": "AEDT", "PST": "PST", "AST": "AST", "HAT": "HAT", "ChST": "ChST", "AWDT": "AWDT", "ECT": "ECT", "CLST": "CLST", "OESZ": "nuorti-Eurohpá geassiáigi", "LHDT": "LHDT", "WIB": "WIB", "AWST": "AWST", "WEZ": "oarje-Eurohpá dábálašáigi", "HNNOMX": "HNNOMX", "BT": "BT", "HEEG": "HEEG", "SRT": "SRT", "ACST": "ACST", "HNCU": "HNCU", "TMT": "TMT", "WAST": "WAST", "EDT": "EDT", "HNEG": "HNEG", "HEPM": "HEPM", "HNPMX": "HNPMX"}, + } +} + +// Locale returns the current translators string locale +func (se *se_FI) Locale() string { + return se.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'se_FI' +func (se *se_FI) PluralsCardinal() []locales.PluralRule { + return se.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'se_FI' +func (se *se_FI) PluralsOrdinal() []locales.PluralRule { + return se.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'se_FI' +func (se *se_FI) PluralsRange() []locales.PluralRule { + return se.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'se_FI' +func (se *se_FI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'se_FI' +func (se *se_FI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'se_FI' +func (se *se_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (se *se_FI) MonthAbbreviated(month time.Month) string { + return se.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (se *se_FI) MonthsAbbreviated() []string { + return se.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (se *se_FI) MonthNarrow(month time.Month) string { + return se.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (se *se_FI) MonthsNarrow() []string { + return se.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (se *se_FI) MonthWide(month time.Month) string { + return se.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (se *se_FI) MonthsWide() []string { + return se.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (se *se_FI) WeekdayAbbreviated(weekday time.Weekday) string { + return se.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (se *se_FI) WeekdaysAbbreviated() []string { + return se.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (se *se_FI) WeekdayNarrow(weekday time.Weekday) string { + return se.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (se *se_FI) WeekdaysNarrow() []string { + return se.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (se *se_FI) WeekdayShort(weekday time.Weekday) string { + return se.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (se *se_FI) WeekdaysShort() []string { + return se.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (se *se_FI) WeekdayWide(weekday time.Weekday) string { + return se.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (se *se_FI) WeekdaysWide() []string { + return se.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'se_FI' and handles both Whole and Real numbers based on 'v' +func (se *se_FI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'se_FI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (se *se_FI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, se.percentSuffix...) + + b = append(b, se.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'se_FI' +func (se *se_FI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := se.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, se.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, se.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'se_FI' +// in accounting notation. +func (se *se_FI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := se.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, se.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, se.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, se.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'se_FI' +func (se *se_FI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'se_FI' +func (se *se_FI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'se_FI' +func (se *se_FI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'se_FI' +func (se *se_FI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, se.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'se_FI' +func (se *se_FI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'se_FI' +func (se *se_FI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'se_FI' +func (se *se_FI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'se_FI' +func (se *se_FI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := se.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/se_FI/se_FI_test.go b/vendor/github.com/go-playground/locales/se_FI/se_FI_test.go new file mode 100644 index 0000000000..10f4e154a7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/se_FI/se_FI_test.go @@ -0,0 +1,1120 @@ +package se_FI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "se_FI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/se_NO/se_NO.go b/vendor/github.com/go-playground/locales/se_NO/se_NO.go new file mode 100644 index 0000000000..86c2fab2fd --- /dev/null +++ b/vendor/github.com/go-playground/locales/se_NO/se_NO.go @@ -0,0 +1,609 @@ +package se_NO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type se_NO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'se_NO' locale +func New() locales.Translator { + return &se_NO{ + locale: "se_NO", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ođđj", "guov", "njuk", "cuo", "mies", "geas", "suoi", "borg", "čakč", "golg", "skáb", "juov"}, + monthsNarrow: []string{"", "O", "G", "N", "C", "M", "G", "S", "B", "Č", "G", "S", "J"}, + monthsWide: []string{"", "ođđajagemánnu", "guovvamánnu", "njukčamánnu", "cuoŋománnu", "miessemánnu", "geassemánnu", "suoidnemánnu", "borgemánnu", "čakčamánnu", "golggotmánnu", "skábmamánnu", "juovlamánnu"}, + daysAbbreviated: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"}, + daysNarrow: []string{"S", "V", "M", "G", "D", "B", "L"}, + daysShort: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"}, + daysWide: []string{"sotnabeaivi", "vuossárga", "maŋŋebárga", "gaskavahkku", "duorasdat", "bearjadat", "lávvardat"}, + periodsAbbreviated: []string{"i.b.", "e.b."}, + periodsNarrow: []string{"i.b.", "e.b."}, + periodsWide: []string{"iđitbeaivet", "eahketbeaivet"}, + erasAbbreviated: []string{"o.Kr.", "m.Kr."}, + erasNarrow: []string{"ooá", "oá"}, + erasWide: []string{"ovdal Kristtusa", "maŋŋel Kristtusa"}, + timezones: map[string]string{"HADT": "HADT", "ECT": "ECT", "HNEG": "HNEG", "ChST": "ChST", "HNCU": "HNCU", "CHADT": "CHADT", "PDT": "PDT", "EDT": "EDT", "ACST": "ACST", "COST": "COST", "UYST": "UYST", "NZDT": "NZDT", "HNOG": "HNOG", "WIB": "WIB", "CHAST": "CHAST", "WAT": "WAT", "OESZ": "nuorti-Eurohpá geassiáigi", "ARST": "ARST", "LHDT": "LHDT", "SRT": "SRT", "CDT": "CDT", "AWST": "AWST", "HAST": "HAST", "∅∅∅": "∅∅∅", "HNPMX": "HNPMX", "BOT": "BOT", "JST": "JST", "WAST": "WAST", "HKST": "HKST", "HENOMX": "HENOMX", "CST": "CST", "ACWDT": "ACWDT", "MEZ": "gaska-Eurohpá dábálašáigi", "VET": "VET", "HAT": "HAT", "HEPM": "HEPM", "WART": "WART", "MDT": "MDT", "HECU": "HECU", "MYT": "MYT", "WITA": "WITA", "AWDT": "AWDT", "NZST": "NZST", "MESZ": "gaska-Eurohpá geassiáigi", "WEZ": "oarje-Eurohpá dábálašáigi", "CLST": "CLST", "HNNOMX": "HNNOMX", "UYT": "UYT", "SAST": "SAST", "PST": "PST", "IST": "IST", "COT": "COT", "AEST": "AEST", "ACWST": "ACWST", "JDT": "JDT", "EST": "EST", "HEEG": "HEEG", "AEDT": "AEDT", "WESZ": "oarje-Eurohpá geassiáigi", "CAT": "CAT", "CLT": "CLT", "AST": "AST", "BT": "BT", "AKDT": "AKDT", "MST": "MST", "HNPM": "HNPM", "HEPMX": "HEPMX", "GMT": "Greenwich gaskka áigi", "TMST": "TMST", "ART": "ART", "WIT": "WIT", "SGT": "SGT", "OEZ": "nuorti-Eurohpá dábálašáigi", "HNT": "HNT", "AKST": "AKST", "LHST": "LHST", "GYT": "GYT", "EAT": "EAT", "WARST": "WARST", "TMT": "TMT", "ACDT": "ACDT", "GFT": "GFT", "HEOG": "HEOG", "ADT": "ADT", "HKT": "HKT"}, + } +} + +// Locale returns the current translators string locale +func (se *se_NO) Locale() string { + return se.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'se_NO' +func (se *se_NO) PluralsCardinal() []locales.PluralRule { + return se.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'se_NO' +func (se *se_NO) PluralsOrdinal() []locales.PluralRule { + return se.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'se_NO' +func (se *se_NO) PluralsRange() []locales.PluralRule { + return se.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'se_NO' +func (se *se_NO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'se_NO' +func (se *se_NO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'se_NO' +func (se *se_NO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (se *se_NO) MonthAbbreviated(month time.Month) string { + return se.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (se *se_NO) MonthsAbbreviated() []string { + return se.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (se *se_NO) MonthNarrow(month time.Month) string { + return se.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (se *se_NO) MonthsNarrow() []string { + return se.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (se *se_NO) MonthWide(month time.Month) string { + return se.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (se *se_NO) MonthsWide() []string { + return se.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (se *se_NO) WeekdayAbbreviated(weekday time.Weekday) string { + return se.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (se *se_NO) WeekdaysAbbreviated() []string { + return se.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (se *se_NO) WeekdayNarrow(weekday time.Weekday) string { + return se.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (se *se_NO) WeekdaysNarrow() []string { + return se.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (se *se_NO) WeekdayShort(weekday time.Weekday) string { + return se.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (se *se_NO) WeekdaysShort() []string { + return se.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (se *se_NO) WeekdayWide(weekday time.Weekday) string { + return se.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (se *se_NO) WeekdaysWide() []string { + return se.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'se_NO' and handles both Whole and Real numbers based on 'v' +func (se *se_NO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'se_NO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (se *se_NO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, se.percentSuffix...) + + b = append(b, se.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'se_NO' +func (se *se_NO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := se.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, se.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, se.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'se_NO' +// in accounting notation. +func (se *se_NO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := se.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, se.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, se.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, se.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'se_NO' +func (se *se_NO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'se_NO' +func (se *se_NO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'se_NO' +func (se *se_NO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'se_NO' +func (se *se_NO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, se.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'se_NO' +func (se *se_NO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'se_NO' +func (se *se_NO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'se_NO' +func (se *se_NO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'se_NO' +func (se *se_NO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := se.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/se_NO/se_NO_test.go b/vendor/github.com/go-playground/locales/se_NO/se_NO_test.go new file mode 100644 index 0000000000..a952fe43b5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/se_NO/se_NO_test.go @@ -0,0 +1,1120 @@ +package se_NO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "se_NO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/se_SE/se_SE.go b/vendor/github.com/go-playground/locales/se_SE/se_SE.go new file mode 100644 index 0000000000..38042e0814 --- /dev/null +++ b/vendor/github.com/go-playground/locales/se_SE/se_SE.go @@ -0,0 +1,609 @@ +package se_SE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type se_SE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'se_SE' locale +func New() locales.Translator { + return &se_SE{ + locale: "se_SE", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "Nkr", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "kr", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ođđj", "guov", "njuk", "cuo", "mies", "geas", "suoi", "borg", "čakč", "golg", "skáb", "juov"}, + monthsNarrow: []string{"", "O", "G", "N", "C", "M", "G", "S", "B", "Č", "G", "S", "J"}, + monthsWide: []string{"", "ođđajagemánnu", "guovvamánnu", "njukčamánnu", "cuoŋománnu", "miessemánnu", "geassemánnu", "suoidnemánnu", "borgemánnu", "čakčamánnu", "golggotmánnu", "skábmamánnu", "juovlamánnu"}, + daysAbbreviated: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"}, + daysNarrow: []string{"S", "V", "M", "G", "D", "B", "L"}, + daysShort: []string{"sotn", "vuos", "maŋ", "gask", "duor", "bear", "láv"}, + daysWide: []string{"sotnabeaivi", "vuossárga", "maŋŋebárga", "gaskavahkku", "duorasdat", "bearjadat", "lávvardat"}, + periodsAbbreviated: []string{"i.b.", "e.b."}, + periodsNarrow: []string{"i.b.", "e.b."}, + periodsWide: []string{"iđitbeaivet", "eahketbeaivet"}, + erasAbbreviated: []string{"o.Kr.", "m.Kr."}, + erasNarrow: []string{"ooá", "oá"}, + erasWide: []string{"ovdal Kristtusa", "maŋŋel Kristtusa"}, + timezones: map[string]string{"TMST": "TMST", "EAT": "EAT", "VET": "VET", "LHST": "LHST", "HEPMX": "HEPMX", "CST": "CST", "HEEG": "HEEG", "BOT": "BOT", "ACWST": "ACWST", "ARST": "ARST", "EST": "EST", "HKT": "HKT", "UYST": "UYST", "JST": "JST", "ACST": "ACST", "HNEG": "HNEG", "AEST": "AEST", "WAST": "WAST", "CDT": "CDT", "CHADT": "CHADT", "WARST": "WARST", "AST": "AST", "MST": "MST", "CLT": "CLT", "COT": "COT", "NZDT": "NZDT", "MDT": "MDT", "HNPM": "HNPM", "AWDT": "AWDT", "SRT": "SRT", "WIB": "WIB", "HAST": "HAST", "CLST": "CLST", "ACDT": "ACDT", "GFT": "GFT", "HNPMX": "HNPMX", "MESZ": "gaska-Eurohpá geassiáigi", "HNNOMX": "HNNOMX", "HNT": "HNT", "LHDT": "LHDT", "ECT": "ECT", "JDT": "JDT", "WART": "WART", "HKST": "HKST", "HNCU": "HNCU", "BT": "BT", "AKST": "AKST", "AKDT": "AKDT", "HEPM": "HEPM", "IST": "IST", "OEZ": "nuorti-Eurohpá dábálašáigi", "HEOG": "HEOG", "COST": "COST", "ART": "ART", "AWST": "AWST", "HADT": "HADT", "WESZ": "oarje-Eurohpá geassiáigi", "MYT": "MYT", "HNOG": "HNOG", "∅∅∅": "∅∅∅", "ChST": "ChST", "WIT": "WIT", "CAT": "CAT", "WEZ": "oarje-Eurohpá dábálašáigi", "HENOMX": "HENOMX", "HAT": "HAT", "GYT": "GYT", "HECU": "HECU", "SGT": "SGT", "CHAST": "CHAST", "PST": "PST", "ADT": "ADT", "TMT": "TMT", "EDT": "EDT", "ACWDT": "ACWDT", "WITA": "WITA", "PDT": "PDT", "NZST": "NZST", "MEZ": "gaska-Eurohpá dábálašáigi", "OESZ": "nuorti-Eurohpá geassiáigi", "GMT": "Greenwich gaskka áigi", "AEDT": "AEDT", "WAT": "WAT", "UYT": "UYT", "SAST": "SAST"}, + } +} + +// Locale returns the current translators string locale +func (se *se_SE) Locale() string { + return se.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'se_SE' +func (se *se_SE) PluralsCardinal() []locales.PluralRule { + return se.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'se_SE' +func (se *se_SE) PluralsOrdinal() []locales.PluralRule { + return se.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'se_SE' +func (se *se_SE) PluralsRange() []locales.PluralRule { + return se.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'se_SE' +func (se *se_SE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'se_SE' +func (se *se_SE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'se_SE' +func (se *se_SE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (se *se_SE) MonthAbbreviated(month time.Month) string { + return se.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (se *se_SE) MonthsAbbreviated() []string { + return se.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (se *se_SE) MonthNarrow(month time.Month) string { + return se.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (se *se_SE) MonthsNarrow() []string { + return se.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (se *se_SE) MonthWide(month time.Month) string { + return se.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (se *se_SE) MonthsWide() []string { + return se.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (se *se_SE) WeekdayAbbreviated(weekday time.Weekday) string { + return se.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (se *se_SE) WeekdaysAbbreviated() []string { + return se.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (se *se_SE) WeekdayNarrow(weekday time.Weekday) string { + return se.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (se *se_SE) WeekdaysNarrow() []string { + return se.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (se *se_SE) WeekdayShort(weekday time.Weekday) string { + return se.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (se *se_SE) WeekdaysShort() []string { + return se.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (se *se_SE) WeekdayWide(weekday time.Weekday) string { + return se.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (se *se_SE) WeekdaysWide() []string { + return se.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'se_SE' and handles both Whole and Real numbers based on 'v' +func (se *se_SE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'se_SE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (se *se_SE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, se.percentSuffix...) + + b = append(b, se.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'se_SE' +func (se *se_SE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := se.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, se.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, se.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'se_SE' +// in accounting notation. +func (se *se_SE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := se.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, se.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(se.group) - 1; j >= 0; j-- { + b = append(b, se.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(se.minus) - 1; j >= 0; j-- { + b = append(b, se.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, se.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, se.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, se.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'se_SE' +func (se *se_SE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'se_SE' +func (se *se_SE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'se_SE' +func (se *se_SE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'se_SE' +func (se *se_SE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, se.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, se.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'se_SE' +func (se *se_SE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'se_SE' +func (se *se_SE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'se_SE' +func (se *se_SE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'se_SE' +func (se *se_SE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, se.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, se.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := se.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/se_SE/se_SE_test.go b/vendor/github.com/go-playground/locales/se_SE/se_SE_test.go new file mode 100644 index 0000000000..ed385b52e7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/se_SE/se_SE_test.go @@ -0,0 +1,1120 @@ +package se_SE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "se_SE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/seh/seh.go b/vendor/github.com/go-playground/locales/seh/seh.go new file mode 100644 index 0000000000..73eaefea63 --- /dev/null +++ b/vendor/github.com/go-playground/locales/seh/seh.go @@ -0,0 +1,508 @@ +package seh + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type seh struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'seh' locale +func New() locales.Translator { + return &seh{ + locale: "seh", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MTn", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Aug", "Set", "Otu", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janeiro", "Fevreiro", "Marco", "Abril", "Maio", "Junho", "Julho", "Augusto", "Setembro", "Otubro", "Novembro", "Decembro"}, + daysAbbreviated: []string{"Dim", "Pos", "Pir", "Tat", "Nai", "Sha", "Sab"}, + daysNarrow: []string{"D", "P", "C", "T", "N", "S", "S"}, + daysWide: []string{"Dimingu", "Chiposi", "Chipiri", "Chitatu", "Chinai", "Chishanu", "Sabudu"}, + erasAbbreviated: []string{"AC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Antes de Cristo", "Anno Domini"}, + timezones: map[string]string{"PDT": "PDT", "HKST": "HKST", "ACDT": "ACDT", "COT": "COT", "AKST": "AKST", "ChST": "ChST", "HNCU": "HNCU", "CST": "CST", "MDT": "MDT", "HNPM": "HNPM", "GYT": "GYT", "PST": "PST", "EST": "EST", "BT": "BT", "LHDT": "LHDT", "WIT": "WIT", "WESZ": "WESZ", "ART": "ART", "GFT": "GFT", "EAT": "EAT", "BOT": "BOT", "ECT": "ECT", "IST": "IST", "ACWST": "ACWST", "HENOMX": "HENOMX", "AKDT": "AKDT", "HECU": "HECU", "HADT": "HADT", "MYT": "MYT", "ADT": "ADT", "∅∅∅": "∅∅∅", "UYT": "UYT", "HEPMX": "HEPMX", "HAST": "HAST", "MEZ": "MEZ", "MESZ": "MESZ", "GMT": "GMT", "HNNOMX": "HNNOMX", "AEDT": "AEDT", "WIB": "WIB", "OESZ": "OESZ", "AEST": "AEST", "LHST": "LHST", "CHADT": "CHADT", "CAT": "CAT", "AST": "AST", "TMT": "TMT", "ARST": "ARST", "WAT": "WAT", "COST": "COST", "UYST": "UYST", "CDT": "CDT", "HAT": "HAT", "HEEG": "HEEG", "WEZ": "WEZ", "ACST": "ACST", "HNEG": "HNEG", "WITA": "WITA", "HNPMX": "HNPMX", "CLT": "CLT", "HNOG": "HNOG", "WAST": "WAST", "EDT": "EDT", "CHAST": "CHAST", "JST": "JST", "WART": "WART", "JDT": "JDT", "MST": "MST", "SRT": "SRT", "AWST": "AWST", "AWDT": "AWDT", "SGT": "SGT", "ACWDT": "ACWDT", "VET": "VET", "OEZ": "OEZ", "HKT": "HKT", "HNT": "HNT", "SAST": "SAST", "NZST": "NZST", "WARST": "WARST", "CLST": "CLST", "HEOG": "HEOG", "TMST": "TMST", "HEPM": "HEPM", "NZDT": "NZDT"}, + } +} + +// Locale returns the current translators string locale +func (seh *seh) Locale() string { + return seh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'seh' +func (seh *seh) PluralsCardinal() []locales.PluralRule { + return seh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'seh' +func (seh *seh) PluralsOrdinal() []locales.PluralRule { + return seh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'seh' +func (seh *seh) PluralsRange() []locales.PluralRule { + return seh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'seh' +func (seh *seh) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'seh' +func (seh *seh) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'seh' +func (seh *seh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (seh *seh) MonthAbbreviated(month time.Month) string { + return seh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (seh *seh) MonthsAbbreviated() []string { + return seh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (seh *seh) MonthNarrow(month time.Month) string { + return seh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (seh *seh) MonthsNarrow() []string { + return seh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (seh *seh) MonthWide(month time.Month) string { + return seh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (seh *seh) MonthsWide() []string { + return seh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (seh *seh) WeekdayAbbreviated(weekday time.Weekday) string { + return seh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (seh *seh) WeekdaysAbbreviated() []string { + return seh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (seh *seh) WeekdayNarrow(weekday time.Weekday) string { + return seh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (seh *seh) WeekdaysNarrow() []string { + return seh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (seh *seh) WeekdayShort(weekday time.Weekday) string { + return seh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (seh *seh) WeekdaysShort() []string { + return seh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (seh *seh) WeekdayWide(weekday time.Weekday) string { + return seh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (seh *seh) WeekdaysWide() []string { + return seh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'seh' and handles both Whole and Real numbers based on 'v' +func (seh *seh) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'seh' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (seh *seh) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'seh' +func (seh *seh) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := seh.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, seh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, seh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, seh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, seh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'seh' +// in accounting notation. +func (seh *seh) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := seh.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, seh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, seh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, seh.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, seh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'seh' +func (seh *seh) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'seh' +func (seh *seh) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, seh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'seh' +func (seh *seh) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, seh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'seh' +func (seh *seh) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, seh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, seh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'seh' +func (seh *seh) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, seh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'seh' +func (seh *seh) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, seh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, seh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'seh' +func (seh *seh) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, seh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, seh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'seh' +func (seh *seh) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, seh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, seh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := seh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/seh/seh_test.go b/vendor/github.com/go-playground/locales/seh/seh_test.go new file mode 100644 index 0000000000..0b5327038c --- /dev/null +++ b/vendor/github.com/go-playground/locales/seh/seh_test.go @@ -0,0 +1,1120 @@ +package seh + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "seh" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/seh_MZ/seh_MZ.go b/vendor/github.com/go-playground/locales/seh_MZ/seh_MZ.go new file mode 100644 index 0000000000..e9889aef89 --- /dev/null +++ b/vendor/github.com/go-playground/locales/seh_MZ/seh_MZ.go @@ -0,0 +1,508 @@ +package seh_MZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type seh_MZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'seh_MZ' locale +func New() locales.Translator { + return &seh_MZ{ + locale: "seh_MZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Aug", "Set", "Otu", "Nov", "Dec"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janeiro", "Fevreiro", "Marco", "Abril", "Maio", "Junho", "Julho", "Augusto", "Setembro", "Otubro", "Novembro", "Decembro"}, + daysAbbreviated: []string{"Dim", "Pos", "Pir", "Tat", "Nai", "Sha", "Sab"}, + daysNarrow: []string{"D", "P", "C", "T", "N", "S", "S"}, + daysWide: []string{"Dimingu", "Chiposi", "Chipiri", "Chitatu", "Chinai", "Chishanu", "Sabudu"}, + erasAbbreviated: []string{"AC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Antes de Cristo", "Anno Domini"}, + timezones: map[string]string{"HEPM": "HEPM", "ChST": "ChST", "ACWST": "ACWST", "CAT": "CAT", "AEDT": "AEDT", "AKDT": "AKDT", "UYT": "UYT", "WAT": "WAT", "SRT": "SRT", "CHADT": "CHADT", "EDT": "EDT", "HENOMX": "HENOMX", "HNPM": "HNPM", "HNPMX": "HNPMX", "OESZ": "OESZ", "PDT": "PDT", "HADT": "HADT", "CLT": "CLT", "HNOG": "HNOG", "TMST": "TMST", "MDT": "MDT", "GFT": "GFT", "UYST": "UYST", "ACST": "ACST", "HEEG": "HEEG", "HNT": "HNT", "BOT": "BOT", "ADT": "ADT", "ACDT": "ACDT", "WESZ": "WESZ", "MYT": "MYT", "HNCU": "HNCU", "SGT": "SGT", "IST": "IST", "ACWDT": "ACWDT", "NZST": "NZST", "OEZ": "OEZ", "CLST": "CLST", "EST": "EST", "AKST": "AKST", "CDT": "CDT", "AWST": "AWST", "HKT": "HKT", "HNNOMX": "HNNOMX", "∅∅∅": "∅∅∅", "SAST": "SAST", "JDT": "JDT", "BT": "BT", "AEST": "AEST", "MEZ": "MEZ", "HKST": "HKST", "CHAST": "CHAST", "HAST": "HAST", "WARST": "WARST", "HEOG": "HEOG", "ARST": "ARST", "WITA": "WITA", "LHST": "LHST", "AWDT": "AWDT", "COT": "COT", "HNEG": "HNEG", "VET": "VET", "TMT": "TMT", "COST": "COST", "HAT": "HAT", "LHDT": "LHDT", "GYT": "GYT", "EAT": "EAT", "JST": "JST", "WEZ": "WEZ", "WAST": "WAST", "MST": "MST", "HECU": "HECU", "ECT": "ECT", "GMT": "GMT", "ART": "ART", "AST": "AST", "WIT": "WIT", "NZDT": "NZDT", "WART": "WART", "PST": "PST", "MESZ": "MESZ", "HEPMX": "HEPMX", "WIB": "WIB", "CST": "CST"}, + } +} + +// Locale returns the current translators string locale +func (seh *seh_MZ) Locale() string { + return seh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'seh_MZ' +func (seh *seh_MZ) PluralsCardinal() []locales.PluralRule { + return seh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'seh_MZ' +func (seh *seh_MZ) PluralsOrdinal() []locales.PluralRule { + return seh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'seh_MZ' +func (seh *seh_MZ) PluralsRange() []locales.PluralRule { + return seh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'seh_MZ' +func (seh *seh_MZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'seh_MZ' +func (seh *seh_MZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'seh_MZ' +func (seh *seh_MZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (seh *seh_MZ) MonthAbbreviated(month time.Month) string { + return seh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (seh *seh_MZ) MonthsAbbreviated() []string { + return seh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (seh *seh_MZ) MonthNarrow(month time.Month) string { + return seh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (seh *seh_MZ) MonthsNarrow() []string { + return seh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (seh *seh_MZ) MonthWide(month time.Month) string { + return seh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (seh *seh_MZ) MonthsWide() []string { + return seh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (seh *seh_MZ) WeekdayAbbreviated(weekday time.Weekday) string { + return seh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (seh *seh_MZ) WeekdaysAbbreviated() []string { + return seh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (seh *seh_MZ) WeekdayNarrow(weekday time.Weekday) string { + return seh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (seh *seh_MZ) WeekdaysNarrow() []string { + return seh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (seh *seh_MZ) WeekdayShort(weekday time.Weekday) string { + return seh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (seh *seh_MZ) WeekdaysShort() []string { + return seh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (seh *seh_MZ) WeekdayWide(weekday time.Weekday) string { + return seh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (seh *seh_MZ) WeekdaysWide() []string { + return seh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'seh_MZ' and handles both Whole and Real numbers based on 'v' +func (seh *seh_MZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'seh_MZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (seh *seh_MZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'seh_MZ' +func (seh *seh_MZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := seh.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, seh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, seh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, seh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, seh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'seh_MZ' +// in accounting notation. +func (seh *seh_MZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := seh.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, seh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, seh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, seh.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, seh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'seh_MZ' +func (seh *seh_MZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'seh_MZ' +func (seh *seh_MZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, seh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'seh_MZ' +func (seh *seh_MZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, seh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'seh_MZ' +func (seh *seh_MZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, seh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + b = append(b, seh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0x64, 0x65}...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'seh_MZ' +func (seh *seh_MZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, seh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'seh_MZ' +func (seh *seh_MZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, seh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, seh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'seh_MZ' +func (seh *seh_MZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, seh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, seh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'seh_MZ' +func (seh *seh_MZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, seh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, seh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := seh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/seh_MZ/seh_MZ_test.go b/vendor/github.com/go-playground/locales/seh_MZ/seh_MZ_test.go new file mode 100644 index 0000000000..d04e8ddd00 --- /dev/null +++ b/vendor/github.com/go-playground/locales/seh_MZ/seh_MZ_test.go @@ -0,0 +1,1120 @@ +package seh_MZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "seh_MZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ses/ses.go b/vendor/github.com/go-playground/locales/ses/ses.go new file mode 100644 index 0000000000..0a8d6cb4e1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ses/ses.go @@ -0,0 +1,500 @@ +package ses + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ses struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ses' locale +func New() locales.Translator { + return &ses{ + locale: "ses", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"}, + monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"}, + daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alz", "Asi"}, + daysNarrow: []string{"H", "T", "T", "L", "L", "L", "S"}, + daysWide: []string{"Alhadi", "Atinni", "Atalaata", "Alarba", "Alhamiisa", "Alzuma", "Asibti"}, + periodsAbbreviated: []string{"Adduha", "Aluula"}, + periodsWide: []string{"Adduha", "Aluula"}, + erasAbbreviated: []string{"IJ", "IZ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Isaa jine", "Isaa zamanoo"}, + timezones: map[string]string{"AWDT": "AWDT", "NZDT": "NZDT", "MESZ": "MESZ", "HKT": "HKT", "HEEG": "HEEG", "AST": "AST", "TMT": "TMT", "ECT": "ECT", "HNNOMX": "HNNOMX", "WITA": "WITA", "LHDT": "LHDT", "HAST": "HAST", "WARST": "WARST", "ADT": "ADT", "EST": "EST", "ACST": "ACST", "CLST": "CLST", "HEOG": "HEOG", "TMST": "TMST", "COT": "COT", "CDT": "CDT", "JST": "JST", "GMT": "GMT", "WAST": "WAST", "COST": "COST", "JDT": "JDT", "UYST": "UYST", "BOT": "BOT", "CAT": "CAT", "AKST": "AKST", "LHST": "LHST", "SGT": "SGT", "PDT": "PDT", "ACWST": "ACWST", "HENOMX": "HENOMX", "UYT": "UYT", "AWST": "AWST", "WIT": "WIT", "∅∅∅": "∅∅∅", "MDT": "MDT", "HNT": "HNT", "HECU": "HECU", "CST": "CST", "WESZ": "WESZ", "BT": "BT", "HNEG": "HNEG", "WIB": "WIB", "ACDT": "ACDT", "GFT": "GFT", "AEST": "AEST", "HEPMX": "HEPMX", "ACWDT": "ACWDT", "MEZ": "MEZ", "CLT": "CLT", "WAT": "WAT", "SRT": "SRT", "EAT": "EAT", "CHADT": "CHADT", "HADT": "HADT", "CHAST": "CHAST", "NZST": "NZST", "VET": "VET", "WEZ": "WEZ", "EDT": "EDT", "HNOG": "HNOG", "OEZ": "OEZ", "ARST": "ARST", "GYT": "GYT", "IST": "IST", "MST": "MST", "HNPM": "HNPM", "HEPM": "HEPM", "AKDT": "AKDT", "WART": "WART", "OESZ": "OESZ", "ART": "ART", "HAT": "HAT", "SAST": "SAST", "HNPMX": "HNPMX", "HNCU": "HNCU", "PST": "PST", "MYT": "MYT", "HKST": "HKST", "AEDT": "AEDT", "ChST": "ChST"}, + } +} + +// Locale returns the current translators string locale +func (ses *ses) Locale() string { + return ses.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ses' +func (ses *ses) PluralsCardinal() []locales.PluralRule { + return ses.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ses' +func (ses *ses) PluralsOrdinal() []locales.PluralRule { + return ses.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ses' +func (ses *ses) PluralsRange() []locales.PluralRule { + return ses.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ses' +func (ses *ses) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ses' +func (ses *ses) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ses' +func (ses *ses) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ses *ses) MonthAbbreviated(month time.Month) string { + return ses.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ses *ses) MonthsAbbreviated() []string { + return ses.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ses *ses) MonthNarrow(month time.Month) string { + return ses.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ses *ses) MonthsNarrow() []string { + return ses.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ses *ses) MonthWide(month time.Month) string { + return ses.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ses *ses) MonthsWide() []string { + return ses.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ses *ses) WeekdayAbbreviated(weekday time.Weekday) string { + return ses.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ses *ses) WeekdaysAbbreviated() []string { + return ses.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ses *ses) WeekdayNarrow(weekday time.Weekday) string { + return ses.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ses *ses) WeekdaysNarrow() []string { + return ses.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ses *ses) WeekdayShort(weekday time.Weekday) string { + return ses.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ses *ses) WeekdaysShort() []string { + return ses.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ses *ses) WeekdayWide(weekday time.Weekday) string { + return ses.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ses *ses) WeekdaysWide() []string { + return ses.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ses' and handles both Whole and Real numbers based on 'v' +func (ses *ses) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ses' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ses *ses) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ses' +func (ses *ses) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ses.currencies[currency] + l := len(s) + len(symbol) + 0 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ses.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ses.group) - 1; j >= 0; j-- { + b = append(b, ses.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ses.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ses.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ses' +// in accounting notation. +func (ses *ses) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ses.currencies[currency] + l := len(s) + len(symbol) + 0 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ses.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ses.group) - 1; j >= 0; j-- { + b = append(b, ses.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ses.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ses.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ses' +func (ses *ses) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ses' +func (ses *ses) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ses.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ses' +func (ses *ses) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ses.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ses' +func (ses *ses) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ses.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ses.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ses' +func (ses *ses) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ses.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ses' +func (ses *ses) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ses.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ses.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ses' +func (ses *ses) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ses.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ses.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ses' +func (ses *ses) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ses.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ses.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ses.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ses/ses_test.go b/vendor/github.com/go-playground/locales/ses/ses_test.go new file mode 100644 index 0000000000..3fdbd5b5a2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ses/ses_test.go @@ -0,0 +1,1120 @@ +package ses + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ses" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ses_ML/ses_ML.go b/vendor/github.com/go-playground/locales/ses_ML/ses_ML.go new file mode 100644 index 0000000000..eb85395ebf --- /dev/null +++ b/vendor/github.com/go-playground/locales/ses_ML/ses_ML.go @@ -0,0 +1,500 @@ +package ses_ML + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ses_ML struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ses_ML' locale +func New() locales.Translator { + return &ses_ML{ + locale: "ses_ML", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"}, + monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"}, + daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alz", "Asi"}, + daysNarrow: []string{"H", "T", "T", "L", "L", "L", "S"}, + daysWide: []string{"Alhadi", "Atinni", "Atalaata", "Alarba", "Alhamiisa", "Alzuma", "Asibti"}, + periodsAbbreviated: []string{"Adduha", "Aluula"}, + periodsWide: []string{"Adduha", "Aluula"}, + erasAbbreviated: []string{"IJ", "IZ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Isaa jine", "Isaa zamanoo"}, + timezones: map[string]string{"ART": "ART", "SAST": "SAST", "HECU": "HECU", "AWDT": "AWDT", "WEZ": "WEZ", "WITA": "WITA", "∅∅∅": "∅∅∅", "HAST": "HAST", "CAT": "CAT", "CLST": "CLST", "GYT": "GYT", "BOT": "BOT", "GMT": "GMT", "WART": "WART", "HEOG": "HEOG", "AST": "AST", "HENOMX": "HENOMX", "BT": "BT", "CST": "CST", "JDT": "JDT", "MYT": "MYT", "GFT": "GFT", "ChST": "ChST", "SGT": "SGT", "JST": "JST", "OESZ": "OESZ", "ARST": "ARST", "EST": "EST", "HEPM": "HEPM", "NZST": "NZST", "MEZ": "MEZ", "MDT": "MDT", "WAT": "WAT", "WIT": "WIT", "CHAST": "CHAST", "CLT": "CLT", "WIB": "WIB", "ACWST": "ACWST", "UYST": "UYST", "HEPMX": "HEPMX", "LHDT": "LHDT", "MESZ": "MESZ", "HNOG": "HNOG", "COT": "COT", "CDT": "CDT", "AWST": "AWST", "PDT": "PDT", "AEDT": "AEDT", "TMT": "TMT", "TMST": "TMST", "HEEG": "HEEG", "EDT": "EDT", "HNT": "HNT", "AKST": "AKST", "UYT": "UYT", "ECT": "ECT", "WARST": "WARST", "MST": "MST", "AEST": "AEST", "LHST": "LHST", "EAT": "EAT", "CHADT": "CHADT", "ACDT": "ACDT", "AKDT": "AKDT", "SRT": "SRT", "VET": "VET", "HKST": "HKST", "PST": "PST", "NZDT": "NZDT", "IST": "IST", "ADT": "ADT", "ACST": "ACST", "HNPM": "HNPM", "HNPMX": "HNPMX", "HNCU": "HNCU", "OEZ": "OEZ", "HKT": "HKT", "WAST": "WAST", "HNNOMX": "HNNOMX", "COST": "COST", "HADT": "HADT", "ACWDT": "ACWDT", "WESZ": "WESZ", "HNEG": "HNEG", "HAT": "HAT"}, + } +} + +// Locale returns the current translators string locale +func (ses *ses_ML) Locale() string { + return ses.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ses_ML' +func (ses *ses_ML) PluralsCardinal() []locales.PluralRule { + return ses.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ses_ML' +func (ses *ses_ML) PluralsOrdinal() []locales.PluralRule { + return ses.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ses_ML' +func (ses *ses_ML) PluralsRange() []locales.PluralRule { + return ses.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ses_ML' +func (ses *ses_ML) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ses_ML' +func (ses *ses_ML) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ses_ML' +func (ses *ses_ML) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ses *ses_ML) MonthAbbreviated(month time.Month) string { + return ses.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ses *ses_ML) MonthsAbbreviated() []string { + return ses.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ses *ses_ML) MonthNarrow(month time.Month) string { + return ses.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ses *ses_ML) MonthsNarrow() []string { + return ses.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ses *ses_ML) MonthWide(month time.Month) string { + return ses.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ses *ses_ML) MonthsWide() []string { + return ses.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ses *ses_ML) WeekdayAbbreviated(weekday time.Weekday) string { + return ses.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ses *ses_ML) WeekdaysAbbreviated() []string { + return ses.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ses *ses_ML) WeekdayNarrow(weekday time.Weekday) string { + return ses.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ses *ses_ML) WeekdaysNarrow() []string { + return ses.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ses *ses_ML) WeekdayShort(weekday time.Weekday) string { + return ses.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ses *ses_ML) WeekdaysShort() []string { + return ses.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ses *ses_ML) WeekdayWide(weekday time.Weekday) string { + return ses.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ses *ses_ML) WeekdaysWide() []string { + return ses.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ses_ML' and handles both Whole and Real numbers based on 'v' +func (ses *ses_ML) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ses_ML' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ses *ses_ML) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ses_ML' +func (ses *ses_ML) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ses.currencies[currency] + l := len(s) + len(symbol) + 0 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ses.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ses.group) - 1; j >= 0; j-- { + b = append(b, ses.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ses.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ses.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ses_ML' +// in accounting notation. +func (ses *ses_ML) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ses.currencies[currency] + l := len(s) + len(symbol) + 0 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ses.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(ses.group) - 1; j >= 0; j-- { + b = append(b, ses.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, ses.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ses.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ses_ML' +func (ses *ses_ML) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ses_ML' +func (ses *ses_ML) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ses.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ses_ML' +func (ses *ses_ML) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ses.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ses_ML' +func (ses *ses_ML) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ses.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ses.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ses_ML' +func (ses *ses_ML) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ses.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ses_ML' +func (ses *ses_ML) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ses.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ses.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ses_ML' +func (ses *ses_ML) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ses.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ses.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ses_ML' +func (ses *ses_ML) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ses.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ses.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ses.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ses_ML/ses_ML_test.go b/vendor/github.com/go-playground/locales/ses_ML/ses_ML_test.go new file mode 100644 index 0000000000..533c8244dd --- /dev/null +++ b/vendor/github.com/go-playground/locales/ses_ML/ses_ML_test.go @@ -0,0 +1,1120 @@ +package ses_ML + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ses_ML" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sg/sg.go b/vendor/github.com/go-playground/locales/sg/sg.go new file mode 100644 index 0000000000..091681c38a --- /dev/null +++ b/vendor/github.com/go-playground/locales/sg/sg.go @@ -0,0 +1,502 @@ +package sg + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sg struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sg' locale +func New() locales.Translator { + return &sg{ + locale: "sg", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Nye", "Ful", "Mbä", "Ngu", "Bêl", "Fön", "Len", "Kük", "Mvu", "Ngb", "Nab", "Kak"}, + monthsNarrow: []string{"", "N", "F", "M", "N", "B", "F", "L", "K", "M", "N", "N", "K"}, + monthsWide: []string{"", "Nyenye", "Fulundïgi", "Mbängü", "Ngubùe", "Bêläwü", "Föndo", "Lengua", "Kükürü", "Mvuka", "Ngberere", "Nabändüru", "Kakauka"}, + daysAbbreviated: []string{"Bk1", "Bk2", "Bk3", "Bk4", "Bk5", "Lâp", "Lây"}, + daysNarrow: []string{"K", "S", "T", "S", "K", "P", "Y"}, + daysWide: []string{"Bikua-ôko", "Bïkua-ûse", "Bïkua-ptâ", "Bïkua-usïö", "Bïkua-okü", "Lâpôsö", "Lâyenga"}, + periodsAbbreviated: []string{"ND", "LK"}, + periodsWide: []string{"ND", "LK"}, + erasAbbreviated: []string{"KnK", "NpK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kôzo na Krîstu", "Na pekô tî Krîstu"}, + timezones: map[string]string{"OESZ": "OESZ", "WEZ": "WEZ", "UYST": "UYST", "LHDT": "LHDT", "HAST": "HAST", "AWDT": "AWDT", "CHADT": "CHADT", "MEZ": "MEZ", "CLST": "CLST", "WESZ": "WESZ", "HENOMX": "HENOMX", "HEEG": "HEEG", "HECU": "HECU", "PDT": "PDT", "ACWDT": "ACWDT", "IST": "IST", "WARST": "WARST", "HNOG": "HNOG", "TMT": "TMT", "HNEG": "HNEG", "HADT": "HADT", "∅∅∅": "∅∅∅", "WART": "WART", "EDT": "EDT", "BOT": "BOT", "ARST": "ARST", "WAT": "WAT", "ACWST": "ACWST", "MESZ": "MESZ", "GMT": "GMT", "MYT": "MYT", "ADT": "ADT", "MDT": "MDT", "EST": "EST", "CHAST": "CHAST", "AST": "AST", "COST": "COST", "SRT": "SRT", "SAST": "SAST", "WIB": "WIB", "CST": "CST", "ECT": "ECT", "NZDT": "NZDT", "VET": "VET", "TMST": "TMST", "ART": "ART", "HKT": "HKT", "UYT": "UYT", "NZST": "NZST", "WITA": "WITA", "CDT": "CDT", "COT": "COT", "HNNOMX": "HNNOMX", "WIT": "WIT", "WAST": "WAST", "AKDT": "AKDT", "AEDT": "AEDT", "AKST": "AKST", "HEPMX": "HEPMX", "GYT": "GYT", "PST": "PST", "MST": "MST", "ACDT": "ACDT", "BT": "BT", "HNT": "HNT", "LHST": "LHST", "AWST": "AWST", "JST": "JST", "OEZ": "OEZ", "ChST": "ChST", "EAT": "EAT", "HEOG": "HEOG", "ACST": "ACST", "HAT": "HAT", "AEST": "AEST", "HEPM": "HEPM", "HNPMX": "HNPMX", "HNCU": "HNCU", "SGT": "SGT", "CAT": "CAT", "JDT": "JDT", "CLT": "CLT", "HKST": "HKST", "GFT": "GFT", "HNPM": "HNPM"}, + } +} + +// Locale returns the current translators string locale +func (sg *sg) Locale() string { + return sg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sg' +func (sg *sg) PluralsCardinal() []locales.PluralRule { + return sg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sg' +func (sg *sg) PluralsOrdinal() []locales.PluralRule { + return sg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sg' +func (sg *sg) PluralsRange() []locales.PluralRule { + return sg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sg' +func (sg *sg) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sg' +func (sg *sg) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sg' +func (sg *sg) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sg *sg) MonthAbbreviated(month time.Month) string { + return sg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sg *sg) MonthsAbbreviated() []string { + return sg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sg *sg) MonthNarrow(month time.Month) string { + return sg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sg *sg) MonthsNarrow() []string { + return sg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sg *sg) MonthWide(month time.Month) string { + return sg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sg *sg) MonthsWide() []string { + return sg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sg *sg) WeekdayAbbreviated(weekday time.Weekday) string { + return sg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sg *sg) WeekdaysAbbreviated() []string { + return sg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sg *sg) WeekdayNarrow(weekday time.Weekday) string { + return sg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sg *sg) WeekdaysNarrow() []string { + return sg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sg *sg) WeekdayShort(weekday time.Weekday) string { + return sg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sg *sg) WeekdaysShort() []string { + return sg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sg *sg) WeekdayWide(weekday time.Weekday) string { + return sg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sg *sg) WeekdaysWide() []string { + return sg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sg' and handles both Whole and Real numbers based on 'v' +func (sg *sg) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sg' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sg *sg) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sg' +func (sg *sg) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sg.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sg' +// in accounting notation. +func (sg *sg) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sg.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sg.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sg' +func (sg *sg) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sg' +func (sg *sg) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sg' +func (sg *sg) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sg' +func (sg *sg) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sg' +func (sg *sg) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sg' +func (sg *sg) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sg' +func (sg *sg) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sg' +func (sg *sg) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sg/sg_test.go b/vendor/github.com/go-playground/locales/sg/sg_test.go new file mode 100644 index 0000000000..85aaeb4850 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sg/sg_test.go @@ -0,0 +1,1120 @@ +package sg + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sg" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sg_CF/sg_CF.go b/vendor/github.com/go-playground/locales/sg_CF/sg_CF.go new file mode 100644 index 0000000000..1dd55330b7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sg_CF/sg_CF.go @@ -0,0 +1,502 @@ +package sg_CF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sg_CF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sg_CF' locale +func New() locales.Translator { + return &sg_CF{ + locale: "sg_CF", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: ".", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Nye", "Ful", "Mbä", "Ngu", "Bêl", "Fön", "Len", "Kük", "Mvu", "Ngb", "Nab", "Kak"}, + monthsNarrow: []string{"", "N", "F", "M", "N", "B", "F", "L", "K", "M", "N", "N", "K"}, + monthsWide: []string{"", "Nyenye", "Fulundïgi", "Mbängü", "Ngubùe", "Bêläwü", "Föndo", "Lengua", "Kükürü", "Mvuka", "Ngberere", "Nabändüru", "Kakauka"}, + daysAbbreviated: []string{"Bk1", "Bk2", "Bk3", "Bk4", "Bk5", "Lâp", "Lây"}, + daysNarrow: []string{"K", "S", "T", "S", "K", "P", "Y"}, + daysWide: []string{"Bikua-ôko", "Bïkua-ûse", "Bïkua-ptâ", "Bïkua-usïö", "Bïkua-okü", "Lâpôsö", "Lâyenga"}, + periodsAbbreviated: []string{"ND", "LK"}, + periodsWide: []string{"ND", "LK"}, + erasAbbreviated: []string{"KnK", "NpK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kôzo na Krîstu", "Na pekô tî Krîstu"}, + timezones: map[string]string{"WIB": "WIB", "CLT": "CLT", "HNEG": "HNEG", "HAST": "HAST", "MEZ": "MEZ", "OEZ": "OEZ", "WAT": "WAT", "SAST": "SAST", "AKDT": "AKDT", "UYT": "UYT", "ACWST": "ACWST", "JST": "JST", "TMT": "TMT", "MST": "MST", "COST": "COST", "AEDT": "AEDT", "HEPMX": "HEPMX", "UYST": "UYST", "LHST": "LHST", "HECU": "HECU", "CST": "CST", "WIT": "WIT", "WART": "WART", "ACST": "ACST", "WITA": "WITA", "LHDT": "LHDT", "WESZ": "WESZ", "MDT": "MDT", "HEEG": "HEEG", "AKST": "AKST", "ChST": "ChST", "ACWDT": "ACWDT", "CLST": "CLST", "HKST": "HKST", "HAT": "HAT", "GFT": "GFT", "VET": "VET", "ART": "ART", "HKT": "HKT", "HEPM": "HEPM", "ARST": "ARST", "HNT": "HNT", "BOT": "BOT", "PST": "PST", "IST": "IST", "JDT": "JDT", "GMT": "GMT", "AST": "AST", "HENOMX": "HENOMX", "BT": "BT", "HNCU": "HNCU", "AWST": "AWST", "SGT": "SGT", "ECT": "ECT", "HADT": "HADT", "WEZ": "WEZ", "HNOG": "HNOG", "AEST": "AEST", "HNPM": "HNPM", "AWDT": "AWDT", "MYT": "MYT", "EDT": "EDT", "HNNOMX": "HNNOMX", "EAT": "EAT", "CDT": "CDT", "CHAST": "CHAST", "NZST": "NZST", "COT": "COT", "HNPMX": "HNPMX", "GYT": "GYT", "CHADT": "CHADT", "ADT": "ADT", "WAST": "WAST", "ACDT": "ACDT", "SRT": "SRT", "∅∅∅": "∅∅∅", "NZDT": "NZDT", "CAT": "CAT", "MESZ": "MESZ", "HEOG": "HEOG", "TMST": "TMST", "PDT": "PDT", "OESZ": "OESZ", "WARST": "WARST", "EST": "EST"}, + } +} + +// Locale returns the current translators string locale +func (sg *sg_CF) Locale() string { + return sg.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sg_CF' +func (sg *sg_CF) PluralsCardinal() []locales.PluralRule { + return sg.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sg_CF' +func (sg *sg_CF) PluralsOrdinal() []locales.PluralRule { + return sg.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sg_CF' +func (sg *sg_CF) PluralsRange() []locales.PluralRule { + return sg.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sg_CF' +func (sg *sg_CF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sg_CF' +func (sg *sg_CF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sg_CF' +func (sg *sg_CF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sg *sg_CF) MonthAbbreviated(month time.Month) string { + return sg.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sg *sg_CF) MonthsAbbreviated() []string { + return sg.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sg *sg_CF) MonthNarrow(month time.Month) string { + return sg.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sg *sg_CF) MonthsNarrow() []string { + return sg.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sg *sg_CF) MonthWide(month time.Month) string { + return sg.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sg *sg_CF) MonthsWide() []string { + return sg.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sg *sg_CF) WeekdayAbbreviated(weekday time.Weekday) string { + return sg.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sg *sg_CF) WeekdaysAbbreviated() []string { + return sg.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sg *sg_CF) WeekdayNarrow(weekday time.Weekday) string { + return sg.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sg *sg_CF) WeekdaysNarrow() []string { + return sg.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sg *sg_CF) WeekdayShort(weekday time.Weekday) string { + return sg.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sg *sg_CF) WeekdaysShort() []string { + return sg.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sg *sg_CF) WeekdayWide(weekday time.Weekday) string { + return sg.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sg *sg_CF) WeekdaysWide() []string { + return sg.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sg_CF' and handles both Whole and Real numbers based on 'v' +func (sg *sg_CF) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sg_CF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sg *sg_CF) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sg_CF' +func (sg *sg_CF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sg.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sg.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sg_CF' +// in accounting notation. +func (sg *sg_CF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sg.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sg.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sg.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sg.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sg.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sg_CF' +func (sg *sg_CF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sg_CF' +func (sg *sg_CF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sg.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sg_CF' +func (sg *sg_CF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sg_CF' +func (sg *sg_CF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sg.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sg.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sg_CF' +func (sg *sg_CF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sg_CF' +func (sg *sg_CF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sg_CF' +func (sg *sg_CF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sg_CF' +func (sg *sg_CF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sg.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sg.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sg.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sg_CF/sg_CF_test.go b/vendor/github.com/go-playground/locales/sg_CF/sg_CF_test.go new file mode 100644 index 0000000000..8db0efb24d --- /dev/null +++ b/vendor/github.com/go-playground/locales/sg_CF/sg_CF_test.go @@ -0,0 +1,1120 @@ +package sg_CF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sg_CF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/shi/shi.go b/vendor/github.com/go-playground/locales/shi/shi.go new file mode 100644 index 0000000000..f20ccf253b --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi/shi.go @@ -0,0 +1,424 @@ +package shi + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type shi struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'shi' locale +func New() locales.Translator { + return &shi{ + locale: "shi", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ⵉⵏⵏ", "ⴱⵕⴰ", "ⵎⴰⵕ", "ⵉⴱⵔ", "ⵎⴰⵢ", "ⵢⵓⵏ", "ⵢⵓⵍ", "ⵖⵓⵛ", "ⵛⵓⵜ", "ⴽⵜⵓ", "ⵏⵓⵡ", "ⴷⵓⵊ"}, + monthsNarrow: []string{"", "ⵉ", "ⴱ", "ⵎ", "ⵉ", "ⵎ", "ⵢ", "ⵢ", "ⵖ", "ⵛ", "ⴽ", "ⵏ", "ⴷ"}, + monthsWide: []string{"", "ⵉⵏⵏⴰⵢⵔ", "ⴱⵕⴰⵢⵕ", "ⵎⴰⵕⵚ", "ⵉⴱⵔⵉⵔ", "ⵎⴰⵢⵢⵓ", "ⵢⵓⵏⵢⵓ", "ⵢⵓⵍⵢⵓⵣ", "ⵖⵓⵛⵜ", "ⵛⵓⵜⴰⵏⴱⵉⵔ", "ⴽⵜⵓⴱⵔ", "ⵏⵓⵡⴰⵏⴱⵉⵔ", "ⴷⵓⵊⴰⵏⴱⵉⵔ"}, + daysAbbreviated: []string{"ⴰⵙⴰ", "ⴰⵢⵏ", "ⴰⵙⵉ", "ⴰⴽⵕ", "ⴰⴽⵡ", "ⴰⵙⵉⵎ", "ⴰⵙⵉⴹ"}, + daysWide: []string{"ⴰⵙⴰⵎⴰⵙ", "ⴰⵢⵏⴰⵙ", "ⴰⵙⵉⵏⴰⵙ", "ⴰⴽⵕⴰⵙ", "ⴰⴽⵡⴰⵙ", "ⵙⵉⵎⵡⴰⵙ", "ⴰⵙⵉⴹⵢⴰⵙ"}, + periodsAbbreviated: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + periodsWide: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + erasAbbreviated: []string{"ⴷⴰⵄ", "ⴷⴼⵄ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ⴷⴰⵜ ⵏ ⵄⵉⵙⴰ", "ⴷⴼⴼⵉⵔ ⵏ ⵄⵉⵙⴰ"}, + timezones: map[string]string{"WAT": "WAT", "SAST": "SAST", "WIT": "WIT", "SGT": "SGT", "PDT": "PDT", "MESZ": "MESZ", "JDT": "JDT", "TMT": "TMT", "CLT": "CLT", "HEEG": "HEEG", "AEST": "AEST", "ChST": "ChST", "CHADT": "CHADT", "IST": "IST", "WART": "WART", "HKST": "HKST", "HNT": "HNT", "CST": "CST", "ECT": "ECT", "ACWDT": "ACWDT", "CHAST": "CHAST", "MDT": "MDT", "ARST": "ARST", "HNNOMX": "HNNOMX", "HAT": "HAT", "HEPM": "HEPM", "PST": "PST", "HNOG": "HNOG", "EST": "EST", "AEDT": "AEDT", "LHST": "LHST", "GFT": "GFT", "∅∅∅": "∅∅∅", "AWDT": "AWDT", "GMT": "GMT", "ACDT": "ACDT", "COT": "COT", "COST": "COST", "HNCU": "HNCU", "HADT": "HADT", "NZDT": "NZDT", "JST": "JST", "AST": "AST", "HENOMX": "HENOMX", "AKST": "AKST", "UYST": "UYST", "GYT": "GYT", "CDT": "CDT", "NZST": "NZST", "WAST": "WAST", "EDT": "EDT", "HKT": "HKT", "ART": "ART", "BT": "BT", "HECU": "HECU", "MEZ": "MEZ", "ADT": "ADT", "OESZ": "OESZ", "WARST": "WARST", "MST": "MST", "WIB": "WIB", "VET": "VET", "CAT": "CAT", "ACWST": "ACWST", "OEZ": "OEZ", "HEOG": "HEOG", "LHDT": "LHDT", "WEZ": "WEZ", "WESZ": "WESZ", "MYT": "MYT", "AKDT": "AKDT", "WITA": "WITA", "SRT": "SRT", "AWST": "AWST", "TMST": "TMST", "HEPMX": "HEPMX", "EAT": "EAT", "BOT": "BOT", "HAST": "HAST", "ACST": "ACST", "UYT": "UYT", "HNPM": "HNPM", "CLST": "CLST", "HNEG": "HNEG", "HNPMX": "HNPMX"}, + } +} + +// Locale returns the current translators string locale +func (shi *shi) Locale() string { + return shi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'shi' +func (shi *shi) PluralsCardinal() []locales.PluralRule { + return shi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'shi' +func (shi *shi) PluralsOrdinal() []locales.PluralRule { + return shi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'shi' +func (shi *shi) PluralsRange() []locales.PluralRule { + return shi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'shi' +func (shi *shi) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } else if n >= 2 && n <= 10 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'shi' +func (shi *shi) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'shi' +func (shi *shi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (shi *shi) MonthAbbreviated(month time.Month) string { + return shi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (shi *shi) MonthsAbbreviated() []string { + return shi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (shi *shi) MonthNarrow(month time.Month) string { + return shi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (shi *shi) MonthsNarrow() []string { + return shi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (shi *shi) MonthWide(month time.Month) string { + return shi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (shi *shi) MonthsWide() []string { + return shi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (shi *shi) WeekdayAbbreviated(weekday time.Weekday) string { + return shi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (shi *shi) WeekdaysAbbreviated() []string { + return shi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (shi *shi) WeekdayNarrow(weekday time.Weekday) string { + return shi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (shi *shi) WeekdaysNarrow() []string { + return shi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (shi *shi) WeekdayShort(weekday time.Weekday) string { + return shi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (shi *shi) WeekdaysShort() []string { + return shi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (shi *shi) WeekdayWide(weekday time.Weekday) string { + return shi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (shi *shi) WeekdaysWide() []string { + return shi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'shi' and handles both Whole and Real numbers based on 'v' +func (shi *shi) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'shi' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (shi *shi) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'shi' +func (shi *shi) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, shi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'shi' +// in accounting notation. +func (shi *shi) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, shi.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'shi' +func (shi *shi) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'shi' +func (shi *shi) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'shi' +func (shi *shi) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'shi' +func (shi *shi) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, shi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'shi' +func (shi *shi) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'shi' +func (shi *shi) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'shi' +func (shi *shi) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'shi' +func (shi *shi) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/shi/shi_test.go b/vendor/github.com/go-playground/locales/shi/shi_test.go new file mode 100644 index 0000000000..1f0560f0d7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi/shi_test.go @@ -0,0 +1,1120 @@ +package shi + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "shi" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/shi_Latn/shi_Latn.go b/vendor/github.com/go-playground/locales/shi_Latn/shi_Latn.go new file mode 100644 index 0000000000..b8d2133003 --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi_Latn/shi_Latn.go @@ -0,0 +1,424 @@ +package shi_Latn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type shi_Latn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'shi_Latn' locale +func New() locales.Translator { + return &shi_Latn{ + locale: "shi_Latn", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "inn", "bṛa", "maṛ", "ibr", "may", "yun", "yul", "ɣuc", "cut", "ktu", "nuw", "duj"}, + monthsNarrow: []string{"", "i", "b", "m", "i", "m", "y", "y", "ɣ", "c", "k", "n", "d"}, + monthsWide: []string{"", "innayr", "bṛayṛ", "maṛṣ", "ibrir", "mayyu", "yunyu", "yulyuz", "ɣuct", "cutanbir", "ktubr", "nuwanbir", "dujanbir"}, + daysAbbreviated: []string{"asa", "ayn", "asi", "akṛ", "akw", "asim", "asiḍ"}, + daysWide: []string{"asamas", "aynas", "asinas", "akṛas", "akwas", "asimwas", "asiḍyas"}, + periodsAbbreviated: []string{"tifawt", "tadggʷat"}, + periodsWide: []string{"tifawt", "tadggʷat"}, + erasAbbreviated: []string{"daɛ", "dfɛ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"dat n ɛisa", "dffir n ɛisa"}, + timezones: map[string]string{"GMT": "GMT", "GFT": "GFT", "MYT": "MYT", "GYT": "GYT", "PST": "PST", "WESZ": "WESZ", "MST": "MST", "EST": "EST", "COST": "COST", "AEDT": "AEDT", "SAST": "SAST", "WIB": "WIB", "ACWST": "ACWST", "NZST": "NZST", "NZDT": "NZDT", "WART": "WART", "MDT": "MDT", "ART": "ART", "WITA": "WITA", "TMST": "TMST", "UYST": "UYST", "HNCU": "HNCU", "AWDT": "AWDT", "SGT": "SGT", "HKT": "HKT", "HNT": "HNT", "HNEG": "HNEG", "ChST": "ChST", "HAST": "HAST", "AST": "AST", "CLT": "CLT", "TMT": "TMT", "HENOMX": "HENOMX", "LHST": "LHST", "HECU": "HECU", "HEOG": "HEOG", "ADT": "ADT", "HEEG": "HEEG", "PDT": "PDT", "ACWDT": "ACWDT", "MEZ": "MEZ", "JST": "JST", "HNOG": "HNOG", "OESZ": "OESZ", "∅∅∅": "∅∅∅", "VET": "VET", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "SRT": "SRT", "EAT": "EAT", "HADT": "HADT", "WAST": "WAST", "HKST": "HKST", "AKDT": "AKDT", "HEPM": "HEPM", "CDT": "CDT", "CHADT": "CHADT", "WAT": "WAT", "ACDT": "ACDT", "WIT": "WIT", "AWST": "AWST", "CHAST": "CHAST", "ACST": "ACST", "CST": "CST", "IST": "IST", "MESZ": "MESZ", "JDT": "JDT", "CLST": "CLST", "BT": "BT", "OEZ": "OEZ", "WEZ": "WEZ", "WARST": "WARST", "EDT": "EDT", "BOT": "BOT", "ECT": "ECT", "CAT": "CAT", "ARST": "ARST", "COT": "COT", "HNNOMX": "HNNOMX", "HAT": "HAT", "AKST": "AKST", "AEST": "AEST", "UYT": "UYT", "HNPM": "HNPM", "LHDT": "LHDT"}, + } +} + +// Locale returns the current translators string locale +func (shi *shi_Latn) Locale() string { + return shi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'shi_Latn' +func (shi *shi_Latn) PluralsCardinal() []locales.PluralRule { + return shi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'shi_Latn' +func (shi *shi_Latn) PluralsOrdinal() []locales.PluralRule { + return shi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'shi_Latn' +func (shi *shi_Latn) PluralsRange() []locales.PluralRule { + return shi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'shi_Latn' +func (shi *shi_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } else if n >= 2 && n <= 10 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'shi_Latn' +func (shi *shi_Latn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'shi_Latn' +func (shi *shi_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (shi *shi_Latn) MonthAbbreviated(month time.Month) string { + return shi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (shi *shi_Latn) MonthsAbbreviated() []string { + return shi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (shi *shi_Latn) MonthNarrow(month time.Month) string { + return shi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (shi *shi_Latn) MonthsNarrow() []string { + return shi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (shi *shi_Latn) MonthWide(month time.Month) string { + return shi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (shi *shi_Latn) MonthsWide() []string { + return shi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (shi *shi_Latn) WeekdayAbbreviated(weekday time.Weekday) string { + return shi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (shi *shi_Latn) WeekdaysAbbreviated() []string { + return shi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (shi *shi_Latn) WeekdayNarrow(weekday time.Weekday) string { + return shi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (shi *shi_Latn) WeekdaysNarrow() []string { + return shi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (shi *shi_Latn) WeekdayShort(weekday time.Weekday) string { + return shi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (shi *shi_Latn) WeekdaysShort() []string { + return shi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (shi *shi_Latn) WeekdayWide(weekday time.Weekday) string { + return shi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (shi *shi_Latn) WeekdaysWide() []string { + return shi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'shi_Latn' and handles both Whole and Real numbers based on 'v' +func (shi *shi_Latn) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'shi_Latn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (shi *shi_Latn) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'shi_Latn' +func (shi *shi_Latn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, shi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'shi_Latn' +// in accounting notation. +func (shi *shi_Latn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, shi.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'shi_Latn' +func (shi *shi_Latn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'shi_Latn' +func (shi *shi_Latn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'shi_Latn' +func (shi *shi_Latn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'shi_Latn' +func (shi *shi_Latn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, shi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'shi_Latn' +func (shi *shi_Latn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'shi_Latn' +func (shi *shi_Latn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'shi_Latn' +func (shi *shi_Latn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'shi_Latn' +func (shi *shi_Latn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/shi_Latn/shi_Latn_test.go b/vendor/github.com/go-playground/locales/shi_Latn/shi_Latn_test.go new file mode 100644 index 0000000000..aa7f29637e --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi_Latn/shi_Latn_test.go @@ -0,0 +1,1120 @@ +package shi_Latn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "shi_Latn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/shi_Latn_MA/shi_Latn_MA.go b/vendor/github.com/go-playground/locales/shi_Latn_MA/shi_Latn_MA.go new file mode 100644 index 0000000000..97e56f1498 --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi_Latn_MA/shi_Latn_MA.go @@ -0,0 +1,424 @@ +package shi_Latn_MA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type shi_Latn_MA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'shi_Latn_MA' locale +func New() locales.Translator { + return &shi_Latn_MA{ + locale: "shi_Latn_MA", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ⵉⵏⵏ", "ⴱⵕⴰ", "ⵎⴰⵕ", "ⵉⴱⵔ", "ⵎⴰⵢ", "ⵢⵓⵏ", "ⵢⵓⵍ", "ⵖⵓⵛ", "ⵛⵓⵜ", "ⴽⵜⵓ", "ⵏⵓⵡ", "ⴷⵓⵊ"}, + monthsNarrow: []string{"", "ⵉ", "ⴱ", "ⵎ", "ⵉ", "ⵎ", "ⵢ", "ⵢ", "ⵖ", "ⵛ", "ⴽ", "ⵏ", "ⴷ"}, + monthsWide: []string{"", "ⵉⵏⵏⴰⵢⵔ", "ⴱⵕⴰⵢⵕ", "ⵎⴰⵕⵚ", "ⵉⴱⵔⵉⵔ", "ⵎⴰⵢⵢⵓ", "ⵢⵓⵏⵢⵓ", "ⵢⵓⵍⵢⵓⵣ", "ⵖⵓⵛⵜ", "ⵛⵓⵜⴰⵏⴱⵉⵔ", "ⴽⵜⵓⴱⵔ", "ⵏⵓⵡⴰⵏⴱⵉⵔ", "ⴷⵓⵊⴰⵏⴱⵉⵔ"}, + daysAbbreviated: []string{"ⴰⵙⴰ", "ⴰⵢⵏ", "ⴰⵙⵉ", "ⴰⴽⵕ", "ⴰⴽⵡ", "ⴰⵙⵉⵎ", "ⴰⵙⵉⴹ"}, + daysWide: []string{"ⴰⵙⴰⵎⴰⵙ", "ⴰⵢⵏⴰⵙ", "ⴰⵙⵉⵏⴰⵙ", "ⴰⴽⵕⴰⵙ", "ⴰⴽⵡⴰⵙ", "ⵙⵉⵎⵡⴰⵙ", "ⴰⵙⵉⴹⵢⴰⵙ"}, + periodsAbbreviated: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + periodsWide: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + erasAbbreviated: []string{"ⴷⴰⵄ", "ⴷⴼⵄ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ⴷⴰⵜ ⵏ ⵄⵉⵙⴰ", "ⴷⴼⴼⵉⵔ ⵏ ⵄⵉⵙⴰ"}, + timezones: map[string]string{"HADT": "HADT", "ARST": "ARST", "CDT": "CDT", "ECT": "ECT", "CAT": "CAT", "IST": "IST", "WART": "WART", "HNT": "HNT", "HAT": "HAT", "UYST": "UYST", "EST": "EST", "∅∅∅": "∅∅∅", "CHAST": "CHAST", "ADT": "ADT", "MESZ": "MESZ", "WESZ": "WESZ", "HKT": "HKT", "COT": "COT", "HEEG": "HEEG", "AKST": "AKST", "ACWDT": "ACWDT", "CHADT": "CHADT", "CLT": "CLT", "HNOG": "HNOG", "OESZ": "OESZ", "ChST": "ChST", "WIB": "WIB", "BOT": "BOT", "WIT": "WIT", "NZST": "NZST", "WAT": "WAT", "HNPM": "HNPM", "HNPMX": "HNPMX", "SAST": "SAST", "EAT": "EAT", "AST": "AST", "ACST": "ACST", "HNEG": "HNEG", "AEST": "AEST", "ACWST": "ACWST", "ART": "ART", "HKST": "HKST", "WAST": "WAST", "HNNOMX": "HNNOMX", "ACDT": "ACDT", "UYT": "UYT", "LHST": "LHST", "CLST": "CLST", "GYT": "GYT", "AWDT": "AWDT", "WEZ": "WEZ", "GMT": "GMT", "MYT": "MYT", "BT": "BT", "HEPMX": "HEPMX", "SRT": "SRT", "WARST": "WARST", "TMST": "TMST", "EDT": "EDT", "AEDT": "AEDT", "WITA": "WITA", "PDT": "PDT", "HEPM": "HEPM", "LHDT": "LHDT", "HNCU": "HNCU", "JST": "JST", "JDT": "JDT", "MEZ": "MEZ", "HEOG": "HEOG", "OEZ": "OEZ", "MDT": "MDT", "AKDT": "AKDT", "HAST": "HAST", "TMT": "TMT", "GFT": "GFT", "HENOMX": "HENOMX", "AWST": "AWST", "SGT": "SGT", "PST": "PST", "NZDT": "NZDT", "VET": "VET", "MST": "MST", "HECU": "HECU", "CST": "CST", "COST": "COST"}, + } +} + +// Locale returns the current translators string locale +func (shi *shi_Latn_MA) Locale() string { + return shi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'shi_Latn_MA' +func (shi *shi_Latn_MA) PluralsCardinal() []locales.PluralRule { + return shi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'shi_Latn_MA' +func (shi *shi_Latn_MA) PluralsOrdinal() []locales.PluralRule { + return shi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'shi_Latn_MA' +func (shi *shi_Latn_MA) PluralsRange() []locales.PluralRule { + return shi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } else if n >= 2 && n <= 10 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (shi *shi_Latn_MA) MonthAbbreviated(month time.Month) string { + return shi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (shi *shi_Latn_MA) MonthsAbbreviated() []string { + return shi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (shi *shi_Latn_MA) MonthNarrow(month time.Month) string { + return shi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (shi *shi_Latn_MA) MonthsNarrow() []string { + return shi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (shi *shi_Latn_MA) MonthWide(month time.Month) string { + return shi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (shi *shi_Latn_MA) MonthsWide() []string { + return shi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (shi *shi_Latn_MA) WeekdayAbbreviated(weekday time.Weekday) string { + return shi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (shi *shi_Latn_MA) WeekdaysAbbreviated() []string { + return shi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (shi *shi_Latn_MA) WeekdayNarrow(weekday time.Weekday) string { + return shi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (shi *shi_Latn_MA) WeekdaysNarrow() []string { + return shi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (shi *shi_Latn_MA) WeekdayShort(weekday time.Weekday) string { + return shi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (shi *shi_Latn_MA) WeekdaysShort() []string { + return shi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (shi *shi_Latn_MA) WeekdayWide(weekday time.Weekday) string { + return shi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (shi *shi_Latn_MA) WeekdaysWide() []string { + return shi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'shi_Latn_MA' and handles both Whole and Real numbers based on 'v' +func (shi *shi_Latn_MA) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'shi_Latn_MA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (shi *shi_Latn_MA) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, shi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'shi_Latn_MA' +// in accounting notation. +func (shi *shi_Latn_MA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, shi.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, shi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'shi_Latn_MA' +func (shi *shi_Latn_MA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/shi_Latn_MA/shi_Latn_MA_test.go b/vendor/github.com/go-playground/locales/shi_Latn_MA/shi_Latn_MA_test.go new file mode 100644 index 0000000000..440eb37fb9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi_Latn_MA/shi_Latn_MA_test.go @@ -0,0 +1,1120 @@ +package shi_Latn_MA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "shi_Latn_MA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/shi_Tfng/shi_Tfng.go b/vendor/github.com/go-playground/locales/shi_Tfng/shi_Tfng.go new file mode 100644 index 0000000000..485e591d28 --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi_Tfng/shi_Tfng.go @@ -0,0 +1,424 @@ +package shi_Tfng + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type shi_Tfng struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'shi_Tfng' locale +func New() locales.Translator { + return &shi_Tfng{ + locale: "shi_Tfng", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ⵉⵏⵏ", "ⴱⵕⴰ", "ⵎⴰⵕ", "ⵉⴱⵔ", "ⵎⴰⵢ", "ⵢⵓⵏ", "ⵢⵓⵍ", "ⵖⵓⵛ", "ⵛⵓⵜ", "ⴽⵜⵓ", "ⵏⵓⵡ", "ⴷⵓⵊ"}, + monthsNarrow: []string{"", "ⵉ", "ⴱ", "ⵎ", "ⵉ", "ⵎ", "ⵢ", "ⵢ", "ⵖ", "ⵛ", "ⴽ", "ⵏ", "ⴷ"}, + monthsWide: []string{"", "ⵉⵏⵏⴰⵢⵔ", "ⴱⵕⴰⵢⵕ", "ⵎⴰⵕⵚ", "ⵉⴱⵔⵉⵔ", "ⵎⴰⵢⵢⵓ", "ⵢⵓⵏⵢⵓ", "ⵢⵓⵍⵢⵓⵣ", "ⵖⵓⵛⵜ", "ⵛⵓⵜⴰⵏⴱⵉⵔ", "ⴽⵜⵓⴱⵔ", "ⵏⵓⵡⴰⵏⴱⵉⵔ", "ⴷⵓⵊⴰⵏⴱⵉⵔ"}, + daysAbbreviated: []string{"ⴰⵙⴰ", "ⴰⵢⵏ", "ⴰⵙⵉ", "ⴰⴽⵕ", "ⴰⴽⵡ", "ⴰⵙⵉⵎ", "ⴰⵙⵉⴹ"}, + daysWide: []string{"ⴰⵙⴰⵎⴰⵙ", "ⴰⵢⵏⴰⵙ", "ⴰⵙⵉⵏⴰⵙ", "ⴰⴽⵕⴰⵙ", "ⴰⴽⵡⴰⵙ", "ⵙⵉⵎⵡⴰⵙ", "ⴰⵙⵉⴹⵢⴰⵙ"}, + periodsAbbreviated: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + periodsWide: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + erasAbbreviated: []string{"ⴷⴰⵄ", "ⴷⴼⵄ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ⴷⴰⵜ ⵏ ⵄⵉⵙⴰ", "ⴷⴼⴼⵉⵔ ⵏ ⵄⵉⵙⴰ"}, + timezones: map[string]string{"AWST": "AWST", "CHAST": "CHAST", "NZST": "NZST", "AST": "AST", "HKST": "HKST", "AEST": "AEST", "AEDT": "AEDT", "LHST": "LHST", "AWDT": "AWDT", "BOT": "BOT", "MESZ": "MESZ", "HEOG": "HEOG", "WAT": "WAT", "LHDT": "LHDT", "HADT": "HADT", "IST": "IST", "TMST": "TMST", "ACDT": "ACDT", "HEEG": "HEEG", "ARST": "ARST", "PST": "PST", "HAST": "HAST", "ACWST": "ACWST", "ACWDT": "ACWDT", "VET": "VET", "JDT": "JDT", "OEZ": "OEZ", "WAST": "WAST", "WITA": "WITA", "ChST": "ChST", "GMT": "GMT", "HKT": "HKT", "HAT": "HAT", "PDT": "PDT", "ECT": "ECT", "TMT": "TMT", "EDT": "EDT", "WART": "WART", "CLT": "CLT", "COT": "COT", "HNT": "HNT", "HNOG": "HNOG", "UYST": "UYST", "JST": "JST", "SAST": "SAST", "HEPMX": "HEPMX", "∅∅∅": "∅∅∅", "GYT": "GYT", "EAT": "EAT", "NZDT": "NZDT", "MEZ": "MEZ", "UYT": "UYT", "SRT": "SRT", "MYT": "MYT", "HNCU": "HNCU", "HECU": "HECU", "CDT": "CDT", "CHADT": "CHADT", "SGT": "SGT", "OESZ": "OESZ", "WESZ": "WESZ", "ART": "ART", "ACST": "ACST", "HNEG": "HNEG", "CLST": "CLST", "GFT": "GFT", "WIB": "WIB", "WIT": "WIT", "CAT": "CAT", "BT": "BT", "HNPM": "HNPM", "HEPM": "HEPM", "HNPMX": "HNPMX", "WARST": "WARST", "MDT": "MDT", "EST": "EST", "HNNOMX": "HNNOMX", "ADT": "ADT", "WEZ": "WEZ", "MST": "MST", "COST": "COST", "AKST": "AKST", "CST": "CST", "HENOMX": "HENOMX", "AKDT": "AKDT"}, + } +} + +// Locale returns the current translators string locale +func (shi *shi_Tfng) Locale() string { + return shi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'shi_Tfng' +func (shi *shi_Tfng) PluralsCardinal() []locales.PluralRule { + return shi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'shi_Tfng' +func (shi *shi_Tfng) PluralsOrdinal() []locales.PluralRule { + return shi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'shi_Tfng' +func (shi *shi_Tfng) PluralsRange() []locales.PluralRule { + return shi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'shi_Tfng' +func (shi *shi_Tfng) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } else if n >= 2 && n <= 10 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'shi_Tfng' +func (shi *shi_Tfng) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'shi_Tfng' +func (shi *shi_Tfng) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (shi *shi_Tfng) MonthAbbreviated(month time.Month) string { + return shi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (shi *shi_Tfng) MonthsAbbreviated() []string { + return shi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (shi *shi_Tfng) MonthNarrow(month time.Month) string { + return shi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (shi *shi_Tfng) MonthsNarrow() []string { + return shi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (shi *shi_Tfng) MonthWide(month time.Month) string { + return shi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (shi *shi_Tfng) MonthsWide() []string { + return shi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (shi *shi_Tfng) WeekdayAbbreviated(weekday time.Weekday) string { + return shi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (shi *shi_Tfng) WeekdaysAbbreviated() []string { + return shi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (shi *shi_Tfng) WeekdayNarrow(weekday time.Weekday) string { + return shi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (shi *shi_Tfng) WeekdaysNarrow() []string { + return shi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (shi *shi_Tfng) WeekdayShort(weekday time.Weekday) string { + return shi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (shi *shi_Tfng) WeekdaysShort() []string { + return shi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (shi *shi_Tfng) WeekdayWide(weekday time.Weekday) string { + return shi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (shi *shi_Tfng) WeekdaysWide() []string { + return shi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'shi_Tfng' and handles both Whole and Real numbers based on 'v' +func (shi *shi_Tfng) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'shi_Tfng' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (shi *shi_Tfng) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'shi_Tfng' +func (shi *shi_Tfng) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, shi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'shi_Tfng' +// in accounting notation. +func (shi *shi_Tfng) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, shi.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'shi_Tfng' +func (shi *shi_Tfng) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'shi_Tfng' +func (shi *shi_Tfng) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'shi_Tfng' +func (shi *shi_Tfng) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'shi_Tfng' +func (shi *shi_Tfng) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, shi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'shi_Tfng' +func (shi *shi_Tfng) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'shi_Tfng' +func (shi *shi_Tfng) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'shi_Tfng' +func (shi *shi_Tfng) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'shi_Tfng' +func (shi *shi_Tfng) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/shi_Tfng/shi_Tfng_test.go b/vendor/github.com/go-playground/locales/shi_Tfng/shi_Tfng_test.go new file mode 100644 index 0000000000..c303ddee82 --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi_Tfng/shi_Tfng_test.go @@ -0,0 +1,1120 @@ +package shi_Tfng + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "shi_Tfng" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/shi_Tfng_MA/shi_Tfng_MA.go b/vendor/github.com/go-playground/locales/shi_Tfng_MA/shi_Tfng_MA.go new file mode 100644 index 0000000000..6c54805a02 --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi_Tfng_MA/shi_Tfng_MA.go @@ -0,0 +1,424 @@ +package shi_Tfng_MA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type shi_Tfng_MA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'shi_Tfng_MA' locale +func New() locales.Translator { + return &shi_Tfng_MA{ + locale: "shi_Tfng_MA", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ⵉⵏⵏ", "ⴱⵕⴰ", "ⵎⴰⵕ", "ⵉⴱⵔ", "ⵎⴰⵢ", "ⵢⵓⵏ", "ⵢⵓⵍ", "ⵖⵓⵛ", "ⵛⵓⵜ", "ⴽⵜⵓ", "ⵏⵓⵡ", "ⴷⵓⵊ"}, + monthsNarrow: []string{"", "ⵉ", "ⴱ", "ⵎ", "ⵉ", "ⵎ", "ⵢ", "ⵢ", "ⵖ", "ⵛ", "ⴽ", "ⵏ", "ⴷ"}, + monthsWide: []string{"", "ⵉⵏⵏⴰⵢⵔ", "ⴱⵕⴰⵢⵕ", "ⵎⴰⵕⵚ", "ⵉⴱⵔⵉⵔ", "ⵎⴰⵢⵢⵓ", "ⵢⵓⵏⵢⵓ", "ⵢⵓⵍⵢⵓⵣ", "ⵖⵓⵛⵜ", "ⵛⵓⵜⴰⵏⴱⵉⵔ", "ⴽⵜⵓⴱⵔ", "ⵏⵓⵡⴰⵏⴱⵉⵔ", "ⴷⵓⵊⴰⵏⴱⵉⵔ"}, + daysAbbreviated: []string{"ⴰⵙⴰ", "ⴰⵢⵏ", "ⴰⵙⵉ", "ⴰⴽⵕ", "ⴰⴽⵡ", "ⴰⵙⵉⵎ", "ⴰⵙⵉⴹ"}, + daysWide: []string{"ⴰⵙⴰⵎⴰⵙ", "ⴰⵢⵏⴰⵙ", "ⴰⵙⵉⵏⴰⵙ", "ⴰⴽⵕⴰⵙ", "ⴰⴽⵡⴰⵙ", "ⵙⵉⵎⵡⴰⵙ", "ⴰⵙⵉⴹⵢⴰⵙ"}, + periodsAbbreviated: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + periodsWide: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + erasAbbreviated: []string{"ⴷⴰⵄ", "ⴷⴼⵄ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ⴷⴰⵜ ⵏ ⵄⵉⵙⴰ", "ⴷⴼⴼⵉⵔ ⵏ ⵄⵉⵙⴰ"}, + timezones: map[string]string{"EAT": "EAT", "BOT": "BOT", "MESZ": "MESZ", "VET": "VET", "COT": "COT", "HEEG": "HEEG", "AKDT": "AKDT", "HEPMX": "HEPMX", "HAST": "HAST", "∅∅∅": "∅∅∅", "AEST": "AEST", "GYT": "GYT", "AWST": "AWST", "ECT": "ECT", "ADT": "ADT", "ARST": "ARST", "CHADT": "CHADT", "WITA": "WITA", "WIB": "WIB", "MYT": "MYT", "WIT": "WIT", "CHAST": "CHAST", "PDT": "PDT", "HADT": "HADT", "EDT": "EDT", "GFT": "GFT", "ACST": "ACST", "HNEG": "HNEG", "IST": "IST", "JST": "JST", "JDT": "JDT", "WARST": "WARST", "AST": "AST", "MDT": "MDT", "UYST": "UYST", "NZST": "NZST", "MEZ": "MEZ", "OESZ": "OESZ", "GMT": "GMT", "ChST": "ChST", "HNPMX": "HNPMX", "ACWST": "ACWST", "CLST": "CLST", "HNOG": "HNOG", "TMST": "TMST", "AKST": "AKST", "LHST": "LHST", "WAT": "WAT", "HKT": "HKT", "HNT": "HNT", "HNPM": "HNPM", "CST": "CST", "SGT": "SGT", "NZDT": "NZDT", "TMT": "TMT", "WAST": "WAST", "BT": "BT", "SAST": "SAST", "SRT": "SRT", "WART": "WART", "HEOG": "HEOG", "OEZ": "OEZ", "ART": "ART", "HENOMX": "HENOMX", "HEPM": "HEPM", "ACWDT": "ACWDT", "AEDT": "AEDT", "AWDT": "AWDT", "CLT": "CLT", "WESZ": "WESZ", "EST": "EST", "ACDT": "ACDT", "UYT": "UYT", "CAT": "CAT", "WEZ": "WEZ", "MST": "MST", "COST": "COST", "HECU": "HECU", "CDT": "CDT", "HKST": "HKST", "HNNOMX": "HNNOMX", "HAT": "HAT", "LHDT": "LHDT", "HNCU": "HNCU", "PST": "PST"}, + } +} + +// Locale returns the current translators string locale +func (shi *shi_Tfng_MA) Locale() string { + return shi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) PluralsCardinal() []locales.PluralRule { + return shi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) PluralsOrdinal() []locales.PluralRule { + return shi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) PluralsRange() []locales.PluralRule { + return shi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } else if n >= 2 && n <= 10 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (shi *shi_Tfng_MA) MonthAbbreviated(month time.Month) string { + return shi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (shi *shi_Tfng_MA) MonthsAbbreviated() []string { + return shi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (shi *shi_Tfng_MA) MonthNarrow(month time.Month) string { + return shi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (shi *shi_Tfng_MA) MonthsNarrow() []string { + return shi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (shi *shi_Tfng_MA) MonthWide(month time.Month) string { + return shi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (shi *shi_Tfng_MA) MonthsWide() []string { + return shi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (shi *shi_Tfng_MA) WeekdayAbbreviated(weekday time.Weekday) string { + return shi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (shi *shi_Tfng_MA) WeekdaysAbbreviated() []string { + return shi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (shi *shi_Tfng_MA) WeekdayNarrow(weekday time.Weekday) string { + return shi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (shi *shi_Tfng_MA) WeekdaysNarrow() []string { + return shi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (shi *shi_Tfng_MA) WeekdayShort(weekday time.Weekday) string { + return shi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (shi *shi_Tfng_MA) WeekdaysShort() []string { + return shi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (shi *shi_Tfng_MA) WeekdayWide(weekday time.Weekday) string { + return shi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (shi *shi_Tfng_MA) WeekdaysWide() []string { + return shi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'shi_Tfng_MA' and handles both Whole and Real numbers based on 'v' +func (shi *shi_Tfng_MA) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'shi_Tfng_MA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (shi *shi_Tfng_MA) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, shi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'shi_Tfng_MA' +// in accounting notation. +func (shi *shi_Tfng_MA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := shi.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, shi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(shi.group) - 1; j >= 0; j-- { + b = append(b, shi.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, shi.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, shi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, shi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, shi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'shi_Tfng_MA' +func (shi *shi_Tfng_MA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/shi_Tfng_MA/shi_Tfng_MA_test.go b/vendor/github.com/go-playground/locales/shi_Tfng_MA/shi_Tfng_MA_test.go new file mode 100644 index 0000000000..8817815e6b --- /dev/null +++ b/vendor/github.com/go-playground/locales/shi_Tfng_MA/shi_Tfng_MA_test.go @@ -0,0 +1,1120 @@ +package shi_Tfng_MA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "shi_Tfng_MA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/si/si.go b/vendor/github.com/go-playground/locales/si/si.go new file mode 100644 index 0000000000..9b1d7b6cc0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/si/si.go @@ -0,0 +1,609 @@ +package si + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type si struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'si' locale +func New() locales.Translator { + return &si{ + locale: "si", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "රු.", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "සිෆ්එ", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ජන", "පෙබ", "මාර්තු", "අප්\u200dරේල්", "මැයි", "ජූනි", "ජූලි", "අගෝ", "සැප්", "ඔක්", "නොවැ", "දෙසැ"}, + monthsNarrow: []string{"", "ජ", "පෙ", "මා", "අ", "මැ", "ජූ", "ජූ", "අ", "සැ", "ඔ", "නෙ", "දෙ"}, + monthsWide: []string{"", "ජනවාරි", "පෙබරවාරි", "මාර්තු", "අප්\u200dරේල්", "මැයි", "ජූනි", "ජූලි", "අගෝස්තු", "සැප්තැම්බර්", "ඔක්තෝබර්", "නොවැම්බර්", "දෙසැම්බර්"}, + daysAbbreviated: []string{"ඉරිදා", "සඳුදා", "අඟහ", "බදාදා", "බ්\u200dරහස්", "සිකු", "සෙන"}, + daysNarrow: []string{"ඉ", "ස", "අ", "බ", "බ්\u200dර", "සි", "සෙ"}, + daysShort: []string{"ඉරි", "සඳු", "අඟ", "බදා", "බ්\u200dරහ", "සිකු", "සෙන"}, + daysWide: []string{"ඉරිදා", "සඳුදා", "අඟහරුවාදා", "බදාදා", "බ්\u200dරහස්පතින්දා", "සිකුරාදා", "සෙනසුරාදා"}, + periodsAbbreviated: []string{"පෙ.ව.", "ප.ව."}, + periodsNarrow: []string{"පෙ", "ප"}, + periodsWide: []string{"පෙ.ව.", "ප.ව."}, + erasAbbreviated: []string{"ක්\u200dරි.පූ.", "ක්\u200dරි.ව."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ක්\u200dරිස්තු පූර්ව", "ක්\u200dරිස්තු වර්ෂ"}, + timezones: map[string]string{"MYT": "මැලේසියානු වේලාව", "WARST": "බටහිර ආර්ජන්ටිනා ග්\u200dරීෂ්ම කාලය", "TMT": "ටර්ක්මෙනිස්තාන සම්මත වේලාව", "WAT": "බටහිර අප්\u200dරිකානු සම්මත වේලාව", "HADT": "හවායි-අලෙයුතියාන් දිවාආලෝක වේලාව", "HEOG": "බටහිර ග්\u200dරීන්ලන්ත ග්\u200dරීෂ්ම කාලය", "WESZ": "බටහිර යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "UYT": "උරුගුවේ සම්මත වේලාව", "CST": "උතුරු ඇමරිකානු මධ්\u200dයම සම්මත වේලාව", "AWST": "බටහිර ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "ADT": "අත්ලාන්තික් දිවාආලෝක වේලාව", "ART": "ආර්ජන්ටිනා සම්මත වේලාව", "ARST": "ආර්ජන්ටිනා ග්\u200dරීෂ්ම කාලය", "HKT": "හොංකොං සම්මත වේලාව", "COT": "කොලොම්බියා සම්මත වේලාව", "BT": "භුතාන වේලාව", "EST": "උතුරු ඇමරිකානු නැගෙනහිර සම්මත වේලාව", "HENOMX": "වයඹ මෙක්සිකෝ දිවාආලෝක වේලාව", "HNPM": "ශාන්ත පියරේ සහ මැකෝලන් සම්මත වේලාව", "WAST": "බටහිර අප්\u200dරිකානු ග්\u200dරීෂ්ම කාලය", "HECU": "කියුබානු දිවාආලෝක වේලාව", "JST": "ජපාන සම්මත වේලාව", "HNOG": "බටහිර ග්\u200dරීන්ලන්ත සම්මත වේලාව", "GYT": "ගයනා වේලාව", "CHADT": "චැතම් දිවා වේලාව", "HEEG": "නැගෙනහිර ග්\u200dරීන්ලන්ත ග්\u200dරීෂ්ම කාලය", "AKST": "ඇලස්කා සම්මත වේලාව", "NZDT": "නවසීලන්ත දිවා වේලාව", "MEZ": "මධ්\u200dයම යුරෝපීය සම්මත වේලාව", "GMT": "ග්\u200dරිනිච් මධ්\u200dයම වේලාව", "OEZ": "නැගෙනහිර යුරෝපීය සම්මත වේලාව", "OESZ": "නැගෙනහිර යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "EDT": "උතුරු ඇමරිකානු නැගෙනහිර දිවාආලෝක වේලාව", "HEPM": "ශාන්ත පියරේ සහ මැකෝලන් දිවාආලෝක වේලාව", "CHAST": "චැතම් සම්මත වේලාව", "NZST": "නවසීලන්ත සම්මත වේලාව", "HNT": "නිව්ෆවුන්ලන්ත සම්මත වේලාව", "AEST": "නැගෙනහිර ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "ChST": "චමොරෝ වේලාව", "HAST": "හවායි-අලෙයුතියාන් සම්මත වේලාව", "PDT": "උතුරු ඇමරිකානු පැසිෆික් දිවාආලෝක වේලාව", "WART": "බටහිර ආර්ජන්ටිනා සම්මත වේලාව", "MST": "MST", "MDT": "MDT", "AEDT": "නැඟෙනහිර ඕස්ට්\u200dරේලියානු දහවල් වේලාව", "LHST": "ලෝර්ඩ් හෝව් සම්මත වේලාව", "HEPMX": "මෙක්සිකෝ පැසිෆික් දිවාආලෝක වේලාව", "∅∅∅": "ඇමර්සන් ග්\u200dරීෂ්ම කාලය", "HAT": "නිව්ෆවුන්ලන්ත දිවාආලෝක වේලාව", "CDT": "උතුරු ඇමරිකානු මධ්\u200dයම දිවාආලෝක වේලාව", "ACWST": "මධ්\u200dයම බටහිර ඔස්ට්\u200dරේලියානු සම්මත වේලාව", "JDT": "ජපාන දහවල් වේලාව", "TMST": "ටර්ක්මෙනිස්තාන ග්\u200dරීෂ්ම වේලාව", "UYST": "උරුගුවේ ග්\u200dරීෂ්ම කාලය", "AWDT": "බටහිර ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "CLT": "චිලී සම්මත වේලාව", "CLST": "චිලී ග්\u200dරීෂ්ම කාලය", "ACST": "ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "COST": "කොලොම්බියා ග්\u200dරීෂ්ම කාලය", "HNNOMX": "වයඹ මෙක්සිකෝ සම්මත වේලාව", "HNEG": "නැගෙනහිර ග්\u200dරීන්ලන්ත සම්මත වේලාව", "SRT": "සුරිනාම වේලාව", "SAST": "දකුණු අප්\u200dරිකානු වේලාව", "CAT": "මධ්\u200dයම අප්\u200dරිකානු වේලාව", "VET": "වෙනිසියුලා වේලාව", "AST": "අත්ලාන්තික් සම්මත වේලාව", "HKST": "හොංකොං ග්\u200dරීෂ්ම වේලාව", "WITA": "මධ්\u200dයම ඉන්දුනීසියානු වේලාව", "AKDT": "ඇලස්කා දිවාආලෝක වේලාව", "WIB": "බටහිර ඉන්දුනීසියානු වේලාව", "BOT": "බොලිවියා වේලාව", "WIT": "නැගෙනහිර ඉන්දුනීසියානු වේලාව", "PST": "උතුරු ඇමරිකානු පැසිෆික් සම්මත වේලාව", "IST": "ඉන්දියානු වේලාව", "MESZ": "මධ්\u200dයම යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "LHDT": "ලෝර්ඩ් හෝව් දිවා වේලාව", "HNPMX": "මෙක්සිකෝ පැසිෆික් සම්මත වේලාව", "EAT": "නැගෙනහිර අප්\u200dරිකානු වේලාව", "HNCU": "කියුබානු සම්මත වේලාව", "ACWDT": "මධ්\u200dයම බටහිර ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "WEZ": "බටහිර යුරෝපීය සම්මත වේලාව", "ACDT": "මධ්\u200dයම ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "GFT": "ප්\u200dරංශ ගයනා වේලාව", "SGT": "සිංගප්පුරු වේලාව", "ECT": "ඉක්වදෝර් වේලාව"}, + } +} + +// Locale returns the current translators string locale +func (si *si) Locale() string { + return si.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'si' +func (si *si) PluralsCardinal() []locales.PluralRule { + return si.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'si' +func (si *si) PluralsOrdinal() []locales.PluralRule { + return si.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'si' +func (si *si) PluralsRange() []locales.PluralRule { + return si.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'si' +func (si *si) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + + if (n == 0 || n == 1) || (i == 0 && f == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'si' +func (si *si) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'si' +func (si *si) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := si.CardinalPluralRule(num1, v1) + end := si.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (si *si) MonthAbbreviated(month time.Month) string { + return si.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (si *si) MonthsAbbreviated() []string { + return si.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (si *si) MonthNarrow(month time.Month) string { + return si.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (si *si) MonthsNarrow() []string { + return si.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (si *si) MonthWide(month time.Month) string { + return si.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (si *si) MonthsWide() []string { + return si.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (si *si) WeekdayAbbreviated(weekday time.Weekday) string { + return si.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (si *si) WeekdaysAbbreviated() []string { + return si.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (si *si) WeekdayNarrow(weekday time.Weekday) string { + return si.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (si *si) WeekdaysNarrow() []string { + return si.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (si *si) WeekdayShort(weekday time.Weekday) string { + return si.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (si *si) WeekdaysShort() []string { + return si.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (si *si) WeekdayWide(weekday time.Weekday) string { + return si.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (si *si) WeekdaysWide() []string { + return si.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'si' and handles both Whole and Real numbers based on 'v' +func (si *si) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, si.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, si.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, si.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'si' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (si *si) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, si.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, si.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, si.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'si' +func (si *si) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := si.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, si.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, si.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, si.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, si.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'si' +// in accounting notation. +func (si *si) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := si.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, si.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, si.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, si.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, si.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, si.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'si' +func (si *si) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'si' +func (si *si) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, si.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'si' +func (si *si) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, si.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'si' +func (si *si) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, si.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, si.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'si' +func (si *si) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'si' +func (si *si) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'si' +func (si *si) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'si' +func (si *si) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := si.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/si/si_test.go b/vendor/github.com/go-playground/locales/si/si_test.go new file mode 100644 index 0000000000..7582ea6360 --- /dev/null +++ b/vendor/github.com/go-playground/locales/si/si_test.go @@ -0,0 +1,1120 @@ +package si + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "si" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/si_LK/si_LK.go b/vendor/github.com/go-playground/locales/si_LK/si_LK.go new file mode 100644 index 0000000000..c6619ba6a3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/si_LK/si_LK.go @@ -0,0 +1,609 @@ +package si_LK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type si_LK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'si_LK' locale +func New() locales.Translator { + return &si_LK{ + locale: "si_LK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ජන", "පෙබ", "මාර්තු", "අප්\u200dරේල්", "මැයි", "ජූනි", "ජූලි", "අගෝ", "සැප්", "ඔක්", "නොවැ", "දෙසැ"}, + monthsNarrow: []string{"", "ජ", "පෙ", "මා", "අ", "මැ", "ජූ", "ජූ", "අ", "සැ", "ඔ", "නෙ", "දෙ"}, + monthsWide: []string{"", "ජනවාරි", "පෙබරවාරි", "මාර්තු", "අප්\u200dරේල්", "මැයි", "ජූනි", "ජූලි", "අගෝස්තු", "සැප්තැම්බර්", "ඔක්තෝබර්", "නොවැම්බර්", "දෙසැම්බර්"}, + daysAbbreviated: []string{"ඉරිදා", "සඳුදා", "අඟහ", "බදාදා", "බ්\u200dරහස්", "සිකු", "සෙන"}, + daysNarrow: []string{"ඉ", "ස", "අ", "බ", "බ්\u200dර", "සි", "සෙ"}, + daysShort: []string{"ඉරි", "සඳු", "අඟ", "බදා", "බ්\u200dරහ", "සිකු", "සෙන"}, + daysWide: []string{"ඉරිදා", "සඳුදා", "අඟහරුවාදා", "බදාදා", "බ්\u200dරහස්පතින්දා", "සිකුරාදා", "සෙනසුරාදා"}, + periodsAbbreviated: []string{"පෙ.ව.", "ප.ව."}, + periodsNarrow: []string{"පෙ", "ප"}, + periodsWide: []string{"පෙ.ව.", "ප.ව."}, + erasAbbreviated: []string{"ක්\u200dරි.පූ.", "ක්\u200dරි.ව."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ක්\u200dරිස්තු පූර්ව", "ක්\u200dරිස්තු වර්ෂ"}, + timezones: map[string]string{"AWST": "බටහිර ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "OESZ": "නැගෙනහිර යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "HEOG": "බටහිර ග්\u200dරීන්ලන්ත ග්\u200dරීෂ්ම කාලය", "MST": "උතුරු ඇමරිකානු කඳුකර සම්මත වේලාව", "UYST": "උරුගුවේ ග්\u200dරීෂ්ම කාලය", "HNCU": "කියුබානු සම්මත වේලාව", "WIB": "බටහිර ඉන්දුනීසියානු වේලාව", "CDT": "උතුරු ඇමරිකානු මධ්\u200dයම දිවාආලෝක වේලාව", "WAT": "බටහිර අප්\u200dරිකානු සම්මත වේලාව", "LHST": "ලෝර්ඩ් හෝව් සම්මත වේලාව", "HEPMX": "මෙක්සිකෝ පැසිෆික් දිවාආලෝක වේලාව", "BOT": "බොලිවියා වේලාව", "ACST": "ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "ACDT": "මධ්\u200dයම ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "AEDT": "නැඟෙනහිර ඕස්ට්\u200dරේලියානු දහවල් වේලාව", "WITA": "මධ්\u200dයම ඉන්දුනීසියානු වේලාව", "HNPM": "ශාන්ත පියරේ සහ මැකෝලන් සම්මත වේලාව", "MEZ": "මධ්\u200dයම යුරෝපීය සම්මත වේලාව", "EST": "උතුරු ඇමරිකානු නැගෙනහිර සම්මත වේලාව", "EDT": "උතුරු ඇමරිකානු නැගෙනහිර දිවාආලෝක වේලාව", "ART": "ආර්ජන්ටිනා සම්මත වේලාව", "BT": "භුතාන වේලාව", "ChST": "චමොරෝ වේලාව", "HAST": "හවායි-අලෙයුතියාන් සම්මත වේලාව", "JST": "ජපාන සම්මත වේලාව", "CLT": "චිලී සම්මත වේලාව", "COST": "කොලොම්බියා ග්\u200dරීෂ්ම කාලය", "JDT": "ජපාන දහවල් වේලාව", "MESZ": "මධ්\u200dයම යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "GMT": "ග්\u200dරිනිච් මධ්\u200dයම වේලාව", "ARST": "ආර්ජන්ටිනා ග්\u200dරීෂ්ම කාලය", "ECT": "ඉක්වදෝර් වේලාව", "NZDT": "නවසීලන්ත දිවා වේලාව", "AKDT": "ඇලස්කා දිවාආලෝක වේලාව", "PST": "උතුරු ඇමරිකානු පැසිෆික් සම්මත වේලාව", "WART": "බටහිර ආර්ජන්ටිනා සම්මත වේලාව", "WAST": "බටහිර අප්\u200dරිකානු ග්\u200dරීෂ්ම කාලය", "HKT": "හොංකොං සම්මත වේලාව", "PDT": "උතුරු ඇමරිකානු පැසිෆික් දිවාආලෝක වේලාව", "WEZ": "බටහිර යුරෝපීය සම්මත වේලාව", "WESZ": "බටහිර යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "TMT": "ටර්ක්මෙනිස්තාන සම්මත වේලාව", "TMST": "ටර්ක්මෙනිස්තාන ග්\u200dරීෂ්ම වේලාව", "HNT": "නිව්ෆවුන්ලන්ත සම්මත වේලාව", "MDT": "උතුරු ඇමරිකානු කඳුකර දිවාආලෝක වේලාව", "SAST": "දකුණු අප්\u200dරිකානු වේලාව", "WARST": "බටහිර ආර්ජන්ටිනා ග්\u200dරීෂ්ම කාලය", "COT": "කොලොම්බියා සම්මත වේලාව", "SRT": "සුරිනාම වේලාව", "HECU": "කියුබානු දිවාආලෝක වේලාව", "CHADT": "චැතම් දිවා වේලාව", "ACWST": "මධ්\u200dයම බටහිර ඔස්ට්\u200dරේලියානු සම්මත වේලාව", "HNEG": "නැගෙනහිර ග්\u200dරීන්ලන්ත සම්මත වේලාව", "AEST": "නැගෙනහිර ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "LHDT": "ලෝර්ඩ් හෝව් දිවා වේලාව", "WIT": "නැගෙනහිර ඉන්දුනීසියානු වේලාව", "ACWDT": "මධ්\u200dයම බටහිර ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "HKST": "හොංකොං ග්\u200dරීෂ්ම වේලාව", "HNNOMX": "වයඹ මෙක්සිකෝ සම්මත වේලාව", "GYT": "ගයනා වේලාව", "OEZ": "නැගෙනහිර යුරෝපීය සම්මත වේලාව", "HNOG": "බටහිර ග්\u200dරීන්ලන්ත සම්මත වේලාව", "ADT": "අත්ලාන්තික් දිවාආලෝක වේලාව", "HAT": "නිව්ෆවුන්ලන්ත දිවාආලෝක වේලාව", "GFT": "ප්\u200dරංශ ගයනා වේලාව", "AKST": "ඇලස්කා සම්මත වේලාව", "HEPM": "ශාන්ත පියරේ සහ මැකෝලන් දිවාආලෝක වේලාව", "NZST": "නවසීලන්ත සම්මත වේලාව", "CLST": "චිලී ග්\u200dරීෂ්ම කාලය", "AST": "අත්ලාන්තික් සම්මත වේලාව", "HEEG": "නැගෙනහිර ග්\u200dරීන්ලන්ත ග්\u200dරීෂ්ම කාලය", "∅∅∅": "∅∅∅", "HNPMX": "මෙක්සිකෝ පැසිෆික් සම්මත වේලාව", "CST": "උතුරු ඇමරිකානු මධ්\u200dයම සම්මත වේලාව", "CAT": "මධ්\u200dයම අප්\u200dරිකානු වේලාව", "UYT": "උරුගුවේ සම්මත වේලාව", "EAT": "නැගෙනහිර අප්\u200dරිකානු වේලාව", "SGT": "සිංගප්පුරු වේලාව", "CHAST": "චැතම් සම්මත වේලාව", "IST": "ඉන්දියානු වේලාව", "HENOMX": "වයඹ මෙක්සිකෝ දිවාආලෝක වේලාව", "AWDT": "බටහිර ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "HADT": "හවායි-අලෙයුතියාන් දිවාආලෝක වේලාව", "VET": "වෙනිසියුලා වේලාව", "MYT": "මැලේසියානු වේලාව"}, + } +} + +// Locale returns the current translators string locale +func (si *si_LK) Locale() string { + return si.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'si_LK' +func (si *si_LK) PluralsCardinal() []locales.PluralRule { + return si.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'si_LK' +func (si *si_LK) PluralsOrdinal() []locales.PluralRule { + return si.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'si_LK' +func (si *si_LK) PluralsRange() []locales.PluralRule { + return si.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'si_LK' +func (si *si_LK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + + if (n == 0 || n == 1) || (i == 0 && f == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'si_LK' +func (si *si_LK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'si_LK' +func (si *si_LK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := si.CardinalPluralRule(num1, v1) + end := si.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (si *si_LK) MonthAbbreviated(month time.Month) string { + return si.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (si *si_LK) MonthsAbbreviated() []string { + return si.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (si *si_LK) MonthNarrow(month time.Month) string { + return si.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (si *si_LK) MonthsNarrow() []string { + return si.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (si *si_LK) MonthWide(month time.Month) string { + return si.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (si *si_LK) MonthsWide() []string { + return si.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (si *si_LK) WeekdayAbbreviated(weekday time.Weekday) string { + return si.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (si *si_LK) WeekdaysAbbreviated() []string { + return si.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (si *si_LK) WeekdayNarrow(weekday time.Weekday) string { + return si.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (si *si_LK) WeekdaysNarrow() []string { + return si.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (si *si_LK) WeekdayShort(weekday time.Weekday) string { + return si.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (si *si_LK) WeekdaysShort() []string { + return si.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (si *si_LK) WeekdayWide(weekday time.Weekday) string { + return si.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (si *si_LK) WeekdaysWide() []string { + return si.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'si_LK' and handles both Whole and Real numbers based on 'v' +func (si *si_LK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, si.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, si.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, si.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'si_LK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (si *si_LK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, si.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, si.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, si.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'si_LK' +func (si *si_LK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := si.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, si.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, si.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, si.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, si.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'si_LK' +// in accounting notation. +func (si *si_LK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := si.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, si.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, si.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, si.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, si.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, si.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'si_LK' +func (si *si_LK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'si_LK' +func (si *si_LK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, si.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'si_LK' +func (si *si_LK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, si.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'si_LK' +func (si *si_LK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, si.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, si.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'si_LK' +func (si *si_LK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'si_LK' +func (si *si_LK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'si_LK' +func (si *si_LK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'si_LK' +func (si *si_LK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := si.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/si_LK/si_LK_test.go b/vendor/github.com/go-playground/locales/si_LK/si_LK_test.go new file mode 100644 index 0000000000..eb4f33bd95 --- /dev/null +++ b/vendor/github.com/go-playground/locales/si_LK/si_LK_test.go @@ -0,0 +1,1120 @@ +package si_LK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "si_LK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sk/sk.go b/vendor/github.com/go-playground/locales/sk/sk.go new file mode 100644 index 0000000000..0e29f00fce --- /dev/null +++ b/vendor/github.com/go-playground/locales/sk/sk.go @@ -0,0 +1,612 @@ +package sk + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sk struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sk' locale +func New() locales.Translator { + return &sk{ + locale: "sk", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "NIS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "máj", "jún", "júl", "aug", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januára", "februára", "marca", "apríla", "mája", "júna", "júla", "augusta", "septembra", "októbra", "novembra", "decembra"}, + daysAbbreviated: []string{"ne", "po", "ut", "st", "št", "pi", "so"}, + daysNarrow: []string{"n", "p", "u", "s", "š", "p", "s"}, + daysShort: []string{"ne", "po", "ut", "st", "št", "pi", "so"}, + daysWide: []string{"nedeľa", "pondelok", "utorok", "streda", "štvrtok", "piatok", "sobota"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"pred Kr.", "po Kr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"pred Kristom", "po Kristovi"}, + timezones: map[string]string{"SAST": "juhoafrický čas", "HECU": "kubánsky letný čas", "ACWST": "stredozápadný austrálsky štandardný čas", "WARST": "západoargentínsky letný čas", "OESZ": "východoeurópsky letný čas", "HNEG": "východogrónsky štandardný čas", "GFT": "francúzskoguyanský čas", "CHADT": "chathamský letný čas", "HAST": "havajsko-aleutský štandardný čas", "JST": "japonský štandardný čas", "HENOMX": "severozápadný mexický letný čas", "CHAST": "chathamský štandardný čas", "AEST": "východoaustrálsky štandardný čas", "UYST": "uruguajský letný čas", "IST": "indický čas", "JDT": "japonský letný čas", "WAT": "západoafrický štandardný čas", "HKT": "hongkonský štandardný čas", "MEZ": "stredoeurópsky štandardný čas", "BT": "bhutánsky čas", "∅∅∅": "∅∅∅", "HEPM": "pierre-miquelonský letný čas", "LHST": "štandardný čas ostrova lorda Howa", "CDT": "severoamerický centrálny letný čas", "WIT": "východoindonézsky čas", "SGT": "singapurský štandardný čas", "EDT": "severoamerický východný letný čas", "HNNOMX": "severozápadný mexický štandardný čas", "UYT": "uruguajský štandardný čas", "HNPM": "pierre-miquelonský štandardný čas", "PDT": "severoamerický tichomorský letný čas", "HKST": "hongkonský letný čas", "ACST": "stredoaustrálsky štandardný čas", "COT": "kolumbijský štandardný čas", "TMST": "turkménsky letný čas", "WITA": "stredoindonézsky čas", "AKDT": "aljašský letný čas", "HNPMX": "mexický tichomorský štandardný čas", "AWDT": "západoaustrálsky letný čas", "ADT": "atlantický letný čas", "OEZ": "východoeurópsky štandardný čas", "WEZ": "západoeurópsky štandardný čas", "BOT": "bolívijský čas", "ACDT": "stredoaustrálsky letný čas", "HNT": "newfoundlandský štandardný čas", "HEEG": "východogrónsky letný čas", "HEPMX": "mexický tichomorský letný čas", "TMT": "turkménsky štandardný čas", "ART": "argentínsky štandardný čas", "EST": "severoamerický východný štandardný čas", "MST": "severoamerický horský štandardný čas", "SRT": "surinamský čas", "GYT": "guyanský čas", "ACWDT": "stredozápadný austrálsky letný čas", "LHDT": "letný čas ostrova lorda Howa", "ECT": "ekvádorský čas", "GMT": "greenwichský čas", "COST": "kolumbijský letný čas", "AEDT": "východoaustrálsky letný čas", "NZST": "novozélandský štandardný čas", "NZDT": "novozélandský letný čas", "AST": "atlantický štandardný čas", "EAT": "východoafrický čas", "WIB": "západoindonézsky čas", "CST": "severoamerický centrálny štandardný čas", "HADT": "havajsko-aleutský letný čas", "CLT": "čilský štandardný čas", "ARST": "argentínsky letný čas", "ChST": "chamorrský štandardný čas", "MESZ": "stredoeurópsky letný čas", "WART": "západoargentínsky štandardný čas", "HNOG": "západogrónsky štandardný čas", "WAST": "západoafrický letný čas", "AKST": "aljašský štandardný čas", "HNCU": "kubánsky štandardný čas", "CAT": "stredoafrický čas", "VET": "venezuelský čas", "CLST": "čilský letný čas", "HEOG": "západogrónsky letný čas", "WESZ": "západoeurópsky letný čas", "HAT": "newfoundlandský letný čas", "MDT": "severoamerický horský letný čas", "AWST": "západoaustrálsky štandardný čas", "PST": "severoamerický tichomorský štandardný čas", "MYT": "malajzijský čas"}, + } +} + +// Locale returns the current translators string locale +func (sk *sk) Locale() string { + return sk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sk' +func (sk *sk) PluralsCardinal() []locales.PluralRule { + return sk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sk' +func (sk *sk) PluralsOrdinal() []locales.PluralRule { + return sk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sk' +func (sk *sk) PluralsRange() []locales.PluralRule { + return sk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sk' +func (sk *sk) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if i >= 2 && i <= 4 && v == 0 { + return locales.PluralRuleFew + } else if v != 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sk' +func (sk *sk) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sk' +func (sk *sk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sk.CardinalPluralRule(num1, v1) + end := sk.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sk *sk) MonthAbbreviated(month time.Month) string { + return sk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sk *sk) MonthsAbbreviated() []string { + return sk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sk *sk) MonthNarrow(month time.Month) string { + return sk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sk *sk) MonthsNarrow() []string { + return sk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sk *sk) MonthWide(month time.Month) string { + return sk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sk *sk) MonthsWide() []string { + return sk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sk *sk) WeekdayAbbreviated(weekday time.Weekday) string { + return sk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sk *sk) WeekdaysAbbreviated() []string { + return sk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sk *sk) WeekdayNarrow(weekday time.Weekday) string { + return sk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sk *sk) WeekdaysNarrow() []string { + return sk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sk *sk) WeekdayShort(weekday time.Weekday) string { + return sk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sk *sk) WeekdaysShort() []string { + return sk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sk *sk) WeekdayWide(weekday time.Weekday) string { + return sk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sk *sk) WeekdaysWide() []string { + return sk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sk' and handles both Whole and Real numbers based on 'v' +func (sk *sk) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sk.group) - 1; j >= 0; j-- { + b = append(b, sk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sk' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sk *sk) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sk.percentSuffix...) + + b = append(b, sk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sk' +func (sk *sk) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sk.group) - 1; j >= 0; j-- { + b = append(b, sk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sk.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sk' +// in accounting notation. +func (sk *sk) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sk.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sk.group) - 1; j >= 0; j-- { + b = append(b, sk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sk.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sk.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sk' +func (sk *sk) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sk' +func (sk *sk) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sk' +func (sk *sk) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sk' +func (sk *sk) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sk.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sk' +func (sk *sk) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sk' +func (sk *sk) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sk' +func (sk *sk) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sk' +func (sk *sk) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sk/sk_test.go b/vendor/github.com/go-playground/locales/sk/sk_test.go new file mode 100644 index 0000000000..25a4c6b533 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sk/sk_test.go @@ -0,0 +1,1120 @@ +package sk + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sk" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sk_SK/sk_SK.go b/vendor/github.com/go-playground/locales/sk_SK/sk_SK.go new file mode 100644 index 0000000000..2ef5ccb1d7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sk_SK/sk_SK.go @@ -0,0 +1,612 @@ +package sk_SK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sk_SK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sk_SK' locale +func New() locales.Translator { + return &sk_SK{ + locale: "sk_SK", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "máj", "jún", "júl", "aug", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januára", "februára", "marca", "apríla", "mája", "júna", "júla", "augusta", "septembra", "októbra", "novembra", "decembra"}, + daysAbbreviated: []string{"ne", "po", "ut", "st", "št", "pi", "so"}, + daysNarrow: []string{"n", "p", "u", "s", "š", "p", "s"}, + daysShort: []string{"ne", "po", "ut", "st", "št", "pi", "so"}, + daysWide: []string{"nedeľa", "pondelok", "utorok", "streda", "štvrtok", "piatok", "sobota"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"pred Kr.", "po Kr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"pred Kristom", "po Kristovi"}, + timezones: map[string]string{"ACWST": "stredozápadný austrálsky štandardný čas", "TMST": "turkménsky letný čas", "WAST": "západoafrický letný čas", "AKDT": "aljašský letný čas", "HEPMX": "mexický tichomorský letný čas", "SAST": "juhoafrický čas", "SGT": "singapurský štandardný čas", "GMT": "greenwichský čas", "WARST": "západoargentínsky letný čas", "ADT": "atlantický letný čas", "BT": "bhutánsky čas", "HAT": "newfoundlandský letný čas", "HNPM": "pierre-miquelonský štandardný čas", "COT": "kolumbijský štandardný čas", "HNEG": "východogrónsky štandardný čas", "EDT": "severoamerický východný letný čas", "HENOMX": "severozápadný mexický letný čas", "AKST": "aljašský štandardný čas", "CST": "severoamerický centrálny štandardný čas", "AWDT": "západoaustrálsky letný čas", "AST": "atlantický štandardný čas", "ACST": "stredoaustrálsky štandardný čas", "EAT": "východoafrický čas", "PDT": "severoamerický tichomorský letný čas", "IST": "indický čas", "ACDT": "stredoaustrálsky letný čas", "HNT": "newfoundlandský štandardný čas", "ChST": "chamorrský štandardný čas", "WART": "západoargentínsky štandardný čas", "CLT": "čilský štandardný čas", "JDT": "japonský letný čas", "TMT": "turkménsky štandardný čas", "UYST": "uruguajský letný čas", "HNPMX": "mexický tichomorský štandardný čas", "JST": "japonský štandardný čas", "CLST": "čilský letný čas", "MDT": "MDT", "GFT": "francúzskoguyanský čas", "WITA": "stredoindonézsky čas", "GYT": "guyanský čas", "ACWDT": "stredozápadný austrálsky letný čas", "MYT": "malajzijský čas", "CAT": "stredoafrický čas", "VET": "venezuelský čas", "BOT": "bolívijský čas", "CHAST": "chathamský štandardný čas", "NZST": "novozélandský štandardný čas", "CDT": "severoamerický centrálny letný čas", "HEOG": "západogrónsky letný čas", "OEZ": "východoeurópsky štandardný čas", "HAST": "havajsko-aleutský štandardný čas", "MEZ": "stredoeurópsky štandardný čas", "COST": "kolumbijský letný čas", "∅∅∅": "azorský letný čas", "LHST": "štandardný čas ostrova lorda Howa", "CHADT": "chathamský letný čas", "MESZ": "stredoeurópsky letný čas", "WEZ": "západoeurópsky štandardný čas", "HNOG": "západogrónsky štandardný čas", "EST": "severoamerický východný štandardný čas", "HEPM": "pierre-miquelonský letný čas", "LHDT": "letný čas ostrova lorda Howa", "WIT": "východoindonézsky čas", "AWST": "západoaustrálsky štandardný čas", "PST": "severoamerický tichomorský štandardný čas", "ART": "argentínsky štandardný čas", "HADT": "havajsko-aleutský letný čas", "NZDT": "novozélandský letný čas", "ARST": "argentínsky letný čas", "HKT": "hongkonský štandardný čas", "AEST": "východoaustrálsky štandardný čas", "WIB": "západoindonézsky čas", "HNCU": "kubánsky štandardný čas", "HECU": "kubánsky letný čas", "MST": "MST", "WAT": "západoafrický štandardný čas", "HNNOMX": "severozápadný mexický štandardný čas", "AEDT": "východoaustrálsky letný čas", "SRT": "surinamský čas", "ECT": "ekvádorský čas", "WESZ": "západoeurópsky letný čas", "HEEG": "východogrónsky letný čas", "UYT": "uruguajský štandardný čas", "OESZ": "východoeurópsky letný čas", "HKST": "hongkonský letný čas"}, + } +} + +// Locale returns the current translators string locale +func (sk *sk_SK) Locale() string { + return sk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sk_SK' +func (sk *sk_SK) PluralsCardinal() []locales.PluralRule { + return sk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sk_SK' +func (sk *sk_SK) PluralsOrdinal() []locales.PluralRule { + return sk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sk_SK' +func (sk *sk_SK) PluralsRange() []locales.PluralRule { + return sk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sk_SK' +func (sk *sk_SK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } else if i >= 2 && i <= 4 && v == 0 { + return locales.PluralRuleFew + } else if v != 0 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sk_SK' +func (sk *sk_SK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sk_SK' +func (sk *sk_SK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sk.CardinalPluralRule(num1, v1) + end := sk.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sk *sk_SK) MonthAbbreviated(month time.Month) string { + return sk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sk *sk_SK) MonthsAbbreviated() []string { + return sk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sk *sk_SK) MonthNarrow(month time.Month) string { + return sk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sk *sk_SK) MonthsNarrow() []string { + return sk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sk *sk_SK) MonthWide(month time.Month) string { + return sk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sk *sk_SK) MonthsWide() []string { + return sk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sk *sk_SK) WeekdayAbbreviated(weekday time.Weekday) string { + return sk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sk *sk_SK) WeekdaysAbbreviated() []string { + return sk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sk *sk_SK) WeekdayNarrow(weekday time.Weekday) string { + return sk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sk *sk_SK) WeekdaysNarrow() []string { + return sk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sk *sk_SK) WeekdayShort(weekday time.Weekday) string { + return sk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sk *sk_SK) WeekdaysShort() []string { + return sk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sk *sk_SK) WeekdayWide(weekday time.Weekday) string { + return sk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sk *sk_SK) WeekdaysWide() []string { + return sk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sk_SK' and handles both Whole and Real numbers based on 'v' +func (sk *sk_SK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sk.group) - 1; j >= 0; j-- { + b = append(b, sk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sk_SK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sk *sk_SK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sk.percentSuffix...) + + b = append(b, sk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sk_SK' +func (sk *sk_SK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sk.group) - 1; j >= 0; j-- { + b = append(b, sk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sk.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sk_SK' +// in accounting notation. +func (sk *sk_SK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sk.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sk.group) - 1; j >= 0; j-- { + b = append(b, sk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sk.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sk.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sk_SK' +func (sk *sk_SK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sk_SK' +func (sk *sk_SK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sk_SK' +func (sk *sk_SK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sk_SK' +func (sk *sk_SK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sk.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sk_SK' +func (sk *sk_SK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sk_SK' +func (sk *sk_SK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sk_SK' +func (sk *sk_SK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sk_SK' +func (sk *sk_SK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sk_SK/sk_SK_test.go b/vendor/github.com/go-playground/locales/sk_SK/sk_SK_test.go new file mode 100644 index 0000000000..991910a00e --- /dev/null +++ b/vendor/github.com/go-playground/locales/sk_SK/sk_SK_test.go @@ -0,0 +1,1120 @@ +package sk_SK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sk_SK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sl/sl.go b/vendor/github.com/go-playground/locales/sl/sl.go new file mode 100644 index 0000000000..22dfdb5a31 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sl/sl.go @@ -0,0 +1,648 @@ +package sl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sl' locale +func New() locales.Translator { + return &sl{ + locale: "sl", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{3, 4, 6}, + decimal: ",", + group: ".", + minus: "–", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "avg.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januar", "februar", "marec", "april", "maj", "junij", "julij", "avgust", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"ned.", "pon.", "tor.", "sre.", "čet.", "pet.", "sob."}, + daysNarrow: []string{"n", "p", "t", "s", "č", "p", "s"}, + daysShort: []string{"ned.", "pon.", "tor.", "sre.", "čet.", "pet.", "sob."}, + daysWide: []string{"nedelja", "ponedeljek", "torek", "sreda", "četrtek", "petek", "sobota"}, + periodsAbbreviated: []string{"dop.", "pop."}, + periodsNarrow: []string{"d", "p"}, + periodsWide: []string{"dop.", "pop."}, + erasAbbreviated: []string{"pr. Kr.", "po Kr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"pred Kristusom", "po Kristusu"}, + timezones: map[string]string{"SRT": "Surinamski čas", "HAST": "Havajski aleutski standardni čas", "HADT": "Havajski aleutski poletni čas", "OESZ": "Vzhodnoevropski poletni čas", "ChST": "Čamorski standardni čas", "EDT": "Vzhodni poletni čas", "HNPMX": "mehiški pacifiški standardni čas", "AWST": "Avstralski zahodni standardni čas", "ADT": "Atlantski poletni čas", "MST": "MST", "WARST": "Argentinski zahodni poletni čas", "HNOG": "Zahodnogrenlandski standardni čas", "∅∅∅": "∅∅∅", "EAT": "Vzhodnoafriški čas", "NZST": "Novozelandski standardni čas", "JDT": "Japonski poletni čas", "WESZ": "Zahodnoevropski poletni čas", "AKDT": "Aljaški poletni čas", "HNCU": "Kubanski standardni čas", "AEST": "Avstralski vzhodni standardni čas", "AEDT": "Avstralski vzhodni poletni čas", "HENOMX": "mehiški severozahodni poletni čas", "CDT": "Centralni poletni čas", "TMT": "Turkmenistanski standardni čas", "MDT": "MDT", "PDT": "Pacifiški poletni čas", "ACWDT": "Avstralski centralni zahodni poletni čas", "ART": "Argentinski standardni čas", "HNPM": "Standardni čas: Saint Pierre in Miquelon", "COT": "Kolumbijski standardni čas", "OEZ": "Vzhodnoevropski standardni čas", "TMST": "Turkmenistanski poletni čas", "ACST": "Avstralski centralni standardni čas", "HNEG": "Vzhodnogrenlandski standardni čas", "HEEG": "Vzhodnogrenlandski poletni čas", "AKST": "Aljaški standardni čas", "UYT": "Urugvajski standardni čas", "SGT": "Singapurski standardni čas", "JST": "Japonski standardni čas", "CLST": "Čilski poletni čas", "IST": "Indijski standardni čas", "EST": "Vzhodni standardni čas", "HAT": "Novofundlandski poletni čas", "BOT": "Bolivijski čas", "VET": "Venezuelski čas", "MEZ": "Srednjeevropski standardni čas", "WAT": "Zahodnoafriški standardni čas", "ACDT": "Avstralski centralni poletni čas", "HNT": "Novofundlandski standardni čas", "WIT": "Indonezijski vzhodni čas", "CAT": "Centralnoafriški čas", "MESZ": "Srednjeevropski poletni čas", "HEOG": "Zahodnogrenlandski poletni čas", "ARST": "Argentinski poletni čas", "GFT": "Čas: Francoska Gvajana", "HEPM": "Poletni čas: Saint Pierre in Miquelon", "LHDT": "Poletni čas otoka Lord Howe", "HEPMX": "mehiški pacifiški poletni čas", "CHADT": "Čatamski poletni čas", "GMT": "Greenwiški srednji čas", "AST": "Atlantski standardni čas", "NZDT": "Novozelandski poletni čas", "CLT": "Čilski standardni čas", "WITA": "Indonezijski osrednji čas", "UYST": "Urugvajski poletni čas", "LHST": "Standardni čas otoka Lord Howe", "CHAST": "Čatamski standardni čas", "WEZ": "Zahodnoevropski standardni čas", "MYT": "Malezijski čas", "GYT": "Gvajanski čas", "WIB": "Indonezijski zahodni čas", "ACWST": "Avstralski centralni zahodni standardni čas", "HKST": "Hongkonški poletni čas", "HNNOMX": "mehiški severozahodni standardni čas", "WAST": "Zahodnoafriški poletni čas", "BT": "Butanski čas", "AWDT": "Avstralski zahodni poletni čas", "PST": "Pacifiški standardni čas", "ECT": "Ekvadorski čas", "WART": "Argentinski zahodni standardni čas", "HKT": "Hongkonški standardni čas", "CST": "Centralni standardni čas", "COST": "Kolumbijski poletni čas", "SAST": "Južnoafriški čas", "HECU": "Kubanski poletni čas"}, + } +} + +// Locale returns the current translators string locale +func (sl *sl) Locale() string { + return sl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sl' +func (sl *sl) PluralsCardinal() []locales.PluralRule { + return sl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sl' +func (sl *sl) PluralsOrdinal() []locales.PluralRule { + return sl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sl' +func (sl *sl) PluralsRange() []locales.PluralRule { + return sl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sl' +func (sl *sl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + + if v == 0 && iMod100 == 1 { + return locales.PluralRuleOne + } else if v == 0 && iMod100 == 2 { + return locales.PluralRuleTwo + } else if (v == 0 && iMod100 >= 3 && iMod100 <= 4) || (v != 0) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sl' +func (sl *sl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sl' +func (sl *sl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sl.CardinalPluralRule(num1, v1) + end := sl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sl *sl) MonthAbbreviated(month time.Month) string { + return sl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sl *sl) MonthsAbbreviated() []string { + return sl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sl *sl) MonthNarrow(month time.Month) string { + return sl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sl *sl) MonthsNarrow() []string { + return sl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sl *sl) MonthWide(month time.Month) string { + return sl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sl *sl) MonthsWide() []string { + return sl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sl *sl) WeekdayAbbreviated(weekday time.Weekday) string { + return sl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sl *sl) WeekdaysAbbreviated() []string { + return sl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sl *sl) WeekdayNarrow(weekday time.Weekday) string { + return sl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sl *sl) WeekdaysNarrow() []string { + return sl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sl *sl) WeekdayShort(weekday time.Weekday) string { + return sl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sl *sl) WeekdaysShort() []string { + return sl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sl *sl) WeekdayWide(weekday time.Weekday) string { + return sl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sl *sl) WeekdaysWide() []string { + return sl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sl' and handles both Whole and Real numbers based on 'v' +func (sl *sl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sl.minus) - 1; j >= 0; j-- { + b = append(b, sl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sl *sl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sl.minus) - 1; j >= 0; j-- { + b = append(b, sl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sl.percentSuffix...) + + b = append(b, sl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sl' +func (sl *sl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sl.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sl.minus) - 1; j >= 0; j-- { + b = append(b, sl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sl' +// in accounting notation. +func (sl *sl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sl.currencies[currency] + l := len(s) + len(symbol) + 8 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sl.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sl' +func (sl *sl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sl' +func (sl *sl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sl' +func (sl *sl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sl' +func (sl *sl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sl' +func (sl *sl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sl' +func (sl *sl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sl' +func (sl *sl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sl' +func (sl *sl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sl/sl_test.go b/vendor/github.com/go-playground/locales/sl/sl_test.go new file mode 100644 index 0000000000..80e34f4341 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sl/sl_test.go @@ -0,0 +1,1120 @@ +package sl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sl_SI/sl_SI.go b/vendor/github.com/go-playground/locales/sl_SI/sl_SI.go new file mode 100644 index 0000000000..d968037f41 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sl_SI/sl_SI.go @@ -0,0 +1,648 @@ +package sl_SI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sl_SI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sl_SI' locale +func New() locales.Translator { + return &sl_SI{ + locale: "sl_SI", + pluralsCardinal: []locales.PluralRule{2, 3, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{3, 4, 6}, + decimal: ",", + group: ".", + minus: "–", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "feb.", "mar.", "apr.", "maj", "jun.", "jul.", "avg.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januar", "februar", "marec", "april", "maj", "junij", "julij", "avgust", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"ned.", "pon.", "tor.", "sre.", "čet.", "pet.", "sob."}, + daysNarrow: []string{"n", "p", "t", "s", "č", "p", "s"}, + daysShort: []string{"ned.", "pon.", "tor.", "sre.", "čet.", "pet.", "sob."}, + daysWide: []string{"nedelja", "ponedeljek", "torek", "sreda", "četrtek", "petek", "sobota"}, + periodsAbbreviated: []string{"dop.", "pop."}, + periodsNarrow: []string{"d", "p"}, + periodsWide: []string{"dop.", "pop."}, + erasAbbreviated: []string{"pr. Kr.", "po Kr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"pred Kristusom", "po Kristusu"}, + timezones: map[string]string{"AWST": "Avstralski zahodni standardni čas", "JDT": "Japonski poletni čas", "GMT": "Greenwiški srednji čas", "OEZ": "Vzhodnoevropski standardni čas", "WITA": "Indonezijski osrednji čas", "LHST": "Standardni čas otoka Lord Howe", "HAST": "Havajski aleutski standardni čas", "HADT": "Havajski aleutski poletni čas", "ACWDT": "Avstralski centralni zahodni poletni čas", "MEZ": "Srednjeevropski standardni čas", "UYST": "Urugvajski poletni čas", "GYT": "Gvajanski čas", "IST": "Indijski standardni čas", "EST": "Vzhodni standardni čas", "COT": "Kolumbijski standardni čas", "ChST": "Čamorski standardni čas", "HNPM": "Standardni čas: Saint Pierre in Miquelon", "HEPM": "Poletni čas: Saint Pierre in Miquelon", "MESZ": "Srednjeevropski poletni čas", "WARST": "Argentinski zahodni poletni čas", "HNEG": "Vzhodnogrenlandski standardni čas", "SAST": "Južnoafriški čas", "HAT": "Novofundlandski poletni čas", "HEEG": "Vzhodnogrenlandski poletni čas", "BOT": "Bolivijski čas", "WESZ": "Zahodnoevropski poletni čas", "WAST": "Zahodnoafriški poletni čas", "EDT": "Vzhodni poletni čas", "ACST": "Avstralski centralni standardni čas", "HNT": "Novofundlandski standardni čas", "HECU": "Kubanski poletni čas", "CDT": "Centralni poletni čas", "AWDT": "Avstralski zahodni poletni čas", "CAT": "Centralnoafriški čas", "VET": "Venezuelski čas", "ACDT": "Avstralski centralni poletni čas", "UYT": "Urugvajski standardni čas", "LHDT": "Poletni čas otoka Lord Howe", "MYT": "Malezijski čas", "AST": "Atlantski standardni čas", "HENOMX": "mehiški severozahodni poletni čas", "NZDT": "Novozelandski poletni čas", "MDT": "MDT", "BT": "Butanski čas", "GFT": "Čas: Francoska Gvajana", "AKST": "Aljaški standardni čas", "HNPMX": "mehiški pacifiški standardni čas", "HNCU": "Kubanski standardni čas", "ACWST": "Avstralski centralni zahodni standardni čas", "HKST": "Hongkonški poletni čas", "CST": "Centralni standardni čas", "ECT": "Ekvadorski čas", "ART": "Argentinski standardni čas", "WAT": "Zahodnoafriški standardni čas", "AKDT": "Aljaški poletni čas", "HEPMX": "mehiški pacifiški poletni čas", "EAT": "Vzhodnoafriški čas", "PDT": "Pacifiški poletni čas", "NZST": "Novozelandski standardni čas", "∅∅∅": "Amazonski poletni čas", "ADT": "Atlantski poletni čas", "COST": "Kolumbijski poletni čas", "WIB": "Indonezijski zahodni čas", "CHAST": "Čatamski standardni čas", "HNOG": "Zahodnogrenlandski standardni čas", "HEOG": "Zahodnogrenlandski poletni čas", "OESZ": "Vzhodnoevropski poletni čas", "TMST": "Turkmenistanski poletni čas", "AEST": "Avstralski vzhodni standardni čas", "WIT": "Indonezijski vzhodni čas", "CHADT": "Čatamski poletni čas", "PST": "Pacifiški standardni čas", "CLST": "Čilski poletni čas", "TMT": "Turkmenistanski standardni čas", "HNNOMX": "mehiški severozahodni standardni čas", "AEDT": "Avstralski vzhodni poletni čas", "SGT": "Singapurski standardni čas", "WEZ": "Zahodnoevropski standardni čas", "MST": "MST", "ARST": "Argentinski poletni čas", "HKT": "Hongkonški standardni čas", "JST": "Japonski standardni čas", "WART": "Argentinski zahodni standardni čas", "CLT": "Čilski standardni čas", "SRT": "Surinamski čas"}, + } +} + +// Locale returns the current translators string locale +func (sl *sl_SI) Locale() string { + return sl.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sl_SI' +func (sl *sl_SI) PluralsCardinal() []locales.PluralRule { + return sl.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sl_SI' +func (sl *sl_SI) PluralsOrdinal() []locales.PluralRule { + return sl.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sl_SI' +func (sl *sl_SI) PluralsRange() []locales.PluralRule { + return sl.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sl_SI' +func (sl *sl_SI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod100 := i % 100 + + if v == 0 && iMod100 == 1 { + return locales.PluralRuleOne + } else if v == 0 && iMod100 == 2 { + return locales.PluralRuleTwo + } else if (v == 0 && iMod100 >= 3 && iMod100 <= 4) || (v != 0) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sl_SI' +func (sl *sl_SI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sl_SI' +func (sl *sl_SI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sl.CardinalPluralRule(num1, v1) + end := sl.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleTwo && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleTwo { + return locales.PluralRuleTwo + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sl *sl_SI) MonthAbbreviated(month time.Month) string { + return sl.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sl *sl_SI) MonthsAbbreviated() []string { + return sl.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sl *sl_SI) MonthNarrow(month time.Month) string { + return sl.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sl *sl_SI) MonthsNarrow() []string { + return sl.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sl *sl_SI) MonthWide(month time.Month) string { + return sl.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sl *sl_SI) MonthsWide() []string { + return sl.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sl *sl_SI) WeekdayAbbreviated(weekday time.Weekday) string { + return sl.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sl *sl_SI) WeekdaysAbbreviated() []string { + return sl.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sl *sl_SI) WeekdayNarrow(weekday time.Weekday) string { + return sl.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sl *sl_SI) WeekdaysNarrow() []string { + return sl.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sl *sl_SI) WeekdayShort(weekday time.Weekday) string { + return sl.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sl *sl_SI) WeekdaysShort() []string { + return sl.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sl *sl_SI) WeekdayWide(weekday time.Weekday) string { + return sl.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sl *sl_SI) WeekdaysWide() []string { + return sl.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sl_SI' and handles both Whole and Real numbers based on 'v' +func (sl *sl_SI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sl.minus) - 1; j >= 0; j-- { + b = append(b, sl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sl_SI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sl *sl_SI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sl.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sl.minus) - 1; j >= 0; j-- { + b = append(b, sl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sl.percentSuffix...) + + b = append(b, sl.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sl_SI' +func (sl *sl_SI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sl.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sl.minus) - 1; j >= 0; j-- { + b = append(b, sl.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sl.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sl_SI' +// in accounting notation. +func (sl *sl_SI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sl.currencies[currency] + l := len(s) + len(symbol) + 8 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sl.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sl.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sl.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sl.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sl.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sl.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sl_SI' +func (sl *sl_SI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sl_SI' +func (sl *sl_SI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sl.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sl_SI' +func (sl *sl_SI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sl_SI' +func (sl *sl_SI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sl.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sl.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sl_SI' +func (sl *sl_SI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sl_SI' +func (sl *sl_SI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sl_SI' +func (sl *sl_SI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sl_SI' +func (sl *sl_SI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sl.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sl.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sl.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sl_SI/sl_SI_test.go b/vendor/github.com/go-playground/locales/sl_SI/sl_SI_test.go new file mode 100644 index 0000000000..f4c9147aee --- /dev/null +++ b/vendor/github.com/go-playground/locales/sl_SI/sl_SI_test.go @@ -0,0 +1,1120 @@ +package sl_SI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sl_SI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/smn/smn.go b/vendor/github.com/go-playground/locales/smn/smn.go new file mode 100644 index 0000000000..2e555ae72f --- /dev/null +++ b/vendor/github.com/go-playground/locales/smn/smn.go @@ -0,0 +1,573 @@ +package smn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type smn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'smn' locale +func New() locales.Translator { + return &smn{ + locale: "smn", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "uđiv", "kuovâ", "njuhčâ", "cuáŋui", "vyesi", "kesi", "syeini", "porge", "čohčâ", "roovvâd", "skammâ", "juovlâ"}, + monthsNarrow: []string{"", "U", "K", "NJ", "C", "V", "K", "S", "P", "Č", "R", "S", "J"}, + monthsWide: []string{"", "uđđâivemáánu", "kuovâmáánu", "njuhčâmáánu", "cuáŋuimáánu", "vyesimáánu", "kesimáánu", "syeinimáánu", "porgemáánu", "čohčâmáánu", "roovvâdmáánu", "skammâmáánu", "juovlâmáánu"}, + daysAbbreviated: []string{"pas", "vuo", "maj", "kos", "tuo", "vás", "láv"}, + daysNarrow: []string{"p", "V", "M", "K", "T", "V", "L"}, + daysShort: []string{"pa", "vu", "ma", "ko", "tu", "vá", "lá"}, + daysWide: []string{"pasepeeivi", "vuossaargâ", "majebaargâ", "koskoho", "tuorâstuv", "vástuppeeivi", "lávurduv"}, + periodsAbbreviated: []string{"ip.", "ep."}, + periodsNarrow: []string{"ip.", "ep."}, + periodsWide: []string{"ip.", "ep."}, + erasAbbreviated: []string{"oKr.", "mKr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Ovdil Kristus šoddâm", "maŋa Kristus šoddâm"}, + timezones: map[string]string{"VET": "VET", "WAST": "WAST", "COT": "COT", "WITA": "WITA", "HNCU": "HNCU", "MYT": "MYT", "TMT": "TMT", "UYT": "UYT", "UYST": "UYST", "HNPM": "HNPM", "IST": "IST", "ACDT": "ACDT", "COST": "COST", "GYT": "GYT", "HECU": "HECU", "PST": "PST", "PDT": "PDT", "NZST": "NZST", "JST": "JST", "WART": "WART", "ADT": "ADT", "WEZ": "WEZ", "ARST": "ARST", "WAT": "WAT", "HKT": "HKT", "HNNOMX": "HNNOMX", "SAST": "SAST", "OEZ": "OEZ", "LHDT": "LHDT", "WIT": "WIT", "HNT": "HNT", "CST": "CST", "JDT": "JDT", "TMST": "TMST", "ACST": "ACST", "AKST": "AKST", "OESZ": "OESZ", "HKST": "HKST", "BT": "BT", "CDT": "CDT", "HADT": "HADT", "HNOG": "HNOG", "HAT": "HAT", "AEDT": "AEDT", "HNPMX": "HNPMX", "EAT": "EAT", "ACWST": "ACWST", "∅∅∅": "∅∅∅", "MEZ": "MEZ", "WARST": "WARST", "WESZ": "WESZ", "HNEG": "HNEG", "HEPM": "HEPM", "LHST": "LHST", "AWST": "AWST", "AWDT": "AWDT", "NZDT": "NZDT", "MDT": "MDT", "EST": "EST", "GFT": "GFT", "ChST": "ChST", "ECT": "ECT", "CAT": "CAT", "CLT": "CLT", "HEOG": "HEOG", "MST": "MST", "HEPMX": "HEPMX", "BOT": "BOT", "MESZ": "MESZ", "GMT": "GMT", "CLST": "CLST", "AST": "AST", "ART": "ART", "HEEG": "HEEG", "SRT": "SRT", "WIB": "WIB", "CHADT": "CHADT", "HAST": "HAST", "HENOMX": "HENOMX", "AKDT": "AKDT", "CHAST": "CHAST", "ACWDT": "ACWDT", "EDT": "EDT", "AEST": "AEST", "SGT": "SGT"}, + } +} + +// Locale returns the current translators string locale +func (smn *smn) Locale() string { + return smn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'smn' +func (smn *smn) PluralsCardinal() []locales.PluralRule { + return smn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'smn' +func (smn *smn) PluralsOrdinal() []locales.PluralRule { + return smn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'smn' +func (smn *smn) PluralsRange() []locales.PluralRule { + return smn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'smn' +func (smn *smn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'smn' +func (smn *smn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'smn' +func (smn *smn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (smn *smn) MonthAbbreviated(month time.Month) string { + return smn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (smn *smn) MonthsAbbreviated() []string { + return smn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (smn *smn) MonthNarrow(month time.Month) string { + return smn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (smn *smn) MonthsNarrow() []string { + return smn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (smn *smn) MonthWide(month time.Month) string { + return smn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (smn *smn) MonthsWide() []string { + return smn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (smn *smn) WeekdayAbbreviated(weekday time.Weekday) string { + return smn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (smn *smn) WeekdaysAbbreviated() []string { + return smn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (smn *smn) WeekdayNarrow(weekday time.Weekday) string { + return smn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (smn *smn) WeekdaysNarrow() []string { + return smn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (smn *smn) WeekdayShort(weekday time.Weekday) string { + return smn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (smn *smn) WeekdaysShort() []string { + return smn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (smn *smn) WeekdayWide(weekday time.Weekday) string { + return smn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (smn *smn) WeekdaysWide() []string { + return smn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'smn' and handles both Whole and Real numbers based on 'v' +func (smn *smn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, smn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(smn.group) - 1; j >= 0; j-- { + b = append(b, smn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, smn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'smn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (smn *smn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, smn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, smn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, smn.percentSuffix...) + + b = append(b, smn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'smn' +func (smn *smn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := smn.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, smn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(smn.group) - 1; j >= 0; j-- { + b = append(b, smn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, smn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, smn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, smn.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'smn' +// in accounting notation. +func (smn *smn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := smn.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, smn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(smn.group) - 1; j >= 0; j-- { + b = append(b, smn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, smn.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, smn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, smn.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, smn.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'smn' +func (smn *smn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'smn' +func (smn *smn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, smn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'smn' +func (smn *smn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, smn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'smn' +func (smn *smn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x63, 0x63, 0x63, 0x63, 0x2c, 0x20}...) + b = append(b, smn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'smn' +func (smn *smn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'smn' +func (smn *smn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'smn' +func (smn *smn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'smn' +func (smn *smn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := smn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/smn/smn_test.go b/vendor/github.com/go-playground/locales/smn/smn_test.go new file mode 100644 index 0000000000..ae03eaf57a --- /dev/null +++ b/vendor/github.com/go-playground/locales/smn/smn_test.go @@ -0,0 +1,1120 @@ +package smn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "smn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/smn_FI/smn_FI.go b/vendor/github.com/go-playground/locales/smn_FI/smn_FI.go new file mode 100644 index 0000000000..0228b65a8d --- /dev/null +++ b/vendor/github.com/go-playground/locales/smn_FI/smn_FI.go @@ -0,0 +1,573 @@ +package smn_FI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type smn_FI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'smn_FI' locale +func New() locales.Translator { + return &smn_FI{ + locale: "smn_FI", + pluralsCardinal: []locales.PluralRule{2, 3, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "uđiv", "kuovâ", "njuhčâ", "cuáŋui", "vyesi", "kesi", "syeini", "porge", "čohčâ", "roovvâd", "skammâ", "juovlâ"}, + monthsNarrow: []string{"", "U", "K", "NJ", "C", "V", "K", "S", "P", "Č", "R", "S", "J"}, + monthsWide: []string{"", "uđđâivemáánu", "kuovâmáánu", "njuhčâmáánu", "cuáŋuimáánu", "vyesimáánu", "kesimáánu", "syeinimáánu", "porgemáánu", "čohčâmáánu", "roovvâdmáánu", "skammâmáánu", "juovlâmáánu"}, + daysAbbreviated: []string{"pas", "vuo", "maj", "kos", "tuo", "vás", "láv"}, + daysNarrow: []string{"p", "V", "M", "K", "T", "V", "L"}, + daysShort: []string{"pa", "vu", "ma", "ko", "tu", "vá", "lá"}, + daysWide: []string{"pasepeeivi", "vuossaargâ", "majebaargâ", "koskoho", "tuorâstuv", "vástuppeeivi", "lávurduv"}, + periodsAbbreviated: []string{"ip.", "ep."}, + periodsNarrow: []string{"ip.", "ep."}, + periodsWide: []string{"ip.", "ep."}, + erasAbbreviated: []string{"oKr.", "mKr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Ovdil Kristus šoddâm", "maŋa Kristus šoddâm"}, + timezones: map[string]string{"ECT": "ECT", "ARST": "ARST", "CLT": "CLT", "ACDT": "ACDT", "UYT": "UYT", "HEPMX": "HEPMX", "BOT": "BOT", "CHAST": "CHAST", "MYT": "MYT", "WAT": "WAT", "HNCU": "HNCU", "HECU": "HECU", "CDT": "CDT", "HADT": "HADT", "WARST": "WARST", "LHST": "LHST", "AWST": "AWST", "MESZ": "MESZ", "CLST": "CLST", "HEOG": "HEOG", "HKT": "HKT", "WITA": "WITA", "ChST": "ChST", "WAST": "WAST", "TMT": "TMT", "ACWDT": "ACWDT", "WEZ": "WEZ", "HENOMX": "HENOMX", "WIT": "WIT", "AWDT": "AWDT", "NZST": "NZST", "NZDT": "NZDT", "JDT": "JDT", "AST": "AST", "COT": "COT", "AKDT": "AKDT", "GYT": "GYT", "CST": "CST", "ACWST": "ACWST", "VET": "VET", "HNNOMX": "HNNOMX", "HEPM": "HEPM", "HNPMX": "HNPMX", "OEZ": "OEZ", "AEST": "AEST", "EAT": "EAT", "CHADT": "CHADT", "SRT": "SRT", "WIB": "WIB", "JST": "JST", "ADT": "ADT", "ACST": "ACST", "BT": "BT", "HNPM": "HNPM", "HEEG": "HEEG", "UYST": "UYST", "SAST": "SAST", "PST": "PST", "CAT": "CAT", "EDT": "EDT", "HAT": "HAT", "HNEG": "HNEG", "WESZ": "WESZ", "ART": "ART", "OESZ": "OESZ", "WART": "WART", "TMST": "TMST", "EST": "EST", "AKST": "AKST", "HAST": "HAST", "SGT": "SGT", "IST": "IST", "GMT": "GMT", "HKST": "HKST", "COST": "COST", "∅∅∅": "∅∅∅", "MST": "MST", "GFT": "GFT", "MEZ": "MEZ", "LHDT": "LHDT", "PDT": "PDT", "HNOG": "HNOG", "HNT": "HNT", "AEDT": "AEDT", "MDT": "MDT"}, + } +} + +// Locale returns the current translators string locale +func (smn *smn_FI) Locale() string { + return smn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'smn_FI' +func (smn *smn_FI) PluralsCardinal() []locales.PluralRule { + return smn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'smn_FI' +func (smn *smn_FI) PluralsOrdinal() []locales.PluralRule { + return smn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'smn_FI' +func (smn *smn_FI) PluralsRange() []locales.PluralRule { + return smn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'smn_FI' +func (smn *smn_FI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } else if n == 2 { + return locales.PluralRuleTwo + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'smn_FI' +func (smn *smn_FI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'smn_FI' +func (smn *smn_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (smn *smn_FI) MonthAbbreviated(month time.Month) string { + return smn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (smn *smn_FI) MonthsAbbreviated() []string { + return smn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (smn *smn_FI) MonthNarrow(month time.Month) string { + return smn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (smn *smn_FI) MonthsNarrow() []string { + return smn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (smn *smn_FI) MonthWide(month time.Month) string { + return smn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (smn *smn_FI) MonthsWide() []string { + return smn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (smn *smn_FI) WeekdayAbbreviated(weekday time.Weekday) string { + return smn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (smn *smn_FI) WeekdaysAbbreviated() []string { + return smn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (smn *smn_FI) WeekdayNarrow(weekday time.Weekday) string { + return smn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (smn *smn_FI) WeekdaysNarrow() []string { + return smn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (smn *smn_FI) WeekdayShort(weekday time.Weekday) string { + return smn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (smn *smn_FI) WeekdaysShort() []string { + return smn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (smn *smn_FI) WeekdayWide(weekday time.Weekday) string { + return smn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (smn *smn_FI) WeekdaysWide() []string { + return smn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'smn_FI' and handles both Whole and Real numbers based on 'v' +func (smn *smn_FI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, smn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(smn.group) - 1; j >= 0; j-- { + b = append(b, smn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, smn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'smn_FI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (smn *smn_FI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, smn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, smn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, smn.percentSuffix...) + + b = append(b, smn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'smn_FI' +func (smn *smn_FI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := smn.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, smn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(smn.group) - 1; j >= 0; j-- { + b = append(b, smn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, smn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, smn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, smn.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'smn_FI' +// in accounting notation. +func (smn *smn_FI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := smn.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, smn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(smn.group) - 1; j >= 0; j-- { + b = append(b, smn.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, smn.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, smn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, smn.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, smn.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'smn_FI' +func (smn *smn_FI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'smn_FI' +func (smn *smn_FI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, smn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'smn_FI' +func (smn *smn_FI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, smn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'smn_FI' +func (smn *smn_FI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x63, 0x63, 0x63, 0x63, 0x2c, 0x20}...) + b = append(b, smn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'smn_FI' +func (smn *smn_FI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'smn_FI' +func (smn *smn_FI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'smn_FI' +func (smn *smn_FI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'smn_FI' +func (smn *smn_FI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x2e}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x2e}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := smn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/smn_FI/smn_FI_test.go b/vendor/github.com/go-playground/locales/smn_FI/smn_FI_test.go new file mode 100644 index 0000000000..25815c3acd --- /dev/null +++ b/vendor/github.com/go-playground/locales/smn_FI/smn_FI_test.go @@ -0,0 +1,1120 @@ +package smn_FI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "smn_FI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sn/sn.go b/vendor/github.com/go-playground/locales/sn/sn.go new file mode 100644 index 0000000000..841e8fe0af --- /dev/null +++ b/vendor/github.com/go-playground/locales/sn/sn.go @@ -0,0 +1,594 @@ +package sn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sn' locale +func New() locales.Translator { + return &sn{ + locale: "sn", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ndi", "Kuk", "Kur", "Kub", "Chv", "Chk", "Chg", "Nya", "Gun", "Gum", "Mbu", "Zvi"}, + monthsNarrow: []string{"", "N", "K", "K", "K", "C", "C", "C", "N", "G", "G", "M", "Z"}, + monthsWide: []string{"", "Ndira", "Kukadzi", "Kurume", "Kubvumbi", "Chivabvu", "Chikumi", "Chikunguru", "Nyamavhuvhu", "Gunyana", "Gumiguru", "Mbudzi", "Zvita"}, + daysAbbreviated: []string{"Svo", "Muv", "Chp", "Cht", "Chn", "Chs", "Mug"}, + daysNarrow: []string{"S", "M", "C", "C", "C", "C", "M"}, + daysShort: []string{"Sv", "Mu", "Cp", "Ct", "Cn", "Cs", "Mg"}, + daysWide: []string{"Svondo", "Muvhuro", "Chipiri", "Chitatu", "China", "Chishanu", "Mugovera"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kristo asati auya", "mugore ramambo vedu"}, + timezones: map[string]string{"WIB": "WIB", "ADT": "ADT", "GMT": "GMT", "MST": "MST", "COST": "COST", "HNNOMX": "HNNOMX", "UYT": "UYT", "BOT": "BOT", "MESZ": "MESZ", "HEEG": "HEEG", "CHADT": "CHADT", "HEOG": "HEOG", "COT": "COT", "AWDT": "AWDT", "EST": "EST", "ACDT": "ACDT", "HNPMX": "HNPMX", "CST": "CST", "WIT": "WIT", "SGT": "SGT", "CLST": "CLST", "ACST": "ACST", "HENOMX": "HENOMX", "HNOG": "HNOG", "AKST": "AKST", "LHDT": "LHDT", "GYT": "GYT", "HECU": "HECU", "HADT": "HADT", "WEZ": "WEZ", "ART": "ART", "GFT": "GFT", "HNCU": "HNCU", "VET": "VET", "OESZ": "OESZ", "WART": "WART", "CAT": "CAT", "AST": "AST", "TMT": "TMT", "HKST": "HKST", "HAT": "HAT", "HNPM": "HNPM", "ECT": "ECT", "ChST": "ChST", "SAST": "SAST", "LHST": "LHST", "CDT": "CDT", "WAT": "WAT", "WITA": "WITA", "HEPMX": "HEPMX", "IST": "IST", "ACWST": "ACWST", "WARST": "WARST", "CLT": "CLT", "TMST": "TMST", "WAST": "WAST", "HNT": "HNT", "AWST": "AWST", "PST": "PST", "ACWDT": "ACWDT", "NZST": "NZST", "NZDT": "NZDT", "MEZ": "MEZ", "JDT": "JDT", "MYT": "MYT", "EDT": "EDT", "∅∅∅": "∅∅∅", "PDT": "PDT", "HAST": "HAST", "JST": "JST", "WESZ": "WESZ", "ARST": "ARST", "UYST": "UYST", "HEPM": "HEPM", "EAT": "EAT", "MDT": "MDT", "HKT": "HKT", "BT": "BT", "AKDT": "AKDT", "AEST": "AEST", "SRT": "SRT", "CHAST": "CHAST", "OEZ": "OEZ", "HNEG": "HNEG", "AEDT": "AEDT"}, + } +} + +// Locale returns the current translators string locale +func (sn *sn) Locale() string { + return sn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sn' +func (sn *sn) PluralsCardinal() []locales.PluralRule { + return sn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sn' +func (sn *sn) PluralsOrdinal() []locales.PluralRule { + return sn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sn' +func (sn *sn) PluralsRange() []locales.PluralRule { + return sn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sn' +func (sn *sn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sn' +func (sn *sn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sn' +func (sn *sn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sn *sn) MonthAbbreviated(month time.Month) string { + return sn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sn *sn) MonthsAbbreviated() []string { + return sn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sn *sn) MonthNarrow(month time.Month) string { + return sn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sn *sn) MonthsNarrow() []string { + return sn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sn *sn) MonthWide(month time.Month) string { + return sn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sn *sn) MonthsWide() []string { + return sn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sn *sn) WeekdayAbbreviated(weekday time.Weekday) string { + return sn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sn *sn) WeekdaysAbbreviated() []string { + return sn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sn *sn) WeekdayNarrow(weekday time.Weekday) string { + return sn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sn *sn) WeekdaysNarrow() []string { + return sn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sn *sn) WeekdayShort(weekday time.Weekday) string { + return sn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sn *sn) WeekdaysShort() []string { + return sn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sn *sn) WeekdayWide(weekday time.Weekday) string { + return sn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sn *sn) WeekdaysWide() []string { + return sn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sn' and handles both Whole and Real numbers based on 'v' +func (sn *sn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sn *sn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sn' +func (sn *sn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sn.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sn' +// in accounting notation. +func (sn *sn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sn.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sn.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sn.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sn' +func (sn *sn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sn' +func (sn *sn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, sn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sn' +func (sn *sn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, sn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sn' +func (sn *sn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, sn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, sn.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sn' +func (sn *sn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sn' +func (sn *sn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sn' +func (sn *sn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sn' +func (sn *sn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sn/sn_test.go b/vendor/github.com/go-playground/locales/sn/sn_test.go new file mode 100644 index 0000000000..beff22a309 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sn/sn_test.go @@ -0,0 +1,1120 @@ +package sn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sn_ZW/sn_ZW.go b/vendor/github.com/go-playground/locales/sn_ZW/sn_ZW.go new file mode 100644 index 0000000000..eccab32f1c --- /dev/null +++ b/vendor/github.com/go-playground/locales/sn_ZW/sn_ZW.go @@ -0,0 +1,594 @@ +package sn_ZW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sn_ZW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sn_ZW' locale +func New() locales.Translator { + return &sn_ZW{ + locale: "sn_ZW", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ndi", "Kuk", "Kur", "Kub", "Chv", "Chk", "Chg", "Nya", "Gun", "Gum", "Mbu", "Zvi"}, + monthsNarrow: []string{"", "N", "K", "K", "K", "C", "C", "C", "N", "G", "G", "M", "Z"}, + monthsWide: []string{"", "Ndira", "Kukadzi", "Kurume", "Kubvumbi", "Chivabvu", "Chikumi", "Chikunguru", "Nyamavhuvhu", "Gunyana", "Gumiguru", "Mbudzi", "Zvita"}, + daysAbbreviated: []string{"Svo", "Muv", "Chp", "Cht", "Chn", "Chs", "Mug"}, + daysNarrow: []string{"S", "M", "C", "C", "C", "C", "M"}, + daysShort: []string{"Sv", "Mu", "Cp", "Ct", "Cn", "Cs", "Mg"}, + daysWide: []string{"Svondo", "Muvhuro", "Chipiri", "Chitatu", "China", "Chishanu", "Mugovera"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kristo asati auya", "mugore ramambo vedu"}, + timezones: map[string]string{"AWDT": "AWDT", "ACWST": "ACWST", "JST": "JST", "WIT": "WIT", "WAT": "WAT", "EST": "EST", "ACST": "ACST", "BT": "BT", "HADT": "HADT", "CAT": "CAT", "WESZ": "WESZ", "TMT": "TMT", "IST": "IST", "HNT": "HNT", "AKDT": "AKDT", "HAST": "HAST", "EDT": "EDT", "HNNOMX": "HNNOMX", "UYT": "UYT", "LHST": "LHST", "AWST": "AWST", "BOT": "BOT", "MEZ": "MEZ", "AST": "AST", "HNEG": "HNEG", "WITA": "WITA", "AEDT": "AEDT", "SAST": "SAST", "HNPMX": "HNPMX", "EAT": "EAT", "VET": "VET", "HKST": "HKST", "HNCU": "HNCU", "HNPM": "HNPM", "SRT": "SRT", "ACWDT": "ACWDT", "WARST": "WARST", "MDT": "MDT", "ECT": "ECT", "ARST": "ARST", "PST": "PST", "ADT": "ADT", "OESZ": "OESZ", "UYST": "UYST", "WIB": "WIB", "CHAST": "CHAST", "NZDT": "NZDT", "CLT": "CLT", "HNOG": "HNOG", "GMT": "GMT", "WAST": "WAST", "HEPM": "HEPM", "JDT": "JDT", "WEZ": "WEZ", "ART": "ART", "HECU": "HECU", "NZST": "NZST", "CLST": "CLST", "OEZ": "OEZ", "COT": "COT", "ChST": "ChST", "∅∅∅": "∅∅∅", "GYT": "GYT", "MESZ": "MESZ", "MYT": "MYT", "ACDT": "ACDT", "GFT": "GFT", "AKST": "AKST", "HEPMX": "HEPMX", "PDT": "PDT", "MST": "MST", "HKT": "HKT", "LHDT": "LHDT", "CHADT": "CHADT", "HAT": "HAT", "HEEG": "HEEG", "AEST": "AEST", "WART": "WART", "TMST": "TMST", "HENOMX": "HENOMX", "CST": "CST", "CDT": "CDT", "SGT": "SGT", "HEOG": "HEOG", "COST": "COST"}, + } +} + +// Locale returns the current translators string locale +func (sn *sn_ZW) Locale() string { + return sn.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sn_ZW' +func (sn *sn_ZW) PluralsCardinal() []locales.PluralRule { + return sn.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sn_ZW' +func (sn *sn_ZW) PluralsOrdinal() []locales.PluralRule { + return sn.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sn_ZW' +func (sn *sn_ZW) PluralsRange() []locales.PluralRule { + return sn.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sn_ZW' +func (sn *sn_ZW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sn_ZW' +func (sn *sn_ZW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sn_ZW' +func (sn *sn_ZW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sn *sn_ZW) MonthAbbreviated(month time.Month) string { + return sn.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sn *sn_ZW) MonthsAbbreviated() []string { + return sn.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sn *sn_ZW) MonthNarrow(month time.Month) string { + return sn.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sn *sn_ZW) MonthsNarrow() []string { + return sn.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sn *sn_ZW) MonthWide(month time.Month) string { + return sn.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sn *sn_ZW) MonthsWide() []string { + return sn.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sn *sn_ZW) WeekdayAbbreviated(weekday time.Weekday) string { + return sn.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sn *sn_ZW) WeekdaysAbbreviated() []string { + return sn.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sn *sn_ZW) WeekdayNarrow(weekday time.Weekday) string { + return sn.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sn *sn_ZW) WeekdaysNarrow() []string { + return sn.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sn *sn_ZW) WeekdayShort(weekday time.Weekday) string { + return sn.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sn *sn_ZW) WeekdaysShort() []string { + return sn.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sn *sn_ZW) WeekdayWide(weekday time.Weekday) string { + return sn.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sn *sn_ZW) WeekdaysWide() []string { + return sn.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sn_ZW' and handles both Whole and Real numbers based on 'v' +func (sn *sn_ZW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sn_ZW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sn *sn_ZW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sn.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sn.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sn_ZW' +func (sn *sn_ZW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sn.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sn.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sn_ZW' +// in accounting notation. +func (sn *sn_ZW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sn.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sn.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sn.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sn.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sn.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sn.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sn_ZW' +func (sn *sn_ZW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sn_ZW' +func (sn *sn_ZW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, sn.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sn_ZW' +func (sn *sn_ZW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, sn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sn_ZW' +func (sn *sn_ZW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, sn.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, sn.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sn_ZW' +func (sn *sn_ZW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sn_ZW' +func (sn *sn_ZW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sn_ZW' +func (sn *sn_ZW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sn_ZW' +func (sn *sn_ZW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sn.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sn.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sn.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sn_ZW/sn_ZW_test.go b/vendor/github.com/go-playground/locales/sn_ZW/sn_ZW_test.go new file mode 100644 index 0000000000..e70d0ac965 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sn_ZW/sn_ZW_test.go @@ -0,0 +1,1120 @@ +package sn_ZW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sn_ZW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/so/so.go b/vendor/github.com/go-playground/locales/so/so.go new file mode 100644 index 0000000000..89d51891cc --- /dev/null +++ b/vendor/github.com/go-playground/locales/so/so.go @@ -0,0 +1,572 @@ +package so + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type so struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'so' locale +func New() locales.Translator { + return &so{ + locale: "so", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "S", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Kob", "Lab", "Sad", "Afr", "Sha", "Lix", "Tod", "Sid", "Sag", "Tob", "KIT", "LIT"}, + monthsNarrow: []string{"", "K", "L", "S", "A", "S", "L", "T", "S", "S", "T", "K", "L"}, + monthsWide: []string{"", "Bisha Koobaad", "Bisha Labaad", "Bisha Saddexaad", "Bisha Afraad", "Bisha Shanaad", "Bisha Lixaad", "Bisha Todobaad", "Bisha Sideedaad", "Bisha Sagaalaad", "Bisha Tobnaad", "Bisha Kow iyo Tobnaad", "Bisha Laba iyo Tobnaad"}, + daysAbbreviated: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysNarrow: []string{"A", "I", "T", "A", "Kh", "J", "S"}, + daysShort: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysWide: []string{"Axad", "Isniin", "Talaado", "Arbaco", "Khamiis", "Jimco", "Sabti"}, + periodsAbbreviated: []string{"sn.", "gn."}, + periodsNarrow: []string{"sn.", "gn."}, + periodsWide: []string{"sn.", "gn."}, + erasAbbreviated: []string{"CK", "CD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"CK", "CD"}, + timezones: map[string]string{"MDT": "MDT", "AKST": "AKST", "JDT": "JDT", "WEZ": "WEZ", "WESZ": "WESZ", "EDT": "EDT", "HKST": "HKST", "HENOMX": "HENOMX", "HAT": "HAT", "AWDT": "AWDT", "TMT": "TMT", "ACST": "ACST", "GYT": "GYT", "AWST": "AWST", "IST": "IST", "MEZ": "MEZ", "OEZ": "OEZ", "OESZ": "OESZ", "TMST": "TMST", "HNPMX": "HNPMX", "WITA": "WITA", "CST": "CST", "CHADT": "CHADT", "SGT": "SGT", "NZST": "NZST", "∅∅∅": "∅∅∅", "HNCU": "HNCU", "HAST": "HAST", "MYT": "MYT", "WAT": "WAT", "HNPM": "HNPM", "LHDT": "LHDT", "HECU": "HECU", "CHAST": "CHAST", "ACWST": "ACWST", "CLST": "CLST", "HEOG": "HEOG", "HNT": "HNT", "GMT": "GMT", "WART": "WART", "WARST": "WARST", "CLT": "CLT", "AKDT": "AKDT", "GFT": "GFT", "SAST": "SAST", "LHST": "LHST", "HEPMX": "HEPMX", "HADT": "HADT", "MESZ": "MESZ", "JST": "JST", "BT": "BT", "HKT": "HKT", "CAT": "CAT", "AST": "AST", "ART": "ART", "ChST": "ChST", "ACWDT": "ACWDT", "VET": "VET", "EST": "EST", "UYT": "UYT", "EAT": "EAT", "WIT": "WIT", "BOT": "BOT", "HNOG": "HNOG", "SRT": "SRT", "AEDT": "AEDT", "UYST": "UYST", "COST": "Waqtiyada Xagaaga Kolambiya", "CDT": "CDT", "ARST": "ARST", "HNEG": "HNEG", "HNNOMX": "HNNOMX", "WIB": "WIB", "PDT": "PDT", "ACDT": "ACDT", "HEEG": "HEEG", "AEST": "AEST", "MST": "MST", "ECT": "ECT", "NZDT": "NZDT", "WAST": "WAST", "COT": "Waqtiyada Caadiga ah ee kolambiya", "PST": "PST", "ADT": "ADT", "HEPM": "HEPM"}, + } +} + +// Locale returns the current translators string locale +func (so *so) Locale() string { + return so.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'so' +func (so *so) PluralsCardinal() []locales.PluralRule { + return so.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'so' +func (so *so) PluralsOrdinal() []locales.PluralRule { + return so.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'so' +func (so *so) PluralsRange() []locales.PluralRule { + return so.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'so' +func (so *so) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'so' +func (so *so) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'so' +func (so *so) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (so *so) MonthAbbreviated(month time.Month) string { + return so.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (so *so) MonthsAbbreviated() []string { + return so.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (so *so) MonthNarrow(month time.Month) string { + return so.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (so *so) MonthsNarrow() []string { + return so.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (so *so) MonthWide(month time.Month) string { + return so.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (so *so) MonthsWide() []string { + return so.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (so *so) WeekdayAbbreviated(weekday time.Weekday) string { + return so.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (so *so) WeekdaysAbbreviated() []string { + return so.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (so *so) WeekdayNarrow(weekday time.Weekday) string { + return so.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (so *so) WeekdaysNarrow() []string { + return so.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (so *so) WeekdayShort(weekday time.Weekday) string { + return so.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (so *so) WeekdaysShort() []string { + return so.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (so *so) WeekdayWide(weekday time.Weekday) string { + return so.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (so *so) WeekdaysWide() []string { + return so.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'so' and handles both Whole and Real numbers based on 'v' +func (so *so) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'so' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (so *so) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'so' +func (so *so) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, so.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'so' +// in accounting notation. +func (so *so) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, so.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'so' +func (so *so) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'so' +func (so *so) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, so.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'so' +func (so *so) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'so' +func (so *so) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, so.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'so' +func (so *so) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'so' +func (so *so) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'so' +func (so *so) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'so' +func (so *so) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := so.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/so/so_test.go b/vendor/github.com/go-playground/locales/so/so_test.go new file mode 100644 index 0000000000..1b927d6e9b --- /dev/null +++ b/vendor/github.com/go-playground/locales/so/so_test.go @@ -0,0 +1,1120 @@ +package so + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "so" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/so_DJ/so_DJ.go b/vendor/github.com/go-playground/locales/so_DJ/so_DJ.go new file mode 100644 index 0000000000..3bab1f6900 --- /dev/null +++ b/vendor/github.com/go-playground/locales/so_DJ/so_DJ.go @@ -0,0 +1,572 @@ +package so_DJ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type so_DJ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'so_DJ' locale +func New() locales.Translator { + return &so_DJ{ + locale: "so_DJ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "Fdj", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Kob", "Lab", "Sad", "Afr", "Sha", "Lix", "Tod", "Sid", "Sag", "Tob", "KIT", "LIT"}, + monthsNarrow: []string{"", "K", "L", "S", "A", "S", "L", "T", "S", "S", "T", "K", "L"}, + monthsWide: []string{"", "Bisha Koobaad", "Bisha Labaad", "Bisha Saddexaad", "Bisha Afraad", "Bisha Shanaad", "Bisha Lixaad", "Bisha Todobaad", "Bisha Sideedaad", "Bisha Sagaalaad", "Bisha Tobnaad", "Bisha Kow iyo Tobnaad", "Bisha Laba iyo Tobnaad"}, + daysAbbreviated: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysNarrow: []string{"A", "I", "T", "A", "Kh", "J", "S"}, + daysShort: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysWide: []string{"Axad", "Isniin", "Talaado", "Arbaco", "Khamiis", "Jimco", "Sabti"}, + periodsAbbreviated: []string{"sn.", "gn."}, + periodsNarrow: []string{"sn.", "gn."}, + periodsWide: []string{"sn.", "gn."}, + erasAbbreviated: []string{"CK", "CD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"CK", "CD"}, + timezones: map[string]string{"SRT": "SRT", "HNCU": "HNCU", "HAST": "HAST", "PDT": "PDT", "ADT": "ADT", "HEPMX": "HEPMX", "MESZ": "MESZ", "EDT": "EDT", "LHDT": "LHDT", "CLST": "CLST", "HKST": "HKST", "AKST": "AKST", "HECU": "HECU", "PST": "PST", "NZST": "NZST", "IST": "IST", "JST": "JST", "EAT": "EAT", "BOT": "BOT", "GMT": "GMT", "OEZ": "OEZ", "WAST": "WAST", "WART": "WART", "COST": "Waqtiyada Xagaaga Kolambiya", "HNPMX": "HNPMX", "AST": "AST", "ARST": "ARST", "HKT": "HKT", "ChST": "ChST", "HADT": "HADT", "ECT": "ECT", "∅∅∅": "∅∅∅", "HEOG": "HEOG", "HAT": "HAT", "AEST": "AEST", "UYST": "UYST", "SGT": "SGT", "NZDT": "NZDT", "CAT": "CAT", "WAT": "WAT", "UYT": "UYT", "VET": "VET", "WARST": "WARST", "TMST": "TMST", "WITA": "WITA", "HENOMX": "HENOMX", "ACST": "ACST", "GFT": "GFT", "LHST": "LHST", "WESZ": "WESZ", "HNNOMX": "HNNOMX", "GYT": "GYT", "CDT": "CDT", "CHAST": "CHAST", "ACWDT": "ACWDT", "HNEG": "HNEG", "HEEG": "HEEG", "MST": "MST", "ACDT": "ACDT", "AEDT": "AEDT", "AWDT": "AWDT", "ACWST": "ACWST", "MEZ": "MEZ", "OESZ": "OESZ", "COT": "Waqtiyada Caadiga ah ee kolambiya", "HEPM": "HEPM", "CST": "CST", "WIT": "WIT", "TMT": "TMT", "EST": "EST", "BT": "BT", "AKDT": "AKDT", "HNOG": "HNOG", "HNT": "HNT", "WIB": "WIB", "CHADT": "CHADT", "JDT": "JDT", "WEZ": "WEZ", "MYT": "MYT", "SAST": "SAST", "AWST": "AWST", "CLT": "CLT", "MDT": "MDT", "ART": "ART", "HNPM": "HNPM"}, + } +} + +// Locale returns the current translators string locale +func (so *so_DJ) Locale() string { + return so.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'so_DJ' +func (so *so_DJ) PluralsCardinal() []locales.PluralRule { + return so.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'so_DJ' +func (so *so_DJ) PluralsOrdinal() []locales.PluralRule { + return so.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'so_DJ' +func (so *so_DJ) PluralsRange() []locales.PluralRule { + return so.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'so_DJ' +func (so *so_DJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'so_DJ' +func (so *so_DJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'so_DJ' +func (so *so_DJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (so *so_DJ) MonthAbbreviated(month time.Month) string { + return so.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (so *so_DJ) MonthsAbbreviated() []string { + return so.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (so *so_DJ) MonthNarrow(month time.Month) string { + return so.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (so *so_DJ) MonthsNarrow() []string { + return so.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (so *so_DJ) MonthWide(month time.Month) string { + return so.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (so *so_DJ) MonthsWide() []string { + return so.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (so *so_DJ) WeekdayAbbreviated(weekday time.Weekday) string { + return so.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (so *so_DJ) WeekdaysAbbreviated() []string { + return so.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (so *so_DJ) WeekdayNarrow(weekday time.Weekday) string { + return so.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (so *so_DJ) WeekdaysNarrow() []string { + return so.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (so *so_DJ) WeekdayShort(weekday time.Weekday) string { + return so.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (so *so_DJ) WeekdaysShort() []string { + return so.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (so *so_DJ) WeekdayWide(weekday time.Weekday) string { + return so.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (so *so_DJ) WeekdaysWide() []string { + return so.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'so_DJ' and handles both Whole and Real numbers based on 'v' +func (so *so_DJ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'so_DJ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (so *so_DJ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'so_DJ' +func (so *so_DJ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, so.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'so_DJ' +// in accounting notation. +func (so *so_DJ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, so.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'so_DJ' +func (so *so_DJ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'so_DJ' +func (so *so_DJ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, so.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'so_DJ' +func (so *so_DJ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'so_DJ' +func (so *so_DJ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, so.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'so_DJ' +func (so *so_DJ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'so_DJ' +func (so *so_DJ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'so_DJ' +func (so *so_DJ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'so_DJ' +func (so *so_DJ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := so.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/so_DJ/so_DJ_test.go b/vendor/github.com/go-playground/locales/so_DJ/so_DJ_test.go new file mode 100644 index 0000000000..07bf86f193 --- /dev/null +++ b/vendor/github.com/go-playground/locales/so_DJ/so_DJ_test.go @@ -0,0 +1,1120 @@ +package so_DJ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "so_DJ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/so_ET/so_ET.go b/vendor/github.com/go-playground/locales/so_ET/so_ET.go new file mode 100644 index 0000000000..f00b135cef --- /dev/null +++ b/vendor/github.com/go-playground/locales/so_ET/so_ET.go @@ -0,0 +1,572 @@ +package so_ET + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type so_ET struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'so_ET' locale +func New() locales.Translator { + return &so_ET{ + locale: "so_ET", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "Br", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Kob", "Lab", "Sad", "Afr", "Sha", "Lix", "Tod", "Sid", "Sag", "Tob", "KIT", "LIT"}, + monthsNarrow: []string{"", "K", "L", "S", "A", "S", "L", "T", "S", "S", "T", "K", "L"}, + monthsWide: []string{"", "Bisha Koobaad", "Bisha Labaad", "Bisha Saddexaad", "Bisha Afraad", "Bisha Shanaad", "Bisha Lixaad", "Bisha Todobaad", "Bisha Sideedaad", "Bisha Sagaalaad", "Bisha Tobnaad", "Bisha Kow iyo Tobnaad", "Bisha Laba iyo Tobnaad"}, + daysAbbreviated: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysNarrow: []string{"A", "I", "T", "A", "Kh", "J", "S"}, + daysShort: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysWide: []string{"Axad", "Isniin", "Talaado", "Arbaco", "Khamiis", "Jimco", "Sabti"}, + periodsAbbreviated: []string{"sn.", "gn."}, + periodsNarrow: []string{"sn.", "gn."}, + periodsWide: []string{"sn.", "gn."}, + erasAbbreviated: []string{"CK", "CD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"CK", "CD"}, + timezones: map[string]string{"WAT": "WAT", "∅∅∅": "∅∅∅", "AKDT": "AKDT", "SAST": "SAST", "HECU": "HECU", "ECT": "ECT", "JDT": "JDT", "OEZ": "OEZ", "AWST": "AWST", "TMST": "TMST", "HKT": "HKT", "GFT": "GFT", "HNCU": "HNCU", "HAST": "HAST", "ARST": "ARST", "HKST": "HKST", "HNT": "HNT", "HEPMX": "HEPMX", "WIB": "WIB", "ART": "ART", "COT": "Waqtiyada Caadiga ah ee kolambiya", "MST": "MST", "WITA": "WITA", "HADT": "HADT", "JST": "JST", "EDT": "EDT", "HNPM": "HNPM", "EAT": "EAT", "NZDT": "NZDT", "CAT": "CAT", "VET": "VET", "ACST": "ACST", "BT": "BT", "HEPM": "HEPM", "AWDT": "AWDT", "MEZ": "MEZ", "MYT": "MYT", "CLST": "CLST", "EST": "EST", "HNEG": "HNEG", "UYST": "UYST", "HNPMX": "HNPMX", "CHADT": "CHADT", "IST": "IST", "AST": "AST", "HEEG": "HEEG", "AEST": "AEST", "LHDT": "LHDT", "GYT": "GYT", "CHAST": "CHAST", "PST": "PST", "ACWST": "ACWST", "WAST": "WAST", "COST": "Waqtiyada Xagaaga Kolambiya", "UYT": "UYT", "SGT": "SGT", "HNOG": "HNOG", "CLT": "CLT", "AKST": "AKST", "SRT": "SRT", "LHST": "LHST", "CDT": "CDT", "MESZ": "MESZ", "GMT": "GMT", "WARST": "WARST", "TMT": "TMT", "MDT": "MDT", "BOT": "BOT", "ACDT": "ACDT", "ACWDT": "ACWDT", "HEOG": "HEOG", "WESZ": "WESZ", "AEDT": "AEDT", "PDT": "PDT", "NZST": "NZST", "OESZ": "OESZ", "ChST": "ChST", "CST": "CST", "WART": "WART", "HAT": "HAT", "WIT": "WIT", "ADT": "ADT", "WEZ": "WEZ", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX"}, + } +} + +// Locale returns the current translators string locale +func (so *so_ET) Locale() string { + return so.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'so_ET' +func (so *so_ET) PluralsCardinal() []locales.PluralRule { + return so.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'so_ET' +func (so *so_ET) PluralsOrdinal() []locales.PluralRule { + return so.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'so_ET' +func (so *so_ET) PluralsRange() []locales.PluralRule { + return so.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'so_ET' +func (so *so_ET) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'so_ET' +func (so *so_ET) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'so_ET' +func (so *so_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (so *so_ET) MonthAbbreviated(month time.Month) string { + return so.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (so *so_ET) MonthsAbbreviated() []string { + return so.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (so *so_ET) MonthNarrow(month time.Month) string { + return so.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (so *so_ET) MonthsNarrow() []string { + return so.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (so *so_ET) MonthWide(month time.Month) string { + return so.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (so *so_ET) MonthsWide() []string { + return so.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (so *so_ET) WeekdayAbbreviated(weekday time.Weekday) string { + return so.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (so *so_ET) WeekdaysAbbreviated() []string { + return so.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (so *so_ET) WeekdayNarrow(weekday time.Weekday) string { + return so.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (so *so_ET) WeekdaysNarrow() []string { + return so.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (so *so_ET) WeekdayShort(weekday time.Weekday) string { + return so.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (so *so_ET) WeekdaysShort() []string { + return so.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (so *so_ET) WeekdayWide(weekday time.Weekday) string { + return so.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (so *so_ET) WeekdaysWide() []string { + return so.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'so_ET' and handles both Whole and Real numbers based on 'v' +func (so *so_ET) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'so_ET' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (so *so_ET) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'so_ET' +func (so *so_ET) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, so.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'so_ET' +// in accounting notation. +func (so *so_ET) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, so.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'so_ET' +func (so *so_ET) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'so_ET' +func (so *so_ET) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, so.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'so_ET' +func (so *so_ET) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'so_ET' +func (so *so_ET) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, so.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'so_ET' +func (so *so_ET) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'so_ET' +func (so *so_ET) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'so_ET' +func (so *so_ET) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'so_ET' +func (so *so_ET) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := so.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/so_ET/so_ET_test.go b/vendor/github.com/go-playground/locales/so_ET/so_ET_test.go new file mode 100644 index 0000000000..4c26b30927 --- /dev/null +++ b/vendor/github.com/go-playground/locales/so_ET/so_ET_test.go @@ -0,0 +1,1120 @@ +package so_ET + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "so_ET" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/so_KE/so_KE.go b/vendor/github.com/go-playground/locales/so_KE/so_KE.go new file mode 100644 index 0000000000..c408a203b6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/so_KE/so_KE.go @@ -0,0 +1,534 @@ +package so_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type so_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'so_KE' locale +func New() locales.Translator { + return &so_KE{ + locale: "so_KE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Kob", "Lab", "Sad", "Afr", "Sha", "Lix", "Tod", "Sid", "Sag", "Tob", "KIT", "LIT"}, + monthsNarrow: []string{"", "K", "L", "S", "A", "S", "L", "T", "S", "S", "T", "K", "L"}, + monthsWide: []string{"", "Bisha Koobaad", "Bisha Labaad", "Bisha Saddexaad", "Bisha Afraad", "Bisha Shanaad", "Bisha Lixaad", "Bisha Todobaad", "Bisha Sideedaad", "Bisha Sagaalaad", "Bisha Tobnaad", "Bisha Kow iyo Tobnaad", "Bisha Laba iyo Tobnaad"}, + daysAbbreviated: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysNarrow: []string{"A", "I", "T", "A", "Kh", "J", "S"}, + daysShort: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysWide: []string{"Axad", "Isniin", "Talaado", "Arbaco", "Khamiis", "Jimco", "Sabti"}, + periodsAbbreviated: []string{"sn.", "gn."}, + periodsNarrow: []string{"sn.", "gn."}, + periodsWide: []string{"sn.", "gn."}, + erasAbbreviated: []string{"CK", "CD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"CK", "CD"}, + timezones: map[string]string{"WAST": "WAST", "EST": "EST", "AEDT": "AEDT", "ACWST": "ACWST", "WIB": "WIB", "PST": "PST", "ECT": "ECT", "ADT": "ADT", "WEZ": "WEZ", "COST": "Waqtiyada Xagaaga Kolambiya", "UYST": "UYST", "BOT": "BOT", "HADT": "HADT", "VET": "VET", "AST": "AST", "OEZ": "OEZ", "WITA": "WITA", "HEPM": "HEPM", "CST": "CST", "AWST": "AWST", "SGT": "SGT", "HNOG": "HNOG", "MDT": "MDT", "ART": "ART", "EDT": "EDT", "SAST": "SAST", "HNT": "HNT", "HAT": "HAT", "ACDT": "ACDT", "CAT": "CAT", "HENOMX": "HENOMX", "HEEG": "HEEG", "AWDT": "AWDT", "EAT": "EAT", "CDT": "CDT", "WIT": "WIT", "HAST": "HAST", "NZST": "NZST", "AKST": "AKST", "HNPMX": "HNPMX", "LHST": "LHST", "∅∅∅": "∅∅∅", "GYT": "GYT", "ACWDT": "ACWDT", "GMT": "GMT", "CLST": "CLST", "ChST": "ChST", "OESZ": "OESZ", "WART": "WART", "JST": "JST", "ARST": "ARST", "PDT": "PDT", "MESZ": "MESZ", "MST": "MST", "HKT": "HKT", "ACST": "ACST", "HNPM": "HNPM", "HEOG": "HEOG", "WAT": "WAT", "HKST": "HKST", "HNNOMX": "HNNOMX", "BT": "BT", "HEPMX": "HEPMX", "HECU": "HECU", "CLT": "CLT", "AKDT": "AKDT", "AEST": "AEST", "SRT": "SRT", "CHADT": "CHADT", "NZDT": "NZDT", "TMT": "TMT", "TMST": "TMST", "LHDT": "LHDT", "CHAST": "CHAST", "MEZ": "MEZ", "JDT": "JDT", "MYT": "MYT", "WARST": "WARST", "COT": "Waqtiyada Caadiga ah ee kolambiya", "UYT": "UYT", "IST": "IST", "WESZ": "WESZ", "HNEG": "HNEG", "GFT": "GFT", "HNCU": "HNCU"}, + } +} + +// Locale returns the current translators string locale +func (so *so_KE) Locale() string { + return so.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'so_KE' +func (so *so_KE) PluralsCardinal() []locales.PluralRule { + return so.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'so_KE' +func (so *so_KE) PluralsOrdinal() []locales.PluralRule { + return so.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'so_KE' +func (so *so_KE) PluralsRange() []locales.PluralRule { + return so.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'so_KE' +func (so *so_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'so_KE' +func (so *so_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'so_KE' +func (so *so_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (so *so_KE) MonthAbbreviated(month time.Month) string { + return so.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (so *so_KE) MonthsAbbreviated() []string { + return so.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (so *so_KE) MonthNarrow(month time.Month) string { + return so.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (so *so_KE) MonthsNarrow() []string { + return so.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (so *so_KE) MonthWide(month time.Month) string { + return so.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (so *so_KE) MonthsWide() []string { + return so.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (so *so_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return so.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (so *so_KE) WeekdaysAbbreviated() []string { + return so.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (so *so_KE) WeekdayNarrow(weekday time.Weekday) string { + return so.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (so *so_KE) WeekdaysNarrow() []string { + return so.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (so *so_KE) WeekdayShort(weekday time.Weekday) string { + return so.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (so *so_KE) WeekdaysShort() []string { + return so.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (so *so_KE) WeekdayWide(weekday time.Weekday) string { + return so.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (so *so_KE) WeekdaysWide() []string { + return so.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'so_KE' and handles both Whole and Real numbers based on 'v' +func (so *so_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'so_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (so *so_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'so_KE' +func (so *so_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, so.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'so_KE' +// in accounting notation. +func (so *so_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, so.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'so_KE' +func (so *so_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'so_KE' +func (so *so_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, so.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'so_KE' +func (so *so_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'so_KE' +func (so *so_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, so.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'so_KE' +func (so *so_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'so_KE' +func (so *so_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'so_KE' +func (so *so_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'so_KE' +func (so *so_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := so.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/so_KE/so_KE_test.go b/vendor/github.com/go-playground/locales/so_KE/so_KE_test.go new file mode 100644 index 0000000000..9c2c2e44a3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/so_KE/so_KE_test.go @@ -0,0 +1,1120 @@ +package so_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "so_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/so_SO/so_SO.go b/vendor/github.com/go-playground/locales/so_SO/so_SO.go new file mode 100644 index 0000000000..644fb8ec4e --- /dev/null +++ b/vendor/github.com/go-playground/locales/so_SO/so_SO.go @@ -0,0 +1,572 @@ +package so_SO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type so_SO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'so_SO' locale +func New() locales.Translator { + return &so_SO{ + locale: "so_SO", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Kob", "Lab", "Sad", "Afr", "Sha", "Lix", "Tod", "Sid", "Sag", "Tob", "KIT", "LIT"}, + monthsNarrow: []string{"", "K", "L", "S", "A", "S", "L", "T", "S", "S", "T", "K", "L"}, + monthsWide: []string{"", "Bisha Koobaad", "Bisha Labaad", "Bisha Saddexaad", "Bisha Afraad", "Bisha Shanaad", "Bisha Lixaad", "Bisha Todobaad", "Bisha Sideedaad", "Bisha Sagaalaad", "Bisha Tobnaad", "Bisha Kow iyo Tobnaad", "Bisha Laba iyo Tobnaad"}, + daysAbbreviated: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysNarrow: []string{"A", "I", "T", "A", "Kh", "J", "S"}, + daysShort: []string{"Axd", "Isn", "Tal", "Arb", "Kha", "Jim", "Sab"}, + daysWide: []string{"Axad", "Isniin", "Talaado", "Arbaco", "Khamiis", "Jimco", "Sabti"}, + periodsAbbreviated: []string{"sn.", "gn."}, + periodsNarrow: []string{"sn.", "gn."}, + periodsWide: []string{"sn.", "gn."}, + erasAbbreviated: []string{"CK", "CD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"CK", "CD"}, + timezones: map[string]string{"BOT": "BOT", "CAT": "CAT", "HNPM": "HNPM", "HNPMX": "HNPMX", "SAST": "SAST", "PST": "PST", "HAST": "HAST", "AST": "AST", "WAST": "WAST", "HNT": "HNT", "AEDT": "AEDT", "JDT": "JDT", "HEPM": "HEPM", "HEPMX": "HEPMX", "HECU": "HECU", "WIB": "WIB", "SGT": "SGT", "ECT": "ECT", "PDT": "PDT", "HKST": "HKST", "ChST": "ChST", "UYST": "UYST", "WIT": "WIT", "MESZ": "MESZ", "OESZ": "OESZ", "MST": "MST", "ART": "ART", "BT": "BT", "CDT": "CDT", "ACST": "ACST", "AKDT": "AKDT", "HNCU": "HNCU", "NZST": "NZST", "ACWDT": "ACWDT", "CLST": "CLST", "ARST": "ARST", "GFT": "GFT", "SRT": "SRT", "ACWST": "ACWST", "MEZ": "MEZ", "HNOG": "HNOG", "TMT": "TMT", "GYT": "GYT", "AKST": "AKST", "UYT": "UYT", "JST": "JST", "GMT": "GMT", "CLT": "CLT", "HKT": "HKT", "ACDT": "ACDT", "HNEG": "HNEG", "EAT": "EAT", "CHAST": "CHAST", "CHADT": "CHADT", "∅∅∅": "∅∅∅", "COT": "Waqtiyada Caadiga ah ee kolambiya", "HNNOMX": "HNNOMX", "AWST": "AWST", "VET": "VET", "WARST": "WARST", "OEZ": "OEZ", "MDT": "MDT", "LHDT": "LHDT", "AWDT": "AWDT", "WEZ": "WEZ", "WESZ": "WESZ", "WAT": "WAT", "COST": "Waqtiyada Xagaaga Kolambiya", "WITA": "WITA", "LHST": "LHST", "ADT": "ADT", "EDT": "EDT", "HENOMX": "HENOMX", "CST": "CST", "IST": "IST", "MYT": "MYT", "HADT": "HADT", "WART": "WART", "HAT": "HAT", "AEST": "AEST", "NZDT": "NZDT", "HEOG": "HEOG", "TMST": "TMST", "EST": "EST", "HEEG": "HEEG"}, + } +} + +// Locale returns the current translators string locale +func (so *so_SO) Locale() string { + return so.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'so_SO' +func (so *so_SO) PluralsCardinal() []locales.PluralRule { + return so.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'so_SO' +func (so *so_SO) PluralsOrdinal() []locales.PluralRule { + return so.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'so_SO' +func (so *so_SO) PluralsRange() []locales.PluralRule { + return so.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'so_SO' +func (so *so_SO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'so_SO' +func (so *so_SO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'so_SO' +func (so *so_SO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (so *so_SO) MonthAbbreviated(month time.Month) string { + return so.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (so *so_SO) MonthsAbbreviated() []string { + return so.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (so *so_SO) MonthNarrow(month time.Month) string { + return so.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (so *so_SO) MonthsNarrow() []string { + return so.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (so *so_SO) MonthWide(month time.Month) string { + return so.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (so *so_SO) MonthsWide() []string { + return so.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (so *so_SO) WeekdayAbbreviated(weekday time.Weekday) string { + return so.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (so *so_SO) WeekdaysAbbreviated() []string { + return so.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (so *so_SO) WeekdayNarrow(weekday time.Weekday) string { + return so.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (so *so_SO) WeekdaysNarrow() []string { + return so.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (so *so_SO) WeekdayShort(weekday time.Weekday) string { + return so.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (so *so_SO) WeekdaysShort() []string { + return so.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (so *so_SO) WeekdayWide(weekday time.Weekday) string { + return so.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (so *so_SO) WeekdaysWide() []string { + return so.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'so_SO' and handles both Whole and Real numbers based on 'v' +func (so *so_SO) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'so_SO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (so *so_SO) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'so_SO' +func (so *so_SO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, so.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'so_SO' +// in accounting notation. +func (so *so_SO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := so.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, so.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, so.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, so.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, so.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'so_SO' +func (so *so_SO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'so_SO' +func (so *so_SO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, so.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'so_SO' +func (so *so_SO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'so_SO' +func (so *so_SO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, so.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, so.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'so_SO' +func (so *so_SO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'so_SO' +func (so *so_SO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'so_SO' +func (so *so_SO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'so_SO' +func (so *so_SO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, so.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, so.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, so.periodsAbbreviated[0]...) + } else { + b = append(b, so.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := so.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/so_SO/so_SO_test.go b/vendor/github.com/go-playground/locales/so_SO/so_SO_test.go new file mode 100644 index 0000000000..2e06e32c68 --- /dev/null +++ b/vendor/github.com/go-playground/locales/so_SO/so_SO_test.go @@ -0,0 +1,1120 @@ +package so_SO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "so_SO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sq/sq.go b/vendor/github.com/go-playground/locales/sq/sq.go new file mode 100644 index 0000000000..a816c7d864 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sq/sq.go @@ -0,0 +1,646 @@ +package sq + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sq struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sq' locale +func New() locales.Translator { + return &sq{ + locale: "sq", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "Lekë", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "$", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan", "shk", "mar", "pri", "maj", "qer", "kor", "gsh", "sht", "tet", "nën", "dhj"}, + monthsNarrow: []string{"", "j", "s", "m", "p", "m", "q", "k", "g", "s", "t", "n", "d"}, + monthsWide: []string{"", "janar", "shkurt", "mars", "prill", "maj", "qershor", "korrik", "gusht", "shtator", "tetor", "nëntor", "dhjetor"}, + daysAbbreviated: []string{"Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Sht"}, + daysNarrow: []string{"D", "H", "M", "M", "E", "P", "S"}, + daysShort: []string{"Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Sht"}, + daysWide: []string{"e diel", "e hënë", "e martë", "e mërkurë", "e enjte", "e premte", "e shtunë"}, + periodsAbbreviated: []string{"e paradites", "e pasdites"}, + periodsNarrow: []string{"e paradites", "e pasdites"}, + periodsWide: []string{"e paradites", "e pasdites"}, + erasAbbreviated: []string{"p.K.", "mb.K."}, + erasNarrow: []string{"p.K.", "mb.K."}, + erasWide: []string{"para Krishtit", "mbas Krishtit"}, + timezones: map[string]string{"HADT": "Ora verore e Ishujve Hauai-Aleutian", "HNNOMX": "Ora standarde e Meksikës Veriperëndimore", "ACST": "Ora standarde e Australisë Qendrore", "HAT": "Ora verore e Njufaundlendit [Tokës së Re]", "HEPMX": "Ora verore meksikane e Bregut të Paqësorit", "AWDT": "Ora verore e Australisë Perëndimore", "HNOG": "Ora standarde e Grenlandës Perëndimore", "HEOG": "Ora verore e Grenlandës Perëndimore", "ART": "Ora standarde e Argjentinës", "COT": "Ora standarde e Kolumbisë", "ACWST": "Ora standarde e Australisë Qendroro-Perëndimore", "CLST": "Ora verore e Kilit", "OEZ": "Ora standarde e Evropës Lindore", "TMST": "Ora verore e Turkmenistanit", "IST": "Ora standarde e Indisë", "OESZ": "Ora verore e Evropës Lindore", "AEST": "Ora standarde e Australisë Lindore", "GFT": "Ora e Guajanës Franceze", "WITA": "Ora e Indonezisë Qendrore", "NZDT": "Ora verore e Zelandës së Re", "UYT": "Ora standarde e Uruguait", "HNCU": "Ora standarde e Kubës", "HECU": "Ora verore e Kubës", "WARST": "Ora verore e Argjentinës Perëndimore", "MDT": "Ora verore e Makaos", "ARST": "Ora verore e Argjentinës", "EDT": "Ora verore e SHBA-së Lindore", "HEEG": "Ora verore e Grenlandës Lindore", "WIT": "Ora e Indonezisë Lindore", "AWST": "Ora standarde e Australisë Perëndimore", "PST": "Ora standarde amerikane e Bregut të Paqësorit", "MEZ": "Ora standarde e Evropës Qendrore", "GMT": "Ora e Meridianit të Grinuiçit", "UYST": "Ora verore e Uruguait", "MYT": "Ora e Malajzisë", "AEDT": "Ora verore e Australisë Lindore", "ChST": "Ora e Kamorros", "SRT": "Ora e Surinamit", "VET": "Ora e Venezuelës", "ACWDT": "Ora verore e Australisë Qendroro-Perëndimore", "WEZ": "Ora standarde e Evropës Perëndimore", "AST": "Ora standarde e Atlantikut", "WIB": "Ora e Indonezisë Perëndimore", "CHAST": "Ora standarde e Katamit", "HAST": "Ora standarde e Ishujve Hauai-Aleutian", "JDT": "Ora verore e Japonisë", "HKT": "Ora standarde e Hong-Kongut", "AKDT": "Ora verore e Alsaskës", "HNPMX": "Ora standarde meksikane e Bregut të Paqësorit", "LHST": "Ora standarde e Lord-Houit", "NZST": "Ora standarde e Zelandës së Re", "SGT": "Ora e Singaporit", "HENOMX": "Ora verore e Meksikës Veriperëndimore", "HNEG": "Ora standarde e Grenlandës Lindore", "HNT": "Ora standarde e Njufaundlendit [Tokës së Re]", "SAST": "Ora standarde e Afrikës Jugore", "GYT": "Ora e Guajanës", "HNPM": "Ora standarde e Shën-Pier dhe Mikuelon", "WART": "Ora standarde e Argjentinës Perëndimore", "ADT": "Ora verore e Atlantikut", "MST": "Ora standarde e Makaos", "HKST": "Ora verore e Hong-Kongut", "EST": "Ora standarde e SHBA-së Lindore", "∅∅∅": "Ora verore e Ejkrit [Ako]", "EAT": "Ora e Afrikës Lindore", "ECT": "Ora e Ekuadorit", "WESZ": "Ora verore e Evropës Perëndimore", "CLT": "Ora standarde e Kilit", "COST": "Ora verore e Kolumbisë", "AKST": "Ora standarde e Alaskës", "LHDT": "Ora verore e Lord-Houit", "JST": "Ora standarde e Japonisë", "MESZ": "Ora verore e Evropës Qendrore", "ACDT": "Ora verore e Australisë Qendrore", "BT": "Ora e Butanit", "HEPM": "Ora verore e Shën-Pier dhe Mikuelon", "CDT": "Ora verore e SHBA-së Qendrore", "PDT": "Ora verore amerikane e Bregut të Paqësorit", "CHADT": "Ora verore e Katamit", "CAT": "Ora e Afrikës Qendrore", "TMT": "Ora standarde e Turkmenistanit", "WAT": "Ora standarde e Afrikës Perëndimore", "WAST": "Ora verore e Afrikës Perëndimore", "CST": "Ora standarde e SHBA-së Qendrore", "BOT": "Ora e Bolivisë"}, + } +} + +// Locale returns the current translators string locale +func (sq *sq) Locale() string { + return sq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sq' +func (sq *sq) PluralsCardinal() []locales.PluralRule { + return sq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sq' +func (sq *sq) PluralsOrdinal() []locales.PluralRule { + return sq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sq' +func (sq *sq) PluralsRange() []locales.PluralRule { + return sq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sq' +func (sq *sq) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sq' +func (sq *sq) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if n == 1 { + return locales.PluralRuleOne + } else if nMod10 == 4 && nMod100 != 14 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sq' +func (sq *sq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sq.CardinalPluralRule(num1, v1) + end := sq.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sq *sq) MonthAbbreviated(month time.Month) string { + return sq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sq *sq) MonthsAbbreviated() []string { + return sq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sq *sq) MonthNarrow(month time.Month) string { + return sq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sq *sq) MonthsNarrow() []string { + return sq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sq *sq) MonthWide(month time.Month) string { + return sq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sq *sq) MonthsWide() []string { + return sq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sq *sq) WeekdayAbbreviated(weekday time.Weekday) string { + return sq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sq *sq) WeekdaysAbbreviated() []string { + return sq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sq *sq) WeekdayNarrow(weekday time.Weekday) string { + return sq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sq *sq) WeekdaysNarrow() []string { + return sq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sq *sq) WeekdayShort(weekday time.Weekday) string { + return sq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sq *sq) WeekdaysShort() []string { + return sq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sq *sq) WeekdayWide(weekday time.Weekday) string { + return sq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sq *sq) WeekdaysWide() []string { + return sq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sq' and handles both Whole and Real numbers based on 'v' +func (sq *sq) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sq' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sq *sq) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sq.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sq' +func (sq *sq) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sq.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sq.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sq' +// in accounting notation. +func (sq *sq) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sq.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sq.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sq.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sq.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sq' +func (sq *sq) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sq' +func (sq *sq) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sq' +func (sq *sq) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sq' +func (sq *sq) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sq' +func (sq *sq) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, sq.periodsAbbreviated[0]...) + } else { + b = append(b, sq.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sq' +func (sq *sq) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, sq.periodsAbbreviated[0]...) + } else { + b = append(b, sq.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sq' +func (sq *sq) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, sq.periodsAbbreviated[0]...) + } else { + b = append(b, sq.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x2c, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sq' +func (sq *sq) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, sq.periodsAbbreviated[0]...) + } else { + b = append(b, sq.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x2c, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sq/sq_test.go b/vendor/github.com/go-playground/locales/sq/sq_test.go new file mode 100644 index 0000000000..4f3083379d --- /dev/null +++ b/vendor/github.com/go-playground/locales/sq/sq_test.go @@ -0,0 +1,1120 @@ +package sq + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sq" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sq_AL/sq_AL.go b/vendor/github.com/go-playground/locales/sq_AL/sq_AL.go new file mode 100644 index 0000000000..1b45285074 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sq_AL/sq_AL.go @@ -0,0 +1,646 @@ +package sq_AL + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sq_AL struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sq_AL' locale +func New() locales.Translator { + return &sq_AL{ + locale: "sq_AL", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan", "shk", "mar", "pri", "maj", "qer", "kor", "gsh", "sht", "tet", "nën", "dhj"}, + monthsNarrow: []string{"", "j", "s", "m", "p", "m", "q", "k", "g", "s", "t", "n", "d"}, + monthsWide: []string{"", "janar", "shkurt", "mars", "prill", "maj", "qershor", "korrik", "gusht", "shtator", "tetor", "nëntor", "dhjetor"}, + daysAbbreviated: []string{"Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Sht"}, + daysNarrow: []string{"D", "H", "M", "M", "E", "P", "S"}, + daysShort: []string{"Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Sht"}, + daysWide: []string{"e diel", "e hënë", "e martë", "e mërkurë", "e enjte", "e premte", "e shtunë"}, + periodsAbbreviated: []string{"e paradites", "e pasdites"}, + periodsNarrow: []string{"e paradites", "e pasdites"}, + periodsWide: []string{"e paradites", "e pasdites"}, + erasAbbreviated: []string{"p.K.", "mb.K."}, + erasNarrow: []string{"p.K.", "mb.K."}, + erasWide: []string{"para Krishtit", "mbas Krishtit"}, + timezones: map[string]string{"MESZ": "Ora verore e Evropës Qendrore", "CLST": "Ora verore e Kilit", "EDT": "Ora verore e SHBA-së Lindore", "COT": "Ora standarde e Kolumbisë", "PDT": "Ora verore amerikane e Bregut të Paqësorit", "NZST": "Ora standarde e Zelandës së Re", "ADT": "Ora verore e Atlantikut", "WAT": "Ora standarde e Afrikës Perëndimore", "HNT": "Ora standarde e Njufaundlendit [Tokës së Re]", "ChST": "Ora e Kamorros", "HADT": "Ora verore e Ishujve Hauai-Aleutian", "IST": "Ora standarde e Indisë", "ACDT": "Ora verore e Australisë Qendrore", "HNNOMX": "Ora standarde e Meksikës Veriperëndimore", "CLT": "Ora standarde e Kilit", "OESZ": "Ora verore e Evropës Lindore", "JDT": "Ora verore e Japonisë", "MDT": "Ora verore e Makaos", "GMT": "Ora e Meridianit të Grinuiçit", "HNPMX": "Ora standarde meksikane e Bregut të Paqësorit", "HEPMX": "Ora verore meksikane e Bregut të Paqësorit", "BOT": "Ora e Bolivisë", "PST": "Ora standarde amerikane e Bregut të Paqësorit", "HAT": "Ora verore e Njufaundlendit [Tokës së Re]", "GFT": "Ora e Guajanës Franceze", "CST": "Ora standarde e SHBA-së Qendrore", "CAT": "Ora e Afrikës Qendrore", "WARST": "Ora verore e Argjentinës Perëndimore", "AKDT": "Ora verore e Alsaskës", "AWST": "Ora standarde e Australisë Perëndimore", "COST": "Ora verore e Kolumbisë", "OEZ": "Ora standarde e Evropës Lindore", "TMT": "Ora standarde e Turkmenistanit", "WAST": "Ora verore e Afrikës Perëndimore", "HKST": "Ora verore e Hong-Kongut", "HNPM": "Ora standarde e Shën-Pier dhe Mikuelon", "SGT": "Ora e Singaporit", "AST": "Ora standarde e Atlantikut", "NZDT": "Ora verore e Zelandës së Re", "JST": "Ora standarde e Japonisë", "WIT": "Ora e Indonezisë Lindore", "VET": "Ora e Venezuelës", "HNEG": "Ora standarde e Grenlandës Lindore", "HKT": "Ora standarde e Hong-Kongut", "ACST": "Ora standarde e Australisë Qendrore", "HEPM": "Ora verore e Shën-Pier dhe Mikuelon", "CDT": "Ora verore e SHBA-së Qendrore", "ECT": "Ora e Ekuadorit", "HNOG": "Ora standarde e Grenlandës Perëndimore", "HENOMX": "Ora verore e Meksikës Veriperëndimore", "HEEG": "Ora verore e Grenlandës Lindore", "WITA": "Ora e Indonezisë Qendrore", "AEDT": "Ora verore e Australisë Lindore", "UYT": "Ora standarde e Uruguait", "LHST": "Ora standarde e Lord-Houit", "AWDT": "Ora verore e Australisë Perëndimore", "∅∅∅": "Ora verore e Amazonës", "WESZ": "Ora verore e Evropës Perëndimore", "MST": "Ora standarde e Makaos", "ARST": "Ora verore e Argjentinës", "AKST": "Ora standarde e Alaskës", "LHDT": "Ora verore e Lord-Houit", "GYT": "Ora e Guajanës", "ACWST": "Ora standarde e Australisë Qendroro-Perëndimore", "WEZ": "Ora standarde e Evropës Perëndimore", "MYT": "Ora e Malajzisë", "TMST": "Ora verore e Turkmenistanit", "ART": "Ora standarde e Argjentinës", "UYST": "Ora verore e Uruguait", "SAST": "Ora standarde e Afrikës Jugore", "CHAST": "Ora standarde e Katamit", "MEZ": "Ora standarde e Evropës Qendrore", "SRT": "Ora e Surinamit", "EAT": "Ora e Afrikës Lindore", "HECU": "Ora verore e Kubës", "CHADT": "Ora verore e Katamit", "HAST": "Ora standarde e Ishujve Hauai-Aleutian", "HEOG": "Ora verore e Grenlandës Perëndimore", "EST": "Ora standarde e SHBA-së Lindore", "BT": "Ora e Butanit", "AEST": "Ora standarde e Australisë Lindore", "HNCU": "Ora standarde e Kubës", "WIB": "Ora e Indonezisë Perëndimore", "ACWDT": "Ora verore e Australisë Qendroro-Perëndimore", "WART": "Ora standarde e Argjentinës Perëndimore"}, + } +} + +// Locale returns the current translators string locale +func (sq *sq_AL) Locale() string { + return sq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sq_AL' +func (sq *sq_AL) PluralsCardinal() []locales.PluralRule { + return sq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sq_AL' +func (sq *sq_AL) PluralsOrdinal() []locales.PluralRule { + return sq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sq_AL' +func (sq *sq_AL) PluralsRange() []locales.PluralRule { + return sq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sq_AL' +func (sq *sq_AL) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sq_AL' +func (sq *sq_AL) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if n == 1 { + return locales.PluralRuleOne + } else if nMod10 == 4 && nMod100 != 14 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sq_AL' +func (sq *sq_AL) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sq.CardinalPluralRule(num1, v1) + end := sq.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sq *sq_AL) MonthAbbreviated(month time.Month) string { + return sq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sq *sq_AL) MonthsAbbreviated() []string { + return sq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sq *sq_AL) MonthNarrow(month time.Month) string { + return sq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sq *sq_AL) MonthsNarrow() []string { + return sq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sq *sq_AL) MonthWide(month time.Month) string { + return sq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sq *sq_AL) MonthsWide() []string { + return sq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sq *sq_AL) WeekdayAbbreviated(weekday time.Weekday) string { + return sq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sq *sq_AL) WeekdaysAbbreviated() []string { + return sq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sq *sq_AL) WeekdayNarrow(weekday time.Weekday) string { + return sq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sq *sq_AL) WeekdaysNarrow() []string { + return sq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sq *sq_AL) WeekdayShort(weekday time.Weekday) string { + return sq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sq *sq_AL) WeekdaysShort() []string { + return sq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sq *sq_AL) WeekdayWide(weekday time.Weekday) string { + return sq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sq *sq_AL) WeekdaysWide() []string { + return sq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sq_AL' and handles both Whole and Real numbers based on 'v' +func (sq *sq_AL) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sq_AL' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sq *sq_AL) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sq.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sq_AL' +func (sq *sq_AL) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sq.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sq.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sq_AL' +// in accounting notation. +func (sq *sq_AL) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sq.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sq.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sq.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sq.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sq_AL' +func (sq *sq_AL) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sq_AL' +func (sq *sq_AL) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sq_AL' +func (sq *sq_AL) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sq_AL' +func (sq *sq_AL) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sq_AL' +func (sq *sq_AL) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, sq.periodsAbbreviated[0]...) + } else { + b = append(b, sq.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sq_AL' +func (sq *sq_AL) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, sq.periodsAbbreviated[0]...) + } else { + b = append(b, sq.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sq_AL' +func (sq *sq_AL) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, sq.periodsAbbreviated[0]...) + } else { + b = append(b, sq.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x2c, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sq_AL' +func (sq *sq_AL) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, sq.periodsAbbreviated[0]...) + } else { + b = append(b, sq.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x2c, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sq_AL/sq_AL_test.go b/vendor/github.com/go-playground/locales/sq_AL/sq_AL_test.go new file mode 100644 index 0000000000..7bcfcd5f65 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sq_AL/sq_AL_test.go @@ -0,0 +1,1120 @@ +package sq_AL + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sq_AL" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sq_MK/sq_MK.go b/vendor/github.com/go-playground/locales/sq_MK/sq_MK.go new file mode 100644 index 0000000000..f369726c8d --- /dev/null +++ b/vendor/github.com/go-playground/locales/sq_MK/sq_MK.go @@ -0,0 +1,608 @@ +package sq_MK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sq_MK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sq_MK' locale +func New() locales.Translator { + return &sq_MK{ + locale: "sq_MK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "den", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan", "shk", "mar", "pri", "maj", "qer", "kor", "gsh", "sht", "tet", "nën", "dhj"}, + monthsNarrow: []string{"", "j", "s", "m", "p", "m", "q", "k", "g", "s", "t", "n", "d"}, + monthsWide: []string{"", "janar", "shkurt", "mars", "prill", "maj", "qershor", "korrik", "gusht", "shtator", "tetor", "nëntor", "dhjetor"}, + daysAbbreviated: []string{"Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Sht"}, + daysNarrow: []string{"D", "H", "M", "M", "E", "P", "S"}, + daysShort: []string{"Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Sht"}, + daysWide: []string{"e diel", "e hënë", "e martë", "e mërkurë", "e enjte", "e premte", "e shtunë"}, + periodsAbbreviated: []string{"e paradites", "e pasdites"}, + periodsNarrow: []string{"e paradites", "e pasdites"}, + periodsWide: []string{"e paradites", "e pasdites"}, + erasAbbreviated: []string{"p.K.", "mb.K."}, + erasNarrow: []string{"p.K.", "mb.K."}, + erasWide: []string{"para Krishtit", "mbas Krishtit"}, + timezones: map[string]string{"MDT": "Ora verore amerikane e Brezit Malor", "HNOG": "Ora standarde e Grenlandës Perëndimore", "IST": "Ora standarde e Indisë", "ACWDT": "Ora verore e Australisë Qendroro-Perëndimore", "HNNOMX": "Ora standarde e Meksikës Veriperëndimore", "MST": "Ora standarde amerikane e Brezit Malor", "UYST": "Ora verore e Uruguait", "ADT": "Ora verore e Atlantikut", "SRT": "Ora e Surinamit", "MEZ": "Ora standarde e Evropës Qendrore", "WART": "Ora standarde e Argjentinës Perëndimore", "AKST": "Ora standarde e Alaskës", "CAT": "Ora e Afrikës Qendrore", "WESZ": "Ora verore e Evropës Perëndimore", "CLST": "Ora verore e Kilit", "AST": "Ora standarde e Atlantikut", "ACST": "Ora standarde e Australisë Qendrore", "HEEG": "Ora verore e Grenlandës Lindore", "WITA": "Ora e Indonezisë Qendrore", "EDT": "Ora verore e SHBA-së Lindore", "EAT": "Ora e Afrikës Lindore", "OESZ": "Ora verore e Evropës Lindore", "WARST": "Ora verore e Argjentinës Perëndimore", "WAST": "Ora verore e Afrikës Perëndimore", "GFT": "Ora e Guajanës Franceze", "HEPM": "Ora verore e Shën-Pier dhe Mikuelon", "HECU": "Ora verore e Kubës", "MYT": "Ora e Malajzisë", "WAT": "Ora standarde e Afrikës Perëndimore", "ACDT": "Ora verore e Australisë Qendrore", "CHADT": "Ora verore e Katamit", "HADT": "Ora verore e Ishujve Hauai-Aleutian", "JDT": "Ora verore e Japonisë", "HENOMX": "Ora verore e Meksikës Veriperëndimore", "HNPM": "Ora standarde e Shën-Pier dhe Mikuelon", "HNPMX": "Ora standarde meksikane e Bregut të Paqësorit", "∅∅∅": "Ora verore e Ejkrit [Ako]", "LHST": "Ora standarde e Lord-Houit", "CLT": "Ora standarde e Kilit", "HEOG": "Ora verore e Grenlandës Perëndimore", "TMST": "Ora verore e Turkmenistanit", "SGT": "Ora e Singaporit", "OEZ": "Ora standarde e Evropës Lindore", "TMT": "Ora standarde e Turkmenistanit", "ARST": "Ora verore e Argjentinës", "HKST": "Ora verore e Hong-Kongut", "AEDT": "Ora verore e Australisë Lindore", "UYT": "Ora standarde e Uruguait", "HEPMX": "Ora verore meksikane e Bregut të Paqësorit", "GYT": "Ora e Guajanës", "CHAST": "Ora standarde e Katamit", "AWST": "Ora standarde e Australisë Perëndimore", "AWDT": "Ora verore e Australisë Perëndimore", "JST": "Ora standarde e Japonisë", "GMT": "Ora e Meridianit të Grinuiçit", "ChST": "Ora e Kamorros", "CST": "Ora standarde e SHBA-së Qendrore", "CDT": "Ora verore e SHBA-së Qendrore", "HNCU": "Ora standarde e Kubës", "BOT": "Ora e Bolivisë", "ACWST": "Ora standarde e Australisë Qendroro-Perëndimore", "NZST": "Ora standarde e Zelandës së Re", "WEZ": "Ora standarde e Evropës Perëndimore", "COT": "Ora standarde e Kolumbisë", "COST": "Ora verore e Kolumbisë", "HAT": "Ora verore e Njufaundlendit [Tokës së Re]", "HKT": "Ora standarde e Hong-Kongut", "EST": "Ora standarde e SHBA-së Lindore", "PST": "Ora standarde amerikane e Bregut të Paqësorit", "PDT": "Ora verore amerikane e Bregut të Paqësorit", "MESZ": "Ora verore e Evropës Qendrore", "HAST": "Ora standarde e Ishujve Hauai-Aleutian", "NZDT": "Ora verore e Zelandës së Re", "HNEG": "Ora standarde e Grenlandës Lindore", "AEST": "Ora standarde e Australisë Lindore", "SAST": "Ora standarde e Afrikës Jugore", "LHDT": "Ora verore e Lord-Houit", "WIB": "Ora e Indonezisë Perëndimore", "WIT": "Ora e Indonezisë Lindore", "ECT": "Ora e Ekuadorit", "VET": "Ora e Venezuelës", "HNT": "Ora standarde e Njufaundlendit [Tokës së Re]", "BT": "Ora e Butanit", "AKDT": "Ora verore e Alsaskës", "ART": "Ora standarde e Argjentinës"}, + } +} + +// Locale returns the current translators string locale +func (sq *sq_MK) Locale() string { + return sq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sq_MK' +func (sq *sq_MK) PluralsCardinal() []locales.PluralRule { + return sq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sq_MK' +func (sq *sq_MK) PluralsOrdinal() []locales.PluralRule { + return sq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sq_MK' +func (sq *sq_MK) PluralsRange() []locales.PluralRule { + return sq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sq_MK' +func (sq *sq_MK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sq_MK' +func (sq *sq_MK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if n == 1 { + return locales.PluralRuleOne + } else if nMod10 == 4 && nMod100 != 14 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sq_MK' +func (sq *sq_MK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sq.CardinalPluralRule(num1, v1) + end := sq.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sq *sq_MK) MonthAbbreviated(month time.Month) string { + return sq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sq *sq_MK) MonthsAbbreviated() []string { + return sq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sq *sq_MK) MonthNarrow(month time.Month) string { + return sq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sq *sq_MK) MonthsNarrow() []string { + return sq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sq *sq_MK) MonthWide(month time.Month) string { + return sq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sq *sq_MK) MonthsWide() []string { + return sq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sq *sq_MK) WeekdayAbbreviated(weekday time.Weekday) string { + return sq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sq *sq_MK) WeekdaysAbbreviated() []string { + return sq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sq *sq_MK) WeekdayNarrow(weekday time.Weekday) string { + return sq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sq *sq_MK) WeekdaysNarrow() []string { + return sq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sq *sq_MK) WeekdayShort(weekday time.Weekday) string { + return sq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sq *sq_MK) WeekdaysShort() []string { + return sq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sq *sq_MK) WeekdayWide(weekday time.Weekday) string { + return sq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sq *sq_MK) WeekdaysWide() []string { + return sq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sq_MK' and handles both Whole and Real numbers based on 'v' +func (sq *sq_MK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sq_MK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sq *sq_MK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sq.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sq_MK' +func (sq *sq_MK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sq.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sq.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sq_MK' +// in accounting notation. +func (sq *sq_MK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sq.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sq.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sq.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sq.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sq_MK' +func (sq *sq_MK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sq_MK' +func (sq *sq_MK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sq_MK' +func (sq *sq_MK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sq_MK' +func (sq *sq_MK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sq_MK' +func (sq *sq_MK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sq_MK' +func (sq *sq_MK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sq_MK' +func (sq *sq_MK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sq_MK' +func (sq *sq_MK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sq_MK/sq_MK_test.go b/vendor/github.com/go-playground/locales/sq_MK/sq_MK_test.go new file mode 100644 index 0000000000..9da8172d46 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sq_MK/sq_MK_test.go @@ -0,0 +1,1120 @@ +package sq_MK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sq_MK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sq_XK/sq_XK.go b/vendor/github.com/go-playground/locales/sq_XK/sq_XK.go new file mode 100644 index 0000000000..72f8ab8d77 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sq_XK/sq_XK.go @@ -0,0 +1,608 @@ +package sq_XK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sq_XK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sq_XK' locale +func New() locales.Translator { + return &sq_XK{ + locale: "sq_XK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 5, 6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan", "shk", "mar", "pri", "maj", "qer", "kor", "gsh", "sht", "tet", "nën", "dhj"}, + monthsNarrow: []string{"", "j", "s", "m", "p", "m", "q", "k", "g", "s", "t", "n", "d"}, + monthsWide: []string{"", "janar", "shkurt", "mars", "prill", "maj", "qershor", "korrik", "gusht", "shtator", "tetor", "nëntor", "dhjetor"}, + daysAbbreviated: []string{"Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Sht"}, + daysNarrow: []string{"D", "H", "M", "M", "E", "P", "S"}, + daysShort: []string{"Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Sht"}, + daysWide: []string{"e diel", "e hënë", "e martë", "e mërkurë", "e enjte", "e premte", "e shtunë"}, + periodsAbbreviated: []string{"e paradites", "e pasdites"}, + periodsNarrow: []string{"e paradites", "e pasdites"}, + periodsWide: []string{"e paradites", "e pasdites"}, + erasAbbreviated: []string{"p.K.", "mb.K."}, + erasNarrow: []string{"p.K.", "mb.K."}, + erasWide: []string{"para Krishtit", "mbas Krishtit"}, + timezones: map[string]string{"WARST": "Ora verore e Argjentinës Perëndimore", "HNOG": "Ora standarde e Grenlandës Perëndimore", "HNT": "Ora standarde e Njufaundlendit [Tokës së Re]", "AEDT": "Ora verore e Australisë Lindore", "HNCU": "Ora standarde e Kubës", "GMT": "Ora e Meridianit të Grinuiçit", "WESZ": "Ora verore e Evropës Perëndimore", "TMT": "Ora standarde e Turkmenistanit", "HKT": "Ora standarde e Hong-Kongut", "BT": "Ora e Butanit", "SGT": "Ora e Singaporit", "CHAST": "Ora standarde e Katamit", "BOT": "Ora e Bolivisë", "ECT": "Ora e Ekuadorit", "CAT": "Ora e Afrikës Qendrore", "IST": "Ora standarde e Indisë", "VET": "Ora e Venezuelës", "WART": "Ora standarde e Argjentinës Perëndimore", "HECU": "Ora verore e Kubës", "AKST": "Ora standarde e Alaskës", "WITA": "Ora e Indonezisë Qendrore", "AKDT": "Ora verore e Alsaskës", "AEST": "Ora standarde e Australisë Lindore", "CLT": "Ora standarde e Kilit", "WAT": "Ora standarde e Afrikës Perëndimore", "GFT": "Ora e Guajanës Franceze", "CHADT": "Ora verore e Katamit", "HNNOMX": "Ora standarde e Meksikës Veriperëndimore", "COT": "Ora standarde e Kolumbisë", "EAT": "Ora e Afrikës Lindore", "AWDT": "Ora verore e Australisë Perëndimore", "JST": "Ora standarde e Japonisë", "OEZ": "Ora standarde e Evropës Lindore", "MST": "Ora standarde e Makaos", "ACST": "Ora standarde e Australisë Qendrore", "HENOMX": "Ora verore e Meksikës Veriperëndimore", "HEPMX": "Ora verore meksikane e Bregut të Paqësorit", "WIB": "Ora e Indonezisë Perëndimore", "AWST": "Ora standarde e Australisë Perëndimore", "PST": "Ora standarde amerikane e Bregut të Paqësorit", "MESZ": "Ora verore e Evropës Qendrore", "EDT": "Ora verore e SHBA-së Lindore", "LHST": "Ora standarde e Lord-Houit", "MDT": "Ora verore e Makaos", "ARST": "Ora verore e Argjentinës", "HAT": "Ora verore e Njufaundlendit [Tokës së Re]", "HEPM": "Ora verore e Shën-Pier dhe Mikuelon", "JDT": "Ora verore e Japonisë", "AST": "Ora standarde e Atlantikut", "NZDT": "Ora verore e Zelandës së Re", "HEOG": "Ora verore e Grenlandës Perëndimore", "COST": "Ora verore e Kolumbisë", "CLST": "Ora verore e Kilit", "CDT": "Ora verore e SHBA-së Qendrore", "ACWDT": "Ora verore e Australisë Qendroro-Perëndimore", "ChST": "Ora e Kamorros", "HNPMX": "Ora standarde meksikane e Bregut të Paqësorit", "LHDT": "Ora verore e Lord-Houit", "GYT": "Ora e Guajanës", "WIT": "Ora e Indonezisë Lindore", "PDT": "Ora verore amerikane e Bregut të Paqësorit", "HAST": "Ora standarde e Ishujve Hauai-Aleutian", "HADT": "Ora verore e Ishujve Hauai-Aleutian", "OESZ": "Ora verore e Evropës Lindore", "SAST": "Ora standarde e Afrikës Jugore", "UYST": "Ora verore e Uruguait", "∅∅∅": "Ora verore e Azoreve", "CST": "Ora standarde e SHBA-së Qendrore", "NZST": "Ora standarde e Zelandës së Re", "MEZ": "Ora standarde e Evropës Qendrore", "MYT": "Ora e Malajzisë", "WAST": "Ora verore e Afrikës Perëndimore", "HNEG": "Ora standarde e Grenlandës Lindore", "SRT": "Ora e Surinamit", "UYT": "Ora standarde e Uruguait", "WEZ": "Ora standarde e Evropës Perëndimore", "ART": "Ora standarde e Argjentinës", "ACWST": "Ora standarde e Australisë Qendroro-Perëndimore", "TMST": "Ora verore e Turkmenistanit", "EST": "Ora standarde e SHBA-së Lindore", "HKST": "Ora verore e Hong-Kongut", "ACDT": "Ora verore e Australisë Qendrore", "HEEG": "Ora verore e Grenlandës Lindore", "HNPM": "Ora standarde e Shën-Pier dhe Mikuelon", "ADT": "Ora verore e Atlantikut"}, + } +} + +// Locale returns the current translators string locale +func (sq *sq_XK) Locale() string { + return sq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sq_XK' +func (sq *sq_XK) PluralsCardinal() []locales.PluralRule { + return sq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sq_XK' +func (sq *sq_XK) PluralsOrdinal() []locales.PluralRule { + return sq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sq_XK' +func (sq *sq_XK) PluralsRange() []locales.PluralRule { + return sq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sq_XK' +func (sq *sq_XK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sq_XK' +func (sq *sq_XK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if n == 1 { + return locales.PluralRuleOne + } else if nMod10 == 4 && nMod100 != 14 { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sq_XK' +func (sq *sq_XK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sq.CardinalPluralRule(num1, v1) + end := sq.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sq *sq_XK) MonthAbbreviated(month time.Month) string { + return sq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sq *sq_XK) MonthsAbbreviated() []string { + return sq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sq *sq_XK) MonthNarrow(month time.Month) string { + return sq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sq *sq_XK) MonthsNarrow() []string { + return sq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sq *sq_XK) MonthWide(month time.Month) string { + return sq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sq *sq_XK) MonthsWide() []string { + return sq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sq *sq_XK) WeekdayAbbreviated(weekday time.Weekday) string { + return sq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sq *sq_XK) WeekdaysAbbreviated() []string { + return sq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sq *sq_XK) WeekdayNarrow(weekday time.Weekday) string { + return sq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sq *sq_XK) WeekdaysNarrow() []string { + return sq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sq *sq_XK) WeekdayShort(weekday time.Weekday) string { + return sq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sq *sq_XK) WeekdaysShort() []string { + return sq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sq *sq_XK) WeekdayWide(weekday time.Weekday) string { + return sq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sq *sq_XK) WeekdaysWide() []string { + return sq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sq_XK' and handles both Whole and Real numbers based on 'v' +func (sq *sq_XK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sq_XK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sq *sq_XK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sq.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sq_XK' +func (sq *sq_XK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sq.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sq.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sq_XK' +// in accounting notation. +func (sq *sq_XK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sq.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sq.group) - 1; j >= 0; j-- { + b = append(b, sq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sq.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sq.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sq.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sq_XK' +func (sq *sq_XK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sq_XK' +func (sq *sq_XK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sq_XK' +func (sq *sq_XK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sq_XK' +func (sq *sq_XK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sq_XK' +func (sq *sq_XK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sq_XK' +func (sq *sq_XK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sq_XK' +func (sq *sq_XK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sq_XK' +func (sq *sq_XK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sq_XK/sq_XK_test.go b/vendor/github.com/go-playground/locales/sq_XK/sq_XK_test.go new file mode 100644 index 0000000000..ef0cb6ed87 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sq_XK/sq_XK_test.go @@ -0,0 +1,1120 @@ +package sq_XK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sq_XK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr/sr.go b/vendor/github.com/go-playground/locales/sr/sr.go new file mode 100644 index 0000000000..52511c20b4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr/sr.go @@ -0,0 +1,638 @@ +package sr + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr' locale +func New() locales.Translator { + return &sr{ + locale: "sr", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "КМ", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "јан", "феб", "мар", "апр", "мај", "јун", "јул", "авг", "сеп", "окт", "нов", "дец"}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"нед", "пон", "уто", "сре", "чет", "пет", "суб"}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"недеља", "понедељак", "уторак", "среда", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"пре подне", "по подне"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"пре подне", "по подне"}, + erasAbbreviated: []string{"п. н. е.", "н. е."}, + erasNarrow: []string{"п.н.е.", "н.е."}, + erasWide: []string{"пре нове ере", "нове ере"}, + timezones: map[string]string{"GFT": "Француска Гвајана време", "HEOG": "Западни Гренланд летње рачунање времена", "ARST": "Аргентина летње рачунање времена", "NZST": "Нови Зеланд стандардно време", "ADT": "Атлантско летње рачунање времена", "EST": "Северноамеричко источно стандардно време", "ACST": "Аустралијско централно стандардно време", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "SAST": "Јужно-афричко време", "HADT": "Хавајско-алеутско летње рачунање времена", "WIT": "Источно-индонезијско време", "AWST": "Аустралијско западно стандардно време", "ECT": "Еквадор време", "NZDT": "Нови Зеланд летње рачунање времена", "HAT": "Њуфаундленд летње рачунање времена", "ChST": "Чаморо време", "UYST": "Уругвај летње рачунање времена", "GYT": "Гвајана време", "HECU": "Куба летње рачунање времена", "PDT": "Северноамеричко пацифичко летње време", "MESZ": "Средњеевропско летње рачунање времена", "JST": "Јапанско стандардно време", "AKDT": "Аљаска, летње рачунање времена", "LHDT": "Лорд Хов летње рачунање времена", "HNPMX": "Мексички Пацифик стандардно време", "ACWST": "Аустралијско централно западно стандардно време", "ART": "Аргентина стандардно време", "HKT": "Хонг Конг стандардно време", "WART": "Западна Аргентина стандардно време", "HNOG": "Западни Гренланд стандардно време", "MYT": "Малезија време", "ACDT": "Аустралијско централно летње рачунање времена", "HENOMX": "Северозападни Мексико летње рачунање времена", "CST": "Северноамеричко централно стандардно време", "CHAST": "Чатам стандардно време", "HAST": "Хавајско-алеутско стандардно време", "CDT": "Северноамеричко централно летње време", "VET": "Венецуела време", "AST": "Атлантско стандардно време", "WAST": "Западно-афричко летње рачунање времена", "EDT": "Северноамеричко источно летње време", "BT": "Бутан време", "HEEG": "Источни Гренланд летње рачунање времена", "WITA": "Централно-индонезијско време", "COT": "Колумбија стандардно време", "HNT": "Њуфаундленд стандардно време", "AEST": "Аустралијско источно стандардно време", "PST": "Северноамеричко пацифичко стандардно време", "HEPMX": "Мексички Пацифик летње рачунање времена", "EAT": "Источно-афричко време", "HKST": "Хонг Конг летње рачунање времена", "HNCU": "Куба стандардно време", "SGT": "Сингапур стандардно време", "BOT": "Боливија време", "MDT": "Северноамеричко планинско летње време", "CAT": "Централно-афричко време", "HNNOMX": "Северозападни Мексико стандардно време", "CLST": "Чиле летње рачунање времена", "WESZ": "Западноевропско летње рачунање времена", "COST": "Колумбија летње рачунање времена", "UYT": "Уругвај стандардно време", "HNPM": "Сен Пјер и Микелон стандардно време", "AWDT": "Аустралијско западно летње рачунање времена", "IST": "Индијско стандардно време", "OEZ": "Источноевропско стандардно време", "AKST": "Аљаска, стандардно време", "MST": "Северноамеричко планинско стандардно време", "LHST": "Лорд Хов стандардно време", "ACWDT": "Аустралијско централно западно летње рачунање времена", "MEZ": "Средњеевропско стандардно време", "WARST": "Западна Аргентина летње рачунање времена", "TMST": "Туркменистан летње рачунање времена", "WAT": "Западно-афричко стандардно време", "HNEG": "Источни Гренланд стандардно време", "∅∅∅": "Перу летње рачунање времена", "WIB": "Западно-индонезијско време", "TMT": "Туркменистан стандардно време", "SRT": "Суринам време", "CHADT": "Чатам летње рачунање времена", "GMT": "Средње време по Гриничу", "OESZ": "Источноевропско летње рачунање времена", "WEZ": "Западноевропско стандардно време", "AEDT": "Аустралијско источно летње рачунање времена", "JDT": "Јапанско летње рачунање времена", "CLT": "Чиле стандардно време"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr' +func (sr *sr) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr' +func (sr *sr) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr' +func (sr *sr) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr' +func (sr *sr) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod100 := f % 100 + fMod10 := f % 10 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr' +func (sr *sr) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr' +func (sr *sr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr' and handles both Whole and Real numbers based on 'v' +func (sr *sr) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr' +func (sr *sr) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr' +// in accounting notation. +func (sr *sr) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr' +func (sr *sr) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr' +func (sr *sr) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr' +func (sr *sr) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr' +func (sr *sr) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr' +func (sr *sr) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr' +func (sr *sr) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr' +func (sr *sr) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr' +func (sr *sr) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr/sr_test.go b/vendor/github.com/go-playground/locales/sr/sr_test.go new file mode 100644 index 0000000000..fcb9dfdf45 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr/sr_test.go @@ -0,0 +1,1120 @@ +package sr + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl/sr_Cyrl.go b/vendor/github.com/go-playground/locales/sr_Cyrl/sr_Cyrl.go new file mode 100644 index 0000000000..ca5e7c4440 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl/sr_Cyrl.go @@ -0,0 +1,638 @@ +package sr_Cyrl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Cyrl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Cyrl' locale +func New() locales.Translator { + return &sr_Cyrl{ + locale: "sr_Cyrl", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "јан", "феб", "мар", "апр", "мај", "јун", "јул", "авг", "сеп", "окт", "нов", "дец"}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"нед", "пон", "уто", "сре", "чет", "пет", "суб"}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"недеља", "понедељак", "уторак", "среда", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"пре подне", "по подне"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"пре подне", "по подне"}, + erasAbbreviated: []string{"п. н. е.", "н. е."}, + erasNarrow: []string{"п.н.е.", "н.е."}, + erasWide: []string{"пре нове ере", "нове ере"}, + timezones: map[string]string{"TMST": "Туркменистан летње рачунање времена", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "SRT": "Суринам време", "HECU": "Куба летње рачунање времена", "PST": "Северноамеричко пацифичко стандардно време", "WART": "Западна Аргентина стандардно време", "HNEG": "Источни Гренланд стандардно време", "SAST": "Јужно-афричко време", "LHST": "Лорд Хов стандардно време", "GYT": "Гвајана време", "PDT": "Северноамеричко пацифичко летње време", "HAT": "Њуфаундленд летње рачунање времена", "ART": "Аргентина стандардно време", "ACST": "Аустралијско централно стандардно време", "CLST": "Чиле летње рачунање времена", "OEZ": "Источноевропско стандардно време", "JST": "Јапанско стандардно време", "WARST": "Западна Аргентина летње рачунање времена", "WAST": "Западно-афричко летње рачунање времена", "BT": "Бутан време", "HEEG": "Источни Гренланд летње рачунање времена", "ChST": "Чаморо време", "HAST": "Хавајско-алеутско стандардно време", "NZDT": "Нови Зеланд летње рачунање времена", "HKST": "Хонг Конг летње рачунање времена", "AKST": "Аљаска, стандардно време", "HEOG": "Западни Гренланд летње рачунање времена", "WAT": "Западно-афричко стандардно време", "HNOG": "Западни Гренланд стандардно време", "HNNOMX": "Северозападни Мексико стандардно време", "AWDT": "Аустралијско западно летње рачунање времена", "ECT": "Еквадор време", "MEZ": "Средњеевропско стандардно време", "JDT": "Јапанско летње рачунање времена", "CLT": "Чиле стандардно време", "WESZ": "Западноевропско летње рачунање времена", "HNPM": "Сен Пјер и Микелон стандардно време", "LHDT": "Лорд Хов летње рачунање времена", "AWST": "Аустралијско западно стандардно време", "CAT": "Централно-афричко време", "HNPMX": "Мексички Пацифик стандардно време", "HNCU": "Куба стандардно време", "CDT": "Северноамеричко централно летње време", "MDT": "Макао летње рачунање времена", "UYT": "Уругвај стандардно време", "ADT": "Атлантско летње рачунање времена", "GMT": "Средње време по Гриничу", "ACDT": "Аустралијско централно летње рачунање времена", "HEPMX": "Мексички Пацифик летње рачунање времена", "CST": "Северноамеричко централно стандардно време", "SGT": "Сингапур стандардно време", "∅∅∅": "Амазон летње рачунање времена", "ACWST": "Аустралијско централно западно стандардно време", "OESZ": "Источноевропско летње рачунање времена", "HKT": "Хонг Конг стандардно време", "HENOMX": "Северозападни Мексико летње рачунање времена", "WITA": "Централно-индонезијско време", "UYST": "Уругвај летње рачунање времена", "BOT": "Боливија време", "HADT": "Хавајско-алеутско летње рачунање времена", "WIT": "Источно-индонезијско време", "WEZ": "Западноевропско стандардно време", "MYT": "Малезија време", "GFT": "Француска Гвајана време", "IST": "Индијско стандардно време", "NZST": "Нови Зеланд стандардно време", "VET": "Венецуела време", "MST": "Макао стандардно време", "COT": "Колумбија стандардно време", "COST": "Колумбија летње рачунање времена", "CHAST": "Чатам стандардно време", "CHADT": "Чатам летње рачунање времена", "HNT": "Њуфаундленд стандардно време", "AKDT": "Аљаска, летње рачунање времена", "MESZ": "Средњеевропско летње рачунање времена", "EST": "Северноамеричко источно стандардно време", "TMT": "Туркменистан стандардно време", "AEDT": "Аустралијско источно летње рачунање времена", "EAT": "Источно-афричко време", "ACWDT": "Аустралијско централно западно летње рачунање времена", "AST": "Атлантско стандардно време", "WIB": "Западно-индонезијско време", "ARST": "Аргентина летње рачунање времена", "AEST": "Аустралијско источно стандардно време", "EDT": "Северноамеричко источно летње време"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Cyrl) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Cyrl' +func (sr *sr_Cyrl) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Cyrl' +func (sr *sr_Cyrl) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Cyrl' +func (sr *sr_Cyrl) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl' +func (sr *sr_Cyrl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl' +func (sr *sr_Cyrl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Cyrl' +func (sr *sr_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Cyrl) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Cyrl) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Cyrl) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Cyrl) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Cyrl) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Cyrl) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Cyrl) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Cyrl) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Cyrl) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Cyrl) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Cyrl) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Cyrl) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Cyrl) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Cyrl) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Cyrl' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Cyrl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Cyrl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Cyrl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl' +// in accounting notation. +func (sr *sr_Cyrl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Cyrl' +func (sr *sr_Cyrl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl/sr_Cyrl_test.go b/vendor/github.com/go-playground/locales/sr_Cyrl/sr_Cyrl_test.go new file mode 100644 index 0000000000..57bb8fff49 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl/sr_Cyrl_test.go @@ -0,0 +1,1120 @@ +package sr_Cyrl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Cyrl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl_BA/sr_Cyrl_BA.go b/vendor/github.com/go-playground/locales/sr_Cyrl_BA/sr_Cyrl_BA.go new file mode 100644 index 0000000000..8da97a4289 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl_BA/sr_Cyrl_BA.go @@ -0,0 +1,638 @@ +package sr_Cyrl_BA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Cyrl_BA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Cyrl_BA' locale +func New() locales.Translator { + return &sr_Cyrl_BA{ + locale: "sr_Cyrl_BA", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "јан.", "феб.", "март", "апр.", "мај", "јун", "јул", "авг.", "септ.", "окт.", "нов.", "дец."}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"нед.", "пон.", "ут.", "ср.", "чет.", "пет.", "суб."}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"недјеља", "понедељак", "уторак", "сриједа", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"прије подне", "по подне"}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"прије подне", "по подне"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"прије нове ере", "нове ере"}, + timezones: map[string]string{"PDT": "Северноамеричко пацифичко летње време", "ARST": "Аргентина летње рачунање времена", "EAT": "Источно-афричко време", "AST": "Атлантско стандардно време", "AEDT": "Аустралијско источно летње рачунање времена", "SRT": "Суринам време", "CHADT": "Чатам летње рачунање времена", "CAT": "Централно-афричко време", "MEZ": "Средњеевропско стандардно време", "HEOG": "Западни Гренланд летње рачунање времена", "AWST": "Аустралијско западно стандардно време", "ACWST": "Аустралијско централно западно стандардно време", "NZST": "Нови Зеланд стандардно време", "CLT": "Чиле стандардно време", "LHST": "Лорд Хов стандардно време", "WIT": "Источно-индонезијско време", "OEZ": "Источноевропско стандардно време", "WART": "Западна Аргентина стандардно време", "CHAST": "Чатам стандардно време", "HKT": "Хонг Конг стандардно време", "CST": "Северноамеричко централно стандардно време", "ACWDT": "Аустралијско централно западно летње рачунање времена", "JST": "Јапанско стандардно време", "HENOMX": "Северозападни Мексико летње рачунање времена", "ACST": "Аустралијско централно стандардно време", "AKST": "Аљаска, стандардно време", "ChST": "Чаморо време", "GYT": "Гвајана време", "SGT": "Сингапур стандардно време", "OESZ": "Источноевропско летње рачунање времена", "WARST": "Западна Аргентина летње рачунање времена", "HNOG": "Западни Гренланд стандардно време", "ADT": "Атлантско летње рачунање времена", "MDT": "Макао летње рачунање времена", "EST": "Северноамеричко источно стандардно време", "COT": "Колумбија стандардно време", "ACDT": "Аустралијско централно летње рачунање времена", "NZDT": "Нови Зеланд летње рачунање времена", "JDT": "Јапанско летње рачунање времена", "AKDT": "Аљаска, летње рачунање времена", "WAST": "Западно-афричко летње рачунање времена", "HECU": "Куба летње рачунање времена", "CDT": "Северноамеричко централно летње време", "MESZ": "Средњеевропско летње рачунање времена", "WEZ": "Западноевропско стандардно време", "UYT": "Уругвај стандардно време", "BT": "Бутан време", "AEST": "Аустралијско источно стандардно време", "CLST": "Чиле летње рачунање времена", "ART": "Аргентина стандардно време", "HKST": "Хонг Конг летње рачунање времена", "HNEG": "Источни Гренланд стандардно време", "HEEG": "Источни Гренланд летње рачунање времена", "HNPM": "Сен Пјер и Микелон стандардно време", "∅∅∅": "Амазон летње рачунање времена", "VET": "Венецуела време", "ECT": "Еквадор време", "LHDT": "Лорд Хов летње рачунање времена", "HAST": "Хавајско-алеутско стандардно време", "COST": "Колумбија летње рачунање времена", "HAT": "Њуфаундленд летње рачунање времена", "HNPMX": "Мексички Пацифик стандардно време", "TMT": "Туркменистан стандардно време", "WAT": "Западно-афричко стандардно време", "SAST": "Јужно-афричко време", "HNCU": "Куба стандардно време", "HADT": "Хавајско-алеутско летње рачунање времена", "GMT": "Средње време по Гриничу", "HNNOMX": "Северозападни Мексико стандардно време", "HNT": "Њуфаундленд стандардно време", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "AWDT": "Аустралијско западно летње рачунање времена", "IST": "Индијско стандардно време", "TMST": "Туркменистан летње рачунање времена", "WESZ": "Западноевропско летње рачунање времена", "HEPMX": "Мексички Пацифик летње рачунање времена", "EDT": "Северноамеричко источно летње време", "GFT": "Француска Гвајана време", "WITA": "Централно-индонезијско време", "UYST": "Уругвај летње рачунање времена", "WIB": "Западно-индонезијско време", "BOT": "Боливија време", "MYT": "Малезија време", "MST": "Макао стандардно време", "PST": "Северноамеричко пацифичко стандардно време"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Cyrl_BA) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod100 := f % 100 + fMod10 := f % 10 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Cyrl_BA) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Cyrl_BA) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Cyrl_BA) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Cyrl_BA) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Cyrl_BA) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Cyrl_BA) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Cyrl_BA) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Cyrl_BA) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Cyrl_BA) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Cyrl_BA) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Cyrl_BA) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Cyrl_BA) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Cyrl_BA) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Cyrl_BA) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Cyrl_BA' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Cyrl_BA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Cyrl_BA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Cyrl_BA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl_BA' +// in accounting notation. +func (sr *sr_Cyrl_BA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Cyrl_BA' +func (sr *sr_Cyrl_BA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl_BA/sr_Cyrl_BA_test.go b/vendor/github.com/go-playground/locales/sr_Cyrl_BA/sr_Cyrl_BA_test.go new file mode 100644 index 0000000000..81943dd232 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl_BA/sr_Cyrl_BA_test.go @@ -0,0 +1,1120 @@ +package sr_Cyrl_BA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Cyrl_BA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl_ME/sr_Cyrl_ME.go b/vendor/github.com/go-playground/locales/sr_Cyrl_ME/sr_Cyrl_ME.go new file mode 100644 index 0000000000..873925875c --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl_ME/sr_Cyrl_ME.go @@ -0,0 +1,638 @@ +package sr_Cyrl_ME + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Cyrl_ME struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Cyrl_ME' locale +func New() locales.Translator { + return &sr_Cyrl_ME{ + locale: "sr_Cyrl_ME", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "јан.", "феб.", "март", "апр.", "мај", "јун", "јул", "авг.", "септ.", "окт.", "нов.", "дец."}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"нед.", "пон.", "ут.", "ср.", "чет.", "пет.", "суб."}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"недјеља", "понедељак", "уторак", "сриједа", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"прије подне", "по подне"}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"прије подне", "по подне"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNPM": "Сен Пјер и Микелон стандардно време", "CST": "Северноамеричко централно стандардно време", "AWST": "Аустралијско западно стандардно време", "ART": "Аргентина стандардно време", "HKT": "Хонг Конг стандардно време", "COT": "Колумбија стандардно време", "∅∅∅": "Акре летње рачунање времена", "LHDT": "Лорд Хов летње рачунање времена", "HNPMX": "Мексички Пацифик стандардно време", "WIB": "Западно-индонезијско време", "SGT": "Сингапур стандардно време", "JST": "Јапанско стандардно време", "WART": "Западна Аргентина стандардно време", "MST": "Макао стандардно време", "HKST": "Хонг Конг летње рачунање времена", "HNCU": "Куба стандардно време", "CDT": "Северноамеричко централно летње време", "CHAST": "Чатам стандардно време", "CLT": "Чиле стандардно време", "CLST": "Чиле летње рачунање времена", "COST": "Колумбија летње рачунање времена", "EAT": "Источно-афричко време", "MESZ": "Средњеевропско летње рачунање времена", "GMT": "Средње време по Гриничу", "EDT": "Северноамеричко источно летње време", "GFT": "Француска Гвајана време", "WITA": "Централно-индонезијско време", "ECT": "Еквадор време", "IST": "Индијско стандардно време", "ARST": "Аргентина летње рачунање времена", "AEDT": "Аустралијско источно летње рачунање времена", "GYT": "Гвајана време", "MEZ": "Средњеевропско стандардно време", "AKST": "Аљаска, стандардно време", "AEST": "Аустралијско источно стандардно време", "OESZ": "Источноевропско летње рачунање времена", "MYT": "Малезија време", "TMST": "Туркменистан летње рачунање времена", "EST": "Северноамеричко источно стандардно време", "LHST": "Лорд Хов стандардно време", "HADT": "Хавајско-алеутско летње рачунање времена", "ACWST": "Аустралијско централно западно стандардно време", "MDT": "Макао летње рачунање времена", "SAST": "Јужно-афричко време", "HECU": "Куба летње рачунање времена", "NZST": "Нови Зеланд стандардно време", "WARST": "Западна Аргентина летње рачунање времена", "WAST": "Западно-афричко летње рачунање времена", "ACDT": "Аустралијско централно летње рачунање времена", "HAT": "Њуфаундленд летње рачунање времена", "PDT": "Северноамеричко пацифичко летње време", "VET": "Венецуела време", "AST": "Атлантско стандардно време", "HEOG": "Западни Гренланд летње рачунање времена", "WAT": "Западно-афричко стандардно време", "ACST": "Аустралијско централно стандардно време", "ADT": "Атлантско летње рачунање времена", "UYST": "Уругвај летње рачунање времена", "SRT": "Суринам време", "WIT": "Источно-индонезијско време", "PST": "Северноамеричко пацифичко стандардно време", "JDT": "Јапанско летње рачунање времена", "OEZ": "Источноевропско стандардно време", "HNOG": "Западни Гренланд стандардно време", "HENOMX": "Северозападни Мексико летње рачунање времена", "BT": "Бутан време", "HNT": "Њуфаундленд стандардно време", "CAT": "Централно-афричко време", "WEZ": "Западноевропско стандардно време", "TMT": "Туркменистан стандардно време", "HNNOMX": "Северозападни Мексико стандардно време", "HEEG": "Источни Гренланд летње рачунање времена", "AKDT": "Аљаска, летње рачунање времена", "ChST": "Чаморо време", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "HEPMX": "Мексички Пацифик летње рачунање времена", "BOT": "Боливија време", "NZDT": "Нови Зеланд летње рачунање времена", "AWDT": "Аустралијско западно летње рачунање времена", "CHADT": "Чатам летње рачунање времена", "WESZ": "Западноевропско летње рачунање времена", "HNEG": "Источни Гренланд стандардно време", "UYT": "Уругвај стандардно време", "HAST": "Хавајско-алеутско стандардно време", "ACWDT": "Аустралијско централно западно летње рачунање времена"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Cyrl_ME) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod100 := f % 100 + fMod10 := f % 10 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Cyrl_ME) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Cyrl_ME) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Cyrl_ME) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Cyrl_ME) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Cyrl_ME) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Cyrl_ME) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Cyrl_ME) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Cyrl_ME) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Cyrl_ME) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Cyrl_ME) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Cyrl_ME) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Cyrl_ME) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Cyrl_ME) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Cyrl_ME) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Cyrl_ME' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Cyrl_ME) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Cyrl_ME' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Cyrl_ME) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl_ME' +// in accounting notation. +func (sr *sr_Cyrl_ME) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Cyrl_ME' +func (sr *sr_Cyrl_ME) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl_ME/sr_Cyrl_ME_test.go b/vendor/github.com/go-playground/locales/sr_Cyrl_ME/sr_Cyrl_ME_test.go new file mode 100644 index 0000000000..4135a25ffd --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl_ME/sr_Cyrl_ME_test.go @@ -0,0 +1,1120 @@ +package sr_Cyrl_ME + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Cyrl_ME" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl_RS/sr_Cyrl_RS.go b/vendor/github.com/go-playground/locales/sr_Cyrl_RS/sr_Cyrl_RS.go new file mode 100644 index 0000000000..4d0a357708 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl_RS/sr_Cyrl_RS.go @@ -0,0 +1,638 @@ +package sr_Cyrl_RS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Cyrl_RS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Cyrl_RS' locale +func New() locales.Translator { + return &sr_Cyrl_RS{ + locale: "sr_Cyrl_RS", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "јан", "феб", "мар", "апр", "мај", "јун", "јул", "авг", "сеп", "окт", "нов", "дец"}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"нед", "пон", "уто", "сре", "чет", "пет", "суб"}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"недеља", "понедељак", "уторак", "среда", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"пре подне", "по подне"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"пре подне", "по подне"}, + erasAbbreviated: []string{"п. н. е.", "н. е."}, + erasNarrow: []string{"п.н.е.", "н.е."}, + erasWide: []string{"пре нове ере", "нове ере"}, + timezones: map[string]string{"ART": "Аргентина стандардно време", "ACST": "Аустралијско централно стандардно време", "ChST": "Чаморо време", "HEOG": "Западни Гренланд летње рачунање времена", "ACDT": "Аустралијско централно летње рачунање времена", "HNOG": "Западни Гренланд стандардно време", "WEZ": "Западноевропско стандардно време", "HKST": "Хонг Конг летње рачунање времена", "JDT": "Јапанско летње рачунање времена", "CLT": "Чиле стандардно време", "WAT": "Западно-афричко стандардно време", "BT": "Бутан време", "AKDT": "Аљаска, летње рачунање времена", "WIB": "Западно-индонезијско време", "AST": "Атлантско стандардно време", "TMST": "Туркменистан летње рачунање времена", "HAT": "Њуфаундленд летње рачунање времена", "UYT": "Уругвај стандардно време", "MESZ": "Средњеевропско летње рачунање времена", "WART": "Западна Аргентина стандардно време", "WESZ": "Западноевропско летње рачунање времена", "HEPMX": "Мексички Пацифик летње рачунање времена", "WIT": "Источно-индонезијско време", "BOT": "Боливија време", "LHST": "Лорд Хов стандардно време", "CST": "Северноамеричко централно стандардно време", "PST": "Северноамеричко пацифичко стандардно време", "HAST": "Хавајско-алеутско стандардно време", "HADT": "Хавајско-алеутско летње рачунање времена", "WARST": "Западна Аргентина летње рачунање времена", "GMT": "Средње време по Гриничу", "HNEG": "Источни Гренланд стандардно време", "HNPMX": "Мексички Пацифик стандардно време", "NZDT": "Нови Зеланд летње рачунање времена", "CLST": "Чиле летње рачунање времена", "EST": "Северноамеричко источно стандардно време", "GFT": "Француска Гвајана време", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "SAST": "Јужно-афричко време", "CDT": "Северноамеричко централно летње време", "AWST": "Аустралијско западно стандардно време", "NZST": "Нови Зеланд стандардно време", "JST": "Јапанско стандардно време", "ADT": "Атлантско летње рачунање времена", "HNNOMX": "Северозападни Мексико стандардно време", "WITA": "Централно-индонезијско време", "∅∅∅": "Азори летње рачунање времена", "EAT": "Источно-афричко време", "HECU": "Куба летње рачунање времена", "MYT": "Малезија време", "MST": "Макао стандардно време", "ARST": "Аргентина летње рачунање времена", "EDT": "Северноамеричко источно летње време", "HEEG": "Источни Гренланд летње рачунање времена", "LHDT": "Лорд Хов летње рачунање времена", "AEST": "Аустралијско источно стандардно време", "CHADT": "Чатам летње рачунање времена", "ACWST": "Аустралијско централно западно стандардно време", "OEZ": "Источноевропско стандардно време", "TMT": "Туркменистан стандардно време", "COT": "Колумбија стандардно време", "COST": "Колумбија летње рачунање времена", "HNT": "Њуфаундленд стандардно време", "GYT": "Гвајана време", "HNPM": "Сен Пјер и Микелон стандардно време", "UYST": "Уругвај летње рачунање времена", "ACWDT": "Аустралијско централно западно летње рачунање времена", "VET": "Венецуела време", "OESZ": "Источноевропско летње рачунање времена", "MDT": "Макао летње рачунање времена", "CAT": "Централно-афричко време", "SGT": "Сингапур стандардно време", "ECT": "Еквадор време", "PDT": "Северноамеричко пацифичко летње време", "IST": "Индијско стандардно време", "WAST": "Западно-афричко летње рачунање времена", "AEDT": "Аустралијско источно летње рачунање времена", "CHAST": "Чатам стандардно време", "HENOMX": "Северозападни Мексико летње рачунање времена", "HNCU": "Куба стандардно време", "AWDT": "Аустралијско западно летње рачунање времена", "MEZ": "Средњеевропско стандардно време", "HKT": "Хонг Конг стандардно време", "AKST": "Аљаска, стандардно време", "SRT": "Суринам време"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Cyrl_RS) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + iMod10 := i % 10 + fMod100 := f % 100 + fMod10 := f % 10 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Cyrl_RS) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Cyrl_RS) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Cyrl_RS) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Cyrl_RS) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Cyrl_RS) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Cyrl_RS) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Cyrl_RS) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Cyrl_RS) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Cyrl_RS) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Cyrl_RS) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Cyrl_RS) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Cyrl_RS) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Cyrl_RS) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Cyrl_RS) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Cyrl_RS' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Cyrl_RS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Cyrl_RS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Cyrl_RS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl_RS' +// in accounting notation. +func (sr *sr_Cyrl_RS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Cyrl_RS' +func (sr *sr_Cyrl_RS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl_RS/sr_Cyrl_RS_test.go b/vendor/github.com/go-playground/locales/sr_Cyrl_RS/sr_Cyrl_RS_test.go new file mode 100644 index 0000000000..92732fe0b2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl_RS/sr_Cyrl_RS_test.go @@ -0,0 +1,1120 @@ +package sr_Cyrl_RS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Cyrl_RS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl_XK/sr_Cyrl_XK.go b/vendor/github.com/go-playground/locales/sr_Cyrl_XK/sr_Cyrl_XK.go new file mode 100644 index 0000000000..6af257885e --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl_XK/sr_Cyrl_XK.go @@ -0,0 +1,638 @@ +package sr_Cyrl_XK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Cyrl_XK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Cyrl_XK' locale +func New() locales.Translator { + return &sr_Cyrl_XK{ + locale: "sr_Cyrl_XK", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "јан.", "феб.", "март", "апр.", "мај", "јун", "јул", "авг.", "септ.", "окт.", "нов.", "дец."}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"нед.", "пон.", "ут.", "ср.", "чет.", "пет.", "суб."}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"недеља", "понедељак", "уторак", "среда", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"", ""}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"пре подне", "по подне"}, + erasAbbreviated: []string{"п. н. е.", "н. е."}, + erasNarrow: []string{"п.н.е.", "н.е."}, + erasWide: []string{"пре нове ере", "нове ере"}, + timezones: map[string]string{"HNEG": "Источни Гренланд стандардно време", "WITA": "Централно-индонезијско време", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "SRT": "Суринам време", "HAST": "Хавајско-алеутско стандардно време", "∅∅∅": "Акре летње рачунање времена", "ACWDT": "Аустралијско централно западно летње рачунање времена", "ADT": "Атлантско летње рачунање времена", "HNOG": "Западни Гренланд стандардно време", "GMT": "Средње време по Гриничу", "ARST": "Аргентина летње рачунање времена", "HNNOMX": "Северозападни Мексико стандардно време", "HEPMX": "Мексички Пацифик летње рачунање времена", "PST": "Северноамеричко пацифичко стандардно време", "NZDT": "Нови Зеланд летње рачунање времена", "CLT": "Чиле стандардно време", "HAT": "Њуфаундленд летње рачунање времена", "MDT": "Северноамеричко планинско летње време", "LHDT": "Лорд Хов летње рачунање времена", "IST": "Индијско стандардно време", "JST": "Јапанско стандардно време", "AKDT": "Аљаска, летње рачунање времена", "GYT": "Гвајана време", "WEZ": "Западноевропско стандардно време", "WART": "Западна Аргентина стандардно време", "HKT": "Хонг Конг стандардно време", "ART": "Аргентина стандардно време", "HKST": "Хонг Конг летње рачунање времена", "COT": "Колумбија стандардно време", "MST": "Северноамеричко планинско стандардно време", "ChST": "Чаморо време", "HECU": "Куба летње рачунање времена", "NZST": "Нови Зеланд стандардно време", "WIT": "Источно-индонезијско време", "CHADT": "Чатам летње рачунање времена", "MYT": "Малезија време", "TMT": "Туркменистан стандардно време", "WESZ": "Западноевропско летње рачунање времена", "EDT": "Северноамеричко источно летње време", "HNPM": "Сен Пјер и Микелон стандардно време", "ECT": "Еквадор време", "ACWST": "Аустралијско централно западно стандардно време", "MEZ": "Средњеевропско стандардно време", "HEOG": "Западни Гренланд летње рачунање времена", "BT": "Бутан време", "UYT": "Уругвај стандардно време", "HNCU": "Куба стандардно време", "CLST": "Чиле летње рачунање времена", "HADT": "Хавајско-алеутско летње рачунање времена", "AEDT": "Аустралијско источно летње рачунање времена", "LHST": "Лорд Хов стандардно време", "CST": "Северноамеричко централно стандардно време", "AWDT": "Аустралијско западно летње рачунање времена", "PDT": "Северноамеричко пацифичко летње време", "HENOMX": "Северозападни Мексико летње рачунање времена", "AKST": "Аљаска, стандардно време", "UYST": "Уругвај летње рачунање времена", "VET": "Венецуела време", "EST": "Северноамеричко источно стандардно време", "COST": "Колумбија летње рачунање времена", "SAST": "Јужно-афричко време", "WIB": "Западно-индонезијско време", "CAT": "Централно-афричко време", "JDT": "Јапанско летње рачунање времена", "HEEG": "Источни Гренланд летње рачунање времена", "HNPMX": "Мексички Пацифик стандардно време", "CDT": "Северноамеричко централно летње време", "BOT": "Боливија време", "MESZ": "Средњеевропско летње рачунање времена", "ACST": "Аустралијско централно стандардно време", "HNT": "Њуфаундленд стандардно време", "AST": "Атлантско стандардно време", "OESZ": "Источноевропско летње рачунање времена", "WAST": "Западно-афричко летње рачунање времена", "ACDT": "Аустралијско централно летње рачунање времена", "EAT": "Источно-афричко време", "AWST": "Аустралијско западно стандардно време", "CHAST": "Чатам стандардно време", "OEZ": "Источноевропско стандардно време", "WAT": "Западно-афричко стандардно време", "GFT": "Француска Гвајана време", "AEST": "Аустралијско источно стандардно време", "SGT": "Сингапур стандардно време", "WARST": "Западна Аргентина летње рачунање времена", "TMST": "Туркменистан летње рачунање времена"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Cyrl_XK) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + iMod10 := i % 10 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Cyrl_XK) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Cyrl_XK) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Cyrl_XK) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Cyrl_XK) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Cyrl_XK) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Cyrl_XK) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Cyrl_XK) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Cyrl_XK) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Cyrl_XK) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Cyrl_XK) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Cyrl_XK) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Cyrl_XK) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Cyrl_XK) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Cyrl_XK) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Cyrl_XK' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Cyrl_XK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Cyrl_XK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Cyrl_XK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl_XK' +// in accounting notation. +func (sr *sr_Cyrl_XK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Cyrl_XK' +func (sr *sr_Cyrl_XK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Cyrl_XK/sr_Cyrl_XK_test.go b/vendor/github.com/go-playground/locales/sr_Cyrl_XK/sr_Cyrl_XK_test.go new file mode 100644 index 0000000000..5b26586ea4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Cyrl_XK/sr_Cyrl_XK_test.go @@ -0,0 +1,1120 @@ +package sr_Cyrl_XK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Cyrl_XK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn/sr_Latn.go b/vendor/github.com/go-playground/locales/sr_Latn/sr_Latn.go new file mode 100644 index 0000000000..f3fa3ca251 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn/sr_Latn.go @@ -0,0 +1,638 @@ +package sr_Latn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Latn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Latn' locale +func New() locales.Translator { + return &sr_Latn{ + locale: "sr_Latn", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "KM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "avg", "sep", "okt", "nov", "dec"}, + monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"}, + monthsWide: []string{"", "januar", "februar", "mart", "april", "maj", "jun", "jul", "avgust", "septembar", "oktobar", "novembar", "decembar"}, + daysAbbreviated: []string{"ned", "pon", "uto", "sre", "čet", "pet", "sub"}, + daysNarrow: []string{"n", "p", "u", "s", "č", "p", "s"}, + daysShort: []string{"ne", "po", "ut", "sr", "če", "pe", "su"}, + daysWide: []string{"nedelja", "ponedeljak", "utorak", "sreda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"pre podne", "po podne"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"pre podne", "po podne"}, + erasAbbreviated: []string{"p. n. e.", "n. e."}, + erasNarrow: []string{"p.n.e.", "n.e."}, + erasWide: []string{"pre nove ere", "nove ere"}, + timezones: map[string]string{"GYT": "Gvajana vreme", "AWDT": "Australijsko zapadno letnje računanje vremena", "MEZ": "Srednjeevropsko standardno vreme", "WITA": "Centralno-indonezijsko vreme", "AKDT": "Aljaska, letnje računanje vremena", "LHDT": "Lord Hov letnje računanje vremena", "ACWST": "Australijsko centralno zapadno standardno vreme", "OESZ": "Istočnoevropsko letnje računanje vremena", "MDT": "Severnoameričko planinsko letnje vreme", "HECU": "Kuba letnje računanje vremena", "CST": "Severnoameričko centralno standardno vreme", "HNPMX": "Meksički Pacifik standardno vreme", "SGT": "Singapur standardno vreme", "ECT": "Ekvador vreme", "IST": "Indijsko standardno vreme", "NZDT": "Novi Zeland letnje računanje vremena", "ACDT": "Australijsko centralno letnje računanje vremena", "HNEG": "Istočni Grenland standardno vreme", "LHST": "Lord Hov standardno vreme", "WESZ": "Zapadnoevropsko letnje računanje vremena", "PST": "Severnoameričko pacifičko standardno vreme", "HAST": "Havajsko-aleutsko standardno vreme", "JST": "Japansko standardno vreme", "HEOG": "Zapadni Grenland letnje računanje vremena", "ART": "Argentina standardno vreme", "HKST": "Hong Kong letnje računanje vremena", "BT": "Butan vreme", "AEDT": "Australijsko istočno letnje računanje vremena", "BOT": "Bolivija vreme", "HADT": "Havajsko-aleutsko letnje računanje vremena", "COT": "Kolumbija standardno vreme", "EAT": "Istočno-afričko vreme", "WIB": "Zapadno-indonezijsko vreme", "EST": "Severnoameričko istočno standardno vreme", "UYST": "Urugvaj letnje računanje vremena", "WARST": "Zapadna Argentina letnje računanje vremena", "AST": "Atlantsko standardno vreme", "HNT": "Njufaundlend standardno vreme", "ChST": "Čamoro vreme", "CDT": "Severnoameričko centralno letnje vreme", "CHAST": "Čatam standardno vreme", "CHADT": "Čatam letnje računanje vremena", "HKT": "Hong Kong standardno vreme", "COST": "Kolumbija letnje računanje vremena", "HNNOMX": "Severozapadni Meksiko standardno vreme", "NZST": "Novi Zeland standardno vreme", "VET": "Venecuela vreme", "∅∅∅": "Peru letnje računanje vremena", "MST": "Severnoameričko planinsko standardno vreme", "MESZ": "Srednjeevropsko letnje računanje vremena", "JDT": "Japansko letnje računanje vremena", "CLST": "Čile letnje računanje vremena", "WAST": "Zapadno-afričko letnje računanje vremena", "EDT": "Severnoameričko istočno letnje vreme", "HENOMX": "Severozapadni Meksiko letnje računanje vremena", "WIT": "Istočno-indonezijsko vreme", "WAT": "Zapadno-afričko standardno vreme", "HEEG": "Istočni Grenland letnje računanje vremena", "HNPM": "Sen Pjer i Mikelon standardno vreme", "TMST": "Turkmenistan letnje računanje vremena", "ACST": "Australijsko centralno standardno vreme", "ADT": "Atlantsko letnje računanje vremena", "WEZ": "Zapadnoevropsko standardno vreme", "MYT": "Malezija vreme", "AEST": "Australijsko istočno standardno vreme", "HNCU": "Kuba standardno vreme", "GMT": "Srednje vreme po Griniču", "ACWDT": "Australijsko centralno zapadno letnje računanje vremena", "WART": "Zapadna Argentina standardno vreme", "GFT": "Francuska Gvajana vreme", "SAST": "Južno-afričko vreme", "PDT": "Severnoameričko pacifičko letnje vreme", "OEZ": "Istočnoevropsko standardno vreme", "AKST": "Aljaska, standardno vreme", "HEPMX": "Meksički Pacifik letnje računanje vremena", "CAT": "Centralno-afričko vreme", "TMT": "Turkmenistan standardno vreme", "HAT": "Njufaundlend letnje računanje vremena", "AWST": "Australijsko zapadno standardno vreme", "CLT": "Čile standardno vreme", "HNOG": "Zapadni Grenland standardno vreme", "ARST": "Argentina letnje računanje vremena", "UYT": "Urugvaj standardno vreme", "HEPM": "Sen Pjer i Mikelon letnje računanje vremena", "SRT": "Surinam vreme"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Latn) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Latn' +func (sr *sr_Latn) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Latn' +func (sr *sr_Latn) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Latn' +func (sr *sr_Latn) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn' +func (sr *sr_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + iMod10 := i % 10 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn' +func (sr *sr_Latn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Latn' +func (sr *sr_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Latn) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Latn) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Latn) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Latn) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Latn) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Latn) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Latn) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Latn) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Latn) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Latn) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Latn) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Latn) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Latn) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Latn) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Latn' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Latn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Latn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Latn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn' +func (sr *sr_Latn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn' +// in accounting notation. +func (sr *sr_Latn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Latn' +func (sr *sr_Latn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Latn' +func (sr *sr_Latn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Latn' +func (sr *sr_Latn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Latn' +func (sr *sr_Latn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Latn' +func (sr *sr_Latn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Latn' +func (sr *sr_Latn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Latn' +func (sr *sr_Latn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Latn' +func (sr *sr_Latn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn/sr_Latn_test.go b/vendor/github.com/go-playground/locales/sr_Latn/sr_Latn_test.go new file mode 100644 index 0000000000..a72ad0520e --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn/sr_Latn_test.go @@ -0,0 +1,1120 @@ +package sr_Latn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Latn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn_BA/sr_Latn_BA.go b/vendor/github.com/go-playground/locales/sr_Latn_BA/sr_Latn_BA.go new file mode 100644 index 0000000000..195f5e5750 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn_BA/sr_Latn_BA.go @@ -0,0 +1,638 @@ +package sr_Latn_BA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Latn_BA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Latn_BA' locale +func New() locales.Translator { + return &sr_Latn_BA{ + locale: "sr_Latn_BA", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "feb.", "mart", "apr.", "maj", "jun", "jul", "avg.", "sept.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"ned.", "pon.", "ut.", "sr.", "čet.", "pet.", "sub."}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"nedjelja", "ponedeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"prije podne", "po podne"}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"prije podne", "po podne"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"prije nove ere", "nove ere"}, + timezones: map[string]string{"PDT": "Северноамеричко пацифичко летње време", "JDT": "Јапанско летње рачунање времена", "MESZ": "Средњеевропско летње рачунање времена", "COT": "Колумбија стандардно време", "HENOMX": "Северозападни Мексико летње рачунање времена", "HAT": "Њуфаундленд летње рачунање времена", "HNEG": "Источни Гренланд стандардно време", "SAST": "Јужно-афричко време", "WAST": "Западно-афричко летње рачунање времена", "∅∅∅": "Акре летње рачунање времена", "AWDT": "Аустралијско западно летње рачунање времена", "GMT": "Средње време по Гриничу", "ART": "Аргентина стандардно време", "HKST": "Хонг Конг летње рачунање времена", "CHAST": "Чатам стандардно време", "PST": "Северноамеричко пацифичко стандардно време", "WESZ": "Западноевропско летње рачунање времена", "TMT": "Туркменистан стандардно време", "CHADT": "Чатам летње рачунање времена", "MYT": "Малезија време", "HNOG": "Западни Гренланд стандардно време", "WAT": "Западно-афричко стандардно време", "HNT": "Њуфаундленд стандардно време", "HEEG": "Источни Гренланд летње рачунање времена", "WIB": "Западно-индонезијско време", "BOT": "Боливија време", "ACDT": "Аустралијско централно летње рачунање времена", "UYT": "Уругвај стандардно време", "HNPMX": "Мексички Пацифик стандардно време", "NZDT": "Нови Зеланд летње рачунање времена", "HEOG": "Западни Гренланд летње рачунање времена", "MST": "Северноамеричко планинско стандардно време", "MDT": "Северноамеричко планинско летње време", "HNCU": "Куба стандардно време", "CST": "Северноамеричко централно стандардно време", "NZST": "Нови Зеланд стандардно време", "AEST": "Аустралијско источно стандардно време", "WIT": "Источно-индонезијско време", "SGT": "Сингапур стандардно време", "CAT": "Централно-афричко време", "WART": "Западна Аргентина стандардно време", "HNNOMX": "Северозападни Мексико стандардно време", "ChST": "Чаморо време", "IST": "Индијско стандардно време", "JST": "Јапанско стандардно време", "TMST": "Туркменистан летње рачунање времена", "MEZ": "Средњеевропско стандардно време", "WARST": "Западна Аргентина летње рачунање времена", "EST": "Северноамеричко источно стандардно време", "HEPMX": "Мексички Пацифик летње рачунање времена", "GYT": "Гвајана време", "CDT": "Северноамеричко централно летње време", "ECT": "Еквадор време", "EAT": "Источно-афричко време", "HADT": "Хавајско-алеутско летње рачунање времена", "BT": "Бутан време", "AEDT": "Аустралијско источно летње рачунање времена", "UYST": "Уругвај летње рачунање времена", "HNPM": "Сен Пјер и Микелон стандардно време", "SRT": "Суринам време", "ADT": "Атлантско летње рачунање времена", "GFT": "Француска Гвајана време", "LHST": "Лорд Хов стандардно време", "AWST": "Аустралијско западно стандардно време", "OEZ": "Источноевропско стандардно време", "WEZ": "Западноевропско стандардно време", "HAST": "Хавајско-алеутско стандардно време", "ACWST": "Аустралијско централно западно стандардно време", "OESZ": "Источноевропско летње рачунање времена", "ARST": "Аргентина летње рачунање времена", "HKT": "Хонг Конг стандардно време", "COST": "Колумбија летње рачунање времена", "ACWDT": "Аустралијско централно западно летње рачунање времена", "CLST": "Чиле летње рачунање времена", "EDT": "Северноамеричко источно летње време", "ACST": "Аустралијско централно стандардно време", "AKST": "Аљаска, стандардно време", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "AST": "Атлантско стандардно време", "AKDT": "Аљаска, летње рачунање времена", "LHDT": "Лорд Хов летње рачунање времена", "VET": "Венецуела време", "CLT": "Чиле стандардно време", "WITA": "Централно-индонезијско време", "HECU": "Куба летње рачунање времена"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Latn_BA) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Latn_BA' +func (sr *sr_Latn_BA) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Latn_BA' +func (sr *sr_Latn_BA) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Latn_BA' +func (sr *sr_Latn_BA) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod100 := i % 100 + iMod10 := i % 10 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Latn_BA) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Latn_BA) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Latn_BA) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Latn_BA) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Latn_BA) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Latn_BA) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Latn_BA) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Latn_BA) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Latn_BA) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Latn_BA) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Latn_BA) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Latn_BA) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Latn_BA) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Latn_BA) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Latn_BA' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Latn_BA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Latn_BA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Latn_BA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn_BA' +// in accounting notation. +func (sr *sr_Latn_BA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Latn_BA' +func (sr *sr_Latn_BA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn_BA/sr_Latn_BA_test.go b/vendor/github.com/go-playground/locales/sr_Latn_BA/sr_Latn_BA_test.go new file mode 100644 index 0000000000..a0c906e778 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn_BA/sr_Latn_BA_test.go @@ -0,0 +1,1120 @@ +package sr_Latn_BA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Latn_BA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn_ME/sr_Latn_ME.go b/vendor/github.com/go-playground/locales/sr_Latn_ME/sr_Latn_ME.go new file mode 100644 index 0000000000..9b6e6876cb --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn_ME/sr_Latn_ME.go @@ -0,0 +1,638 @@ +package sr_Latn_ME + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Latn_ME struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Latn_ME' locale +func New() locales.Translator { + return &sr_Latn_ME{ + locale: "sr_Latn_ME", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "feb.", "mart", "apr.", "maj", "jun", "jul", "avg.", "sept.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"ned.", "pon.", "ut.", "sr.", "čet.", "pet.", "sub."}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"nedjelja", "ponedeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"}, + periodsAbbreviated: []string{"prije podne", "po podne"}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"prije podne", "po podne"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HNPM": "Сен Пјер и Микелон стандардно време", "HECU": "Куба летње рачунање времена", "CST": "Северноамеричко централно стандардно време", "HAST": "Хавајско-алеутско стандардно време", "OEZ": "Источноевропско стандардно време", "ACST": "Аустралијско централно стандардно време", "AEDT": "Аустралијско источно летње рачунање времена", "CAT": "Централно-афричко време", "MESZ": "Средњеевропско летње рачунање времена", "JST": "Јапанско стандардно време", "WAT": "Западно-афричко стандардно време", "LHDT": "Лорд Хов летње рачунање времена", "HADT": "Хавајско-алеутско летње рачунање времена", "UYT": "Уругвај стандардно време", "VET": "Венецуела време", "CLT": "Чиле стандардно време", "ARST": "Аргентина летње рачунање времена", "HNT": "Њуфаундленд стандардно време", "AWDT": "Аустралијско западно летње рачунање времена", "SGT": "Сингапур стандардно време", "ACWST": "Аустралијско централно западно стандардно време", "HEOG": "Западни Гренланд летње рачунање времена", "MDT": "Макао летње рачунање времена", "ChST": "Чаморо време", "EDT": "Северноамеричко источно летње време", "HKST": "Хонг Конг летње рачунање времена", "NZDT": "Нови Зеланд летње рачунање времена", "UYST": "Уругвај летње рачунање времена", "ADT": "Атлантско летње рачунање времена", "HENOMX": "Северозападни Мексико летње рачунање времена", "AKDT": "Аљаска, летње рачунање времена", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "HNCU": "Куба стандардно време", "TMT": "Туркменистан стандардно време", "MST": "Макао стандардно време", "GFT": "Француска Гвајана време", "SRT": "Суринам време", "AWST": "Аустралијско западно стандардно време", "MEZ": "Средњеевропско стандардно време", "HNOG": "Западни Гренланд стандардно време", "HNNOMX": "Северозападни Мексико стандардно време", "LHST": "Лорд Хов стандардно време", "AKST": "Аљаска, стандардно време", "CHADT": "Чатам летње рачунање времена", "WART": "Западна Аргентина стандардно време", "ART": "Аргентина стандардно време", "COST": "Колумбија летње рачунање времена", "WITA": "Централно-индонезијско време", "HNPMX": "Мексички Пацифик стандардно време", "WIB": "Западно-индонезијско време", "CDT": "Северноамеричко централно летње време", "IST": "Индијско стандардно време", "WESZ": "Западноевропско летње рачунање времена", "WARST": "Западна Аргентина летње рачунање времена", "∅∅∅": "Акре летње рачунање времена", "GMT": "Средње време по Гриничу", "SAST": "Јужно-афричко време", "EAT": "Источно-афричко време", "ECT": "Еквадор време", "JDT": "Јапанско летње рачунање времена", "TMST": "Туркменистан летње рачунање времена", "EST": "Северноамеричко источно стандардно време", "BT": "Бутан време", "AEST": "Аустралијско источно стандардно време", "HEPMX": "Мексички Пацифик летње рачунање времена", "WIT": "Источно-индонезијско време", "PDT": "Северноамеричко пацифичко летње време", "ACWDT": "Аустралијско централно западно летње рачунање времена", "MYT": "Малезија време", "ACDT": "Аустралијско централно летње рачунање времена", "COT": "Колумбија стандардно време", "HEEG": "Источни Гренланд летње рачунање времена", "CLST": "Чиле летње рачунање времена", "WAST": "Западно-афричко летње рачунање времена", "HNEG": "Источни Гренланд стандардно време", "HKT": "Хонг Конг стандардно време", "HAT": "Њуфаундленд летње рачунање времена", "GYT": "Гвајана време", "CHAST": "Чатам стандардно време", "BOT": "Боливија време", "AST": "Атлантско стандардно време", "OESZ": "Источноевропско летње рачунање времена", "WEZ": "Западноевропско стандардно време", "PST": "Северноамеричко пацифичко стандардно време", "NZST": "Нови Зеланд стандардно време"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Latn_ME) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Latn_ME' +func (sr *sr_Latn_ME) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Latn_ME' +func (sr *sr_Latn_ME) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Latn_ME' +func (sr *sr_Latn_ME) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod100 := f % 100 + fMod10 := f % 10 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Latn_ME) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Latn_ME) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Latn_ME) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Latn_ME) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Latn_ME) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Latn_ME) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Latn_ME) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Latn_ME) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Latn_ME) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Latn_ME) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Latn_ME) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Latn_ME) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Latn_ME) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Latn_ME) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Latn_ME' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Latn_ME) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Latn_ME' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Latn_ME) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn_ME' +// in accounting notation. +func (sr *sr_Latn_ME) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Latn_ME' +func (sr *sr_Latn_ME) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn_ME/sr_Latn_ME_test.go b/vendor/github.com/go-playground/locales/sr_Latn_ME/sr_Latn_ME_test.go new file mode 100644 index 0000000000..61fcd8ca9e --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn_ME/sr_Latn_ME_test.go @@ -0,0 +1,1120 @@ +package sr_Latn_ME + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Latn_ME" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn_RS/sr_Latn_RS.go b/vendor/github.com/go-playground/locales/sr_Latn_RS/sr_Latn_RS.go new file mode 100644 index 0000000000..7a3ba74036 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn_RS/sr_Latn_RS.go @@ -0,0 +1,638 @@ +package sr_Latn_RS + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Latn_RS struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Latn_RS' locale +func New() locales.Translator { + return &sr_Latn_RS{ + locale: "sr_Latn_RS", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "јан", "феб", "мар", "апр", "мај", "јун", "јул", "авг", "сеп", "окт", "нов", "дец"}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"нед", "пон", "уто", "сре", "чет", "пет", "суб"}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"недеља", "понедељак", "уторак", "среда", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"пре подне", "по подне"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"пре подне", "по подне"}, + erasAbbreviated: []string{"п. н. е.", "н. е."}, + erasNarrow: []string{"п.н.е.", "н.е."}, + erasWide: []string{"пре нове ере", "нове ере"}, + timezones: map[string]string{"ECT": "Еквадор време", "PST": "Северноамеричко пацифичко стандардно време", "IST": "Индијско стандардно време", "MESZ": "Средњеевропско летње рачунање времена", "COT": "Колумбија стандардно време", "AKDT": "Аљаска, летње рачунање времена", "VET": "Венецуела време", "ADT": "Атлантско летње рачунање времена", "WAT": "Западно-афричко стандардно време", "SRT": "Суринам време", "HECU": "Куба летње рачунање времена", "WIB": "Западно-индонезијско време", "ACWDT": "Аустралијско централно западно летње рачунање времена", "CLT": "Чиле стандардно време", "WAST": "Западно-афричко летње рачунање времена", "HKT": "Хонг Конг стандардно време", "COST": "Колумбија летње рачунање времена", "SAST": "Јужно-афричко време", "BOT": "Боливија време", "NZDT": "Нови Зеланд летње рачунање времена", "HNT": "Њуфаундленд стандардно време", "WITA": "Централно-индонезијско време", "LHDT": "Лорд Хов летње рачунање времена", "ACWST": "Аустралијско централно западно стандардно време", "WESZ": "Западноевропско летње рачунање времена", "GMT": "Средње време по Гриничу", "ACDT": "Аустралијско централно летње рачунање времена", "∅∅∅": "Амазон летње рачунање времена", "NZST": "Нови Зеланд стандардно време", "AST": "Атлантско стандардно време", "MST": "Макао стандардно време", "HNNOMX": "Северозападни Мексико стандардно време", "HAT": "Њуфаундленд летње рачунање времена", "HAST": "Хавајско-алеутско стандардно време", "JDT": "Јапанско летње рачунање времена", "ART": "Аргентина стандардно време", "HEEG": "Источни Гренланд летње рачунање времена", "ChST": "Чаморо време", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "HNOG": "Западни Гренланд стандардно време", "HEOG": "Западни Гренланд летње рачунање времена", "OEZ": "Источноевропско стандардно време", "EST": "Северноамеричко источно стандардно време", "WIT": "Источно-индонезијско време", "CHAST": "Чатам стандардно време", "BT": "Бутан време", "AEDT": "Аустралијско источно летње рачунање времена", "UYT": "Уругвај стандардно време", "EAT": "Источно-афричко време", "CST": "Северноамеричко централно стандардно време", "PDT": "Северноамеричко пацифичко летње време", "HADT": "Хавајско-алеутско летње рачунање времена", "MEZ": "Средњеевропско стандардно време", "MYT": "Малезија време", "WART": "Западна Аргентина стандардно време", "OESZ": "Источноевропско летње рачунање времена", "WEZ": "Западноевропско стандардно време", "TMST": "Туркменистан летње рачунање времена", "HENOMX": "Северозападни Мексико летње рачунање времена", "HNEG": "Источни Гренланд стандардно време", "UYST": "Уругвај летње рачунање времена", "HEPMX": "Мексички Пацифик летње рачунање времена", "CDT": "Северноамеричко централно летње време", "SGT": "Сингапур стандардно време", "CAT": "Централно-афричко време", "AEST": "Аустралијско источно стандардно време", "GYT": "Гвајана време", "MDT": "Макао летње рачунање времена", "EDT": "Северноамеричко источно летње време", "HNPM": "Сен Пјер и Микелон стандардно време", "AWDT": "Аустралијско западно летње рачунање времена", "JST": "Јапанско стандардно време", "TMT": "Туркменистан стандардно време", "ARST": "Аргентина летње рачунање времена", "GFT": "Француска Гвајана време", "AKST": "Аљаска, стандардно време", "WARST": "Западна Аргентина летње рачунање времена", "ACST": "Аустралијско централно стандардно време", "HNPMX": "Мексички Пацифик стандардно време", "HNCU": "Куба стандардно време", "CHADT": "Чатам летње рачунање времена", "CLST": "Чиле летње рачунање времена", "HKST": "Хонг Конг летње рачунање времена", "LHST": "Лорд Хов стандардно време", "AWST": "Аустралијско западно стандардно време"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Latn_RS) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Latn_RS' +func (sr *sr_Latn_RS) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Latn_RS' +func (sr *sr_Latn_RS) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Latn_RS' +func (sr *sr_Latn_RS) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Latn_RS) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Latn_RS) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Latn_RS) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Latn_RS) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Latn_RS) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Latn_RS) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Latn_RS) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Latn_RS) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Latn_RS) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Latn_RS) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Latn_RS) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Latn_RS) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Latn_RS) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Latn_RS) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Latn_RS' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Latn_RS) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Latn_RS' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Latn_RS) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn_RS' +// in accounting notation. +func (sr *sr_Latn_RS) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Latn_RS' +func (sr *sr_Latn_RS) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn_RS/sr_Latn_RS_test.go b/vendor/github.com/go-playground/locales/sr_Latn_RS/sr_Latn_RS_test.go new file mode 100644 index 0000000000..c854e71926 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn_RS/sr_Latn_RS_test.go @@ -0,0 +1,1120 @@ +package sr_Latn_RS + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Latn_RS" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn_XK/sr_Latn_XK.go b/vendor/github.com/go-playground/locales/sr_Latn_XK/sr_Latn_XK.go new file mode 100644 index 0000000000..b5a9035bd2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn_XK/sr_Latn_XK.go @@ -0,0 +1,638 @@ +package sr_Latn_XK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sr_Latn_XK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sr_Latn_XK' locale +func New() locales.Translator { + return &sr_Latn_XK{ + locale: "sr_Latn_XK", + pluralsCardinal: []locales.PluralRule{2, 4, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 4, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ".", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "jan.", "feb.", "mart", "apr.", "maj", "jun", "jul", "avg.", "sept.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"}, + monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"}, + daysAbbreviated: []string{"ned.", "pon.", "ut.", "sr.", "čet.", "pet.", "sub."}, + daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"}, + daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"}, + daysWide: []string{"недеља", "понедељак", "уторак", "среда", "четвртак", "петак", "субота"}, + periodsAbbreviated: []string{"", ""}, + periodsNarrow: []string{"", ""}, + periodsWide: []string{"пре подне", "по подне"}, + erasAbbreviated: []string{"п. н. е.", "н. е."}, + erasNarrow: []string{"п.н.е.", "н.е."}, + erasWide: []string{"пре нове ере", "нове ере"}, + timezones: map[string]string{"CST": "Северноамеричко централно стандардно време", "WART": "Западна Аргентина стандардно време", "AEDT": "Аустралијско источно летње рачунање времена", "HECU": "Куба летње рачунање времена", "MEZ": "Средњеевропско стандардно време", "MESZ": "Средњеевропско летње рачунање времена", "CLST": "Чиле летње рачунање времена", "OEZ": "Источноевропско стандардно време", "HKST": "Хонг Конг летње рачунање времена", "SRT": "Суринам време", "ARST": "Аргентина летње рачунање времена", "HAST": "Хавајско-алеутско стандардно време", "ACWST": "Аустралијско централно западно стандардно време", "GMT": "Средње време по Гриничу", "AST": "Атлантско стандардно време", "OESZ": "Источноевропско летње рачунање времена", "WEZ": "Западноевропско стандардно време", "IST": "Индијско стандардно време", "TMST": "Туркменистан летње рачунање времена", "WAT": "Западно-афричко стандардно време", "UYT": "Уругвај стандардно време", "CDT": "Северноамеричко централно летње време", "CHAST": "Чатам стандардно време", "BOT": "Боливија време", "AEST": "Аустралијско источно стандардно време", "HNPM": "Сен Пјер и Микелон стандардно време", "AWST": "Аустралијско западно стандардно време", "HADT": "Хавајско-алеутско летње рачунање времена", "HENOMX": "Северозападни Мексико летње рачунање времена", "HNEG": "Источни Гренланд стандардно време", "AKST": "Аљаска, стандардно време", "UYST": "Уругвај летње рачунање времена", "HNOG": "Западни Гренланд стандардно време", "HEOG": "Западни Гренланд летње рачунање времена", "TMT": "Туркменистан стандардно време", "HKT": "Хонг Конг стандардно време", "BT": "Бутан време", "HAT": "Њуфаундленд летње рачунање времена", "HNCU": "Куба стандардно време", "WIB": "Западно-индонезијско време", "∅∅∅": "Бразилија летње рачунање времена", "JDT": "Јапанско летње рачунање времена", "EST": "Северноамеричко источно стандардно време", "AKDT": "Аљаска, летње рачунање времена", "SAST": "Јужно-афричко време", "ACWDT": "Аустралијско централно западно летње рачунање времена", "COT": "Колумбија стандардно време", "LHDT": "Лорд Хов летње рачунање времена", "ChST": "Чаморо време", "EAT": "Источно-афричко време", "SGT": "Сингапур стандардно време", "CAT": "Централно-афричко време", "WARST": "Западна Аргентина летње рачунање времена", "ACDT": "Аустралијско централно летње рачунање времена", "HNNOMX": "Северозападни Мексико стандардно време", "HEEG": "Источни Гренланд летње рачунање времена", "LHST": "Лорд Хов стандардно време", "CHADT": "Чатам летње рачунање времена", "ECT": "Еквадор време", "JST": "Јапанско стандардно време", "ADT": "Атлантско летње рачунање времена", "EDT": "Северноамеричко источно летње време", "ACST": "Аустралијско централно стандардно време", "AWDT": "Аустралијско западно летње рачунање времена", "PST": "Северноамеричко пацифичко стандардно време", "PDT": "Северноамеричко пацифичко летње време", "CLT": "Чиле стандардно време", "MST": "Макао стандардно време", "WIT": "Источно-индонезијско време", "NZST": "Нови Зеланд стандардно време", "WITA": "Централно-индонезијско време", "HEPM": "Сен Пјер и Микелон летње рачунање времена", "HEPMX": "Мексички Пацифик летње рачунање времена", "NZDT": "Нови Зеланд летње рачунање времена", "MYT": "Малезија време", "HNT": "Њуфаундленд стандардно време", "VET": "Венецуела време", "MDT": "Макао летње рачунање времена", "WAST": "Западно-афричко летње рачунање времена", "COST": "Колумбија летње рачунање времена", "GFT": "Француска Гвајана време", "WESZ": "Западноевропско летње рачунање времена", "ART": "Аргентина стандардно време", "HNPMX": "Мексички Пацифик стандардно време", "GYT": "Гвајана време"}, + } +} + +// Locale returns the current translators string locale +func (sr *sr_Latn_XK) Locale() string { + return sr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Latn_XK' +func (sr *sr_Latn_XK) PluralsCardinal() []locales.PluralRule { + return sr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Latn_XK' +func (sr *sr_Latn_XK) PluralsOrdinal() []locales.PluralRule { + return sr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sr_Latn_XK' +func (sr *sr_Latn_XK) PluralsRange() []locales.PluralRule { + return sr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + f := locales.F(n, v) + iMod10 := i % 10 + iMod100 := i % 100 + fMod10 := f % 10 + fMod100 := f % 100 + + if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) { + return locales.PluralRuleOne + } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sr.CardinalPluralRule(num1, v1) + end := sr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sr *sr_Latn_XK) MonthAbbreviated(month time.Month) string { + return sr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sr *sr_Latn_XK) MonthsAbbreviated() []string { + return sr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sr *sr_Latn_XK) MonthNarrow(month time.Month) string { + return sr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sr *sr_Latn_XK) MonthsNarrow() []string { + return sr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sr *sr_Latn_XK) MonthWide(month time.Month) string { + return sr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sr *sr_Latn_XK) MonthsWide() []string { + return sr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sr *sr_Latn_XK) WeekdayAbbreviated(weekday time.Weekday) string { + return sr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sr *sr_Latn_XK) WeekdaysAbbreviated() []string { + return sr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sr *sr_Latn_XK) WeekdayNarrow(weekday time.Weekday) string { + return sr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sr *sr_Latn_XK) WeekdaysNarrow() []string { + return sr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sr *sr_Latn_XK) WeekdayShort(weekday time.Weekday) string { + return sr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sr *sr_Latn_XK) WeekdaysShort() []string { + return sr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sr *sr_Latn_XK) WeekdayWide(weekday time.Weekday) string { + return sr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sr *sr_Latn_XK) WeekdaysWide() []string { + return sr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Latn_XK' and handles both Whole and Real numbers based on 'v' +func (sr *sr_Latn_XK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Latn_XK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sr *sr_Latn_XK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sr.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sr.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Latn_XK' +// in accounting notation. +func (sr *sr_Latn_XK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sr.currencies[currency] + l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, sr.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sr.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sr.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sr.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, sr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sr_Latn_XK' +func (sr *sr_Latn_XK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sr_Latn_XK/sr_Latn_XK_test.go b/vendor/github.com/go-playground/locales/sr_Latn_XK/sr_Latn_XK_test.go new file mode 100644 index 0000000000..e0089c0893 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sr_Latn_XK/sr_Latn_XK_test.go @@ -0,0 +1,1120 @@ +package sr_Latn_XK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sr_Latn_XK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sv/sv.go b/vendor/github.com/go-playground/locales/sv/sv.go new file mode 100644 index 0000000000..5536a7bc71 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sv/sv.go @@ -0,0 +1,620 @@ +package sv + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sv struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sv' locale +func New() locales.Translator { + return &sv{ + locale: "sv", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "Bds$", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BM$", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BR$", "BRN", "BRR", "BRZ", "BS$", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZ$", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "Dkr", "RD$", "DZD", "ECS", "ECV", "Ekr", "EG£", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IE£", "ILP", "ILR", "₪", "INR", "IQD", "IRR", "ISJ", "Ikr", "ITL", "JM$", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "Nkr", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "kr", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mars", "apr.", "maj", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"sön", "mån", "tis", "ons", "tors", "fre", "lör"}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sö", "må", "ti", "on", "to", "fr", "lö"}, + daysWide: []string{"söndag", "måndag", "tisdag", "onsdag", "torsdag", "fredag", "lördag"}, + periodsAbbreviated: []string{"fm", "em"}, + periodsNarrow: []string{"fm", "em"}, + periodsWide: []string{"fm", "em"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"före Kristus", "efter Kristus"}, + timezones: map[string]string{"IST": "indisk tid", "CAT": "centralafrikansk tid", "JST": "japansk normaltid", "HAT": "Newfoundland, sommartid", "HNPMX": "mexikansk stillahavstid, normaltid", "HEPMX": "mexikansk stillahavstid, sommartid", "∅∅∅": "azorisk sommartid", "WAT": "västafrikansk normaltid", "GYT": "Guyanatid", "MEZ": "centraleuropeisk normaltid", "WESZ": "västeuropeisk sommartid", "AST": "nordamerikansk atlantnormaltid", "WIB": "västindonesisk tid", "EAT": "östafrikansk tid", "HADT": "Honolulu, sommartid", "PDT": "västnordamerikansk sommartid", "JDT": "japansk sommartid", "WART": "västargentinsk normaltid", "HEEG": "östgrönländsk sommartid", "AKDT": "Alaska, sommartid", "LHDT": "Lord Howe, sommartid", "CDT": "centralnordamerikansk sommartid", "BOT": "boliviansk tid", "HKST": "Hongkong, sommartid", "SAST": "sydafrikansk tid", "MYT": "malaysisk tid", "CLT": "chilensk normaltid", "ChST": "Chamorrotid", "HEOG": "västgrönländsk sommartid", "BT": "bhutansk tid", "TMST": "turkmensk sommartid", "EDT": "östnordamerikansk sommartid", "AEDT": "östaustralisk sommartid", "CHAST": "Chatham, normaltid", "PST": "västnordamerikansk normaltid", "HNPM": "S:t Pierre och Miquelon, normaltid", "HEPM": "S:t Pierre och Miquelon, sommartid", "CST": "centralnordamerikansk normaltid", "OEZ": "östeuropeisk normaltid", "WAST": "västafrikansk sommartid", "SRT": "Surinamtid", "SGT": "Singaporetid", "HAST": "Honolulu, normaltid", "ART": "östargentinsk normaltid", "ACDT": "centralaustralisk sommartid", "AEST": "östaustralisk normaltid", "ECT": "ecuadoriansk tid", "MESZ": "centraleuropeisk sommartid", "WEZ": "västeuropeisk normaltid", "HNOG": "västgrönländsk normaltid", "TMT": "turkmensk normaltid", "MST": "Macaunormaltid", "HKT": "Hongkong, normaltid", "HENOMX": "nordvästmexikansk sommartid", "ACWDT": "västcentralaustralisk sommartid", "VET": "venezuelansk tid", "CLST": "chilensk sommartid", "GFT": "Franska Guyanatid", "WITA": "centralindonesisk tid", "CHADT": "Chatham, sommartid", "COT": "colombiansk normaltid", "COST": "colombiansk sommartid", "HNNOMX": "nordvästmexikansk normaltid", "UYST": "uruguayansk sommartid", "AWDT": "västaustralisk sommartid", "ACWST": "västcentralaustralisk normaltid", "HNT": "Newfoundland, normaltid", "AKST": "Alaska, normaltid", "LHST": "Lord Howe, normaltid", "HNCU": "kubansk normaltid", "EST": "östnordamerikansk normaltid", "GMT": "Greenwichtid", "WARST": "västargentinsk sommartid", "HNEG": "östgrönländsk normaltid", "UYT": "uruguayansk normaltid", "WIT": "östindonesisk tid", "NZDT": "nyzeeländsk sommartid", "OESZ": "östeuropeisk sommartid", "ADT": "nordamerikansk atlantsommartid", "ARST": "östargentinsk sommartid", "MDT": "Macausommartid", "ACST": "centralaustralisk normaltid", "HECU": "kubansk sommartid", "AWST": "västaustralisk normaltid", "NZST": "nyzeeländsk normaltid"}, + } +} + +// Locale returns the current translators string locale +func (sv *sv) Locale() string { + return sv.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sv' +func (sv *sv) PluralsCardinal() []locales.PluralRule { + return sv.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sv' +func (sv *sv) PluralsOrdinal() []locales.PluralRule { + return sv.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sv' +func (sv *sv) PluralsRange() []locales.PluralRule { + return sv.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sv' +func (sv *sv) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sv' +func (sv *sv) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if (nMod10 == 1 || nMod10 == 2) && (nMod100 != 11 && nMod100 != 12) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sv' +func (sv *sv) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sv *sv) MonthAbbreviated(month time.Month) string { + return sv.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sv *sv) MonthsAbbreviated() []string { + return sv.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sv *sv) MonthNarrow(month time.Month) string { + return sv.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sv *sv) MonthsNarrow() []string { + return sv.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sv *sv) MonthWide(month time.Month) string { + return sv.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sv *sv) MonthsWide() []string { + return sv.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sv *sv) WeekdayAbbreviated(weekday time.Weekday) string { + return sv.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sv *sv) WeekdaysAbbreviated() []string { + return sv.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sv *sv) WeekdayNarrow(weekday time.Weekday) string { + return sv.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sv *sv) WeekdaysNarrow() []string { + return sv.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sv *sv) WeekdayShort(weekday time.Weekday) string { + return sv.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sv *sv) WeekdaysShort() []string { + return sv.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sv *sv) WeekdayWide(weekday time.Weekday) string { + return sv.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sv *sv) WeekdaysWide() []string { + return sv.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sv' and handles both Whole and Real numbers based on 'v' +func (sv *sv) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sv' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sv *sv) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sv.percentSuffix...) + + b = append(b, sv.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sv' +func (sv *sv) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sv.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sv.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sv' +// in accounting notation. +func (sv *sv) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sv.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sv.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sv.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sv' +func (sv *sv) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sv' +func (sv *sv) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sv' +func (sv *sv) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sv' +func (sv *sv) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sv.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sv' +func (sv *sv) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sv' +func (sv *sv) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sv' +func (sv *sv) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sv' +func (sv *sv) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x6b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sv.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sv/sv_test.go b/vendor/github.com/go-playground/locales/sv/sv_test.go new file mode 100644 index 0000000000..7df10cfb1f --- /dev/null +++ b/vendor/github.com/go-playground/locales/sv/sv_test.go @@ -0,0 +1,1120 @@ +package sv + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sv" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sv_AX/sv_AX.go b/vendor/github.com/go-playground/locales/sv_AX/sv_AX.go new file mode 100644 index 0000000000..af30ebc42d --- /dev/null +++ b/vendor/github.com/go-playground/locales/sv_AX/sv_AX.go @@ -0,0 +1,620 @@ +package sv_AX + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sv_AX struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sv_AX' locale +func New() locales.Translator { + return &sv_AX{ + locale: "sv_AX", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mars", "apr.", "maj", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"sön", "mån", "tis", "ons", "tors", "fre", "lör"}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sö", "må", "ti", "on", "to", "fr", "lö"}, + daysWide: []string{"söndag", "måndag", "tisdag", "onsdag", "torsdag", "fredag", "lördag"}, + periodsAbbreviated: []string{"fm", "em"}, + periodsNarrow: []string{"fm", "em"}, + periodsWide: []string{"fm", "em"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"före Kristus", "efter Kristus"}, + timezones: map[string]string{"HEOG": "västgrönländsk sommartid", "ACST": "centralaustralisk normaltid", "COT": "colombiansk normaltid", "COST": "colombiansk sommartid", "HENOMX": "nordvästmexikansk sommartid", "GYT": "Guyanatid", "CHAST": "Chatham, normaltid", "BOT": "boliviansk tid", "EDT": "östnordamerikansk sommartid", "HKST": "Hongkong, sommartid", "HNPMX": "mexikansk stillahavstid, normaltid", "HEPMX": "mexikansk stillahavstid, sommartid", "SGT": "Singaporetid", "NZST": "nyzeeländsk normaltid", "WESZ": "västeuropeisk sommartid", "HAST": "Honolulu, normaltid", "HNT": "Newfoundland, normaltid", "AEDT": "östaustralisk sommartid", "ChST": "Chamorrotid", "HECU": "kubansk sommartid", "AWDT": "västaustralisk sommartid", "CHADT": "Chatham, sommartid", "PST": "västnordamerikansk normaltid", "JST": "japansk normaltid", "TMST": "turkmensk sommartid", "UYST": "uruguayansk sommartid", "LHDT": "Lord Howe, sommartid", "AST": "nordamerikansk atlantnormaltid", "CLST": "chilensk sommartid", "BT": "bhutansk tid", "IST": "indisk tid", "HNOG": "västgrönländsk normaltid", "HAT": "Newfoundland, sommartid", "ACWDT": "västcentralaustralisk sommartid", "HNNOMX": "nordvästmexikansk normaltid", "∅∅∅": "västbrasiliansk sommartid", "UYT": "uruguayansk normaltid", "SAST": "sydafrikansk tid", "WART": "västargentinsk normaltid", "WARST": "västargentinsk sommartid", "WEZ": "västeuropeisk normaltid", "ART": "östargentinsk normaltid", "WAST": "västafrikansk sommartid", "EST": "östnordamerikansk normaltid", "WITA": "centralindonesisk tid", "HNPM": "S:t Pierre och Miquelon, normaltid", "LHST": "Lord Howe, normaltid", "ACWST": "västcentralaustralisk normaltid", "MDT": "Macausommartid", "AKDT": "Alaska, sommartid", "HNCU": "kubansk normaltid", "HADT": "Honolulu, sommartid", "OESZ": "östeuropeisk sommartid", "VET": "venezuelansk tid", "HNEG": "östgrönländsk normaltid", "HEEG": "östgrönländsk sommartid", "AKST": "Alaska, normaltid", "GFT": "Franska Guyanatid", "EAT": "östafrikansk tid", "CDT": "centralnordamerikansk sommartid", "MEZ": "centraleuropeisk normaltid", "OEZ": "östeuropeisk normaltid", "AEST": "östaustralisk normaltid", "HEPM": "S:t Pierre och Miquelon, sommartid", "PDT": "västnordamerikansk sommartid", "GMT": "Greenwichtid", "MYT": "malaysisk tid", "WAT": "västafrikansk normaltid", "HKT": "Hongkong, normaltid", "CST": "centralnordamerikansk normaltid", "ECT": "ecuadoriansk tid", "CLT": "chilensk normaltid", "ACDT": "centralaustralisk sommartid", "MST": "Macaunormaltid", "SRT": "Surinamtid", "WIB": "västindonesisk tid", "WIT": "östindonesisk tid", "AWST": "västaustralisk normaltid", "ADT": "nordamerikansk atlantsommartid", "ARST": "östargentinsk sommartid", "CAT": "centralafrikansk tid", "NZDT": "nyzeeländsk sommartid", "MESZ": "centraleuropeisk sommartid", "TMT": "turkmensk normaltid", "JDT": "japansk sommartid"}, + } +} + +// Locale returns the current translators string locale +func (sv *sv_AX) Locale() string { + return sv.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sv_AX' +func (sv *sv_AX) PluralsCardinal() []locales.PluralRule { + return sv.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sv_AX' +func (sv *sv_AX) PluralsOrdinal() []locales.PluralRule { + return sv.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sv_AX' +func (sv *sv_AX) PluralsRange() []locales.PluralRule { + return sv.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sv_AX' +func (sv *sv_AX) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sv_AX' +func (sv *sv_AX) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if (nMod10 == 1 || nMod10 == 2) && (nMod100 != 11 && nMod100 != 12) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sv_AX' +func (sv *sv_AX) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sv *sv_AX) MonthAbbreviated(month time.Month) string { + return sv.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sv *sv_AX) MonthsAbbreviated() []string { + return sv.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sv *sv_AX) MonthNarrow(month time.Month) string { + return sv.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sv *sv_AX) MonthsNarrow() []string { + return sv.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sv *sv_AX) MonthWide(month time.Month) string { + return sv.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sv *sv_AX) MonthsWide() []string { + return sv.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sv *sv_AX) WeekdayAbbreviated(weekday time.Weekday) string { + return sv.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sv *sv_AX) WeekdaysAbbreviated() []string { + return sv.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sv *sv_AX) WeekdayNarrow(weekday time.Weekday) string { + return sv.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sv *sv_AX) WeekdaysNarrow() []string { + return sv.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sv *sv_AX) WeekdayShort(weekday time.Weekday) string { + return sv.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sv *sv_AX) WeekdaysShort() []string { + return sv.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sv *sv_AX) WeekdayWide(weekday time.Weekday) string { + return sv.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sv *sv_AX) WeekdaysWide() []string { + return sv.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sv_AX' and handles both Whole and Real numbers based on 'v' +func (sv *sv_AX) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sv_AX' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sv *sv_AX) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sv.percentSuffix...) + + b = append(b, sv.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sv_AX' +func (sv *sv_AX) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sv.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sv.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sv_AX' +// in accounting notation. +func (sv *sv_AX) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sv.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sv.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sv.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sv_AX' +func (sv *sv_AX) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sv_AX' +func (sv *sv_AX) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sv_AX' +func (sv *sv_AX) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sv_AX' +func (sv *sv_AX) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sv.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sv_AX' +func (sv *sv_AX) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sv_AX' +func (sv *sv_AX) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sv_AX' +func (sv *sv_AX) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sv_AX' +func (sv *sv_AX) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x6b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sv.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sv_AX/sv_AX_test.go b/vendor/github.com/go-playground/locales/sv_AX/sv_AX_test.go new file mode 100644 index 0000000000..f7bc010dfb --- /dev/null +++ b/vendor/github.com/go-playground/locales/sv_AX/sv_AX_test.go @@ -0,0 +1,1120 @@ +package sv_AX + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sv_AX" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sv_FI/sv_FI.go b/vendor/github.com/go-playground/locales/sv_FI/sv_FI.go new file mode 100644 index 0000000000..78c3166e1b --- /dev/null +++ b/vendor/github.com/go-playground/locales/sv_FI/sv_FI.go @@ -0,0 +1,619 @@ +package sv_FI + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sv_FI struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sv_FI' locale +func New() locales.Translator { + return &sv_FI{ + locale: "sv_FI", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mars", "apr.", "maj", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"sön", "mån", "tis", "ons", "tors", "fre", "lör"}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sö", "må", "ti", "on", "to", "fr", "lö"}, + daysWide: []string{"söndag", "måndag", "tisdag", "onsdag", "torsdag", "fredag", "lördag"}, + periodsAbbreviated: []string{"fm", "em"}, + periodsNarrow: []string{"fm", "em"}, + periodsWide: []string{"fm", "em"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"före Kristus", "efter Kristus"}, + timezones: map[string]string{"CHADT": "Chatham, sommartid", "BOT": "boliviansk tid", "TMT": "turkmensk normaltid", "TMST": "turkmensk sommartid", "HENOMX": "nordvästmexikansk sommartid", "AKST": "Alaska, normaltid", "AEST": "östaustralisk normaltid", "ECT": "ecuadoriansk tid", "∅∅∅": "Amazonas, sommartid", "ACWDT": "västcentralaustralisk sommartid", "MESZ": "centraleuropeisk sommartid", "WITA": "centralindonesisk tid", "COST": "colombiansk sommartid", "UYT": "uruguayansk normaltid", "CAT": "centralafrikansk tid", "JST": "japansk normaltid", "JDT": "japansk sommartid", "WEZ": "västeuropeisk normaltid", "ARST": "östargentinsk sommartid", "WAT": "västafrikansk normaltid", "HNPMX": "mexikansk stillahavstid, normaltid", "HEPMX": "mexikansk stillahavstid, sommartid", "WART": "västargentinsk normaltid", "HEOG": "västgrönländsk sommartid", "ADT": "nordamerikansk atlantsommartid", "ART": "östargentinsk normaltid", "PDT": "västnordamerikansk sommartid", "OEZ": "östeuropeisk normaltid", "MYT": "malaysisk tid", "HNEG": "östgrönländsk normaltid", "HEPM": "S:t Pierre och Miquelon, sommartid", "BT": "bhutansk tid", "HECU": "kubansk sommartid", "WIT": "östindonesisk tid", "CDT": "centralnordamerikansk sommartid", "HNNOMX": "nordvästmexikansk normaltid", "UYST": "uruguayansk sommartid", "LHST": "Lord Howe, normaltid", "EAT": "östafrikansk tid", "NZST": "nyzeeländsk normaltid", "ACDT": "centralaustralisk sommartid", "HNT": "Newfoundland, normaltid", "HNPM": "S:t Pierre och Miquelon, normaltid", "HKT": "Hongkong, normaltid", "HEEG": "östgrönländsk sommartid", "GYT": "Guyanatid", "PST": "västnordamerikansk normaltid", "ACWST": "västcentralaustralisk normaltid", "CLT": "chilensk normaltid", "CLST": "chilensk sommartid", "AST": "nordamerikansk atlantnormaltid", "HAST": "Honolulu, normaltid", "MST": "Macaunormaltid", "WAST": "västafrikansk sommartid", "LHDT": "Lord Howe, sommartid", "AWDT": "västaustralisk sommartid", "GFT": "Franska Guyanatid", "SGT": "Singaporetid", "VET": "venezuelansk tid", "MDT": "Macausommartid", "EDT": "östnordamerikansk sommartid", "ACST": "centralaustralisk normaltid", "WIB": "västindonesisk tid", "CHAST": "Chatham, normaltid", "HADT": "Honolulu, sommartid", "WARST": "västargentinsk sommartid", "OESZ": "östeuropeisk sommartid", "COT": "colombiansk normaltid", "AEDT": "östaustralisk sommartid", "EST": "östnordamerikansk normaltid", "ChST": "Chamorrotid", "SRT": "Surinamtid", "HNCU": "kubansk normaltid", "WESZ": "västeuropeisk sommartid", "HKST": "Hongkong, sommartid", "AKDT": "Alaska, sommartid", "SAST": "sydafrikansk tid", "CST": "centralnordamerikansk normaltid", "IST": "indisk tid", "NZDT": "nyzeeländsk sommartid", "HNOG": "västgrönländsk normaltid", "HAT": "Newfoundland, sommartid", "MEZ": "centraleuropeisk normaltid", "GMT": "Greenwichtid", "AWST": "västaustralisk normaltid"}, + } +} + +// Locale returns the current translators string locale +func (sv *sv_FI) Locale() string { + return sv.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sv_FI' +func (sv *sv_FI) PluralsCardinal() []locales.PluralRule { + return sv.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sv_FI' +func (sv *sv_FI) PluralsOrdinal() []locales.PluralRule { + return sv.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sv_FI' +func (sv *sv_FI) PluralsRange() []locales.PluralRule { + return sv.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sv_FI' +func (sv *sv_FI) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sv_FI' +func (sv *sv_FI) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if (nMod10 == 1 || nMod10 == 2) && (nMod100 != 11 && nMod100 != 12) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sv_FI' +func (sv *sv_FI) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sv *sv_FI) MonthAbbreviated(month time.Month) string { + return sv.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sv *sv_FI) MonthsAbbreviated() []string { + return sv.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sv *sv_FI) MonthNarrow(month time.Month) string { + return sv.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sv *sv_FI) MonthsNarrow() []string { + return sv.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sv *sv_FI) MonthWide(month time.Month) string { + return sv.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sv *sv_FI) MonthsWide() []string { + return sv.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sv *sv_FI) WeekdayAbbreviated(weekday time.Weekday) string { + return sv.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sv *sv_FI) WeekdaysAbbreviated() []string { + return sv.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sv *sv_FI) WeekdayNarrow(weekday time.Weekday) string { + return sv.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sv *sv_FI) WeekdaysNarrow() []string { + return sv.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sv *sv_FI) WeekdayShort(weekday time.Weekday) string { + return sv.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sv *sv_FI) WeekdaysShort() []string { + return sv.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sv *sv_FI) WeekdayWide(weekday time.Weekday) string { + return sv.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sv *sv_FI) WeekdaysWide() []string { + return sv.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sv_FI' and handles both Whole and Real numbers based on 'v' +func (sv *sv_FI) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sv_FI' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sv *sv_FI) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sv.percentSuffix...) + + b = append(b, sv.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sv_FI' +func (sv *sv_FI) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sv.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sv.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sv_FI' +// in accounting notation. +func (sv *sv_FI) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sv.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sv.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sv.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sv_FI' +func (sv *sv_FI) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sv_FI' +func (sv *sv_FI) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sv_FI' +func (sv *sv_FI) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sv_FI' +func (sv *sv_FI) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sv.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sv_FI' +func (sv *sv_FI) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sv_FI' +func (sv *sv_FI) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sv_FI' +func (sv *sv_FI) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sv_FI' +func (sv *sv_FI) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x6b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sv.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sv_FI/sv_FI_test.go b/vendor/github.com/go-playground/locales/sv_FI/sv_FI_test.go new file mode 100644 index 0000000000..1db6a36401 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sv_FI/sv_FI_test.go @@ -0,0 +1,1120 @@ +package sv_FI + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sv_FI" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sv_SE/sv_SE.go b/vendor/github.com/go-playground/locales/sv_SE/sv_SE.go new file mode 100644 index 0000000000..0d86eda491 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sv_SE/sv_SE.go @@ -0,0 +1,620 @@ +package sv_SE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sv_SE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sv_SE' locale +func New() locales.Translator { + return &sv_SE{ + locale: "sv_SE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: " ", + minus: "−", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "jan.", "feb.", "mars", "apr.", "maj", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "dec."}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december"}, + daysAbbreviated: []string{"sön", "mån", "tis", "ons", "tors", "fre", "lör"}, + daysNarrow: []string{"S", "M", "T", "O", "T", "F", "L"}, + daysShort: []string{"sö", "må", "ti", "on", "to", "fr", "lö"}, + daysWide: []string{"söndag", "måndag", "tisdag", "onsdag", "torsdag", "fredag", "lördag"}, + periodsAbbreviated: []string{"fm", "em"}, + periodsNarrow: []string{"fm", "em"}, + periodsWide: []string{"fm", "em"}, + erasAbbreviated: []string{"f.Kr.", "e.Kr."}, + erasNarrow: []string{"f.Kr.", "e.Kr."}, + erasWide: []string{"före Kristus", "efter Kristus"}, + timezones: map[string]string{"EAT": "östafrikansk tid", "COST": "colombiansk sommartid", "HAT": "Newfoundland, sommartid", "LHST": "Lord Howe, normaltid", "LHDT": "Lord Howe, sommartid", "HNPMX": "mexikansk stillahavstid, normaltid", "HAST": "Honolulu, normaltid", "WESZ": "västeuropeisk sommartid", "CLST": "chilensk sommartid", "HNEG": "östgrönländsk normaltid", "AEST": "östaustralisk normaltid", "ChST": "Chamorrotid", "HECU": "kubansk sommartid", "ADT": "nordamerikansk atlantsommartid", "HNT": "Newfoundland, normaltid", "UYT": "uruguayansk normaltid", "SAST": "sydafrikansk tid", "GYT": "Guyanatid", "JST": "japansk normaltid", "COT": "colombiansk normaltid", "NZDT": "nyzeeländsk sommartid", "WAT": "västafrikansk normaltid", "WIB": "västindonesisk tid", "HADT": "Honolulu, sommartid", "WARST": "västargentinsk sommartid", "WAST": "västafrikansk sommartid", "AWST": "västaustralisk normaltid", "CHAST": "Chatham, normaltid", "NZST": "nyzeeländsk normaltid", "VET": "venezuelansk tid", "OEZ": "östeuropeisk normaltid", "HNPM": "S:t Pierre och Miquelon, normaltid", "HKST": "Hongkong, sommartid", "AWDT": "västaustralisk sommartid", "SGT": "Singaporetid", "PST": "västnordamerikansk normaltid", "CAT": "centralafrikansk tid", "GMT": "Greenwichtid", "CLT": "chilensk normaltid", "MEZ": "centraleuropeisk normaltid", "ACDT": "centralaustralisk sommartid", "HEEG": "östgrönländsk sommartid", "AEDT": "östaustralisk sommartid", "GFT": "Franska Guyanatid", "CDT": "centralnordamerikansk sommartid", "WIT": "östindonesisk tid", "ECT": "ecuadoriansk tid", "HNOG": "västgrönländsk normaltid", "MST": "Macaunormaltid", "HKT": "Hongkong, normaltid", "WITA": "centralindonesisk tid", "WART": "västargentinsk normaltid", "EDT": "östnordamerikansk sommartid", "∅∅∅": "Brasilia, sommartid", "CHADT": "Chatham, sommartid", "BOT": "boliviansk tid", "IST": "indisk tid", "JDT": "japansk sommartid", "MYT": "malaysisk tid", "HNNOMX": "nordvästmexikansk normaltid", "ACWST": "västcentralaustralisk normaltid", "AST": "nordamerikansk atlantnormaltid", "ACST": "centralaustralisk normaltid", "CST": "centralnordamerikansk normaltid", "PDT": "västnordamerikansk sommartid", "MDT": "Macausommartid", "ART": "östargentinsk normaltid", "BT": "bhutansk tid", "UYST": "uruguayansk sommartid", "HEPMX": "mexikansk stillahavstid, sommartid", "HNCU": "kubansk normaltid", "OESZ": "östeuropeisk sommartid", "WEZ": "västeuropeisk normaltid", "TMST": "turkmensk sommartid", "EST": "östnordamerikansk normaltid", "AKST": "Alaska, normaltid", "ACWDT": "västcentralaustralisk sommartid", "ARST": "östargentinsk sommartid", "SRT": "Surinamtid", "MESZ": "centraleuropeisk sommartid", "HEOG": "västgrönländsk sommartid", "TMT": "turkmensk normaltid", "HENOMX": "nordvästmexikansk sommartid", "AKDT": "Alaska, sommartid", "HEPM": "S:t Pierre och Miquelon, sommartid"}, + } +} + +// Locale returns the current translators string locale +func (sv *sv_SE) Locale() string { + return sv.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sv_SE' +func (sv *sv_SE) PluralsCardinal() []locales.PluralRule { + return sv.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sv_SE' +func (sv *sv_SE) PluralsOrdinal() []locales.PluralRule { + return sv.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sv_SE' +func (sv *sv_SE) PluralsRange() []locales.PluralRule { + return sv.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sv_SE' +func (sv *sv_SE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sv_SE' +func (sv *sv_SE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if (nMod10 == 1 || nMod10 == 2) && (nMod100 != 11 && nMod100 != 12) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sv_SE' +func (sv *sv_SE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sv *sv_SE) MonthAbbreviated(month time.Month) string { + return sv.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sv *sv_SE) MonthsAbbreviated() []string { + return sv.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sv *sv_SE) MonthNarrow(month time.Month) string { + return sv.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sv *sv_SE) MonthsNarrow() []string { + return sv.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sv *sv_SE) MonthWide(month time.Month) string { + return sv.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sv *sv_SE) MonthsWide() []string { + return sv.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sv *sv_SE) WeekdayAbbreviated(weekday time.Weekday) string { + return sv.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sv *sv_SE) WeekdaysAbbreviated() []string { + return sv.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sv *sv_SE) WeekdayNarrow(weekday time.Weekday) string { + return sv.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sv *sv_SE) WeekdaysNarrow() []string { + return sv.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sv *sv_SE) WeekdayShort(weekday time.Weekday) string { + return sv.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sv *sv_SE) WeekdaysShort() []string { + return sv.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sv *sv_SE) WeekdayWide(weekday time.Weekday) string { + return sv.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sv *sv_SE) WeekdaysWide() []string { + return sv.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sv_SE' and handles both Whole and Real numbers based on 'v' +func (sv *sv_SE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sv_SE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sv *sv_SE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 7 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sv.percentSuffix...) + + b = append(b, sv.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sv_SE' +func (sv *sv_SE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sv.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, sv.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sv_SE' +// in accounting notation. +func (sv *sv_SE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sv.currencies[currency] + l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sv.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(sv.group) - 1; j >= 0; j-- { + b = append(b, sv.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(sv.minus) - 1; j >= 0; j-- { + b = append(b, sv.minus[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sv.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sv.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, sv.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sv_SE' +func (sv *sv_SE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sv_SE' +func (sv *sv_SE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sv_SE' +func (sv *sv_SE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sv_SE' +func (sv *sv_SE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sv.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sv.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sv_SE' +func (sv *sv_SE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sv_SE' +func (sv *sv_SE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sv_SE' +func (sv *sv_SE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sv_SE' +func (sv *sv_SE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, []byte{0x6b, 0x6c}...) + b = append(b, []byte{0x2e, 0x20}...) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sv.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sv.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sv.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sv_SE/sv_SE_test.go b/vendor/github.com/go-playground/locales/sv_SE/sv_SE_test.go new file mode 100644 index 0000000000..7a2bcf53e3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sv_SE/sv_SE_test.go @@ -0,0 +1,1120 @@ +package sv_SE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sv_SE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sw/sw.go b/vendor/github.com/go-playground/locales/sw/sw.go new file mode 100644 index 0000000000..a6b49c51d7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw/sw.go @@ -0,0 +1,605 @@ +package sw + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sw struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sw' locale +func New() locales.Translator { + return &sw{ + locale: "sw", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TSh", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysWide: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"Asubuhi", "Mchana"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristo", "Baada ya Kristo"}, + timezones: map[string]string{"MST": "Saa za Wastani za Mountain", "ChST": "Saa Wastani za Chamorro", "WEZ": "Saa Wastani za Magharibi mwa Ulaya", "HAT": "Saa za Mchana za Newfoundland", "UYT": "Saa za Wastani za Uruguay", "HADT": "Saa za Mchana za Hawaii-Aleutian", "ACWDT": "Saa za Mchana za Magharibi ya Kati ya Australia", "CLST": "Saa za Majira ya joto za Chile", "WART": "Saa Wastani za Magharibi mwa Argentina", "TMT": "Saa za Wastani za Turkmenistan", "HNNOMX": "Saa Wastani za Mexico Kaskazini Magharibi", "LHST": "Saa Wastani za Lord Howe", "HEPMX": "Saa za mchana za pasifiki za Mexico", "WIT": "Saa za Mashariki mwa Indonesia", "ACWST": "Saa Wastani za Magharibi ya Kati ya Australia", "AEST": "Saa Wastani za Mashariki mwa Australia", "HKT": "Saa Wastani za Hong Kong", "MEZ": "Saa Wastani za Ulaya ya kati", "VET": "Saa za Venezuela", "TMST": "Saa za Majira ya joto za Turkmenistan", "ARST": "Saa za Majira ya joto za Argentina", "COT": "Saa za Wastani za Colombia", "GFT": "Saa za Guiana ya Ufaransa", "UYST": "Saa za Majira ya joto za Uruguay", "NZST": "Saa Wastani za New Zealand", "JST": "Saa Wastani za Japan", "EST": "Saa za Wastani za Mashariki", "HENOMX": "Saa za mchana za Mexico Kaskazini Magharibi", "WITA": "Saa za Indonesia ya Kati", "AKST": "Saa za Wastani za Alaska", "HNPM": "Saa za Wastani ya Saint-Pierre na Miquelon", "CHAST": "Saa Wastani za Chatham", "WAST": "Saa za Majira ya joto za Afrika Magharibi", "HNEG": "Saa za Wastani za Greenland Mashariki", "GYT": "Saa za Guyana", "HNCU": "Saa za Wastani ya Cuba", "WARST": "Saa za Majira ya joto za Magharibi mwa Argentina", "OESZ": "Saa za Majira ya joto za Mashariki mwa Ulaya", "HAST": "Saa za Wastani za Hawaii-Aleutian", "CLT": "Saa za Wastani za Chile", "HNOG": "Saa za Wastani za Greenland Magharibi", "ACDT": "Saa za Mchana za Australia ya Kati", "LHDT": "Saa za Mchana za Lord Howe", "HNPMX": "Saa za wastani za pasifiki za Mexico", "AWDT": "Saa za Mchana za Australia Magharibi", "CHADT": "Saa za Mchana za Chatham", "ADT": "Saa za Mchana za Atlantiki", "MYT": "Saa za Malaysia", "AKDT": "Saa za Mchana za Alaska", "WAT": "Saa za Wastani za Afrika Magharibi", "HNT": "Saa za Wastani za Newfoundland", "∅∅∅": "Saa za Majira ya joto za Peru", "CAT": "Saa za Afrika ya Kati", "MESZ": "Saa za Majira ya joto za Ulaya ya Kati", "EDT": "Saa za Mchana za Mashariki", "PDT": "Saa za Mchana za Pasifiki", "HEEG": "Saa za Majira ya joto za Greenland Mashariki", "WIB": "Saa za Magharibi mwa Indonesia", "CDT": "Saa za Mchana za Kati", "SGT": "Saa Wastani za Singapore", "ECT": "Saa za Ecuador", "AEDT": "Saa za Mchana za Mashariki mwa Australia", "EAT": "Saa za Afrika Mashariki", "AST": "Saa za Wastani za Atlantiki", "JDT": "Saa za Mchana za Japan", "BT": "Saa za Bhutan", "MDT": "Saa za Mchana za Mountain", "HEPM": "Saa za Mchana za Saint-Pierre na Miquelon", "PST": "Saa za Wastani za Pasifiki", "IST": "Saa Wastani za India", "COST": "Saa za Majira ya joto za Colombia", "CST": "Saa za Wastani za Kati", "AWST": "Saa Wastani za Australia Magharibi", "WESZ": "Saa za Majira ya joto za Magharibi mwa Ulaya", "HKST": "Saa za Majira ya joto za Hong Kong", "NZDT": "Saa za Mchana za New Zealand", "HEOG": "Saa za Majira ya joto za Greenland Magharibi", "OEZ": "Saa Wastani za Mashariki mwa Ulaya", "ACST": "Saa Wastani za Australia ya Kati", "SAST": "Saa Wastani za Afrika Kusini", "SRT": "Saa za Suriname", "HECU": "Saa za Mchana za Cuba", "BOT": "Saa za Bolivia", "GMT": "Saa za Greenwich", "ART": "Saa za Wastani za Argentina"}, + } +} + +// Locale returns the current translators string locale +func (sw *sw) Locale() string { + return sw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sw' +func (sw *sw) PluralsCardinal() []locales.PluralRule { + return sw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sw' +func (sw *sw) PluralsOrdinal() []locales.PluralRule { + return sw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sw' +func (sw *sw) PluralsRange() []locales.PluralRule { + return sw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sw' +func (sw *sw) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sw' +func (sw *sw) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sw' +func (sw *sw) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sw.CardinalPluralRule(num1, v1) + end := sw.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sw *sw) MonthAbbreviated(month time.Month) string { + return sw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sw *sw) MonthsAbbreviated() []string { + return sw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sw *sw) MonthNarrow(month time.Month) string { + return sw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sw *sw) MonthsNarrow() []string { + return sw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sw *sw) MonthWide(month time.Month) string { + return sw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sw *sw) MonthsWide() []string { + return sw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sw *sw) WeekdayAbbreviated(weekday time.Weekday) string { + return sw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sw *sw) WeekdaysAbbreviated() []string { + return sw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sw *sw) WeekdayNarrow(weekday time.Weekday) string { + return sw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sw *sw) WeekdaysNarrow() []string { + return sw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sw *sw) WeekdayShort(weekday time.Weekday) string { + return sw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sw *sw) WeekdaysShort() []string { + return sw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sw *sw) WeekdayWide(weekday time.Weekday) string { + return sw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sw *sw) WeekdaysWide() []string { + return sw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sw' and handles both Whole and Real numbers based on 'v' +func (sw *sw) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sw' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sw *sw) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sw' +func (sw *sw) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sw' +// in accounting notation. +func (sw *sw) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sw.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sw.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sw' +func (sw *sw) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sw' +func (sw *sw) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sw' +func (sw *sw) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sw' +func (sw *sw) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sw' +func (sw *sw) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sw' +func (sw *sw) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sw' +func (sw *sw) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sw' +func (sw *sw) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sw/sw_test.go b/vendor/github.com/go-playground/locales/sw/sw_test.go new file mode 100644 index 0000000000..8f972295b6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw/sw_test.go @@ -0,0 +1,1120 @@ +package sw + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sw" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sw_CD/sw_CD.go b/vendor/github.com/go-playground/locales/sw_CD/sw_CD.go new file mode 100644 index 0000000000..ca3537beaf --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw_CD/sw_CD.go @@ -0,0 +1,605 @@ +package sw_CD + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sw_CD struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sw_CD' locale +func New() locales.Translator { + return &sw_CD{ + locale: "sw_CD", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "FC", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysWide: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"Asubuhi", "Mchana"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristo", "Baada ya Kristo"}, + timezones: map[string]string{"HAST": "Saa za Wastani za Hawaii-Aleutian", "JDT": "Saa za Mchana za Japan", "HNCU": "Saa za Wastani ya Cuba", "CST": "Saa za Wastani za Kati", "MYT": "Saa za Malaysia", "HEOG": "Saa za Majira ya joto za Greenland Magharibi", "TMST": "Saa za Majira ya joto za Turkmenistan", "HNT": "Saa za Wastani za Newfoundland", "MESZ": "Saa za Majira ya joto za Ulaya ya Kati", "ART": "Saa za Wastani za Argentina", "ARST": "Saa za Majira ya joto za Argentina", "HKST": "Saa za Majira ya joto za Hong Kong", "HEPMX": "Saa za mchana za pasifiki za Mexico", "CDT": "Saa za Mchana za Kati", "HADT": "Saa za Mchana za Hawaii-Aleutian", "HNNOMX": "Saa Wastani za Mexico Kaskazini Magharibi", "AKST": "Saa za Wastani za Alaska", "ChST": "Saa Wastani za Chamorro", "SRT": "Saa za Suriname", "AWDT": "Saa za Mchana za Australia Magharibi", "WAT": "Saa za Wastani za Afrika Magharibi", "EDT": "Saa za Mchana za Mashariki", "HEPM": "Saa za Mchana za Saint-Pierre na Miquelon", "NZST": "Saa Wastani za New Zealand", "JST": "Saa Wastani za Japan", "GMT": "Saa za Greenwich", "OEZ": "Saa Wastani za Mashariki mwa Ulaya", "AEDT": "Saa za Mchana za Mashariki mwa Australia", "LHST": "Saa Wastani za Lord Howe", "GYT": "Saa za Guyana", "WEZ": "Saa Wastani za Magharibi mwa Ulaya", "WESZ": "Saa za Majira ya joto za Magharibi mwa Ulaya", "WIT": "Saa za Mashariki mwa Indonesia", "CHAST": "Saa Wastani za Chatham", "SGT": "Saa Wastani za Singapore", "OESZ": "Saa za Majira ya joto za Mashariki mwa Ulaya", "HENOMX": "Saa za mchana za Mexico Kaskazini Magharibi", "HNPMX": "Saa za wastani za pasifiki za Mexico", "EAT": "Saa za Afrika Mashariki", "HECU": "Saa za Mchana za Cuba", "PST": "Saa za Wastani za Pasifiki", "ACWST": "Saa Wastani za Magharibi ya Kati ya Australia", "ACDT": "Saa za Mchana za Australia ya Kati", "COST": "Saa za Majira ya joto za Colombia", "AEST": "Saa Wastani za Mashariki mwa Australia", "GFT": "Saa za Guiana ya Ufaransa", "∅∅∅": "Saa za Majira ya joto za Azores", "WIB": "Saa za Magharibi mwa Indonesia", "CAT": "Saa za Afrika ya Kati", "IST": "Saa Wastani za India", "CLT": "Saa za Wastani za Chile", "HKT": "Saa Wastani za Hong Kong", "ACST": "Saa Wastani za Australia ya Kati", "UYST": "Saa za Majira ya joto za Uruguay", "AWST": "Saa Wastani za Australia Magharibi", "PDT": "Saa za Mchana za Pasifiki", "CLST": "Saa za Majira ya joto za Chile", "HNOG": "Saa za Wastani za Greenland Magharibi", "AST": "Saa za Wastani za Atlantiki", "MDT": "MDT", "WITA": "Saa za Indonesia ya Kati", "NZDT": "Saa za Mchana za New Zealand", "ADT": "Saa za Mchana za Atlantiki", "TMT": "Saa za Wastani za Turkmenistan", "HAT": "Saa za Mchana za Newfoundland", "UYT": "Saa za Wastani za Uruguay", "SAST": "Saa Wastani za Afrika Kusini", "LHDT": "Saa za Mchana za Lord Howe", "CHADT": "Saa za Mchana za Chatham", "MEZ": "Saa Wastani za Ulaya ya kati", "VET": "Saa za Venezuela", "WAST": "Saa za Majira ya joto za Afrika Magharibi", "AKDT": "Saa za Mchana za Alaska", "HNPM": "Saa za Wastani ya Saint-Pierre na Miquelon", "BOT": "Saa za Bolivia", "ACWDT": "Saa za Mchana za Magharibi ya Kati ya Australia", "WART": "Saa Wastani za Magharibi mwa Argentina", "MST": "MST", "EST": "Saa za Wastani za Mashariki", "ECT": "Saa za Ecuador", "WARST": "Saa za Majira ya joto za Magharibi mwa Argentina", "COT": "Saa za Wastani za Colombia", "BT": "Saa za Bhutan", "HNEG": "Saa za Wastani za Greenland Mashariki", "HEEG": "Saa za Majira ya joto za Greenland Mashariki"}, + } +} + +// Locale returns the current translators string locale +func (sw *sw_CD) Locale() string { + return sw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sw_CD' +func (sw *sw_CD) PluralsCardinal() []locales.PluralRule { + return sw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sw_CD' +func (sw *sw_CD) PluralsOrdinal() []locales.PluralRule { + return sw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sw_CD' +func (sw *sw_CD) PluralsRange() []locales.PluralRule { + return sw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sw_CD' +func (sw *sw_CD) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sw_CD' +func (sw *sw_CD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sw_CD' +func (sw *sw_CD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sw.CardinalPluralRule(num1, v1) + end := sw.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sw *sw_CD) MonthAbbreviated(month time.Month) string { + return sw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sw *sw_CD) MonthsAbbreviated() []string { + return sw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sw *sw_CD) MonthNarrow(month time.Month) string { + return sw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sw *sw_CD) MonthsNarrow() []string { + return sw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sw *sw_CD) MonthWide(month time.Month) string { + return sw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sw *sw_CD) MonthsWide() []string { + return sw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sw *sw_CD) WeekdayAbbreviated(weekday time.Weekday) string { + return sw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sw *sw_CD) WeekdaysAbbreviated() []string { + return sw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sw *sw_CD) WeekdayNarrow(weekday time.Weekday) string { + return sw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sw *sw_CD) WeekdaysNarrow() []string { + return sw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sw *sw_CD) WeekdayShort(weekday time.Weekday) string { + return sw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sw *sw_CD) WeekdaysShort() []string { + return sw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sw *sw_CD) WeekdayWide(weekday time.Weekday) string { + return sw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sw *sw_CD) WeekdaysWide() []string { + return sw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sw_CD' and handles both Whole and Real numbers based on 'v' +func (sw *sw_CD) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sw_CD' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sw *sw_CD) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sw_CD' +func (sw *sw_CD) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sw_CD' +// in accounting notation. +func (sw *sw_CD) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sw.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sw.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sw_CD' +func (sw *sw_CD) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sw_CD' +func (sw *sw_CD) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sw_CD' +func (sw *sw_CD) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sw_CD' +func (sw *sw_CD) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sw_CD' +func (sw *sw_CD) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sw_CD' +func (sw *sw_CD) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sw_CD' +func (sw *sw_CD) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sw_CD' +func (sw *sw_CD) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sw_CD/sw_CD_test.go b/vendor/github.com/go-playground/locales/sw_CD/sw_CD_test.go new file mode 100644 index 0000000000..7c834e6289 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw_CD/sw_CD_test.go @@ -0,0 +1,1120 @@ +package sw_CD + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sw_CD" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sw_KE/sw_KE.go b/vendor/github.com/go-playground/locales/sw_KE/sw_KE.go new file mode 100644 index 0000000000..c8f83aecda --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw_KE/sw_KE.go @@ -0,0 +1,605 @@ +package sw_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sw_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sw_KE' locale +func New() locales.Translator { + return &sw_KE{ + locale: "sw_KE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysWide: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristo", "Baada ya Kristo"}, + timezones: map[string]string{"TMST": "Saa za Majira ya joto za Turkmenistan", "HENOMX": "Saa za mchana za Mexico Kaskazini Magharibi", "UYT": "Saa za Wastani za Uruguay", "HADT": "Saa za Mchana za Hawaii-Aleutian", "IST": "Saa Wastani za India", "WESZ": "Saa za Majira ya joto za Magharibi mwa Ulaya", "GFT": "Saa za Guiana ya Ufaransa", "HNPM": "Saa za Wastani ya Saint-Pierre na Miquelon", "UYST": "Saa za Majira ya joto za Uruguay", "CHAST": "Saa Wastani za Chatham", "CAT": "Saa za Afrika ya Kati", "ADT": "Saa za Mchana za Atlantiki", "HNNOMX": "Saa Wastani za Mexico Kaskazini Magharibi", "MST": "Saa za Wastani za Mountain", "HEPMX": "Saa za mchana za pasifiki za Mexico", "WIB": "Saa za Magharibi mwa Indonesia", "EAT": "Saa za Afrika Mashariki", "BT": "Saa za Bhutan", "CHADT": "Saa za Mchana za Chatham", "HEOG": "Saa za Majira ya joto za Greenland Magharibi", "TMT": "Saa za Wastani za Turkmenistan", "HNEG": "Saa za Wastani za Greenland Mashariki", "CST": "Saa za Wastani za Kati", "BOT": "Saa za Bolivia", "PST": "Saa za Wastani za Pasifiki", "JST": "Saa Wastani za Japan", "ChST": "Saa Wastani za Chamorro", "AST": "Saa za Wastani za Atlantiki", "AKDT": "Saa za Mchana za Alaska", "LHDT": "Saa za Mchana za Lord Howe", "GYT": "Saa za Guyana", "ACWDT": "Saa za Mchana za Magharibi ya Kati ya Australia", "CLT": "Saa za Wastani za Chile", "WEZ": "Saa Wastani za Magharibi mwa Ulaya", "MYT": "Saa za Malaysia", "WARST": "Saa za Majira ya joto za Magharibi mwa Argentina", "HKST": "Saa za Majira ya joto za Hong Kong", "HNPMX": "Saa za wastani za pasifiki za Mexico", "SAST": "Saa Wastani za Afrika Kusini", "HAST": "Saa za Wastani za Hawaii-Aleutian", "ACWST": "Saa Wastani za Magharibi ya Kati ya Australia", "ART": "Saa za Wastani za Argentina", "NZDT": "Saa za Mchana za New Zealand", "JDT": "Saa za Mchana za Japan", "OEZ": "Saa Wastani za Mashariki mwa Ulaya", "SRT": "Saa za Suriname", "LHST": "Saa Wastani za Lord Howe", "HECU": "Saa za Mchana za Cuba", "AWDT": "Saa za Mchana za Australia Magharibi", "ECT": "Saa za Ecuador", "EDT": "Saa za Mchana za Mashariki", "ACST": "Saa Wastani za Australia ya Kati", "COT": "Saa za Wastani za Colombia", "AEST": "Saa Wastani za Mashariki mwa Australia", "GMT": "Saa za Greenwich", "OESZ": "Saa za Majira ya joto za Mashariki mwa Ulaya", "ARST": "Saa za Majira ya joto za Argentina", "EST": "Saa za Wastani za Mashariki", "AEDT": "Saa za Mchana za Mashariki mwa Australia", "HEPM": "Saa za Mchana za Saint-Pierre na Miquelon", "AWST": "Saa Wastani za Australia Magharibi", "SGT": "Saa Wastani za Singapore", "WAT": "Saa za Wastani za Afrika Magharibi", "HAT": "Saa za Mchana za Newfoundland", "MDT": "Saa za Mchana za Mountain", "MESZ": "Saa za Majira ya joto za Ulaya ya Kati", "HNOG": "Saa za Wastani za Greenland Magharibi", "MEZ": "Saa Wastani za Ulaya ya kati", "CLST": "Saa za Majira ya joto za Chile", "HKT": "Saa Wastani za Hong Kong", "WAST": "Saa za Majira ya joto za Afrika Magharibi", "HNT": "Saa za Wastani za Newfoundland", "WITA": "Saa za Indonesia ya Kati", "HNCU": "Saa za Wastani ya Cuba", "ACDT": "Saa za Mchana za Australia ya Kati", "PDT": "Saa za Mchana za Pasifiki", "WART": "Saa Wastani za Magharibi mwa Argentina", "COST": "Saa za Majira ya joto za Colombia", "∅∅∅": "∅∅∅", "CDT": "Saa za Mchana za Kati", "WIT": "Saa za Mashariki mwa Indonesia", "VET": "Saa za Venezuela", "HEEG": "Saa za Majira ya joto za Greenland Mashariki", "AKST": "Saa za Wastani za Alaska", "NZST": "Saa Wastani za New Zealand"}, + } +} + +// Locale returns the current translators string locale +func (sw *sw_KE) Locale() string { + return sw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sw_KE' +func (sw *sw_KE) PluralsCardinal() []locales.PluralRule { + return sw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sw_KE' +func (sw *sw_KE) PluralsOrdinal() []locales.PluralRule { + return sw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sw_KE' +func (sw *sw_KE) PluralsRange() []locales.PluralRule { + return sw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sw_KE' +func (sw *sw_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sw_KE' +func (sw *sw_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sw_KE' +func (sw *sw_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sw.CardinalPluralRule(num1, v1) + end := sw.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sw *sw_KE) MonthAbbreviated(month time.Month) string { + return sw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sw *sw_KE) MonthsAbbreviated() []string { + return sw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sw *sw_KE) MonthNarrow(month time.Month) string { + return sw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sw *sw_KE) MonthsNarrow() []string { + return sw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sw *sw_KE) MonthWide(month time.Month) string { + return sw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sw *sw_KE) MonthsWide() []string { + return sw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sw *sw_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return sw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sw *sw_KE) WeekdaysAbbreviated() []string { + return sw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sw *sw_KE) WeekdayNarrow(weekday time.Weekday) string { + return sw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sw *sw_KE) WeekdaysNarrow() []string { + return sw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sw *sw_KE) WeekdayShort(weekday time.Weekday) string { + return sw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sw *sw_KE) WeekdaysShort() []string { + return sw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sw *sw_KE) WeekdayWide(weekday time.Weekday) string { + return sw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sw *sw_KE) WeekdaysWide() []string { + return sw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sw_KE' and handles both Whole and Real numbers based on 'v' +func (sw *sw_KE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sw_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sw *sw_KE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sw_KE' +func (sw *sw_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sw_KE' +// in accounting notation. +func (sw *sw_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sw.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sw.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sw_KE' +func (sw *sw_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sw_KE' +func (sw *sw_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sw_KE' +func (sw *sw_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sw_KE' +func (sw *sw_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sw_KE' +func (sw *sw_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sw_KE' +func (sw *sw_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sw_KE' +func (sw *sw_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sw_KE' +func (sw *sw_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sw_KE/sw_KE_test.go b/vendor/github.com/go-playground/locales/sw_KE/sw_KE_test.go new file mode 100644 index 0000000000..fa61d74cfd --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw_KE/sw_KE_test.go @@ -0,0 +1,1120 @@ +package sw_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sw_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sw_TZ/sw_TZ.go b/vendor/github.com/go-playground/locales/sw_TZ/sw_TZ.go new file mode 100644 index 0000000000..ef62f82210 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw_TZ/sw_TZ.go @@ -0,0 +1,605 @@ +package sw_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sw_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sw_TZ' locale +func New() locales.Translator { + return &sw_TZ{ + locale: "sw_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysWide: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"Asubuhi", "Mchana"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristo", "Baada ya Kristo"}, + timezones: map[string]string{"CLST": "Saa za Majira ya joto za Chile", "COT": "Saa za Wastani za Colombia", "BT": "Saa za Bhutan", "HNT": "Saa za Wastani za Newfoundland", "EAT": "Saa za Afrika Mashariki", "HAST": "Saa za Wastani za Hawaii-Aleutian", "WAST": "Saa za Majira ya joto za Afrika Magharibi", "HKT": "Saa Wastani za Hong Kong", "AWST": "Saa Wastani za Australia Magharibi", "CAT": "Saa za Afrika ya Kati", "WESZ": "Saa za Majira ya joto za Magharibi mwa Ulaya", "ART": "Saa za Wastani za Argentina", "ACST": "Saa Wastani za Australia ya Kati", "WIT": "Saa za Mashariki mwa Indonesia", "ACWST": "Saa Wastani za Magharibi ya Kati ya Australia", "NZST": "Saa Wastani za New Zealand", "MESZ": "Saa za Majira ya joto za Ulaya ya Kati", "HEOG": "Saa za Majira ya joto za Greenland Magharibi", "ADT": "Saa za Mchana za Atlantiki", "OESZ": "Saa za Majira ya joto za Mashariki mwa Ulaya", "CLT": "Saa za Wastani za Chile", "LHDT": "Saa za Mchana za Lord Howe", "HEPM": "Saa za Mchana za Saint-Pierre na Miquelon", "HEEG": "Saa za Majira ya joto za Greenland Mashariki", "ACWDT": "Saa za Mchana za Magharibi ya Kati ya Australia", "HENOMX": "Saa za mchana za Mexico Kaskazini Magharibi", "WITA": "Saa za Indonesia ya Kati", "UYST": "Saa za Majira ya joto za Uruguay", "CHADT": "Saa za Mchana za Chatham", "CDT": "Saa za Mchana za Kati", "ECT": "Saa za Ecuador", "JST": "Saa Wastani za Japan", "∅∅∅": "Saa za Majira ya joto za Azores", "OEZ": "Saa Wastani za Mashariki mwa Ulaya", "GMT": "Saa za Greenwich", "CST": "Saa za Wastani za Kati", "WARST": "Saa za Majira ya joto za Magharibi mwa Argentina", "ARST": "Saa za Majira ya joto za Argentina", "COST": "Saa za Majira ya joto za Colombia", "AST": "Saa za Wastani za Atlantiki", "NZDT": "Saa za Mchana za New Zealand", "HNNOMX": "Saa Wastani za Mexico Kaskazini Magharibi", "AKDT": "Saa za Mchana za Alaska", "HEPMX": "Saa za mchana za pasifiki za Mexico", "HADT": "Saa za Mchana za Hawaii-Aleutian", "MEZ": "Saa Wastani za Ulaya ya kati", "VET": "Saa za Venezuela", "JDT": "Saa za Mchana za Japan", "WEZ": "Saa Wastani za Magharibi mwa Ulaya", "MST": "MST", "HKST": "Saa za Majira ya joto za Hong Kong", "HNPMX": "Saa za wastani za pasifiki za Mexico", "UYT": "Saa za Wastani za Uruguay", "HNEG": "Saa za Wastani za Greenland Mashariki", "SGT": "Saa Wastani za Singapore", "MYT": "Saa za Malaysia", "AEST": "Saa Wastani za Mashariki mwa Australia", "ChST": "Saa Wastani za Chamorro", "SAST": "Saa Wastani za Afrika Kusini", "BOT": "Saa za Bolivia", "PDT": "Saa za Mchana za Pasifiki", "CHAST": "Saa Wastani za Chatham", "WAT": "Saa za Wastani za Afrika Magharibi", "EST": "Saa za Wastani za Mashariki", "ACDT": "Saa za Mchana za Australia ya Kati", "AEDT": "Saa za Mchana za Mashariki mwa Australia", "SRT": "Saa za Suriname", "WIB": "Saa za Magharibi mwa Indonesia", "AWDT": "Saa za Mchana za Australia Magharibi", "PST": "Saa za Wastani za Pasifiki", "WART": "Saa Wastani za Magharibi mwa Argentina", "TMT": "Saa za Wastani za Turkmenistan", "TMST": "Saa za Majira ya joto za Turkmenistan", "MDT": "MDT", "LHST": "Saa Wastani za Lord Howe", "HAT": "Saa za Mchana za Newfoundland", "AKST": "Saa za Wastani za Alaska", "GFT": "Saa za Guiana ya Ufaransa", "EDT": "Saa za Mchana za Mashariki", "HNCU": "Saa za Wastani ya Cuba", "HECU": "Saa za Mchana za Cuba", "IST": "Saa Wastani za India", "HNOG": "Saa za Wastani za Greenland Magharibi", "HNPM": "Saa za Wastani ya Saint-Pierre na Miquelon", "GYT": "Saa za Guyana"}, + } +} + +// Locale returns the current translators string locale +func (sw *sw_TZ) Locale() string { + return sw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sw_TZ' +func (sw *sw_TZ) PluralsCardinal() []locales.PluralRule { + return sw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sw_TZ' +func (sw *sw_TZ) PluralsOrdinal() []locales.PluralRule { + return sw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sw_TZ' +func (sw *sw_TZ) PluralsRange() []locales.PluralRule { + return sw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sw_TZ' +func (sw *sw_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sw_TZ' +func (sw *sw_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sw_TZ' +func (sw *sw_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sw.CardinalPluralRule(num1, v1) + end := sw.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sw *sw_TZ) MonthAbbreviated(month time.Month) string { + return sw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sw *sw_TZ) MonthsAbbreviated() []string { + return sw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sw *sw_TZ) MonthNarrow(month time.Month) string { + return sw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sw *sw_TZ) MonthsNarrow() []string { + return sw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sw *sw_TZ) MonthWide(month time.Month) string { + return sw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sw *sw_TZ) MonthsWide() []string { + return sw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sw *sw_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return sw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sw *sw_TZ) WeekdaysAbbreviated() []string { + return sw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sw *sw_TZ) WeekdayNarrow(weekday time.Weekday) string { + return sw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sw *sw_TZ) WeekdaysNarrow() []string { + return sw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sw *sw_TZ) WeekdayShort(weekday time.Weekday) string { + return sw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sw *sw_TZ) WeekdaysShort() []string { + return sw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sw *sw_TZ) WeekdayWide(weekday time.Weekday) string { + return sw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sw *sw_TZ) WeekdaysWide() []string { + return sw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sw_TZ' and handles both Whole and Real numbers based on 'v' +func (sw *sw_TZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sw_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sw *sw_TZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sw_TZ' +func (sw *sw_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sw_TZ' +// in accounting notation. +func (sw *sw_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sw.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sw.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sw_TZ' +func (sw *sw_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sw_TZ' +func (sw *sw_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sw_TZ' +func (sw *sw_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sw_TZ' +func (sw *sw_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sw_TZ' +func (sw *sw_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sw_TZ' +func (sw *sw_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sw_TZ' +func (sw *sw_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sw_TZ' +func (sw *sw_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sw_TZ/sw_TZ_test.go b/vendor/github.com/go-playground/locales/sw_TZ/sw_TZ_test.go new file mode 100644 index 0000000000..9203076503 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw_TZ/sw_TZ_test.go @@ -0,0 +1,1120 @@ +package sw_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sw_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/sw_UG/sw_UG.go b/vendor/github.com/go-playground/locales/sw_UG/sw_UG.go new file mode 100644 index 0000000000..313d5fb49e --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw_UG/sw_UG.go @@ -0,0 +1,605 @@ +package sw_UG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type sw_UG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'sw_UG' locale +func New() locales.Translator { + return &sw_UG{ + locale: "sw_UG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "USh", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + daysWide: []string{"Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"am", "pm"}, + periodsWide: []string{"Asubuhi", "Mchana"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristo", "Baada ya Kristo"}, + timezones: map[string]string{"AST": "Saa za Wastani za Atlantiki", "MDT": "MDT", "MESZ": "Saa za Majira ya joto za Ulaya ya Kati", "VET": "Saa za Venezuela", "WART": "Saa Wastani za Magharibi mwa Argentina", "CLST": "Saa za Majira ya joto za Chile", "OEZ": "Saa Wastani za Mashariki mwa Ulaya", "MEZ": "Saa Wastani za Ulaya ya kati", "HKT": "Saa Wastani za Hong Kong", "WAST": "Saa za Majira ya joto za Afrika Magharibi", "EST": "Saa za Wastani za Mashariki", "ChST": "Saa Wastani za Chamorro", "TMST": "Saa za Majira ya joto za Turkmenistan", "EDT": "Saa za Mchana za Mashariki", "ACDT": "Saa za Mchana za Australia ya Kati", "AWST": "Saa Wastani za Australia Magharibi", "CHADT": "Saa za Mchana za Chatham", "HAST": "Saa za Wastani za Hawaii-Aleutian", "NZST": "Saa Wastani za New Zealand", "NZDT": "Saa za Mchana za New Zealand", "HEPM": "Saa za Mchana za Saint-Pierre na Miquelon", "HEEG": "Saa za Majira ya joto za Greenland Mashariki", "AEST": "Saa Wastani za Mashariki mwa Australia", "CDT": "Saa za Mchana za Kati", "WIT": "Saa za Mashariki mwa Indonesia", "AWDT": "Saa za Mchana za Australia Magharibi", "WEZ": "Saa Wastani za Magharibi mwa Ulaya", "ART": "Saa za Wastani za Argentina", "SGT": "Saa Wastani za Singapore", "JDT": "Saa za Mchana za Japan", "WARST": "Saa za Majira ya joto za Magharibi mwa Argentina", "AKDT": "Saa za Mchana za Alaska", "UYST": "Saa za Majira ya joto za Uruguay", "WAT": "Saa za Wastani za Afrika Magharibi", "HAT": "Saa za Mchana za Newfoundland", "SRT": "Saa za Suriname", "∅∅∅": "Saa za Majira ya joto za Azores", "WIB": "Saa za Magharibi mwa Indonesia", "CLT": "Saa za Wastani za Chile", "MST": "MST", "GFT": "Saa za Guiana ya Ufaransa", "LHDT": "Saa za Mchana za Lord Howe", "BOT": "Saa za Bolivia", "PST": "Saa za Wastani za Pasifiki", "IST": "Saa Wastani za India", "HENOMX": "Saa za mchana za Mexico Kaskazini Magharibi", "LHST": "Saa Wastani za Lord Howe", "CAT": "Saa za Afrika ya Kati", "HKST": "Saa za Majira ya joto za Hong Kong", "CST": "Saa za Wastani za Kati", "COST": "Saa za Majira ya joto za Colombia", "WITA": "Saa za Indonesia ya Kati", "EAT": "Saa za Afrika Mashariki", "ACST": "Saa Wastani za Australia ya Kati", "HNEG": "Saa za Wastani za Greenland Mashariki", "AEDT": "Saa za Mchana za Mashariki mwa Australia", "OESZ": "Saa za Majira ya joto za Mashariki mwa Ulaya", "ARST": "Saa za Majira ya joto za Argentina", "AKST": "Saa za Wastani za Alaska", "GYT": "Saa za Guyana", "HNCU": "Saa za Wastani ya Cuba", "HADT": "Saa za Mchana za Hawaii-Aleutian", "GMT": "Saa za Greenwich", "ADT": "Saa za Mchana za Atlantiki", "HEPMX": "Saa za mchana za pasifiki za Mexico", "SAST": "Saa Wastani za Afrika Kusini", "HECU": "Saa za Mchana za Cuba", "PDT": "Saa za Mchana za Pasifiki", "TMT": "Saa za Wastani za Turkmenistan", "HNPM": "Saa za Wastani ya Saint-Pierre na Miquelon", "HNPMX": "Saa za wastani za pasifiki za Mexico", "ECT": "Saa za Ecuador", "JST": "Saa Wastani za Japan", "HNOG": "Saa za Wastani za Greenland Magharibi", "COT": "Saa za Wastani za Colombia", "CHAST": "Saa Wastani za Chatham", "HEOG": "Saa za Majira ya joto za Greenland Magharibi", "HNNOMX": "Saa Wastani za Mexico Kaskazini Magharibi", "HNT": "Saa za Wastani za Newfoundland", "UYT": "Saa za Wastani za Uruguay", "ACWST": "Saa Wastani za Magharibi ya Kati ya Australia", "ACWDT": "Saa za Mchana za Magharibi ya Kati ya Australia", "WESZ": "Saa za Majira ya joto za Magharibi mwa Ulaya", "MYT": "Saa za Malaysia", "BT": "Saa za Bhutan"}, + } +} + +// Locale returns the current translators string locale +func (sw *sw_UG) Locale() string { + return sw.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'sw_UG' +func (sw *sw_UG) PluralsCardinal() []locales.PluralRule { + return sw.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'sw_UG' +func (sw *sw_UG) PluralsOrdinal() []locales.PluralRule { + return sw.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'sw_UG' +func (sw *sw_UG) PluralsRange() []locales.PluralRule { + return sw.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sw_UG' +func (sw *sw_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sw_UG' +func (sw *sw_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sw_UG' +func (sw *sw_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := sw.CardinalPluralRule(num1, v1) + end := sw.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (sw *sw_UG) MonthAbbreviated(month time.Month) string { + return sw.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (sw *sw_UG) MonthsAbbreviated() []string { + return sw.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (sw *sw_UG) MonthNarrow(month time.Month) string { + return sw.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (sw *sw_UG) MonthsNarrow() []string { + return sw.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (sw *sw_UG) MonthWide(month time.Month) string { + return sw.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (sw *sw_UG) MonthsWide() []string { + return sw.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (sw *sw_UG) WeekdayAbbreviated(weekday time.Weekday) string { + return sw.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (sw *sw_UG) WeekdaysAbbreviated() []string { + return sw.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (sw *sw_UG) WeekdayNarrow(weekday time.Weekday) string { + return sw.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (sw *sw_UG) WeekdaysNarrow() []string { + return sw.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (sw *sw_UG) WeekdayShort(weekday time.Weekday) string { + return sw.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (sw *sw_UG) WeekdaysShort() []string { + return sw.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (sw *sw_UG) WeekdayWide(weekday time.Weekday) string { + return sw.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (sw *sw_UG) WeekdaysWide() []string { + return sw.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'sw_UG' and handles both Whole and Real numbers based on 'v' +func (sw *sw_UG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'sw_UG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (sw *sw_UG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, sw.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sw_UG' +func (sw *sw_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, sw.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sw_UG' +// in accounting notation. +func (sw *sw_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := sw.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, sw.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, sw.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, sw.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, sw.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, sw.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'sw_UG' +func (sw *sw_UG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'sw_UG' +func (sw *sw_UG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'sw_UG' +func (sw *sw_UG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'sw_UG' +func (sw *sw_UG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, sw.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, sw.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'sw_UG' +func (sw *sw_UG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'sw_UG' +func (sw *sw_UG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'sw_UG' +func (sw *sw_UG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'sw_UG' +func (sw *sw_UG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, sw.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, sw.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := sw.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/sw_UG/sw_UG_test.go b/vendor/github.com/go-playground/locales/sw_UG/sw_UG_test.go new file mode 100644 index 0000000000..a42471e007 --- /dev/null +++ b/vendor/github.com/go-playground/locales/sw_UG/sw_UG_test.go @@ -0,0 +1,1120 @@ +package sw_UG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "sw_UG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ta/ta.go b/vendor/github.com/go-playground/locales/ta/ta.go new file mode 100644 index 0000000000..f87af63738 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta/ta.go @@ -0,0 +1,643 @@ +package ta + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ta struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ta' locale +func New() locales.Translator { + return &ta{ + locale: "ta", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ஜன.", "பிப்.", "மார்.", "ஏப்.", "மே", "ஜூன்", "ஜூலை", "ஆக.", "செப்.", "அக்.", "நவ.", "டிச."}, + monthsNarrow: []string{"", "ஜ", "பி", "மா", "ஏ", "மே", "ஜூ", "ஜூ", "ஆ", "செ", "அ", "ந", "டி"}, + monthsWide: []string{"", "ஜனவரி", "பிப்ரவரி", "மார்ச்", "ஏப்ரல்", "மே", "ஜூன்", "ஜூலை", "ஆகஸ்ட்", "செப்டம்பர்", "அக்டோபர்", "நவம்பர்", "டிசம்பர்"}, + daysAbbreviated: []string{"ஞாயி.", "திங்.", "செவ்.", "புத.", "வியா.", "வெள்.", "சனி"}, + daysNarrow: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysShort: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysWide: []string{"ஞாயிறு", "திங்கள்", "செவ்வாய்", "புதன்", "வியாழன்", "வெள்ளி", "சனி"}, + periodsAbbreviated: []string{"முற்பகல்", "பிற்பகல்"}, + periodsNarrow: []string{"மு.ப", "பி.ப"}, + periodsWide: []string{"முற்பகல்", "பிற்பகல்"}, + erasAbbreviated: []string{"கி.மு.", "கி.பி."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"கிறிஸ்துவுக்கு முன்", "அன்னோ டோமினி"}, + timezones: map[string]string{"WAT": "மேற்கு ஆப்பிரிக்க நிலையான நேரம்", "ACST": "ஆஸ்திரேலியன் மத்திய நிலையான நேரம்", "AWDT": "ஆஸ்திரேலியன் மேற்கத்திய பகலொளி நேரம்", "HADT": "ஹவாய்-அலேஷியன் பகலொளி நேரம்", "MEZ": "மத்திய ஐரோப்பிய நிலையான நேரம்", "HEOG": "மேற்கு கிரீன்லாந்து கோடை நேரம்", "MDT": "மக்காவ் கோடை நேரம்", "HENOMX": "வடமேற்கு மெக்ஸிகோ பகலொளி நேரம்", "SRT": "சுரினாம் நேரம்", "HNCU": "கியூபா நிலையான நேரம்", "NZDT": "நியூசிலாந்து பகலொளி நேரம்", "CAT": "மத்திய ஆப்பிரிக்க நேரம்", "VET": "வெனிசுலா நேரம்", "WART": "மேற்கத்திய அர்ஜென்டினா நிலையான நேரம்", "ADT": "அட்லாண்டிக் பகலொளி நேரம்", "COST": "கொலம்பியா கோடை நேரம்", "GFT": "ஃபிரஞ்சு கயானா நேரம்", "BOT": "பொலிவியா நேரம்", "ACWST": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய நிலையான நேரம்", "HAST": "ஹவாய்-அலேஷியன் நிலையான நேரம்", "JDT": "ஜப்பான் பகலொளி நேரம்", "WESZ": "மேற்கத்திய ஐரோப்பிய கோடை நேரம்", "ART": "அர்ஜென்டினா நிலையான நேரம்", "WAST": "மேற்கு ஆப்பிரிக்க கோடை நேரம்", "UYT": "உருகுவே நிலையான நேரம்", "EAT": "கிழக்கு ஆப்பிரிக்க நேரம்", "JST": "ஜப்பான் நிலையான நேரம்", "WARST": "மேற்கத்திய அர்ஜென்டினா கோடை நேரம்", "HNOG": "மேற்கு கிரீன்லாந்து நிலையான நேரம்", "TMST": "துர்க்மெனிஸ்தான் கோடை நேரம்", "HKST": "ஹாங்காங் கோடை நேரம்", "WITA": "மத்திய இந்தோனேசிய நேரம்", "HNPM": "செயின்ட் பியரி & மிக்குயிலான் நிலையான நேரம்", "MYT": "மலேஷிய நேரம்", "ACDT": "ஆஸ்திரேலியன் மத்திய பகலொளி நேரம்", "SAST": "தென் ஆப்பிரிக்க நிலையான நேரம்", "HECU": "கியூபா பகலொளி நேரம்", "IST": "இந்திய நிலையான நேரம்", "MESZ": "மத்திய ஐரோப்பிய கோடை நேரம்", "CLST": "சிலி கோடை நேரம்", "BT": "பூடான் நேரம்", "HEPMX": "மெக்ஸிகன் பசிபிக் பகலொளி நேரம்", "CHADT": "சத்தாம் பகலொளி நேரம்", "SGT": "சிங்கப்பூர் நிலையான நேரம்", "ARST": "அர்ஜென்டினா கோடை நேரம்", "HKT": "ஹாங்காங் நிலையான நேரம்", "AKST": "அலாஸ்கா நிலையான நேரம்", "AKDT": "அலாஸ்கா பகலொளி நேரம்", "ECT": "ஈக்வடார் நேரம்", "PDT": "பசிபிக் பகலொளி நேரம்", "CLT": "சிலி நிலையான நேரம்", "HNT": "நியூஃபவுண்ட்லாந்து நிலையான நேரம்", "HNEG": "கிழக்கு கிரீன்லாந்து நிலையான நேரம்", "AEST": "ஆஸ்திரேலியன் கிழக்கத்திய நிலையான நேரம்", "WIB": "மேற்கத்திய இந்தோனேசிய நேரம்", "CDT": "மத்திய பகலொளி நேரம்", "GMT": "கிரீன்விச் சராசரி நேரம்", "AEDT": "ஆஸ்திரேலியன் கிழக்கத்திய பகலொளி நேரம்", "OESZ": "கிழக்கத்திய ஐரோப்பிய கோடை நேரம்", "MST": "மக்காவ் தர நேரம்", "CST": "மத்திய நிலையான நேரம்", "AWST": "ஆஸ்திரேலியன் மேற்கத்திய நிலையான நேரம்", "AST": "அட்லாண்டிக் நிலையான நேரம்", "TMT": "துர்க்மெனிஸ்தான் நிலையான நேரம்", "EST": "கிழக்கத்திய நிலையான நேரம்", "HEEG": "கிழக்கு கிரீன்லாந்து கோடை நேரம்", "LHST": "லார்ட் ஹோவ் நிலையான நேரம்", "HNPMX": "மெக்ஸிகன் பசிபிக் நிலையான நேரம்", "ACWDT": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய பகலொளி நேரம்", "CHAST": "சத்தாம் நிலையான நேரம்", "OEZ": "கிழக்கத்திய ஐரோப்பிய நிலையான நேரம்", "WEZ": "மேற்கத்திய ஐரோப்பிய நிலையான நேரம்", "COT": "கொலம்பியா நிலையான நேரம்", "∅∅∅": "அக்ரே கோடை நேரம்", "GYT": "கயானா நேரம்", "WIT": "கிழக்கத்திய இந்தோனேசிய நேரம்", "EDT": "கிழக்கத்திய பகலொளி நேரம்", "HNNOMX": "வடமேற்கு மெக்ஸிகோ நிலையான நேரம்", "HAT": "நியூஃபவுண்ட்லாந்து பகலொளி நேரம்", "HEPM": "செயின்ட் பியரி & மிக்குயிலான் பகலொளி நேரம்", "PST": "பசிபிக் நிலையான நேரம்", "ChST": "சாமோரோ நிலையான நேரம்", "UYST": "உருகுவே கோடை நேரம்", "LHDT": "லார்ட் ஹோவ் பகலொளி நேரம்", "NZST": "நியூசிலாந்து நிலையான நேரம்"}, + } +} + +// Locale returns the current translators string locale +func (ta *ta) Locale() string { + return ta.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ta' +func (ta *ta) PluralsCardinal() []locales.PluralRule { + return ta.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ta' +func (ta *ta) PluralsOrdinal() []locales.PluralRule { + return ta.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ta' +func (ta *ta) PluralsRange() []locales.PluralRule { + return ta.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ta' +func (ta *ta) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ta' +func (ta *ta) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ta' +func (ta *ta) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ta.CardinalPluralRule(num1, v1) + end := ta.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ta *ta) MonthAbbreviated(month time.Month) string { + return ta.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ta *ta) MonthsAbbreviated() []string { + return ta.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ta *ta) MonthNarrow(month time.Month) string { + return ta.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ta *ta) MonthsNarrow() []string { + return ta.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ta *ta) MonthWide(month time.Month) string { + return ta.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ta *ta) MonthsWide() []string { + return ta.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ta *ta) WeekdayAbbreviated(weekday time.Weekday) string { + return ta.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ta *ta) WeekdaysAbbreviated() []string { + return ta.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ta *ta) WeekdayNarrow(weekday time.Weekday) string { + return ta.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ta *ta) WeekdaysNarrow() []string { + return ta.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ta *ta) WeekdayShort(weekday time.Weekday) string { + return ta.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ta *ta) WeekdaysShort() []string { + return ta.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ta *ta) WeekdayWide(weekday time.Weekday) string { + return ta.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ta *ta) WeekdaysWide() []string { + return ta.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ta' and handles both Whole and Real numbers based on 'v' +func (ta *ta) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ta.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ta' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ta *ta) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ta.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ta' +func (ta *ta) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ta' +// in accounting notation. +func (ta *ta) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ta.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ta.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ta' +func (ta *ta) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ta' +func (ta *ta) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ta' +func (ta *ta) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ta' +func (ta *ta) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ta.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ta' +func (ta *ta) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ta' +func (ta *ta) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ta' +func (ta *ta) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ta' +func (ta *ta) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ta.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ta/ta_test.go b/vendor/github.com/go-playground/locales/ta/ta_test.go new file mode 100644 index 0000000000..2cc59d8ec1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta/ta_test.go @@ -0,0 +1,1120 @@ +package ta + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ta" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ta_IN/ta_IN.go b/vendor/github.com/go-playground/locales/ta_IN/ta_IN.go new file mode 100644 index 0000000000..f2cbd9a2a8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta_IN/ta_IN.go @@ -0,0 +1,643 @@ +package ta_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ta_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ta_IN' locale +func New() locales.Translator { + return &ta_IN{ + locale: "ta_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ஜன.", "பிப்.", "மார்.", "ஏப்.", "மே", "ஜூன்", "ஜூலை", "ஆக.", "செப்.", "அக்.", "நவ.", "டிச."}, + monthsNarrow: []string{"", "ஜ", "பி", "மா", "ஏ", "மே", "ஜூ", "ஜூ", "ஆ", "செ", "அ", "ந", "டி"}, + monthsWide: []string{"", "ஜனவரி", "பிப்ரவரி", "மார்ச்", "ஏப்ரல்", "மே", "ஜூன்", "ஜூலை", "ஆகஸ்ட்", "செப்டம்பர்", "அக்டோபர்", "நவம்பர்", "டிசம்பர்"}, + daysAbbreviated: []string{"ஞாயி.", "திங்.", "செவ்.", "புத.", "வியா.", "வெள்.", "சனி"}, + daysNarrow: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysShort: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysWide: []string{"ஞாயிறு", "திங்கள்", "செவ்வாய்", "புதன்", "வியாழன்", "வெள்ளி", "சனி"}, + periodsAbbreviated: []string{"முற்பகல்", "பிற்பகல்"}, + periodsNarrow: []string{"மு.ப", "பி.ப"}, + periodsWide: []string{"முற்பகல்", "பிற்பகல்"}, + erasAbbreviated: []string{"கி.மு.", "கி.பி."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"கிறிஸ்துவுக்கு முன்", "அன்னோ டோமினி"}, + timezones: map[string]string{"ECT": "ஈக்வடார் நேரம்", "CLST": "சிலி கோடை நேரம்", "EDT": "கிழக்கத்திய பகலொளி நேரம்", "UYT": "உருகுவே நிலையான நேரம்", "GYT": "கயானா நேரம்", "WIB": "மேற்கத்திய இந்தோனேசிய நேரம்", "MEZ": "மத்திய ஐரோப்பிய நிலையான நேரம்", "JST": "ஜப்பான் நிலையான நேரம்", "AST": "அட்லாண்டிக் நிலையான நேரம்", "HKT": "ஹாங்காங் நிலையான நேரம்", "HKST": "ஹாங்காங் கோடை நேரம்", "UYST": "உருகுவே கோடை நேரம்", "HNCU": "கியூபா நிலையான நேரம்", "ACWDT": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய பகலொளி நேரம்", "HNT": "நியூஃபவுண்ட்லாந்து நிலையான நேரம்", "AWDT": "ஆஸ்திரேலியன் மேற்கத்திய பகலொளி நேரம்", "BOT": "பொலிவியா நேரம்", "PST": "பசிபிக் நிலையான நேரம்", "BT": "பூடான் நேரம்", "HEEG": "கிழக்கு கிரீன்லாந்து கோடை நேரம்", "WITA": "மத்திய இந்தோனேசிய நேரம்", "LHDT": "லார்ட் ஹோவ் பகலொளி நேரம்", "∅∅∅": "அசோர்ஸ் கோடை நேரம்", "SGT": "சிங்கப்பூர் நிலையான நேரம்", "HAST": "ஹவாய்-அலேஷியன் நிலையான நேரம்", "OEZ": "கிழக்கத்திய ஐரோப்பிய நிலையான நேரம்", "MYT": "மலேஷிய நேரம்", "EST": "கிழக்கத்திய நிலையான நேரம்", "HEPM": "செயின்ட் பியரி & மிக்குயிலான் பகலொளி நேரம்", "SAST": "தென் ஆப்பிரிக்க நிலையான நேரம்", "WIT": "கிழக்கத்திய இந்தோனேசிய நேரம்", "COT": "கொலம்பியா நிலையான நேரம்", "HEPMX": "மெக்ஸிகன் பசிபிக் பகலொளி நேரம்", "HADT": "ஹவாய்-அலேஷியன் பகலொளி நேரம்", "WART": "மேற்கத்திய அர்ஜென்டினா நிலையான நேரம்", "HEOG": "மேற்கு கிரீன்லாந்து கோடை நேரம்", "MST": "மவுன்டைன் நிலையான நேரம்", "CHADT": "சத்தாம் பகலொளி நேரம்", "PDT": "பசிபிக் பகலொளி நேரம்", "JDT": "ஜப்பான் பகலொளி நேரம்", "HNNOMX": "வடமேற்கு மெக்ஸிகோ நிலையான நேரம்", "AEDT": "ஆஸ்திரேலியன் கிழக்கத்திய பகலொளி நேரம்", "MDT": "மவுன்டைன் பகலொளி நேரம்", "NZST": "நியூசிலாந்து நிலையான நேரம்", "ADT": "அட்லாண்டிக் பகலொளி நேரம்", "WEZ": "மேற்கத்திய ஐரோப்பிய நிலையான நேரம்", "WESZ": "மேற்கத்திய ஐரோப்பிய கோடை நேரம்", "ACDT": "ஆஸ்திரேலியன் மத்திய பகலொளி நேரம்", "AKST": "அலாஸ்கா நிலையான நேரம்", "CST": "மத்திய நிலையான நேரம்", "IST": "இந்திய நிலையான நேரம்", "OESZ": "கிழக்கத்திய ஐரோப்பிய கோடை நேரம்", "TMT": "துர்க்மெனிஸ்தான் நிலையான நேரம்", "WAST": "மேற்கு ஆப்பிரிக்க கோடை நேரம்", "HENOMX": "வடமேற்கு மெக்ஸிகோ பகலொளி நேரம்", "CDT": "மத்திய பகலொளி நேரம்", "CHAST": "சத்தாம் நிலையான நேரம்", "CLT": "சிலி நிலையான நேரம்", "GMT": "கிரீன்விச் சராசரி நேரம்", "GFT": "ஃபிரஞ்சு கயானா நேரம்", "ARST": "அர்ஜென்டினா கோடை நேரம்", "HNEG": "கிழக்கு கிரீன்லாந்து நிலையான நேரம்", "WAT": "மேற்கு ஆப்பிரிக்க நிலையான நேரம்", "HNPM": "செயின்ட் பியரி & மிக்குயிலான் நிலையான நேரம்", "EAT": "கிழக்கு ஆப்பிரிக்க நேரம்", "TMST": "துர்க்மெனிஸ்தான் கோடை நேரம்", "CAT": "மத்திய ஆப்பிரிக்க நேரம்", "NZDT": "நியூசிலாந்து பகலொளி நேரம்", "HNOG": "மேற்கு கிரீன்லாந்து நிலையான நேரம்", "ChST": "சாமோரோ நிலையான நேரம்", "HECU": "கியூபா பகலொளி நேரம்", "AWST": "ஆஸ்திரேலியன் மேற்கத்திய நிலையான நேரம்", "COST": "கொலம்பியா கோடை நேரம்", "AKDT": "அலாஸ்கா பகலொளி நேரம்", "ACWST": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய நிலையான நேரம்", "VET": "வெனிசுலா நேரம்", "WARST": "மேற்கத்திய அர்ஜென்டினா கோடை நேரம்", "ACST": "ஆஸ்திரேலியன் மத்திய நிலையான நேரம்", "HAT": "நியூஃபவுண்ட்லாந்து பகலொளி நேரம்", "AEST": "ஆஸ்திரேலியன் கிழக்கத்திய நிலையான நேரம்", "LHST": "லார்ட் ஹோவ் நிலையான நேரம்", "HNPMX": "மெக்ஸிகன் பசிபிக் நிலையான நேரம்", "SRT": "சுரினாம் நேரம்", "MESZ": "மத்திய ஐரோப்பிய கோடை நேரம்", "ART": "அர்ஜென்டினா நிலையான நேரம்"}, + } +} + +// Locale returns the current translators string locale +func (ta *ta_IN) Locale() string { + return ta.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ta_IN' +func (ta *ta_IN) PluralsCardinal() []locales.PluralRule { + return ta.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ta_IN' +func (ta *ta_IN) PluralsOrdinal() []locales.PluralRule { + return ta.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ta_IN' +func (ta *ta_IN) PluralsRange() []locales.PluralRule { + return ta.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ta_IN' +func (ta *ta_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ta_IN' +func (ta *ta_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ta_IN' +func (ta *ta_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ta.CardinalPluralRule(num1, v1) + end := ta.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ta *ta_IN) MonthAbbreviated(month time.Month) string { + return ta.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ta *ta_IN) MonthsAbbreviated() []string { + return ta.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ta *ta_IN) MonthNarrow(month time.Month) string { + return ta.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ta *ta_IN) MonthsNarrow() []string { + return ta.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ta *ta_IN) MonthWide(month time.Month) string { + return ta.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ta *ta_IN) MonthsWide() []string { + return ta.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ta *ta_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return ta.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ta *ta_IN) WeekdaysAbbreviated() []string { + return ta.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ta *ta_IN) WeekdayNarrow(weekday time.Weekday) string { + return ta.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ta *ta_IN) WeekdaysNarrow() []string { + return ta.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ta *ta_IN) WeekdayShort(weekday time.Weekday) string { + return ta.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ta *ta_IN) WeekdaysShort() []string { + return ta.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ta *ta_IN) WeekdayWide(weekday time.Weekday) string { + return ta.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ta *ta_IN) WeekdaysWide() []string { + return ta.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ta_IN' and handles both Whole and Real numbers based on 'v' +func (ta *ta_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ta.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ta_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ta *ta_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ta.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ta_IN' +func (ta *ta_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ta_IN' +// in accounting notation. +func (ta *ta_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ta.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ta.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ta_IN' +func (ta *ta_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ta_IN' +func (ta *ta_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ta_IN' +func (ta *ta_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ta_IN' +func (ta *ta_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ta.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ta_IN' +func (ta *ta_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ta_IN' +func (ta *ta_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ta_IN' +func (ta *ta_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ta_IN' +func (ta *ta_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ta.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ta_IN/ta_IN_test.go b/vendor/github.com/go-playground/locales/ta_IN/ta_IN_test.go new file mode 100644 index 0000000000..931757d513 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta_IN/ta_IN_test.go @@ -0,0 +1,1120 @@ +package ta_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ta_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ta_LK/ta_LK.go b/vendor/github.com/go-playground/locales/ta_LK/ta_LK.go new file mode 100644 index 0000000000..e790f2982d --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta_LK/ta_LK.go @@ -0,0 +1,603 @@ +package ta_LK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ta_LK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ta_LK' locale +func New() locales.Translator { + return &ta_LK{ + locale: "ta_LK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "Rs.", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ஜன.", "பிப்.", "மார்.", "ஏப்.", "மே", "ஜூன்", "ஜூலை", "ஆக.", "செப்.", "அக்.", "நவ.", "டிச."}, + monthsNarrow: []string{"", "ஜ", "பி", "மா", "ஏ", "மே", "ஜூ", "ஜூ", "ஆ", "செ", "அ", "ந", "டி"}, + monthsWide: []string{"", "ஜனவரி", "பிப்ரவரி", "மார்ச்", "ஏப்ரல்", "மே", "ஜூன்", "ஜூலை", "ஆகஸ்ட்", "செப்டம்பர்", "அக்டோபர்", "நவம்பர்", "டிசம்பர்"}, + daysAbbreviated: []string{"ஞாயி.", "திங்.", "செவ்.", "புத.", "வியா.", "வெள்.", "சனி"}, + daysNarrow: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysShort: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysWide: []string{"ஞாயிறு", "திங்கள்", "செவ்வாய்", "புதன்", "வியாழன்", "வெள்ளி", "சனி"}, + periodsAbbreviated: []string{"முற்பகல்", "பிற்பகல்"}, + periodsNarrow: []string{"மு.ப", "பி.ப"}, + periodsWide: []string{"முற்பகல்", "பிற்பகல்"}, + erasAbbreviated: []string{"கி.மு.", "கி.பி."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"கிறிஸ்துவுக்கு முன்", "அன்னோ டோமினி"}, + timezones: map[string]string{"ACWDT": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய பகலொளி நேரம்", "CAT": "மத்திய ஆப்பிரிக்க நேரம்", "JST": "ஜப்பான் நிலையான நேரம்", "JDT": "ஜப்பான் பகலொளி நேரம்", "OESZ": "கிழக்கத்திய ஐரோப்பிய கோடை நேரம்", "ADT": "அட்லாண்டிக் பகலொளி நேரம்", "EAT": "கிழக்கு ஆப்பிரிக்க நேரம்", "AWDT": "ஆஸ்திரேலியன் மேற்கத்திய பகலொளி நேரம்", "COST": "கொலம்பியா கோடை நேரம்", "AKST": "அலாஸ்கா நிலையான நேரம்", "LHDT": "லார்ட் ஹோவ் பகலொளி நேரம்", "ARST": "அர்ஜென்டினா கோடை நேரம்", "MDT": "மக்காவ் கோடை நேரம்", "COT": "கொலம்பியா நிலையான நேரம்", "SRT": "சுரினாம் நேரம்", "PST": "பசிபிக் நிலையான நேரம்", "EDT": "கிழக்கத்திய பகலொளி நேரம்", "HKT": "ஹாங்காங் நிலையான நேரம்", "ChST": "சாமோரோ நிலையான நேரம்", "HNCU": "கியூபா நிலையான நேரம்", "HNOG": "மேற்கு கிரீன்லாந்து நிலையான நேரம்", "HEPM": "செயின்ட் பியரி & மிக்குயிலான் பகலொளி நேரம்", "SAST": "தென் ஆப்பிரிக்க நிலையான நேரம்", "VET": "வெனிசுலா நேரம்", "GMT": "கிரீன்விச் சராசரி நேரம்", "NZST": "நியூசிலாந்து நிலையான நேரம்", "WAT": "மேற்கு ஆப்பிரிக்க நிலையான நேரம்", "HNNOMX": "வடமேற்கு மெக்ஸிகோ நிலையான நேரம்", "HNT": "நியூஃபவுண்ட்லாந்து நிலையான நேரம்", "HNEG": "கிழக்கு கிரீன்லாந்து நிலையான நேரம்", "AWST": "ஆஸ்திரேலியன் மேற்கத்திய நிலையான நேரம்", "IST": "இந்திய நிலையான நேரம்", "HAST": "ஹவாய்-அலேஷியன் நிலையான நேரம்", "AST": "அட்லாண்டிக் நிலையான நேரம்", "WAST": "மேற்கு ஆப்பிரிக்க கோடை நேரம்", "HAT": "நியூஃபவுண்ட்லாந்து பகலொளி நேரம்", "CDT": "மத்திய பகலொளி நேரம்", "PDT": "பசிபிக் பகலொளி நேரம்", "WART": "மேற்கத்திய அர்ஜென்டினா நிலையான நேரம்", "BT": "பூடான் நேரம்", "HNPM": "செயின்ட் பியரி & மிக்குயிலான் நிலையான நேரம்", "SGT": "சிங்கப்பூர் நிலையான நேரம்", "OEZ": "கிழக்கத்திய ஐரோப்பிய நிலையான நேரம்", "HEEG": "கிழக்கு கிரீன்லாந்து கோடை நேரம்", "CLST": "சிலி கோடை நேரம்", "TMT": "துர்க்மெனிஸ்தான் நிலையான நேரம்", "TMST": "துர்க்மெனிஸ்தான் கோடை நேரம்", "HENOMX": "வடமேற்கு மெக்ஸிகோ பகலொளி நேரம்", "∅∅∅": "பிரேசிலியா கோடை நேரம்", "ECT": "ஈக்வடார் நேரம்", "HKST": "ஹாங்காங் கோடை நேரம்", "ACDT": "ஆஸ்திரேலியன் மத்திய பகலொளி நேரம்", "HNPMX": "மெக்ஸிகன் பசிபிக் நிலையான நேரம்", "WESZ": "மேற்கத்திய ஐரோப்பிய கோடை நேரம்", "ART": "அர்ஜென்டினா நிலையான நேரம்", "MEZ": "மத்திய ஐரோப்பிய நிலையான நேரம்", "MST": "மக்காவ் தர நேரம்", "ACST": "ஆஸ்திரேலியன் மத்திய நிலையான நேரம்", "GFT": "ஃபிரஞ்சு கயானா நேரம்", "UYT": "உருகுவே நிலையான நேரம்", "HECU": "கியூபா பகலொளி நேரம்", "CST": "மத்திய நிலையான நேரம்", "MYT": "மலேஷிய நேரம்", "CLT": "சிலி நிலையான நேரம்", "WIT": "கிழக்கத்திய இந்தோனேசிய நேரம்", "HADT": "ஹவாய்-அலேஷியன் பகலொளி நேரம்", "NZDT": "நியூசிலாந்து பகலொளி நேரம்", "MESZ": "மத்திய ஐரோப்பிய கோடை நேரம்", "WARST": "மேற்கத்திய அர்ஜென்டினா கோடை நேரம்", "WITA": "மத்திய இந்தோனேசிய நேரம்", "AKDT": "அலாஸ்கா பகலொளி நேரம்", "LHST": "லார்ட் ஹோவ் நிலையான நேரம்", "GYT": "கயானா நேரம்", "CHADT": "சத்தாம் பகலொளி நேரம்", "BOT": "பொலிவியா நேரம்", "WEZ": "மேற்கத்திய ஐரோப்பிய நிலையான நேரம்", "AEST": "ஆஸ்திரேலியன் கிழக்கத்திய நிலையான நேரம்", "AEDT": "ஆஸ்திரேலியன் கிழக்கத்திய பகலொளி நேரம்", "UYST": "உருகுவே கோடை நேரம்", "HEPMX": "மெக்ஸிகன் பசிபிக் பகலொளி நேரம்", "ACWST": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய நிலையான நேரம்", "HEOG": "மேற்கு கிரீன்லாந்து கோடை நேரம்", "EST": "கிழக்கத்திய நிலையான நேரம்", "WIB": "மேற்கத்திய இந்தோனேசிய நேரம்", "CHAST": "சத்தாம் நிலையான நேரம்"}, + } +} + +// Locale returns the current translators string locale +func (ta *ta_LK) Locale() string { + return ta.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ta_LK' +func (ta *ta_LK) PluralsCardinal() []locales.PluralRule { + return ta.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ta_LK' +func (ta *ta_LK) PluralsOrdinal() []locales.PluralRule { + return ta.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ta_LK' +func (ta *ta_LK) PluralsRange() []locales.PluralRule { + return ta.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ta_LK' +func (ta *ta_LK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ta_LK' +func (ta *ta_LK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ta_LK' +func (ta *ta_LK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ta.CardinalPluralRule(num1, v1) + end := ta.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ta *ta_LK) MonthAbbreviated(month time.Month) string { + return ta.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ta *ta_LK) MonthsAbbreviated() []string { + return ta.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ta *ta_LK) MonthNarrow(month time.Month) string { + return ta.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ta *ta_LK) MonthsNarrow() []string { + return ta.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ta *ta_LK) MonthWide(month time.Month) string { + return ta.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ta *ta_LK) MonthsWide() []string { + return ta.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ta *ta_LK) WeekdayAbbreviated(weekday time.Weekday) string { + return ta.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ta *ta_LK) WeekdaysAbbreviated() []string { + return ta.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ta *ta_LK) WeekdayNarrow(weekday time.Weekday) string { + return ta.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ta *ta_LK) WeekdaysNarrow() []string { + return ta.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ta *ta_LK) WeekdayShort(weekday time.Weekday) string { + return ta.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ta *ta_LK) WeekdaysShort() []string { + return ta.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ta *ta_LK) WeekdayWide(weekday time.Weekday) string { + return ta.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ta *ta_LK) WeekdaysWide() []string { + return ta.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ta_LK' and handles both Whole and Real numbers based on 'v' +func (ta *ta_LK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ta.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ta_LK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ta *ta_LK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ta.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ta_LK' +func (ta *ta_LK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ta_LK' +// in accounting notation. +func (ta *ta_LK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ta.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ta.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ta_LK' +func (ta *ta_LK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ta_LK' +func (ta *ta_LK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ta_LK' +func (ta *ta_LK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ta_LK' +func (ta *ta_LK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ta.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ta_LK' +func (ta *ta_LK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ta_LK' +func (ta *ta_LK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ta_LK' +func (ta *ta_LK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ta_LK' +func (ta *ta_LK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ta.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ta_LK/ta_LK_test.go b/vendor/github.com/go-playground/locales/ta_LK/ta_LK_test.go new file mode 100644 index 0000000000..5540fc50e3 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta_LK/ta_LK_test.go @@ -0,0 +1,1120 @@ +package ta_LK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ta_LK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ta_MY/ta_MY.go b/vendor/github.com/go-playground/locales/ta_MY/ta_MY.go new file mode 100644 index 0000000000..cfedc482d6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta_MY/ta_MY.go @@ -0,0 +1,642 @@ +package ta_MY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ta_MY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ta_MY' locale +func New() locales.Translator { + return &ta_MY{ + locale: "ta_MY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "RM", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "S$", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ஜன.", "பிப்.", "மார்.", "ஏப்.", "மே", "ஜூன்", "ஜூலை", "ஆக.", "செப்.", "அக்.", "நவ.", "டிச."}, + monthsNarrow: []string{"", "ஜ", "பி", "மா", "ஏ", "மே", "ஜூ", "ஜூ", "ஆ", "செ", "அ", "ந", "டி"}, + monthsWide: []string{"", "ஜனவரி", "பிப்ரவரி", "மார்ச்", "ஏப்ரல்", "மே", "ஜூன்", "ஜூலை", "ஆகஸ்ட்", "செப்டம்பர்", "அக்டோபர்", "நவம்பர்", "டிசம்பர்"}, + daysAbbreviated: []string{"ஞாயி.", "திங்.", "செவ்.", "புத.", "வியா.", "வெள்.", "சனி"}, + daysNarrow: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysShort: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysWide: []string{"ஞாயிறு", "திங்கள்", "செவ்வாய்", "புதன்", "வியாழன்", "வெள்ளி", "சனி"}, + periodsAbbreviated: []string{"முற்பகல்", "பிற்பகல்"}, + periodsNarrow: []string{"மு.ப", "பி.ப"}, + periodsWide: []string{"முற்பகல்", "பிற்பகல்"}, + erasAbbreviated: []string{"கி.மு.", "கி.பி."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"கிறிஸ்துவுக்கு முன்", "அன்னோ டோமினி"}, + timezones: map[string]string{"MDT": "மக்காவ் கோடை நேரம்", "HNCU": "கியூபா நிலையான நேரம்", "ACWDT": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய பகலொளி நேரம்", "WART": "மேற்கத்திய அர்ஜென்டினா நிலையான நேரம்", "HAT": "நியூஃபவுண்ட்லாந்து பகலொளி நேரம்", "HNPMX": "மெக்ஸிகன் பசிபிக் நிலையான நேரம்", "HEPMX": "மெக்ஸிகன் பசிபிக் பகலொளி நேரம்", "AWST": "ஆஸ்திரேலியன் மேற்கத்திய நிலையான நேரம்", "HADT": "ஹவாய்-அலேஷியன் பகலொளி நேரம்", "ART": "அர்ஜென்டினா நிலையான நேரம்", "HNT": "நியூஃபவுண்ட்லாந்து நிலையான நேரம்", "AKST": "அலாஸ்கா நிலையான நேரம்", "∅∅∅": "பிரேசிலியா கோடை நேரம்", "WESZ": "மேற்கத்திய ஐரோப்பிய கோடை நேரம்", "AST": "அட்லாண்டிக் நிலையான நேரம்", "EDT": "கிழக்கத்திய பகலொளி நேரம்", "WAST": "மேற்கு ஆப்பிரிக்க கோடை நேரம்", "COT": "கொலம்பியா நிலையான நேரம்", "HEEG": "கிழக்கு கிரீன்லாந்து கோடை நேரம்", "SAST": "தென் ஆப்பிரிக்க நிலையான நேரம்", "CDT": "மத்திய பகலொளி நேரம்", "JDT": "ஜப்பான் பகலொளி நேரம்", "WEZ": "மேற்கத்திய ஐரோப்பிய நிலையான நேரம்", "WARST": "மேற்கத்திய அர்ஜென்டினா கோடை நேரம்", "AEDT": "ஆஸ்திரேலியன் கிழக்கத்திய பகலொளி நேரம்", "LHST": "லார்ட் ஹோவ் நிலையான நேரம்", "WIB": "மேற்கத்திய இந்தோனேசிய நேரம்", "WIT": "கிழக்கத்திய இந்தோனேசிய நேரம்", "NZDT": "நியூசிலாந்து பகலொளி நேரம்", "LHDT": "லார்ட் ஹோவ் பகலொளி நேரம்", "CHADT": "சத்தாம் பகலொளி நேரம்", "MST": "மக்காவ் தர நேரம்", "ACST": "ஆஸ்திரேலியன் மத்திய நிலையான நேரம்", "ACDT": "ஆஸ்திரேலியன் மத்திய பகலொளி நேரம்", "VET": "வெனிசுலா நேரம்", "HNNOMX": "வடமேற்கு மெக்ஸிகோ நிலையான நேரம்", "AEST": "ஆஸ்திரேலியன் கிழக்கத்திய நிலையான நேரம்", "ChST": "சாமோரோ நிலையான நேரம்", "IST": "இந்திய நிலையான நேரம்", "NZST": "நியூசிலாந்து நிலையான நேரம்", "MEZ": "மத்திய ஐரோப்பிய நிலையான நேரம்", "CLT": "சிலி நிலையான நேரம்", "HNOG": "மேற்கு கிரீன்லாந்து நிலையான நேரம்", "HEPM": "செயின்ட் பியரி & மிக்குயிலான் பகலொளி நேரம்", "HECU": "கியூபா பகலொளி நேரம்", "CHAST": "சத்தாம் நிலையான நேரம்", "HAST": "ஹவாய்-அலேஷியன் நிலையான நேரம்", "ADT": "அட்லாண்டிக் பகலொளி நேரம்", "HKST": "ஹாங்காங் கோடை நேரம்", "HNEG": "கிழக்கு கிரீன்லாந்து நிலையான நேரம்", "HNPM": "செயின்ட் பியரி & மிக்குயிலான் நிலையான நேரம்", "CAT": "மத்திய ஆப்பிரிக்க நேரம்", "OEZ": "கிழக்கத்திய ஐரோப்பிய நிலையான நேரம்", "MYT": "மலேஷிய நேரம்", "HENOMX": "வடமேற்கு மெக்ஸிகோ பகலொளி நேரம்", "GFT": "ஃபிரஞ்சு கயானா நேரம்", "GYT": "கயானா நேரம்", "SGT": "சிங்கப்பூர் நிலையான நேரம்", "BOT": "பொலிவியா நேரம்", "HEOG": "மேற்கு கிரீன்லாந்து கோடை நேரம்", "TMST": "துர்க்மெனிஸ்தான் கோடை நேரம்", "ARST": "அர்ஜென்டினா கோடை நேரம்", "HKT": "ஹாங்காங் நிலையான நேரம்", "COST": "கொலம்பியா கோடை நேரம்", "JST": "ஜப்பான் நிலையான நேரம்", "OESZ": "கிழக்கத்திய ஐரோப்பிய கோடை நேரம்", "GMT": "கிரீன்விச் சராசரி நேரம்", "WAT": "மேற்கு ஆப்பிரிக்க நிலையான நேரம்", "AKDT": "அலாஸ்கா பகலொளி நேரம்", "SRT": "சுரினாம் நேரம்", "PST": "பசிபிக் நிலையான நேரம்", "PDT": "பசிபிக் பகலொளி நேரம்", "ACWST": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய நிலையான நேரம்", "TMT": "துர்க்மெனிஸ்தான் நிலையான நேரம்", "EST": "கிழக்கத்திய நிலையான நேரம்", "WITA": "மத்திய இந்தோனேசிய நேரம்", "EAT": "கிழக்கு ஆப்பிரிக்க நேரம்", "AWDT": "ஆஸ்திரேலியன் மேற்கத்திய பகலொளி நேரம்", "ECT": "ஈக்வடார் நேரம்", "UYST": "உருகுவே கோடை நேரம்", "CLST": "சிலி கோடை நேரம்", "BT": "பூடான் நேரம்", "UYT": "உருகுவே நிலையான நேரம்", "CST": "மத்திய நிலையான நேரம்", "MESZ": "மத்திய ஐரோப்பிய கோடை நேரம்"}, + } +} + +// Locale returns the current translators string locale +func (ta *ta_MY) Locale() string { + return ta.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ta_MY' +func (ta *ta_MY) PluralsCardinal() []locales.PluralRule { + return ta.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ta_MY' +func (ta *ta_MY) PluralsOrdinal() []locales.PluralRule { + return ta.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ta_MY' +func (ta *ta_MY) PluralsRange() []locales.PluralRule { + return ta.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ta_MY' +func (ta *ta_MY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ta_MY' +func (ta *ta_MY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ta_MY' +func (ta *ta_MY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ta.CardinalPluralRule(num1, v1) + end := ta.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ta *ta_MY) MonthAbbreviated(month time.Month) string { + return ta.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ta *ta_MY) MonthsAbbreviated() []string { + return ta.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ta *ta_MY) MonthNarrow(month time.Month) string { + return ta.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ta *ta_MY) MonthsNarrow() []string { + return ta.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ta *ta_MY) MonthWide(month time.Month) string { + return ta.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ta *ta_MY) MonthsWide() []string { + return ta.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ta *ta_MY) WeekdayAbbreviated(weekday time.Weekday) string { + return ta.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ta *ta_MY) WeekdaysAbbreviated() []string { + return ta.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ta *ta_MY) WeekdayNarrow(weekday time.Weekday) string { + return ta.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ta *ta_MY) WeekdaysNarrow() []string { + return ta.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ta *ta_MY) WeekdayShort(weekday time.Weekday) string { + return ta.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ta *ta_MY) WeekdaysShort() []string { + return ta.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ta *ta_MY) WeekdayWide(weekday time.Weekday) string { + return ta.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ta *ta_MY) WeekdaysWide() []string { + return ta.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ta_MY' and handles both Whole and Real numbers based on 'v' +func (ta *ta_MY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ta_MY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ta *ta_MY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ta.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ta_MY' +func (ta *ta_MY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ta.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ta.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ta_MY' +// in accounting notation. +func (ta *ta_MY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ta.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ta.currencyNegativePrefix[j]) + } + + b = append(b, ta.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ta.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ta.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ta_MY' +func (ta *ta_MY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ta_MY' +func (ta *ta_MY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ta_MY' +func (ta *ta_MY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ta_MY' +func (ta *ta_MY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ta.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ta_MY' +func (ta *ta_MY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ta_MY' +func (ta *ta_MY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ta_MY' +func (ta *ta_MY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ta_MY' +func (ta *ta_MY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ta.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ta_MY/ta_MY_test.go b/vendor/github.com/go-playground/locales/ta_MY/ta_MY_test.go new file mode 100644 index 0000000000..ae1e12f39a --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta_MY/ta_MY_test.go @@ -0,0 +1,1120 @@ +package ta_MY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ta_MY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ta_SG/ta_SG.go b/vendor/github.com/go-playground/locales/ta_SG/ta_SG.go new file mode 100644 index 0000000000..39d018b649 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta_SG/ta_SG.go @@ -0,0 +1,642 @@ +package ta_SG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ta_SG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ta_SG' locale +func New() locales.Translator { + return &ta_SG{ + locale: "ta_SG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "RM", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "$", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "ஜன.", "பிப்.", "மார்.", "ஏப்.", "மே", "ஜூன்", "ஜூலை", "ஆக.", "செப்.", "அக்.", "நவ.", "டிச."}, + monthsNarrow: []string{"", "ஜ", "பி", "மா", "ஏ", "மே", "ஜூ", "ஜூ", "ஆ", "செ", "அ", "ந", "டி"}, + monthsWide: []string{"", "ஜனவரி", "பிப்ரவரி", "மார்ச்", "ஏப்ரல்", "மே", "ஜூன்", "ஜூலை", "ஆகஸ்ட்", "செப்டம்பர்", "அக்டோபர்", "நவம்பர்", "டிசம்பர்"}, + daysAbbreviated: []string{"ஞாயி.", "திங்.", "செவ்.", "புத.", "வியா.", "வெள்.", "சனி"}, + daysNarrow: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysShort: []string{"ஞா", "தி", "செ", "பு", "வி", "வெ", "ச"}, + daysWide: []string{"ஞாயிறு", "திங்கள்", "செவ்வாய்", "புதன்", "வியாழன்", "வெள்ளி", "சனி"}, + periodsAbbreviated: []string{"முற்பகல்", "பிற்பகல்"}, + periodsNarrow: []string{"மு.ப", "பி.ப"}, + periodsWide: []string{"முற்பகல்", "பிற்பகல்"}, + erasAbbreviated: []string{"கி.மு.", "கி.பி."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"கிறிஸ்துவுக்கு முன்", "அன்னோ டோமினி"}, + timezones: map[string]string{"IST": "இந்திய நிலையான நேரம்", "JDT": "ஜப்பான் பகலொளி நேரம்", "EDT": "கிழக்கத்திய பகலொளி நேரம்", "ChST": "சாமோரோ நிலையான நேரம்", "CST": "மத்திய நிலையான நேரம்", "PST": "பசிபிக் நிலையான நேரம்", "OESZ": "கிழக்கத்திய ஐரோப்பிய கோடை நேரம்", "WARST": "மேற்கத்திய அர்ஜென்டினா கோடை நேரம்", "HENOMX": "வடமேற்கு மெக்ஸிகோ பகலொளி நேரம்", "HNPMX": "மெக்ஸிகன் பசிபிக் நிலையான நேரம்", "HECU": "கியூபா பகலொளி நேரம்", "HAT": "நியூஃபவுண்ட்லாந்து பகலொளி நேரம்", "HNOG": "மேற்கு கிரீன்லாந்து நிலையான நேரம்", "HEOG": "மேற்கு கிரீன்லாந்து கோடை நேரம்", "WEZ": "மேற்கத்திய ஐரோப்பிய நிலையான நேரம்", "EST": "கிழக்கத்திய நிலையான நேரம்", "AEDT": "ஆஸ்திரேலியன் கிழக்கத்திய பகலொளி நேரம்", "AEST": "ஆஸ்திரேலியன் கிழக்கத்திய நிலையான நேரம்", "CDT": "மத்திய பகலொளி நேரம்", "JST": "ஜப்பான் நிலையான நேரம்", "GMT": "கிரீன்விச் சராசரி நேரம்", "HKT": "ஹாங்காங் நிலையான நேரம்", "BT": "பூடான் நேரம்", "WITA": "மத்திய இந்தோனேசிய நேரம்", "AKST": "அலாஸ்கா நிலையான நேரம்", "WIT": "கிழக்கத்திய இந்தோனேசிய நேரம்", "AWST": "ஆஸ்திரேலியன் மேற்கத்திய நிலையான நேரம்", "ARST": "அர்ஜென்டினா கோடை நேரம்", "COT": "கொலம்பியா நிலையான நேரம்", "HNNOMX": "வடமேற்கு மெக்ஸிகோ நிலையான நேரம்", "SAST": "தென் ஆப்பிரிக்க நிலையான நேரம்", "HNPM": "செயின்ட் பியரி & மிக்குயிலான் நிலையான நேரம்", "GYT": "கயானா நேரம்", "CHADT": "சத்தாம் பகலொளி நேரம்", "PDT": "பசிபிக் பகலொளி நேரம்", "CLT": "சிலி நிலையான நேரம்", "ART": "அர்ஜென்டினா நிலையான நேரம்", "HNT": "நியூஃபவுண்ட்லாந்து நிலையான நேரம்", "HEEG": "கிழக்கு கிரீன்லாந்து கோடை நேரம்", "ACWDT": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய பகலொளி நேரம்", "AST": "அட்லாண்டிக் நிலையான நேரம்", "MST": "மக்காவ் தர நேரம்", "WAT": "மேற்கு ஆப்பிரிக்க நிலையான நேரம்", "ACST": "ஆஸ்திரேலியன் மத்திய நிலையான நேரம்", "HEPM": "செயின்ட் பியரி & மிக்குயிலான் பகலொளி நேரம்", "CLST": "சிலி கோடை நேரம்", "ACDT": "ஆஸ்திரேலியன் மத்திய பகலொளி நேரம்", "COST": "கொலம்பியா கோடை நேரம்", "SRT": "சுரினாம் நேரம்", "WIB": "மேற்கத்திய இந்தோனேசிய நேரம்", "CAT": "மத்திய ஆப்பிரிக்க நேரம்", "ACWST": "ஆஸ்திரேலியன் மத்திய மேற்கத்திய நிலையான நேரம்", "NZDT": "நியூசிலாந்து பகலொளி நேரம்", "TMT": "துர்க்மெனிஸ்தான் நிலையான நேரம்", "WAST": "மேற்கு ஆப்பிரிக்க கோடை நேரம்", "AKDT": "அலாஸ்கா பகலொளி நேரம்", "AWDT": "ஆஸ்திரேலியன் மேற்கத்திய பகலொளி நேரம்", "NZST": "நியூசிலாந்து நிலையான நேரம்", "OEZ": "கிழக்கத்திய ஐரோப்பிய நிலையான நேரம்", "WART": "மேற்கத்திய அர்ஜென்டினா நிலையான நேரம்", "TMST": "துர்க்மெனிஸ்தான் கோடை நேரம்", "HKST": "ஹாங்காங் கோடை நேரம்", "BOT": "பொலிவியா நேரம்", "ADT": "அட்லாண்டிக் பகலொளி நேரம்", "HNEG": "கிழக்கு கிரீன்லாந்து நிலையான நேரம்", "LHST": "லார்ட் ஹோவ் நிலையான நேரம்", "∅∅∅": "அமேசான் கோடை நேரம்", "MEZ": "மத்திய ஐரோப்பிய நிலையான நேரம்", "MESZ": "மத்திய ஐரோப்பிய கோடை நேரம்", "UYT": "உருகுவே நிலையான நேரம்", "HEPMX": "மெக்ஸிகன் பசிபிக் பகலொளி நேரம்", "HAST": "ஹவாய்-அலேஷியன் நிலையான நேரம்", "HADT": "ஹவாய்-அலேஷியன் பகலொளி நேரம்", "VET": "வெனிசுலா நேரம்", "MDT": "மக்காவ் கோடை நேரம்", "HNCU": "கியூபா நிலையான நேரம்", "CHAST": "சத்தாம் நிலையான நேரம்", "SGT": "சிங்கப்பூர் நிலையான நேரம்", "MYT": "மலேஷிய நேரம்", "LHDT": "லார்ட் ஹோவ் பகலொளி நேரம்", "EAT": "கிழக்கு ஆப்பிரிக்க நேரம்", "ECT": "ஈக்வடார் நேரம்", "WESZ": "மேற்கத்திய ஐரோப்பிய கோடை நேரம்", "GFT": "ஃபிரஞ்சு கயானா நேரம்", "UYST": "உருகுவே கோடை நேரம்"}, + } +} + +// Locale returns the current translators string locale +func (ta *ta_SG) Locale() string { + return ta.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ta_SG' +func (ta *ta_SG) PluralsCardinal() []locales.PluralRule { + return ta.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ta_SG' +func (ta *ta_SG) PluralsOrdinal() []locales.PluralRule { + return ta.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ta_SG' +func (ta *ta_SG) PluralsRange() []locales.PluralRule { + return ta.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ta_SG' +func (ta *ta_SG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ta_SG' +func (ta *ta_SG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ta_SG' +func (ta *ta_SG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ta.CardinalPluralRule(num1, v1) + end := ta.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ta *ta_SG) MonthAbbreviated(month time.Month) string { + return ta.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ta *ta_SG) MonthsAbbreviated() []string { + return ta.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ta *ta_SG) MonthNarrow(month time.Month) string { + return ta.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ta *ta_SG) MonthsNarrow() []string { + return ta.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ta *ta_SG) MonthWide(month time.Month) string { + return ta.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ta *ta_SG) MonthsWide() []string { + return ta.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ta *ta_SG) WeekdayAbbreviated(weekday time.Weekday) string { + return ta.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ta *ta_SG) WeekdaysAbbreviated() []string { + return ta.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ta *ta_SG) WeekdayNarrow(weekday time.Weekday) string { + return ta.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ta *ta_SG) WeekdaysNarrow() []string { + return ta.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ta *ta_SG) WeekdayShort(weekday time.Weekday) string { + return ta.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ta *ta_SG) WeekdaysShort() []string { + return ta.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ta *ta_SG) WeekdayWide(weekday time.Weekday) string { + return ta.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ta *ta_SG) WeekdaysWide() []string { + return ta.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ta_SG' and handles both Whole and Real numbers based on 'v' +func (ta *ta_SG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ta_SG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ta *ta_SG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ta.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ta_SG' +func (ta *ta_SG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ta.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ta.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, ta.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ta_SG' +// in accounting notation. +func (ta *ta_SG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ta.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ta.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ta.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ta.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ta.currencyNegativePrefix[j]) + } + + b = append(b, ta.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ta.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ta.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ta.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ta_SG' +func (ta *ta_SG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ta_SG' +func (ta *ta_SG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ta_SG' +func (ta *ta_SG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ta_SG' +func (ta *ta_SG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ta.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ta.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ta_SG' +func (ta *ta_SG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ta_SG' +func (ta *ta_SG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ta_SG' +func (ta *ta_SG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ta_SG' +func (ta *ta_SG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, ta.periodsAbbreviated[0]...) + } else { + b = append(b, ta.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ta.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ta.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ta.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ta_SG/ta_SG_test.go b/vendor/github.com/go-playground/locales/ta_SG/ta_SG_test.go new file mode 100644 index 0000000000..2bbfcbb59e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ta_SG/ta_SG_test.go @@ -0,0 +1,1120 @@ +package ta_SG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ta_SG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/te/te.go b/vendor/github.com/go-playground/locales/te/te.go new file mode 100644 index 0000000000..f0e538fa08 --- /dev/null +++ b/vendor/github.com/go-playground/locales/te/te.go @@ -0,0 +1,670 @@ +package te + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type te struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'te' locale +func New() locales.Translator { + return &te{ + locale: "te", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "జన", "ఫిబ్ర", "మార్చి", "ఏప్రి", "మే", "జూన్", "జులై", "ఆగ", "సెప్టెం", "అక్టో", "నవం", "డిసెం"}, + monthsNarrow: []string{"", "జ", "ఫి", "మా", "ఏ", "మే", "జూ", "జు", "ఆ", "సె", "అ", "న", "డి"}, + monthsWide: []string{"", "జనవరి", "ఫిబ్రవరి", "మార్చి", "ఏప్రిల్", "మే", "జూన్", "జులై", "ఆగస్టు", "సెప్టెంబర్", "అక్టోబర్", "నవంబర్", "డిసెంబర్"}, + daysAbbreviated: []string{"ఆది", "సోమ", "మంగళ", "బుధ", "గురు", "శుక్ర", "శని"}, + daysNarrow: []string{"ఆ", "సో", "మ", "బు", "గు", "శు", "శ"}, + daysShort: []string{"ఆది", "సోమ", "మం", "బుధ", "గురు", "శుక్ర", "శని"}, + daysWide: []string{"ఆదివారం", "సోమవారం", "మంగళవారం", "బుధవారం", "గురువారం", "శుక్రవారం", "శనివారం"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"ఉ", "సా"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"క్రీపూ", "క్రీశ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"క్రీస్తు పూర్వం", "క్రీస్తు శకం"}, + timezones: map[string]string{"AWST": "పశ్చిమ ఆస్ట్రేలియన్ ప్రామాణిక సమయం", "SGT": "సింగపూర్ ప్రామాణిక సమయం", "CAT": "సెంట్రల్ ఆఫ్రికా సమయం", "ACWST": "మధ్యమ ఆస్ట్రేలియా పశ్చిమ ప్రామాణిక సమయం", "HNEG": "తూర్పు గ్రీన్\u200cల్యాండ్ ప్రామాణిక సమయం", "CHADT": "చాథమ్ పగటి వెలుతురు సమయం", "ECT": "ఈక్వడార్ సమయం", "MESZ": "సెంట్రల్ యూరోపియన్ వేసవి సమయం", "GMT": "గ్రీన్\u200cవిచ్ సగటు సమయం", "MDT": "మకావ్ వేసవి సమయం", "HEEG": "తూర్పు గ్రీన్\u200cల్యాండ్ వేసవి సమయం", "PDT": "పసిఫిక్ పగటి సమయం", "IST": "భారతదేశ సమయం", "NZDT": "న్యూజిల్యాండ్ పగటి వెలుతురు సమయం", "TMST": "తుర్క్మెనిస్థాన్ వేసవి సమయం", "ChST": "చామర్రో ప్రామాణిక సమయం", "HNPMX": "మెక్సికన్ పసిఫిక్ ప్రామాణిక సమయం", "ACWDT": "మధ్యమ ఆస్ట్రేలియన్ పశ్చిమ పగటి సమయం", "COST": "కొలంబియా వేసవి సమయం", "LHDT": "లార్డ్ హోవ్ పగటి సమయం", "MEZ": "సెంట్రల్ యూరోపియన్ ప్రామాణిక సమయం", "JST": "జపాన్ ప్రామాణిక సమయం", "GFT": "ఫ్రెంచ్ గయానా సమయం", "GYT": "గయానా సమయం", "EAT": "తూర్పు ఆఫ్రికా సమయం", "WIB": "పశ్చిమ ఇండోనేషియా సమయం", "HADT": "హవాయ్-అల్యూషియన్ పగటి వెలుతురు సమయం", "MYT": "మలేషియా సమయం", "HENOMX": "వాయవ్య మెక్సికో పగటి సమయం", "WITA": "సెంట్రల్ ఇండోనేషియా సమయం", "HAST": "హవాయ్-అల్యూషియన్ ప్రామాణిక సమయం", "HEOG": "పశ్చిమ గ్రీన్\u200cల్యాండ్ వేసవి సమయం", "ADT": "అట్లాంటిక్ పగటి సమయం", "OEZ": "తూర్పు యూరోపియన్ ప్రామాణిక సమయం", "WEZ": "పశ్చిమ యూరోపియన్ ప్రామాణిక సమయం", "ACST": "ఆస్ట్రేలియా మధ్యమ ప్రామాణిక సమయం", "HAT": "న్యూఫౌండ్ ల్యాండ్ పగటి సమయం", "UYST": "ఉరుగ్వే వేసవి సమయం", "CST": "మధ్యమ ప్రామాణిక సమయం", "AWDT": "పశ్చిమ ఆస్ట్రేలియన్ పగటి సమయం", "VET": "వెనిజులా సమయం", "JDT": "జపాన్ పగటి వెలుతురు సమయం", "CLST": "చిలీ వేసవి సమయం", "HNOG": "పశ్చిమ గ్రీన్\u200cల్యాండ్ ప్రామాణిక సమయం", "HEPM": "సెయింట్ పియర్ మరియు మిక్వెలాన్ పగటి సమయం", "∅∅∅": "అజోర్స్ వేసవి సమయం", "HNCU": "క్యూబా ప్రామాణిక సమయం", "BOT": "బొలీవియా సమయం", "PST": "పసిఫిక్ ప్రామాణిక సమయం", "TMT": "తుర్క్మెనిస్థాన్ ప్రామాణిక సమయం", "AKDT": "అలాస్కా పగటి సమయం", "LHST": "లార్డ్ హోవ్ ప్రామాణిక సమయం", "ARST": "ఆర్జెంటీనా వేసవి సమయం", "EST": "తూర్పు ప్రామాణిక సమయం", "ACDT": "ఆస్ట్రేలియా మధ్యమ పగటి సమయం", "HNNOMX": "వాయవ్య మెక్సికో ప్రామాణిక సమయం", "AEST": "తూర్పు ఆస్ట్రేలియా ప్రామాణిక సమయం", "HEPMX": "మెక్సికన్ పసిఫిక్ పగటి సమయం", "WIT": "తూర్పు ఇండోనేషియా సమయం", "WART": "పశ్చిమ అర్జెంటీనా ప్రామాణిక సమయం", "CLT": "చిలీ ప్రామాణిక సమయం", "MST": "మకావ్ ప్రామాణిక సమయం", "ART": "అర్జెంటీనా ప్రామాణిక సమయం", "UYT": "ఉరుగ్వే ప్రామాణిక సమయం", "CHAST": "చాథమ్ ప్రామాణిక సమయం", "NZST": "న్యూజిల్యాండ్ ప్రామాణిక సమయం", "AST": "అట్లాంటిక్ ప్రామాణిక సమయం", "OESZ": "తూర్పు యూరోపియన్ వేసవి సమయం", "HKT": "హాంకాంగ్ ప్రామాణిక సమయం", "HKST": "హాంకాంగ్ వేసవి సమయం", "HNPM": "సెయింట్ పియెర్ మరియు మిక్వెలాన్ ప్రామాణిక సమయం", "SAST": "దక్షిణ ఆఫ్రికా ప్రామాణిక సమయం", "SRT": "సూరినామ్ సమయం", "CDT": "మధ్యమ పగటి సమయం", "EDT": "తూర్పు పగటి సమయం", "HNT": "న్యూఫౌండ్ ల్యాండ్ ప్రామాణిక సమయం", "AEDT": "తూర్పు ఆస్ట్రేలియా పగటి సమయం", "HECU": "క్యూబా పగటి సమయం", "WESZ": "పశ్చిమ యూరోపియన్ వేసవి సమయం", "COT": "కొలంబియా ప్రామాణిక సమయం", "BT": "భూటాన్ సమయం", "AKST": "అలాస్కా ప్రామాణిక సమయం", "WARST": "పశ్చిమ అర్జెంటీనా వేసవి సమయం", "WAT": "పశ్చిమ ఆఫ్రికా ప్రామాణిక సమయం", "WAST": "పశ్చిమ ఆఫ్రికా వేసవి సమయం"}, + } +} + +// Locale returns the current translators string locale +func (te *te) Locale() string { + return te.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'te' +func (te *te) PluralsCardinal() []locales.PluralRule { + return te.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'te' +func (te *te) PluralsOrdinal() []locales.PluralRule { + return te.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'te' +func (te *te) PluralsRange() []locales.PluralRule { + return te.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'te' +func (te *te) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'te' +func (te *te) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'te' +func (te *te) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := te.CardinalPluralRule(num1, v1) + end := te.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (te *te) MonthAbbreviated(month time.Month) string { + return te.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (te *te) MonthsAbbreviated() []string { + return te.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (te *te) MonthNarrow(month time.Month) string { + return te.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (te *te) MonthsNarrow() []string { + return te.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (te *te) MonthWide(month time.Month) string { + return te.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (te *te) MonthsWide() []string { + return te.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (te *te) WeekdayAbbreviated(weekday time.Weekday) string { + return te.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (te *te) WeekdaysAbbreviated() []string { + return te.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (te *te) WeekdayNarrow(weekday time.Weekday) string { + return te.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (te *te) WeekdaysNarrow() []string { + return te.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (te *te) WeekdayShort(weekday time.Weekday) string { + return te.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (te *te) WeekdaysShort() []string { + return te.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (te *te) WeekdayWide(weekday time.Weekday) string { + return te.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (te *te) WeekdaysWide() []string { + return te.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'te' and handles both Whole and Real numbers based on 'v' +func (te *te) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, te.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, te.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, te.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'te' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (te *te) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, te.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, te.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, te.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'te' +func (te *te) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := te.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, te.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, te.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, te.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, te.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'te' +// in accounting notation. +func (te *te) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := te.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, te.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, te.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, te.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, te.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, te.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'te' +func (te *te) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'te' +func (te *te) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, te.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'te' +func (te *te) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, te.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'te' +func (te *te) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, te.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, te.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'te' +func (te *te) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, te.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, te.periodsAbbreviated[0]...) + } else { + b = append(b, te.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'te' +func (te *te) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, te.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, te.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, te.periodsAbbreviated[0]...) + } else { + b = append(b, te.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'te' +func (te *te) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, te.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, te.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, te.periodsAbbreviated[0]...) + } else { + b = append(b, te.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'te' +func (te *te) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, te.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, te.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, te.periodsAbbreviated[0]...) + } else { + b = append(b, te.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := te.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/te/te_test.go b/vendor/github.com/go-playground/locales/te/te_test.go new file mode 100644 index 0000000000..a8c203e1cd --- /dev/null +++ b/vendor/github.com/go-playground/locales/te/te_test.go @@ -0,0 +1,1120 @@ +package te + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "te" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/te_IN/te_IN.go b/vendor/github.com/go-playground/locales/te_IN/te_IN.go new file mode 100644 index 0000000000..2be3b03fb5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/te_IN/te_IN.go @@ -0,0 +1,670 @@ +package te_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type te_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'te_IN' locale +func New() locales.Translator { + return &te_IN{ + locale: "te_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "జన", "ఫిబ్ర", "మార్చి", "ఏప్రి", "మే", "జూన్", "జులై", "ఆగ", "సెప్టెం", "అక్టో", "నవం", "డిసెం"}, + monthsNarrow: []string{"", "జ", "ఫి", "మా", "ఏ", "మే", "జూ", "జు", "ఆ", "సె", "అ", "న", "డి"}, + monthsWide: []string{"", "జనవరి", "ఫిబ్రవరి", "మార్చి", "ఏప్రిల్", "మే", "జూన్", "జులై", "ఆగస్టు", "సెప్టెంబర్", "అక్టోబర్", "నవంబర్", "డిసెంబర్"}, + daysAbbreviated: []string{"ఆది", "సోమ", "మంగళ", "బుధ", "గురు", "శుక్ర", "శని"}, + daysNarrow: []string{"ఆ", "సో", "మ", "బు", "గు", "శు", "శ"}, + daysShort: []string{"ఆది", "సోమ", "మం", "బుధ", "గురు", "శుక్ర", "శని"}, + daysWide: []string{"ఆదివారం", "సోమవారం", "మంగళవారం", "బుధవారం", "గురువారం", "శుక్రవారం", "శనివారం"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"ఉ", "సా"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"క్రీపూ", "క్రీశ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"క్రీస్తు పూర్వం", "క్రీస్తు శకం"}, + timezones: map[string]string{"HECU": "క్యూబా పగటి సమయం", "OESZ": "తూర్పు యూరోపియన్ వేసవి సమయం", "MDT": "మకావ్ వేసవి సమయం", "HNNOMX": "వాయవ్య మెక్సికో ప్రామాణిక సమయం", "LHST": "లార్డ్ హోవ్ ప్రామాణిక సమయం", "TMT": "తుర్క్మెనిస్థాన్ ప్రామాణిక సమయం", "COST": "కొలంబియా వేసవి సమయం", "HNT": "న్యూఫౌండ్ ల్యాండ్ ప్రామాణిక సమయం", "HAT": "న్యూఫౌండ్ ల్యాండ్ పగటి సమయం", "NZST": "న్యూజిల్యాండ్ ప్రామాణిక సమయం", "NZDT": "న్యూజిల్యాండ్ పగటి వెలుతురు సమయం", "MYT": "మలేషియా సమయం", "WART": "పశ్చిమ అర్జెంటీనా ప్రామాణిక సమయం", "AEDT": "తూర్పు ఆస్ట్రేలియా పగటి సమయం", "EST": "తూర్పు ప్రామాణిక సమయం", "ChST": "చామర్రో ప్రామాణిక సమయం", "SRT": "సూరినామ్ సమయం", "VET": "వెనిజులా సమయం", "CLST": "చిలీ వేసవి సమయం", "ADT": "అట్లాంటిక్ పగటి సమయం", "ART": "అర్జెంటీనా ప్రామాణిక సమయం", "HNCU": "క్యూబా ప్రామాణిక సమయం", "ECT": "ఈక్వడార్ సమయం", "HNOG": "పశ్చిమ గ్రీన్\u200cల్యాండ్ ప్రామాణిక సమయం", "WEZ": "పశ్చిమ యూరోపియన్ ప్రామాణిక సమయం", "HNPMX": "మెక్సికన్ పసిఫిక్ ప్రామాణిక సమయం", "HEEG": "తూర్పు గ్రీన్\u200cల్యాండ్ వేసవి సమయం", "SAST": "దక్షిణ ఆఫ్రికా ప్రామాణిక సమయం", "∅∅∅": "అమెజాన్ వేసవి సమయం", "MEZ": "సెంట్రల్ యూరోపియన్ ప్రామాణిక సమయం", "ARST": "ఆర్జెంటీనా వేసవి సమయం", "ACDT": "ఆస్ట్రేలియా మధ్యమ పగటి సమయం", "HAST": "హవాయ్-అల్యూషియన్ ప్రామాణిక సమయం", "GFT": "ఫ్రెంచ్ గయానా సమయం", "HEPM": "సెయింట్ పియర్ మరియు మిక్వెలాన్ పగటి సమయం", "GYT": "గయానా సమయం", "AKST": "అలాస్కా ప్రామాణిక సమయం", "UYT": "ఉరుగ్వే ప్రామాణిక సమయం", "ACWDT": "మధ్యమ ఆస్ట్రేలియన్ పశ్చిమ పగటి సమయం", "JDT": "జపాన్ పగటి వెలుతురు సమయం", "CLT": "చిలీ ప్రామాణిక సమయం", "EDT": "తూర్పు పగటి సమయం", "WARST": "పశ్చిమ అర్జెంటీనా వేసవి సమయం", "WAT": "పశ్చిమ ఆఫ్రికా ప్రామాణిక సమయం", "HEPMX": "మెక్సికన్ పసిఫిక్ పగటి సమయం", "AWDT": "పశ్చిమ ఆస్ట్రేలియన్ పగటి సమయం", "SGT": "సింగపూర్ ప్రామాణిక సమయం", "IST": "భారతదేశ సమయం", "COT": "కొలంబియా ప్రామాణిక సమయం", "HENOMX": "వాయవ్య మెక్సికో పగటి సమయం", "HADT": "హవాయ్-అల్యూషియన్ పగటి వెలుతురు సమయం", "JST": "జపాన్ ప్రామాణిక సమయం", "HEOG": "పశ్చిమ గ్రీన్\u200cల్యాండ్ వేసవి సమయం", "HNEG": "తూర్పు గ్రీన్\u200cల్యాండ్ ప్రామాణిక సమయం", "MESZ": "సెంట్రల్ యూరోపియన్ వేసవి సమయం", "HKT": "హాంకాంగ్ ప్రామాణిక సమయం", "AKDT": "అలాస్కా పగటి సమయం", "BT": "భూటాన్ సమయం", "AEST": "తూర్పు ఆస్ట్రేలియా ప్రామాణిక సమయం", "HNPM": "సెయింట్ పియెర్ మరియు మిక్వెలాన్ ప్రామాణిక సమయం", "EAT": "తూర్పు ఆఫ్రికా సమయం", "PDT": "పసిఫిక్ పగటి సమయం", "ACWST": "మధ్యమ ఆస్ట్రేలియా పశ్చిమ ప్రామాణిక సమయం", "TMST": "తుర్క్మెనిస్థాన్ వేసవి సమయం", "MST": "మకావ్ ప్రామాణిక సమయం", "WIB": "పశ్చిమ ఇండోనేషియా సమయం", "WIT": "తూర్పు ఇండోనేషియా సమయం", "AWST": "పశ్చిమ ఆస్ట్రేలియన్ ప్రామాణిక సమయం", "CDT": "మధ్యమ పగటి సమయం", "OEZ": "తూర్పు యూరోపియన్ ప్రామాణిక సమయం", "WAST": "పశ్చిమ ఆఫ్రికా వేసవి సమయం", "WITA": "సెంట్రల్ ఇండోనేషియా సమయం", "LHDT": "లార్డ్ హోవ్ పగటి సమయం", "ACST": "ఆస్ట్రేలియా మధ్యమ ప్రామాణిక సమయం", "PST": "పసిఫిక్ ప్రామాణిక సమయం", "WESZ": "పశ్చిమ యూరోపియన్ వేసవి సమయం", "GMT": "గ్రీన్\u200cవిచ్ సగటు సమయం", "HKST": "హాంకాంగ్ వేసవి సమయం", "CHADT": "చాథమ్ పగటి వెలుతురు సమయం", "CAT": "సెంట్రల్ ఆఫ్రికా సమయం", "CST": "మధ్యమ ప్రామాణిక సమయం", "CHAST": "చాథమ్ ప్రామాణిక సమయం", "BOT": "బొలీవియా సమయం", "AST": "అట్లాంటిక్ ప్రామాణిక సమయం", "UYST": "ఉరుగ్వే వేసవి సమయం"}, + } +} + +// Locale returns the current translators string locale +func (te *te_IN) Locale() string { + return te.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'te_IN' +func (te *te_IN) PluralsCardinal() []locales.PluralRule { + return te.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'te_IN' +func (te *te_IN) PluralsOrdinal() []locales.PluralRule { + return te.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'te_IN' +func (te *te_IN) PluralsRange() []locales.PluralRule { + return te.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'te_IN' +func (te *te_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'te_IN' +func (te *te_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'te_IN' +func (te *te_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := te.CardinalPluralRule(num1, v1) + end := te.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (te *te_IN) MonthAbbreviated(month time.Month) string { + return te.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (te *te_IN) MonthsAbbreviated() []string { + return te.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (te *te_IN) MonthNarrow(month time.Month) string { + return te.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (te *te_IN) MonthsNarrow() []string { + return te.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (te *te_IN) MonthWide(month time.Month) string { + return te.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (te *te_IN) MonthsWide() []string { + return te.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (te *te_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return te.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (te *te_IN) WeekdaysAbbreviated() []string { + return te.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (te *te_IN) WeekdayNarrow(weekday time.Weekday) string { + return te.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (te *te_IN) WeekdaysNarrow() []string { + return te.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (te *te_IN) WeekdayShort(weekday time.Weekday) string { + return te.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (te *te_IN) WeekdaysShort() []string { + return te.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (te *te_IN) WeekdayWide(weekday time.Weekday) string { + return te.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (te *te_IN) WeekdaysWide() []string { + return te.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'te_IN' and handles both Whole and Real numbers based on 'v' +func (te *te_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, te.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, te.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, te.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'te_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (te *te_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, te.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, te.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, te.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'te_IN' +func (te *te_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := te.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, te.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, te.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, te.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, te.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'te_IN' +// in accounting notation. +func (te *te_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := te.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, te.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, te.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, te.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, te.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, te.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'te_IN' +func (te *te_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'te_IN' +func (te *te_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, te.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'te_IN' +func (te *te_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, te.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'te_IN' +func (te *te_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, te.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, te.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'te_IN' +func (te *te_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, te.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, te.periodsAbbreviated[0]...) + } else { + b = append(b, te.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'te_IN' +func (te *te_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, te.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, te.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, te.periodsAbbreviated[0]...) + } else { + b = append(b, te.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'te_IN' +func (te *te_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, te.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, te.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, te.periodsAbbreviated[0]...) + } else { + b = append(b, te.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'te_IN' +func (te *te_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, te.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, te.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, te.periodsAbbreviated[0]...) + } else { + b = append(b, te.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := te.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/te_IN/te_IN_test.go b/vendor/github.com/go-playground/locales/te_IN/te_IN_test.go new file mode 100644 index 0000000000..34096030d0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/te_IN/te_IN_test.go @@ -0,0 +1,1120 @@ +package te_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "te_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/teo/teo.go b/vendor/github.com/go-playground/locales/teo/teo.go new file mode 100644 index 0000000000..26dbd4f096 --- /dev/null +++ b/vendor/github.com/go-playground/locales/teo/teo.go @@ -0,0 +1,525 @@ +package teo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type teo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'teo' locale +func New() locales.Translator { + return &teo{ + locale: "teo", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "USh", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Rar", "Muk", "Kwa", "Dun", "Mar", "Mod", "Jol", "Ped", "Sok", "Tib", "Lab", "Poo"}, + monthsNarrow: []string{"", "R", "M", "K", "D", "M", "M", "J", "P", "S", "T", "L", "P"}, + monthsWide: []string{"", "Orara", "Omuk", "Okwamg’", "Odung’el", "Omaruk", "Omodok’king’ol", "Ojola", "Opedel", "Osokosokoma", "Otibar", "Olabor", "Opoo"}, + daysAbbreviated: []string{"Jum", "Bar", "Aar", "Uni", "Ung", "Kan", "Sab"}, + daysNarrow: []string{"J", "B", "A", "U", "U", "K", "S"}, + daysWide: []string{"Nakaejuma", "Nakaebarasa", "Nakaare", "Nakauni", "Nakaung’on", "Nakakany", "Nakasabiti"}, + periodsAbbreviated: []string{"Taparachu", "Ebongi"}, + periodsWide: []string{"Taparachu", "Ebongi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Christo", "Baada ya Christo"}, + timezones: map[string]string{"CST": "CST", "CDT": "CDT", "AWST": "AWST", "ADT": "ADT", "WESZ": "WESZ", "WARST": "WARST", "ACDT": "ACDT", "AEDT": "AEDT", "UYT": "UYT", "UYST": "UYST", "EAT": "EAT", "AEST": "AEST", "LHST": "LHST", "HNPMX": "HNPMX", "HKT": "HKT", "AKST": "AKST", "HECU": "HECU", "ACWDT": "ACWDT", "NZDT": "NZDT", "WAT": "WAT", "WITA": "WITA", "VET": "VET", "COST": "COST", "MDT": "MDT", "GFT": "GFT", "LHDT": "LHDT", "ACWST": "ACWST", "MEZ": "MEZ", "EST": "EST", "BT": "BT", "HNNOMX": "HNNOMX", "∅∅∅": "∅∅∅", "WIT": "WIT", "PDT": "PDT", "IST": "IST", "GMT": "GMT", "MYT": "MYT", "TMST": "TMST", "ACST": "ACST", "MST": "MST", "AST": "AST", "OEZ": "OEZ", "OESZ": "OESZ", "WAST": "WAST", "HAT": "HAT", "ECT": "ECT", "NZST": "NZST", "WART": "WART", "EDT": "EDT", "HENOMX": "HENOMX", "GYT": "GYT", "JST": "JST", "HEOG": "HEOG", "HNCU": "HNCU", "SGT": "SGT", "BOT": "BOT", "WIB": "WIB", "HNPM": "HNPM", "CAT": "CAT", "MESZ": "MESZ", "ART": "ART", "HNT": "HNT", "SAST": "SAST", "HAST": "HAST", "HNOG": "HNOG", "WEZ": "WEZ", "CLST": "CLST", "HEPM": "HEPM", "CHADT": "CHADT", "PST": "PST", "HADT": "HADT", "JDT": "JDT", "CLT": "CLT", "CHAST": "CHAST", "HEEG": "HEEG", "AKDT": "AKDT", "ChST": "ChST", "HEPMX": "HEPMX", "SRT": "SRT", "AWDT": "AWDT", "TMT": "TMT", "HNEG": "HNEG", "HKST": "HKST", "COT": "COT", "ARST": "ARST"}, + } +} + +// Locale returns the current translators string locale +func (teo *teo) Locale() string { + return teo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'teo' +func (teo *teo) PluralsCardinal() []locales.PluralRule { + return teo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'teo' +func (teo *teo) PluralsOrdinal() []locales.PluralRule { + return teo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'teo' +func (teo *teo) PluralsRange() []locales.PluralRule { + return teo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'teo' +func (teo *teo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'teo' +func (teo *teo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'teo' +func (teo *teo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (teo *teo) MonthAbbreviated(month time.Month) string { + return teo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (teo *teo) MonthsAbbreviated() []string { + return teo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (teo *teo) MonthNarrow(month time.Month) string { + return teo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (teo *teo) MonthsNarrow() []string { + return teo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (teo *teo) MonthWide(month time.Month) string { + return teo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (teo *teo) MonthsWide() []string { + return teo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (teo *teo) WeekdayAbbreviated(weekday time.Weekday) string { + return teo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (teo *teo) WeekdaysAbbreviated() []string { + return teo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (teo *teo) WeekdayNarrow(weekday time.Weekday) string { + return teo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (teo *teo) WeekdaysNarrow() []string { + return teo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (teo *teo) WeekdayShort(weekday time.Weekday) string { + return teo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (teo *teo) WeekdaysShort() []string { + return teo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (teo *teo) WeekdayWide(weekday time.Weekday) string { + return teo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (teo *teo) WeekdaysWide() []string { + return teo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'teo' and handles both Whole and Real numbers based on 'v' +func (teo *teo) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'teo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (teo *teo) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'teo' +func (teo *teo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := teo.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, teo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, teo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, teo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, teo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'teo' +// in accounting notation. +func (teo *teo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := teo.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, teo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, teo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, teo.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, teo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, teo.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'teo' +func (teo *teo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'teo' +func (teo *teo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'teo' +func (teo *teo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'teo' +func (teo *teo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, teo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'teo' +func (teo *teo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'teo' +func (teo *teo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'teo' +func (teo *teo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'teo' +func (teo *teo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := teo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/teo/teo_test.go b/vendor/github.com/go-playground/locales/teo/teo_test.go new file mode 100644 index 0000000000..441bcf4572 --- /dev/null +++ b/vendor/github.com/go-playground/locales/teo/teo_test.go @@ -0,0 +1,1120 @@ +package teo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "teo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/teo_KE/teo_KE.go b/vendor/github.com/go-playground/locales/teo_KE/teo_KE.go new file mode 100644 index 0000000000..851cde30fa --- /dev/null +++ b/vendor/github.com/go-playground/locales/teo_KE/teo_KE.go @@ -0,0 +1,525 @@ +package teo_KE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type teo_KE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'teo_KE' locale +func New() locales.Translator { + return &teo_KE{ + locale: "teo_KE", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "Ksh", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Rar", "Muk", "Kwa", "Dun", "Mar", "Mod", "Jol", "Ped", "Sok", "Tib", "Lab", "Poo"}, + monthsNarrow: []string{"", "R", "M", "K", "D", "M", "M", "J", "P", "S", "T", "L", "P"}, + monthsWide: []string{"", "Orara", "Omuk", "Okwamg’", "Odung’el", "Omaruk", "Omodok’king’ol", "Ojola", "Opedel", "Osokosokoma", "Otibar", "Olabor", "Opoo"}, + daysAbbreviated: []string{"Jum", "Bar", "Aar", "Uni", "Ung", "Kan", "Sab"}, + daysNarrow: []string{"J", "B", "A", "U", "U", "K", "S"}, + daysWide: []string{"Nakaejuma", "Nakaebarasa", "Nakaare", "Nakauni", "Nakaung’on", "Nakakany", "Nakasabiti"}, + periodsAbbreviated: []string{"Taparachu", "Ebongi"}, + periodsWide: []string{"Taparachu", "Ebongi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Christo", "Baada ya Christo"}, + timezones: map[string]string{"AWST": "AWST", "PDT": "PDT", "COST": "COST", "UYT": "UYT", "UYST": "UYST", "LHST": "LHST", "HECU": "HECU", "CST": "CST", "ECT": "ECT", "CAT": "CAT", "MDT": "MDT", "ART": "ART", "COT": "COT", "HNNOMX": "HNNOMX", "GFT": "GFT", "NZST": "NZST", "CLST": "CLST", "HKST": "HKST", "HNPM": "HNPM", "ACWST": "ACWST", "OEZ": "OEZ", "OESZ": "OESZ", "AKST": "AKST", "AEDT": "AEDT", "HAST": "HAST", "TMT": "TMT", "BT": "BT", "AEST": "AEST", "CDT": "CDT", "MESZ": "MESZ", "WESZ": "WESZ", "WART": "WART", "WITA": "WITA", "MYT": "MYT", "ACDT": "ACDT", "GYT": "GYT", "ACWDT": "ACWDT", "ADT": "ADT", "ChST": "ChST", "CHAST": "CHAST", "CHADT": "CHADT", "HADT": "HADT", "NZDT": "NZDT", "GMT": "GMT", "HNOG": "HNOG", "HEOG": "HEOG", "HKT": "HKT", "SAST": "SAST", "WIT": "WIT", "AST": "AST", "WAST": "WAST", "ACST": "ACST", "HNT": "HNT", "AKDT": "AKDT", "LHDT": "LHDT", "∅∅∅": "∅∅∅", "VET": "VET", "EDT": "EDT", "HNCU": "HNCU", "WIB": "WIB", "EST": "EST", "SRT": "SRT", "EAT": "EAT", "SGT": "SGT", "MEZ": "MEZ", "JST": "JST", "WEZ": "WEZ", "WAT": "WAT", "HENOMX": "HENOMX", "HAT": "HAT", "IST": "IST", "MST": "MST", "ARST": "ARST", "HEEG": "HEEG", "HNPMX": "HNPMX", "PST": "PST", "WARST": "WARST", "CLT": "CLT", "HNEG": "HNEG", "HEPMX": "HEPMX", "AWDT": "AWDT", "JDT": "JDT", "TMST": "TMST", "HEPM": "HEPM", "BOT": "BOT"}, + } +} + +// Locale returns the current translators string locale +func (teo *teo_KE) Locale() string { + return teo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'teo_KE' +func (teo *teo_KE) PluralsCardinal() []locales.PluralRule { + return teo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'teo_KE' +func (teo *teo_KE) PluralsOrdinal() []locales.PluralRule { + return teo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'teo_KE' +func (teo *teo_KE) PluralsRange() []locales.PluralRule { + return teo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'teo_KE' +func (teo *teo_KE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'teo_KE' +func (teo *teo_KE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'teo_KE' +func (teo *teo_KE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (teo *teo_KE) MonthAbbreviated(month time.Month) string { + return teo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (teo *teo_KE) MonthsAbbreviated() []string { + return teo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (teo *teo_KE) MonthNarrow(month time.Month) string { + return teo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (teo *teo_KE) MonthsNarrow() []string { + return teo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (teo *teo_KE) MonthWide(month time.Month) string { + return teo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (teo *teo_KE) MonthsWide() []string { + return teo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (teo *teo_KE) WeekdayAbbreviated(weekday time.Weekday) string { + return teo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (teo *teo_KE) WeekdaysAbbreviated() []string { + return teo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (teo *teo_KE) WeekdayNarrow(weekday time.Weekday) string { + return teo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (teo *teo_KE) WeekdaysNarrow() []string { + return teo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (teo *teo_KE) WeekdayShort(weekday time.Weekday) string { + return teo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (teo *teo_KE) WeekdaysShort() []string { + return teo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (teo *teo_KE) WeekdayWide(weekday time.Weekday) string { + return teo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (teo *teo_KE) WeekdaysWide() []string { + return teo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'teo_KE' and handles both Whole and Real numbers based on 'v' +func (teo *teo_KE) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'teo_KE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (teo *teo_KE) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'teo_KE' +func (teo *teo_KE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := teo.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, teo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, teo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, teo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, teo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'teo_KE' +// in accounting notation. +func (teo *teo_KE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := teo.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, teo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, teo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, teo.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, teo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, teo.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'teo_KE' +func (teo *teo_KE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'teo_KE' +func (teo *teo_KE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'teo_KE' +func (teo *teo_KE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'teo_KE' +func (teo *teo_KE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, teo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'teo_KE' +func (teo *teo_KE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'teo_KE' +func (teo *teo_KE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'teo_KE' +func (teo *teo_KE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'teo_KE' +func (teo *teo_KE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := teo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/teo_KE/teo_KE_test.go b/vendor/github.com/go-playground/locales/teo_KE/teo_KE_test.go new file mode 100644 index 0000000000..c5133fefc5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/teo_KE/teo_KE_test.go @@ -0,0 +1,1120 @@ +package teo_KE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "teo_KE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/teo_UG/teo_UG.go b/vendor/github.com/go-playground/locales/teo_UG/teo_UG.go new file mode 100644 index 0000000000..17ae4e5028 --- /dev/null +++ b/vendor/github.com/go-playground/locales/teo_UG/teo_UG.go @@ -0,0 +1,525 @@ +package teo_UG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type teo_UG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'teo_UG' locale +func New() locales.Translator { + return &teo_UG{ + locale: "teo_UG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Rar", "Muk", "Kwa", "Dun", "Mar", "Mod", "Jol", "Ped", "Sok", "Tib", "Lab", "Poo"}, + monthsNarrow: []string{"", "R", "M", "K", "D", "M", "M", "J", "P", "S", "T", "L", "P"}, + monthsWide: []string{"", "Orara", "Omuk", "Okwamg’", "Odung’el", "Omaruk", "Omodok’king’ol", "Ojola", "Opedel", "Osokosokoma", "Otibar", "Olabor", "Opoo"}, + daysAbbreviated: []string{"Jum", "Bar", "Aar", "Uni", "Ung", "Kan", "Sab"}, + daysNarrow: []string{"J", "B", "A", "U", "U", "K", "S"}, + daysWide: []string{"Nakaejuma", "Nakaebarasa", "Nakaare", "Nakauni", "Nakaung’on", "Nakakany", "Nakasabiti"}, + periodsAbbreviated: []string{"Taparachu", "Ebongi"}, + periodsWide: []string{"Taparachu", "Ebongi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Christo", "Baada ya Christo"}, + timezones: map[string]string{"HAST": "HAST", "ACWDT": "ACWDT", "WARST": "WARST", "AKST": "AKST", "AKDT": "AKDT", "ADT": "ADT", "WAST": "WAST", "UYT": "UYT", "CST": "CST", "WIT": "WIT", "∅∅∅": "∅∅∅", "WESZ": "WESZ", "WAT": "WAT", "HKST": "HKST", "HNPMX": "HNPMX", "BOT": "BOT", "OESZ": "OESZ", "MYT": "MYT", "CLST": "CLST", "BT": "BT", "HAT": "HAT", "WEZ": "WEZ", "MDT": "MDT", "HNNOMX": "HNNOMX", "JDT": "JDT", "HNEG": "HNEG", "ChST": "ChST", "LHDT": "LHDT", "SRT": "SRT", "CHADT": "CHADT", "GMT": "GMT", "EDT": "EDT", "HKT": "HKT", "EAT": "EAT", "PST": "PST", "MEZ": "MEZ", "HNOG": "HNOG", "ACST": "ACST", "HEEG": "HEEG", "LHST": "LHST", "GYT": "GYT", "HNCU": "HNCU", "WIB": "WIB", "TMT": "TMT", "TMST": "TMST", "ARST": "ARST", "EST": "EST", "CDT": "CDT", "HADT": "HADT", "ACWST": "ACWST", "NZDT": "NZDT", "MESZ": "MESZ", "WART": "WART", "COT": "COT", "HENOMX": "HENOMX", "UYST": "UYST", "HNPM": "HNPM", "SGT": "SGT", "JST": "JST", "OEZ": "OEZ", "AEDT": "AEDT", "HEPM": "HEPM", "SAST": "SAST", "CHAST": "CHAST", "ECT": "ECT", "CAT": "CAT", "ART": "ART", "HNT": "HNT", "WITA": "WITA", "HEPMX": "HEPMX", "AWST": "AWST", "IST": "IST", "AWDT": "AWDT", "AST": "AST", "ACDT": "ACDT", "AEST": "AEST", "GFT": "GFT", "PDT": "PDT", "VET": "VET", "CLT": "CLT", "MST": "MST", "COST": "COST", "HECU": "HECU", "NZST": "NZST", "HEOG": "HEOG"}, + } +} + +// Locale returns the current translators string locale +func (teo *teo_UG) Locale() string { + return teo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'teo_UG' +func (teo *teo_UG) PluralsCardinal() []locales.PluralRule { + return teo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'teo_UG' +func (teo *teo_UG) PluralsOrdinal() []locales.PluralRule { + return teo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'teo_UG' +func (teo *teo_UG) PluralsRange() []locales.PluralRule { + return teo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'teo_UG' +func (teo *teo_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'teo_UG' +func (teo *teo_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'teo_UG' +func (teo *teo_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (teo *teo_UG) MonthAbbreviated(month time.Month) string { + return teo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (teo *teo_UG) MonthsAbbreviated() []string { + return teo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (teo *teo_UG) MonthNarrow(month time.Month) string { + return teo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (teo *teo_UG) MonthsNarrow() []string { + return teo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (teo *teo_UG) MonthWide(month time.Month) string { + return teo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (teo *teo_UG) MonthsWide() []string { + return teo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (teo *teo_UG) WeekdayAbbreviated(weekday time.Weekday) string { + return teo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (teo *teo_UG) WeekdaysAbbreviated() []string { + return teo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (teo *teo_UG) WeekdayNarrow(weekday time.Weekday) string { + return teo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (teo *teo_UG) WeekdaysNarrow() []string { + return teo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (teo *teo_UG) WeekdayShort(weekday time.Weekday) string { + return teo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (teo *teo_UG) WeekdaysShort() []string { + return teo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (teo *teo_UG) WeekdayWide(weekday time.Weekday) string { + return teo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (teo *teo_UG) WeekdaysWide() []string { + return teo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'teo_UG' and handles both Whole and Real numbers based on 'v' +func (teo *teo_UG) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'teo_UG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (teo *teo_UG) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'teo_UG' +func (teo *teo_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := teo.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, teo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, teo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, teo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, teo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'teo_UG' +// in accounting notation. +func (teo *teo_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := teo.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, teo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, teo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, teo.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, teo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, teo.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'teo_UG' +func (teo *teo_UG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'teo_UG' +func (teo *teo_UG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'teo_UG' +func (teo *teo_UG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'teo_UG' +func (teo *teo_UG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, teo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, teo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'teo_UG' +func (teo *teo_UG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'teo_UG' +func (teo *teo_UG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'teo_UG' +func (teo *teo_UG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'teo_UG' +func (teo *teo_UG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, teo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, teo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := teo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/teo_UG/teo_UG_test.go b/vendor/github.com/go-playground/locales/teo_UG/teo_UG_test.go new file mode 100644 index 0000000000..efa8c95c10 --- /dev/null +++ b/vendor/github.com/go-playground/locales/teo_UG/teo_UG_test.go @@ -0,0 +1,1120 @@ +package teo_UG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "teo_UG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/th/th.go b/vendor/github.com/go-playground/locales/th/th.go new file mode 100644 index 0000000000..19f618bf83 --- /dev/null +++ b/vendor/github.com/go-playground/locales/th/th.go @@ -0,0 +1,584 @@ +package th + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type th struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'th' locale +func New() locales.Translator { + return &th{ + locale: "th", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."}, + monthsNarrow: []string{"", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."}, + monthsWide: []string{"", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"}, + daysAbbreviated: []string{"อา.", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส."}, + daysNarrow: []string{"อา", "จ", "อ", "พ", "พฤ", "ศ", "ส"}, + daysShort: []string{"อา.", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส."}, + daysWide: []string{"วันอาทิตย์", "วันจันทร์", "วันอังคาร", "วันพุธ", "วันพฤหัสบดี", "วันศุกร์", "วันเสาร์"}, + periodsAbbreviated: []string{"ก่อนเที่ยง", "หลังเที่ยง"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"ก่อนเที่ยง", "หลังเที่ยง"}, + erasAbbreviated: []string{"ปีก่อน ค.ศ.", "ค.ศ."}, + erasNarrow: []string{"ก่อน ค.ศ.", "ค.ศ."}, + erasWide: []string{"ปีก่อนคริสต์ศักราช", "คริสต์ศักราช"}, + timezones: map[string]string{"WIT": "เวลาอินโดนีเซียฝั่งตะวันออก", "OESZ": "เวลาฤดูร้อนยุโรปตะวันออก", "MST": "เวลามาตรฐานมาเก๊า", "GFT": "เวลาเฟรนช์เกียนา", "HADT": "เวลาออมแสงฮาวาย-อะลูเชียน", "AEDT": "เวลาออมแสงทางตะวันออกของออสเตรเลีย", "HAT": "เวลาออมแสงนิวฟันด์แลนด์", "LHST": "เวลามาตรฐานลอร์ดโฮว์", "CST": "เวลามาตรฐานตอนกลางในอเมริกาเหนือ", "HAST": "เวลามาตรฐานฮาวาย-อะลูเชียน", "MESZ": "เวลาฤดูร้อนยุโรปกลาง", "CLST": "เวลาฤดูร้อนชิลี", "WESZ": "เวลาฤดูร้อนยุโรปตะวันตก", "AST": "เวลามาตรฐานแอตแลนติก", "ARST": "เวลาฤดูร้อนอาร์เจนตินา", "GYT": "เวลากายอานา", "∅∅∅": "เวลาฤดูร้อนบราซิเลีย", "CHADT": "เวลาออมแสงแชทัม", "PST": "เวลามาตรฐานแปซิฟิกในอเมริกาเหนือ", "HNCU": "เวลามาตรฐานคิวบา", "ADT": "เวลาออมแสงของแอตแลนติก", "HENOMX": "เวลาออมแสงเม็กซิโกตะวันตกเฉียงเหนือ", "HNT": "เวลามาตรฐานนิวฟันด์แลนด์", "HEPM": "เวลาออมแสงของแซงปีแยร์และมีเกอลง", "CDT": "เวลาออมแสงตอนกลางในอเมริกาเหนือ", "SGT": "เวลาสิงคโปร์", "MYT": "เวลามาเลเซีย", "ART": "เวลามาตรฐานอาร์เจนตินา", "AKST": "เวลามาตรฐานอะแลสกา", "HEOG": "เวลาฤดูร้อนกรีนแลนด์ตะวันตก", "HKST": "เวลาฤดูร้อนฮ่องกง", "HNNOMX": "เวลามาตรฐานเม็กซิโกตะวันตกเฉียงเหนือ", "HEEG": "เวลาฤดูร้อนกรีนแลนด์ตะวันออก", "HNEG": "เวลามาตรฐานกรีนแลนด์ตะวันออก", "EAT": "เวลาแอฟริกาตะวันออก", "PDT": "เวลาออมแสงแปซิฟิกในอเมริกาเหนือ", "NZDT": "เวลาออมแสงนิวซีแลนด์", "MDT": "เวลาฤดูร้อนมาเก๊า", "AWST": "เวลามาตรฐานทางตะวันตกของออสเตรเลีย", "NZST": "เวลามาตรฐานนิวซีแลนด์", "EST": "เวลามาตรฐานทางตะวันออกในอเมริกาเหนือ", "ChST": "เวลาชามอร์โร", "CLT": "เวลามาตรฐานชิลี", "TMT": "เวลามาตรฐานเติร์กเมนิสถาน", "ACST": "เวลามาตรฐานทางตอนกลางของออสเตรเลีย", "UYST": "เวลาฤดูร้อนอุรุกวัย", "ECT": "เวลาเอกวาดอร์", "IST": "เวลาอินเดีย", "JST": "เวลามาตรฐานญี่ปุ่น", "OEZ": "เวลามาตรฐานยุโรปตะวันออก", "HNPMX": "เวลามาตรฐานแปซิฟิกเม็กซิโก", "HECU": "เวลาออมแสงของคิวบา", "WART": "เวลามาตรฐานทางตะวันตกของอาร์เจนตินา", "HKT": "เวลามาตรฐานฮ่องกง", "BT": "เวลาภูฏาน", "WAT": "เวลามาตรฐานแอฟริกาตะวันตก", "ACDT": "เวลาออมแสงทางตอนกลางของออสเตรเลีย", "UYT": "เวลามาตรฐานอุรุกวัย", "LHDT": "เวลาออมแสงลอร์ดโฮว์", "ACWST": "เวลามาตรฐานทางตะวันตกตอนกลางของออสเตรเลีย", "VET": "เวลาเวเนซุเอลา", "MEZ": "เวลามาตรฐานยุโรปกลาง", "WARST": "เวลาฤดูร้อนทางตะวันตกของอาร์เจนตินา", "WITA": "เวลาอินโดนีเซียตอนกลาง", "HNPM": "เวลามาตรฐานแซงปีแยร์และมีเกอลง", "HEPMX": "เวลาออมแสงแปซิฟิกเม็กซิโก", "SRT": "เวลาซูรินาเม", "WEZ": "เวลามาตรฐานยุโรปตะวันตก", "TMST": "เวลาฤดูร้อนเติร์กเมนิสถาน", "WAST": "เวลาฤดูร้อนแอฟริกาตะวันตก", "COST": "เวลาฤดูร้อนโคลอมเบีย", "AKDT": "เวลาออมแสงของอะแลสกา", "WIB": "เวลาอินโดนีเซียฝั่งตะวันตก", "CHAST": "เวลามาตรฐานแชทัม", "ACWDT": "เวลาออมแสงทางตะวันตกตอนกลางของออสเตรเลีย", "AEST": "เวลามาตรฐานทางตะวันออกของออสเตรเลีย", "COT": "เวลามาตรฐานโคลอมเบีย", "BOT": "เวลาโบลิเวีย", "CAT": "เวลาแอฟริกากลาง", "JDT": "เวลาออมแสงญี่ปุ่น", "GMT": "เวลามาตรฐานกรีนิช", "AWDT": "เวลาออมแสงทางตะวันตกของออสเตรเลีย", "HNOG": "เวลามาตรฐานกรีนแลนด์ตะวันตก", "EDT": "เวลาออมแสงทางตะวันออกในอเมริกาเหนือ", "SAST": "เวลาแอฟริกาใต้"}, + } +} + +// Locale returns the current translators string locale +func (th *th) Locale() string { + return th.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'th' +func (th *th) PluralsCardinal() []locales.PluralRule { + return th.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'th' +func (th *th) PluralsOrdinal() []locales.PluralRule { + return th.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'th' +func (th *th) PluralsRange() []locales.PluralRule { + return th.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'th' +func (th *th) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'th' +func (th *th) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'th' +func (th *th) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (th *th) MonthAbbreviated(month time.Month) string { + return th.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (th *th) MonthsAbbreviated() []string { + return th.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (th *th) MonthNarrow(month time.Month) string { + return th.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (th *th) MonthsNarrow() []string { + return th.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (th *th) MonthWide(month time.Month) string { + return th.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (th *th) MonthsWide() []string { + return th.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (th *th) WeekdayAbbreviated(weekday time.Weekday) string { + return th.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (th *th) WeekdaysAbbreviated() []string { + return th.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (th *th) WeekdayNarrow(weekday time.Weekday) string { + return th.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (th *th) WeekdaysNarrow() []string { + return th.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (th *th) WeekdayShort(weekday time.Weekday) string { + return th.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (th *th) WeekdaysShort() []string { + return th.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (th *th) WeekdayWide(weekday time.Weekday) string { + return th.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (th *th) WeekdaysWide() []string { + return th.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'th' and handles both Whole and Real numbers based on 'v' +func (th *th) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, th.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, th.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, th.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'th' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (th *th) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, th.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, th.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, th.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'th' +func (th *th) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := th.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, th.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, th.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, th.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, th.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'th' +// in accounting notation. +func (th *th) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := th.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, th.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, th.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, th.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, th.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, th.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'th' +func (th *th) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'th' +func (th *th) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, th.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'th' +func (th *th) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, th.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, th.erasAbbreviated[0]...) + } else { + b = append(b, th.erasAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'th' +func (th *th) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, th.daysWide[t.Weekday()]...) + b = append(b, []byte{0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0xe0, 0xb9, 0x88, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, th.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, th.erasWide[0]...) + } else { + b = append(b, th.erasWide[1]...) + } + + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'th' +func (th *th) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, th.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'th' +func (th *th) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, th.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, th.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'th' +func (th *th) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'th' +func (th *th) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := th.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/th/th_test.go b/vendor/github.com/go-playground/locales/th/th_test.go new file mode 100644 index 0000000000..e3b51e3030 --- /dev/null +++ b/vendor/github.com/go-playground/locales/th/th_test.go @@ -0,0 +1,1120 @@ +package th + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "th" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/th_TH/th_TH.go b/vendor/github.com/go-playground/locales/th_TH/th_TH.go new file mode 100644 index 0000000000..2fec96a80a --- /dev/null +++ b/vendor/github.com/go-playground/locales/th_TH/th_TH.go @@ -0,0 +1,584 @@ +package th_TH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type th_TH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'th_TH' locale +func New() locales.Translator { + return &th_TH{ + locale: "th_TH", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."}, + monthsNarrow: []string{"", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."}, + monthsWide: []string{"", "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"}, + daysAbbreviated: []string{"อา.", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส."}, + daysNarrow: []string{"อา", "จ", "อ", "พ", "พฤ", "ศ", "ส"}, + daysShort: []string{"อา.", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส."}, + daysWide: []string{"วันอาทิตย์", "วันจันทร์", "วันอังคาร", "วันพุธ", "วันพฤหัสบดี", "วันศุกร์", "วันเสาร์"}, + periodsAbbreviated: []string{"ก่อนเที่ยง", "หลังเที่ยง"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"ก่อนเที่ยง", "หลังเที่ยง"}, + erasAbbreviated: []string{"ปีก่อน ค.ศ.", "ค.ศ."}, + erasNarrow: []string{"ก่อน ค.ศ.", "ค.ศ."}, + erasWide: []string{"ปีก่อนคริสต์ศักราช", "คริสต์ศักราช"}, + timezones: map[string]string{"AKST": "เวลามาตรฐานอะแลสกา", "HEPMX": "เวลาออมแสงแปซิฟิกเม็กซิโก", "AWST": "เวลามาตรฐานทางตะวันตกของออสเตรเลีย", "HAST": "เวลามาตรฐานฮาวาย-อะลูเชียน", "OEZ": "เวลามาตรฐานยุโรปตะวันออก", "ART": "เวลามาตรฐานอาร์เจนตินา", "HNT": "เวลามาตรฐานนิวฟันด์แลนด์", "WITA": "เวลาอินโดนีเซียตอนกลาง", "ChST": "เวลาชามอร์โร", "PST": "เวลามาตรฐานแปซิฟิกในอเมริกาเหนือ", "CAT": "เวลาแอฟริกากลาง", "HNEG": "เวลามาตรฐานกรีนแลนด์ตะวันออก", "GFT": "เวลาเฟรนช์เกียนา", "HNPM": "เวลามาตรฐานแซงปีแยร์และมีเกอลง", "BOT": "เวลาโบลิเวีย", "JDT": "เวลาออมแสงญี่ปุ่น", "HAT": "เวลาออมแสงนิวฟันด์แลนด์", "CST": "เวลามาตรฐานตอนกลางในอเมริกาเหนือ", "CDT": "เวลาออมแสงตอนกลางในอเมริกาเหนือ", "ECT": "เวลาเอกวาดอร์", "HNOG": "เวลามาตรฐานกรีนแลนด์ตะวันตก", "OESZ": "เวลาฤดูร้อนยุโรปตะวันออก", "TMST": "เวลาฤดูร้อนเติร์กเมนิสถาน", "∅∅∅": "เวลาฤดูร้อนอาเกร", "AKDT": "เวลาออมแสงของอะแลสกา", "WIT": "เวลาอินโดนีเซียฝั่งตะวันออก", "CLT": "เวลามาตรฐานชิลี", "CLST": "เวลาฤดูร้อนชิลี", "ADT": "เวลาออมแสงของแอตแลนติก", "GMT": "เวลามาตรฐานกรีนิช", "HNNOMX": "เวลามาตรฐานเม็กซิโกตะวันตกเฉียงเหนือ", "LHST": "เวลามาตรฐานลอร์ดโฮว์", "SGT": "เวลาสิงคโปร์", "ACWDT": "เวลาออมแสงทางตะวันตกตอนกลางของออสเตรเลีย", "WARST": "เวลาฤดูร้อนทางตะวันตกของอาร์เจนตินา", "EST": "เวลามาตรฐานทางตะวันออกในอเมริกาเหนือ", "MDT": "เวลาออมแสงแถบภูเขาในอเมริกาเหนือ", "HNPMX": "เวลามาตรฐานแปซิฟิกเม็กซิโก", "ACWST": "เวลามาตรฐานทางตะวันตกตอนกลางของออสเตรเลีย", "TMT": "เวลามาตรฐานเติร์กเมนิสถาน", "HKST": "เวลาฤดูร้อนฮ่องกง", "SAST": "เวลาแอฟริกาใต้", "IST": "เวลาอินเดีย", "WAT": "เวลามาตรฐานแอฟริกาตะวันตก", "BT": "เวลาภูฏาน", "WESZ": "เวลาฤดูร้อนยุโรปตะวันตก", "VET": "เวลาเวเนซุเอลา", "HECU": "เวลาออมแสงของคิวบา", "AWDT": "เวลาออมแสงทางตะวันตกของออสเตรเลีย", "MESZ": "เวลาฤดูร้อนยุโรปกลาง", "COT": "เวลามาตรฐานโคลอมเบีย", "HEEG": "เวลาฤดูร้อนกรีนแลนด์ตะวันออก", "MST": "เวลามาตรฐานแถบภูเขาในอเมริกาเหนือ", "UYT": "เวลามาตรฐานอุรุกวัย", "HNCU": "เวลามาตรฐานคิวบา", "JST": "เวลามาตรฐานญี่ปุ่น", "ARST": "เวลาฤดูร้อนอาร์เจนตินา", "EDT": "เวลาออมแสงทางตะวันออกในอเมริกาเหนือ", "ACDT": "เวลาออมแสงทางตอนกลางของออสเตรเลีย", "HKT": "เวลามาตรฐานฮ่องกง", "NZST": "เวลามาตรฐานนิวซีแลนด์", "HADT": "เวลาออมแสงฮาวาย-อะลูเชียน", "AEST": "เวลามาตรฐานทางตะวันออกของออสเตรเลีย", "CHADT": "เวลาออมแสงแชทัม", "NZDT": "เวลาออมแสงนิวซีแลนด์", "MEZ": "เวลามาตรฐานยุโรปกลาง", "MYT": "เวลามาเลเซีย", "HEOG": "เวลาฤดูร้อนกรีนแลนด์ตะวันตก", "AST": "เวลามาตรฐานแอตแลนติก", "ACST": "เวลามาตรฐานทางตอนกลางของออสเตรเลีย", "EAT": "เวลาแอฟริกาตะวันออก", "PDT": "เวลาออมแสงแปซิฟิกในอเมริกาเหนือ", "UYST": "เวลาฤดูร้อนอุรุกวัย", "SRT": "เวลาซูรินาเม", "GYT": "เวลากายอานา", "WIB": "เวลาอินโดนีเซียฝั่งตะวันตก", "CHAST": "เวลามาตรฐานแชทัม", "WEZ": "เวลามาตรฐานยุโรปตะวันตก", "COST": "เวลาฤดูร้อนโคลอมเบีย", "AEDT": "เวลาออมแสงทางตะวันออกของออสเตรเลีย", "HEPM": "เวลาออมแสงของแซงปีแยร์และมีเกอลง", "LHDT": "เวลาออมแสงลอร์ดโฮว์", "WART": "เวลามาตรฐานทางตะวันตกของอาร์เจนตินา", "WAST": "เวลาฤดูร้อนแอฟริกาตะวันตก", "HENOMX": "เวลาออมแสงเม็กซิโกตะวันตกเฉียงเหนือ"}, + } +} + +// Locale returns the current translators string locale +func (th *th_TH) Locale() string { + return th.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'th_TH' +func (th *th_TH) PluralsCardinal() []locales.PluralRule { + return th.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'th_TH' +func (th *th_TH) PluralsOrdinal() []locales.PluralRule { + return th.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'th_TH' +func (th *th_TH) PluralsRange() []locales.PluralRule { + return th.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'th_TH' +func (th *th_TH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'th_TH' +func (th *th_TH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'th_TH' +func (th *th_TH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (th *th_TH) MonthAbbreviated(month time.Month) string { + return th.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (th *th_TH) MonthsAbbreviated() []string { + return th.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (th *th_TH) MonthNarrow(month time.Month) string { + return th.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (th *th_TH) MonthsNarrow() []string { + return th.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (th *th_TH) MonthWide(month time.Month) string { + return th.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (th *th_TH) MonthsWide() []string { + return th.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (th *th_TH) WeekdayAbbreviated(weekday time.Weekday) string { + return th.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (th *th_TH) WeekdaysAbbreviated() []string { + return th.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (th *th_TH) WeekdayNarrow(weekday time.Weekday) string { + return th.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (th *th_TH) WeekdaysNarrow() []string { + return th.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (th *th_TH) WeekdayShort(weekday time.Weekday) string { + return th.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (th *th_TH) WeekdaysShort() []string { + return th.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (th *th_TH) WeekdayWide(weekday time.Weekday) string { + return th.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (th *th_TH) WeekdaysWide() []string { + return th.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'th_TH' and handles both Whole and Real numbers based on 'v' +func (th *th_TH) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, th.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, th.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, th.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'th_TH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (th *th_TH) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, th.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, th.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, th.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'th_TH' +func (th *th_TH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := th.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, th.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, th.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, th.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, th.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'th_TH' +// in accounting notation. +func (th *th_TH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := th.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, th.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, th.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, th.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, th.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, th.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'th_TH' +func (th *th_TH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'th_TH' +func (th *th_TH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, th.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'th_TH' +func (th *th_TH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, th.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, th.erasAbbreviated[0]...) + } else { + b = append(b, th.erasAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'th_TH' +func (th *th_TH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, th.daysWide[t.Weekday()]...) + b = append(b, []byte{0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0xe0, 0xb9, 0x88, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, th.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, th.erasWide[0]...) + } else { + b = append(b, th.erasWide[1]...) + } + + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'th_TH' +func (th *th_TH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, th.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'th_TH' +func (th *th_TH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, th.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, th.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'th_TH' +func (th *th_TH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'th_TH' +func (th *th_TH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0xac, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x81, 0xe0, 0xb8, 0xb2, 0x20}...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0xe0, 0xb8, 0xa7, 0xe0, 0xb8, 0xb4, 0xe0, 0xb8, 0x99, 0xe0, 0xb8, 0xb2, 0xe0, 0xb8, 0x97, 0xe0, 0xb8, 0xb5, 0x20}...) + + tz, _ := t.Zone() + + if btz, ok := th.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/th_TH/th_TH_test.go b/vendor/github.com/go-playground/locales/th_TH/th_TH_test.go new file mode 100644 index 0000000000..8ab959e8a0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/th_TH/th_TH_test.go @@ -0,0 +1,1120 @@ +package th_TH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "th_TH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ti/ti.go b/vendor/github.com/go-playground/locales/ti/ti.go new file mode 100644 index 0000000000..c7fa8d464f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ti/ti.go @@ -0,0 +1,643 @@ +package ti + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ti struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ti' locale +func New() locales.Translator { + return &ti{ + locale: "ti", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "Br", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ጥሪ", "ለካ", "መጋ", "ሚያ", "ግን", "ሰነ", "ሓም", "ነሓ", "መስ", "ጥቅ", "ሕዳ", "ታሕ"}, + monthsNarrow: []string{"", "ጥ", "ለ", "መ", "ሚ", "ግ", "ሰ", "ሓ", "ነ", "መ", "ጥ", "ሕ", "ታ"}, + monthsWide: []string{"", "ጥሪ", "ለካቲት", "መጋቢት", "ሚያዝያ", "ግንቦት", "ሰነ", "ሓምለ", "ነሓሰ", "መስከረም", "ጥቅምቲ", "ሕዳር", "ታሕሳስ"}, + daysAbbreviated: []string{"ሰን", "ሰኑ", "ሰሉ", "ረቡ", "ሓሙ", "ዓር", "ቀዳ"}, + daysNarrow: []string{"ሰ", "ሰ", "ሰ", "ረ", "ሓ", "ዓ", "ቀ"}, + daysShort: []string{"ሰን", "ሰኑ", "ሰሉ", "ረቡ", "ሓሙ", "ዓር", "ቀዳ"}, + daysWide: []string{"ሰንበት", "ሰኑይ", "ሠሉስ", "ረቡዕ", "ኃሙስ", "ዓርቢ", "ቀዳም"}, + periodsAbbreviated: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"}, + periodsWide: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"}, + erasAbbreviated: []string{"ዓ/ዓ", "ዓ/ም"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ዓ/ዓ", "ዓመተ ምህረት"}, + timezones: map[string]string{"MESZ": "MESZ", "WART": "WART", "WARST": "WARST", "MDT": "MDT", "AKST": "AKST", "GYT": "GYT", "CHADT": "CHADT", "HAST": "HAST", "TMT": "TMT", "WAT": "WAT", "COT": "COT", "SAST": "SAST", "WITA": "WITA", "HEPM": "HEPM", "HECU": "HECU", "CDT": "CDT", "TMST": "TMST", "ART": "ART", "COST": "COST", "HAT": "HAT", "WIB": "WIB", "MYT": "MYT", "HEOG": "HEOG", "AEST": "AEST", "ChST": "ChST", "LHDT": "LHDT", "HNOG": "HNOG", "WAST": "WAST", "ECT": "ECT", "ACWST": "ACWST", "OESZ": "OESZ", "HNEG": "HNEG", "∅∅∅": "∅∅∅", "AEDT": "AEDT", "GFT": "GFT", "HNPMX": "HNPMX", "UYST": "UYST", "EAT": "EAT", "EDT": "EDT", "NZST": "NZST", "CAT": "CAT", "HKT": "HKT", "AKDT": "AKDT", "UYT": "UYT", "HNCU": "HNCU", "WIT": "WIT", "HADT": "HADT", "SGT": "SGT", "JST": "JST", "GMT": "GMT", "ACDT": "ACDT", "HEEG": "HEEG", "HNPM": "HNPM", "HEPMX": "HEPMX", "CST": "CST", "ADT": "ADT", "ARST": "ARST", "HKST": "HKST", "CHAST": "CHAST", "NZDT": "NZDT", "CLST": "CLST", "CLT": "CLT", "HNNOMX": "HNNOMX", "ACST": "ACST", "PDT": "PDT", "OEZ": "OEZ", "WESZ": "WESZ", "BT": "BT", "LHST": "LHST", "SRT": "SRT", "VET": "VET", "WEZ": "WEZ", "HNT": "HNT", "MEZ": "MEZ", "ACWDT": "ACWDT", "EST": "EST", "MST": "MST", "AWST": "AWST", "BOT": "BOT", "PST": "PST", "IST": "IST", "HENOMX": "HENOMX", "AWDT": "AWDT", "AST": "AST", "JDT": "JDT"}, + } +} + +// Locale returns the current translators string locale +func (ti *ti) Locale() string { + return ti.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ti' +func (ti *ti) PluralsCardinal() []locales.PluralRule { + return ti.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ti' +func (ti *ti) PluralsOrdinal() []locales.PluralRule { + return ti.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ti' +func (ti *ti) PluralsRange() []locales.PluralRule { + return ti.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ti' +func (ti *ti) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ti' +func (ti *ti) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ti' +func (ti *ti) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ti *ti) MonthAbbreviated(month time.Month) string { + return ti.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ti *ti) MonthsAbbreviated() []string { + return ti.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ti *ti) MonthNarrow(month time.Month) string { + return ti.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ti *ti) MonthsNarrow() []string { + return ti.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ti *ti) MonthWide(month time.Month) string { + return ti.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ti *ti) MonthsWide() []string { + return ti.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ti *ti) WeekdayAbbreviated(weekday time.Weekday) string { + return ti.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ti *ti) WeekdaysAbbreviated() []string { + return ti.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ti *ti) WeekdayNarrow(weekday time.Weekday) string { + return ti.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ti *ti) WeekdaysNarrow() []string { + return ti.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ti *ti) WeekdayShort(weekday time.Weekday) string { + return ti.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ti *ti) WeekdaysShort() []string { + return ti.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ti *ti) WeekdayWide(weekday time.Weekday) string { + return ti.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ti *ti) WeekdaysWide() []string { + return ti.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ti' and handles both Whole and Real numbers based on 'v' +func (ti *ti) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ti' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ti *ti) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ti.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ti' +func (ti *ti) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ti.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ti.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ti' +// in accounting notation. +func (ti *ti) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ti.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ti.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ti.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ti' +func (ti *ti) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ti' +func (ti *ti) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ti.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ti' +func (ti *ti) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ti.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ti' +func (ti *ti) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ti.daysWide[t.Weekday()]...) + b = append(b, []byte{0xe1, 0x8d, 0xa3, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ti.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xe1, 0x88, 0x98, 0xe1, 0x8b, 0x93, 0xe1, 0x88, 0x8d, 0xe1, 0x89, 0xb2, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, ti.erasWide[0]...) + } else { + b = append(b, ti.erasWide[1]...) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ti' +func (ti *ti) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ti' +func (ti *ti) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ti' +func (ti *ti) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ti' +func (ti *ti) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ti.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ti/ti_test.go b/vendor/github.com/go-playground/locales/ti/ti_test.go new file mode 100644 index 0000000000..1fdc058a9e --- /dev/null +++ b/vendor/github.com/go-playground/locales/ti/ti_test.go @@ -0,0 +1,1120 @@ +package ti + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ti" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ti_ER/ti_ER.go b/vendor/github.com/go-playground/locales/ti_ER/ti_ER.go new file mode 100644 index 0000000000..11b4a17c90 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ti_ER/ti_ER.go @@ -0,0 +1,643 @@ +package ti_ER + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ti_ER struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ti_ER' locale +func New() locales.Translator { + return &ti_ER{ + locale: "ti_ER", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "Nfk", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ጥሪ", "ለካ", "መጋ", "ሚያ", "ግን", "ሰነ", "ሓም", "ነሓ", "መስ", "ጥቅ", "ሕዳ", "ታሕ"}, + monthsNarrow: []string{"", "ጥ", "ለ", "መ", "ሚ", "ግ", "ሰ", "ሓ", "ነ", "መ", "ጥ", "ሕ", "ታ"}, + monthsWide: []string{"", "ጥሪ", "ለካቲት", "መጋቢት", "ሚያዝያ", "ግንቦት", "ሰነ", "ሓምለ", "ነሓሰ", "መስከረም", "ጥቅምቲ", "ሕዳር", "ታሕሳስ"}, + daysAbbreviated: []string{"ሰን", "ሰኑ", "ሰሉ", "ረቡ", "ሓሙ", "ዓር", "ቀዳ"}, + daysNarrow: []string{"ሰ", "ሰ", "ሰ", "ረ", "ሓ", "ዓ", "ቀ"}, + daysShort: []string{"ሰን", "ሰኑ", "ሰሉ", "ረቡ", "ሓሙ", "ዓር", "ቀዳ"}, + daysWide: []string{"ሰንበት", "ሰኑይ", "ሠሉስ", "ረቡዕ", "ኃሙስ", "ዓርቢ", "ቀዳም"}, + periodsAbbreviated: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"}, + periodsWide: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"ECT": "ECT", "CAT": "CAT", "COT": "COT", "WARST": "WARST", "ART": "ART", "HEPM": "HEPM", "CDT": "CDT", "ARST": "ARST", "BT": "BT", "LHDT": "LHDT", "WIB": "WIB", "PDT": "PDT", "NZDT": "NZDT", "MEZ": "MEZ", "CLST": "CLST", "CHADT": "CHADT", "HAT": "HAT", "AWDT": "AWDT", "HNEG": "HNEG", "MST": "MST", "AEST": "AEST", "HNPM": "HNPM", "HADT": "HADT", "IST": "IST", "JST": "JST", "WART": "WART", "MYT": "MYT", "TMT": "TMT", "GYT": "GYT", "PST": "PST", "∅∅∅": "∅∅∅", "VET": "VET", "AST": "AST", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "WITA": "WITA", "SRT": "SRT", "HNOG": "HNOG", "HEOG": "HEOG", "OESZ": "OESZ", "HKST": "HKST", "HEPMX": "HEPMX", "EAT": "EAT", "HNCU": "HNCU", "CLT": "CLT", "AKDT": "AKDT", "LHST": "LHST", "HNPMX": "HNPMX", "WAST": "WAST", "ACST": "ACST", "HNT": "HNT", "ACWST": "ACWST", "ACWDT": "ACWDT", "ADT": "ADT", "MDT": "MDT", "HENOMX": "HENOMX", "GFT": "GFT", "HECU": "HECU", "AEDT": "AEDT", "ChST": "ChST", "UYT": "UYT", "WIT": "WIT", "HAST": "HAST", "JDT": "JDT", "OEZ": "OEZ", "WESZ": "WESZ", "AKST": "AKST", "CHAST": "CHAST", "NZST": "NZST", "HKT": "HKT", "COST": "COST", "TMST": "TMST", "WAT": "WAT", "EST": "EST", "EDT": "EDT", "AWST": "AWST", "BOT": "BOT", "WEZ": "WEZ", "GMT": "GMT", "HEEG": "HEEG", "UYST": "UYST", "SGT": "SGT", "MESZ": "MESZ", "SAST": "SAST", "CST": "CST"}, + } +} + +// Locale returns the current translators string locale +func (ti *ti_ER) Locale() string { + return ti.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ti_ER' +func (ti *ti_ER) PluralsCardinal() []locales.PluralRule { + return ti.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ti_ER' +func (ti *ti_ER) PluralsOrdinal() []locales.PluralRule { + return ti.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ti_ER' +func (ti *ti_ER) PluralsRange() []locales.PluralRule { + return ti.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ti_ER' +func (ti *ti_ER) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ti_ER' +func (ti *ti_ER) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ti_ER' +func (ti *ti_ER) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ti *ti_ER) MonthAbbreviated(month time.Month) string { + return ti.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ti *ti_ER) MonthsAbbreviated() []string { + return ti.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ti *ti_ER) MonthNarrow(month time.Month) string { + return ti.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ti *ti_ER) MonthsNarrow() []string { + return ti.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ti *ti_ER) MonthWide(month time.Month) string { + return ti.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ti *ti_ER) MonthsWide() []string { + return ti.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ti *ti_ER) WeekdayAbbreviated(weekday time.Weekday) string { + return ti.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ti *ti_ER) WeekdaysAbbreviated() []string { + return ti.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ti *ti_ER) WeekdayNarrow(weekday time.Weekday) string { + return ti.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ti *ti_ER) WeekdaysNarrow() []string { + return ti.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ti *ti_ER) WeekdayShort(weekday time.Weekday) string { + return ti.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ti *ti_ER) WeekdaysShort() []string { + return ti.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ti *ti_ER) WeekdayWide(weekday time.Weekday) string { + return ti.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ti *ti_ER) WeekdaysWide() []string { + return ti.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ti_ER' and handles both Whole and Real numbers based on 'v' +func (ti *ti_ER) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ti_ER' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ti *ti_ER) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ti.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ti_ER' +func (ti *ti_ER) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ti.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ti.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ti_ER' +// in accounting notation. +func (ti *ti_ER) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ti.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ti.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ti.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ti_ER' +func (ti *ti_ER) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ti_ER' +func (ti *ti_ER) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ti.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ti_ER' +func (ti *ti_ER) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ti.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ti_ER' +func (ti *ti_ER) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ti.daysWide[t.Weekday()]...) + b = append(b, []byte{0xe1, 0x8d, 0xa3, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ti.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xe1, 0x88, 0x98, 0xe1, 0x8b, 0x93, 0xe1, 0x88, 0x8d, 0xe1, 0x89, 0xb2, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, ti.erasWide[0]...) + } else { + b = append(b, ti.erasWide[1]...) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ti_ER' +func (ti *ti_ER) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ti_ER' +func (ti *ti_ER) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ti_ER' +func (ti *ti_ER) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ti_ER' +func (ti *ti_ER) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ti.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ti_ER/ti_ER_test.go b/vendor/github.com/go-playground/locales/ti_ER/ti_ER_test.go new file mode 100644 index 0000000000..3d7ce4b909 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ti_ER/ti_ER_test.go @@ -0,0 +1,1120 @@ +package ti_ER + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ti_ER" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ti_ET/ti_ET.go b/vendor/github.com/go-playground/locales/ti_ET/ti_ET.go new file mode 100644 index 0000000000..e5c34e6abc --- /dev/null +++ b/vendor/github.com/go-playground/locales/ti_ET/ti_ET.go @@ -0,0 +1,643 @@ +package ti_ET + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ti_ET struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ti_ET' locale +func New() locales.Translator { + return &ti_ET{ + locale: "ti_ET", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "ጥሪ", "ለካ", "መጋ", "ሚያ", "ግን", "ሰነ", "ሓም", "ነሓ", "መስ", "ጥቅ", "ሕዳ", "ታሕ"}, + monthsNarrow: []string{"", "ጥ", "ለ", "መ", "ሚ", "ግ", "ሰ", "ሓ", "ነ", "መ", "ጥ", "ሕ", "ታ"}, + monthsWide: []string{"", "ጥሪ", "ለካቲት", "መጋቢት", "ሚያዝያ", "ግንቦት", "ሰነ", "ሓምለ", "ነሓሰ", "መስከረም", "ጥቅምቲ", "ሕዳር", "ታሕሳስ"}, + daysAbbreviated: []string{"ሰን", "ሰኑ", "ሰሉ", "ረቡ", "ሓሙ", "ዓር", "ቀዳ"}, + daysNarrow: []string{"ሰ", "ሰ", "ሰ", "ረ", "ሓ", "ዓ", "ቀ"}, + daysShort: []string{"ሰን", "ሰኑ", "ሰሉ", "ረቡ", "ሓሙ", "ዓር", "ቀዳ"}, + daysWide: []string{"ሰንበት", "ሰኑይ", "ሠሉስ", "ረቡዕ", "ኃሙስ", "ዓርቢ", "ቀዳም"}, + periodsAbbreviated: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"}, + periodsWide: []string{"ንጉሆ ሰዓተ", "ድሕር ሰዓት"}, + erasAbbreviated: []string{"ዓ/ዓ", "ዓ/ም"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ዓ/ዓ", "ዓመተ ምህረት"}, + timezones: map[string]string{"ACDT": "ACDT", "HNT": "HNT", "HNPM": "HNPM", "SGT": "SGT", "WART": "WART", "MDT": "MDT", "GFT": "GFT", "WIT": "WIT", "MYT": "MYT", "ECT": "ECT", "CAT": "CAT", "UYST": "UYST", "HEPMX": "HEPMX", "HADT": "HADT", "NZST": "NZST", "∅∅∅": "∅∅∅", "WAST": "WAST", "SAST": "SAST", "IST": "IST", "BT": "BT", "AKDT": "AKDT", "HEPM": "HEPM", "TMT": "TMT", "EDT": "EDT", "HAT": "HAT", "AKST": "AKST", "EST": "EST", "OEZ": "OEZ", "CLT": "CLT", "CLST": "CLST", "TMST": "TMST", "HKST": "HKST", "HNEG": "HNEG", "WITA": "WITA", "HAST": "HAST", "GYT": "GYT", "ADT": "ADT", "WAT": "WAT", "AWST": "AWST", "JDT": "JDT", "MEZ": "MEZ", "LHDT": "LHDT", "HNPMX": "HNPMX", "HNCU": "HNCU", "CST": "CST", "NZDT": "NZDT", "HENOMX": "HENOMX", "SRT": "SRT", "WIB": "WIB", "ACWST": "ACWST", "MST": "MST", "ARST": "ARST", "HKT": "HKT", "COT": "COT", "HNNOMX": "HNNOMX", "AEST": "AEST", "AEDT": "AEDT", "OESZ": "OESZ", "CDT": "CDT", "HEOG": "HEOG", "CHAST": "CHAST", "ACWDT": "ACWDT", "MESZ": "MESZ", "WEZ": "WEZ", "WARST": "WARST", "LHST": "LHST", "PDT": "PDT", "HNOG": "HNOG", "AST": "AST", "ChST": "ChST", "EAT": "EAT", "JST": "JST", "COST": "COST", "HECU": "HECU", "AWDT": "AWDT", "BOT": "BOT", "PST": "PST", "WESZ": "WESZ", "GMT": "GMT", "ART": "ART", "ACST": "ACST", "HEEG": "HEEG", "UYT": "UYT", "CHADT": "CHADT", "VET": "VET"}, + } +} + +// Locale returns the current translators string locale +func (ti *ti_ET) Locale() string { + return ti.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ti_ET' +func (ti *ti_ET) PluralsCardinal() []locales.PluralRule { + return ti.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ti_ET' +func (ti *ti_ET) PluralsOrdinal() []locales.PluralRule { + return ti.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ti_ET' +func (ti *ti_ET) PluralsRange() []locales.PluralRule { + return ti.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ti_ET' +func (ti *ti_ET) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n >= 0 && n <= 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ti_ET' +func (ti *ti_ET) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ti_ET' +func (ti *ti_ET) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ti *ti_ET) MonthAbbreviated(month time.Month) string { + return ti.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ti *ti_ET) MonthsAbbreviated() []string { + return ti.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ti *ti_ET) MonthNarrow(month time.Month) string { + return ti.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ti *ti_ET) MonthsNarrow() []string { + return ti.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ti *ti_ET) MonthWide(month time.Month) string { + return ti.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ti *ti_ET) MonthsWide() []string { + return ti.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ti *ti_ET) WeekdayAbbreviated(weekday time.Weekday) string { + return ti.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ti *ti_ET) WeekdaysAbbreviated() []string { + return ti.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ti *ti_ET) WeekdayNarrow(weekday time.Weekday) string { + return ti.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ti *ti_ET) WeekdaysNarrow() []string { + return ti.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ti *ti_ET) WeekdayShort(weekday time.Weekday) string { + return ti.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ti *ti_ET) WeekdaysShort() []string { + return ti.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ti *ti_ET) WeekdayWide(weekday time.Weekday) string { + return ti.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ti *ti_ET) WeekdaysWide() []string { + return ti.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ti_ET' and handles both Whole and Real numbers based on 'v' +func (ti *ti_ET) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ti_ET' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ti *ti_ET) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ti.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ti_ET' +func (ti *ti_ET) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ti.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ti.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ti.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ti_ET' +// in accounting notation. +func (ti *ti_ET) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ti.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ti.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ti.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ti.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ti.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ti_ET' +func (ti *ti_ET) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ti_ET' +func (ti *ti_ET) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ti.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2d}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ti_ET' +func (ti *ti_ET) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ti.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ti_ET' +func (ti *ti_ET) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ti.daysWide[t.Weekday()]...) + b = append(b, []byte{0xe1, 0x8d, 0xa3, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ti.monthsWide[t.Month()]...) + b = append(b, []byte{0x20, 0xe1, 0x88, 0x98, 0xe1, 0x8b, 0x93, 0xe1, 0x88, 0x8d, 0xe1, 0x89, 0xb2, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + + if t.Year() < 0 { + b = append(b, ti.erasWide[0]...) + } else { + b = append(b, ti.erasWide[1]...) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ti_ET' +func (ti *ti_ET) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ti_ET' +func (ti *ti_ET) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ti_ET' +func (ti *ti_ET) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ti_ET' +func (ti *ti_ET) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ti.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ti.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ti.periodsAbbreviated[0]...) + } else { + b = append(b, ti.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ti.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ti_ET/ti_ET_test.go b/vendor/github.com/go-playground/locales/ti_ET/ti_ET_test.go new file mode 100644 index 0000000000..51928f6686 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ti_ET/ti_ET_test.go @@ -0,0 +1,1120 @@ +package ti_ET + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ti_ET" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/tk/tk.go b/vendor/github.com/go-playground/locales/tk/tk.go new file mode 100644 index 0000000000..38566b6d52 --- /dev/null +++ b/vendor/github.com/go-playground/locales/tk/tk.go @@ -0,0 +1,592 @@ +package tk + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type tk struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'tk' locale +func New() locales.Translator { + return &tk{ + locale: "tk", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ýan", "few", "mart", "apr", "maý", "iýun", "iýul", "awg", "sen", "okt", "noý", "dek"}, + monthsNarrow: []string{"", "Ý", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "ýanwar", "fewral", "mart", "aprel", "maý", "iýun", "iýul", "awgust", "sentýabr", "oktýabr", "noýabr", "dekabr"}, + daysAbbreviated: []string{"ýb", "db", "sb", "çb", "pb", "an", "şb"}, + daysNarrow: []string{"Ý", "D", "S", "Ç", "P", "A", "Ş"}, + daysWide: []string{"ýekşenbe", "duşenbe", "sişenbe", "çarşenbe", "penşenbe", "anna", "şenbe"}, + timezones: map[string]string{"BOT": "Boliwiýa", "HADT": "Gawaý-Aleut, tomusky wagt", "CLT": "Çili, standart wagt", "TMST": "Türkmenistan, tomusky wagt", "HKST": "Gonkong, tomusky wagt", "∅∅∅": "Peru, tomusky wagt", "GYT": "Gaýana", "AWDT": "Günbatar Awstraliýa, tomusky wagt", "VET": "Wenesuela", "CLST": "Çili, tomusky wagt", "ADT": "Atlantika, tomusky wagt", "OEZ": "Gündogar Ýewropa, standart wagt", "WAST": "Günbatar Afrika, tomusky wagt", "CST": "Merkezi Amerika, standart wagt", "WIT": "Gündogar Indoneziýa", "OESZ": "Gündogar Ýewropa, tomusky wagt", "GMT": "Grinwiç boýunça orta wagt", "AKST": "Alýaska, standart wagt", "HEPM": "Sen Pýer we Mikelon, tomusky wagt", "JST": "Ýaponiýa, standart wagt", "HEOG": "Günbatar Grenlandiýa, tomusky wagt", "MST": "MST", "ART": "Argentina, standart wagt", "ARST": "Argentina, tomusky wagt", "WEZ": "Günbatar Ýewropa, standart wagt", "HENOMX": "D.g.-G.b. Meksika, tomusky wagt", "HEPMX": "Meksikan Ýuwaş umman, tomusky wagt", "HNCU": "Kuba, standart wagt", "MDT": "MDT", "SAST": "Günorta Afrika, standart wagt", "HAST": "Gawaý-Aleut, standart wagt", "ECT": "Ekwador", "UYST": "Urugwaý, tomusky wagt", "AWST": "Günbatar Awstraliýa, standart wagt", "CHAST": "Çatem, standart wagt", "SGT": "Singapur, standart wagt", "WAT": "Günbatar Afrika, standart wagt", "UYT": "Urugwaý, standart wagt", "LHDT": "Lord-Hau, tomusky wagt", "EST": "Günorta Amerika, standart wagt", "WIB": "Günbatar Indoneziýa", "WART": "Günbatar Argentina, standart wagt", "ACST": "Merkezi Awstraliýa, standart wagt", "CHADT": "Çatem, tomusky wagt", "NZDT": "Täze Zelandiýa, tomusky wagt", "AEDT": "Gündogar Awstraliýa, tomusky wagt", "HNPMX": "Meksikan Ýuwaş umman, standart wagt", "CAT": "Merkezi Afrika", "MYT": "Malaýziýa", "EDT": "Günorta Amerika, tomusky wagt", "COT": "Kolumbiýa, standart wagt", "BT": "Butan", "MEZ": "Merkezi Ýewropa, standart wagt", "WARST": "Günbatar Argentina, tomusky wagt", "AST": "Atlantika, standart wagt", "WITA": "Merkezi Indoneziýa", "AKDT": "Alýaska, tomusky wagt", "LHST": "Lord-Hau, standart wagt", "SRT": "Surinam", "EAT": "Gündogar Afrika", "ACDT": "Merkezi Awstraliýa, tomusky wagt", "HAT": "Nýufaundlend, tomusky wagt", "HEEG": "Gündogar Grenlandiýa, tomusky wagt", "GFT": "Fransuz Gwiana", "ACWDT": "Merkezi Awstraliýa, günbatar tarap, tomusky wagt", "NZST": "Täze Zelandiýa, standart wagt", "HNNOMX": "D.g.-G.b. Meksika, standart wagt", "HNT": "Nýufaundlend, standart wagt", "HNEG": "Gündogar Grenlandiýa, standart wagt", "MESZ": "Merkezi Ýewropa, tomusky wagt", "JDT": "Ýaponiýa, tomusky wagt", "COST": "Kolumbiýa, tomusky wagt", "HNPM": "Sen Pýer we Mikelon, standart wagt", "PST": "Ýuwaş umman, standart wagt", "IST": "Hindistan", "ACWST": "Merkezi Awstraliýa, günbatar tarap, standart wagt", "WESZ": "Günbatar Ýewropa, tomusky wagt", "TMT": "Türkmenistan, standart wagt", "HKT": "Gonkong, standart wagt", "ChST": "Çamorro", "PDT": "Ýuwaş umman, tomusky wagt", "HNOG": "Günbatar Grenlandiýa, standart wagt", "AEST": "Gündogar Awstraliýa, standart wagt", "HECU": "Kuba, tomusky wagt", "CDT": "Merkezi Amerika, tomusky wagt"}, + } +} + +// Locale returns the current translators string locale +func (tk *tk) Locale() string { + return tk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'tk' +func (tk *tk) PluralsCardinal() []locales.PluralRule { + return tk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'tk' +func (tk *tk) PluralsOrdinal() []locales.PluralRule { + return tk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'tk' +func (tk *tk) PluralsRange() []locales.PluralRule { + return tk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tk' +func (tk *tk) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tk' +func (tk *tk) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tk' +func (tk *tk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (tk *tk) MonthAbbreviated(month time.Month) string { + return tk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (tk *tk) MonthsAbbreviated() []string { + return tk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (tk *tk) MonthNarrow(month time.Month) string { + return tk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (tk *tk) MonthsNarrow() []string { + return tk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (tk *tk) MonthWide(month time.Month) string { + return tk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (tk *tk) MonthsWide() []string { + return tk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (tk *tk) WeekdayAbbreviated(weekday time.Weekday) string { + return tk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (tk *tk) WeekdaysAbbreviated() []string { + return tk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (tk *tk) WeekdayNarrow(weekday time.Weekday) string { + return tk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (tk *tk) WeekdaysNarrow() []string { + return tk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (tk *tk) WeekdayShort(weekday time.Weekday) string { + return tk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (tk *tk) WeekdaysShort() []string { + return tk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (tk *tk) WeekdayWide(weekday time.Weekday) string { + return tk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (tk *tk) WeekdaysWide() []string { + return tk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'tk' and handles both Whole and Real numbers based on 'v' +func (tk *tk) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tk.group) - 1; j >= 0; j-- { + b = append(b, tk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'tk' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (tk *tk) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, tk.percentSuffix...) + + b = append(b, tk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tk' +func (tk *tk) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tk.group) - 1; j >= 0; j-- { + b = append(b, tk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, tk.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tk' +// in accounting notation. +func (tk *tk) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tk.group) - 1; j >= 0; j-- { + b = append(b, tk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, tk.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, tk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, tk.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'tk' +func (tk *tk) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'tk' +func (tk *tk) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tk.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'tk' +func (tk *tk) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'tk' +func (tk *tk) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, tk.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'tk' +func (tk *tk) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'tk' +func (tk *tk) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'tk' +func (tk *tk) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'tk' +func (tk *tk) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := tk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/tk/tk_test.go b/vendor/github.com/go-playground/locales/tk/tk_test.go new file mode 100644 index 0000000000..489eb98b85 --- /dev/null +++ b/vendor/github.com/go-playground/locales/tk/tk_test.go @@ -0,0 +1,1120 @@ +package tk + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "tk" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/tk_TM/tk_TM.go b/vendor/github.com/go-playground/locales/tk_TM/tk_TM.go new file mode 100644 index 0000000000..79079363df --- /dev/null +++ b/vendor/github.com/go-playground/locales/tk_TM/tk_TM.go @@ -0,0 +1,592 @@ +package tk_TM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type tk_TM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'tk_TM' locale +func New() locales.Translator { + return &tk_TM{ + locale: "tk_TM", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "ýan", "few", "mart", "apr", "maý", "iýun", "iýul", "awg", "sen", "okt", "noý", "dek"}, + monthsNarrow: []string{"", "Ý", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "ýanwar", "fewral", "mart", "aprel", "maý", "iýun", "iýul", "awgust", "sentýabr", "oktýabr", "noýabr", "dekabr"}, + daysAbbreviated: []string{"ýb", "db", "sb", "çb", "pb", "an", "şb"}, + daysNarrow: []string{"Ý", "D", "S", "Ç", "P", "A", "Ş"}, + daysWide: []string{"ýekşenbe", "duşenbe", "sişenbe", "çarşenbe", "penşenbe", "anna", "şenbe"}, + timezones: map[string]string{"PDT": "Ýuwaş umman, tomusky wagt", "WITA": "Merkezi Indoneziýa", "AEST": "Gündogar Awstraliýa, standart wagt", "BOT": "Boliwiýa", "CLT": "Çili, standart wagt", "SRT": "Surinam", "LHDT": "Lord-Hau, tomusky wagt", "OEZ": "Gündogar Ýewropa, standart wagt", "ACST": "Merkezi Awstraliýa, standart wagt", "HENOMX": "D.g.-G.b. Meksika, tomusky wagt", "HAT": "Nýufaundlend, tomusky wagt", "HNEG": "Gündogar Grenlandiýa, standart wagt", "GFT": "Fransuz Gwiana", "CST": "Merkezi Amerika, standart wagt", "AWST": "Günbatar Awstraliýa, standart wagt", "ECT": "Ekwador", "MYT": "Malaýziýa", "WIT": "Gündogar Indoneziýa", "ADT": "Atlantika, tomusky wagt", "ARST": "Argentina, tomusky wagt", "EST": "Günorta Amerika, standart wagt", "HKST": "Gonkong, tomusky wagt", "HNPM": "Sen Pýer we Mikelon, standart wagt", "CHADT": "Çatem, tomusky wagt", "MESZ": "Merkezi Ýewropa, tomusky wagt", "WEZ": "Günbatar Ýewropa, standart wagt", "HKT": "Gonkong, standart wagt", "HADT": "Gawaý-Aleut, tomusky wagt", "MEZ": "Merkezi Ýewropa, standart wagt", "BT": "Butan", "HEEG": "Gündogar Grenlandiýa, tomusky wagt", "AEDT": "Gündogar Awstraliýa, tomusky wagt", "AWDT": "Günbatar Awstraliýa, tomusky wagt", "JDT": "Ýaponiýa, tomusky wagt", "WARST": "Günbatar Argentina, tomusky wagt", "GMT": "Grinwiç boýunça orta wagt", "PST": "Ýuwaş umman, standart wagt", "AST": "Atlantika, standart wagt", "WAST": "Günbatar Afrika, tomusky wagt", "TMST": "Türkmenistan, tomusky wagt", "MST": "MST", "COST": "Kolumbiýa, tomusky wagt", "UYT": "Urugwaý, standart wagt", "EAT": "Gündogar Afrika", "HAST": "Gawaý-Aleut, standart wagt", "CLST": "Çili, tomusky wagt", "WESZ": "Günbatar Ýewropa, tomusky wagt", "HEPM": "Sen Pýer we Mikelon, tomusky wagt", "HECU": "Kuba, tomusky wagt", "WIB": "Günbatar Indoneziýa", "CHAST": "Çatem, standart wagt", "ACWDT": "Merkezi Awstraliýa, günbatar tarap, tomusky wagt", "EDT": "Günorta Amerika, tomusky wagt", "ACDT": "Merkezi Awstraliýa, tomusky wagt", "ChST": "Çamorro", "HNPMX": "Meksikan Ýuwaş umman, standart wagt", "SGT": "Singapur, standart wagt", "CAT": "Merkezi Afrika", "ACWST": "Merkezi Awstraliýa, günbatar tarap, standart wagt", "ART": "Argentina, standart wagt", "COT": "Kolumbiýa, standart wagt", "AKST": "Alýaska, standart wagt", "SAST": "Günorta Afrika, standart wagt", "∅∅∅": "Braziliýa, tomusky wagt", "NZDT": "Täze Zelandiýa, tomusky wagt", "OESZ": "Gündogar Ýewropa, tomusky wagt", "UYST": "Urugwaý, tomusky wagt", "TMT": "Türkmenistan, standart wagt", "MDT": "MDT", "WAT": "Günbatar Afrika, standart wagt", "HNNOMX": "D.g.-G.b. Meksika, standart wagt", "IST": "Hindistan", "JST": "Ýaponiýa, standart wagt", "HNOG": "Günbatar Grenlandiýa, standart wagt", "HEOG": "Günbatar Grenlandiýa, tomusky wagt", "AKDT": "Alýaska, tomusky wagt", "LHST": "Lord-Hau, standart wagt", "VET": "Wenesuela", "WART": "Günbatar Argentina, standart wagt", "HNT": "Nýufaundlend, standart wagt", "HEPMX": "Meksikan Ýuwaş umman, tomusky wagt", "GYT": "Gaýana", "HNCU": "Kuba, standart wagt", "CDT": "Merkezi Amerika, tomusky wagt", "NZST": "Täze Zelandiýa, standart wagt"}, + } +} + +// Locale returns the current translators string locale +func (tk *tk_TM) Locale() string { + return tk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'tk_TM' +func (tk *tk_TM) PluralsCardinal() []locales.PluralRule { + return tk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'tk_TM' +func (tk *tk_TM) PluralsOrdinal() []locales.PluralRule { + return tk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'tk_TM' +func (tk *tk_TM) PluralsRange() []locales.PluralRule { + return tk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tk_TM' +func (tk *tk_TM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tk_TM' +func (tk *tk_TM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tk_TM' +func (tk *tk_TM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (tk *tk_TM) MonthAbbreviated(month time.Month) string { + return tk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (tk *tk_TM) MonthsAbbreviated() []string { + return tk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (tk *tk_TM) MonthNarrow(month time.Month) string { + return tk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (tk *tk_TM) MonthsNarrow() []string { + return tk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (tk *tk_TM) MonthWide(month time.Month) string { + return tk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (tk *tk_TM) MonthsWide() []string { + return tk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (tk *tk_TM) WeekdayAbbreviated(weekday time.Weekday) string { + return tk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (tk *tk_TM) WeekdaysAbbreviated() []string { + return tk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (tk *tk_TM) WeekdayNarrow(weekday time.Weekday) string { + return tk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (tk *tk_TM) WeekdaysNarrow() []string { + return tk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (tk *tk_TM) WeekdayShort(weekday time.Weekday) string { + return tk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (tk *tk_TM) WeekdaysShort() []string { + return tk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (tk *tk_TM) WeekdayWide(weekday time.Weekday) string { + return tk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (tk *tk_TM) WeekdaysWide() []string { + return tk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'tk_TM' and handles both Whole and Real numbers based on 'v' +func (tk *tk_TM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tk.group) - 1; j >= 0; j-- { + b = append(b, tk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'tk_TM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (tk *tk_TM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, tk.percentSuffix...) + + b = append(b, tk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tk_TM' +func (tk *tk_TM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tk.group) - 1; j >= 0; j-- { + b = append(b, tk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, tk.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tk_TM' +// in accounting notation. +func (tk *tk_TM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tk.group) - 1; j >= 0; j-- { + b = append(b, tk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, tk.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, tk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, tk.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'tk_TM' +func (tk *tk_TM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'tk_TM' +func (tk *tk_TM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tk.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'tk_TM' +func (tk *tk_TM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'tk_TM' +func (tk *tk_TM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, tk.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'tk_TM' +func (tk *tk_TM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'tk_TM' +func (tk *tk_TM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'tk_TM' +func (tk *tk_TM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'tk_TM' +func (tk *tk_TM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := tk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/tk_TM/tk_TM_test.go b/vendor/github.com/go-playground/locales/tk_TM/tk_TM_test.go new file mode 100644 index 0000000000..8ac020165d --- /dev/null +++ b/vendor/github.com/go-playground/locales/tk_TM/tk_TM_test.go @@ -0,0 +1,1120 @@ +package tk_TM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "tk_TM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/to/to.go b/vendor/github.com/go-playground/locales/to/to.go new file mode 100644 index 0000000000..e2b56670a6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/to/to.go @@ -0,0 +1,622 @@ +package to + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type to struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'to' locale +func New() locales.Translator { + return &to{ + locale: "to", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "₾", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "T$", "TPE", "TRL", "TRY", "TTD", "$", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Sān", "Fēp", "Maʻa", "ʻEpe", "Mē", "Sun", "Siu", "ʻAok", "Sep", "ʻOka", "Nōv", "Tīs"}, + monthsNarrow: []string{"", "S", "F", "M", "E", "M", "S", "S", "A", "S", "O", "N", "T"}, + monthsWide: []string{"", "Sānuali", "Fēpueli", "Maʻasi", "ʻEpeleli", "Mē", "Sune", "Siulai", "ʻAokosi", "Sepitema", "ʻOkatopa", "Nōvema", "Tīsema"}, + daysAbbreviated: []string{"Sāp", "Mōn", "Tūs", "Pul", "Tuʻa", "Fal", "Tok"}, + daysNarrow: []string{"S", "M", "T", "P", "T", "F", "T"}, + daysShort: []string{"Sāp", "Mōn", "Tūs", "Pul", "Tuʻa", "Fal", "Tok"}, + daysWide: []string{"Sāpate", "Mōnite", "Tūsite", "Pulelulu", "Tuʻapulelulu", "Falaite", "Tokonaki"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"hengihengi", "efiafi"}, + erasAbbreviated: []string{"KM", "TS"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ki muʻa", "taʻu ʻo Sīsū"}, + timezones: map[string]string{"GMT": "houa fakakiliniuisi mālie", "EDT": "houa fakaʻamelika-tokelau hahake taimi liliu", "HNNOMX": "houa fakamekisikou-tokelauhihifo taimi totonu", "LHDT": "houa fakamotuʻeikihoue taimi liliu", "AWDT": "houa fakaʻaositelēlia-hihifo taimi liliu", "HAST": "houa fakahauaʻi taimi totonu", "HADT": "houa fakahauaʻi taimi liliu", "OESZ": "houa fakaʻeulope-hahake taimi liliu", "HNPM": "houa fakasā-piea-mo-mikeloni taimi totonu", "ACST": "houa fakaʻaositelēlia-loto taimi totonu", "HNT": "houa fakafonuaʻilofoʻou taimi totonu", "∅∅∅": "houa fakaʻāsolesi taimi liliu", "HECU": "houa fakakiupa taimi liliu", "AWST": "houa fakaʻaositelēlia-hihifo taimi totonu", "MESZ": "houa fakaʻeulope-loto taimi liliu", "AST": "houa fakaʻamelika-tokelau ʻatalanitiki taimi totonu", "CAT": "houa fakaʻafelika-loto", "WEZ": "houa fakaʻeulope-hihifo taimi totonu", "AEDT": "houa fakaʻaositelēlia-hahake taimi liliu", "ChST": "houa fakakamolo", "SAST": "houa fakaʻafelika-tonga", "WIB": "houa fakaʻinitonisia-hihifo", "ACWST": "houa fakaʻaositelēlia-loto-hihifo taimi totonu", "HAT": "houa fakafonuaʻilofoʻou taimi liliu", "UYT": "houa fakaʻulukuai taimi totonu", "MDT": "houa fakamakau taimi liliu", "ACWDT": "houa fakaʻaositelēlia-loto-hihifo taimi liliu", "OEZ": "houa fakaʻeulope-hahake taimi totonu", "MYT": "houa fakamaleisia", "HEOG": "houa fakafonuamata-hihifo taimi liliu", "ADT": "houa fakaʻamelika-tokelau ʻatalanitiki taimi liliu", "HEEG": "houa fakafonuamata-hahake taimi liliu", "UYST": "houa fakaʻulukuai taimi liliu", "BOT": "houa fakapolīvia", "HNOG": "houa fakafonuamata-hihifo taimi totonu", "MST": "houa fakamakau taimi totonu", "COST": "houa fakakolomipia taimi liliu", "HENOMX": "houa fakamekisikou-tokelauhihifo taimi liliu", "LHST": "houa fakamotuʻeikihoue taimi totonu", "PDT": "houa fakaʻamelika-tokelau pasifika taimi liliu", "ECT": "houa fakaʻekuetoa", "AKDT": "houa fakaʻalasika taimi liliu", "HEPM": "houa fakasā-piea-mo-mikeloni taimi liliu", "ART": "houa fakaʻasenitina taimi totonu", "HKT": "houa fakahongi-kongi taimi totonu", "HKST": "houa fakahongi-kongi taimi liliu", "ACDT": "houa fakaʻaositelēlia-loto taimi liliu", "AKST": "houa fakaʻalasika taimi totonu", "GYT": "houa fakakuiana", "CHADT": "houa fakasatihami taimi liliu", "MEZ": "houa fakaʻeulope-loto taimi totonu", "BT": "houa fakapūtani", "GFT": "houa fakakuiana-fakafalanisē", "TMT": "houa fakatūkimenisitani taimi totonu", "WAT": "houa fakaʻafelika-hihifo taimi totonu", "HNPMX": "houa fakamekisikou-pasifika taimi totonu", "HNCU": "houa fakakiupa taimi totonu", "PST": "houa fakaʻamelika-tokelau pasifika taimi totonu", "JDT": "houa fakasiapani taimi liliu", "CLST": "houa fakasili taimi liliu", "SRT": "houa fakasuliname", "EAT": "houa fakaʻafelika-hahake", "SGT": "houa fakasingapoa", "CHAST": "houa fakasatihami taimi totonu", "WESZ": "houa fakaʻeulope-hihifo taimi liliu", "IST": "houa fakaʻinitia", "NZST": "houa fakanuʻusila taimi totonu", "TMST": "houa fakatūkimenisitani taimi liliu", "HNEG": "houa fakafonuamata-hahake taimi totonu", "WIT": "houa fakaʻinitonisia-hahake", "CST": "houa fakaʻamelika-tokelau loto taimi totonu", "JST": "houa fakasiapani taimi totonu", "WARST": "houa fakaʻasenitina-hihifo taimi liliu", "AEST": "houa fakaʻaositelēlia-hahake taimi totonu", "COT": "houa fakakolomipia taimi totonu", "HEPMX": "houa fakamekisikou-pasifika taimi liliu", "NZDT": "houa fakanuʻusila taimi liliu", "WART": "houa fakaʻasenitina-hihifo taimi totonu", "CLT": "houa fakasili taimi totonu", "EST": "houa fakaʻamelika-tokelau hahake taimi totonu", "CDT": "houa fakaʻamelika-tokelau loto taimi liliu", "WAST": "houa fakaʻafelika-hihifo taimi liliu", "WITA": "houa fakaʻinitonisia-loto", "VET": "houa fakavenesuela", "ARST": "houa fakaʻasenitina taimi liliu"}, + } +} + +// Locale returns the current translators string locale +func (to *to) Locale() string { + return to.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'to' +func (to *to) PluralsCardinal() []locales.PluralRule { + return to.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'to' +func (to *to) PluralsOrdinal() []locales.PluralRule { + return to.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'to' +func (to *to) PluralsRange() []locales.PluralRule { + return to.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'to' +func (to *to) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'to' +func (to *to) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'to' +func (to *to) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (to *to) MonthAbbreviated(month time.Month) string { + return to.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (to *to) MonthsAbbreviated() []string { + return to.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (to *to) MonthNarrow(month time.Month) string { + return to.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (to *to) MonthsNarrow() []string { + return to.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (to *to) MonthWide(month time.Month) string { + return to.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (to *to) MonthsWide() []string { + return to.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (to *to) WeekdayAbbreviated(weekday time.Weekday) string { + return to.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (to *to) WeekdaysAbbreviated() []string { + return to.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (to *to) WeekdayNarrow(weekday time.Weekday) string { + return to.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (to *to) WeekdaysNarrow() []string { + return to.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (to *to) WeekdayShort(weekday time.Weekday) string { + return to.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (to *to) WeekdaysShort() []string { + return to.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (to *to) WeekdayWide(weekday time.Weekday) string { + return to.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (to *to) WeekdaysWide() []string { + return to.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'to' and handles both Whole and Real numbers based on 'v' +func (to *to) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, to.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, to.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, to.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'to' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (to *to) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, to.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, to.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, to.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'to' +func (to *to) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := to.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, to.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, to.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(to.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, to.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, to.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, to.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'to' +// in accounting notation. +func (to *to) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := to.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, to.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, to.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(to.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, to.currencyNegativePrefix[j]) + } + + b = append(b, to.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(to.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, to.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, to.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'to' +func (to *to) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'to' +func (to *to) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, to.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'to' +func (to *to) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, to.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'to' +func (to *to) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, to.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, to.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'to' +func (to *to) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, to.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, to.periodsAbbreviated[0]...) + } else { + b = append(b, to.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'to' +func (to *to) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, to.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, to.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, to.periodsAbbreviated[0]...) + } else { + b = append(b, to.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'to' +func (to *to) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, to.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, to.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, to.periodsAbbreviated[0]...) + } else { + b = append(b, to.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'to' +func (to *to) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, to.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, to.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, to.periodsAbbreviated[0]...) + } else { + b = append(b, to.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := to.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/to/to_test.go b/vendor/github.com/go-playground/locales/to/to_test.go new file mode 100644 index 0000000000..938186762c --- /dev/null +++ b/vendor/github.com/go-playground/locales/to/to_test.go @@ -0,0 +1,1120 @@ +package to + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "to" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/to_TO/to_TO.go b/vendor/github.com/go-playground/locales/to_TO/to_TO.go new file mode 100644 index 0000000000..e13b9dc6ac --- /dev/null +++ b/vendor/github.com/go-playground/locales/to_TO/to_TO.go @@ -0,0 +1,622 @@ +package to_TO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type to_TO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'to_TO' locale +func New() locales.Translator { + return &to_TO{ + locale: "to_TO", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "Sān", "Fēp", "Maʻa", "ʻEpe", "Mē", "Sun", "Siu", "ʻAok", "Sep", "ʻOka", "Nōv", "Tīs"}, + monthsNarrow: []string{"", "S", "F", "M", "E", "M", "S", "S", "A", "S", "O", "N", "T"}, + monthsWide: []string{"", "Sānuali", "Fēpueli", "Maʻasi", "ʻEpeleli", "Mē", "Sune", "Siulai", "ʻAokosi", "Sepitema", "ʻOkatopa", "Nōvema", "Tīsema"}, + daysAbbreviated: []string{"Sāp", "Mōn", "Tūs", "Pul", "Tuʻa", "Fal", "Tok"}, + daysNarrow: []string{"S", "M", "T", "P", "T", "F", "T"}, + daysShort: []string{"Sāp", "Mōn", "Tūs", "Pul", "Tuʻa", "Fal", "Tok"}, + daysWide: []string{"Sāpate", "Mōnite", "Tūsite", "Pulelulu", "Tuʻapulelulu", "Falaite", "Tokonaki"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"AM", "PM"}, + periodsWide: []string{"hengihengi", "efiafi"}, + erasAbbreviated: []string{"KM", "TS"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ki muʻa", "taʻu ʻo Sīsū"}, + timezones: map[string]string{"WARST": "houa fakaʻasenitina-hihifo taimi liliu", "GYT": "houa fakakuiana", "EAT": "houa fakaʻafelika-hahake", "AWST": "houa fakaʻaositelēlia-hihifo taimi totonu", "AWDT": "houa fakaʻaositelēlia-hihifo taimi liliu", "CHADT": "houa fakasatihami taimi liliu", "MESZ": "houa fakaʻeulope-loto taimi liliu", "WART": "houa fakaʻasenitina-hihifo taimi totonu", "WAST": "houa fakaʻafelika-hihifo taimi liliu", "HNPM": "houa fakasā-piea-mo-mikeloni taimi totonu", "HNPMX": "houa fakamekisikou-pasifika taimi totonu", "PDT": "houa fakaʻamelika-tokelau pasifika taimi liliu", "AST": "houa fakaʻamelika-tokelau ʻatalanitiki taimi totonu", "COT": "houa fakakolomipia taimi totonu", "AEST": "houa fakaʻaositelēlia-hahake taimi totonu", "LHDT": "houa fakamotuʻeikihoue taimi liliu", "ACWST": "houa fakaʻaositelēlia-loto-hihifo taimi totonu", "VET": "houa fakavenesuela", "HEOG": "houa fakafonuamata-hihifo taimi liliu", "HAT": "houa fakafonuaʻilofoʻou taimi liliu", "HAST": "houa fakahauaʻi taimi totonu", "ECT": "houa fakaʻekuetoa", "IST": "houa fakaʻinitia", "TMST": "houa fakatūkimenisitani taimi liliu", "AKST": "houa fakaʻalasika taimi totonu", "UYST": "houa fakaʻulukuai taimi liliu", "LHST": "houa fakamotuʻeikihoue taimi totonu", "WIT": "houa fakaʻinitonisia-hahake", "WESZ": "houa fakaʻeulope-hihifo taimi liliu", "ACDT": "houa fakaʻaositelēlia-loto taimi liliu", "BOT": "houa fakapolīvia", "ACWDT": "houa fakaʻaositelēlia-loto-hihifo taimi liliu", "OESZ": "houa fakaʻeulope-hahake taimi liliu", "HNT": "houa fakafonuaʻilofoʻou taimi totonu", "GFT": "houa fakakuiana-fakafalanisē", "SAST": "houa fakaʻafelika-tonga", "HECU": "houa fakakiupa taimi liliu", "NZST": "houa fakanuʻusila taimi totonu", "NZDT": "houa fakanuʻusila taimi liliu", "HNOG": "houa fakafonuamata-hihifo taimi totonu", "HEPM": "houa fakasā-piea-mo-mikeloni taimi liliu", "UYT": "houa fakaʻulukuai taimi totonu", "SGT": "houa fakasingapoa", "MYT": "houa fakamaleisia", "CLST": "houa fakasili taimi liliu", "ADT": "houa fakaʻamelika-tokelau ʻatalanitiki taimi liliu", "MDT": "houa fakamakau taimi liliu", "WITA": "houa fakaʻinitonisia-loto", "AEDT": "houa fakaʻaositelēlia-hahake taimi liliu", "CLT": "houa fakasili taimi totonu", "GMT": "houa fakakiliniuisi mālie", "EST": "houa fakaʻamelika-tokelau hahake taimi totonu", "ACST": "houa fakaʻaositelēlia-loto taimi totonu", "WIB": "houa fakaʻinitonisia-hihifo", "PST": "houa fakaʻamelika-tokelau pasifika taimi totonu", "JST": "houa fakasiapani taimi totonu", "WAT": "houa fakaʻafelika-hihifo taimi totonu", "HENOMX": "houa fakamekisikou-tokelauhihifo taimi liliu", "CHAST": "houa fakasatihami taimi totonu", "JDT": "houa fakasiapani taimi liliu", "MST": "houa fakamakau taimi totonu", "HEEG": "houa fakafonuamata-hahake taimi liliu", "HEPMX": "houa fakamekisikou-pasifika taimi liliu", "SRT": "houa fakasuliname", "∅∅∅": "houa fakaʻamasōne taimi liliu", "CAT": "houa fakaʻafelika-loto", "ARST": "houa fakaʻasenitina taimi liliu", "HKT": "houa fakahongi-kongi taimi totonu", "COST": "houa fakakolomipia taimi liliu", "AKDT": "houa fakaʻalasika taimi liliu", "HADT": "houa fakahauaʻi taimi liliu", "TMT": "houa fakatūkimenisitani taimi totonu", "EDT": "houa fakaʻamelika-tokelau hahake taimi liliu", "HNNOMX": "houa fakamekisikou-tokelauhihifo taimi totonu", "CST": "houa fakaʻamelika-tokelau loto taimi totonu", "CDT": "houa fakaʻamelika-tokelau loto taimi liliu", "HNEG": "houa fakafonuamata-hahake taimi totonu", "ChST": "houa fakakamolo", "MEZ": "houa fakaʻeulope-loto taimi totonu", "OEZ": "houa fakaʻeulope-hahake taimi totonu", "WEZ": "houa fakaʻeulope-hihifo taimi totonu", "ART": "houa fakaʻasenitina taimi totonu", "HKST": "houa fakahongi-kongi taimi liliu", "BT": "houa fakapūtani", "HNCU": "houa fakakiupa taimi totonu"}, + } +} + +// Locale returns the current translators string locale +func (to *to_TO) Locale() string { + return to.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'to_TO' +func (to *to_TO) PluralsCardinal() []locales.PluralRule { + return to.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'to_TO' +func (to *to_TO) PluralsOrdinal() []locales.PluralRule { + return to.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'to_TO' +func (to *to_TO) PluralsRange() []locales.PluralRule { + return to.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'to_TO' +func (to *to_TO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'to_TO' +func (to *to_TO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'to_TO' +func (to *to_TO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (to *to_TO) MonthAbbreviated(month time.Month) string { + return to.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (to *to_TO) MonthsAbbreviated() []string { + return to.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (to *to_TO) MonthNarrow(month time.Month) string { + return to.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (to *to_TO) MonthsNarrow() []string { + return to.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (to *to_TO) MonthWide(month time.Month) string { + return to.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (to *to_TO) MonthsWide() []string { + return to.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (to *to_TO) WeekdayAbbreviated(weekday time.Weekday) string { + return to.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (to *to_TO) WeekdaysAbbreviated() []string { + return to.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (to *to_TO) WeekdayNarrow(weekday time.Weekday) string { + return to.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (to *to_TO) WeekdaysNarrow() []string { + return to.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (to *to_TO) WeekdayShort(weekday time.Weekday) string { + return to.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (to *to_TO) WeekdaysShort() []string { + return to.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (to *to_TO) WeekdayWide(weekday time.Weekday) string { + return to.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (to *to_TO) WeekdaysWide() []string { + return to.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'to_TO' and handles both Whole and Real numbers based on 'v' +func (to *to_TO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, to.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, to.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, to.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'to_TO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (to *to_TO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, to.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, to.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, to.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'to_TO' +func (to *to_TO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := to.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, to.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, to.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(to.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, to.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, to.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, to.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'to_TO' +// in accounting notation. +func (to *to_TO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := to.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, to.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, to.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(to.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, to.currencyNegativePrefix[j]) + } + + b = append(b, to.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(to.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, to.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, to.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'to_TO' +func (to *to_TO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'to_TO' +func (to *to_TO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, to.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'to_TO' +func (to *to_TO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, to.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'to_TO' +func (to *to_TO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, to.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, to.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'to_TO' +func (to *to_TO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, to.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, to.periodsAbbreviated[0]...) + } else { + b = append(b, to.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'to_TO' +func (to *to_TO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, to.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, to.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, to.periodsAbbreviated[0]...) + } else { + b = append(b, to.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'to_TO' +func (to *to_TO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, to.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, to.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, to.periodsAbbreviated[0]...) + } else { + b = append(b, to.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'to_TO' +func (to *to_TO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, to.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, to.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, to.periodsAbbreviated[0]...) + } else { + b = append(b, to.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := to.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/to_TO/to_TO_test.go b/vendor/github.com/go-playground/locales/to_TO/to_TO_test.go new file mode 100644 index 0000000000..2fac3a8e74 --- /dev/null +++ b/vendor/github.com/go-playground/locales/to_TO/to_TO_test.go @@ -0,0 +1,1120 @@ +package to_TO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "to_TO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/tr/tr.go b/vendor/github.com/go-playground/locales/tr/tr.go new file mode 100644 index 0000000000..0ed34fe9dd --- /dev/null +++ b/vendor/github.com/go-playground/locales/tr/tr.go @@ -0,0 +1,614 @@ +package tr + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type tr struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'tr' locale +func New() locales.Translator { + return &tr{ + locale: "tr", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "₺", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"}, + monthsNarrow: []string{"", "O", "Ş", "M", "N", "M", "H", "T", "A", "E", "E", "K", "A"}, + monthsWide: []string{"", "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"}, + daysAbbreviated: []string{"Paz", "Pzt", "Sal", "Çar", "Per", "Cum", "Cmt"}, + daysNarrow: []string{"P", "P", "S", "Ç", "P", "C", "C"}, + daysShort: []string{"Pa", "Pt", "Sa", "Ça", "Pe", "Cu", "Ct"}, + daysWide: []string{"Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"}, + periodsAbbreviated: []string{"ÖÖ", "ÖS"}, + periodsNarrow: []string{"öö", "ös"}, + periodsWide: []string{"ÖÖ", "ÖS"}, + erasAbbreviated: []string{"MÖ", "MS"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Milattan Önce", "Milattan Sonra"}, + timezones: map[string]string{"CAT": "Orta Afrika Saati", "HNEG": "Doğu Grönland Standart Saati", "AEST": "Doğu Avustralya Standart Saati", "HNCU": "Küba Standart Saati", "WIT": "Doğu Endonezya Saati", "CHADT": "Chatham Yaz Saati", "HAST": "Hawaii-Aleut Standart Saati", "IST": "Hindistan Standart Saati", "CLST": "Şili Yaz Saati", "HEEG": "Doğu Grönland Yaz Saati", "WIB": "Batı Endonezya Saati", "MESZ": "Orta Avrupa Yaz Saati", "OESZ": "Doğu Avrupa Yaz Saati", "TMT": "Türkmenistan Standart Saati", "ART": "Arjantin Standart Saati", "UYT": "Uruguay Standart Saati", "GYT": "Guyana Saati", "CHAST": "Chatham Standart Saati", "MDT": "Makao Yaz Saati", "ACST": "Orta Avustralya Standart Saati", "AEDT": "Doğu Avustralya Yaz Saati", "GFT": "Fransız Guyanası Saati", "HNPM": "Saint Pierre ve Miquelon Standart Saati", "WEZ": "Batı Avrupa Standart Saati", "EDT": "Kuzey Amerika Doğu Yaz Saati", "HKST": "Hong Kong Yaz Saati", "COST": "Kolombiya Yaz Saati", "MYT": "Malezya Saati", "HNNOMX": "Kuzeybatı Meksika Standart Saati", "HNPMX": "Meksika Pasifik Kıyısı Standart Saati", "EAT": "Doğu Afrika Saati", "HECU": "Küba Yaz Saati", "AWST": "Batı Avustralya Standart Saati", "HNOG": "Batı Grönland Standart Saati", "WITA": "Orta Endonezya Saati", "UYST": "Uruguay Yaz Saati", "HEPM": "Saint Pierre ve Miquelon Yaz Saati", "LHDT": "Lord Howe Yaz Saati", "ACWST": "İçbatı Avustralya Standart Saati", "ARST": "Arjantin Yaz Saati", "HKT": "Hong Kong Standart Saati", "LHST": "Lord Howe Standart Saati", "CST": "Kuzey Amerika Merkezi Standart Saati", "JDT": "Japonya Yaz Saati", "COT": "Kolombiya Standart Saati", "HAT": "Newfoundland Yaz Saati", "ChST": "Chamorro Saati", "SAST": "Güney Afrika Standart Saati", "SGT": "Singapur Standart Saati", "NZST": "Yeni Zelanda Standart Saati", "WART": "Batı Arjantin Standart Saati", "SRT": "Surinam Saati", "VET": "Venezuela Saati", "ADT": "Atlantik Yaz Saati", "HNT": "Newfoundland Standart Saati", "AKDT": "Alaska Yaz Saati", "NZDT": "Yeni Zelanda Yaz Saati", "HEOG": "Batı Grönland Yaz Saati", "GMT": "Greenwich Ortalama Saati", "MST": "Makao Standart Saati", "BOT": "Bolivya Saati", "PST": "Kuzey Amerika Pasifik Standart Saati", "MEZ": "Orta Avrupa Standart Saati", "AST": "Atlantik Standart Saati", "HENOMX": "Kuzeybatı Meksika Yaz Saati", "OEZ": "Doğu Avrupa Standart Saati", "WESZ": "Batı Avrupa Yaz Saati", "WAT": "Batı Afrika Standart Saati", "WAST": "Batı Afrika Yaz Saati", "CDT": "Kuzey Amerika Merkezi Yaz Saati", "AWDT": "Batı Avustralya Yaz Saati", "HADT": "Hawaii-Aleut Yaz Saati", "JST": "Japonya Standart Saati", "CLT": "Şili Standart Saati", "BT": "Bhutan Saati", "HEPMX": "Meksika Pasifik Kıyısı Yaz Saati", "EST": "Kuzey Amerika Doğu Standart Saati", "ACDT": "Orta Avustralya Yaz Saati", "PDT": "Kuzey Amerika Pasifik Yaz Saati", "ECT": "Ekvador Saati", "ACWDT": "İçbatı Avustralya Yaz Saati", "∅∅∅": "Amazon Yaz Saati", "WARST": "Batı Arjantin Yaz Saati", "TMST": "Türkmenistan Yaz Saati", "AKST": "Alaska Standart Saati"}, + } +} + +// Locale returns the current translators string locale +func (tr *tr) Locale() string { + return tr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'tr' +func (tr *tr) PluralsCardinal() []locales.PluralRule { + return tr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'tr' +func (tr *tr) PluralsOrdinal() []locales.PluralRule { + return tr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'tr' +func (tr *tr) PluralsRange() []locales.PluralRule { + return tr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tr' +func (tr *tr) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tr' +func (tr *tr) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tr' +func (tr *tr) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := tr.CardinalPluralRule(num1, v1) + end := tr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (tr *tr) MonthAbbreviated(month time.Month) string { + return tr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (tr *tr) MonthsAbbreviated() []string { + return tr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (tr *tr) MonthNarrow(month time.Month) string { + return tr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (tr *tr) MonthsNarrow() []string { + return tr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (tr *tr) MonthWide(month time.Month) string { + return tr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (tr *tr) MonthsWide() []string { + return tr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (tr *tr) WeekdayAbbreviated(weekday time.Weekday) string { + return tr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (tr *tr) WeekdaysAbbreviated() []string { + return tr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (tr *tr) WeekdayNarrow(weekday time.Weekday) string { + return tr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (tr *tr) WeekdaysNarrow() []string { + return tr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (tr *tr) WeekdayShort(weekday time.Weekday) string { + return tr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (tr *tr) WeekdaysShort() []string { + return tr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (tr *tr) WeekdayWide(weekday time.Weekday) string { + return tr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (tr *tr) WeekdaysWide() []string { + return tr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'tr' and handles both Whole and Real numbers based on 'v' +func (tr *tr) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'tr' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (tr *tr) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + b = append(b, tr.percent[0]) + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tr' +func (tr *tr) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tr' +// in accounting notation. +func (tr *tr) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, tr.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, tr.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'tr' +func (tr *tr) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'tr' +func (tr *tr) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'tr' +func (tr *tr) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'tr' +func (tr *tr) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, tr.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'tr' +func (tr *tr) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'tr' +func (tr *tr) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'tr' +func (tr *tr) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'tr' +func (tr *tr) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := tr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/tr/tr_test.go b/vendor/github.com/go-playground/locales/tr/tr_test.go new file mode 100644 index 0000000000..10c9e2e0d7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/tr/tr_test.go @@ -0,0 +1,1120 @@ +package tr + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "tr" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/tr_CY/tr_CY.go b/vendor/github.com/go-playground/locales/tr_CY/tr_CY.go new file mode 100644 index 0000000000..0c589aab7c --- /dev/null +++ b/vendor/github.com/go-playground/locales/tr_CY/tr_CY.go @@ -0,0 +1,652 @@ +package tr_CY + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type tr_CY struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'tr_CY' locale +func New() locales.Translator { + return &tr_CY{ + locale: "tr_CY", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"}, + monthsNarrow: []string{"", "O", "Ş", "M", "N", "M", "H", "T", "A", "E", "E", "K", "A"}, + monthsWide: []string{"", "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"}, + daysAbbreviated: []string{"Paz", "Pzt", "Sal", "Çar", "Per", "Cum", "Cmt"}, + daysNarrow: []string{"P", "P", "S", "Ç", "P", "C", "C"}, + daysShort: []string{"Pa", "Pt", "Sa", "Ça", "Pe", "Cu", "Ct"}, + daysWide: []string{"Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"}, + periodsAbbreviated: []string{"ÖÖ", "ÖS"}, + periodsNarrow: []string{"öö", "ös"}, + periodsWide: []string{"ÖÖ", "ÖS"}, + erasAbbreviated: []string{"MÖ", "MS"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Milattan Önce", "Milattan Sonra"}, + timezones: map[string]string{"ACDT": "Orta Avustralya Yaz Saati", "AEST": "Doğu Avustralya Standart Saati", "HEPMX": "Meksika Pasifik Kıyısı Yaz Saati", "CST": "Kuzey Amerika Merkezi Standart Saati", "CHADT": "Chatham Yaz Saati", "CAT": "Orta Afrika Saati", "JST": "Japonya Standart Saati", "HNEG": "Doğu Grönland Standart Saati", "LHDT": "Lord Howe Yaz Saati", "AST": "Atlantik Standart Saati", "ART": "Arjantin Standart Saati", "PST": "Kuzey Amerika Pasifik Standart Saati", "ECT": "Ekvador Saati", "∅∅∅": "Amazon Yaz Saati", "HNCU": "Küba Standart Saati", "HKT": "Hong Kong Standart Saati", "AKDT": "Alaska Yaz Saati", "HNPM": "Saint Pierre ve Miquelon Standart Saati", "EAT": "Doğu Afrika Saati", "NZST": "Yeni Zelanda Standart Saati", "MEZ": "Orta Avrupa Standart Saati", "HEEG": "Doğu Grönland Yaz Saati", "WIB": "Batı Endonezya Saati", "GYT": "Guyana Saati", "SGT": "Singapur Standart Saati", "PDT": "Kuzey Amerika Pasifik Yaz Saati", "HADT": "Hawaii-Aleut Yaz Saati", "WARST": "Batı Arjantin Yaz Saati", "HKST": "Hong Kong Yaz Saati", "HNOG": "Batı Grönland Standart Saati", "UYT": "Uruguay Standart Saati", "HECU": "Küba Yaz Saati", "AWST": "Batı Avustralya Standart Saati", "NZDT": "Yeni Zelanda Yaz Saati", "MESZ": "Orta Avrupa Yaz Saati", "WART": "Batı Arjantin Standart Saati", "MDT": "Makao Yaz Saati", "HEPM": "Saint Pierre ve Miquelon Yaz Saati", "HAST": "Hawaii-Aleut Standart Saati", "OEZ": "Doğu Avrupa Standart Saati", "GMT": "Greenwich Ortalama Saati", "ADT": "Atlantik Yaz Saati", "BT": "Bhutan Saati", "SRT": "Surinam Saati", "CDT": "Kuzey Amerika Merkezi Yaz Saati", "BOT": "Bolivya Saati", "VET": "Venezuela Saati", "OESZ": "Doğu Avrupa Yaz Saati", "TMST": "Türkmenistan Yaz Saati", "HAT": "Newfoundland Yaz Saati", "UYST": "Uruguay Yaz Saati", "HNPMX": "Meksika Pasifik Kıyısı Standart Saati", "WIT": "Doğu Endonezya Saati", "AWDT": "Batı Avustralya Yaz Saati", "WESZ": "Batı Avrupa Yaz Saati", "WAT": "Batı Afrika Standart Saati", "MST": "Makao Standart Saati", "COST": "Kolombiya Yaz Saati", "CLT": "Şili Standart Saati", "CLST": "Şili Yaz Saati", "EDT": "Kuzey Amerika Doğu Yaz Saati", "ACWST": "İçbatı Avustralya Standart Saati", "ACWDT": "İçbatı Avustralya Yaz Saati", "EST": "Kuzey Amerika Doğu Standart Saati", "WAST": "Batı Afrika Yaz Saati", "HNNOMX": "Kuzeybatı Meksika Standart Saati", "HENOMX": "Kuzeybatı Meksika Yaz Saati", "HNT": "Newfoundland Standart Saati", "GFT": "Fransız Guyanası Saati", "JDT": "Japonya Yaz Saati", "HEOG": "Batı Grönland Yaz Saati", "SAST": "Güney Afrika Standart Saati", "WITA": "Orta Endonezya Saati", "ChST": "Chamorro Saati", "ARST": "Arjantin Yaz Saati", "ACST": "Orta Avustralya Standart Saati", "AEDT": "Doğu Avustralya Yaz Saati", "AKST": "Alaska Standart Saati", "LHST": "Lord Howe Standart Saati", "IST": "Hindistan Standart Saati", "TMT": "Türkmenistan Standart Saati", "COT": "Kolombiya Standart Saati", "CHAST": "Chatham Standart Saati", "WEZ": "Batı Avrupa Standart Saati", "MYT": "Malezya Saati"}, + } +} + +// Locale returns the current translators string locale +func (tr *tr_CY) Locale() string { + return tr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'tr_CY' +func (tr *tr_CY) PluralsCardinal() []locales.PluralRule { + return tr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'tr_CY' +func (tr *tr_CY) PluralsOrdinal() []locales.PluralRule { + return tr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'tr_CY' +func (tr *tr_CY) PluralsRange() []locales.PluralRule { + return tr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tr_CY' +func (tr *tr_CY) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tr_CY' +func (tr *tr_CY) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tr_CY' +func (tr *tr_CY) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := tr.CardinalPluralRule(num1, v1) + end := tr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (tr *tr_CY) MonthAbbreviated(month time.Month) string { + return tr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (tr *tr_CY) MonthsAbbreviated() []string { + return tr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (tr *tr_CY) MonthNarrow(month time.Month) string { + return tr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (tr *tr_CY) MonthsNarrow() []string { + return tr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (tr *tr_CY) MonthWide(month time.Month) string { + return tr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (tr *tr_CY) MonthsWide() []string { + return tr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (tr *tr_CY) WeekdayAbbreviated(weekday time.Weekday) string { + return tr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (tr *tr_CY) WeekdaysAbbreviated() []string { + return tr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (tr *tr_CY) WeekdayNarrow(weekday time.Weekday) string { + return tr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (tr *tr_CY) WeekdaysNarrow() []string { + return tr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (tr *tr_CY) WeekdayShort(weekday time.Weekday) string { + return tr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (tr *tr_CY) WeekdaysShort() []string { + return tr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (tr *tr_CY) WeekdayWide(weekday time.Weekday) string { + return tr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (tr *tr_CY) WeekdaysWide() []string { + return tr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'tr_CY' and handles both Whole and Real numbers based on 'v' +func (tr *tr_CY) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'tr_CY' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (tr *tr_CY) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + b = append(b, tr.percent[0]) + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tr_CY' +func (tr *tr_CY) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tr_CY' +// in accounting notation. +func (tr *tr_CY) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, tr.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, tr.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'tr_CY' +func (tr *tr_CY) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'tr_CY' +func (tr *tr_CY) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'tr_CY' +func (tr *tr_CY) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'tr_CY' +func (tr *tr_CY) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, tr.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'tr_CY' +func (tr *tr_CY) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, tr.periodsAbbreviated[0]...) + } else { + b = append(b, tr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'tr_CY' +func (tr *tr_CY) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, tr.periodsAbbreviated[0]...) + } else { + b = append(b, tr.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'tr_CY' +func (tr *tr_CY) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, tr.periodsAbbreviated[0]...) + } else { + b = append(b, tr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'tr_CY' +func (tr *tr_CY) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, tr.periodsAbbreviated[0]...) + } else { + b = append(b, tr.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := tr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/tr_CY/tr_CY_test.go b/vendor/github.com/go-playground/locales/tr_CY/tr_CY_test.go new file mode 100644 index 0000000000..f9564a8d6d --- /dev/null +++ b/vendor/github.com/go-playground/locales/tr_CY/tr_CY_test.go @@ -0,0 +1,1120 @@ +package tr_CY + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "tr_CY" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/tr_TR/tr_TR.go b/vendor/github.com/go-playground/locales/tr_TR/tr_TR.go new file mode 100644 index 0000000000..a4c7777738 --- /dev/null +++ b/vendor/github.com/go-playground/locales/tr_TR/tr_TR.go @@ -0,0 +1,614 @@ +package tr_TR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type tr_TR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'tr_TR' locale +func New() locales.Translator { + return &tr_TR{ + locale: "tr_TR", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"}, + monthsNarrow: []string{"", "O", "Ş", "M", "N", "M", "H", "T", "A", "E", "E", "K", "A"}, + monthsWide: []string{"", "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"}, + daysAbbreviated: []string{"Paz", "Pzt", "Sal", "Çar", "Per", "Cum", "Cmt"}, + daysNarrow: []string{"P", "P", "S", "Ç", "P", "C", "C"}, + daysShort: []string{"Pa", "Pt", "Sa", "Ça", "Pe", "Cu", "Ct"}, + daysWide: []string{"Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"}, + periodsAbbreviated: []string{"ÖÖ", "ÖS"}, + periodsNarrow: []string{"öö", "ös"}, + periodsWide: []string{"ÖÖ", "ÖS"}, + erasAbbreviated: []string{"MÖ", "MS"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Milattan Önce", "Milattan Sonra"}, + timezones: map[string]string{"AKDT": "Alaska Yaz Saati", "AEDT": "Doğu Avustralya Yaz Saati", "WIB": "Batı Endonezya Saati", "MESZ": "Orta Avrupa Yaz Saati", "CLST": "Şili Yaz Saati", "EST": "Kuzey Amerika Doğu Standart Saati", "HKST": "Hong Kong Yaz Saati", "HAT": "Newfoundland Yaz Saati", "VET": "Venezuela Saati", "TMT": "Türkmenistan Standart Saati", "WAT": "Batı Afrika Standart Saati", "HNT": "Newfoundland Standart Saati", "HNPMX": "Meksika Pasifik Kıyısı Standart Saati", "HECU": "Küba Yaz Saati", "CHAST": "Chatham Standart Saati", "SGT": "Singapur Standart Saati", "OESZ": "Doğu Avrupa Yaz Saati", "GMT": "Greenwich Ortalama Saati", "HNPM": "Saint Pierre ve Miquelon Standart Saati", "CLT": "Şili Standart Saati", "HKT": "Hong Kong Standart Saati", "AWDT": "Batı Avustralya Yaz Saati", "ACWDT": "İçbatı Avustralya Yaz Saati", "MEZ": "Orta Avrupa Standart Saati", "WEZ": "Batı Avrupa Standart Saati", "WESZ": "Batı Avrupa Yaz Saati", "MYT": "Malezya Saati", "WAST": "Batı Afrika Yaz Saati", "WITA": "Orta Endonezya Saati", "CAT": "Orta Afrika Saati", "IST": "Hindistan Standart Saati", "OEZ": "Doğu Avrupa Standart Saati", "WART": "Batı Arjantin Standart Saati", "HNOG": "Batı Grönland Standart Saati", "TMST": "Türkmenistan Yaz Saati", "HEPM": "Saint Pierre ve Miquelon Yaz Saati", "HEEG": "Doğu Grönland Yaz Saati", "LHST": "Lord Howe Standart Saati", "EAT": "Doğu Afrika Saati", "WIT": "Doğu Endonezya Saati", "∅∅∅": "Brasilia Yaz Saati", "NZST": "Yeni Zelanda Standart Saati", "WARST": "Batı Arjantin Yaz Saati", "HEOG": "Batı Grönland Yaz Saati", "HEPMX": "Meksika Pasifik Kıyısı Yaz Saati", "CST": "Kuzey Amerika Merkezi Standart Saati", "AWST": "Batı Avustralya Standart Saati", "ADT": "Atlantik Yaz Saati", "EDT": "Kuzey Amerika Doğu Yaz Saati", "COST": "Kolombiya Yaz Saati", "UYT": "Uruguay Standart Saati", "HNCU": "Küba Standart Saati", "CDT": "Kuzey Amerika Merkezi Yaz Saati", "COT": "Kolombiya Standart Saati", "AEST": "Doğu Avustralya Standart Saati", "ACWST": "İçbatı Avustralya Standart Saati", "AST": "Atlantik Standart Saati", "ART": "Arjantin Standart Saati", "GFT": "Fransız Guyanası Saati", "GYT": "Guyana Saati", "ECT": "Ekvador Saati", "NZDT": "Yeni Zelanda Yaz Saati", "BT": "Bhutan Saati", "MST": "Makao Standart Saati", "ARST": "Arjantin Yaz Saati", "ACDT": "Orta Avustralya Yaz Saati", "JDT": "Japonya Yaz Saati", "HENOMX": "Kuzeybatı Meksika Yaz Saati", "HNEG": "Doğu Grönland Standart Saati", "CHADT": "Chatham Yaz Saati", "BOT": "Bolivya Saati", "PST": "Kuzey Amerika Pasifik Standart Saati", "PDT": "Kuzey Amerika Pasifik Yaz Saati", "HAST": "Hawaii-Aleut Standart Saati", "ACST": "Orta Avustralya Standart Saati", "UYST": "Uruguay Yaz Saati", "HADT": "Hawaii-Aleut Yaz Saati", "MDT": "Makao Yaz Saati", "ChST": "Chamorro Saati", "SAST": "Güney Afrika Standart Saati", "SRT": "Surinam Saati", "JST": "Japonya Standart Saati", "HNNOMX": "Kuzeybatı Meksika Standart Saati", "AKST": "Alaska Standart Saati", "LHDT": "Lord Howe Yaz Saati"}, + } +} + +// Locale returns the current translators string locale +func (tr *tr_TR) Locale() string { + return tr.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'tr_TR' +func (tr *tr_TR) PluralsCardinal() []locales.PluralRule { + return tr.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'tr_TR' +func (tr *tr_TR) PluralsOrdinal() []locales.PluralRule { + return tr.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'tr_TR' +func (tr *tr_TR) PluralsRange() []locales.PluralRule { + return tr.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tr_TR' +func (tr *tr_TR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tr_TR' +func (tr *tr_TR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tr_TR' +func (tr *tr_TR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := tr.CardinalPluralRule(num1, v1) + end := tr.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (tr *tr_TR) MonthAbbreviated(month time.Month) string { + return tr.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (tr *tr_TR) MonthsAbbreviated() []string { + return tr.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (tr *tr_TR) MonthNarrow(month time.Month) string { + return tr.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (tr *tr_TR) MonthsNarrow() []string { + return tr.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (tr *tr_TR) MonthWide(month time.Month) string { + return tr.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (tr *tr_TR) MonthsWide() []string { + return tr.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (tr *tr_TR) WeekdayAbbreviated(weekday time.Weekday) string { + return tr.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (tr *tr_TR) WeekdaysAbbreviated() []string { + return tr.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (tr *tr_TR) WeekdayNarrow(weekday time.Weekday) string { + return tr.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (tr *tr_TR) WeekdaysNarrow() []string { + return tr.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (tr *tr_TR) WeekdayShort(weekday time.Weekday) string { + return tr.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (tr *tr_TR) WeekdaysShort() []string { + return tr.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (tr *tr_TR) WeekdayWide(weekday time.Weekday) string { + return tr.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (tr *tr_TR) WeekdaysWide() []string { + return tr.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'tr_TR' and handles both Whole and Real numbers based on 'v' +func (tr *tr_TR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'tr_TR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (tr *tr_TR) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + b = append(b, tr.percent[0]) + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tr_TR' +func (tr *tr_TR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tr.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, tr.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tr_TR' +// in accounting notation. +func (tr *tr_TR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tr.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tr.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, tr.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, tr.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tr.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, tr.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'tr_TR' +func (tr *tr_TR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'tr_TR' +func (tr *tr_TR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'tr_TR' +func (tr *tr_TR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'tr_TR' +func (tr *tr_TR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tr.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, tr.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'tr_TR' +func (tr *tr_TR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'tr_TR' +func (tr *tr_TR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'tr_TR' +func (tr *tr_TR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'tr_TR' +func (tr *tr_TR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, tr.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, tr.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := tr.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/tr_TR/tr_TR_test.go b/vendor/github.com/go-playground/locales/tr_TR/tr_TR_test.go new file mode 100644 index 0000000000..10e00a2c5d --- /dev/null +++ b/vendor/github.com/go-playground/locales/tr_TR/tr_TR_test.go @@ -0,0 +1,1120 @@ +package tr_TR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "tr_TR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/twq/twq.go b/vendor/github.com/go-playground/locales/twq/twq.go new file mode 100644 index 0000000000..6589f3c378 --- /dev/null +++ b/vendor/github.com/go-playground/locales/twq/twq.go @@ -0,0 +1,563 @@ +package twq + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type twq struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'twq' locale +func New() locales.Translator { + return &twq{ + locale: "twq", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"}, + monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"}, + daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alz", "Asi"}, + daysNarrow: []string{"H", "T", "T", "L", "L", "L", "S"}, + daysWide: []string{"Alhadi", "Atinni", "Atalaata", "Alarba", "Alhamiisa", "Alzuma", "Asibti"}, + periodsAbbreviated: []string{"Subbaahi", "Zaarikay b"}, + periodsWide: []string{"Subbaahi", "Zaarikay b"}, + erasAbbreviated: []string{"IJ", "IZ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Isaa jine", "Isaa zamanoo"}, + timezones: map[string]string{"PST": "PST", "MESZ": "MESZ", "HNOG": "HNOG", "AST": "AST", "OESZ": "OESZ", "WAT": "WAT", "AEST": "AEST", "LHDT": "LHDT", "WARST": "WARST", "EDT": "EDT", "HNNOMX": "HNNOMX", "AWST": "AWST", "HNPM": "HNPM", "SAST": "SAST", "WIB": "WIB", "CST": "CST", "AWDT": "AWDT", "HKT": "HKT", "HKST": "HKST", "ACST": "ACST", "ACWST": "ACWST", "MEZ": "MEZ", "AKDT": "AKDT", "CHAST": "CHAST", "HADT": "HADT", "ACDT": "ACDT", "BT": "BT", "AKST": "AKST", "HAST": "HAST", "JDT": "JDT", "CLT": "CLT", "ARST": "ARST", "HAT": "HAT", "∅∅∅": "∅∅∅", "CDT": "CDT", "WITA": "WITA", "HNPMX": "HNPMX", "WESZ": "WESZ", "HEPMX": "HEPMX", "EAT": "EAT", "PDT": "PDT", "ECT": "ECT", "TMST": "TMST", "COT": "COT", "GFT": "GFT", "UYST": "UYST", "NZST": "NZST", "ART": "ART", "CAT": "CAT", "NZDT": "NZDT", "WEZ": "WEZ", "MYT": "MYT", "WART": "WART", "EST": "EST", "SGT": "SGT", "HEOG": "HEOG", "ADT": "ADT", "LHST": "LHST", "GYT": "GYT", "HECU": "HECU", "HNCU": "HNCU", "WIT": "WIT", "CHADT": "CHADT", "HNEG": "HNEG", "MST": "MST", "SRT": "SRT", "HEPM": "HEPM", "ACWDT": "ACWDT", "JST": "JST", "COST": "COST", "HNT": "HNT", "AEDT": "AEDT", "CLST": "CLST", "OEZ": "OEZ", "GMT": "GMT", "TMT": "TMT", "HENOMX": "HENOMX", "BOT": "BOT", "VET": "VET", "IST": "IST", "HEEG": "HEEG", "MDT": "MDT", "ChST": "ChST", "WAST": "WAST", "UYT": "UYT"}, + } +} + +// Locale returns the current translators string locale +func (twq *twq) Locale() string { + return twq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'twq' +func (twq *twq) PluralsCardinal() []locales.PluralRule { + return twq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'twq' +func (twq *twq) PluralsOrdinal() []locales.PluralRule { + return twq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'twq' +func (twq *twq) PluralsRange() []locales.PluralRule { + return twq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'twq' +func (twq *twq) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'twq' +func (twq *twq) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'twq' +func (twq *twq) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (twq *twq) MonthAbbreviated(month time.Month) string { + return twq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (twq *twq) MonthsAbbreviated() []string { + return twq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (twq *twq) MonthNarrow(month time.Month) string { + return twq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (twq *twq) MonthsNarrow() []string { + return twq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (twq *twq) MonthWide(month time.Month) string { + return twq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (twq *twq) MonthsWide() []string { + return twq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (twq *twq) WeekdayAbbreviated(weekday time.Weekday) string { + return twq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (twq *twq) WeekdaysAbbreviated() []string { + return twq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (twq *twq) WeekdayNarrow(weekday time.Weekday) string { + return twq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (twq *twq) WeekdaysNarrow() []string { + return twq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (twq *twq) WeekdayShort(weekday time.Weekday) string { + return twq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (twq *twq) WeekdaysShort() []string { + return twq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (twq *twq) WeekdayWide(weekday time.Weekday) string { + return twq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (twq *twq) WeekdaysWide() []string { + return twq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'twq' and handles both Whole and Real numbers based on 'v' +func (twq *twq) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, twq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(twq.group) - 1; j >= 0; j-- { + b = append(b, twq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, twq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'twq' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (twq *twq) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, twq.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, twq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, twq.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'twq' +func (twq *twq) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := twq.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, twq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(twq.group) - 1; j >= 0; j-- { + b = append(b, twq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, twq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, twq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'twq' +// in accounting notation. +func (twq *twq) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := twq.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, twq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(twq.group) - 1; j >= 0; j-- { + b = append(b, twq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, twq.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, twq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'twq' +func (twq *twq) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'twq' +func (twq *twq) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, twq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'twq' +func (twq *twq) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, twq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'twq' +func (twq *twq) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, twq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, twq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'twq' +func (twq *twq) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, twq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'twq' +func (twq *twq) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, twq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, twq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'twq' +func (twq *twq) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, twq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, twq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'twq' +func (twq *twq) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, twq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, twq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := twq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/twq/twq_test.go b/vendor/github.com/go-playground/locales/twq/twq_test.go new file mode 100644 index 0000000000..b155422654 --- /dev/null +++ b/vendor/github.com/go-playground/locales/twq/twq_test.go @@ -0,0 +1,1120 @@ +package twq + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "twq" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/twq_NE/twq_NE.go b/vendor/github.com/go-playground/locales/twq_NE/twq_NE.go new file mode 100644 index 0000000000..c19cc05558 --- /dev/null +++ b/vendor/github.com/go-playground/locales/twq_NE/twq_NE.go @@ -0,0 +1,563 @@ +package twq_NE + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type twq_NE struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'twq_NE' locale +func New() locales.Translator { + return &twq_NE{ + locale: "twq_NE", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Žan", "Fee", "Mar", "Awi", "Me", "Žuw", "Žuy", "Ut", "Sek", "Okt", "Noo", "Dee"}, + monthsNarrow: []string{"", "Ž", "F", "M", "A", "M", "Ž", "Ž", "U", "S", "O", "N", "D"}, + monthsWide: []string{"", "Žanwiye", "Feewiriye", "Marsi", "Awiril", "Me", "Žuweŋ", "Žuyye", "Ut", "Sektanbur", "Oktoobur", "Noowanbur", "Deesanbur"}, + daysAbbreviated: []string{"Alh", "Ati", "Ata", "Ala", "Alm", "Alz", "Asi"}, + daysNarrow: []string{"H", "T", "T", "L", "L", "L", "S"}, + daysWide: []string{"Alhadi", "Atinni", "Atalaata", "Alarba", "Alhamiisa", "Alzuma", "Asibti"}, + periodsAbbreviated: []string{"Subbaahi", "Zaarikay b"}, + periodsWide: []string{"Subbaahi", "Zaarikay b"}, + erasAbbreviated: []string{"IJ", "IZ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Isaa jine", "Isaa zamanoo"}, + timezones: map[string]string{"MESZ": "MESZ", "GMT": "GMT", "HNCU": "HNCU", "CAT": "CAT", "ACST": "ACST", "WITA": "WITA", "HEEG": "HEEG", "CDT": "CDT", "ECT": "ECT", "HKT": "HKT", "WAST": "WAST", "COT": "COT", "CST": "CST", "IST": "IST", "JST": "JST", "EDT": "EDT", "ACDT": "ACDT", "AKST": "AKST", "HAST": "HAST", "HADT": "HADT", "PST": "PST", "PDT": "PDT", "WAT": "WAT", "HNEG": "HNEG", "HAT": "HAT", "HNPM": "HNPM", "BOT": "BOT", "WART": "WART", "AST": "AST", "HKST": "HKST", "COST": "COST", "BT": "BT", "ChST": "ChST", "CHAST": "CHAST", "SGT": "SGT", "HNOG": "HNOG", "MDT": "MDT", "TMST": "TMST", "∅∅∅": "∅∅∅", "WEZ": "WEZ", "WESZ": "WESZ", "CLT": "CLT", "MST": "MST", "SAST": "SAST", "HECU": "HECU", "MYT": "MYT", "OESZ": "OESZ", "TMT": "TMT", "SRT": "SRT", "AWDT": "AWDT", "OEZ": "OEZ", "ART": "ART", "CHADT": "CHADT", "UYST": "UYST", "WIT": "WIT", "GFT": "GFT", "AKDT": "AKDT", "HEPM": "HEPM", "HNPMX": "HNPMX", "NZST": "NZST", "WARST": "WARST", "HEOG": "HEOG", "ADT": "ADT", "AEDT": "AEDT", "UYT": "UYT", "GYT": "GYT", "AWST": "AWST", "ACWST": "ACWST", "CLST": "CLST", "AEST": "AEST", "HEPMX": "HEPMX", "LHDT": "LHDT", "WIB": "WIB", "NZDT": "NZDT", "MEZ": "MEZ", "ARST": "ARST", "HNNOMX": "HNNOMX", "HENOMX": "HENOMX", "HNT": "HNT", "LHST": "LHST", "EAT": "EAT", "ACWDT": "ACWDT", "JDT": "JDT", "VET": "VET", "EST": "EST"}, + } +} + +// Locale returns the current translators string locale +func (twq *twq_NE) Locale() string { + return twq.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'twq_NE' +func (twq *twq_NE) PluralsCardinal() []locales.PluralRule { + return twq.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'twq_NE' +func (twq *twq_NE) PluralsOrdinal() []locales.PluralRule { + return twq.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'twq_NE' +func (twq *twq_NE) PluralsRange() []locales.PluralRule { + return twq.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'twq_NE' +func (twq *twq_NE) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'twq_NE' +func (twq *twq_NE) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'twq_NE' +func (twq *twq_NE) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (twq *twq_NE) MonthAbbreviated(month time.Month) string { + return twq.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (twq *twq_NE) MonthsAbbreviated() []string { + return twq.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (twq *twq_NE) MonthNarrow(month time.Month) string { + return twq.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (twq *twq_NE) MonthsNarrow() []string { + return twq.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (twq *twq_NE) MonthWide(month time.Month) string { + return twq.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (twq *twq_NE) MonthsWide() []string { + return twq.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (twq *twq_NE) WeekdayAbbreviated(weekday time.Weekday) string { + return twq.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (twq *twq_NE) WeekdaysAbbreviated() []string { + return twq.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (twq *twq_NE) WeekdayNarrow(weekday time.Weekday) string { + return twq.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (twq *twq_NE) WeekdaysNarrow() []string { + return twq.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (twq *twq_NE) WeekdayShort(weekday time.Weekday) string { + return twq.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (twq *twq_NE) WeekdaysShort() []string { + return twq.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (twq *twq_NE) WeekdayWide(weekday time.Weekday) string { + return twq.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (twq *twq_NE) WeekdaysWide() []string { + return twq.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'twq_NE' and handles both Whole and Real numbers based on 'v' +func (twq *twq_NE) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, twq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(twq.group) - 1; j >= 0; j-- { + b = append(b, twq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, twq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'twq_NE' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (twq *twq_NE) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, twq.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, twq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, twq.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'twq_NE' +func (twq *twq_NE) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := twq.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, twq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(twq.group) - 1; j >= 0; j-- { + b = append(b, twq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, twq.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, twq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'twq_NE' +// in accounting notation. +func (twq *twq_NE) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := twq.currencies[currency] + l := len(s) + len(symbol) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, twq.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(twq.group) - 1; j >= 0; j-- { + b = append(b, twq.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, twq.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, twq.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'twq_NE' +func (twq *twq_NE) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'twq_NE' +func (twq *twq_NE) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, twq.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'twq_NE' +func (twq *twq_NE) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, twq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'twq_NE' +func (twq *twq_NE) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, twq.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, twq.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'twq_NE' +func (twq *twq_NE) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, twq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'twq_NE' +func (twq *twq_NE) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, twq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, twq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'twq_NE' +func (twq *twq_NE) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, twq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, twq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'twq_NE' +func (twq *twq_NE) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, twq.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, twq.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := twq.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/twq_NE/twq_NE_test.go b/vendor/github.com/go-playground/locales/twq_NE/twq_NE_test.go new file mode 100644 index 0000000000..96bec05eb1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/twq_NE/twq_NE_test.go @@ -0,0 +1,1120 @@ +package twq_NE + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "twq_NE" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/tzm/tzm.go b/vendor/github.com/go-playground/locales/tzm/tzm.go new file mode 100644 index 0000000000..75338dcde1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/tzm/tzm.go @@ -0,0 +1,440 @@ +package tzm + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type tzm struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'tzm' locale +func New() locales.Translator { + return &tzm{ + locale: "tzm", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Yen", "Yeb", "Mar", "Ibr", "May", "Yun", "Yul", "Ɣuc", "Cut", "Kṭu", "Nwa", "Duj"}, + monthsNarrow: []string{"", "Y", "Y", "M", "I", "M", "Y", "Y", "Ɣ", "C", "K", "N", "D"}, + monthsWide: []string{"", "Yennayer", "Yebrayer", "Mars", "Ibrir", "Mayyu", "Yunyu", "Yulyuz", "Ɣuct", "Cutanbir", "Kṭuber", "Nwanbir", "Dujanbir"}, + daysAbbreviated: []string{"Asa", "Ayn", "Asn", "Akr", "Akw", "Asm", "Asḍ"}, + daysNarrow: []string{"A", "A", "A", "A", "A", "A", "A"}, + daysWide: []string{"Asamas", "Aynas", "Asinas", "Akras", "Akwas", "Asimwas", "Asiḍyas"}, + periodsAbbreviated: []string{"Zdat azal", "Ḍeffir aza"}, + periodsWide: []string{"Zdat azal", "Ḍeffir aza"}, + erasAbbreviated: []string{"ZƐ", "ḌƐ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Zdat Ɛisa (TAƔ)", "Ḍeffir Ɛisa (TAƔ)"}, + timezones: map[string]string{"GFT": "GFT", "LHST": "LHST", "JDT": "JDT", "AEST": "AEST", "EAT": "EAT", "SAST": "SAST", "AEDT": "AEDT", "CST": "CST", "CLST": "CLST", "HNEG": "HNEG", "WIT": "WIT", "HADT": "HADT", "AST": "AST", "ADT": "ADT", "TMT": "TMT", "HAT": "HAT", "COST": "COST", "BT": "BT", "ACWDT": "ACWDT", "WEZ": "WEZ", "GMT": "GMT", "ACST": "ACST", "MEZ": "MEZ", "OEZ": "OEZ", "HNOG": "HNOG", "MDT": "MDT", "AWST": "AWST", "HAST": "HAST", "IST": "IST", "VET": "VET", "CLT": "CLT", "HEOG": "HEOG", "HNPMX": "HNPMX", "HNCU": "HNCU", "JST": "JST", "MST": "MST", "CHADT": "CHADT", "SGT": "SGT", "PDT": "PDT", "HNPM": "HNPM", "ACDT": "ACDT", "ChST": "ChST", "HEPM": "HEPM", "CHAST": "CHAST", "CAT": "CAT", "NZST": "NZST", "WESZ": "WESZ", "EDT": "EDT", "WAST": "WAST", "HNNOMX": "HNNOMX", "AKDT": "AKDT", "WITA": "WITA", "UYT": "UYT", "WART": "WART", "ARST": "ARST", "HEEG": "HEEG", "GYT": "GYT", "ACWST": "ACWST", "ART": "ART", "HKT": "HKT", "COT": "COT", "HNT": "HNT", "AKST": "AKST", "HEPMX": "HEPMX", "SRT": "SRT", "HECU": "HECU", "WAT": "WAT", "OESZ": "OESZ", "WARST": "WARST", "TMST": "TMST", "BOT": "BOT", "WIB": "WIB", "AWDT": "AWDT", "ECT": "ECT", "UYST": "UYST", "HENOMX": "HENOMX", "∅∅∅": "∅∅∅", "LHDT": "LHDT", "CDT": "CDT", "NZDT": "NZDT", "MYT": "MYT", "EST": "EST", "PST": "PST", "MESZ": "MESZ", "HKST": "HKST"}, + } +} + +// Locale returns the current translators string locale +func (tzm *tzm) Locale() string { + return tzm.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'tzm' +func (tzm *tzm) PluralsCardinal() []locales.PluralRule { + return tzm.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'tzm' +func (tzm *tzm) PluralsOrdinal() []locales.PluralRule { + return tzm.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'tzm' +func (tzm *tzm) PluralsRange() []locales.PluralRule { + return tzm.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tzm' +func (tzm *tzm) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if (n >= 0 && n <= 1) || (n >= 11 && n <= 99) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tzm' +func (tzm *tzm) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tzm' +func (tzm *tzm) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (tzm *tzm) MonthAbbreviated(month time.Month) string { + return tzm.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (tzm *tzm) MonthsAbbreviated() []string { + return tzm.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (tzm *tzm) MonthNarrow(month time.Month) string { + return tzm.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (tzm *tzm) MonthsNarrow() []string { + return tzm.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (tzm *tzm) MonthWide(month time.Month) string { + return tzm.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (tzm *tzm) MonthsWide() []string { + return tzm.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (tzm *tzm) WeekdayAbbreviated(weekday time.Weekday) string { + return tzm.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (tzm *tzm) WeekdaysAbbreviated() []string { + return tzm.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (tzm *tzm) WeekdayNarrow(weekday time.Weekday) string { + return tzm.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (tzm *tzm) WeekdaysNarrow() []string { + return tzm.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (tzm *tzm) WeekdayShort(weekday time.Weekday) string { + return tzm.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (tzm *tzm) WeekdaysShort() []string { + return tzm.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (tzm *tzm) WeekdayWide(weekday time.Weekday) string { + return tzm.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (tzm *tzm) WeekdaysWide() []string { + return tzm.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'tzm' and handles both Whole and Real numbers based on 'v' +func (tzm *tzm) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'tzm' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (tzm *tzm) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tzm' +func (tzm *tzm) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tzm.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tzm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tzm.group) - 1; j >= 0; j-- { + b = append(b, tzm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tzm.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tzm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, tzm.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tzm' +// in accounting notation. +func (tzm *tzm) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tzm.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tzm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tzm.group) - 1; j >= 0; j-- { + b = append(b, tzm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, tzm.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tzm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, tzm.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, tzm.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'tzm' +func (tzm *tzm) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'tzm' +func (tzm *tzm) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tzm.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'tzm' +func (tzm *tzm) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tzm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'tzm' +func (tzm *tzm) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, tzm.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tzm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'tzm' +func (tzm *tzm) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'tzm' +func (tzm *tzm) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'tzm' +func (tzm *tzm) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'tzm' +func (tzm *tzm) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/tzm/tzm_test.go b/vendor/github.com/go-playground/locales/tzm/tzm_test.go new file mode 100644 index 0000000000..0ce2e4eeb6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/tzm/tzm_test.go @@ -0,0 +1,1120 @@ +package tzm + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "tzm" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/tzm_MA/tzm_MA.go b/vendor/github.com/go-playground/locales/tzm_MA/tzm_MA.go new file mode 100644 index 0000000000..7eda1e50b0 --- /dev/null +++ b/vendor/github.com/go-playground/locales/tzm_MA/tzm_MA.go @@ -0,0 +1,440 @@ +package tzm_MA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type tzm_MA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'tzm_MA' locale +func New() locales.Translator { + return &tzm_MA{ + locale: "tzm_MA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Yen", "Yeb", "Mar", "Ibr", "May", "Yun", "Yul", "Ɣuc", "Cut", "Kṭu", "Nwa", "Duj"}, + monthsNarrow: []string{"", "Y", "Y", "M", "I", "M", "Y", "Y", "Ɣ", "C", "K", "N", "D"}, + monthsWide: []string{"", "Yennayer", "Yebrayer", "Mars", "Ibrir", "Mayyu", "Yunyu", "Yulyuz", "Ɣuct", "Cutanbir", "Kṭuber", "Nwanbir", "Dujanbir"}, + daysAbbreviated: []string{"Asa", "Ayn", "Asn", "Akr", "Akw", "Asm", "Asḍ"}, + daysNarrow: []string{"A", "A", "A", "A", "A", "A", "A"}, + daysWide: []string{"Asamas", "Aynas", "Asinas", "Akras", "Akwas", "Asimwas", "Asiḍyas"}, + periodsAbbreviated: []string{"Zdat azal", "Ḍeffir aza"}, + periodsWide: []string{"Zdat azal", "Ḍeffir aza"}, + erasAbbreviated: []string{"ZƐ", "ḌƐ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Zdat Ɛisa (TAƔ)", "Ḍeffir Ɛisa (TAƔ)"}, + timezones: map[string]string{"∅∅∅": "∅∅∅", "AEDT": "AEDT", "LHDT": "LHDT", "HAST": "HAST", "HNOG": "HNOG", "OEZ": "OEZ", "HAT": "HAT", "EAT": "EAT", "WIB": "WIB", "PST": "PST", "CDT": "CDT", "NZDT": "NZDT", "CLT": "CLT", "ADT": "ADT", "HEEG": "HEEG", "HEPM": "HEPM", "CST": "CST", "ACWST": "ACWST", "HKT": "HKT", "SGT": "SGT", "ACWDT": "ACWDT", "WART": "WART", "HKST": "HKST", "COT": "COT", "HNT": "HNT", "WITA": "WITA", "HNEG": "HNEG", "AEST": "AEST", "WARST": "WARST", "CLST": "CLST", "AST": "AST", "TMST": "TMST", "ARST": "ARST", "WAT": "WAT", "ChST": "ChST", "UYT": "UYT", "BOT": "BOT", "HECU": "HECU", "AWST": "AWST", "MEZ": "MEZ", "OESZ": "OESZ", "ACDT": "ACDT", "HNPM": "HNPM", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "ECT": "ECT", "WEZ": "WEZ", "MST": "MST", "EDT": "EDT", "WESZ": "WESZ", "TMT": "TMT", "MDT": "MDT", "ART": "ART", "HADT": "HADT", "GMT": "GMT", "HNNOMX": "HNNOMX", "JST": "JST", "JDT": "JDT", "GFT": "GFT", "AKDT": "AKDT", "UYST": "UYST", "CAT": "CAT", "HEOG": "HEOG", "PDT": "PDT", "MESZ": "MESZ", "WAST": "WAST", "BT": "BT", "AKST": "AKST", "GYT": "GYT", "CHADT": "CHADT", "VET": "VET", "MYT": "MYT", "COST": "COST", "HNCU": "HNCU", "CHAST": "CHAST", "IST": "IST", "NZST": "NZST", "ACST": "ACST", "SAST": "SAST", "LHST": "LHST", "SRT": "SRT", "EST": "EST", "HENOMX": "HENOMX", "WIT": "WIT", "AWDT": "AWDT"}, + } +} + +// Locale returns the current translators string locale +func (tzm *tzm_MA) Locale() string { + return tzm.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'tzm_MA' +func (tzm *tzm_MA) PluralsCardinal() []locales.PluralRule { + return tzm.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'tzm_MA' +func (tzm *tzm_MA) PluralsOrdinal() []locales.PluralRule { + return tzm.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'tzm_MA' +func (tzm *tzm_MA) PluralsRange() []locales.PluralRule { + return tzm.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'tzm_MA' +func (tzm *tzm_MA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if (n >= 0 && n <= 1) || (n >= 11 && n <= 99) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'tzm_MA' +func (tzm *tzm_MA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'tzm_MA' +func (tzm *tzm_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (tzm *tzm_MA) MonthAbbreviated(month time.Month) string { + return tzm.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (tzm *tzm_MA) MonthsAbbreviated() []string { + return tzm.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (tzm *tzm_MA) MonthNarrow(month time.Month) string { + return tzm.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (tzm *tzm_MA) MonthsNarrow() []string { + return tzm.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (tzm *tzm_MA) MonthWide(month time.Month) string { + return tzm.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (tzm *tzm_MA) MonthsWide() []string { + return tzm.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (tzm *tzm_MA) WeekdayAbbreviated(weekday time.Weekday) string { + return tzm.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (tzm *tzm_MA) WeekdaysAbbreviated() []string { + return tzm.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (tzm *tzm_MA) WeekdayNarrow(weekday time.Weekday) string { + return tzm.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (tzm *tzm_MA) WeekdaysNarrow() []string { + return tzm.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (tzm *tzm_MA) WeekdayShort(weekday time.Weekday) string { + return tzm.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (tzm *tzm_MA) WeekdaysShort() []string { + return tzm.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (tzm *tzm_MA) WeekdayWide(weekday time.Weekday) string { + return tzm.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (tzm *tzm_MA) WeekdaysWide() []string { + return tzm.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'tzm_MA' and handles both Whole and Real numbers based on 'v' +func (tzm *tzm_MA) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'tzm_MA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (tzm *tzm_MA) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'tzm_MA' +func (tzm *tzm_MA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tzm.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tzm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tzm.group) - 1; j >= 0; j-- { + b = append(b, tzm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, tzm.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tzm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, tzm.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'tzm_MA' +// in accounting notation. +func (tzm *tzm_MA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := tzm.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, tzm.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(tzm.group) - 1; j >= 0; j-- { + b = append(b, tzm.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, tzm.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, tzm.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, tzm.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, tzm.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'tzm_MA' +func (tzm *tzm_MA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'tzm_MA' +func (tzm *tzm_MA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tzm.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'tzm_MA' +func (tzm *tzm_MA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tzm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'tzm_MA' +func (tzm *tzm_MA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, tzm.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, tzm.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'tzm_MA' +func (tzm *tzm_MA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'tzm_MA' +func (tzm *tzm_MA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'tzm_MA' +func (tzm *tzm_MA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'tzm_MA' +func (tzm *tzm_MA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/tzm_MA/tzm_MA_test.go b/vendor/github.com/go-playground/locales/tzm_MA/tzm_MA_test.go new file mode 100644 index 0000000000..4b50adf4fe --- /dev/null +++ b/vendor/github.com/go-playground/locales/tzm_MA/tzm_MA_test.go @@ -0,0 +1,1120 @@ +package tzm_MA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "tzm_MA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ug/ug.go b/vendor/github.com/go-playground/locales/ug/ug.go new file mode 100644 index 0000000000..c6ebf7f595 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ug/ug.go @@ -0,0 +1,643 @@ +package ug + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ug struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ug' locale +func New() locales.Translator { + return &ug{ + locale: "ug", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "يانۋار", "فېۋرال", "مارت", "ئاپرېل", "ماي", "ئىيۇن", "ئىيۇل", "ئاۋغۇست", "سېنتەبىر", "ئۆكتەبىر", "نويابىر", "دېكابىر"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "يانۋار", "فېۋرال", "مارت", "ئاپرېل", "ماي", "ئىيۇن", "ئىيۇل", "ئاۋغۇست", "سېنتەبىر", "ئۆكتەبىر", "نويابىر", "دېكابىر"}, + daysAbbreviated: []string{"يە", "دۈ", "سە", "چا", "پە", "جۈ", "شە"}, + daysNarrow: []string{"ي", "د", "س", "چ", "پ", "ج", "ش"}, + daysShort: []string{"ي", "د", "س", "چ", "پ", "ج", "ش"}, + daysWide: []string{"يەكشەنبە", "دۈشەنبە", "سەيشەنبە", "چارشەنبە", "پەيشەنبە", "جۈمە", "شەنبە"}, + periodsAbbreviated: []string{"چ.ب", "چ.ك"}, + periodsNarrow: []string{"ب", "ك"}, + periodsWide: []string{"چۈشتىن بۇرۇن", "چۈشتىن كېيىن"}, + erasAbbreviated: []string{"BCE", "مىلادىيە"}, + erasNarrow: []string{"BCE", "مىلادىيە"}, + erasWide: []string{"مىلادىيەدىن بۇرۇن", "مىلادىيە"}, + timezones: map[string]string{"EAT": "شەرقىي ئافرىقا ۋاقتى", "HNEG": "شەرقىي گىرېنلاند ئۆلچەملىك ۋاقتى", "LHDT": "لورد-خاي يازلىق ۋاقتى", "CHAST": "چاتام ئۆلچەملىك ۋاقتى", "SGT": "سىنگاپور ۋاقتى", "PDT": "تىنچ ئوكيان يازلىق ۋاقتى", "ADT": "ئاتلانتىك ئوكيان يازلىق ۋاقتى", "OESZ": "شەرقىي ياۋروپا يازلىق ۋاقتى", "UYT": "ئۇرۇگۋاي ئۆلچەملىك ۋاقتى", "HNPMX": "مېكسىكا تىنچ ئوكيان ئۆلچەملىك ۋاقتى", "SAST": "جەنۇبىي ئافرىقا ئۆلچەملىك ۋاقتى", "CDT": "ئوتتۇرا قىسىم يازلىق ۋاقتى", "PST": "تىنچ ئوكيان ئۆلچەملىك ۋاقتى", "JDT": "ياپونىيە يازلىق ۋاقتى", "ARST": "ئارگېنتىنا يازلىق ۋاقتى", "WAST": "غەربىي ئافرىقا يازلىق ۋاقتى", "EDT": "شەرقىي قىسىم يازلىق ۋاقتى", "HKT": "شياڭگاڭ ئۆلچەملىك ۋاقتى", "CHADT": "چاتام يازلىق ۋاقتى", "JST": "ياپونىيە ئۆلچەملىك ۋاقتى", "MDT": "ئاۋمېن يازلىق ۋاقتى", "GYT": "گىۋىيانا ۋاقتى", "BOT": "بولىۋىيە ۋاقتى", "HADT": "ھاۋاي-ئالېيۇت يازلىق ۋاقتى", "ACWDT": "ئاۋسترالىيە ئوتتۇرا غەربىي قىسىم يازلىق ۋاقتى", "NZST": "يېڭى زېلاندىيە ئۆلچەملىك ۋاقتى", "AST": "ئاتلانتىك ئوكيان ئۆلچەملىك ۋاقتى", "WART": "غەربىي ئارگېنتىنا ئۆلچەملىك ۋاقتى", "ChST": "چاموررو ئۆلچەملىك ۋاقتى", "HNCU": "كۇبا ئۆلچەملىك ۋاقتى", "CST": "ئوتتۇرا قىسىم ئۆلچەملىك ۋاقتى", "CAT": "ئوتتۇرا ئافرىقا ۋاقتى", "HEOG": "غەربىي گىرېنلاند يازلىق ۋاقتى", "HEEG": "شەرقىي گىرېنلاند يازلىق ۋاقتى", "AKST": "ئالياسكا ئۆلچەملىك ۋاقتى", "HEPMX": "مېكسىكا تىنچ ئوكيان يازلىق ۋاقتى", "AWST": "ئاۋسترالىيە غەربىي قىسىم ئۆلچەملىك ۋاقتى", "WEZ": "غەربىي ياۋروپا ئۆلچەملىك ۋاقتى", "WESZ": "غەربىي ياۋروپا يازلىق ۋاقتى", "CLT": "چىلى ئۆلچەملىك ۋاقتى", "ART": "ئارگېنتىنا ئۆلچەملىك ۋاقتى", "COST": "كولومبىيە يازلىق ۋاقتى", "HENOMX": "مېكسىكا غەربىي شىمالىي قىسىم يازلىق ۋاقتى", "VET": "ۋېنېزۇئېلا ۋاقتى", "MYT": "مالايشىيا ۋاقتى", "TMT": "تۈركمەنىستان ئۆلچەملىك ۋاقتى", "GFT": "فىرانسىيەگە قاراشلىق گىۋىيانا ۋاقتى", "∅∅∅": "بىرازىلىيە يازلىق ۋاقتى", "NZDT": "يېڭى زېلاندىيە يازلىق ۋاقتى", "OEZ": "شەرقىي ياۋروپا ئۆلچەملىك ۋاقتى", "CLST": "چىلى يازلىق ۋاقتى", "MST": "ئاۋمېن ئۆلچەملىك ۋاقتى", "AEST": "ئاۋسترالىيە شەرقىي قىسىم ئۆلچەملىك ۋاقتى", "HNPM": "ساينىت پىئېر ۋە مىكېلون ئۆلچەملىك ۋاقتى", "HKST": "شياڭگاڭ يازلىق ۋاقتى", "COT": "كولومبىيە ئۆلچەملىك ۋاقتى", "HNOG": "غەربىي گىرېنلاند ئۆلچەملىك ۋاقتى", "WARST": "غەربىي ئارگېنتىنا يازلىق ۋاقتى", "HNNOMX": "مېكسىكا غەربىي شىمالىي قىسىم ئۆلچەملىك ۋاقتى", "AEDT": "ئاۋسترالىيە شەرقىي قىسىم يازلىق ۋاقتى", "AWDT": "ئاۋسترالىيە غەربىي قىسىم يازلىق ۋاقتى", "ACWST": "ئاۋستىرالىيە ئوتتۇرا غەربىي قىسىم ئۆلچەملىك ۋاقتى", "TMST": "تۈركمەنىستان يازلىق ۋاقتى", "ACST": "ئاۋسترالىيە ئوتتۇرا قىسىم ئۆلچەملىك ۋاقتى", "HAT": "نىۋفوئۇنلاند يازلىق ۋاقتى", "LHST": "لورد-خاي ئۆلچەملىك ۋاقتى", "WIT": "شەرقىي ھىندونېزىيە ۋاقتى", "WAT": "غەربىي ئافرىقا ئۆلچەملىك ۋاقتى", "HNT": "نىۋفوئۇنلاند ئۆلچەملىك ۋاقتى", "WITA": "ئوتتۇرا ھىندونېزىيە ۋاقتى", "AKDT": "ئالياسكا يازلىق ۋاقتى", "MESZ": "ئوتتۇرا ياۋروپا يازلىق ۋاقتى", "GMT": "گىرىنۋىچ ۋاقتى", "BT": "بۇتان ۋاقتى", "UYST": "ئۇرۇگۋاي يازلىق ۋاقتى", "HEPM": "ساينىت پىئېر ۋە مىكېلون يازلىق ۋاقتى", "SRT": "سۇرىنام ۋاقتى", "WIB": "غەربىي ھىندونېزىيە ۋاقتى", "HAST": "ھاۋاي-ئالېيۇت ئۆلچەملىك ۋاقتى", "ECT": "ئېكۋادور ۋاقتى", "MEZ": "ئوتتۇرا ياۋروپا ئۆلچەملىك ۋاقتى", "EST": "شەرقىي قىسىم ئۆلچەملىك ۋاقتى", "ACDT": "ئاۋسترالىيە ئوتتۇرا قىسىم يازلىق ۋاقتى", "HECU": "كۇبا يازلىق ۋاقتى", "IST": "ھىندىستان ئۆلچەملىك ۋاقتى"}, + } +} + +// Locale returns the current translators string locale +func (ug *ug) Locale() string { + return ug.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ug' +func (ug *ug) PluralsCardinal() []locales.PluralRule { + return ug.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ug' +func (ug *ug) PluralsOrdinal() []locales.PluralRule { + return ug.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ug' +func (ug *ug) PluralsRange() []locales.PluralRule { + return ug.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ug' +func (ug *ug) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ug' +func (ug *ug) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ug' +func (ug *ug) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ug.CardinalPluralRule(num1, v1) + end := ug.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ug *ug) MonthAbbreviated(month time.Month) string { + return ug.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ug *ug) MonthsAbbreviated() []string { + return ug.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ug *ug) MonthNarrow(month time.Month) string { + return ug.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ug *ug) MonthsNarrow() []string { + return ug.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ug *ug) MonthWide(month time.Month) string { + return ug.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ug *ug) MonthsWide() []string { + return ug.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ug *ug) WeekdayAbbreviated(weekday time.Weekday) string { + return ug.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ug *ug) WeekdaysAbbreviated() []string { + return ug.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ug *ug) WeekdayNarrow(weekday time.Weekday) string { + return ug.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ug *ug) WeekdaysNarrow() []string { + return ug.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ug *ug) WeekdayShort(weekday time.Weekday) string { + return ug.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ug *ug) WeekdaysShort() []string { + return ug.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ug *ug) WeekdayWide(weekday time.Weekday) string { + return ug.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ug *ug) WeekdaysWide() []string { + return ug.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ug' and handles both Whole and Real numbers based on 'v' +func (ug *ug) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ug.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ug.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ug.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ug' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ug *ug) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ug.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ug.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ug.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ug' +func (ug *ug) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ug.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ug.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ug.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ug.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ug.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ug' +// in accounting notation. +func (ug *ug) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ug.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ug.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ug.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ug.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ug.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ug.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ug' +func (ug *ug) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ug' +func (ug *ug) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ug.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ug' +func (ug *ug) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ug.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ug' +func (ug *ug) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ug.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = append(b, ug.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ug' +func (ug *ug) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ug.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ug.periodsAbbreviated[0]...) + } else { + b = append(b, ug.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ug' +func (ug *ug) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ug.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ug.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ug.periodsAbbreviated[0]...) + } else { + b = append(b, ug.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ug' +func (ug *ug) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ug.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ug.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ug.periodsAbbreviated[0]...) + } else { + b = append(b, ug.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ug' +func (ug *ug) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ug.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ug.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ug.periodsAbbreviated[0]...) + } else { + b = append(b, ug.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ug.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ug/ug_test.go b/vendor/github.com/go-playground/locales/ug/ug_test.go new file mode 100644 index 0000000000..565a0181d2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ug/ug_test.go @@ -0,0 +1,1120 @@ +package ug + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ug" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ug_CN/ug_CN.go b/vendor/github.com/go-playground/locales/ug_CN/ug_CN.go new file mode 100644 index 0000000000..0e180bb5bf --- /dev/null +++ b/vendor/github.com/go-playground/locales/ug_CN/ug_CN.go @@ -0,0 +1,643 @@ +package ug_CN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ug_CN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ug_CN' locale +func New() locales.Translator { + return &ug_CN{ + locale: "ug_CN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "يانۋار", "فېۋرال", "مارت", "ئاپرېل", "ماي", "ئىيۇن", "ئىيۇل", "ئاۋغۇست", "سېنتەبىر", "ئۆكتەبىر", "نويابىر", "دېكابىر"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "يانۋار", "فېۋرال", "مارت", "ئاپرېل", "ماي", "ئىيۇن", "ئىيۇل", "ئاۋغۇست", "سېنتەبىر", "ئۆكتەبىر", "نويابىر", "دېكابىر"}, + daysAbbreviated: []string{"يە", "دۈ", "سە", "چا", "پە", "جۈ", "شە"}, + daysNarrow: []string{"ي", "د", "س", "چ", "پ", "ج", "ش"}, + daysShort: []string{"ي", "د", "س", "چ", "پ", "ج", "ش"}, + daysWide: []string{"يەكشەنبە", "دۈشەنبە", "سەيشەنبە", "چارشەنبە", "پەيشەنبە", "جۈمە", "شەنبە"}, + periodsAbbreviated: []string{"چ.ب", "چ.ك"}, + periodsNarrow: []string{"ب", "ك"}, + periodsWide: []string{"چۈشتىن بۇرۇن", "چۈشتىن كېيىن"}, + erasAbbreviated: []string{"BCE", "مىلادىيە"}, + erasNarrow: []string{"BCE", "مىلادىيە"}, + erasWide: []string{"مىلادىيەدىن بۇرۇن", "مىلادىيە"}, + timezones: map[string]string{"WART": "غەربىي ئارگېنتىنا ئۆلچەملىك ۋاقتى", "ARST": "ئارگېنتىنا يازلىق ۋاقتى", "COST": "كولومبىيە يازلىق ۋاقتى", "HEPM": "ساينىت پىئېر ۋە مىكېلون يازلىق ۋاقتى", "VET": "ۋېنېزۇئېلا ۋاقتى", "JST": "ياپونىيە ئۆلچەملىك ۋاقتى", "AST": "ئاتلانتىك ئوكيان ئۆلچەملىك ۋاقتى", "EST": "شەرقىي قىسىم ئۆلچەملىك ۋاقتى", "HEEG": "شەرقىي گىرېنلاند يازلىق ۋاقتى", "UYST": "ئۇرۇگۋاي يازلىق ۋاقتى", "AWST": "ئاۋسترالىيە غەربىي قىسىم ئۆلچەملىك ۋاقتى", "HAST": "ھاۋاي-ئالېيۇت ئۆلچەملىك ۋاقتى", "CLT": "چىلى ئۆلچەملىك ۋاقتى", "SAST": "جەنۇبىي ئافرىقا ئۆلچەملىك ۋاقتى", "HENOMX": "مېكسىكا غەربىي شىمالىي قىسىم يازلىق ۋاقتى", "WITA": "ئوتتۇرا ھىندونېزىيە ۋاقتى", "AEDT": "ئاۋسترالىيە شەرقىي قىسىم يازلىق ۋاقتى", "OESZ": "شەرقىي ياۋروپا يازلىق ۋاقتى", "MST": "ئاۋمېن ئۆلچەملىك ۋاقتى", "HNOG": "غەربىي گىرېنلاند ئۆلچەملىك ۋاقتى", "EDT": "شەرقىي قىسىم يازلىق ۋاقتى", "HAT": "نىۋفوئۇنلاند يازلىق ۋاقتى", "EAT": "شەرقىي ئافرىقا ۋاقتى", "∅∅∅": "بىرازىلىيە يازلىق ۋاقتى", "PST": "تىنچ ئوكيان ئۆلچەملىك ۋاقتى", "HNPM": "ساينىت پىئېر ۋە مىكېلون ئۆلچەملىك ۋاقتى", "HECU": "كۇبا يازلىق ۋاقتى", "WAST": "غەربىي ئافرىقا يازلىق ۋاقتى", "ChST": "چاموررو ئۆلچەملىك ۋاقتى", "MYT": "مالايشىيا ۋاقتى", "GFT": "فىرانسىيەگە قاراشلىق گىۋىيانا ۋاقتى", "HNCU": "كۇبا ئۆلچەملىك ۋاقتى", "CDT": "ئوتتۇرا قىسىم يازلىق ۋاقتى", "MESZ": "ئوتتۇرا ياۋروپا يازلىق ۋاقتى", "HNNOMX": "مېكسىكا غەربىي شىمالىي قىسىم ئۆلچەملىك ۋاقتى", "GYT": "گىۋىيانا ۋاقتى", "CST": "ئوتتۇرا قىسىم ئۆلچەملىك ۋاقتى", "WESZ": "غەربىي ياۋروپا يازلىق ۋاقتى", "HNEG": "شەرقىي گىرېنلاند ئۆلچەملىك ۋاقتى", "AEST": "ئاۋسترالىيە شەرقىي قىسىم ئۆلچەملىك ۋاقتى", "HEPMX": "مېكسىكا تىنچ ئوكيان يازلىق ۋاقتى", "AWDT": "ئاۋسترالىيە غەربىي قىسىم يازلىق ۋاقتى", "HNT": "نىۋفوئۇنلاند ئۆلچەملىك ۋاقتى", "HEOG": "غەربىي گىرېنلاند يازلىق ۋاقتى", "ADT": "ئاتلانتىك ئوكيان يازلىق ۋاقتى", "WEZ": "غەربىي ياۋروپا ئۆلچەملىك ۋاقتى", "HKT": "شياڭگاڭ ئۆلچەملىك ۋاقتى", "HKST": "شياڭگاڭ يازلىق ۋاقتى", "AKDT": "ئالياسكا يازلىق ۋاقتى", "HADT": "ھاۋاي-ئالېيۇت يازلىق ۋاقتى", "WARST": "غەربىي ئارگېنتىنا يازلىق ۋاقتى", "UYT": "ئۇرۇگۋاي ئۆلچەملىك ۋاقتى", "LHST": "لورد-خاي ئۆلچەملىك ۋاقتى", "LHDT": "لورد-خاي يازلىق ۋاقتى", "WIB": "غەربىي ھىندونېزىيە ۋاقتى", "NZDT": "يېڭى زېلاندىيە يازلىق ۋاقتى", "ART": "ئارگېنتىنا ئۆلچەملىك ۋاقتى", "HNPMX": "مېكسىكا تىنچ ئوكيان ئۆلچەملىك ۋاقتى", "WIT": "شەرقىي ھىندونېزىيە ۋاقتى", "CLST": "چىلى يازلىق ۋاقتى", "ECT": "ئېكۋادور ۋاقتى", "NZST": "يېڭى زېلاندىيە ئۆلچەملىك ۋاقتى", "JDT": "ياپونىيە يازلىق ۋاقتى", "OEZ": "شەرقىي ياۋروپا ئۆلچەملىك ۋاقتى", "GMT": "گىرىنۋىچ ۋاقتى", "ACDT": "ئاۋسترالىيە ئوتتۇرا قىسىم يازلىق ۋاقتى", "CHAST": "چاتام ئۆلچەملىك ۋاقتى", "SGT": "سىنگاپور ۋاقتى", "CAT": "ئوتتۇرا ئافرىقا ۋاقتى", "WAT": "غەربىي ئافرىقا ئۆلچەملىك ۋاقتى", "COT": "كولومبىيە ئۆلچەملىك ۋاقتى", "CHADT": "چاتام يازلىق ۋاقتى", "BOT": "بولىۋىيە ۋاقتى", "TMST": "تۈركمەنىستان يازلىق ۋاقتى", "BT": "بۇتان ۋاقتى", "AKST": "ئالياسكا ئۆلچەملىك ۋاقتى", "SRT": "سۇرىنام ۋاقتى", "ACWDT": "ئاۋسترالىيە ئوتتۇرا غەربىي قىسىم يازلىق ۋاقتى", "MEZ": "ئوتتۇرا ياۋروپا ئۆلچەملىك ۋاقتى", "ACWST": "ئاۋستىرالىيە ئوتتۇرا غەربىي قىسىم ئۆلچەملىك ۋاقتى", "TMT": "تۈركمەنىستان ئۆلچەملىك ۋاقتى", "MDT": "ئاۋمېن يازلىق ۋاقتى", "ACST": "ئاۋسترالىيە ئوتتۇرا قىسىم ئۆلچەملىك ۋاقتى", "PDT": "تىنچ ئوكيان يازلىق ۋاقتى", "IST": "ھىندىستان ئۆلچەملىك ۋاقتى"}, + } +} + +// Locale returns the current translators string locale +func (ug *ug_CN) Locale() string { + return ug.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ug_CN' +func (ug *ug_CN) PluralsCardinal() []locales.PluralRule { + return ug.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ug_CN' +func (ug *ug_CN) PluralsOrdinal() []locales.PluralRule { + return ug.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ug_CN' +func (ug *ug_CN) PluralsRange() []locales.PluralRule { + return ug.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ug_CN' +func (ug *ug_CN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ug_CN' +func (ug *ug_CN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ug_CN' +func (ug *ug_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := ug.CardinalPluralRule(num1, v1) + end := ug.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ug *ug_CN) MonthAbbreviated(month time.Month) string { + return ug.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ug *ug_CN) MonthsAbbreviated() []string { + return ug.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ug *ug_CN) MonthNarrow(month time.Month) string { + return ug.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ug *ug_CN) MonthsNarrow() []string { + return ug.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ug *ug_CN) MonthWide(month time.Month) string { + return ug.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ug *ug_CN) MonthsWide() []string { + return ug.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ug *ug_CN) WeekdayAbbreviated(weekday time.Weekday) string { + return ug.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ug *ug_CN) WeekdaysAbbreviated() []string { + return ug.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ug *ug_CN) WeekdayNarrow(weekday time.Weekday) string { + return ug.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ug *ug_CN) WeekdaysNarrow() []string { + return ug.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ug *ug_CN) WeekdayShort(weekday time.Weekday) string { + return ug.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ug *ug_CN) WeekdaysShort() []string { + return ug.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ug *ug_CN) WeekdayWide(weekday time.Weekday) string { + return ug.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ug *ug_CN) WeekdaysWide() []string { + return ug.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ug_CN' and handles both Whole and Real numbers based on 'v' +func (ug *ug_CN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ug.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ug.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ug.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ug_CN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ug *ug_CN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ug.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, ug.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ug.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ug_CN' +func (ug *ug_CN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ug.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ug.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ug.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, ug.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ug.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ug_CN' +// in accounting notation. +func (ug *ug_CN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ug.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ug.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ug.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, ug.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ug.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, ug.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ug_CN' +func (ug *ug_CN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ug_CN' +func (ug *ug_CN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ug.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ug_CN' +func (ug *ug_CN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ug.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ug_CN' +func (ug *ug_CN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, ug.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = append(b, ug.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ug_CN' +func (ug *ug_CN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ug.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ug.periodsAbbreviated[0]...) + } else { + b = append(b, ug.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ug_CN' +func (ug *ug_CN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ug.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ug.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ug.periodsAbbreviated[0]...) + } else { + b = append(b, ug.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ug_CN' +func (ug *ug_CN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ug.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ug.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ug.periodsAbbreviated[0]...) + } else { + b = append(b, ug.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ug_CN' +func (ug *ug_CN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ug.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ug.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ug.periodsAbbreviated[0]...) + } else { + b = append(b, ug.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ug.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ug_CN/ug_CN_test.go b/vendor/github.com/go-playground/locales/ug_CN/ug_CN_test.go new file mode 100644 index 0000000000..e40143e6b8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ug_CN/ug_CN_test.go @@ -0,0 +1,1120 @@ +package ug_CN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ug_CN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uk/uk.go b/vendor/github.com/go-playground/locales/uk/uk.go new file mode 100644 index 0000000000..914406e77c --- /dev/null +++ b/vendor/github.com/go-playground/locales/uk/uk.go @@ -0,0 +1,653 @@ +package uk + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uk struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uk' locale +func New() locales.Translator { + return &uk{ + locale: "uk", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{4, 6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "₴", "крб.", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "січ.", "лют.", "бер.", "квіт.", "трав.", "черв.", "лип.", "серп.", "вер.", "жовт.", "лист.", "груд."}, + monthsNarrow: []string{"", "с", "л", "б", "к", "т", "ч", "л", "с", "в", "ж", "л", "г"}, + monthsWide: []string{"", "січня", "лютого", "березня", "квітня", "травня", "червня", "липня", "серпня", "вересня", "жовтня", "листопада", "грудня"}, + daysAbbreviated: []string{"нд", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"Н", "П", "В", "С", "Ч", "П", "С"}, + daysShort: []string{"нд", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"неділя", "понеділок", "вівторок", "середа", "четвер", "пʼятниця", "субота"}, + periodsAbbreviated: []string{"дп", "пп"}, + periodsNarrow: []string{"дп", "пп"}, + periodsWide: []string{"дп", "пп"}, + erasAbbreviated: []string{"до н. е.", "н. е."}, + erasNarrow: []string{"до н.е.", "н.е."}, + erasWide: []string{"до нашої ери", "нашої ери"}, + timezones: map[string]string{"HEEG": "за літнім східним часом у Гренландії", "LHDT": "за літнім часом на острові Лорд-Хау", "HECU": "за літнім часом на Кубі", "NZDT": "за літнім часом у Новій Зеландії", "ART": "за стандартним аргентинським часом", "EST": "за північноамериканським східним стандартним часом", "EDT": "за північноамериканським східним літнім часом", "HNEG": "за стандартним східним часом у Гренландії", "AKDT": "за літнім часом на Алясці", "AWDT": "за літнім західноавстралійським часом", "OEZ": "за східноєвропейським стандартним часом", "TMT": "за стандартним часом у Туркменістані", "WIB": "за західноіндонезійським часом", "SGT": "за часом у Сінгапурі", "IST": "за індійським стандартним часом", "MEZ": "за центральноєвропейським стандартним часом", "JST": "за японським стандартним часом", "MDT": "за північноамериканським гірським літнім часом", "AWST": "за стандартним західноавстралійським часом", "ACWST": "за стандартним центральнозахідним австралійським часом", "HKST": "за літнім часом у Гонконзі", "HAT": "за літнім часом у Ньюфаундленд", "AEDT": "за літнім східноавстралійським часом", "BOT": "за болівійським часом", "MESZ": "за центральноєвропейським літнім часом", "COT": "за стандартним колумбійським часом", "ARST": "за літнім аргентинським часом", "GFT": "за часом Французької Гвіани", "HNPM": "за стандартним часом на островах Сен-П’єр і Мікелон", "PDT": "за північноамериканським тихоокеанським літнім часом", "HADT": "за літнім гавайсько-алеутським часом", "GMT": "за Гринвічем", "WAT": "за західноафриканським стандартним часом", "AKST": "за стандартним часом на Алясці", "HNPMX": "за стандартним тихоокеанським часом у Мексиці", "ACWDT": "за літнім центральнозахідним австралійським часом", "NZST": "за стандартним часом у Новій Зеландії", "MYT": "за часом у Малайзії", "BT": "за часом у Бутані", "UYT": "за стандартним часом в Уругваї", "HEPM": "за літнім часом на островах Сен-П’єр і Мікелон", "SAST": "за південноафриканським часом", "CAT": "за центральноафриканським часом", "HNNOMX": "за стандартним північнозахідним часом у Мексиці", "CHAST": "за стандартним часом на архіпелазі Чатем", "ADT": "за атлантичним літнім часом", "ACDT": "за літнім центральноавстралійським часом", "WITA": "за центральноіндонезійським часом", "MST": "за північноамериканським гірським стандартним часом", "HEPMX": "за літнім тихоокеанським часом у Мексиці", "SRT": "за часом у Суринамі", "WIT": "за східноіндонезійським часом", "COST": "за літнім колумбійським часом", "HNOG": "за стандартним західним часом у Гренландії", "HKT": "за стандартним часом у Гонконзі", "∅∅∅": "час: Акрі, літній", "ChST": "за часом на Північних Маріанських островах", "LHST": "за стандартним часом на острові Лорд-Хау", "GYT": "за часом у Гаяні", "CHADT": "за літнім часом на архіпелазі Чатем", "AST": "за атлантичним стандартним часом", "HNCU": "за стандартним часом на Кубі", "ECT": "за часом в Еквадорі", "VET": "за часом у Венесуелі", "CLT": "за стандартним чилійським часом", "HEOG": "за літнім західним часом у Гренландії", "ACST": "за стандартним центральноавстралійським часом", "AEST": "за стандартним східноавстралійським часом", "UYST": "за літнім часом в Уругваї", "EAT": "за східноафриканським часом", "CDT": "за північноамериканським центральним літнім часом", "WART": "за стандартним західноаргентинським часом", "CST": "за північноамериканським центральним стандартним часом", "JDT": "за японським літнім часом", "WESZ": "за західноєвропейським літнім часом", "HENOMX": "за літнім північнозахідним часом у Мексиці", "CLST": "за літнім чилійським часом", "WEZ": "за західноєвропейським стандартним часом", "WARST": "за літнім за західноаргентинським часом", "WAST": "за західноафриканським літнім часом", "HNT": "за стандартним часом на острові Ньюфаундленд", "PST": "за північноамериканським тихоокеанським стандартним часом", "HAST": "за стандартним гавайсько-алеутським часом", "OESZ": "за східноєвропейським літнім часом", "TMST": "за літнім часом у Туркменістані"}, + } +} + +// Locale returns the current translators string locale +func (uk *uk) Locale() string { + return uk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uk' +func (uk *uk) PluralsCardinal() []locales.PluralRule { + return uk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uk' +func (uk *uk) PluralsOrdinal() []locales.PluralRule { + return uk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uk' +func (uk *uk) PluralsRange() []locales.PluralRule { + return uk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uk' +func (uk *uk) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uk' +func (uk *uk) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uk' +func (uk *uk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uk.CardinalPluralRule(num1, v1) + end := uk.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uk *uk) MonthAbbreviated(month time.Month) string { + return uk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uk *uk) MonthsAbbreviated() []string { + return uk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uk *uk) MonthNarrow(month time.Month) string { + return uk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uk *uk) MonthsNarrow() []string { + return uk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uk *uk) MonthWide(month time.Month) string { + return uk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uk *uk) MonthsWide() []string { + return uk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uk *uk) WeekdayAbbreviated(weekday time.Weekday) string { + return uk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uk *uk) WeekdaysAbbreviated() []string { + return uk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uk *uk) WeekdayNarrow(weekday time.Weekday) string { + return uk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uk *uk) WeekdaysNarrow() []string { + return uk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uk *uk) WeekdayShort(weekday time.Weekday) string { + return uk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uk *uk) WeekdaysShort() []string { + return uk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uk *uk) WeekdayWide(weekday time.Weekday) string { + return uk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uk *uk) WeekdaysWide() []string { + return uk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uk' and handles both Whole and Real numbers based on 'v' +func (uk *uk) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uk.group) - 1; j >= 0; j-- { + b = append(b, uk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uk' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uk *uk) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uk' +func (uk *uk) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uk.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uk.group) - 1; j >= 0; j-- { + b = append(b, uk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uk' +// in accounting notation. +func (uk *uk) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uk.group) - 1; j >= 0; j-- { + b = append(b, uk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uk.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uk' +func (uk *uk) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uk' +func (uk *uk) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uk.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd1, 0x80}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uk' +func (uk *uk) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd1, 0x80}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uk' +func (uk *uk) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, uk.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd1, 0x80}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uk' +func (uk *uk) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uk' +func (uk *uk) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uk' +func (uk *uk) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uk' +func (uk *uk) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := uk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uk/uk_test.go b/vendor/github.com/go-playground/locales/uk/uk_test.go new file mode 100644 index 0000000000..6f92d85048 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uk/uk_test.go @@ -0,0 +1,1120 @@ +package uk + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uk" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uk_UA/uk_UA.go b/vendor/github.com/go-playground/locales/uk_UA/uk_UA.go new file mode 100644 index 0000000000..520d45b613 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uk_UA/uk_UA.go @@ -0,0 +1,653 @@ +package uk_UA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uk_UA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uk_UA' locale +func New() locales.Translator { + return &uk_UA{ + locale: "uk_UA", + pluralsCardinal: []locales.PluralRule{2, 4, 5, 6}, + pluralsOrdinal: []locales.PluralRule{4, 6}, + pluralsRange: []locales.PluralRule{2, 4, 5, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "січ.", "лют.", "бер.", "квіт.", "трав.", "черв.", "лип.", "серп.", "вер.", "жовт.", "лист.", "груд."}, + monthsNarrow: []string{"", "с", "л", "б", "к", "т", "ч", "л", "с", "в", "ж", "л", "г"}, + monthsWide: []string{"", "січня", "лютого", "березня", "квітня", "травня", "червня", "липня", "серпня", "вересня", "жовтня", "листопада", "грудня"}, + daysAbbreviated: []string{"нд", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysNarrow: []string{"Н", "П", "В", "С", "Ч", "П", "С"}, + daysShort: []string{"нд", "пн", "вт", "ср", "чт", "пт", "сб"}, + daysWide: []string{"неділя", "понеділок", "вівторок", "середа", "четвер", "пʼятниця", "субота"}, + periodsAbbreviated: []string{"дп", "пп"}, + periodsNarrow: []string{"дп", "пп"}, + periodsWide: []string{"дп", "пп"}, + erasAbbreviated: []string{"до н. е.", "н. е."}, + erasNarrow: []string{"до н.е.", "н.е."}, + erasWide: []string{"до нашої ери", "нашої ери"}, + timezones: map[string]string{"PST": "за північноамериканським тихоокеанським стандартним часом", "PDT": "за північноамериканським тихоокеанським літнім часом", "ACWST": "за стандартним центральнозахідним австралійським часом", "UYT": "за стандартним часом в Уругваї", "HNPMX": "за стандартним тихоокеанським часом у Мексиці", "VET": "за часом у Венесуелі", "HEOG": "за літнім західним часом у Гренландії", "MST": "MST", "AKST": "за стандартним часом на Алясці", "AKDT": "за літнім часом на Алясці", "SAST": "за південноафриканським часом", "BOT": "за болівійським часом", "ARST": "за літнім аргентинським часом", "HEPM": "за літнім часом на островах Сен-П’єр і Мікелон", "CST": "за північноамериканським центральним стандартним часом", "HNEG": "за стандартним східним часом у Гренландії", "ACWDT": "за літнім центральнозахідним австралійським часом", "MESZ": "за центральноєвропейським літнім часом", "WART": "за стандартним західноаргентинським часом", "TMST": "за літнім часом у Туркменістані", "MDT": "MDT", "COST": "за літнім колумбійським часом", "HAST": "за стандартним гавайсько-алеутським часом", "WARST": "за літнім за західноаргентинським часом", "HENOMX": "за літнім північнозахідним часом у Мексиці", "AEST": "за стандартним східноавстралійським часом", "LHDT": "за літнім часом на острові Лорд-Хау", "HNOG": "за стандартним західним часом у Гренландії", "WIT": "за східноіндонезійським часом", "CHAST": "за стандартним часом на архіпелазі Чатем", "CAT": "за центральноафриканським часом", "NZDT": "за літнім часом у Новій Зеландії", "COT": "за стандартним колумбійським часом", "LHST": "за стандартним часом на острові Лорд-Хау", "CDT": "за північноамериканським центральним літнім часом", "AWDT": "за літнім західноавстралійським часом", "JDT": "за японським літнім часом", "OESZ": "за східноєвропейським літнім часом", "CLT": "за стандартним чилійським часом", "CLST": "за літнім чилійським часом", "HEPMX": "за літнім тихоокеанським часом у Мексиці", "ECT": "за часом в Еквадорі", "∅∅∅": "за літнім часом на Амазонці", "HKST": "за літнім часом у Гонконзі", "AWST": "за стандартним західноавстралійським часом", "WESZ": "за західноєвропейським літнім часом", "ART": "за стандартним аргентинським часом", "SRT": "за часом у Суринамі", "GYT": "за часом у Гаяні", "WIB": "за західноіндонезійським часом", "NZST": "за стандартним часом у Новій Зеландії", "HNT": "за стандартним часом на острові Ньюфаундленд", "HAT": "за літнім часом у Ньюфаундленд", "HEEG": "за літнім східним часом у Гренландії", "AEDT": "за літнім східноавстралійським часом", "EAT": "за східноафриканським часом", "JST": "за японським стандартним часом", "GMT": "за Гринвічем", "EST": "за північноамериканським східним стандартним часом", "ACDT": "за літнім центральноавстралійським часом", "ChST": "за часом на Північних Маріанських островах", "CHADT": "за літнім часом на архіпелазі Чатем", "TMT": "за стандартним часом у Туркменістані", "WAT": "за західноафриканським стандартним часом", "WAST": "за західноафриканським літнім часом", "GFT": "за часом Французької Гвіани", "HECU": "за літнім часом на Кубі", "WEZ": "за західноєвропейським стандартним часом", "HKT": "за стандартним часом у Гонконзі", "HNNOMX": "за стандартним північнозахідним часом у Мексиці", "UYST": "за літнім часом в Уругваї", "HNPM": "за стандартним часом на островах Сен-П’єр і Мікелон", "HNCU": "за стандартним часом на Кубі", "HADT": "за літнім гавайсько-алеутським часом", "IST": "за індійським стандартним часом", "AST": "за атлантичним стандартним часом", "ADT": "за атлантичним літнім часом", "EDT": "за північноамериканським східним літнім часом", "WITA": "за центральноіндонезійським часом", "SGT": "за часом у Сінгапурі", "MEZ": "за центральноєвропейським стандартним часом", "OEZ": "за східноєвропейським стандартним часом", "MYT": "за часом у Малайзії", "ACST": "за стандартним центральноавстралійським часом", "BT": "за часом у Бутані"}, + } +} + +// Locale returns the current translators string locale +func (uk *uk_UA) Locale() string { + return uk.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uk_UA' +func (uk *uk_UA) PluralsCardinal() []locales.PluralRule { + return uk.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uk_UA' +func (uk *uk_UA) PluralsOrdinal() []locales.PluralRule { + return uk.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uk_UA' +func (uk *uk_UA) PluralsRange() []locales.PluralRule { + return uk.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uk_UA' +func (uk *uk_UA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + iMod10 := i % 10 + iMod100 := i % 100 + + if v == 0 && iMod10 == 1 && iMod100 != 11 { + return locales.PluralRuleOne + } else if v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14) { + return locales.PluralRuleFew + } else if (v == 0 && iMod10 == 0) || (v == 0 && iMod10 >= 5 && iMod10 <= 9) || (v == 0 && iMod100 >= 11 && iMod100 <= 14) { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uk_UA' +func (uk *uk_UA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + nMod10 := math.Mod(n, 10) + nMod100 := math.Mod(n, 100) + + if nMod10 == 3 && nMod100 != 13 { + return locales.PluralRuleFew + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uk_UA' +func (uk *uk_UA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uk.CardinalPluralRule(num1, v1) + end := uk.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew { + return locales.PluralRuleFew + } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany { + return locales.PluralRuleMany + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uk *uk_UA) MonthAbbreviated(month time.Month) string { + return uk.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uk *uk_UA) MonthsAbbreviated() []string { + return uk.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uk *uk_UA) MonthNarrow(month time.Month) string { + return uk.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uk *uk_UA) MonthsNarrow() []string { + return uk.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uk *uk_UA) MonthWide(month time.Month) string { + return uk.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uk *uk_UA) MonthsWide() []string { + return uk.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uk *uk_UA) WeekdayAbbreviated(weekday time.Weekday) string { + return uk.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uk *uk_UA) WeekdaysAbbreviated() []string { + return uk.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uk *uk_UA) WeekdayNarrow(weekday time.Weekday) string { + return uk.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uk *uk_UA) WeekdaysNarrow() []string { + return uk.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uk *uk_UA) WeekdayShort(weekday time.Weekday) string { + return uk.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uk *uk_UA) WeekdaysShort() []string { + return uk.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uk *uk_UA) WeekdayWide(weekday time.Weekday) string { + return uk.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uk *uk_UA) WeekdaysWide() []string { + return uk.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uk_UA' and handles both Whole and Real numbers based on 'v' +func (uk *uk_UA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uk.group) - 1; j >= 0; j-- { + b = append(b, uk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uk_UA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uk *uk_UA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uk.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uk.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uk_UA' +func (uk *uk_UA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uk.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uk.group) - 1; j >= 0; j-- { + b = append(b, uk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uk.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uk_UA' +// in accounting notation. +func (uk *uk_UA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uk.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uk.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uk.group) - 1; j >= 0; j-- { + b = append(b, uk.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uk.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uk.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uk.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uk_UA' +func (uk *uk_UA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2e}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uk_UA' +func (uk *uk_UA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uk.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd1, 0x80}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uk_UA' +func (uk *uk_UA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd1, 0x80}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uk_UA' +func (uk *uk_UA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, uk.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uk.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd1, 0x80}...) + b = append(b, []byte{0x2e}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uk_UA' +func (uk *uk_UA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uk_UA' +func (uk *uk_UA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uk_UA' +func (uk *uk_UA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uk_UA' +func (uk *uk_UA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uk.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uk.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := uk.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uk_UA/uk_UA_test.go b/vendor/github.com/go-playground/locales/uk_UA/uk_UA_test.go new file mode 100644 index 0000000000..f223174f6b --- /dev/null +++ b/vendor/github.com/go-playground/locales/uk_UA/uk_UA_test.go @@ -0,0 +1,1120 @@ +package uk_UA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uk_UA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ur/ur.go b/vendor/github.com/go-playground/locales/ur/ur.go new file mode 100644 index 0000000000..ab849e3821 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ur/ur.go @@ -0,0 +1,622 @@ +package ur + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ur struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ur' locale +func New() locales.Translator { + return &ur{ + locale: "ur", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "‎-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "Rs", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + daysWide: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"قبل مسیح", "عیسوی"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"قبل مسیح", "عیسوی"}, + timezones: map[string]string{"WEZ": "مغربی یورپ کا معیاری وقت", "WESZ": "مغربی یورپ کا موسم گرما کا وقت", "ARST": "ارجنٹینا سمر ٹائم", "EST": "ایسٹرن اسٹینڈرڈ ٹائم", "HNCU": "کیوبا اسٹینڈرڈ ٹائم", "ACWST": "آسٹریلین سنٹرل ویسٹرن اسٹینڈرڈ ٹائم", "ADT": "اٹلانٹک ڈے لائٹ ٹائم", "CLST": "چلی کا موسم گرما کا وقت", "HNOG": "مغربی گرین لینڈ اسٹینڈرڈ ٹائم", "WITA": "وسطی انڈونیشیا ٹائم", "UYT": "یوروگوئے کا معیاری وقت", "NZST": "نیوزی لینڈ کا معیاری وقت", "JDT": "جاپان ڈے لائٹ ٹائم", "WARST": "مغربی ارجنٹینا کا موسم گرما کا وقت", "HEPM": "سینٹ پیئر اور مکلیئون ڈے لائٹ ٹائم", "AWST": "آسٹریلیا ویسٹرن اسٹینڈرڈ ٹائم", "CAT": "وسطی افریقہ ٹائم", "MESZ": "وسطی یورپ کا موسم گرما کا وقت", "OESZ": "مشرقی یورپ کا موسم گرما کا وقت", "TMT": "ترکمانستان کا معیاری وقت", "AEST": "آسٹریلین ایسٹرن اسٹینڈرڈ ٹائم", "SAST": "جنوبی افریقہ سٹینڈرڈ ٹائم", "CST": "سنٹرل اسٹینڈرڈ ٹائم", "PST": "پیسفک اسٹینڈرڈ ٹائم", "TMST": "ترکمانستان کا موسم گرما کا وقت", "HEEG": "مشرقی گرین لینڈ کا موسم گرما کا وقت", "AKST": "الاسکا اسٹینڈرڈ ٹائم", "WIB": "مغربی انڈونیشیا ٹائم", "HECU": "کیوبا ڈے لائٹ ٹائم", "CHAST": "چیتھم اسٹینڈرڈ ٹائم", "HAST": "ہوائی الیوٹیئن اسٹینڈرڈ ٹائم", "MEZ": "وسطی یورپ کا معیاری وقت", "VET": "وینزوئیلا کا وقت", "BT": "بھوٹان کا وقت", "HNEG": "مشرقی گرین لینڈ اسٹینڈرڈ ٹائم", "MST": "ماؤنٹین اسٹینڈرڈ ٹائم", "IST": "ہندوستان کا معیاری وقت", "WART": "مغربی ارجنٹینا کا معیاری وقت", "ART": "ارجنٹینا سٹینڈرڈ ٹائم", "GFT": "فرینچ گیانا کا وقت", "UYST": "یوروگوئے کا موسم گرما کا وقت", "BOT": "بولیویا کا وقت", "NZDT": "نیوزی لینڈ ڈے لائٹ ٹائم", "JST": "جاپان سٹینڈرڈ ٹائم", "HKT": "ہانگ کانگ سٹینڈرڈ ٹائم", "HAT": "نیو فاؤنڈ لینڈ ڈے لائٹ ٹائم", "ECT": "ایکواڈور کا وقت", "ACWDT": "آسٹریلین سنٹرل ویسٹرن ڈے لائٹ ٹائم", "COT": "کولمبیا کا معیاری وقت", "HNNOMX": "شمال مغربی میکسیکو اسٹینڈرڈ ٹائم", "AEDT": "آسٹریلین ایسٹرن ڈے لائٹ ٹائم", "AST": "اٹلانٹک اسٹینڈرڈ ٹائم", "WAT": "مغربی افریقہ سٹینڈرڈ ٹائم", "GYT": "گیانا کا وقت", "CHADT": "چیتھم ڈے لائٹ ٹائم", "HADT": "ہوائی الیوٹیئن ڈے لائٹ ٹائم", "HKST": "ہانگ کانگ سمر ٹائم", "ACST": "آسٹریلین سنٹرل اسٹینڈرڈ ٹائم", "HNT": "نیو فاؤنڈ لینڈ اسٹینڈرڈ ٹائم", "HNPM": "سینٹ پیئر اور مکلیئون اسٹینڈرڈ ٹائم", "HNPMX": "میکسیکن پیسفک اسٹینڈرڈ ٹائم", "ACDT": "آسٹریلین سنٹرل ڈے لائٹ ٹائم", "PDT": "پیسفک ڈے لائٹ ٹائم", "HEOG": "مغربی گرین لینڈ کا موسم گرما کا وقت", "AKDT": "الاسکا ڈے لائٹ ٹائم", "LHDT": "لارڈ ہووے ڈے لائٹ ٹائم", "CDT": "سنٹرل ڈے لائٹ ٹائم", "EDT": "ایسٹرن ڈے لائٹ ٹائم", "ChST": "چامورو سٹینڈرڈ ٹائم", "EAT": "مشرقی افریقہ ٹائم", "SGT": "سنگاپور سٹینڈرڈ ٹائم", "LHST": "لارڈ ہووے اسٹینڈرڈ ٹائم", "HEPMX": "میکسیکن پیسفک ڈے لائٹ ٹائم", "HENOMX": "شمال مغربی میکسیکو ڈے لائٹ ٹائم", "MDT": "ماؤنٹین ڈے لائٹ ٹائم", "MYT": "ملیشیا ٹائم", "COST": "کولمبیا کا موسم گرما کا وقت", "WAST": "مغربی افریقہ سمر ٹائم", "AWDT": "آسٹریلین ویسٹرن ڈے لائٹ ٹائم", "OEZ": "مشرقی یورپ کا معیاری وقت", "GMT": "گرین وچ کا اصل وقت", "CLT": "چلی کا معیاری وقت", "∅∅∅": "∅∅∅", "SRT": "سورینام کا وقت", "WIT": "مشرقی انڈونیشیا ٹائم"}, + } +} + +// Locale returns the current translators string locale +func (ur *ur) Locale() string { + return ur.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ur' +func (ur *ur) PluralsCardinal() []locales.PluralRule { + return ur.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ur' +func (ur *ur) PluralsOrdinal() []locales.PluralRule { + return ur.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ur' +func (ur *ur) PluralsRange() []locales.PluralRule { + return ur.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ur' +func (ur *ur) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ur' +func (ur *ur) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ur' +func (ur *ur) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ur *ur) MonthAbbreviated(month time.Month) string { + return ur.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ur *ur) MonthsAbbreviated() []string { + return ur.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ur *ur) MonthNarrow(month time.Month) string { + return ur.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ur *ur) MonthsNarrow() []string { + return ur.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ur *ur) MonthWide(month time.Month) string { + return ur.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ur *ur) MonthsWide() []string { + return ur.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ur *ur) WeekdayAbbreviated(weekday time.Weekday) string { + return ur.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ur *ur) WeekdaysAbbreviated() []string { + return ur.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ur *ur) WeekdayNarrow(weekday time.Weekday) string { + return ur.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ur *ur) WeekdaysNarrow() []string { + return ur.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ur *ur) WeekdayShort(weekday time.Weekday) string { + return ur.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ur *ur) WeekdaysShort() []string { + return ur.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ur *ur) WeekdayWide(weekday time.Weekday) string { + return ur.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ur *ur) WeekdaysWide() []string { + return ur.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ur' and handles both Whole and Real numbers based on 'v' +func (ur *ur) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ur' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ur *ur) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ur.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ur' +func (ur *ur) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ur.currencies[currency] + l := len(s) + len(symbol) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ur' +// in accounting notation. +func (ur *ur) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ur.currencies[currency] + l := len(s) + len(symbol) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ur' +func (ur *ur) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ur' +func (ur *ur) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ur' +func (ur *ur) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ur' +func (ur *ur) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ur.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ur' +func (ur *ur) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ur' +func (ur *ur) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ur' +func (ur *ur) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ur' +func (ur *ur) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ur.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ur/ur_test.go b/vendor/github.com/go-playground/locales/ur/ur_test.go new file mode 100644 index 0000000000..5f8c39a161 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ur/ur_test.go @@ -0,0 +1,1120 @@ +package ur + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ur" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ur_IN/ur_IN.go b/vendor/github.com/go-playground/locales/ur_IN/ur_IN.go new file mode 100644 index 0000000000..b27733af67 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ur_IN/ur_IN.go @@ -0,0 +1,656 @@ +package ur_IN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ur_IN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyNegativePrefix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ur_IN' locale +func New() locales.Translator { + return &ur_IN{ + locale: "ur_IN", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "‎-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyNegativePrefix: " ", + monthsAbbreviated: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"اتوار", "پیر", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"اتوار", "پیر", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + daysWide: []string{"اتوار", "پیر", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"قبل مسیح", "عیسوی"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"قبل مسیح", "عیسوی"}, + timezones: map[string]string{"SRT": "سورینام ٹائم", "NZDT": "نیوزی لینڈ ڈے لائٹ ٹائم", "JST": "جاپان سٹینڈرڈ ٹائم", "WAST": "مغربی افریقہ سمر ٹائم", "HEEG": "مشرقی گرین لینڈ کا موسم گرما کا وقت", "COST": "کولمبیا سمر ٹائم", "HEPMX": "میکسیکن پیسفک ڈے لائٹ ٹائم", "HECU": "کیوبا ڈے لائٹ ٹائم", "CST": "سنٹرل اسٹینڈرڈ ٹائم", "WESZ": "مغربی یورپ کا موسم گرما کا وقت", "TMT": "ترکمانستان سٹینڈرڈ ٹائم", "WAT": "مغربی افریقہ سٹینڈرڈ ٹائم", "AWST": "آسٹریلیا ویسٹرن اسٹینڈرڈ ٹائم", "ACWDT": "آسٹریلین سنٹرل ویسٹرن ڈے لائٹ ٹائم", "LHDT": "لارڈ ہووے ڈے لائٹ ٹائم", "WITA": "وسطی انڈونیشیا ٹائم", "AKST": "الاسکا اسٹینڈرڈ ٹائم", "AEST": "آسٹریلین ایسٹرن اسٹینڈرڈ ٹائم", "UYST": "یوروگوئے سمر ٹائم", "AWDT": "آسٹریلین ویسٹرن ڈے لائٹ ٹائم", "HADT": "ہوائی الیوٹیئن ڈے لائٹ ٹائم", "WART": "مغربی ارجنٹینا سٹینڈرڈ ٹائم", "ACST": "آسٹریلین سنٹرل اسٹینڈرڈ ٹائم", "MYT": "ملیشیا ٹائم", "WARST": "مغربی ارجنٹینا سمر ٹائم", "ART": "ارجنٹینا سٹینڈرڈ ٹائم", "HNEG": "مشرقی گرین لینڈ اسٹینڈرڈ ٹائم", "SGT": "سنگاپور سٹینڈرڈ ٹائم", "NZST": "نیوزی لینڈ سٹینڈرڈ ٹائم", "VET": "وینزوئیلا ٹائم", "OEZ": "مشرقی یورپ کا معیاری وقت", "BT": "بھوٹان ٹائم", "UYT": "یوروگوئے سٹینڈرڈ ٹائم", "WIB": "مغربی انڈونیشیا ٹائم", "BOT": "بولیویا ٹائم", "PST": "پیسفک اسٹینڈرڈ ٹائم", "CLT": "چلی سٹینڈرڈ ٹائم", "HENOMX": "شمال مغربی میکسیکو ڈے لائٹ ٹائم", "AKDT": "الاسکا ڈے لائٹ ٹائم", "SAST": "جنوبی افریقہ سٹینڈرڈ ٹائم", "WIT": "مشرقی انڈونیشیا ٹائم", "CHAST": "چیتھم اسٹینڈرڈ ٹائم", "CHADT": "چیتھم ڈے لائٹ ٹائم", "HNOG": "مغربی گرین لینڈ اسٹینڈرڈ ٹائم", "HKT": "ہانگ کانگ سٹینڈرڈ ٹائم", "ChST": "چامورو سٹینڈرڈ ٹائم", "HEPM": "سینٹ پیئر اور مکلیئون ڈے لائٹ ٹائم", "HNCU": "کیوبا اسٹینڈرڈ ٹائم", "CAT": "وسطی افریقہ ٹائم", "IST": "انڈیا سٹینڈرڈ ٹائم", "CLST": "چلی سمر ٹائم", "TMST": "ترکمانستان سمر ٹائم", "HEOG": "مغربی گرین لینڈ کا موسم گرما کا وقت", "HNT": "نیو فاؤنڈ لینڈ اسٹینڈرڈ ٹائم", "GFT": "فرینچ گیانا ٹائم", "MEZ": "وسطی یورپ کا معیاری وقت", "AEDT": "آسٹریلین ایسٹرن ڈے لائٹ ٹائم", "HNPM": "سینٹ پیئر اور مکلیئون اسٹینڈرڈ ٹائم", "ACDT": "آسٹریلین سنٹرل ڈے لائٹ ٹائم", "COT": "کولمبیا سٹینڈرڈ ٹائم", "LHST": "لارڈ ہووے اسٹینڈرڈ ٹائم", "MESZ": "وسطی یورپ کا موسم گرما کا وقت", "AST": "اٹلانٹک اسٹینڈرڈ ٹائم", "GMT": "گرین وچ مین ٹائم", "ARST": "ارجنٹینا سمر ٹائم", "JDT": "جاپان ڈے لائٹ ٹائم", "MDT": "MDT", "HAT": "نیو فاؤنڈ لینڈ ڈے لائٹ ٹائم", "GYT": "گیانا ٹائم", "EDT": "ایسٹرن ڈے لائٹ ٹائم", "CDT": "سنٹرل ڈے لائٹ ٹائم", "∅∅∅": "برازیلیا سمر ٹائم", "OESZ": "مشرقی یورپ کا موسم گرما کا وقت", "WEZ": "مغربی یورپ کا معیاری وقت", "HAST": "ہوائی الیوٹیئن اسٹینڈرڈ ٹائم", "ADT": "اٹلانٹک ڈے لائٹ ٹائم", "MST": "MST", "HNNOMX": "شمال مغربی میکسیکو اسٹینڈرڈ ٹائم", "HNPMX": "میکسیکن پیسفک اسٹینڈرڈ ٹائم", "EAT": "مشرقی افریقہ ٹائم", "HKST": "ہانگ کانگ سمر ٹائم", "PDT": "پیسفک ڈے لائٹ ٹائم", "ECT": "ایکواڈور ٹائم", "ACWST": "آسٹریلین سنٹرل ویسٹرن اسٹینڈرڈ ٹائم", "EST": "ایسٹرن اسٹینڈرڈ ٹائم"}, + } +} + +// Locale returns the current translators string locale +func (ur *ur_IN) Locale() string { + return ur.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ur_IN' +func (ur *ur_IN) PluralsCardinal() []locales.PluralRule { + return ur.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ur_IN' +func (ur *ur_IN) PluralsOrdinal() []locales.PluralRule { + return ur.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ur_IN' +func (ur *ur_IN) PluralsRange() []locales.PluralRule { + return ur.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ur_IN' +func (ur *ur_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ur_IN' +func (ur *ur_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ur_IN' +func (ur *ur_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ur *ur_IN) MonthAbbreviated(month time.Month) string { + return ur.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ur *ur_IN) MonthsAbbreviated() []string { + return ur.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ur *ur_IN) MonthNarrow(month time.Month) string { + return ur.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ur *ur_IN) MonthsNarrow() []string { + return ur.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ur *ur_IN) MonthWide(month time.Month) string { + return ur.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ur *ur_IN) MonthsWide() []string { + return ur.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ur *ur_IN) WeekdayAbbreviated(weekday time.Weekday) string { + return ur.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ur *ur_IN) WeekdaysAbbreviated() []string { + return ur.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ur *ur_IN) WeekdayNarrow(weekday time.Weekday) string { + return ur.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ur *ur_IN) WeekdaysNarrow() []string { + return ur.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ur *ur_IN) WeekdayShort(weekday time.Weekday) string { + return ur.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ur *ur_IN) WeekdaysShort() []string { + return ur.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ur *ur_IN) WeekdayWide(weekday time.Weekday) string { + return ur.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ur *ur_IN) WeekdaysWide() []string { + return ur.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ur_IN' and handles both Whole and Real numbers based on 'v' +func (ur *ur_IN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ur_IN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ur *ur_IN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ur.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ur_IN' +func (ur *ur_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ur.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ur.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ur.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ur.currencyPositivePrefix[j]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ur_IN' +// in accounting notation. +func (ur *ur_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ur.currencies[currency] + l := len(s) + len(symbol) + 7 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + inSecondary := false + groupThreshold := 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + + if count == groupThreshold { + b = append(b, ur.group[0]) + count = 1 + + if !inSecondary { + inSecondary = true + groupThreshold = 2 + } + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ur.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, ur.currencyNegativePrefix[j]) + } + + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ur.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, ur.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ur_IN' +func (ur *ur_IN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ur_IN' +func (ur *ur_IN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ur_IN' +func (ur *ur_IN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ur_IN' +func (ur *ur_IN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ur.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ur_IN' +func (ur *ur_IN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ur_IN' +func (ur *ur_IN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ur_IN' +func (ur *ur_IN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ur_IN' +func (ur *ur_IN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ur.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ur_IN/ur_IN_test.go b/vendor/github.com/go-playground/locales/ur_IN/ur_IN_test.go new file mode 100644 index 0000000000..361d2233c5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ur_IN/ur_IN_test.go @@ -0,0 +1,1120 @@ +package ur_IN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ur_IN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/ur_PK/ur_PK.go b/vendor/github.com/go-playground/locales/ur_PK/ur_PK.go new file mode 100644 index 0000000000..2ed6538121 --- /dev/null +++ b/vendor/github.com/go-playground/locales/ur_PK/ur_PK.go @@ -0,0 +1,622 @@ +package ur_PK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type ur_PK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'ur_PK' locale +func New() locales.Translator { + return &ur_PK{ + locale: "ur_PK", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "‎-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + daysWide: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"قبل مسیح", "عیسوی"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"قبل مسیح", "عیسوی"}, + timezones: map[string]string{"HNEG": "مشرقی گرین لینڈ اسٹینڈرڈ ٹائم", "HNPMX": "میکسیکن پیسفک اسٹینڈرڈ ٹائم", "SRT": "سورینام کا وقت", "HENOMX": "شمال مغربی میکسیکو ڈے لائٹ ٹائم", "BT": "بھوٹان کا وقت", "TMT": "ترکمانستان کا معیاری وقت", "ARST": "ارجنٹینا سمر ٹائم", "EST": "ایسٹرن اسٹینڈرڈ ٹائم", "ACDT": "آسٹریلین سنٹرل ڈے لائٹ ٹائم", "LHST": "لارڈ ہووے اسٹینڈرڈ ٹائم", "∅∅∅": "برازیلیا سمر ٹائم", "WART": "مغربی ارجنٹینا کا معیاری وقت", "MEZ": "وسطی یورپ کا معیاری وقت", "HNOG": "مغربی گرین لینڈ اسٹینڈرڈ ٹائم", "HEOG": "مغربی گرین لینڈ کا موسم گرما کا وقت", "MDT": "MDT", "COT": "کولمبیا کا معیاری وقت", "ChST": "چامورو سٹینڈرڈ ٹائم", "AWDT": "آسٹریلین ویسٹرن ڈے لائٹ ٹائم", "PDT": "پیسفک ڈے لائٹ ٹائم", "HECU": "کیوبا ڈے لائٹ ٹائم", "NZDT": "نیوزی لینڈ ڈے لائٹ ٹائم", "HKST": "ہانگ کانگ سمر ٹائم", "AEDT": "آسٹریلین ایسٹرن ڈے لائٹ ٹائم", "UYT": "یوروگوئے کا معیاری وقت", "PST": "پیسفک اسٹینڈرڈ ٹائم", "CAT": "وسطی افریقہ ٹائم", "JST": "جاپان سٹینڈرڈ ٹائم", "MYT": "ملیشیا ٹائم", "ART": "ارجنٹینا سٹینڈرڈ ٹائم", "HAT": "نیو فاؤنڈ لینڈ ڈے لائٹ ٹائم", "ACWDT": "آسٹریلین سنٹرل ویسٹرن ڈے لائٹ ٹائم", "WARST": "مغربی ارجنٹینا کا موسم گرما کا وقت", "WAST": "مغربی افریقہ سمر ٹائم", "SAST": "جنوبی افریقہ سٹینڈرڈ ٹائم", "WIB": "مغربی انڈونیشیا ٹائم", "ECT": "ایکواڈور کا وقت", "VET": "وینزوئیلا کا وقت", "ACST": "آسٹریلین سنٹرل اسٹینڈرڈ ٹائم", "CDT": "سنٹرل ڈے لائٹ ٹائم", "CLST": "چلی کا موسم گرما کا وقت", "GYT": "گیانا کا وقت", "CHADT": "چیتھم ڈے لائٹ ٹائم", "OEZ": "مشرقی یورپ کا معیاری وقت", "AST": "اٹلانٹک اسٹینڈرڈ ٹائم", "TMST": "ترکمانستان کا موسم گرما کا وقت", "WAT": "مغربی افریقہ سٹینڈرڈ ٹائم", "COST": "کولمبیا کا موسم گرما کا وقت", "HEEG": "مشرقی گرین لینڈ کا موسم گرما کا وقت", "LHDT": "لارڈ ہووے ڈے لائٹ ٹائم", "AWST": "آسٹریلیا ویسٹرن اسٹینڈرڈ ٹائم", "IST": "ہندوستان کا معیاری وقت", "HNPM": "سینٹ پیئر اور مکلیئون اسٹینڈرڈ ٹائم", "OESZ": "مشرقی یورپ کا موسم گرما کا وقت", "EDT": "ایسٹرن ڈے لائٹ ٹائم", "GMT": "گرین وچ کا اصل وقت", "AKST": "الاسکا اسٹینڈرڈ ٹائم", "AEST": "آسٹریلین ایسٹرن اسٹینڈرڈ ٹائم", "EAT": "مشرقی افریقہ ٹائم", "ADT": "اٹلانٹک ڈے لائٹ ٹائم", "WESZ": "مغربی یورپ کا موسم گرما کا وقت", "AKDT": "الاسکا ڈے لائٹ ٹائم", "UYST": "یوروگوئے کا موسم گرما کا وقت", "HEPM": "سینٹ پیئر اور مکلیئون ڈے لائٹ ٹائم", "HEPMX": "میکسیکن پیسفک ڈے لائٹ ٹائم", "ACWST": "آسٹریلین سنٹرل ویسٹرن اسٹینڈرڈ ٹائم", "JDT": "جاپان ڈے لائٹ ٹائم", "HAST": "ہوائی الیوٹیئن اسٹینڈرڈ ٹائم", "MST": "MST", "WITA": "وسطی انڈونیشیا ٹائم", "HNCU": "کیوبا اسٹینڈرڈ ٹائم", "CST": "سنٹرل اسٹینڈرڈ ٹائم", "SGT": "سنگاپور سٹینڈرڈ ٹائم", "HADT": "ہوائی الیوٹیئن ڈے لائٹ ٹائم", "NZST": "نیوزی لینڈ کا معیاری وقت", "CLT": "چلی کا معیاری وقت", "HKT": "ہانگ کانگ سٹینڈرڈ ٹائم", "HNT": "نیو فاؤنڈ لینڈ اسٹینڈرڈ ٹائم", "WIT": "مشرقی انڈونیشیا ٹائم", "CHAST": "چیتھم اسٹینڈرڈ ٹائم", "WEZ": "مغربی یورپ کا معیاری وقت", "HNNOMX": "شمال مغربی میکسیکو اسٹینڈرڈ ٹائم", "GFT": "فرینچ گیانا کا وقت", "BOT": "بولیویا کا وقت", "MESZ": "وسطی یورپ کا موسم گرما کا وقت"}, + } +} + +// Locale returns the current translators string locale +func (ur *ur_PK) Locale() string { + return ur.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'ur_PK' +func (ur *ur_PK) PluralsCardinal() []locales.PluralRule { + return ur.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'ur_PK' +func (ur *ur_PK) PluralsOrdinal() []locales.PluralRule { + return ur.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'ur_PK' +func (ur *ur_PK) PluralsRange() []locales.PluralRule { + return ur.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ur_PK' +func (ur *ur_PK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ur_PK' +func (ur *ur_PK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ur_PK' +func (ur *ur_PK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (ur *ur_PK) MonthAbbreviated(month time.Month) string { + return ur.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (ur *ur_PK) MonthsAbbreviated() []string { + return ur.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (ur *ur_PK) MonthNarrow(month time.Month) string { + return ur.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (ur *ur_PK) MonthsNarrow() []string { + return ur.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (ur *ur_PK) MonthWide(month time.Month) string { + return ur.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (ur *ur_PK) MonthsWide() []string { + return ur.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (ur *ur_PK) WeekdayAbbreviated(weekday time.Weekday) string { + return ur.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (ur *ur_PK) WeekdaysAbbreviated() []string { + return ur.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (ur *ur_PK) WeekdayNarrow(weekday time.Weekday) string { + return ur.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (ur *ur_PK) WeekdaysNarrow() []string { + return ur.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (ur *ur_PK) WeekdayShort(weekday time.Weekday) string { + return ur.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (ur *ur_PK) WeekdaysShort() []string { + return ur.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (ur *ur_PK) WeekdayWide(weekday time.Weekday) string { + return ur.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (ur *ur_PK) WeekdaysWide() []string { + return ur.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'ur_PK' and handles both Whole and Real numbers based on 'v' +func (ur *ur_PK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'ur_PK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (ur *ur_PK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 6 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, ur.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ur_PK' +func (ur *ur_PK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ur.currencies[currency] + l := len(s) + len(symbol) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ur_PK' +// in accounting notation. +func (ur *ur_PK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := ur.currencies[currency] + l := len(s) + len(symbol) + 5 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, ur.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, ur.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(ur.minus) - 1; j >= 0; j-- { + b = append(b, ur.minus[j]) + } + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, ur.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'ur_PK' +func (ur *ur_PK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'ur_PK' +func (ur *ur_PK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'ur_PK' +func (ur *ur_PK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'ur_PK' +func (ur *ur_PK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, ur.daysWide[t.Weekday()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, ur.monthsWide[t.Month()]...) + b = append(b, []byte{0xd8, 0x8c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'ur_PK' +func (ur *ur_PK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'ur_PK' +func (ur *ur_PK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'ur_PK' +func (ur *ur_PK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'ur_PK' +func (ur *ur_PK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, ur.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, ur.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, ur.periodsAbbreviated[0]...) + } else { + b = append(b, ur.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := ur.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/ur_PK/ur_PK_test.go b/vendor/github.com/go-playground/locales/ur_PK/ur_PK_test.go new file mode 100644 index 0000000000..fe27e3939f --- /dev/null +++ b/vendor/github.com/go-playground/locales/ur_PK/ur_PK_test.go @@ -0,0 +1,1120 @@ +package ur_PK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "ur_PK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uz/uz.go b/vendor/github.com/go-playground/locales/uz/uz.go new file mode 100644 index 0000000000..6575c697fe --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz/uz.go @@ -0,0 +1,601 @@ +package uz + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uz struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uz' locale +func New() locales.Translator { + return &uz{ + locale: "uz", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "soʻm", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avg", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "Y", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avgust", "sentabr", "oktabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"Yak", "Dush", "Sesh", "Chor", "Pay", "Jum", "Shan"}, + daysNarrow: []string{"Y", "D", "S", "C", "P", "J", "S"}, + daysShort: []string{"Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"}, + daysWide: []string{"yakshanba", "dushanba", "seshanba", "chorshanba", "payshanba", "juma", "shanba"}, + periodsAbbreviated: []string{"TO", "TK"}, + periodsNarrow: []string{"TO", "TK"}, + periodsWide: []string{"TO", "TK"}, + erasAbbreviated: []string{"m.a.", "milodiy"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"AKDT": "Alyaska yozgi vaqti", "HADT": "Gavayi-aleut yozgi vaqti", "CLT": "Chili standart vaqti", "TMT": "Turkmaniston standart vaqti", "ACWST": "Markaziy Avstraliya g‘arbiy standart vaqti", "ART": "Argentina standart vaqti", "SAST": "Janubiy Afrika standart vaqti", "LHDT": "Lord-Xau yozgi vaqti", "WIT": "Sharqiy Indoneziya vaqti", "CHADT": "Chatem yozgi vaqti", "CHAST": "Chatem standart vaqti", "MST": "MST", "HEEG": "Sharqiy Grenlandiya yozgi vaqti", "ChST": "Chamorro standart vaqti", "HNPMX": "Meksika Tinch okeani standart vaqti", "EAT": "Sharqiy Afrika vaqti", "HNCU": "Kuba standart vaqti", "BOT": "Boliviya vaqti", "IST": "Hindiston vaqti", "WAT": "Gʻarbiy Afrika standart vaqti", "HNT": "Nyufaundlend standart vaqti", "HNEG": "Sharqiy Grenlandiya standart vaqti", "∅∅∅": "Peru yozgi vaqti", "HEPM": "Sen-Pyer va Mikelon yozgi vaqti", "MYT": "Malayziya vaqti", "HKT": "Gonkong standart vaqti", "UYST": "Urugvay yozgi vaqti", "HAST": "Gavayi-aleut standart vaqti", "JST": "Yaponiya standart vaqti", "TMST": "Turkmaniston yozgi vaqti", "AWST": "G‘arbiy Avstraliya standart vaqti", "NZDT": "Yangi Zelandiya yozgi vaqti", "WARST": "Gʻarbiy Argentina yozgi vaqti", "COST": "Kolumbiya yozgi vaqti", "UYT": "Urugvay standart vaqti", "HNPM": "Sen-Pyer va Mikelon standart vaqti", "LHST": "Lord-Xau standart vaqti", "CST": "Markaziy Amerika standart vaqti", "HNOG": "G‘arbiy Grenlandiya standart vaqti", "WEZ": "G‘arbiy Yevropa standart vaqti", "MEZ": "Markaziy Yevropa standart vaqti", "JDT": "Yaponiya yozgi vaqti", "GMT": "Grinvich o‘rtacha vaqti", "MDT": "MDT", "HENOMX": "Shimoli-g‘arbiy Meksika yozgi vaqti", "HAT": "Nyufaundlend yozgi vaqti", "GYT": "Gayana vaqti", "HECU": "Kuba yozgi vaqti", "ECT": "Ekvador vaqti", "PDT": "Tinch okeani yozgi vaqti", "OESZ": "Sharqiy Yevropa yozgi vaqti", "WAST": "Gʻarbiy Afrika yozgi vaqti", "EDT": "Sharqiy Amerika yozgi vaqti", "WITA": "Markaziy Indoneziya vaqti", "WIB": "Gʻarbiy Indoneziya vaqti", "AWDT": "G‘arbiy Avstraliya yozgi vaqti", "BT": "Butan vaqti", "AKST": "Alyaska standart vaqti", "MESZ": "Markaziy Yevropa yozgi vaqti", "WART": "Gʻarbiy Argentina standart vaqti", "EST": "Sharqiy Amerika standart vaqti", "ACST": "Markaziy Avstraliya standart vaqti", "COT": "Kolumbiya standart vaqti", "VET": "Venesuela vaqti", "HKST": "Gonkong yozgi vaqti", "SGT": "Singapur vaqti", "NZST": "Yangi Zelandiya standart vaqti", "CLST": "Chili yozgi vaqti", "ADT": "Atlantika yozgi vaqti", "HEPMX": "Meksika Tinch okeani yozgi vaqti", "SRT": "Surinam vaqti", "CDT": "Markaziy Amerika yozgi vaqti", "CAT": "Markaziy Afrika vaqti", "AST": "Atlantika standart vaqti", "HEOG": "G‘arbiy Grenlandiya yozgi vaqti", "OEZ": "Sharqiy Yevropa standart vaqti", "HNNOMX": "Shimoli-g‘arbiy Meksika standart vaqti", "ACDT": "Markaziy Avstraliya yozgi vaqti", "ACWDT": "Markaziy Avstraliya g‘arbiy yozgi vaqti", "WESZ": "G‘arbiy Yevropa yozgi vaqti", "ARST": "Argentina yozgi vaqti", "GFT": "Fransuz Gvianasi vaqti", "AEST": "Sharqiy Avstraliya standart vaqti", "AEDT": "Sharqiy Avstraliya yozgi vaqti", "PST": "Tinch okeani standart vaqti"}, + } +} + +// Locale returns the current translators string locale +func (uz *uz) Locale() string { + return uz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uz' +func (uz *uz) PluralsCardinal() []locales.PluralRule { + return uz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uz' +func (uz *uz) PluralsOrdinal() []locales.PluralRule { + return uz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uz' +func (uz *uz) PluralsRange() []locales.PluralRule { + return uz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uz' +func (uz *uz) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uz' +func (uz *uz) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uz' +func (uz *uz) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uz.CardinalPluralRule(num1, v1) + end := uz.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uz *uz) MonthAbbreviated(month time.Month) string { + return uz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uz *uz) MonthsAbbreviated() []string { + return uz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uz *uz) MonthNarrow(month time.Month) string { + return uz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uz *uz) MonthsNarrow() []string { + return uz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uz *uz) MonthWide(month time.Month) string { + return uz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uz *uz) MonthsWide() []string { + return uz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uz *uz) WeekdayAbbreviated(weekday time.Weekday) string { + return uz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uz *uz) WeekdaysAbbreviated() []string { + return uz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uz *uz) WeekdayNarrow(weekday time.Weekday) string { + return uz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uz *uz) WeekdaysNarrow() []string { + return uz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uz *uz) WeekdayShort(weekday time.Weekday) string { + return uz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uz *uz) WeekdaysShort() []string { + return uz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uz *uz) WeekdayWide(weekday time.Weekday) string { + return uz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uz *uz) WeekdaysWide() []string { + return uz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uz' and handles both Whole and Real numbers based on 'v' +func (uz *uz) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uz' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uz *uz) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz' +func (uz *uz) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, uz.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz' +// in accounting notation. +func (uz *uz) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uz.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uz.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, uz.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uz' +func (uz *uz) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uz' +func (uz *uz) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uz' +func (uz *uz) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uz' +func (uz *uz) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, uz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uz' +func (uz *uz) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uz' +func (uz *uz) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uz' +func (uz *uz) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uz' +func (uz *uz) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := uz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uz/uz_test.go b/vendor/github.com/go-playground/locales/uz/uz_test.go new file mode 100644 index 0000000000..c79fd707f6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz/uz_test.go @@ -0,0 +1,1120 @@ +package uz + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uz" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uz_Arab/uz_Arab.go b/vendor/github.com/go-playground/locales/uz_Arab/uz_Arab.go new file mode 100644 index 0000000000..3ee46fd87d --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Arab/uz_Arab.go @@ -0,0 +1,592 @@ +package uz_Arab + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uz_Arab struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uz_Arab' locale +func New() locales.Translator { + return &uz_Arab{ + locale: "uz_Arab", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: "٫", + group: "٬", + minus: "-", + percent: "٪", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "؋", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "جنو", "فبر", "مار", "اپر", "می", "جون", "جول", "اگس", "سپت", "اکت", "نوم", "دسم"}, + monthsNarrow: []string{"", "Y", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "جنوری", "فبروری", "مارچ", "اپریل", "می", "جون", "جولای", "اگست", "سپتمبر", "اکتوبر", "نومبر", "دسمبر"}, + daysAbbreviated: []string{"ی.", "د.", "س.", "چ.", "پ.", "ج.", "ش."}, + daysNarrow: []string{"Y", "D", "S", "C", "P", "J", "S"}, + daysShort: []string{"Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"}, + daysWide: []string{"یکشنبه", "دوشنبه", "سه\u200cشنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"}, + periodsAbbreviated: []string{"TO", "TK"}, + periodsNarrow: []string{"TO", "TK"}, + periodsWide: []string{"TO", "TK"}, + erasAbbreviated: []string{"ق.م.", "م."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"JST": "Yaponiya standart vaqti", "WAT": "Gʻarbiy Afrika standart vaqti", "HEPM": "Sen-Pyer va Mikelon yozgi vaqti", "HNCU": "Kuba standart vaqti", "BOT": "Boliviya vaqti", "LHST": "Lord-Xau standart vaqti", "HECU": "Kuba yozgi vaqti", "CAT": "Markaziy Afrika vaqti", "ACWDT": "Markaziy Avstraliya g‘arbiy yozgi vaqti", "OESZ": "Sharqiy Yevropa yozgi vaqti", "MDT": "MDT", "COST": "Kolumbiya yozgi vaqti", "HNPM": "Sen-Pyer va Mikelon standart vaqti", "COT": "Kolumbiya standart vaqti", "ChST": "Chamorro standart vaqti", "AKDT": "Alyaska yozgi vaqti", "AEST": "Sharqiy Avstraliya standart vaqti", "NZST": "Yangi Zelandiya standart vaqti", "HEOG": "G‘arbiy Grenlandiya yozgi vaqti", "ADT": "Atlantika yozgi vaqti", "ACDT": "Markaziy Avstraliya yozgi vaqti", "HEEG": "Sharqiy Grenlandiya yozgi vaqti", "AKST": "Alyaska standart vaqti", "SAST": "Janubiy Afrika standart vaqti", "GYT": "Gayana vaqti", "AWST": "G‘arbiy Avstraliya standart vaqti", "SGT": "Singapur vaqti", "OEZ": "Sharqiy Yevropa standart vaqti", "EAT": "Sharqiy Afrika vaqti", "HNEG": "Sharqiy Grenlandiya standart vaqti", "WART": "Gʻarbiy Argentina standart vaqti", "CLT": "Chili standart vaqti", "HNNOMX": "Shimoli-g‘arbiy Meksika standart vaqti", "HAST": "Gavayi-aleut standart vaqti", "HNOG": "G‘arbiy Grenlandiya standart vaqti", "ARST": "Argentina yozgi vaqti", "WAST": "Gʻarbiy Afrika yozgi vaqti", "HKT": "Gonkong standart vaqti", "BT": "Butan vaqti", "HNPMX": "Meksika Tinch okeani standart vaqti", "WEZ": "G‘arbiy Yevropa standart vaqti", "EST": "Sharqiy Amerika standart vaqti", "UYST": "Urugvay yozgi vaqti", "SRT": "Surinam vaqti", "CST": "Markaziy Amerika standart vaqti", "HEPMX": "Meksika Tinch okeani yozgi vaqti", "AWDT": "G‘arbiy Avstraliya yozgi vaqti", "ACWST": "Markaziy Avstraliya g‘arbiy standart vaqti", "AST": "Atlantika standart vaqti", "GMT": "Grinvich o‘rtacha vaqti", "TMST": "Turkmaniston yozgi vaqti", "EDT": "Sharqiy Amerika yozgi vaqti", "UYT": "Urugvay standart vaqti", "ECT": "Ekvador vaqti", "TMT": "Turkmaniston standart vaqti", "MST": "MST", "HADT": "Gavayi-aleut yozgi vaqti", "CLST": "Chili yozgi vaqti", "HENOMX": "Shimoli-g‘arbiy Meksika yozgi vaqti", "HNT": "Nyufaundlend standart vaqti", "HAT": "Nyufaundlend yozgi vaqti", "WIB": "Gʻarbiy Indoneziya vaqti", "PDT": "Tinch okeani yozgi vaqti", "CDT": "Markaziy Amerika yozgi vaqti", "CHAST": "Chatem standart vaqti", "NZDT": "Yangi Zelandiya yozgi vaqti", "VET": "Venesuela vaqti", "WARST": "Gʻarbiy Argentina yozgi vaqti", "WESZ": "G‘arbiy Yevropa yozgi vaqti", "HKST": "Gonkong yozgi vaqti", "GFT": "Fransuz Gvianasi vaqti", "WITA": "Markaziy Indoneziya vaqti", "LHDT": "Lord-Xau yozgi vaqti", "WIT": "Sharqiy Indoneziya vaqti", "CHADT": "Chatem yozgi vaqti", "∅∅∅": "Amazonka yozgi vaqti", "MYT": "Malayziya vaqti", "ART": "Argentina standart vaqti", "PST": "Tinch okeani standart vaqti", "IST": "Hindiston vaqti", "MEZ": "Markaziy Yevropa standart vaqti", "MESZ": "Markaziy Yevropa yozgi vaqti", "JDT": "Yaponiya yozgi vaqti", "ACST": "Markaziy Avstraliya standart vaqti", "AEDT": "Sharqiy Avstraliya yozgi vaqti"}, + } +} + +// Locale returns the current translators string locale +func (uz *uz_Arab) Locale() string { + return uz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uz_Arab' +func (uz *uz_Arab) PluralsCardinal() []locales.PluralRule { + return uz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uz_Arab' +func (uz *uz_Arab) PluralsOrdinal() []locales.PluralRule { + return uz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uz_Arab' +func (uz *uz_Arab) PluralsRange() []locales.PluralRule { + return uz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Arab' +func (uz *uz_Arab) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Arab' +func (uz *uz_Arab) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uz_Arab' +func (uz *uz_Arab) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uz.CardinalPluralRule(num1, v1) + end := uz.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uz *uz_Arab) MonthAbbreviated(month time.Month) string { + return uz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uz *uz_Arab) MonthsAbbreviated() []string { + return uz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uz *uz_Arab) MonthNarrow(month time.Month) string { + return uz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uz *uz_Arab) MonthsNarrow() []string { + return uz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uz *uz_Arab) MonthWide(month time.Month) string { + return uz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uz *uz_Arab) MonthsWide() []string { + return uz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uz *uz_Arab) WeekdayAbbreviated(weekday time.Weekday) string { + return uz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uz *uz_Arab) WeekdaysAbbreviated() []string { + return uz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uz *uz_Arab) WeekdayNarrow(weekday time.Weekday) string { + return uz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uz *uz_Arab) WeekdaysNarrow() []string { + return uz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uz *uz_Arab) WeekdayShort(weekday time.Weekday) string { + return uz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uz *uz_Arab) WeekdaysShort() []string { + return uz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uz *uz_Arab) WeekdayWide(weekday time.Weekday) string { + return uz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uz *uz_Arab) WeekdaysWide() []string { + return uz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uz_Arab' and handles both Whole and Real numbers based on 'v' +func (uz *uz_Arab) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(uz.decimal) - 1; j >= 0; j-- { + b = append(b, uz.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uz_Arab' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uz *uz_Arab) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(uz.decimal) - 1; j >= 0; j-- { + b = append(b, uz.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Arab' +func (uz *uz_Arab) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(uz.decimal) - 1; j >= 0; j-- { + b = append(b, uz.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, uz.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Arab' +// in accounting notation. +func (uz *uz_Arab) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(uz.decimal) - 1; j >= 0; j-- { + b = append(b, uz.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uz.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uz.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, uz.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uz_Arab' +func (uz *uz_Arab) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uz_Arab' +func (uz *uz_Arab) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uz_Arab' +func (uz *uz_Arab) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd9, 0x86, 0xda, 0x86, 0xdb, 0x8c, 0x20}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uz_Arab' +func (uz *uz_Arab) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20, 0xd9, 0x86, 0xda, 0x86, 0xdb, 0x8c, 0x20, 0xdb, 0x8c, 0xdb, 0x8c, 0xd9, 0x84, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20, 0xd9, 0x86, 0xda, 0x86, 0xdb, 0x8c, 0x20}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = append(b, uz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20, 0xda, 0xa9, 0xd9, 0x88, 0xd9, 0x86, 0xdb, 0x8c}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uz_Arab' +func (uz *uz_Arab) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uz_Arab' +func (uz *uz_Arab) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uz_Arab' +func (uz *uz_Arab) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uz_Arab' +func (uz *uz_Arab) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := uz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uz_Arab/uz_Arab_test.go b/vendor/github.com/go-playground/locales/uz_Arab/uz_Arab_test.go new file mode 100644 index 0000000000..2c9400ae5d --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Arab/uz_Arab_test.go @@ -0,0 +1,1120 @@ +package uz_Arab + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uz_Arab" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uz_Arab_AF/uz_Arab_AF.go b/vendor/github.com/go-playground/locales/uz_Arab_AF/uz_Arab_AF.go new file mode 100644 index 0000000000..607619df77 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Arab_AF/uz_Arab_AF.go @@ -0,0 +1,601 @@ +package uz_Arab_AF + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uz_Arab_AF struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uz_Arab_AF' locale +func New() locales.Translator { + return &uz_Arab_AF{ + locale: "uz_Arab_AF", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avg", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "Y", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avgust", "sentabr", "oktabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"Yak", "Dush", "Sesh", "Chor", "Pay", "Jum", "Shan"}, + daysNarrow: []string{"Y", "D", "S", "C", "P", "J", "S"}, + daysShort: []string{"Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"}, + daysWide: []string{"yakshanba", "dushanba", "seshanba", "chorshanba", "payshanba", "juma", "shanba"}, + periodsAbbreviated: []string{"TO", "TK"}, + periodsNarrow: []string{"TO", "TK"}, + periodsWide: []string{"TO", "TK"}, + erasAbbreviated: []string{"m.a.", "milodiy"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"WART": "Gʻarbiy Argentina standart vaqti", "TMST": "Turkmaniston yozgi vaqti", "HNNOMX": "Shimoli-g‘arbiy Meksika standart vaqti", "OESZ": "Sharqiy Yevropa yozgi vaqti", "ARST": "Argentina yozgi vaqti", "GFT": "Fransuz Gvianasi vaqti", "ChST": "Chamorro standart vaqti", "MDT": "MDT", "HNCU": "Kuba standart vaqti", "CHADT": "Chatem yozgi vaqti", "VET": "Venesuela vaqti", "ADT": "Atlantika yozgi vaqti", "COT": "Kolumbiya standart vaqti", "HEEG": "Sharqiy Grenlandiya yozgi vaqti", "AKST": "Alyaska standart vaqti", "HNPMX": "Meksika Tinch okeani standart vaqti", "CST": "Markaziy Amerika standart vaqti", "PDT": "Tinch okeani yozgi vaqti", "CAT": "Markaziy Afrika vaqti", "NZDT": "Yangi Zelandiya yozgi vaqti", "HKT": "Gonkong standart vaqti", "AKDT": "Alyaska yozgi vaqti", "LHST": "Lord-Xau standart vaqti", "CLST": "Chili yozgi vaqti", "UYST": "Urugvay yozgi vaqti", "HEPM": "Sen-Pyer va Mikelon yozgi vaqti", "CHAST": "Chatem standart vaqti", "EST": "Sharqiy Amerika standart vaqti", "EDT": "Sharqiy Amerika yozgi vaqti", "HENOMX": "Shimoli-g‘arbiy Meksika yozgi vaqti", "BT": "Butan vaqti", "ACWST": "Markaziy Avstraliya g‘arbiy standart vaqti", "MESZ": "Markaziy Yevropa yozgi vaqti", "HEOG": "G‘arbiy Grenlandiya yozgi vaqti", "WAT": "Gʻarbiy Afrika standart vaqti", "HNT": "Nyufaundlend standart vaqti", "AEDT": "Sharqiy Avstraliya yozgi vaqti", "GYT": "Gayana vaqti", "HECU": "Kuba yozgi vaqti", "CDT": "Markaziy Amerika yozgi vaqti", "BOT": "Boliviya vaqti", "IST": "Hindiston vaqti", "TMT": "Turkmaniston standart vaqti", "ACST": "Markaziy Avstraliya standart vaqti", "WITA": "Markaziy Indoneziya vaqti", "EAT": "Sharqiy Afrika vaqti", "UYT": "Urugvay standart vaqti", "AEST": "Sharqiy Avstraliya standart vaqti", "HNPM": "Sen-Pyer va Mikelon standart vaqti", "GMT": "Grinvich o‘rtacha vaqti", "WARST": "Gʻarbiy Argentina yozgi vaqti", "PST": "Tinch okeani standart vaqti", "HNOG": "G‘arbiy Grenlandiya standart vaqti", "WESZ": "G‘arbiy Yevropa yozgi vaqti", "HNEG": "Sharqiy Grenlandiya standart vaqti", "AWDT": "G‘arbiy Avstraliya yozgi vaqti", "HAT": "Nyufaundlend yozgi vaqti", "CLT": "Chili standart vaqti", "LHDT": "Lord-Xau yozgi vaqti", "∅∅∅": "Azor orollari yozgi vaqti", "WIB": "Gʻarbiy Indoneziya vaqti", "SGT": "Singapur vaqti", "HAST": "Gavayi-aleut standart vaqti", "ACWDT": "Markaziy Avstraliya g‘arbiy yozgi vaqti", "OEZ": "Sharqiy Yevropa standart vaqti", "SAST": "Janubiy Afrika standart vaqti", "ACDT": "Markaziy Avstraliya yozgi vaqti", "AWST": "G‘arbiy Avstraliya standart vaqti", "AST": "Atlantika standart vaqti", "WEZ": "G‘arbiy Yevropa standart vaqti", "MYT": "Malayziya vaqti", "WAST": "Gʻarbiy Afrika yozgi vaqti", "COST": "Kolumbiya yozgi vaqti", "HEPMX": "Meksika Tinch okeani yozgi vaqti", "WIT": "Sharqiy Indoneziya vaqti", "HADT": "Gavayi-aleut yozgi vaqti", "MEZ": "Markaziy Yevropa standart vaqti", "MST": "MST", "SRT": "Surinam vaqti", "NZST": "Yangi Zelandiya standart vaqti", "JST": "Yaponiya standart vaqti", "JDT": "Yaponiya yozgi vaqti", "ART": "Argentina standart vaqti", "HKST": "Gonkong yozgi vaqti", "ECT": "Ekvador vaqti"}, + } +} + +// Locale returns the current translators string locale +func (uz *uz_Arab_AF) Locale() string { + return uz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uz_Arab_AF' +func (uz *uz_Arab_AF) PluralsCardinal() []locales.PluralRule { + return uz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uz_Arab_AF' +func (uz *uz_Arab_AF) PluralsOrdinal() []locales.PluralRule { + return uz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uz_Arab_AF' +func (uz *uz_Arab_AF) PluralsRange() []locales.PluralRule { + return uz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uz.CardinalPluralRule(num1, v1) + end := uz.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uz *uz_Arab_AF) MonthAbbreviated(month time.Month) string { + return uz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uz *uz_Arab_AF) MonthsAbbreviated() []string { + return uz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uz *uz_Arab_AF) MonthNarrow(month time.Month) string { + return uz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uz *uz_Arab_AF) MonthsNarrow() []string { + return uz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uz *uz_Arab_AF) MonthWide(month time.Month) string { + return uz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uz *uz_Arab_AF) MonthsWide() []string { + return uz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uz *uz_Arab_AF) WeekdayAbbreviated(weekday time.Weekday) string { + return uz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uz *uz_Arab_AF) WeekdaysAbbreviated() []string { + return uz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uz *uz_Arab_AF) WeekdayNarrow(weekday time.Weekday) string { + return uz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uz *uz_Arab_AF) WeekdaysNarrow() []string { + return uz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uz *uz_Arab_AF) WeekdayShort(weekday time.Weekday) string { + return uz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uz *uz_Arab_AF) WeekdaysShort() []string { + return uz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uz *uz_Arab_AF) WeekdayWide(weekday time.Weekday) string { + return uz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uz *uz_Arab_AF) WeekdaysWide() []string { + return uz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uz_Arab_AF' and handles both Whole and Real numbers based on 'v' +func (uz *uz_Arab_AF) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uz_Arab_AF' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uz *uz_Arab_AF) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, uz.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Arab_AF' +// in accounting notation. +func (uz *uz_Arab_AF) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uz.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uz.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, uz.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, uz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uz_Arab_AF' +func (uz *uz_Arab_AF) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := uz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uz_Arab_AF/uz_Arab_AF_test.go b/vendor/github.com/go-playground/locales/uz_Arab_AF/uz_Arab_AF_test.go new file mode 100644 index 0000000000..2597b9d42b --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Arab_AF/uz_Arab_AF_test.go @@ -0,0 +1,1120 @@ +package uz_Arab_AF + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uz_Arab_AF" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uz_Cyrl/uz_Cyrl.go b/vendor/github.com/go-playground/locales/uz_Cyrl/uz_Cyrl.go new file mode 100644 index 0000000000..e8e8f1a6e2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Cyrl/uz_Cyrl.go @@ -0,0 +1,622 @@ +package uz_Cyrl + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uz_Cyrl struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uz_Cyrl' locale +func New() locales.Translator { + return &uz_Cyrl{ + locale: "uz_Cyrl", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: "٫", + group: "٬", + minus: "-", + percent: "٪", + perMille: "؉", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "сўм", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "янв", "фев", "мар", "апр", "май", "июн", "июл", "авг", "сен", "окт", "ноя", "дек"}, + monthsNarrow: []string{"", "Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"}, + monthsWide: []string{"", "январ", "феврал", "март", "апрел", "май", "июн", "июл", "август", "сентябр", "октябр", "ноябр", "декабр"}, + daysAbbreviated: []string{"якш", "душ", "сеш", "чор", "пай", "жум", "шан"}, + daysNarrow: []string{"Я", "Д", "С", "Ч", "П", "Ж", "Ш"}, + daysShort: []string{"Як", "Ду", "Се", "Чо", "Па", "Жу", "Ша"}, + daysWide: []string{"якшанба", "душанба", "сешанба", "чоршанба", "пайшанба", "жума", "шанба"}, + periodsAbbreviated: []string{"ТО", "ТК"}, + periodsNarrow: []string{"ТО", "ТК"}, + periodsWide: []string{"ТО", "ТК"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HKT": "Гонконг стандарт вақти", "HAT": "Ньюфаундленд кундузги вақти", "HEEG": "Шарқий Гренландия ёзги вақти", "SRT": "Суринам вақти", "WIT": "Шарқий Индонезия вақти", "NZDT": "Янги Зеландия кундузги вақти", "HNOG": "Ғарбий Гренландия стандарт вақти", "EST": "Шимолий Америка шарқий стандарт вақти", "COT": "Колумбия стандарт вақти", "HNEG": "Шарқий Гренландия стандарт вақти", "MST": "Шимолий Америка тоғ стандарт вақти", "HNPMX": "Meksika Tinch okeani standart vaqti", "CHAST": "Чатхам стандарт вақти", "WEZ": "Ғарбий Европа стандарт вақти", "ACDT": "Марказий Австралия кундузги вақти", "GFT": "Француз Гвианаси вақти", "UYST": "Уругвай ёзги вақти", "WIB": "Ғарбий Индонезия вақти", "CST": "Шимолий Америка марказий стандарт вақти", "SGT": "Сингапур вақти", "ACST": "Марказий Австралия стандарт вақти", "∅∅∅": "∅∅∅", "BOT": "Боливия вақти", "NZST": "Янги Зеландия стандарт вақти", "EDT": "Шимолий Америка шарқий кундузги вақти", "AEST": "Шарқий Австралия стандарт вақти", "HNPM": "Сент-Пьер ва Микелон стандарт вақти", "HADT": "Гавайи-алеут кундузги вақти", "CLST": "Чили ёзги вақти", "HKST": "Гонконг ёзги вақти", "LHDT": "Лорд Хове кундузги вақти", "MESZ": "Марказий Европа ёзги вақти", "WARST": "Ғарбий Аргентина ёзги вақти", "OEZ": "Шарқий Европа стандарт вақти", "BT": "Бутан вақти", "HAST": "Гавайи-алеут стандарт вақти", "VET": "Венесуэла вақти", "JDT": "Япония кундузги вақти", "OESZ": "Шарқий Европа ёзги вақти", "ChST": "Каморро вақти", "WITA": "Марказий Индонезия вақти", "UYT": "Уругвай стандарт вақти", "HNCU": "Куба стандарт вақти", "AWST": "Ғарбий Австралия стандарт вақти", "ACWDT": "Марказий Австралия Ғарбий кундузги вақти", "MDT": "Шимолий Америка тоғ кундузги вақти", "HEPMX": "Meksika Tinch okeani yozgi vaqti", "AWDT": "Ғарбий Австралия кундузги вақти", "ECT": "Эквадор вақти", "TMT": "Туркманистон стандарт вақти", "AKST": "Аляска стандарт вақти", "CAT": "Марказий Африка вақти", "HEOG": "Ғарбий Гренландия ёзги вақти", "HEPM": "Сент-Пьер ва Микелон кундузги вақти", "PDT": "Шимолий Америка тинч океани кундузги вақти", "MYT": "Малайзия вақти", "GMT": "Гринвич вақти", "ARST": "Аргентина ёзги вақти", "HNNOMX": "Shimoli-g‘arbiy Meksika standart vaqti", "LHST": "Лорд Хове стандарт вақти", "HECU": "Куба кундузги вақти", "ART": "Аргентина стандарт вақти", "COST": "Колумбия ёзги вақти", "HENOMX": "Shimoli-g‘arbiy Meksika yozgi vaqti", "AKDT": "Аляска кундузги вақти", "EAT": "Шарқий Африка вақти", "IST": "Ҳиндистон вақти", "MEZ": "Марказий Европа стандарт вақти", "JST": "Япония стандарт вақти", "AST": "Атлантика стандарт вақти", "WAST": "Ғарбий Африка ёзги вақти", "WESZ": "Ғарбий Европа ёзги вақти", "CDT": "Шимолий Америка марказий кундузги вақти", "AEDT": "Шарқий Австралия кундузги вақти", "GYT": "Гайана вақти", "CHADT": "Чатхам кундузги вақти", "PST": "Шимолий Америка тинч океани стандарт вақти", "ACWST": "Марказий Австралия Ғарбий стандарт вақти", "WART": "Ғарбий Аргентина стандарт вақти", "TMST": "Туркманистон ёзги вақти", "HNT": "Ньюфаундленд стандарт вақти", "SAST": "Жанубий Африка вақти", "CLT": "Чили стандарт вақти", "ADT": "Атлантика кундузги вақти", "WAT": "Ғарбий Африка стандарт вақти"}, + } +} + +// Locale returns the current translators string locale +func (uz *uz_Cyrl) Locale() string { + return uz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uz_Cyrl' +func (uz *uz_Cyrl) PluralsCardinal() []locales.PluralRule { + return uz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uz_Cyrl' +func (uz *uz_Cyrl) PluralsOrdinal() []locales.PluralRule { + return uz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uz_Cyrl' +func (uz *uz_Cyrl) PluralsRange() []locales.PluralRule { + return uz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Cyrl' +func (uz *uz_Cyrl) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Cyrl' +func (uz *uz_Cyrl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uz_Cyrl' +func (uz *uz_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uz.CardinalPluralRule(num1, v1) + end := uz.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uz *uz_Cyrl) MonthAbbreviated(month time.Month) string { + return uz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uz *uz_Cyrl) MonthsAbbreviated() []string { + return uz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uz *uz_Cyrl) MonthNarrow(month time.Month) string { + return uz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uz *uz_Cyrl) MonthsNarrow() []string { + return uz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uz *uz_Cyrl) MonthWide(month time.Month) string { + return uz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uz *uz_Cyrl) MonthsWide() []string { + return uz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uz *uz_Cyrl) WeekdayAbbreviated(weekday time.Weekday) string { + return uz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uz *uz_Cyrl) WeekdaysAbbreviated() []string { + return uz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uz *uz_Cyrl) WeekdayNarrow(weekday time.Weekday) string { + return uz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uz *uz_Cyrl) WeekdaysNarrow() []string { + return uz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uz *uz_Cyrl) WeekdayShort(weekday time.Weekday) string { + return uz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uz *uz_Cyrl) WeekdaysShort() []string { + return uz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uz *uz_Cyrl) WeekdayWide(weekday time.Weekday) string { + return uz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uz *uz_Cyrl) WeekdaysWide() []string { + return uz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uz_Cyrl' and handles both Whole and Real numbers based on 'v' +func (uz *uz_Cyrl) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(uz.decimal) - 1; j >= 0; j-- { + b = append(b, uz.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uz_Cyrl' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uz *uz_Cyrl) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(uz.decimal) - 1; j >= 0; j-- { + b = append(b, uz.decimal[j]) + } + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(uz.decimal) - 1; j >= 0; j-- { + b = append(b, uz.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, uz.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Cyrl' +// in accounting notation. +func (uz *uz_Cyrl) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + for j := len(uz.decimal) - 1; j >= 0; j-- { + b = append(b, uz.decimal[j]) + } + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uz.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uz.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, uz.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, uz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uz_Cyrl' +func (uz *uz_Cyrl) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := uz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uz_Cyrl/uz_Cyrl_test.go b/vendor/github.com/go-playground/locales/uz_Cyrl/uz_Cyrl_test.go new file mode 100644 index 0000000000..9ee22c1d9f --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Cyrl/uz_Cyrl_test.go @@ -0,0 +1,1120 @@ +package uz_Cyrl + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uz_Cyrl" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go b/vendor/github.com/go-playground/locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go new file mode 100644 index 0000000000..403f22bad6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Cyrl_UZ/uz_Cyrl_UZ.go @@ -0,0 +1,601 @@ +package uz_Cyrl_UZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uz_Cyrl_UZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uz_Cyrl_UZ' locale +func New() locales.Translator { + return &uz_Cyrl_UZ{ + locale: "uz_Cyrl_UZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avg", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "Y", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avgust", "sentabr", "oktabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"Yak", "Dush", "Sesh", "Chor", "Pay", "Jum", "Shan"}, + daysNarrow: []string{"Y", "D", "S", "C", "P", "J", "S"}, + daysShort: []string{"Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"}, + daysWide: []string{"yakshanba", "dushanba", "seshanba", "chorshanba", "payshanba", "juma", "shanba"}, + periodsAbbreviated: []string{"TO", "TK"}, + periodsNarrow: []string{"TO", "TK"}, + periodsWide: []string{"TO", "TK"}, + erasAbbreviated: []string{"m.a.", "milodiy"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"HEEG": "Sharqiy Grenlandiya yozgi vaqti", "AEST": "Sharqiy Avstraliya standart vaqti", "GFT": "Fransuz Gvianasi vaqti", "GMT": "Grinvich o‘rtacha vaqti", "MYT": "Malayziya vaqti", "TMST": "Turkmaniston yozgi vaqti", "ART": "Argentina standart vaqti", "ACDT": "Markaziy Avstraliya yozgi vaqti", "HEPMX": "Meksika Tinch okeani yozgi vaqti", "NZST": "Yangi Zelandiya standart vaqti", "GYT": "Gayana vaqti", "SGT": "Singapur vaqti", "WART": "Gʻarbiy Argentina standart vaqti", "CLT": "Chili standart vaqti", "HKT": "Gonkong standart vaqti", "LHDT": "Lord-Xau yozgi vaqti", "SRT": "Surinam vaqti", "∅∅∅": "∅∅∅", "UYST": "Urugvay yozgi vaqti", "EAT": "Sharqiy Afrika vaqti", "WESZ": "G‘arbiy Yevropa yozgi vaqti", "MDT": "MDT", "BT": "Butan vaqti", "AEDT": "Sharqiy Avstraliya yozgi vaqti", "PST": "Tinch okeani standart vaqti", "HADT": "Gavayi-aleut yozgi vaqti", "JST": "Yaponiya standart vaqti", "ADT": "Atlantika yozgi vaqti", "MST": "MST", "COST": "Kolumbiya yozgi vaqti", "HNPM": "Sen-Pyer va Mikelon standart vaqti", "CDT": "Markaziy Amerika yozgi vaqti", "WAST": "Gʻarbiy Afrika yozgi vaqti", "CAT": "Markaziy Afrika vaqti", "VET": "Venesuela vaqti", "EST": "Sharqiy Amerika standart vaqti", "EDT": "Sharqiy Amerika yozgi vaqti", "AKDT": "Alyaska yozgi vaqti", "HEPM": "Sen-Pyer va Mikelon yozgi vaqti", "AWST": "G‘arbiy Avstraliya standart vaqti", "ARST": "Argentina yozgi vaqti", "ACST": "Markaziy Avstraliya standart vaqti", "HNT": "Nyufaundlend standart vaqti", "WAT": "Gʻarbiy Afrika standart vaqti", "CHADT": "Chatem yozgi vaqti", "HNOG": "G‘arbiy Grenlandiya standart vaqti", "ACWST": "Markaziy Avstraliya g‘arbiy standart vaqti", "OESZ": "Sharqiy Yevropa yozgi vaqti", "HAT": "Nyufaundlend yozgi vaqti", "LHST": "Lord-Xau standart vaqti", "AWDT": "G‘arbiy Avstraliya yozgi vaqti", "IST": "Hindiston vaqti", "WIB": "Gʻarbiy Indoneziya vaqti", "PDT": "Tinch okeani yozgi vaqti", "ECT": "Ekvador vaqti", "CLST": "Chili yozgi vaqti", "HEOG": "G‘arbiy Grenlandiya yozgi vaqti", "AKST": "Alyaska standart vaqti", "SAST": "Janubiy Afrika standart vaqti", "HNCU": "Kuba standart vaqti", "JDT": "Yaponiya yozgi vaqti", "HKST": "Gonkong yozgi vaqti", "HNNOMX": "Shimoli-g‘arbiy Meksika standart vaqti", "HENOMX": "Shimoli-g‘arbiy Meksika yozgi vaqti", "HNPMX": "Meksika Tinch okeani standart vaqti", "BOT": "Boliviya vaqti", "HAST": "Gavayi-aleut standart vaqti", "OEZ": "Sharqiy Yevropa standart vaqti", "AST": "Atlantika standart vaqti", "WITA": "Markaziy Indoneziya vaqti", "CST": "Markaziy Amerika standart vaqti", "CHAST": "Chatem standart vaqti", "MESZ": "Markaziy Yevropa yozgi vaqti", "WARST": "Gʻarbiy Argentina yozgi vaqti", "TMT": "Turkmaniston standart vaqti", "COT": "Kolumbiya standart vaqti", "NZDT": "Yangi Zelandiya yozgi vaqti", "MEZ": "Markaziy Yevropa standart vaqti", "WIT": "Sharqiy Indoneziya vaqti", "ACWDT": "Markaziy Avstraliya g‘arbiy yozgi vaqti", "WEZ": "G‘arbiy Yevropa standart vaqti", "HNEG": "Sharqiy Grenlandiya standart vaqti", "UYT": "Urugvay standart vaqti", "ChST": "Chamorro standart vaqti", "HECU": "Kuba yozgi vaqti"}, + } +} + +// Locale returns the current translators string locale +func (uz *uz_Cyrl_UZ) Locale() string { + return uz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) PluralsCardinal() []locales.PluralRule { + return uz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) PluralsOrdinal() []locales.PluralRule { + return uz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) PluralsRange() []locales.PluralRule { + return uz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uz.CardinalPluralRule(num1, v1) + end := uz.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uz *uz_Cyrl_UZ) MonthAbbreviated(month time.Month) string { + return uz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uz *uz_Cyrl_UZ) MonthsAbbreviated() []string { + return uz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uz *uz_Cyrl_UZ) MonthNarrow(month time.Month) string { + return uz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uz *uz_Cyrl_UZ) MonthsNarrow() []string { + return uz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uz *uz_Cyrl_UZ) MonthWide(month time.Month) string { + return uz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uz *uz_Cyrl_UZ) MonthsWide() []string { + return uz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uz *uz_Cyrl_UZ) WeekdayAbbreviated(weekday time.Weekday) string { + return uz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uz *uz_Cyrl_UZ) WeekdaysAbbreviated() []string { + return uz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uz *uz_Cyrl_UZ) WeekdayNarrow(weekday time.Weekday) string { + return uz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uz *uz_Cyrl_UZ) WeekdaysNarrow() []string { + return uz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uz *uz_Cyrl_UZ) WeekdayShort(weekday time.Weekday) string { + return uz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uz *uz_Cyrl_UZ) WeekdaysShort() []string { + return uz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uz *uz_Cyrl_UZ) WeekdayWide(weekday time.Weekday) string { + return uz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uz *uz_Cyrl_UZ) WeekdaysWide() []string { + return uz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uz_Cyrl_UZ' and handles both Whole and Real numbers based on 'v' +func (uz *uz_Cyrl_UZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uz_Cyrl_UZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uz *uz_Cyrl_UZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, uz.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Cyrl_UZ' +// in accounting notation. +func (uz *uz_Cyrl_UZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uz.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uz.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, uz.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, uz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uz_Cyrl_UZ' +func (uz *uz_Cyrl_UZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := uz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uz_Cyrl_UZ/uz_Cyrl_UZ_test.go b/vendor/github.com/go-playground/locales/uz_Cyrl_UZ/uz_Cyrl_UZ_test.go new file mode 100644 index 0000000000..88b8fec379 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Cyrl_UZ/uz_Cyrl_UZ_test.go @@ -0,0 +1,1120 @@ +package uz_Cyrl_UZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uz_Cyrl_UZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uz_Latn/uz_Latn.go b/vendor/github.com/go-playground/locales/uz_Latn/uz_Latn.go new file mode 100644 index 0000000000..158fe389cf --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Latn/uz_Latn.go @@ -0,0 +1,601 @@ +package uz_Latn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uz_Latn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uz_Latn' locale +func New() locales.Translator { + return &uz_Latn{ + locale: "uz_Latn", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avg", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "Y", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avgust", "sentabr", "oktabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"Yak", "Dush", "Sesh", "Chor", "Pay", "Jum", "Shan"}, + daysNarrow: []string{"Y", "D", "S", "C", "P", "J", "S"}, + daysShort: []string{"Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"}, + daysWide: []string{"yakshanba", "dushanba", "seshanba", "chorshanba", "payshanba", "juma", "shanba"}, + periodsAbbreviated: []string{"TO", "TK"}, + periodsNarrow: []string{"TO", "TK"}, + periodsWide: []string{"TO", "TK"}, + erasAbbreviated: []string{"m.a.", "milodiy"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"WIT": "Sharqiy Indoneziya vaqti", "HKST": "Gonkong yozgi vaqti", "COT": "Kolumbiya standart vaqti", "HECU": "Kuba yozgi vaqti", "CST": "Markaziy Amerika standart vaqti", "ACST": "Markaziy Avstraliya standart vaqti", "HNNOMX": "Shimoli-g‘arbiy Meksika standart vaqti", "WIB": "Gʻarbiy Indoneziya vaqti", "MESZ": "Markaziy Yevropa yozgi vaqti", "HNOG": "G‘arbiy Grenlandiya standart vaqti", "MDT": "MDT", "HEEG": "Sharqiy Grenlandiya yozgi vaqti", "ADT": "Atlantika yozgi vaqti", "MYT": "Malayziya vaqti", "HNEG": "Sharqiy Grenlandiya standart vaqti", "HEPMX": "Meksika Tinch okeani yozgi vaqti", "IST": "Hindiston vaqti", "CLT": "Chili standart vaqti", "CLST": "Chili yozgi vaqti", "HEOG": "G‘arbiy Grenlandiya yozgi vaqti", "HENOMX": "Shimoli-g‘arbiy Meksika yozgi vaqti", "LHST": "Lord-Xau standart vaqti", "BOT": "Boliviya vaqti", "BT": "Butan vaqti", "WITA": "Markaziy Indoneziya vaqti", "HADT": "Gavayi-aleut yozgi vaqti", "CAT": "Markaziy Afrika vaqti", "GMT": "Grinvich o‘rtacha vaqti", "EDT": "Sharqiy Amerika yozgi vaqti", "NZDT": "Yangi Zelandiya yozgi vaqti", "HNT": "Nyufaundlend standart vaqti", "ChST": "Chamorro standart vaqti", "JDT": "Yaponiya yozgi vaqti", "ARST": "Argentina yozgi vaqti", "UYT": "Urugvay standart vaqti", "HNCU": "Kuba standart vaqti", "PST": "Tinch okeani standart vaqti", "HAST": "Gavayi-aleut standart vaqti", "MEZ": "Markaziy Yevropa standart vaqti", "VET": "Venesuela vaqti", "SGT": "Singapur vaqti", "WESZ": "G‘arbiy Yevropa yozgi vaqti", "HAT": "Nyufaundlend yozgi vaqti", "AKST": "Alyaska standart vaqti", "AWDT": "G‘arbiy Avstraliya yozgi vaqti", "SRT": "Surinam vaqti", "GYT": "Gayana vaqti", "ECT": "Ekvador vaqti", "ACWDT": "Markaziy Avstraliya g‘arbiy yozgi vaqti", "OESZ": "Sharqiy Yevropa yozgi vaqti", "COST": "Kolumbiya yozgi vaqti", "EAT": "Sharqiy Afrika vaqti", "ACWST": "Markaziy Avstraliya g‘arbiy standart vaqti", "WEZ": "G‘arbiy Yevropa standart vaqti", "MST": "MST", "WAT": "Gʻarbiy Afrika standart vaqti", "LHDT": "Lord-Xau yozgi vaqti", "CDT": "Markaziy Amerika yozgi vaqti", "CHADT": "Chatem yozgi vaqti", "OEZ": "Sharqiy Yevropa standart vaqti", "TMT": "Turkmaniston standart vaqti", "ART": "Argentina standart vaqti", "HNPM": "Sen-Pyer va Mikelon standart vaqti", "JST": "Yaponiya standart vaqti", "WART": "Gʻarbiy Argentina standart vaqti", "TMST": "Turkmaniston yozgi vaqti", "EST": "Sharqiy Amerika standart vaqti", "WAST": "Gʻarbiy Afrika yozgi vaqti", "HKT": "Gonkong standart vaqti", "ACDT": "Markaziy Avstraliya yozgi vaqti", "AKDT": "Alyaska yozgi vaqti", "PDT": "Tinch okeani yozgi vaqti", "NZST": "Yangi Zelandiya standart vaqti", "WARST": "Gʻarbiy Argentina yozgi vaqti", "AST": "Atlantika standart vaqti", "CHAST": "Chatem standart vaqti", "AEDT": "Sharqiy Avstraliya yozgi vaqti", "SAST": "Janubiy Afrika standart vaqti", "HNPMX": "Meksika Tinch okeani standart vaqti", "AWST": "G‘arbiy Avstraliya standart vaqti", "HEPM": "Sen-Pyer va Mikelon yozgi vaqti", "∅∅∅": "Amazonka yozgi vaqti", "GFT": "Fransuz Gvianasi vaqti", "AEST": "Sharqiy Avstraliya standart vaqti", "UYST": "Urugvay yozgi vaqti"}, + } +} + +// Locale returns the current translators string locale +func (uz *uz_Latn) Locale() string { + return uz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uz_Latn' +func (uz *uz_Latn) PluralsCardinal() []locales.PluralRule { + return uz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uz_Latn' +func (uz *uz_Latn) PluralsOrdinal() []locales.PluralRule { + return uz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uz_Latn' +func (uz *uz_Latn) PluralsRange() []locales.PluralRule { + return uz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Latn' +func (uz *uz_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Latn' +func (uz *uz_Latn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uz_Latn' +func (uz *uz_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uz.CardinalPluralRule(num1, v1) + end := uz.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uz *uz_Latn) MonthAbbreviated(month time.Month) string { + return uz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uz *uz_Latn) MonthsAbbreviated() []string { + return uz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uz *uz_Latn) MonthNarrow(month time.Month) string { + return uz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uz *uz_Latn) MonthsNarrow() []string { + return uz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uz *uz_Latn) MonthWide(month time.Month) string { + return uz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uz *uz_Latn) MonthsWide() []string { + return uz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uz *uz_Latn) WeekdayAbbreviated(weekday time.Weekday) string { + return uz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uz *uz_Latn) WeekdaysAbbreviated() []string { + return uz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uz *uz_Latn) WeekdayNarrow(weekday time.Weekday) string { + return uz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uz *uz_Latn) WeekdaysNarrow() []string { + return uz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uz *uz_Latn) WeekdayShort(weekday time.Weekday) string { + return uz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uz *uz_Latn) WeekdaysShort() []string { + return uz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uz *uz_Latn) WeekdayWide(weekday time.Weekday) string { + return uz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uz *uz_Latn) WeekdaysWide() []string { + return uz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uz_Latn' and handles both Whole and Real numbers based on 'v' +func (uz *uz_Latn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uz_Latn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uz *uz_Latn) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Latn' +func (uz *uz_Latn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, uz.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Latn' +// in accounting notation. +func (uz *uz_Latn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uz.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uz.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, uz.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uz_Latn' +func (uz *uz_Latn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uz_Latn' +func (uz *uz_Latn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uz_Latn' +func (uz *uz_Latn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uz_Latn' +func (uz *uz_Latn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, uz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uz_Latn' +func (uz *uz_Latn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uz_Latn' +func (uz *uz_Latn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uz_Latn' +func (uz *uz_Latn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uz_Latn' +func (uz *uz_Latn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := uz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uz_Latn/uz_Latn_test.go b/vendor/github.com/go-playground/locales/uz_Latn/uz_Latn_test.go new file mode 100644 index 0000000000..0c813d2aaa --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Latn/uz_Latn_test.go @@ -0,0 +1,1120 @@ +package uz_Latn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uz_Latn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/uz_Latn_UZ/uz_Latn_UZ.go b/vendor/github.com/go-playground/locales/uz_Latn_UZ/uz_Latn_UZ.go new file mode 100644 index 0000000000..e0d58c8c63 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Latn_UZ/uz_Latn_UZ.go @@ -0,0 +1,601 @@ +package uz_Latn_UZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type uz_Latn_UZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'uz_Latn_UZ' locale +func New() locales.Translator { + return &uz_Latn_UZ{ + locale: "uz_Latn_UZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avg", "sen", "okt", "noy", "dek"}, + monthsNarrow: []string{"", "Y", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avgust", "sentabr", "oktabr", "noyabr", "dekabr"}, + daysAbbreviated: []string{"Yak", "Dush", "Sesh", "Chor", "Pay", "Jum", "Shan"}, + daysNarrow: []string{"Y", "D", "S", "C", "P", "J", "S"}, + daysShort: []string{"Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"}, + daysWide: []string{"yakshanba", "dushanba", "seshanba", "chorshanba", "payshanba", "juma", "shanba"}, + periodsAbbreviated: []string{"TO", "TK"}, + periodsNarrow: []string{"TO", "TK"}, + periodsWide: []string{"TO", "TK"}, + erasAbbreviated: []string{"m.a.", "milodiy"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"AST": "Atlantika standart vaqti", "HNCU": "Kuba standart vaqti", "PST": "Tinch okeani standart vaqti", "ACWST": "Markaziy Avstraliya g‘arbiy standart vaqti", "HKT": "Gonkong standart vaqti", "COST": "Kolumbiya yozgi vaqti", "HNT": "Nyufaundlend standart vaqti", "GFT": "Fransuz Gvianasi vaqti", "BOT": "Boliviya vaqti", "HNEG": "Sharqiy Grenlandiya standart vaqti", "AKST": "Alyaska standart vaqti", "SGT": "Singapur vaqti", "MEZ": "Markaziy Yevropa standart vaqti", "VET": "Venesuela vaqti", "OEZ": "Sharqiy Yevropa standart vaqti", "HNPMX": "Meksika Tinch okeani standart vaqti", "CST": "Markaziy Amerika standart vaqti", "CHADT": "Chatem yozgi vaqti", "MYT": "Malayziya vaqti", "WARST": "Gʻarbiy Argentina yozgi vaqti", "HEOG": "G‘arbiy Grenlandiya yozgi vaqti", "WEZ": "G‘arbiy Yevropa standart vaqti", "WAST": "Gʻarbiy Afrika yozgi vaqti", "HNNOMX": "Shimoli-g‘arbiy Meksika standart vaqti", "AEDT": "Sharqiy Avstraliya yozgi vaqti", "AWDT": "G‘arbiy Avstraliya yozgi vaqti", "CAT": "Markaziy Afrika vaqti", "WIT": "Sharqiy Indoneziya vaqti", "HADT": "Gavayi-aleut yozgi vaqti", "NZST": "Yangi Zelandiya standart vaqti", "ACWDT": "Markaziy Avstraliya g‘arbiy yozgi vaqti", "GMT": "Grinvich o‘rtacha vaqti", "EST": "Sharqiy Amerika standart vaqti", "HKST": "Gonkong yozgi vaqti", "ACDT": "Markaziy Avstraliya yozgi vaqti", "HAT": "Nyufaundlend yozgi vaqti", "LHDT": "Lord-Xau yozgi vaqti", "GYT": "Gayana vaqti", "CHAST": "Chatem standart vaqti", "JDT": "Yaponiya yozgi vaqti", "CLT": "Chili standart vaqti", "TMST": "Turkmaniston yozgi vaqti", "EDT": "Sharqiy Amerika yozgi vaqti", "UYT": "Urugvay standart vaqti", "LHST": "Lord-Xau standart vaqti", "CLST": "Chili yozgi vaqti", "WAT": "Gʻarbiy Afrika standart vaqti", "WART": "Gʻarbiy Argentina standart vaqti", "WESZ": "G‘arbiy Yevropa yozgi vaqti", "MST": "MST", "ACST": "Markaziy Avstraliya standart vaqti", "HENOMX": "Shimoli-g‘arbiy Meksika yozgi vaqti", "WITA": "Markaziy Indoneziya vaqti", "EAT": "Sharqiy Afrika vaqti", "AWST": "G‘arbiy Avstraliya standart vaqti", "NZDT": "Yangi Zelandiya yozgi vaqti", "ADT": "Atlantika yozgi vaqti", "OESZ": "Sharqiy Yevropa yozgi vaqti", "ART": "Argentina standart vaqti", "COT": "Kolumbiya standart vaqti", "BT": "Butan vaqti", "AEST": "Sharqiy Avstraliya standart vaqti", "HEPM": "Sen-Pyer va Mikelon yozgi vaqti", "CDT": "Markaziy Amerika yozgi vaqti", "PDT": "Tinch okeani yozgi vaqti", "HAST": "Gavayi-aleut standart vaqti", "TMT": "Turkmaniston standart vaqti", "ChST": "Chamorro standart vaqti", "HNPM": "Sen-Pyer va Mikelon standart vaqti", "ECT": "Ekvador vaqti", "HEEG": "Sharqiy Grenlandiya yozgi vaqti", "UYST": "Urugvay yozgi vaqti", "JST": "Yaponiya standart vaqti", "SAST": "Janubiy Afrika standart vaqti", "WIB": "Gʻarbiy Indoneziya vaqti", "MESZ": "Markaziy Yevropa yozgi vaqti", "HNOG": "G‘arbiy Grenlandiya standart vaqti", "ARST": "Argentina yozgi vaqti", "AKDT": "Alyaska yozgi vaqti", "SRT": "Surinam vaqti", "HEPMX": "Meksika Tinch okeani yozgi vaqti", "HECU": "Kuba yozgi vaqti", "∅∅∅": "Amazonka yozgi vaqti", "IST": "Hindiston vaqti", "MDT": "MDT"}, + } +} + +// Locale returns the current translators string locale +func (uz *uz_Latn_UZ) Locale() string { + return uz.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) PluralsCardinal() []locales.PluralRule { + return uz.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) PluralsOrdinal() []locales.PluralRule { + return uz.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) PluralsRange() []locales.PluralRule { + return uz.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := uz.CardinalPluralRule(num1, v1) + end := uz.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (uz *uz_Latn_UZ) MonthAbbreviated(month time.Month) string { + return uz.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (uz *uz_Latn_UZ) MonthsAbbreviated() []string { + return uz.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (uz *uz_Latn_UZ) MonthNarrow(month time.Month) string { + return uz.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (uz *uz_Latn_UZ) MonthsNarrow() []string { + return uz.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (uz *uz_Latn_UZ) MonthWide(month time.Month) string { + return uz.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (uz *uz_Latn_UZ) MonthsWide() []string { + return uz.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (uz *uz_Latn_UZ) WeekdayAbbreviated(weekday time.Weekday) string { + return uz.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (uz *uz_Latn_UZ) WeekdaysAbbreviated() []string { + return uz.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (uz *uz_Latn_UZ) WeekdayNarrow(weekday time.Weekday) string { + return uz.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (uz *uz_Latn_UZ) WeekdaysNarrow() []string { + return uz.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (uz *uz_Latn_UZ) WeekdayShort(weekday time.Weekday) string { + return uz.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (uz *uz_Latn_UZ) WeekdaysShort() []string { + return uz.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (uz *uz_Latn_UZ) WeekdayWide(weekday time.Weekday) string { + return uz.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (uz *uz_Latn_UZ) WeekdaysWide() []string { + return uz.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'uz_Latn_UZ' and handles both Whole and Real numbers based on 'v' +func (uz *uz_Latn_UZ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'uz_Latn_UZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (uz *uz_Latn_UZ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, uz.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, uz.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, uz.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz_Latn_UZ' +// in accounting notation. +func (uz *uz_Latn_UZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := uz.currencies[currency] + l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, uz.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(uz.group) - 1; j >= 0; j-- { + b = append(b, uz.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, uz.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, uz.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, uz.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, uz.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, uz.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2d}...) + b = append(b, uz.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x29}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'uz_Latn_UZ' +func (uz *uz_Latn_UZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, uz.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, uz.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x28}...) + + tz, _ := t.Zone() + + if btz, ok := uz.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x29}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/uz_Latn_UZ/uz_Latn_UZ_test.go b/vendor/github.com/go-playground/locales/uz_Latn_UZ/uz_Latn_UZ_test.go new file mode 100644 index 0000000000..496cd1a492 --- /dev/null +++ b/vendor/github.com/go-playground/locales/uz_Latn_UZ/uz_Latn_UZ_test.go @@ -0,0 +1,1120 @@ +package uz_Latn_UZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "uz_Latn_UZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vai/vai.go b/vendor/github.com/go-playground/locales/vai/vai.go new file mode 100644 index 0000000000..5f610c44ca --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai/vai.go @@ -0,0 +1,584 @@ +package vai + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vai struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vai' locale +func New() locales.Translator { + return &vai{ + locale: "vai", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "$", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsWide: []string{"", "ꖨꕪꖃ ꔞꕮ", "ꕒꕡꖝꖕ", "ꕾꖺ", "ꖢꖕ", "ꖑꕱ", "6", "7", "ꗛꔕ", "ꕢꕌ", "ꕭꖃ", "ꔞꘋꕔꕿ ꕸꖃꗏ", "ꖨꕪꕱ ꗏꕮ"}, + daysWide: []string{"ꕞꕌꔵ", "ꗳꗡꘉ", "ꕚꕞꕚ", "ꕉꕞꕒ", "ꕉꔤꕆꕢ", "ꕉꔤꕀꕮ", "ꔻꔬꔳ"}, + timezones: map[string]string{"CHADT": "CHADT", "AKDT": "AKDT", "UYT": "UYT", "ACWDT": "ACWDT", "MYT": "MYT", "ARST": "ARST", "ChST": "ChST", "WESZ": "WESZ", "WAT": "WAT", "HNEG": "HNEG", "JDT": "JDT", "AST": "AST", "GMT": "GMT", "EDT": "EDT", "HENOMX": "HENOMX", "HNT": "HNT", "WITA": "WITA", "HECU": "HECU", "NZST": "NZST", "EST": "EST", "WIB": "WIB", "AWST": "AWST", "HADT": "HADT", "∅∅∅": "∅∅∅", "ACDT": "ACDT", "HNPMX": "HNPMX", "ADT": "ADT", "TMT": "TMT", "HKST": "HKST", "HNPM": "HNPM", "CST": "CST", "MDT": "MDT", "ACST": "ACST", "COT": "COT", "HNNOMX": "HNNOMX", "AKST": "AKST", "HNCU": "HNCU", "CDT": "CDT", "AWDT": "AWDT", "BOT": "BOT", "ECT": "ECT", "VET": "VET", "OESZ": "OESZ", "WAST": "WAST", "GFT": "GFT", "UYST": "UYST", "CHAST": "CHAST", "PST": "PST", "MEZ": "MEZ", "WARST": "WARST", "HNOG": "HNOG", "LHDT": "LHDT", "ACWST": "ACWST", "HEOG": "HEOG", "ART": "ART", "HAT": "HAT", "EAT": "EAT", "IST": "IST", "OEZ": "OEZ", "WART": "WART", "CLT": "CLT", "TMST": "TMST", "AEDT": "AEDT", "HEPMX": "HEPMX", "WEZ": "WEZ", "LHST": "LHST", "SGT": "SGT", "PDT": "PDT", "HKT": "HKT", "HEEG": "HEEG", "SRT": "SRT", "WIT": "WIT", "MESZ": "MESZ", "CLST": "CLST", "COST": "COST", "BT": "BT", "SAST": "SAST", "GYT": "GYT", "HAST": "HAST", "CAT": "CAT", "NZDT": "NZDT", "JST": "JST", "MST": "MST", "AEST": "AEST", "HEPM": "HEPM"}, + } +} + +// Locale returns the current translators string locale +func (vai *vai) Locale() string { + return vai.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vai' +func (vai *vai) PluralsCardinal() []locales.PluralRule { + return vai.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vai' +func (vai *vai) PluralsOrdinal() []locales.PluralRule { + return vai.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vai' +func (vai *vai) PluralsRange() []locales.PluralRule { + return vai.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vai' +func (vai *vai) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vai' +func (vai *vai) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vai' +func (vai *vai) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vai *vai) MonthAbbreviated(month time.Month) string { + return vai.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vai *vai) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vai *vai) MonthNarrow(month time.Month) string { + return vai.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vai *vai) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vai *vai) MonthWide(month time.Month) string { + return vai.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vai *vai) MonthsWide() []string { + return vai.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vai *vai) WeekdayAbbreviated(weekday time.Weekday) string { + return vai.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vai *vai) WeekdaysAbbreviated() []string { + return vai.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vai *vai) WeekdayNarrow(weekday time.Weekday) string { + return vai.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vai *vai) WeekdaysNarrow() []string { + return vai.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vai *vai) WeekdayShort(weekday time.Weekday) string { + return vai.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vai *vai) WeekdaysShort() []string { + return vai.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vai *vai) WeekdayWide(weekday time.Weekday) string { + return vai.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vai *vai) WeekdaysWide() []string { + return vai.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vai' and handles both Whole and Real numbers based on 'v' +func (vai *vai) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vai' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vai *vai) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vai' +func (vai *vai) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vai' +// in accounting notation. +func (vai *vai) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, vai.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, vai.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vai' +func (vai *vai) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vai' +func (vai *vai) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vai' +func (vai *vai) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vai' +func (vai *vai) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vai.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vai' +func (vai *vai) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vai' +func (vai *vai) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vai' +func (vai *vai) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vai' +func (vai *vai) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vai.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vai/vai_test.go b/vendor/github.com/go-playground/locales/vai/vai_test.go new file mode 100644 index 0000000000..cbb914ebc5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai/vai_test.go @@ -0,0 +1,1120 @@ +package vai + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vai" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vai_Latn/vai_Latn.go b/vendor/github.com/go-playground/locales/vai_Latn/vai_Latn.go new file mode 100644 index 0000000000..2517ac5027 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai_Latn/vai_Latn.go @@ -0,0 +1,584 @@ +package vai_Latn + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vai_Latn struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vai_Latn' locale +func New() locales.Translator { + return &vai_Latn{ + locale: "vai_Latn", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "$", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsWide: []string{"", "luukao kemã", "ɓandaɓu", "vɔɔ", "fulu", "goo", "6", "7", "kɔnde", "saah", "galo", "kenpkato ɓololɔ", "luukao lɔma"}, + daysWide: []string{"lahadi", "tɛɛnɛɛ", "talata", "alaba", "aimisa", "aijima", "siɓiti"}, + timezones: map[string]string{"PDT": "PDT", "EST": "EST", "ACST": "ACST", "COST": "COST", "MST": "MST", "GFT": "GFT", "WITA": "WITA", "HNPMX": "HNPMX", "JST": "JST", "JDT": "JDT", "OEZ": "OEZ", "COT": "COT", "HNNOMX": "HNNOMX", "EAT": "EAT", "MEZ": "MEZ", "MDT": "MDT", "HEPM": "HEPM", "WIT": "WIT", "GMT": "GMT", "WARST": "WARST", "OESZ": "OESZ", "HAT": "HAT", "SAST": "SAST", "LHST": "LHST", "LHDT": "LHDT", "HEPMX": "HEPMX", "HADT": "HADT", "BT": "BT", "WIB": "WIB", "CHAST": "CHAST", "NZDT": "NZDT", "WEZ": "WEZ", "TMT": "TMT", "AEDT": "AEDT", "MYT": "MYT", "WAST": "WAST", "HNT": "HNT", "CST": "CST", "ACWDT": "ACWDT", "CLST": "CLST", "ART": "ART", "HENOMX": "HENOMX", "HEEG": "HEEG", "ECT": "ECT", "NZST": "NZST", "ADT": "ADT", "TMST": "TMST", "AKST": "AKST", "HNPM": "HNPM", "GYT": "GYT", "HNCU": "HNCU", "WART": "WART", "ARST": "ARST", "ACDT": "ACDT", "HECU": "HECU", "CHADT": "CHADT", "ACWST": "ACWST", "HKST": "HKST", "UYT": "UYT", "BOT": "BOT", "CAT": "CAT", "HNEG": "HNEG", "UYST": "UYST", "AWST": "AWST", "∅∅∅": "∅∅∅", "SRT": "SRT", "WAT": "WAT", "HKT": "HKT", "AWDT": "AWDT", "HAST": "HAST", "VET": "VET", "CLT": "CLT", "HNOG": "HNOG", "WESZ": "WESZ", "AEST": "AEST", "AKDT": "AKDT", "CDT": "CDT", "PST": "PST", "IST": "IST", "MESZ": "MESZ", "HEOG": "HEOG", "EDT": "EDT", "ChST": "ChST", "SGT": "SGT", "AST": "AST"}, + } +} + +// Locale returns the current translators string locale +func (vai *vai_Latn) Locale() string { + return vai.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vai_Latn' +func (vai *vai_Latn) PluralsCardinal() []locales.PluralRule { + return vai.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vai_Latn' +func (vai *vai_Latn) PluralsOrdinal() []locales.PluralRule { + return vai.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vai_Latn' +func (vai *vai_Latn) PluralsRange() []locales.PluralRule { + return vai.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vai_Latn' +func (vai *vai_Latn) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vai_Latn' +func (vai *vai_Latn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vai_Latn' +func (vai *vai_Latn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vai *vai_Latn) MonthAbbreviated(month time.Month) string { + return vai.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vai *vai_Latn) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vai *vai_Latn) MonthNarrow(month time.Month) string { + return vai.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vai *vai_Latn) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vai *vai_Latn) MonthWide(month time.Month) string { + return vai.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vai *vai_Latn) MonthsWide() []string { + return vai.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vai *vai_Latn) WeekdayAbbreviated(weekday time.Weekday) string { + return vai.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vai *vai_Latn) WeekdaysAbbreviated() []string { + return vai.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vai *vai_Latn) WeekdayNarrow(weekday time.Weekday) string { + return vai.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vai *vai_Latn) WeekdaysNarrow() []string { + return vai.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vai *vai_Latn) WeekdayShort(weekday time.Weekday) string { + return vai.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vai *vai_Latn) WeekdaysShort() []string { + return vai.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vai *vai_Latn) WeekdayWide(weekday time.Weekday) string { + return vai.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vai *vai_Latn) WeekdaysWide() []string { + return vai.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vai_Latn' and handles both Whole and Real numbers based on 'v' +func (vai *vai_Latn) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vai_Latn' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vai *vai_Latn) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vai_Latn' +func (vai *vai_Latn) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vai_Latn' +// in accounting notation. +func (vai *vai_Latn) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, vai.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, vai.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vai_Latn' +func (vai *vai_Latn) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vai_Latn' +func (vai *vai_Latn) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vai_Latn' +func (vai *vai_Latn) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vai_Latn' +func (vai *vai_Latn) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vai.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vai_Latn' +func (vai *vai_Latn) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vai_Latn' +func (vai *vai_Latn) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vai_Latn' +func (vai *vai_Latn) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vai_Latn' +func (vai *vai_Latn) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vai.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vai_Latn/vai_Latn_test.go b/vendor/github.com/go-playground/locales/vai_Latn/vai_Latn_test.go new file mode 100644 index 0000000000..5feb87f2cc --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai_Latn/vai_Latn_test.go @@ -0,0 +1,1120 @@ +package vai_Latn + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vai_Latn" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vai_Latn_LR/vai_Latn_LR.go b/vendor/github.com/go-playground/locales/vai_Latn_LR/vai_Latn_LR.go new file mode 100644 index 0000000000..c4e69075d9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai_Latn_LR/vai_Latn_LR.go @@ -0,0 +1,584 @@ +package vai_Latn_LR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vai_Latn_LR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vai_Latn_LR' locale +func New() locales.Translator { + return &vai_Latn_LR{ + locale: "vai_Latn_LR", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsWide: []string{"", "ꖨꕪꖃ ꔞꕮ", "ꕒꕡꖝꖕ", "ꕾꖺ", "ꖢꖕ", "ꖑꕱ", "6", "7", "ꗛꔕ", "ꕢꕌ", "ꕭꖃ", "ꔞꘋꕔꕿ ꕸꖃꗏ", "ꖨꕪꕱ ꗏꕮ"}, + daysWide: []string{"ꕞꕌꔵ", "ꗳꗡꘉ", "ꕚꕞꕚ", "ꕉꕞꕒ", "ꕉꔤꕆꕢ", "ꕉꔤꕀꕮ", "ꔻꔬꔳ"}, + timezones: map[string]string{"MYT": "MYT", "WIT": "WIT", "HEOG": "HEOG", "HEPMX": "HEPMX", "WIB": "WIB", "HNOG": "HNOG", "AST": "AST", "ADT": "ADT", "OESZ": "OESZ", "SAST": "SAST", "CAT": "CAT", "NZDT": "NZDT", "WART": "WART", "EST": "EST", "ACST": "ACST", "SRT": "SRT", "JDT": "JDT", "WESZ": "WESZ", "GMT": "GMT", "COST": "COST", "BT": "BT", "AKST": "AKST", "HAST": "HAST", "NZST": "NZST", "ART": "ART", "ACDT": "ACDT", "HEPM": "HEPM", "HECU": "HECU", "AWDT": "AWDT", "CLT": "CLT", "OEZ": "OEZ", "AEDT": "AEDT", "MST": "MST", "HEEG": "HEEG", "GFT": "GFT", "WITA": "WITA", "CHAST": "CHAST", "WEZ": "WEZ", "TMT": "TMT", "TMST": "TMST", "HKST": "HKST", "COT": "COT", "LHST": "LHST", "HKT": "HKT", "HENOMX": "HENOMX", "AWST": "AWST", "MEZ": "MEZ", "WARST": "WARST", "CLST": "CLST", "ARST": "ARST", "WAST": "WAST", "HNEG": "HNEG", "HNPMX": "HNPMX", "PDT": "PDT", "HADT": "HADT", "EDT": "EDT", "AKDT": "AKDT", "WAT": "WAT", "AEST": "AEST", "EAT": "EAT", "HNCU": "HNCU", "∅∅∅": "∅∅∅", "IST": "IST", "VET": "VET", "JST": "JST", "UYT": "UYT", "UYST": "UYST", "LHDT": "LHDT", "HAT": "HAT", "ChST": "ChST", "CDT": "CDT", "ECT": "ECT", "ACWDT": "ACWDT", "MESZ": "MESZ", "MDT": "MDT", "HNT": "HNT", "CST": "CST", "CHADT": "CHADT", "BOT": "BOT", "ACWST": "ACWST", "SGT": "SGT", "PST": "PST", "HNPM": "HNPM", "HNNOMX": "HNNOMX", "GYT": "GYT"}, + } +} + +// Locale returns the current translators string locale +func (vai *vai_Latn_LR) Locale() string { + return vai.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vai_Latn_LR' +func (vai *vai_Latn_LR) PluralsCardinal() []locales.PluralRule { + return vai.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vai_Latn_LR' +func (vai *vai_Latn_LR) PluralsOrdinal() []locales.PluralRule { + return vai.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vai_Latn_LR' +func (vai *vai_Latn_LR) PluralsRange() []locales.PluralRule { + return vai.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vai *vai_Latn_LR) MonthAbbreviated(month time.Month) string { + return vai.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vai *vai_Latn_LR) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vai *vai_Latn_LR) MonthNarrow(month time.Month) string { + return vai.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vai *vai_Latn_LR) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vai *vai_Latn_LR) MonthWide(month time.Month) string { + return vai.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vai *vai_Latn_LR) MonthsWide() []string { + return vai.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vai *vai_Latn_LR) WeekdayAbbreviated(weekday time.Weekday) string { + return vai.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vai *vai_Latn_LR) WeekdaysAbbreviated() []string { + return vai.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vai *vai_Latn_LR) WeekdayNarrow(weekday time.Weekday) string { + return vai.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vai *vai_Latn_LR) WeekdaysNarrow() []string { + return vai.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vai *vai_Latn_LR) WeekdayShort(weekday time.Weekday) string { + return vai.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vai *vai_Latn_LR) WeekdaysShort() []string { + return vai.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vai *vai_Latn_LR) WeekdayWide(weekday time.Weekday) string { + return vai.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vai *vai_Latn_LR) WeekdaysWide() []string { + return vai.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vai_Latn_LR' and handles both Whole and Real numbers based on 'v' +func (vai *vai_Latn_LR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vai_Latn_LR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vai *vai_Latn_LR) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vai_Latn_LR' +// in accounting notation. +func (vai *vai_Latn_LR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, vai.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, vai.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vai.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vai_Latn_LR' +func (vai *vai_Latn_LR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vai.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vai_Latn_LR/vai_Latn_LR_test.go b/vendor/github.com/go-playground/locales/vai_Latn_LR/vai_Latn_LR_test.go new file mode 100644 index 0000000000..a7e9720bf8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai_Latn_LR/vai_Latn_LR_test.go @@ -0,0 +1,1120 @@ +package vai_Latn_LR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vai_Latn_LR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vai_Vaii/vai_Vaii.go b/vendor/github.com/go-playground/locales/vai_Vaii/vai_Vaii.go new file mode 100644 index 0000000000..e31d1e1f21 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai_Vaii/vai_Vaii.go @@ -0,0 +1,584 @@ +package vai_Vaii + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vai_Vaii struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vai_Vaii' locale +func New() locales.Translator { + return &vai_Vaii{ + locale: "vai_Vaii", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsWide: []string{"", "ꖨꕪꖃ ꔞꕮ", "ꕒꕡꖝꖕ", "ꕾꖺ", "ꖢꖕ", "ꖑꕱ", "6", "7", "ꗛꔕ", "ꕢꕌ", "ꕭꖃ", "ꔞꘋꕔꕿ ꕸꖃꗏ", "ꖨꕪꕱ ꗏꕮ"}, + daysWide: []string{"ꕞꕌꔵ", "ꗳꗡꘉ", "ꕚꕞꕚ", "ꕉꕞꕒ", "ꕉꔤꕆꕢ", "ꕉꔤꕀꕮ", "ꔻꔬꔳ"}, + timezones: map[string]string{"OESZ": "OESZ", "WART": "WART", "EDT": "EDT", "HKST": "HKST", "AKDT": "AKDT", "AEDT": "AEDT", "HEPMX": "HEPMX", "AWST": "AWST", "ACWDT": "ACWDT", "MESZ": "MESZ", "AST": "AST", "GMT": "GMT", "MDT": "MDT", "HNT": "HNT", "HNEG": "HNEG", "ChST": "ChST", "LHDT": "LHDT", "TMT": "TMT", "SRT": "SRT", "WIB": "WIB", "NZDT": "NZDT", "JDT": "JDT", "MST": "MST", "COST": "COST", "PDT": "PDT", "NZST": "NZST", "CLT": "CLT", "CLST": "CLST", "HNOG": "HNOG", "AWDT": "AWDT", "CHAST": "CHAST", "TMST": "TMST", "EST": "EST", "WITA": "WITA", "GYT": "GYT", "BOT": "BOT", "PST": "PST", "CAT": "CAT", "MEZ": "MEZ", "VET": "VET", "HAT": "HAT", "HNPM": "HNPM", "HNCU": "HNCU", "HAST": "HAST", "HEOG": "HEOG", "WAST": "WAST", "HNPMX": "HNPMX", "HADT": "HADT", "ECT": "ECT", "OEZ": "OEZ", "ARST": "ARST", "UYST": "UYST", "CHADT": "CHADT", "WARST": "WARST", "WAT": "WAT", "ACDT": "ACDT", "CDT": "CDT", "WIT": "WIT", "IST": "IST", "JST": "JST", "WEZ": "WEZ", "COT": "COT", "BT": "BT", "SAST": "SAST", "MYT": "MYT", "ACST": "ACST", "HEEG": "HEEG", "CST": "CST", "HKT": "HKT", "HENOMX": "HENOMX", "UYT": "UYT", "AEST": "AEST", "ACWST": "ACWST", "WESZ": "WESZ", "HNNOMX": "HNNOMX", "GFT": "GFT", "LHST": "LHST", "EAT": "EAT", "HECU": "HECU", "∅∅∅": "∅∅∅", "ADT": "ADT", "ART": "ART", "AKST": "AKST", "HEPM": "HEPM", "SGT": "SGT"}, + } +} + +// Locale returns the current translators string locale +func (vai *vai_Vaii) Locale() string { + return vai.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vai_Vaii' +func (vai *vai_Vaii) PluralsCardinal() []locales.PluralRule { + return vai.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vai_Vaii' +func (vai *vai_Vaii) PluralsOrdinal() []locales.PluralRule { + return vai.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vai_Vaii' +func (vai *vai_Vaii) PluralsRange() []locales.PluralRule { + return vai.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vai_Vaii' +func (vai *vai_Vaii) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vai_Vaii' +func (vai *vai_Vaii) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vai_Vaii' +func (vai *vai_Vaii) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vai *vai_Vaii) MonthAbbreviated(month time.Month) string { + return vai.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vai *vai_Vaii) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vai *vai_Vaii) MonthNarrow(month time.Month) string { + return vai.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vai *vai_Vaii) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vai *vai_Vaii) MonthWide(month time.Month) string { + return vai.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vai *vai_Vaii) MonthsWide() []string { + return vai.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vai *vai_Vaii) WeekdayAbbreviated(weekday time.Weekday) string { + return vai.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vai *vai_Vaii) WeekdaysAbbreviated() []string { + return vai.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vai *vai_Vaii) WeekdayNarrow(weekday time.Weekday) string { + return vai.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vai *vai_Vaii) WeekdaysNarrow() []string { + return vai.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vai *vai_Vaii) WeekdayShort(weekday time.Weekday) string { + return vai.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vai *vai_Vaii) WeekdaysShort() []string { + return vai.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vai *vai_Vaii) WeekdayWide(weekday time.Weekday) string { + return vai.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vai *vai_Vaii) WeekdaysWide() []string { + return vai.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vai_Vaii' and handles both Whole and Real numbers based on 'v' +func (vai *vai_Vaii) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vai_Vaii' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vai *vai_Vaii) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vai_Vaii' +func (vai *vai_Vaii) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vai_Vaii' +// in accounting notation. +func (vai *vai_Vaii) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, vai.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, vai.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vai_Vaii' +func (vai *vai_Vaii) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vai_Vaii' +func (vai *vai_Vaii) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vai_Vaii' +func (vai *vai_Vaii) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vai_Vaii' +func (vai *vai_Vaii) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vai.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vai_Vaii' +func (vai *vai_Vaii) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vai_Vaii' +func (vai *vai_Vaii) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vai_Vaii' +func (vai *vai_Vaii) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vai_Vaii' +func (vai *vai_Vaii) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vai.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vai_Vaii/vai_Vaii_test.go b/vendor/github.com/go-playground/locales/vai_Vaii/vai_Vaii_test.go new file mode 100644 index 0000000000..53054e77ef --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai_Vaii/vai_Vaii_test.go @@ -0,0 +1,1120 @@ +package vai_Vaii + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vai_Vaii" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vai_Vaii_LR/vai_Vaii_LR.go b/vendor/github.com/go-playground/locales/vai_Vaii_LR/vai_Vaii_LR.go new file mode 100644 index 0000000000..d3fb0227b1 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai_Vaii_LR/vai_Vaii_LR.go @@ -0,0 +1,584 @@ +package vai_Vaii_LR + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vai_Vaii_LR struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vai_Vaii_LR' locale +func New() locales.Translator { + return &vai_Vaii_LR{ + locale: "vai_Vaii_LR", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsWide: []string{"", "ꖨꕪꖃ ꔞꕮ", "ꕒꕡꖝꖕ", "ꕾꖺ", "ꖢꖕ", "ꖑꕱ", "6", "7", "ꗛꔕ", "ꕢꕌ", "ꕭꖃ", "ꔞꘋꕔꕿ ꕸꖃꗏ", "ꖨꕪꕱ ꗏꕮ"}, + daysWide: []string{"ꕞꕌꔵ", "ꗳꗡꘉ", "ꕚꕞꕚ", "ꕉꕞꕒ", "ꕉꔤꕆꕢ", "ꕉꔤꕀꕮ", "ꔻꔬꔳ"}, + timezones: map[string]string{"VET": "VET", "MST": "MST", "HENOMX": "HENOMX", "AKDT": "AKDT", "WAT": "WAT", "HKST": "HKST", "AEST": "AEST", "UYT": "UYT", "HAT": "HAT", "LHDT": "LHDT", "WIB": "WIB", "WIT": "WIT", "GMT": "GMT", "HEOG": "HEOG", "AST": "AST", "COST": "COST", "HEPMX": "HEPMX", "NZDT": "NZDT", "HNPM": "HNPM", "ECT": "ECT", "PST": "PST", "OESZ": "OESZ", "HKT": "HKT", "AWDT": "AWDT", "WART": "WART", "UYST": "UYST", "GYT": "GYT", "ACWST": "ACWST", "MESZ": "MESZ", "CLT": "CLT", "TMT": "TMT", "HEEG": "HEEG", "SRT": "SRT", "HNCU": "HNCU", "CST": "CST", "AWST": "AWST", "SGT": "SGT", "HNOG": "HNOG", "WAST": "WAST", "HADT": "HADT", "CAT": "CAT", "ARST": "ARST", "HNNOMX": "HNNOMX", "HNEG": "HNEG", "SAST": "SAST", "HNPMX": "HNPMX", "CHAST": "CHAST", "ADT": "ADT", "EDT": "EDT", "ACDT": "ACDT", "AKST": "AKST", "LHST": "LHST", "HECU": "HECU", "ACWDT": "ACWDT", "MEZ": "MEZ", "WARST": "WARST", "CLST": "CLST", "WESZ": "WESZ", "EST": "EST", "GFT": "GFT", "BT": "BT", "EAT": "EAT", "HAST": "HAST", "NZST": "NZST", "MYT": "MYT", "OEZ": "OEZ", "TMST": "TMST", "ART": "ART", "COT": "COT", "∅∅∅": "∅∅∅", "CHADT": "CHADT", "BOT": "BOT", "JDT": "JDT", "WEZ": "WEZ", "MDT": "MDT", "WITA": "WITA", "ChST": "ChST", "HEPM": "HEPM", "PDT": "PDT", "JST": "JST", "ACST": "ACST", "AEDT": "AEDT", "CDT": "CDT", "IST": "IST", "HNT": "HNT"}, + } +} + +// Locale returns the current translators string locale +func (vai *vai_Vaii_LR) Locale() string { + return vai.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) PluralsCardinal() []locales.PluralRule { + return vai.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) PluralsOrdinal() []locales.PluralRule { + return vai.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) PluralsRange() []locales.PluralRule { + return vai.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vai *vai_Vaii_LR) MonthAbbreviated(month time.Month) string { + return vai.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vai *vai_Vaii_LR) MonthsAbbreviated() []string { + return nil +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vai *vai_Vaii_LR) MonthNarrow(month time.Month) string { + return vai.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vai *vai_Vaii_LR) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vai *vai_Vaii_LR) MonthWide(month time.Month) string { + return vai.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vai *vai_Vaii_LR) MonthsWide() []string { + return vai.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vai *vai_Vaii_LR) WeekdayAbbreviated(weekday time.Weekday) string { + return vai.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vai *vai_Vaii_LR) WeekdaysAbbreviated() []string { + return vai.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vai *vai_Vaii_LR) WeekdayNarrow(weekday time.Weekday) string { + return vai.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vai *vai_Vaii_LR) WeekdaysNarrow() []string { + return vai.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vai *vai_Vaii_LR) WeekdayShort(weekday time.Weekday) string { + return vai.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vai *vai_Vaii_LR) WeekdaysShort() []string { + return vai.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vai *vai_Vaii_LR) WeekdayWide(weekday time.Weekday) string { + return vai.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vai *vai_Vaii_LR) WeekdaysWide() []string { + return vai.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vai_Vaii_LR' and handles both Whole and Real numbers based on 'v' +func (vai *vai_Vaii_LR) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vai_Vaii_LR' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vai *vai_Vaii_LR) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, vai.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vai_Vaii_LR' +// in accounting notation. +func (vai *vai_Vaii_LR) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vai.currencies[currency] + l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vai.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vai.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, vai.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vai.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, vai.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vai.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vai.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vai_Vaii_LR' +func (vai *vai_Vaii_LR) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, vai.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vai.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, vai.periodsAbbreviated[0]...) + } else { + b = append(b, vai.periodsAbbreviated[1]...) + } + + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vai.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vai_Vaii_LR/vai_Vaii_LR_test.go b/vendor/github.com/go-playground/locales/vai_Vaii_LR/vai_Vaii_LR_test.go new file mode 100644 index 0000000000..a5b1258bdb --- /dev/null +++ b/vendor/github.com/go-playground/locales/vai_Vaii_LR/vai_Vaii_LR_test.go @@ -0,0 +1,1120 @@ +package vai_Vaii_LR + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vai_Vaii_LR" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vi/vi.go b/vendor/github.com/go-playground/locales/vi/vi.go new file mode 100644 index 0000000000..1c28ffc02b --- /dev/null +++ b/vendor/github.com/go-playground/locales/vi/vi.go @@ -0,0 +1,588 @@ +package vi + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vi struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vi' locale +func New() locales.Translator { + return &vi{ + locale: "vi", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "thg 1", "thg 2", "thg 3", "thg 4", "thg 5", "thg 6", "thg 7", "thg 8", "thg 9", "thg 10", "thg 11", "thg 12"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "tháng 1", "tháng 2", "tháng 3", "tháng 4", "tháng 5", "tháng 6", "tháng 7", "tháng 8", "tháng 9", "tháng 10", "tháng 11", "tháng 12"}, + daysAbbreviated: []string{"CN", "Th 2", "Th 3", "Th 4", "Th 5", "Th 6", "Th 7"}, + daysNarrow: []string{"CN", "T2", "T3", "T4", "T5", "T6", "T7"}, + daysShort: []string{"CN", "T2", "T3", "T4", "T5", "T6", "T7"}, + daysWide: []string{"Chủ Nhật", "Thứ Hai", "Thứ Ba", "Thứ Tư", "Thứ Năm", "Thứ Sáu", "Thứ Bảy"}, + periodsAbbreviated: []string{"SA", "CH"}, + periodsNarrow: []string{"s", "c"}, + periodsWide: []string{"SA", "CH"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"tr. CN", "sau CN"}, + erasWide: []string{"", ""}, + timezones: map[string]string{"EST": "Giờ chuẩn miền đông", "ACST": "Giờ Chuẩn Miền Trung Nước Úc", "AWDT": "Giờ Mùa Hè Miền Tây Nước Úc", "AEDT": "Giờ Mùa Hè Miền Đông Nước Úc", "SAST": "Giờ Chuẩn Nam Phi", "GYT": "Giờ Guyana", "UYST": "Giờ Mùa Hè Uruguay", "WIT": "Giờ Miền Đông Indonesia", "BOT": "Giờ Bolivia", "CHAST": "Giờ Chuẩn Chatham", "HAST": "Giờ Chuẩn Hawaii-Aleutian", "HNNOMX": "Giờ Chuẩn Tây Bắc Mexico", "ACDT": "Giờ Mùa Hè Miền Trung Nước Úc", "WITA": "Giờ Miền Trung Indonesia", "OEZ": "Giờ Chuẩn Đông Âu", "PDT": "Giờ Mùa hè Thái Bình Dương", "JST": "Giờ Chuẩn Nhật Bản", "CLT": "Giờ Chuẩn Chile", "MEZ": "Giờ Chuẩn Trung Âu", "WESZ": "Giờ Mùa hè Tây Âu", "HKT": "Giờ Chuẩn Hồng Kông", "HNPM": "Giờ Chuẩn St. Pierre và Miquelon", "IST": "Giờ Chuẩn Ấn Độ", "AKST": "Giờ Chuẩn Alaska", "AST": "Giờ Chuẩn Đại Tây Dương", "TMT": "Giờ Chuẩn Turkmenistan", "BT": "Giờ Bhutan", "GFT": "Giờ Guiana thuộc Pháp", "LHDT": "Giờ Mùa Hè Lord Howe", "HNCU": "Giờ Chuẩn Cuba", "SGT": "Giờ Singapore", "ART": "Giờ Chuẩn Argentina", "WAT": "Giờ Chuẩn Tây Phi", "∅∅∅": "Giờ Mùa Hè Acre", "HADT": "Giờ Mùa Hè Hawaii-Aleutian", "CAT": "Giờ Trung Phi", "MESZ": "Giờ Mùa Hè Trung Âu", "ADT": "Giờ Mùa hè Đại Tây Dương", "HKST": "Giờ Mùa Hè Hồng Kông", "CHADT": "Giờ Mùa Hè Chatham", "WART": "Giờ chuẩn miền mây Argentina", "CST": "Giờ chuẩn miền trung", "NZST": "Giờ Chuẩn New Zealand", "TMST": "Giờ Mùa Hè Turkmenistan", "MDT": "Giờ Mùa Hè Ma Cao", "HEEG": "Giờ Mùa Hè Miền Đông Greenland", "HNT": "Giờ Chuẩn Newfoundland", "HECU": "Giờ Mùa Hè Cuba", "AWST": "Giờ Chuẩn Miền Tây Nước Úc", "PST": "Giờ chuẩn Thái Bình Dương", "HNOG": "Giờ Chuẩn Miền Tây Greenland", "ARST": "Giờ Mùa Hè Argentina", "COT": "Giờ Chuẩn Colombia", "AKDT": "Giờ Mùa Hè Alaska", "ACWST": "Giờ Chuẩn Miền Trung Tây Nước Úc", "WAST": "Giờ Mùa Hè Tây Phi", "AEST": "Giờ Chuẩn Miền Đông Nước Úc", "ECT": "Giờ Ecuador", "COST": "Giờ Mùa Hè Colombia", "HEPM": "Giờ Mùa Hè Saint Pierre và Miquelon", "OESZ": "Giờ Mùa Hè Đông Âu", "HEOG": "Giờ Mùa Hè Miền Tây Greenland", "MST": "Giờ Chuẩn Ma Cao", "HAT": "Giờ Mùa Hè Newfoundland", "WARST": "Giờ mùa hè miền tây Argentina", "HEPMX": "Giờ Mùa Hè Thái Bình Dương Mexico", "SRT": "Giờ Suriname", "MYT": "Giờ Malaysia", "CLST": "Giờ Mùa Hè Chile", "LHST": "Giờ Chuẩn Lord Howe", "VET": "Giờ Venezuela", "GMT": "Giờ Trung bình Greenwich", "HNPMX": "Giờ Chuẩn Thái Bình Dương Mexico", "EAT": "Giờ Đông Phi", "CDT": "Giờ mùa hè miền trung", "JDT": "Giờ Mùa Hè Nhật Bản", "WEZ": "Giờ Chuẩn Tây Âu", "EDT": "Giờ mùa hè miền đông", "HNEG": "Giờ Chuẩn Miền Đông Greenland", "ChST": "Giờ Chamorro", "ACWDT": "Giờ Mùa Hè Miền Trung Tây Nước Úc", "NZDT": "Giờ Mùa Hè New Zealand", "HENOMX": "Giờ Mùa Hè Tây Bắc Mexico", "UYT": "Giờ Chuẩn Uruguay", "WIB": "Giờ Miền Tây Indonesia"}, + } +} + +// Locale returns the current translators string locale +func (vi *vi) Locale() string { + return vi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vi' +func (vi *vi) PluralsCardinal() []locales.PluralRule { + return vi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vi' +func (vi *vi) PluralsOrdinal() []locales.PluralRule { + return vi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vi' +func (vi *vi) PluralsRange() []locales.PluralRule { + return vi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vi' +func (vi *vi) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vi' +func (vi *vi) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vi' +func (vi *vi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vi *vi) MonthAbbreviated(month time.Month) string { + return vi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vi *vi) MonthsAbbreviated() []string { + return vi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vi *vi) MonthNarrow(month time.Month) string { + return vi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vi *vi) MonthsNarrow() []string { + return vi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vi *vi) MonthWide(month time.Month) string { + return vi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vi *vi) MonthsWide() []string { + return vi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vi *vi) WeekdayAbbreviated(weekday time.Weekday) string { + return vi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vi *vi) WeekdaysAbbreviated() []string { + return vi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vi *vi) WeekdayNarrow(weekday time.Weekday) string { + return vi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vi *vi) WeekdaysNarrow() []string { + return vi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vi *vi) WeekdayShort(weekday time.Weekday) string { + return vi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vi *vi) WeekdaysShort() []string { + return vi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vi *vi) WeekdayWide(weekday time.Weekday) string { + return vi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vi *vi) WeekdaysWide() []string { + return vi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vi' and handles both Whole and Real numbers based on 'v' +func (vi *vi) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vi.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vi' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vi *vi) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, vi.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vi' +func (vi *vi) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vi.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vi.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, vi.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vi' +// in accounting notation. +func (vi *vi) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vi.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vi.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, vi.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, vi.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, vi.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vi' +func (vi *vi) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vi' +func (vi *vi) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vi' +func (vi *vi) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vi.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vi' +func (vi *vi) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vi.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vi' +func (vi *vi) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vi' +func (vi *vi) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vi' +func (vi *vi) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vi' +func (vi *vi) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vi.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vi/vi_test.go b/vendor/github.com/go-playground/locales/vi/vi_test.go new file mode 100644 index 0000000000..b4e5deae85 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vi/vi_test.go @@ -0,0 +1,1120 @@ +package vi + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vi" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vi_VN/vi_VN.go b/vendor/github.com/go-playground/locales/vi_VN/vi_VN.go new file mode 100644 index 0000000000..4d4603764a --- /dev/null +++ b/vendor/github.com/go-playground/locales/vi_VN/vi_VN.go @@ -0,0 +1,588 @@ +package vi_VN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vi_VN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vi_VN' locale +func New() locales.Translator { + return &vi_VN{ + locale: "vi_VN", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{2, 6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ",", + group: ".", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "thg 1", "thg 2", "thg 3", "thg 4", "thg 5", "thg 6", "thg 7", "thg 8", "thg 9", "thg 10", "thg 11", "thg 12"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "tháng 1", "tháng 2", "tháng 3", "tháng 4", "tháng 5", "tháng 6", "tháng 7", "tháng 8", "tháng 9", "tháng 10", "tháng 11", "tháng 12"}, + daysAbbreviated: []string{"CN", "Th 2", "Th 3", "Th 4", "Th 5", "Th 6", "Th 7"}, + daysNarrow: []string{"CN", "T2", "T3", "T4", "T5", "T6", "T7"}, + daysShort: []string{"CN", "T2", "T3", "T4", "T5", "T6", "T7"}, + daysWide: []string{"Chủ Nhật", "Thứ Hai", "Thứ Ba", "Thứ Tư", "Thứ Năm", "Thứ Sáu", "Thứ Bảy"}, + periodsAbbreviated: []string{"SA", "CH"}, + periodsNarrow: []string{"s", "c"}, + periodsWide: []string{"SA", "CH"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"tr. CN", "sau CN"}, + erasWide: []string{"", ""}, + timezones: map[string]string{"JDT": "Giờ Mùa Hè Nhật Bản", "AST": "Giờ Chuẩn Đại Tây Dương", "OESZ": "Giờ Mùa Hè Đông Âu", "TMST": "Giờ Mùa Hè Turkmenistan", "HNNOMX": "Giờ Chuẩn Tây Bắc Mexico", "GYT": "Giờ Guyana", "OEZ": "Giờ Chuẩn Đông Âu", "CHAST": "Giờ Chuẩn Chatham", "PST": "Giờ chuẩn Thái Bình Dương", "CLST": "Giờ Mùa Hè Chile", "COST": "Giờ Mùa Hè Colombia", "HNT": "Giờ Chuẩn Newfoundland", "GFT": "Giờ Guiana thuộc Pháp", "LHST": "Giờ Chuẩn Lord Howe", "ACDT": "Giờ Mùa Hè Miền Trung Nước Úc", "BT": "Giờ Bhutan", "HNCU": "Giờ Chuẩn Cuba", "CHADT": "Giờ Mùa Hè Chatham", "VET": "Giờ Venezuela", "WAT": "Giờ Chuẩn Tây Phi", "HNEG": "Giờ Chuẩn Miền Đông Greenland", "HECU": "Giờ Mùa Hè Cuba", "HAST": "Giờ Chuẩn Hawaii-Aleutian", "CLT": "Giờ Chuẩn Chile", "WAST": "Giờ Mùa Hè Tây Phi", "HKT": "Giờ Chuẩn Hồng Kông", "AEDT": "Giờ Mùa Hè Miền Đông Nước Úc", "WITA": "Giờ Miền Trung Indonesia", "AKST": "Giờ Chuẩn Alaska", "WIB": "Giờ Miền Tây Indonesia", "BOT": "Giờ Bolivia", "NZST": "Giờ Chuẩn New Zealand", "MYT": "Giờ Malaysia", "MST": "Giờ Chuẩn Ma Cao", "HEPM": "Giờ Mùa Hè Saint Pierre và Miquelon", "ACWST": "Giờ Chuẩn Miền Trung Tây Nước Úc", "MEZ": "Giờ Chuẩn Trung Âu", "HEOG": "Giờ Mùa Hè Miền Tây Greenland", "MDT": "Giờ Mùa Hè Ma Cao", "SRT": "Giờ Suriname", "WARST": "Giờ mùa hè miền tây Argentina", "HNOG": "Giờ Chuẩn Miền Tây Greenland", "ART": "Giờ Chuẩn Argentina", "LHDT": "Giờ Mùa Hè Lord Howe", "NZDT": "Giờ Mùa Hè New Zealand", "GMT": "Giờ Trung bình Greenwich", "ADT": "Giờ Mùa hè Đại Tây Dương", "EST": "Giờ chuẩn miền đông", "ACST": "Giờ Chuẩn Miền Trung Nước Úc", "IST": "Giờ Chuẩn Ấn Độ", "ARST": "Giờ Mùa Hè Argentina", "HEEG": "Giờ Mùa Hè Miền Đông Greenland", "UYT": "Giờ Chuẩn Uruguay", "AWST": "Giờ Chuẩn Miền Tây Nước Úc", "AWDT": "Giờ Mùa Hè Miền Tây Nước Úc", "WART": "Giờ chuẩn miền mây Argentina", "HKST": "Giờ Mùa Hè Hồng Kông", "HENOMX": "Giờ Mùa Hè Tây Bắc Mexico", "HNPMX": "Giờ Chuẩn Thái Bình Dương Mexico", "WESZ": "Giờ Mùa hè Tây Âu", "TMT": "Giờ Chuẩn Turkmenistan", "∅∅∅": "Giờ Mùa Hè Acre", "UYST": "Giờ Mùa Hè Uruguay", "PDT": "Giờ Mùa hè Thái Bình Dương", "JST": "Giờ Chuẩn Nhật Bản", "ChST": "Giờ Chamorro", "SAST": "Giờ Chuẩn Nam Phi", "HEPMX": "Giờ Mùa Hè Thái Bình Dương Mexico", "ECT": "Giờ Ecuador", "CAT": "Giờ Trung Phi", "ACWDT": "Giờ Mùa Hè Miền Trung Tây Nước Úc", "WEZ": "Giờ Chuẩn Tây Âu", "COT": "Giờ Chuẩn Colombia", "HNPM": "Giờ Chuẩn St. Pierre và Miquelon", "CST": "Giờ chuẩn miền trung", "CDT": "Giờ mùa hè miền trung", "WIT": "Giờ Miền Đông Indonesia", "MESZ": "Giờ Mùa Hè Trung Âu", "EDT": "Giờ mùa hè miền đông", "HAT": "Giờ Mùa Hè Newfoundland", "AEST": "Giờ Chuẩn Miền Đông Nước Úc", "AKDT": "Giờ Mùa Hè Alaska", "EAT": "Giờ Đông Phi", "SGT": "Giờ Singapore", "HADT": "Giờ Mùa Hè Hawaii-Aleutian"}, + } +} + +// Locale returns the current translators string locale +func (vi *vi_VN) Locale() string { + return vi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vi_VN' +func (vi *vi_VN) PluralsCardinal() []locales.PluralRule { + return vi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vi_VN' +func (vi *vi_VN) PluralsOrdinal() []locales.PluralRule { + return vi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vi_VN' +func (vi *vi_VN) PluralsRange() []locales.PluralRule { + return vi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vi_VN' +func (vi *vi_VN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vi_VN' +func (vi *vi_VN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vi_VN' +func (vi *vi_VN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vi *vi_VN) MonthAbbreviated(month time.Month) string { + return vi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vi *vi_VN) MonthsAbbreviated() []string { + return vi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vi *vi_VN) MonthNarrow(month time.Month) string { + return vi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vi *vi_VN) MonthsNarrow() []string { + return vi.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vi *vi_VN) MonthWide(month time.Month) string { + return vi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vi *vi_VN) MonthsWide() []string { + return vi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vi *vi_VN) WeekdayAbbreviated(weekday time.Weekday) string { + return vi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vi *vi_VN) WeekdaysAbbreviated() []string { + return vi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vi *vi_VN) WeekdayNarrow(weekday time.Weekday) string { + return vi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vi *vi_VN) WeekdaysNarrow() []string { + return vi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vi *vi_VN) WeekdayShort(weekday time.Weekday) string { + return vi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vi *vi_VN) WeekdaysShort() []string { + return vi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vi *vi_VN) WeekdayWide(weekday time.Weekday) string { + return vi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vi *vi_VN) WeekdaysWide() []string { + return vi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vi_VN' and handles both Whole and Real numbers based on 'v' +func (vi *vi_VN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vi.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vi_VN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vi *vi_VN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, vi.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vi_VN' +func (vi *vi_VN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vi.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vi.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, vi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, vi.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vi_VN' +// in accounting notation. +func (vi *vi_VN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vi.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vi.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vi.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, vi.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vi.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, vi.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, vi.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vi_VN' +func (vi *vi_VN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vi_VN' +func (vi *vi_VN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vi_VN' +func (vi *vi_VN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vi.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vi_VN' +func (vi *vi_VN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vi.monthsWide[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vi_VN' +func (vi *vi_VN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vi_VN' +func (vi *vi_VN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vi_VN' +func (vi *vi_VN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vi_VN' +func (vi *vi_VN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vi.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vi_VN/vi_VN_test.go b/vendor/github.com/go-playground/locales/vi_VN/vi_VN_test.go new file mode 100644 index 0000000000..8840e405fe --- /dev/null +++ b/vendor/github.com/go-playground/locales/vi_VN/vi_VN_test.go @@ -0,0 +1,1120 @@ +package vi_VN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vi_VN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vo/vo.go b/vendor/github.com/go-playground/locales/vo/vo.go new file mode 100644 index 0000000000..0557e7f294 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vo/vo.go @@ -0,0 +1,411 @@ +package vo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vo' locale +func New() locales.Translator { + return &vo{ + locale: "vo", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "yan", "feb", "mäz", "prl", "may", "yun", "yul", "gst", "set", "ton", "nov", "dek"}, + monthsNarrow: []string{"", "Y", "F", "M", "P", "M", "Y", "Y", "G", "S", "T", "N", "D"}, + monthsWide: []string{"", "yanul", "febul", "mäzul", "prilul", "mayul", "yunul", "yulul", "gustul", "setul", "tobul", "novul", "dekul"}, + daysAbbreviated: []string{"su.", "mu.", "tu.", "ve.", "dö.", "fr.", "zä."}, + daysNarrow: []string{"S", "M", "T", "V", "D", "F", "Z"}, + daysWide: []string{"sudel", "mudel", "tudel", "vedel", "dödel", "fridel", "zädel"}, + erasAbbreviated: []string{"b. t. kr.", "p. t. kr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"b. t. kr.", "p. t. kr."}, + timezones: map[string]string{"SGT": "SGT", "CAT": "CAT", "HNNOMX": "HNNOMX", "GYT": "GYT", "WIB": "WIB", "AWST": "AWST", "AEST": "AEST", "AKDT": "AKDT", "ECT": "ECT", "ACWDT": "ACWDT", "HADT": "HADT", "MEZ": "MEZ", "MYT": "MYT", "CLT": "CLT", "HENOMX": "HENOMX", "AKST": "AKST", "ChST": "ChST", "HEPMX": "HEPMX", "HKST": "HKST", "MST": "MST", "LHDT": "LHDT", "BOT": "BOT", "JDT": "JDT", "LHST": "LHST", "HECU": "HECU", "HAST": "HAST", "WESZ": "WESZ", "IST": "IST", "WART": "WART", "HNOG": "HNOG", "ADT": "ADT", "NZDT": "NZDT", "OESZ": "OESZ", "WAST": "WAST", "HAT": "HAT", "CDT": "CDT", "AWDT": "AWDT", "PDT": "PDT", "TMST": "TMST", "ACST": "ACST", "HNEG": "HNEG", "AST": "AST", "TMT": "TMT", "SAST": "SAST", "ARST": "ARST", "EDT": "EDT", "ACDT": "ACDT", "COST": "COST", "HEPM": "HEPM", "SRT": "SRT", "HEOG": "HEOG", "COT": "COT", "WITA": "WITA", "CHADT": "CHADT", "GMT": "GMT", "HEEG": "HEEG", "UYT": "UYT", "UYST": "UYST", "WAT": "WAT", "PST": "PST", "JST": "JST", "WEZ": "WEZ", "∅∅∅": "∅∅∅", "BT": "BT", "MDT": "MDT", "GFT": "GFT", "WARST": "WARST", "HNPMX": "HNPMX", "CST": "CST", "WIT": "WIT", "NZST": "NZST", "CLST": "CLST", "OEZ": "OEZ", "AEDT": "AEDT", "HNPM": "HNPM", "EAT": "EAT", "CHAST": "CHAST", "ACWST": "ACWST", "MESZ": "MESZ", "VET": "VET", "EST": "EST", "HNT": "HNT", "HNCU": "HNCU", "ART": "ART", "HKT": "HKT"}, + } +} + +// Locale returns the current translators string locale +func (vo *vo) Locale() string { + return vo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vo' +func (vo *vo) PluralsCardinal() []locales.PluralRule { + return vo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vo' +func (vo *vo) PluralsOrdinal() []locales.PluralRule { + return vo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vo' +func (vo *vo) PluralsRange() []locales.PluralRule { + return vo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vo' +func (vo *vo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vo' +func (vo *vo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vo' +func (vo *vo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vo *vo) MonthAbbreviated(month time.Month) string { + return vo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vo *vo) MonthsAbbreviated() []string { + return vo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vo *vo) MonthNarrow(month time.Month) string { + return vo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vo *vo) MonthsNarrow() []string { + return vo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vo *vo) MonthWide(month time.Month) string { + return vo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vo *vo) MonthsWide() []string { + return vo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vo *vo) WeekdayAbbreviated(weekday time.Weekday) string { + return vo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vo *vo) WeekdaysAbbreviated() []string { + return vo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vo *vo) WeekdayNarrow(weekday time.Weekday) string { + return vo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vo *vo) WeekdaysNarrow() []string { + return vo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vo *vo) WeekdayShort(weekday time.Weekday) string { + return vo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vo *vo) WeekdaysShort() []string { + return vo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vo *vo) WeekdayWide(weekday time.Weekday) string { + return vo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vo *vo) WeekdaysWide() []string { + return vo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vo' and handles both Whole and Real numbers based on 'v' +func (vo *vo) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vo *vo) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vo' +func (vo *vo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vo.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vo' +// in accounting notation. +func (vo *vo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vo.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtDateShort returns the short date representation of 't' for 'vo' +func (vo *vo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vo' +func (vo *vo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, vo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vo' +func (vo *vo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, vo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vo' +func (vo *vo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, vo.monthsWide[t.Month()]...) + b = append(b, []byte{0x61}...) + b = append(b, []byte{0x20, 0x64}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x69, 0x64}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vo' +func (vo *vo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vo' +func (vo *vo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vo' +func (vo *vo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vo' +func (vo *vo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vo/vo_test.go b/vendor/github.com/go-playground/locales/vo/vo_test.go new file mode 100644 index 0000000000..274d5c08ff --- /dev/null +++ b/vendor/github.com/go-playground/locales/vo/vo_test.go @@ -0,0 +1,1120 @@ +package vo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vo_001/vo_001.go b/vendor/github.com/go-playground/locales/vo_001/vo_001.go new file mode 100644 index 0000000000..015cd21a02 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vo_001/vo_001.go @@ -0,0 +1,411 @@ +package vo_001 + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vo_001 struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vo_001' locale +func New() locales.Translator { + return &vo_001{ + locale: "vo_001", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "yan", "feb", "mäz", "prl", "may", "yun", "yul", "gst", "set", "ton", "nov", "dek"}, + monthsNarrow: []string{"", "Y", "F", "M", "P", "M", "Y", "Y", "G", "S", "T", "N", "D"}, + monthsWide: []string{"", "yanul", "febul", "mäzul", "prilul", "mayul", "yunul", "yulul", "gustul", "setul", "tobul", "novul", "dekul"}, + daysAbbreviated: []string{"su.", "mu.", "tu.", "ve.", "dö.", "fr.", "zä."}, + daysNarrow: []string{"S", "M", "T", "V", "D", "F", "Z"}, + daysWide: []string{"sudel", "mudel", "tudel", "vedel", "dödel", "fridel", "zädel"}, + erasAbbreviated: []string{"b. t. kr.", "p. t. kr."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"b. t. kr.", "p. t. kr."}, + timezones: map[string]string{"CST": "CST", "OEZ": "OEZ", "ART": "ART", "HNPM": "HNPM", "IST": "IST", "MST": "MST", "MDT": "MDT", "VET": "VET", "HKST": "HKST", "ACST": "ACST", "HNEG": "HNEG", "AWST": "AWST", "WARST": "WARST", "CLT": "CLT", "HEOG": "HEOG", "BT": "BT", "HEEG": "HEEG", "GYT": "GYT", "CHAST": "CHAST", "BOT": "BOT", "MEZ": "MEZ", "OESZ": "OESZ", "WESZ": "WESZ", "HECU": "HECU", "∅∅∅": "∅∅∅", "HADT": "HADT", "CAT": "CAT", "NZST": "NZST", "GMT": "GMT", "MYT": "MYT", "COST": "COST", "HENOMX": "HENOMX", "AEST": "AEST", "LHST": "LHST", "WIT": "WIT", "SGT": "SGT", "ACWST": "ACWST", "MESZ": "MESZ", "ChST": "ChST", "UYT": "UYT", "AWDT": "AWDT", "HAT": "HAT", "TMT": "TMT", "WAST": "WAST", "AKST": "AKST", "NZDT": "NZDT", "WEZ": "WEZ", "EDT": "EDT", "AKDT": "AKDT", "SRT": "SRT", "WART": "WART", "HNOG": "HNOG", "EST": "EST", "ACDT": "ACDT", "SAST": "SAST", "LHDT": "LHDT", "HNCU": "HNCU", "CHADT": "CHADT", "PST": "PST", "JDT": "JDT", "AST": "AST", "ARST": "ARST", "WAT": "WAT", "COT": "COT", "WIB": "WIB", "HAST": "HAST", "ACWDT": "ACWDT", "JST": "JST", "HKT": "HKT", "HNNOMX": "HNNOMX", "AEDT": "AEDT", "UYST": "UYST", "HEPM": "HEPM", "CDT": "CDT", "ECT": "ECT", "ADT": "ADT", "TMST": "TMST", "HNT": "HNT", "EAT": "EAT", "PDT": "PDT", "CLST": "CLST", "GFT": "GFT", "WITA": "WITA", "HNPMX": "HNPMX", "HEPMX": "HEPMX"}, + } +} + +// Locale returns the current translators string locale +func (vo *vo_001) Locale() string { + return vo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vo_001' +func (vo *vo_001) PluralsCardinal() []locales.PluralRule { + return vo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vo_001' +func (vo *vo_001) PluralsOrdinal() []locales.PluralRule { + return vo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vo_001' +func (vo *vo_001) PluralsRange() []locales.PluralRule { + return vo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vo_001' +func (vo *vo_001) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vo_001' +func (vo *vo_001) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vo_001' +func (vo *vo_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vo *vo_001) MonthAbbreviated(month time.Month) string { + return vo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vo *vo_001) MonthsAbbreviated() []string { + return vo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vo *vo_001) MonthNarrow(month time.Month) string { + return vo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vo *vo_001) MonthsNarrow() []string { + return vo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vo *vo_001) MonthWide(month time.Month) string { + return vo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vo *vo_001) MonthsWide() []string { + return vo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vo *vo_001) WeekdayAbbreviated(weekday time.Weekday) string { + return vo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vo *vo_001) WeekdaysAbbreviated() []string { + return vo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vo *vo_001) WeekdayNarrow(weekday time.Weekday) string { + return vo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vo *vo_001) WeekdaysNarrow() []string { + return vo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vo *vo_001) WeekdayShort(weekday time.Weekday) string { + return vo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vo *vo_001) WeekdaysShort() []string { + return vo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vo *vo_001) WeekdayWide(weekday time.Weekday) string { + return vo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vo *vo_001) WeekdaysWide() []string { + return vo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vo_001' and handles both Whole and Real numbers based on 'v' +func (vo *vo_001) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vo_001' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vo *vo_001) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vo_001' +func (vo *vo_001) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vo.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vo_001' +// in accounting notation. +func (vo *vo_001) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vo.currencies[currency] + return string(append(append([]byte{}, symbol...), s...)) +} + +// FmtDateShort returns the short date representation of 't' for 'vo_001' +func (vo *vo_001) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2d}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2d}...) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vo_001' +func (vo *vo_001) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, vo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vo_001' +func (vo *vo_001) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, vo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vo_001' +func (vo *vo_001) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x20}...) + b = append(b, vo.monthsWide[t.Month()]...) + b = append(b, []byte{0x61}...) + b = append(b, []byte{0x20, 0x64}...) + b = append(b, []byte{0x2e, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x69, 0x64}...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vo_001' +func (vo *vo_001) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vo_001' +func (vo *vo_001) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vo_001' +func (vo *vo_001) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vo_001' +func (vo *vo_001) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vo_001/vo_001_test.go b/vendor/github.com/go-playground/locales/vo_001/vo_001_test.go new file mode 100644 index 0000000000..798c30ebeb --- /dev/null +++ b/vendor/github.com/go-playground/locales/vo_001/vo_001_test.go @@ -0,0 +1,1120 @@ +package vo_001 + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vo_001" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vun/vun.go b/vendor/github.com/go-playground/locales/vun/vun.go new file mode 100644 index 0000000000..d340429e63 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vun/vun.go @@ -0,0 +1,517 @@ +package vun + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vun struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vun' locale +func New() locales.Translator { + return &vun{ + locale: "vun", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TSh", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprilyi", "Mei", "Junyi", "Julyai", "Agusti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Jumapilyi", "Jumatatuu", "Jumanne", "Jumatanu", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"utuko", "kyiukonyi"}, + periodsWide: []string{"utuko", "kyiukonyi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristu", "Baada ya Kristu"}, + timezones: map[string]string{"SGT": "SGT", "∅∅∅": "∅∅∅", "UYT": "UYT", "SAST": "SAST", "SRT": "SRT", "EAT": "EAT", "AWDT": "AWDT", "CHADT": "CHADT", "CAT": "CAT", "WAST": "WAST", "HKST": "HKST", "ACDT": "ACDT", "HENOMX": "HENOMX", "AWST": "AWST", "CHAST": "CHAST", "HAST": "HAST", "ACWST": "ACWST", "WESZ": "WESZ", "BT": "BT", "ChST": "ChST", "CST": "CST", "ARST": "ARST", "WAT": "WAT", "HNT": "HNT", "AEDT": "AEDT", "HNPM": "HNPM", "ECT": "ECT", "HADT": "HADT", "AST": "AST", "OEZ": "OEZ", "MEZ": "MEZ", "MYT": "MYT", "TMT": "TMT", "HKT": "HKT", "COT": "COT", "HEEG": "HEEG", "PDT": "PDT", "EST": "EST", "HNOG": "HNOG", "ACST": "ACST", "HNEG": "HNEG", "AKST": "AKST", "LHST": "LHST", "BOT": "BOT", "IST": "IST", "JST": "JST", "HEOG": "HEOG", "ART": "ART", "HAT": "HAT", "AEST": "AEST", "CDT": "CDT", "NZST": "NZST", "WARST": "WARST", "HNPMX": "HNPMX", "HNCU": "HNCU", "ADT": "ADT", "WITA": "WITA", "UYST": "UYST", "HEPMX": "HEPMX", "HECU": "HECU", "WART": "WART", "CLT": "CLT", "CLST": "CLST", "MST": "MST", "GFT": "GFT", "AKDT": "AKDT", "JDT": "JDT", "GMT": "GMT", "WIT": "WIT", "NZDT": "NZDT", "OESZ": "OESZ", "TMST": "TMST", "HNNOMX": "HNNOMX", "WIB": "WIB", "EDT": "EDT", "COST": "COST", "HEPM": "HEPM", "VET": "VET", "MDT": "MDT", "LHDT": "LHDT", "GYT": "GYT", "PST": "PST", "ACWDT": "ACWDT", "MESZ": "MESZ", "WEZ": "WEZ"}, + } +} + +// Locale returns the current translators string locale +func (vun *vun) Locale() string { + return vun.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vun' +func (vun *vun) PluralsCardinal() []locales.PluralRule { + return vun.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vun' +func (vun *vun) PluralsOrdinal() []locales.PluralRule { + return vun.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vun' +func (vun *vun) PluralsRange() []locales.PluralRule { + return vun.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vun' +func (vun *vun) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vun' +func (vun *vun) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vun' +func (vun *vun) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vun *vun) MonthAbbreviated(month time.Month) string { + return vun.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vun *vun) MonthsAbbreviated() []string { + return vun.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vun *vun) MonthNarrow(month time.Month) string { + return vun.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vun *vun) MonthsNarrow() []string { + return vun.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vun *vun) MonthWide(month time.Month) string { + return vun.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vun *vun) MonthsWide() []string { + return vun.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vun *vun) WeekdayAbbreviated(weekday time.Weekday) string { + return vun.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vun *vun) WeekdaysAbbreviated() []string { + return vun.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vun *vun) WeekdayNarrow(weekday time.Weekday) string { + return vun.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vun *vun) WeekdaysNarrow() []string { + return vun.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vun *vun) WeekdayShort(weekday time.Weekday) string { + return vun.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vun *vun) WeekdaysShort() []string { + return vun.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vun *vun) WeekdayWide(weekday time.Weekday) string { + return vun.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vun *vun) WeekdaysWide() []string { + return vun.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vun' and handles both Whole and Real numbers based on 'v' +func (vun *vun) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vun' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vun *vun) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vun' +func (vun *vun) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vun.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vun.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vun.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, vun.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vun.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vun' +// in accounting notation. +func (vun *vun) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vun.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vun.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vun.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, vun.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vun.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vun' +func (vun *vun) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vun' +func (vun *vun) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vun.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vun' +func (vun *vun) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vun.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vun' +func (vun *vun) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vun.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vun.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vun' +func (vun *vun) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vun.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vun' +func (vun *vun) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vun.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vun.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vun' +func (vun *vun) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vun.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vun.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vun' +func (vun *vun) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vun.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vun.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vun.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vun/vun_test.go b/vendor/github.com/go-playground/locales/vun/vun_test.go new file mode 100644 index 0000000000..0b94dbcc0b --- /dev/null +++ b/vendor/github.com/go-playground/locales/vun/vun_test.go @@ -0,0 +1,1120 @@ +package vun + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vun" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/vun_TZ/vun_TZ.go b/vendor/github.com/go-playground/locales/vun_TZ/vun_TZ.go new file mode 100644 index 0000000000..d86225c248 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vun_TZ/vun_TZ.go @@ -0,0 +1,517 @@ +package vun_TZ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type vun_TZ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'vun_TZ' locale +func New() locales.Translator { + return &vun_TZ{ + locale: "vun_TZ", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Januari", "Februari", "Machi", "Aprilyi", "Mei", "Junyi", "Julyai", "Agusti", "Septemba", "Oktoba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Jpi", "Jtt", "Jnn", "Jtn", "Alh", "Iju", "Jmo"}, + daysNarrow: []string{"J", "J", "J", "J", "A", "I", "J"}, + daysWide: []string{"Jumapilyi", "Jumatatuu", "Jumanne", "Jumatanu", "Alhamisi", "Ijumaa", "Jumamosi"}, + periodsAbbreviated: []string{"utuko", "kyiukonyi"}, + periodsWide: []string{"utuko", "kyiukonyi"}, + erasAbbreviated: []string{"KK", "BK"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kabla ya Kristu", "Baada ya Kristu"}, + timezones: map[string]string{"WESZ": "WESZ", "CLT": "CLT", "ACST": "ACST", "COT": "COT", "WITA": "WITA", "CDT": "CDT", "CAT": "CAT", "AKST": "AKST", "EAT": "EAT", "HECU": "HECU", "HKST": "HKST", "HNPM": "HNPM", "ACWST": "ACWST", "ACWDT": "ACWDT", "JDT": "JDT", "OEZ": "OEZ", "HNCU": "HNCU", "CST": "CST", "HADT": "HADT", "HNOG": "HNOG", "ART": "ART", "WAST": "WAST", "BT": "BT", "SAST": "SAST", "HNPMX": "HNPMX", "WIB": "WIB", "NZDT": "NZDT", "HKT": "HKT", "COST": "COST", "HNEG": "HNEG", "NZST": "NZST", "VET": "VET", "AST": "AST", "GMT": "GMT", "GYT": "GYT", "PDT": "PDT", "ECT": "ECT", "JST": "JST", "HENOMX": "HENOMX", "HEEG": "HEEG", "ChST": "ChST", "AWST": "AWST", "SGT": "SGT", "MDT": "MDT", "HAT": "HAT", "AEDT": "AEDT", "UYST": "UYST", "AWDT": "AWDT", "IST": "IST", "ADT": "ADT", "CLST": "CLST", "TMST": "TMST", "LHDT": "LHDT", "CHAST": "CHAST", "HEOG": "HEOG", "WARST": "WARST", "ACDT": "ACDT", "HEPMX": "HEPMX", "HAST": "HAST", "TMT": "TMT", "MST": "MST", "HNT": "HNT", "GFT": "GFT", "BOT": "BOT", "MYT": "MYT", "WART": "WART", "ARST": "ARST", "EST": "EST", "HEPM": "HEPM", "LHST": "LHST", "SRT": "SRT", "WEZ": "WEZ", "EDT": "EDT", "HNNOMX": "HNNOMX", "∅∅∅": "∅∅∅", "WAT": "WAT", "AKDT": "AKDT", "AEST": "AEST", "UYT": "UYT", "WIT": "WIT", "PST": "PST", "OESZ": "OESZ", "CHADT": "CHADT", "MEZ": "MEZ", "MESZ": "MESZ"}, + } +} + +// Locale returns the current translators string locale +func (vun *vun_TZ) Locale() string { + return vun.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'vun_TZ' +func (vun *vun_TZ) PluralsCardinal() []locales.PluralRule { + return vun.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'vun_TZ' +func (vun *vun_TZ) PluralsOrdinal() []locales.PluralRule { + return vun.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'vun_TZ' +func (vun *vun_TZ) PluralsRange() []locales.PluralRule { + return vun.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'vun_TZ' +func (vun *vun_TZ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'vun_TZ' +func (vun *vun_TZ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'vun_TZ' +func (vun *vun_TZ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (vun *vun_TZ) MonthAbbreviated(month time.Month) string { + return vun.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (vun *vun_TZ) MonthsAbbreviated() []string { + return vun.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (vun *vun_TZ) MonthNarrow(month time.Month) string { + return vun.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (vun *vun_TZ) MonthsNarrow() []string { + return vun.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (vun *vun_TZ) MonthWide(month time.Month) string { + return vun.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (vun *vun_TZ) MonthsWide() []string { + return vun.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (vun *vun_TZ) WeekdayAbbreviated(weekday time.Weekday) string { + return vun.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (vun *vun_TZ) WeekdaysAbbreviated() []string { + return vun.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (vun *vun_TZ) WeekdayNarrow(weekday time.Weekday) string { + return vun.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (vun *vun_TZ) WeekdaysNarrow() []string { + return vun.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (vun *vun_TZ) WeekdayShort(weekday time.Weekday) string { + return vun.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (vun *vun_TZ) WeekdaysShort() []string { + return vun.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (vun *vun_TZ) WeekdayWide(weekday time.Weekday) string { + return vun.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (vun *vun_TZ) WeekdaysWide() []string { + return vun.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'vun_TZ' and handles both Whole and Real numbers based on 'v' +func (vun *vun_TZ) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'vun_TZ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (vun *vun_TZ) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'vun_TZ' +func (vun *vun_TZ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vun.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vun.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vun.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, vun.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vun.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'vun_TZ' +// in accounting notation. +func (vun *vun_TZ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := vun.currencies[currency] + l := len(s) + len(symbol) + 0 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, vun.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, vun.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, vun.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, vun.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'vun_TZ' +func (vun *vun_TZ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'vun_TZ' +func (vun *vun_TZ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vun.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'vun_TZ' +func (vun *vun_TZ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vun.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'vun_TZ' +func (vun *vun_TZ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, vun.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, vun.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'vun_TZ' +func (vun *vun_TZ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vun.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'vun_TZ' +func (vun *vun_TZ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vun.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vun.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'vun_TZ' +func (vun *vun_TZ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vun.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vun.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'vun_TZ' +func (vun *vun_TZ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, vun.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, vun.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := vun.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/vun_TZ/vun_TZ_test.go b/vendor/github.com/go-playground/locales/vun_TZ/vun_TZ_test.go new file mode 100644 index 0000000000..65f3dc0d19 --- /dev/null +++ b/vendor/github.com/go-playground/locales/vun_TZ/vun_TZ_test.go @@ -0,0 +1,1120 @@ +package vun_TZ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "vun_TZ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/wae/wae.go b/vendor/github.com/go-playground/locales/wae/wae.go new file mode 100644 index 0000000000..caa7a14615 --- /dev/null +++ b/vendor/github.com/go-playground/locales/wae/wae.go @@ -0,0 +1,395 @@ +package wae + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type wae struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'wae' locale +func New() locales.Translator { + return &wae{ + locale: "wae", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: "’", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "Jen", "Hor", "Mär", "Abr", "Mei", "Brá", "Hei", "Öig", "Her", "Wím", "Win", "Chr"}, + monthsNarrow: []string{"", "J", "H", "M", "A", "M", "B", "H", "Ö", "H", "W", "W", "C"}, + monthsWide: []string{"", "Jenner", "Hornig", "Märze", "Abrille", "Meije", "Bráčet", "Heiwet", "Öigšte", "Herbštmánet", "Wímánet", "Wintermánet", "Chrištmánet"}, + daysAbbreviated: []string{"Sun", "Män", "Ziš", "Mit", "Fró", "Fri", "Sam"}, + daysNarrow: []string{"S", "M", "Z", "M", "F", "F", "S"}, + daysWide: []string{"Sunntag", "Mäntag", "Zištag", "Mittwuč", "Fróntag", "Fritag", "Samštag"}, + erasAbbreviated: []string{"v. Chr.", "n. Chr"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"CST": "CST", "AWST": "AWST", "ECT": "ECT", "HNOG": "HNOG", "WESZ": "Wešteuropäiši Summerzit", "SAST": "SAST", "MDT": "MDT", "AKDT": "AKDT", "ACWST": "ACWST", "VET": "VET", "JST": "JST", "HEEG": "HEEG", "HNPM": "HNPM", "HEPMX": "HEPMX", "EAT": "EAT", "MESZ": "Mitteleuropäiši Summerzit", "MYT": "MYT", "ACST": "ACST", "AWDT": "AWDT", "CAT": "CAT", "WART": "WART", "CLST": "CLST", "HEOG": "HEOG", "TMST": "TMST", "AEDT": "AEDT", "HENOMX": "HENOMX", "GYT": "GYT", "CHAST": "CHAST", "OEZ": "Ošteuropäiši Standardzit", "ART": "ART", "COT": "COT", "HNCU": "HNCU", "SGT": "SGT", "TMT": "TMT", "ARST": "ARST", "HAT": "HAT", "MST": "MST", "UYT": "UYT", "UYST": "UYST", "LHDT": "LHDT", "HADT": "HADT", "EDT": "EDT", "HNNOMX": "HNNOMX", "ADT": "Atlantiši Summerzit", "OESZ": "Ošteuropäiši Summerzit", "WAT": "WAT", "WAST": "WAST", "NZST": "NZST", "IST": "IST", "MEZ": "Mitteleuropäiši Standardzit", "WARST": "WARST", "HEPM": "HEPM", "∅∅∅": "∅∅∅", "ChST": "ChST", "HECU": "HECU", "BT": "BT", "SRT": "SRT", "BOT": "BOT", "AST": "Atlantiši Standardzit", "GMT": "GMT", "HKST": "HKST", "WITA": "WITA", "GFT": "GFT", "LHST": "LHST", "CHADT": "CHADT", "HAST": "HAST", "WEZ": "Wešteuropäiši Standardzit", "HNT": "HNT", "AKST": "AKST", "HNPMX": "HNPMX", "WIB": "WIB", "WIT": "WIT", "NZDT": "NZDT", "EST": "EST", "HKT": "HKT", "HNEG": "HNEG", "AEST": "AEST", "CDT": "CDT", "ACDT": "ACDT", "ACWDT": "ACWDT", "JDT": "JDT", "CLT": "CLT", "PDT": "PDT", "PST": "PST", "COST": "COST"}, + } +} + +// Locale returns the current translators string locale +func (wae *wae) Locale() string { + return wae.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'wae' +func (wae *wae) PluralsCardinal() []locales.PluralRule { + return wae.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'wae' +func (wae *wae) PluralsOrdinal() []locales.PluralRule { + return wae.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'wae' +func (wae *wae) PluralsRange() []locales.PluralRule { + return wae.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'wae' +func (wae *wae) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'wae' +func (wae *wae) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'wae' +func (wae *wae) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (wae *wae) MonthAbbreviated(month time.Month) string { + return wae.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (wae *wae) MonthsAbbreviated() []string { + return wae.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (wae *wae) MonthNarrow(month time.Month) string { + return wae.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (wae *wae) MonthsNarrow() []string { + return wae.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (wae *wae) MonthWide(month time.Month) string { + return wae.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (wae *wae) MonthsWide() []string { + return wae.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (wae *wae) WeekdayAbbreviated(weekday time.Weekday) string { + return wae.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (wae *wae) WeekdaysAbbreviated() []string { + return wae.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (wae *wae) WeekdayNarrow(weekday time.Weekday) string { + return wae.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (wae *wae) WeekdaysNarrow() []string { + return wae.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (wae *wae) WeekdayShort(weekday time.Weekday) string { + return wae.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (wae *wae) WeekdaysShort() []string { + return wae.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (wae *wae) WeekdayWide(weekday time.Weekday) string { + return wae.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (wae *wae) WeekdaysWide() []string { + return wae.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'wae' and handles both Whole and Real numbers based on 'v' +func (wae *wae) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'wae' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (wae *wae) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'wae' +func (wae *wae) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := wae.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, wae.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(wae.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, wae.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, wae.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, wae.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'wae' +// in accounting notation. +func (wae *wae) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := wae.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, wae.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(wae.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, wae.currencyNegativePrefix[j]) + } + + b = append(b, wae.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(wae.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, wae.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, wae.currencyNegativeSuffix...) + } else { + + b = append(b, wae.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'wae' +func (wae *wae) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'wae' +func (wae *wae) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, wae.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'wae' +func (wae *wae) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, wae.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'wae' +func (wae *wae) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, wae.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, wae.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'wae' +func (wae *wae) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'wae' +func (wae *wae) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'wae' +func (wae *wae) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'wae' +func (wae *wae) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/wae/wae_test.go b/vendor/github.com/go-playground/locales/wae/wae_test.go new file mode 100644 index 0000000000..67ee9a4c2a --- /dev/null +++ b/vendor/github.com/go-playground/locales/wae/wae_test.go @@ -0,0 +1,1120 @@ +package wae + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "wae" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/wae_CH/wae_CH.go b/vendor/github.com/go-playground/locales/wae_CH/wae_CH.go new file mode 100644 index 0000000000..202398cdd4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/wae_CH/wae_CH.go @@ -0,0 +1,395 @@ +package wae_CH + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type wae_CH struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'wae_CH' locale +func New() locales.Translator { + return &wae_CH{ + locale: "wae_CH", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: "’", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "Jen", "Hor", "Mär", "Abr", "Mei", "Brá", "Hei", "Öig", "Her", "Wím", "Win", "Chr"}, + monthsNarrow: []string{"", "J", "H", "M", "A", "M", "B", "H", "Ö", "H", "W", "W", "C"}, + monthsWide: []string{"", "Jenner", "Hornig", "Märze", "Abrille", "Meije", "Bráčet", "Heiwet", "Öigšte", "Herbštmánet", "Wímánet", "Wintermánet", "Chrištmánet"}, + daysAbbreviated: []string{"Sun", "Män", "Ziš", "Mit", "Fró", "Fri", "Sam"}, + daysNarrow: []string{"S", "M", "Z", "M", "F", "F", "S"}, + daysWide: []string{"Sunntag", "Mäntag", "Zištag", "Mittwuč", "Fróntag", "Fritag", "Samštag"}, + erasAbbreviated: []string{"v. Chr.", "n. Chr"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"", ""}, + timezones: map[string]string{"VET": "VET", "CLST": "CLST", "COT": "COT", "COST": "COST", "BT": "BT", "UYT": "UYT", "PDT": "PDT", "SGT": "SGT", "MYT": "MYT", "EST": "EST", "EDT": "EDT", "ACST": "ACST", "HECU": "HECU", "HEOG": "HEOG", "ART": "ART", "AKDT": "AKDT", "SRT": "SRT", "CDT": "CDT", "NZST": "NZST", "CLT": "CLT", "AST": "Atlantiši Standardzit", "TMST": "TMST", "HEEG": "HEEG", "MESZ": "Mitteleuropäiši Summerzit", "OESZ": "Ošteuropäiši Summerzit", "WEZ": "Wešteuropäiši Standardzit", "WESZ": "Wešteuropäiši Summerzit", "HNPM": "HNPM", "LHDT": "LHDT", "GYT": "GYT", "HKT": "HKT", "HENOMX": "HENOMX", "ACDT": "ACDT", "WITA": "WITA", "UYST": "UYST", "CHAST": "CHAST", "ACWDT": "ACWDT", "ECT": "ECT", "CAT": "CAT", "MDT": "MDT", "HNEG": "HNEG", "HNPMX": "HNPMX", "SAST": "SAST", "CST": "CST", "BOT": "BOT", "HADT": "HADT", "JST": "JST", "HNNOMX": "HNNOMX", "WIB": "WIB", "OEZ": "Ošteuropäiši Standardzit", "GMT": "GMT", "HNOG": "HNOG", "JDT": "JDT", "TMT": "TMT", "WAST": "WAST", "AKST": "AKST", "WIT": "WIT", "HAST": "HAST", "IST": "IST", "WART": "WART", "WAT": "WAT", "∅∅∅": "∅∅∅", "GFT": "GFT", "HEPMX": "HEPMX", "HNCU": "HNCU", "HKST": "HKST", "LHST": "LHST", "AWST": "AWST", "NZDT": "NZDT", "AEST": "AEST", "EAT": "EAT", "AWDT": "AWDT", "PST": "PST", "ACWST": "ACWST", "ARST": "ARST", "MST": "MST", "CHADT": "CHADT", "MEZ": "Mitteleuropäiši Standardzit", "WARST": "WARST", "AEDT": "AEDT", "HEPM": "HEPM", "HNT": "HNT", "HAT": "HAT", "ChST": "ChST", "ADT": "Atlantiši Summerzit"}, + } +} + +// Locale returns the current translators string locale +func (wae *wae_CH) Locale() string { + return wae.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'wae_CH' +func (wae *wae_CH) PluralsCardinal() []locales.PluralRule { + return wae.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'wae_CH' +func (wae *wae_CH) PluralsOrdinal() []locales.PluralRule { + return wae.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'wae_CH' +func (wae *wae_CH) PluralsRange() []locales.PluralRule { + return wae.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'wae_CH' +func (wae *wae_CH) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'wae_CH' +func (wae *wae_CH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'wae_CH' +func (wae *wae_CH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (wae *wae_CH) MonthAbbreviated(month time.Month) string { + return wae.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (wae *wae_CH) MonthsAbbreviated() []string { + return wae.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (wae *wae_CH) MonthNarrow(month time.Month) string { + return wae.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (wae *wae_CH) MonthsNarrow() []string { + return wae.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (wae *wae_CH) MonthWide(month time.Month) string { + return wae.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (wae *wae_CH) MonthsWide() []string { + return wae.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (wae *wae_CH) WeekdayAbbreviated(weekday time.Weekday) string { + return wae.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (wae *wae_CH) WeekdaysAbbreviated() []string { + return wae.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (wae *wae_CH) WeekdayNarrow(weekday time.Weekday) string { + return wae.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (wae *wae_CH) WeekdaysNarrow() []string { + return wae.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (wae *wae_CH) WeekdayShort(weekday time.Weekday) string { + return wae.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (wae *wae_CH) WeekdaysShort() []string { + return wae.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (wae *wae_CH) WeekdayWide(weekday time.Weekday) string { + return wae.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (wae *wae_CH) WeekdaysWide() []string { + return wae.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'wae_CH' and handles both Whole and Real numbers based on 'v' +func (wae *wae_CH) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'wae_CH' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (wae *wae_CH) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'wae_CH' +func (wae *wae_CH) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := wae.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, wae.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(wae.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, wae.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, wae.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, wae.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'wae_CH' +// in accounting notation. +func (wae *wae_CH) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := wae.currencies[currency] + l := len(s) + len(symbol) + 4 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, wae.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(wae.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, wae.currencyNegativePrefix[j]) + } + + b = append(b, wae.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(wae.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, wae.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, wae.currencyNegativeSuffix...) + } else { + + b = append(b, wae.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'wae_CH' +func (wae *wae_CH) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'wae_CH' +func (wae *wae_CH) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, wae.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'wae_CH' +func (wae *wae_CH) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, wae.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'wae_CH' +func (wae *wae_CH) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, wae.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2e, 0x20}...) + b = append(b, wae.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'wae_CH' +func (wae *wae_CH) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'wae_CH' +func (wae *wae_CH) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'wae_CH' +func (wae *wae_CH) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'wae_CH' +func (wae *wae_CH) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/wae_CH/wae_CH_test.go b/vendor/github.com/go-playground/locales/wae_CH/wae_CH_test.go new file mode 100644 index 0000000000..8496b5bd5f --- /dev/null +++ b/vendor/github.com/go-playground/locales/wae_CH/wae_CH_test.go @@ -0,0 +1,1120 @@ +package wae_CH + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "wae_CH" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/xog/xog.go b/vendor/github.com/go-playground/locales/xog/xog.go new file mode 100644 index 0000000000..174c786797 --- /dev/null +++ b/vendor/github.com/go-playground/locales/xog/xog.go @@ -0,0 +1,520 @@ +package xog + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type xog struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'xog' locale +func New() locales.Translator { + return &xog{ + locale: "xog", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "USh", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apu", "Maa", "Juu", "Jul", "Agu", "Seb", "Oki", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janwaliyo", "Febwaliyo", "Marisi", "Apuli", "Maayi", "Juuni", "Julaayi", "Agusito", "Sebuttemba", "Okitobba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Sabi", "Bala", "Kubi", "Kusa", "Kuna", "Kuta", "Muka"}, + daysNarrow: []string{"S", "B", "B", "S", "K", "K", "M"}, + daysWide: []string{"Sabiiti", "Balaza", "Owokubili", "Owokusatu", "Olokuna", "Olokutaanu", "Olomukaaga"}, + periodsAbbreviated: []string{"Munkyo", "Eigulo"}, + periodsWide: []string{"Munkyo", "Eigulo"}, + erasAbbreviated: []string{"AZ", "AF"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kulisto nga azilawo", "Kulisto nga affile"}, + timezones: map[string]string{"HNPMX": "HNPMX", "WIB": "WIB", "SGT": "SGT", "ARST": "ARST", "HAT": "HAT", "AKST": "AKST", "NZDT": "NZDT", "CLT": "CLT", "TMST": "TMST", "GFT": "GFT", "MESZ": "MESZ", "AST": "AST", "TMT": "TMT", "HNEG": "HNEG", "CST": "CST", "AWST": "AWST", "WEZ": "WEZ", "MST": "MST", "MDT": "MDT", "ART": "ART", "HKST": "HKST", "VET": "VET", "HNPM": "HNPM", "SRT": "SRT", "PST": "PST", "WAST": "WAST", "HNT": "HNT", "HEEG": "HEEG", "UYST": "UYST", "WIT": "WIT", "CHADT": "CHADT", "WARST": "WARST", "HEPM": "HEPM", "HEPMX": "HEPMX", "HADT": "HADT", "ACWDT": "ACWDT", "MYT": "MYT", "AKDT": "AKDT", "CDT": "CDT", "JST": "JST", "HNOG": "HNOG", "OESZ": "OESZ", "WAT": "WAT", "HKT": "HKT", "ACDT": "ACDT", "COT": "COT", "AWDT": "AWDT", "CAT": "CAT", "CLST": "CLST", "HEOG": "HEOG", "OEZ": "OEZ", "WESZ": "WESZ", "UYT": "UYT", "HECU": "HECU", "EDT": "EDT", "COST": "COST", "HNNOMX": "HNNOMX", "GYT": "GYT", "HNCU": "HNCU", "HAST": "HAST", "JDT": "JDT", "SAST": "SAST", "CHAST": "CHAST", "NZST": "NZST", "ACST": "ACST", "AEDT": "AEDT", "ChST": "ChST", "ECT": "ECT", "MEZ": "MEZ", "WART": "WART", "BT": "BT", "WITA": "WITA", "∅∅∅": "∅∅∅", "EAT": "EAT", "BOT": "BOT", "PDT": "PDT", "ACWST": "ACWST", "EST": "EST", "HENOMX": "HENOMX", "AEST": "AEST", "LHST": "LHST", "LHDT": "LHDT", "IST": "IST", "ADT": "ADT", "GMT": "GMT"}, + } +} + +// Locale returns the current translators string locale +func (xog *xog) Locale() string { + return xog.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'xog' +func (xog *xog) PluralsCardinal() []locales.PluralRule { + return xog.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'xog' +func (xog *xog) PluralsOrdinal() []locales.PluralRule { + return xog.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'xog' +func (xog *xog) PluralsRange() []locales.PluralRule { + return xog.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'xog' +func (xog *xog) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'xog' +func (xog *xog) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'xog' +func (xog *xog) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (xog *xog) MonthAbbreviated(month time.Month) string { + return xog.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (xog *xog) MonthsAbbreviated() []string { + return xog.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (xog *xog) MonthNarrow(month time.Month) string { + return xog.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (xog *xog) MonthsNarrow() []string { + return xog.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (xog *xog) MonthWide(month time.Month) string { + return xog.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (xog *xog) MonthsWide() []string { + return xog.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (xog *xog) WeekdayAbbreviated(weekday time.Weekday) string { + return xog.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (xog *xog) WeekdaysAbbreviated() []string { + return xog.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (xog *xog) WeekdayNarrow(weekday time.Weekday) string { + return xog.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (xog *xog) WeekdaysNarrow() []string { + return xog.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (xog *xog) WeekdayShort(weekday time.Weekday) string { + return xog.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (xog *xog) WeekdaysShort() []string { + return xog.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (xog *xog) WeekdayWide(weekday time.Weekday) string { + return xog.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (xog *xog) WeekdaysWide() []string { + return xog.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'xog' and handles both Whole and Real numbers based on 'v' +func (xog *xog) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'xog' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (xog *xog) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'xog' +func (xog *xog) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := xog.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, xog.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, xog.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, xog.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, xog.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, xog.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'xog' +// in accounting notation. +func (xog *xog) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := xog.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, xog.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, xog.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, xog.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, xog.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, xog.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, xog.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'xog' +func (xog *xog) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'xog' +func (xog *xog) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, xog.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'xog' +func (xog *xog) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, xog.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'xog' +func (xog *xog) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, xog.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, xog.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'xog' +func (xog *xog) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, xog.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'xog' +func (xog *xog) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, xog.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, xog.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'xog' +func (xog *xog) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, xog.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, xog.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'xog' +func (xog *xog) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, xog.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, xog.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := xog.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/xog/xog_test.go b/vendor/github.com/go-playground/locales/xog/xog_test.go new file mode 100644 index 0000000000..47a38a3ec7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/xog/xog_test.go @@ -0,0 +1,1120 @@ +package xog + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "xog" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/xog_UG/xog_UG.go b/vendor/github.com/go-playground/locales/xog_UG/xog_UG.go new file mode 100644 index 0000000000..b4fd2ce878 --- /dev/null +++ b/vendor/github.com/go-playground/locales/xog_UG/xog_UG.go @@ -0,0 +1,520 @@ +package xog_UG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type xog_UG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'xog_UG' locale +func New() locales.Translator { + return &xog_UG{ + locale: "xog_UG", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativeSuffix: " ", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apu", "Maa", "Juu", "Jul", "Agu", "Seb", "Oki", "Nov", "Des"}, + monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "Janwaliyo", "Febwaliyo", "Marisi", "Apuli", "Maayi", "Juuni", "Julaayi", "Agusito", "Sebuttemba", "Okitobba", "Novemba", "Desemba"}, + daysAbbreviated: []string{"Sabi", "Bala", "Kubi", "Kusa", "Kuna", "Kuta", "Muka"}, + daysNarrow: []string{"S", "B", "B", "S", "K", "K", "M"}, + daysWide: []string{"Sabiiti", "Balaza", "Owokubili", "Owokusatu", "Olokuna", "Olokutaanu", "Olomukaaga"}, + periodsAbbreviated: []string{"Munkyo", "Eigulo"}, + periodsWide: []string{"Munkyo", "Eigulo"}, + erasAbbreviated: []string{"AZ", "AF"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Kulisto nga azilawo", "Kulisto nga affile"}, + timezones: map[string]string{"AEST": "AEST", "CDT": "CDT", "OEZ": "OEZ", "TMT": "TMT", "WAST": "WAST", "AWST": "AWST", "CLT": "CLT", "HEOG": "HEOG", "MDT": "MDT", "EST": "EST", "HKT": "HKT", "HNEG": "HNEG", "WITA": "WITA", "WIB": "WIB", "TMST": "TMST", "MST": "MST", "CHADT": "CHADT", "PST": "PST", "CST": "CST", "AWDT": "AWDT", "HAST": "HAST", "UYT": "UYT", "LHDT": "LHDT", "JST": "JST", "OESZ": "OESZ", "WEZ": "WEZ", "HNPM": "HNPM", "EAT": "EAT", "BOT": "BOT", "IST": "IST", "MESZ": "MESZ", "AST": "AST", "COT": "COT", "HEPM": "HEPM", "WIT": "WIT", "PDT": "PDT", "ACWDT": "ACWDT", "NZST": "NZST", "HNT": "HNT", "WESZ": "WESZ", "EDT": "EDT", "JDT": "JDT", "HEEG": "HEEG", "HECU": "HECU", "SGT": "SGT", "ECT": "ECT", "NZDT": "NZDT", "MEZ": "MEZ", "SAST": "SAST", "ACST": "ACST", "HENOMX": "HENOMX", "GFT": "GFT", "AEDT": "AEDT", "ChST": "ChST", "UYST": "UYST", "WART": "WART", "MYT": "MYT", "COST": "COST", "HNNOMX": "HNNOMX", "LHST": "LHST", "HNPMX": "HNPMX", "SRT": "SRT", "HADT": "HADT", "∅∅∅": "∅∅∅", "HKST": "HKST", "HEPMX": "HEPMX", "GYT": "GYT", "HNOG": "HNOG", "AKDT": "AKDT", "GMT": "GMT", "ACDT": "ACDT", "AKST": "AKST", "CHAST": "CHAST", "CAT": "CAT", "VET": "VET", "ART": "ART", "ARST": "ARST", "WAT": "WAT", "BT": "BT", "HNCU": "HNCU", "CLST": "CLST", "ADT": "ADT", "HAT": "HAT", "ACWST": "ACWST", "WARST": "WARST"}, + } +} + +// Locale returns the current translators string locale +func (xog *xog_UG) Locale() string { + return xog.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'xog_UG' +func (xog *xog_UG) PluralsCardinal() []locales.PluralRule { + return xog.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'xog_UG' +func (xog *xog_UG) PluralsOrdinal() []locales.PluralRule { + return xog.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'xog_UG' +func (xog *xog_UG) PluralsRange() []locales.PluralRule { + return xog.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'xog_UG' +func (xog *xog_UG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + + if n == 1 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'xog_UG' +func (xog *xog_UG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'xog_UG' +func (xog *xog_UG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (xog *xog_UG) MonthAbbreviated(month time.Month) string { + return xog.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (xog *xog_UG) MonthsAbbreviated() []string { + return xog.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (xog *xog_UG) MonthNarrow(month time.Month) string { + return xog.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (xog *xog_UG) MonthsNarrow() []string { + return xog.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (xog *xog_UG) MonthWide(month time.Month) string { + return xog.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (xog *xog_UG) MonthsWide() []string { + return xog.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (xog *xog_UG) WeekdayAbbreviated(weekday time.Weekday) string { + return xog.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (xog *xog_UG) WeekdaysAbbreviated() []string { + return xog.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (xog *xog_UG) WeekdayNarrow(weekday time.Weekday) string { + return xog.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (xog *xog_UG) WeekdaysNarrow() []string { + return xog.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (xog *xog_UG) WeekdayShort(weekday time.Weekday) string { + return xog.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (xog *xog_UG) WeekdaysShort() []string { + return xog.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (xog *xog_UG) WeekdayWide(weekday time.Weekday) string { + return xog.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (xog *xog_UG) WeekdaysWide() []string { + return xog.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'xog_UG' and handles both Whole and Real numbers based on 'v' +func (xog *xog_UG) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'xog_UG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (xog *xog_UG) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'xog_UG' +func (xog *xog_UG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := xog.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, xog.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, xog.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, xog.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, xog.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, xog.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'xog_UG' +// in accounting notation. +func (xog *xog_UG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := xog.currencies[currency] + l := len(s) + len(symbol) + 2 + 0*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, xog.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, xog.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, xog.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, xog.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, xog.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, xog.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'xog_UG' +func (xog *xog_UG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'xog_UG' +func (xog *xog_UG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, xog.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'xog_UG' +func (xog *xog_UG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, xog.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'xog_UG' +func (xog *xog_UG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, xog.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, xog.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'xog_UG' +func (xog *xog_UG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, xog.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'xog_UG' +func (xog *xog_UG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, xog.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, xog.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'xog_UG' +func (xog *xog_UG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, xog.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, xog.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'xog_UG' +func (xog *xog_UG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, xog.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, xog.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := xog.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/xog_UG/xog_UG_test.go b/vendor/github.com/go-playground/locales/xog_UG/xog_UG_test.go new file mode 100644 index 0000000000..3bc5ee1f72 --- /dev/null +++ b/vendor/github.com/go-playground/locales/xog_UG/xog_UG_test.go @@ -0,0 +1,1120 @@ +package xog_UG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "xog_UG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yav/yav.go b/vendor/github.com/go-playground/locales/yav/yav.go new file mode 100644 index 0000000000..03bb61dd76 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yav/yav.go @@ -0,0 +1,572 @@ +package yav + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yav struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yav' locale +func New() locales.Translator { + return &yav{ + locale: "yav", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "o.1", "o.2", "o.3", "o.4", "o.5", "o.6", "o.7", "o.8", "o.9", "o.10", "o.11", "o.12"}, + monthsWide: []string{"", "pikítíkítie, oólí ú kutúan", "siɛyɛ́, oóli ú kándíɛ", "ɔnsúmbɔl, oóli ú kátátúɛ", "mesiŋ, oóli ú kénie", "ensil, oóli ú kátánuɛ", "ɔsɔn", "efute", "pisuyú", "imɛŋ i puɔs", "imɛŋ i putúk,oóli ú kátíɛ", "makandikɛ", "pilɔndɔ́"}, + daysAbbreviated: []string{"sd", "md", "mw", "et", "kl", "fl", "ss"}, + daysNarrow: []string{"s", "m", "m", "e", "k", "f", "s"}, + daysWide: []string{"sɔ́ndiɛ", "móndie", "muányáŋmóndie", "metúkpíápɛ", "kúpélimetúkpiapɛ", "feléte", "séselé"}, + periodsAbbreviated: []string{"kiɛmɛ́ɛm", "kisɛ́ndɛ"}, + periodsWide: []string{"kiɛmɛ́ɛm", "kisɛ́ndɛ"}, + erasAbbreviated: []string{"k.Y.", "+J.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"katikupíen Yésuse", "ékélémkúnupíén n"}, + timezones: map[string]string{"CAT": "CAT", "VET": "VET", "AST": "AST", "MDT": "MDT", "HNPMX": "HNPMX", "∅∅∅": "∅∅∅", "HNCU": "HNCU", "CDT": "CDT", "HENOMX": "HENOMX", "HNT": "HNT", "PDT": "PDT", "MEZ": "MEZ", "HNOG": "HNOG", "HKT": "HKT", "HKST": "HKST", "ART": "ART", "HNEG": "HNEG", "AEST": "AEST", "WITA": "WITA", "SRT": "SRT", "CHAST": "CHAST", "ACWDT": "ACWDT", "AKDT": "AKDT", "PST": "PST", "EST": "EST", "ACDT": "ACDT", "OEZ": "OEZ", "HNNOMX": "HNNOMX", "HEPM": "HEPM", "LHST": "LHST", "IST": "IST", "WEZ": "WEZ", "HEOG": "HEOG", "AWDT": "AWDT", "CHADT": "CHADT", "WARST": "WARST", "BT": "BT", "CLT": "CLT", "ADT": "ADT", "MST": "MST", "HNPM": "HNPM", "CST": "CST", "ECT": "ECT", "ACWST": "ACWST", "LHDT": "LHDT", "CLST": "CLST", "HAT": "HAT", "AEDT": "AEDT", "AKST": "AKST", "UYT": "UYT", "HAST": "HAST", "GMT": "GMT", "UYST": "UYST", "EAT": "EAT", "HECU": "HECU", "NZST": "NZST", "NZDT": "NZDT", "WIB": "WIB", "TMT": "TMT", "EDT": "EDT", "COST": "COST", "SAST": "SAST", "SGT": "SGT", "JST": "JST", "TMST": "TMST", "ARST": "ARST", "WART": "WART", "HEEG": "HEEG", "COT": "COT", "WIT": "WIT", "HADT": "HADT", "WESZ": "WESZ", "MYT": "MYT", "ACST": "ACST", "OESZ": "OESZ", "WAT": "WAT", "ChST": "ChST", "HEPMX": "HEPMX", "AWST": "AWST", "BOT": "BOT", "MESZ": "MESZ", "GFT": "GFT", "GYT": "GYT", "JDT": "JDT", "WAST": "WAST"}, + } +} + +// Locale returns the current translators string locale +func (yav *yav) Locale() string { + return yav.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yav' +func (yav *yav) PluralsCardinal() []locales.PluralRule { + return yav.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yav' +func (yav *yav) PluralsOrdinal() []locales.PluralRule { + return yav.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yav' +func (yav *yav) PluralsRange() []locales.PluralRule { + return yav.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yav' +func (yav *yav) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yav' +func (yav *yav) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yav' +func (yav *yav) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yav *yav) MonthAbbreviated(month time.Month) string { + return yav.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yav *yav) MonthsAbbreviated() []string { + return yav.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yav *yav) MonthNarrow(month time.Month) string { + return yav.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yav *yav) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yav *yav) MonthWide(month time.Month) string { + return yav.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yav *yav) MonthsWide() []string { + return yav.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yav *yav) WeekdayAbbreviated(weekday time.Weekday) string { + return yav.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yav *yav) WeekdaysAbbreviated() []string { + return yav.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yav *yav) WeekdayNarrow(weekday time.Weekday) string { + return yav.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yav *yav) WeekdaysNarrow() []string { + return yav.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yav *yav) WeekdayShort(weekday time.Weekday) string { + return yav.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yav *yav) WeekdaysShort() []string { + return yav.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yav *yav) WeekdayWide(weekday time.Weekday) string { + return yav.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yav *yav) WeekdaysWide() []string { + return yav.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yav' and handles both Whole and Real numbers based on 'v' +func (yav *yav) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(yav.group) - 1; j >= 0; j-- { + b = append(b, yav.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yav.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yav' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yav *yav) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yav.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yav.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yav.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yav' +func (yav *yav) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yav.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(yav.group) - 1; j >= 0; j-- { + b = append(b, yav.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yav.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yav.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, yav.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yav' +// in accounting notation. +func (yav *yav) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yav.currencies[currency] + l := len(s) + len(symbol) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(yav.group) - 1; j >= 0; j-- { + b = append(b, yav.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, yav.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yav.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, yav.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, yav.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yav' +func (yav *yav) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yav' +func (yav *yav) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yav.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yav' +func (yav *yav) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yav.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yav' +func (yav *yav) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, yav.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yav.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yav' +func (yav *yav) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yav' +func (yav *yav) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yav' +func (yav *yav) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yav' +func (yav *yav) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := yav.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yav/yav_test.go b/vendor/github.com/go-playground/locales/yav/yav_test.go new file mode 100644 index 0000000000..e603f0b260 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yav/yav_test.go @@ -0,0 +1,1120 @@ +package yav + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yav" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yav_CM/yav_CM.go b/vendor/github.com/go-playground/locales/yav_CM/yav_CM.go new file mode 100644 index 0000000000..4a8a985dea --- /dev/null +++ b/vendor/github.com/go-playground/locales/yav_CM/yav_CM.go @@ -0,0 +1,572 @@ +package yav_CM + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yav_CM struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yav_CM' locale +func New() locales.Translator { + return &yav_CM{ + locale: "yav_CM", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + timeSeparator: ":", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: " ", + currencyNegativePrefix: "(", + currencyNegativeSuffix: " )", + monthsAbbreviated: []string{"", "o.1", "o.2", "o.3", "o.4", "o.5", "o.6", "o.7", "o.8", "o.9", "o.10", "o.11", "o.12"}, + monthsWide: []string{"", "pikítíkítie, oólí ú kutúan", "siɛyɛ́, oóli ú kándíɛ", "ɔnsúmbɔl, oóli ú kátátúɛ", "mesiŋ, oóli ú kénie", "ensil, oóli ú kátánuɛ", "ɔsɔn", "efute", "pisuyú", "imɛŋ i puɔs", "imɛŋ i putúk,oóli ú kátíɛ", "makandikɛ", "pilɔndɔ́"}, + daysAbbreviated: []string{"sd", "md", "mw", "et", "kl", "fl", "ss"}, + daysNarrow: []string{"s", "m", "m", "e", "k", "f", "s"}, + daysWide: []string{"sɔ́ndiɛ", "móndie", "muányáŋmóndie", "metúkpíápɛ", "kúpélimetúkpiapɛ", "feléte", "séselé"}, + periodsAbbreviated: []string{"kiɛmɛ́ɛm", "kisɛ́ndɛ"}, + periodsWide: []string{"kiɛmɛ́ɛm", "kisɛ́ndɛ"}, + erasAbbreviated: []string{"k.Y.", "+J.C."}, + erasNarrow: []string{"", ""}, + erasWide: []string{"katikupíen Yésuse", "ékélémkúnupíén n"}, + timezones: map[string]string{"CHADT": "CHADT", "OESZ": "OESZ", "AST": "AST", "ADT": "ADT", "WAST": "WAST", "HENOMX": "HENOMX", "WIB": "WIB", "AWST": "AWST", "UYT": "UYT", "UYST": "UYST", "ChST": "ChST", "HEPMX": "HEPMX", "HAT": "HAT", "WITA": "WITA", "WARST": "WARST", "AEST": "AEST", "GMT": "GMT", "HEOG": "HEOG", "EDT": "EDT", "HKST": "HKST", "AKST": "AKST", "IST": "IST", "JDT": "JDT", "NZST": "NZST", "MDT": "MDT", "TMT": "TMT", "TMST": "TMST", "HEEG": "HEEG", "ECT": "ECT", "WESZ": "WESZ", "NZDT": "NZDT", "JST": "JST", "MEZ": "MEZ", "OEZ": "OEZ", "MYT": "MYT", "COST": "COST", "EAT": "EAT", "ACWDT": "ACWDT", "HNPMX": "HNPMX", "SAST": "SAST", "HNNOMX": "HNNOMX", "HNT": "HNT", "BOT": "BOT", "MST": "MST", "VET": "VET", "EST": "EST", "ACDT": "ACDT", "AWDT": "AWDT", "HAST": "HAST", "HKT": "HKT", "BT": "BT", "GFT": "GFT", "∅∅∅": "∅∅∅", "HNOG": "HNOG", "SGT": "SGT", "CLST": "CLST", "WAT": "WAT", "AEDT": "AEDT", "AKDT": "AKDT", "HEPM": "HEPM", "HNCU": "HNCU", "WIT": "WIT", "GYT": "GYT", "LHDT": "LHDT", "SRT": "SRT", "MESZ": "MESZ", "ARST": "ARST", "HNEG": "HNEG", "CST": "CST", "CDT": "CDT", "CHAST": "CHAST", "ACST": "ACST", "CAT": "CAT", "WART": "WART", "CLT": "CLT", "ART": "ART", "COT": "COT", "LHST": "LHST", "PDT": "PDT", "HADT": "HADT", "PST": "PST", "WEZ": "WEZ", "HNPM": "HNPM", "HECU": "HECU", "ACWST": "ACWST"}, + } +} + +// Locale returns the current translators string locale +func (yav *yav_CM) Locale() string { + return yav.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yav_CM' +func (yav *yav_CM) PluralsCardinal() []locales.PluralRule { + return yav.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yav_CM' +func (yav *yav_CM) PluralsOrdinal() []locales.PluralRule { + return yav.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yav_CM' +func (yav *yav_CM) PluralsRange() []locales.PluralRule { + return yav.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yav_CM' +func (yav *yav_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yav_CM' +func (yav *yav_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yav_CM' +func (yav *yav_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yav *yav_CM) MonthAbbreviated(month time.Month) string { + return yav.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yav *yav_CM) MonthsAbbreviated() []string { + return yav.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yav *yav_CM) MonthNarrow(month time.Month) string { + return yav.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yav *yav_CM) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yav *yav_CM) MonthWide(month time.Month) string { + return yav.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yav *yav_CM) MonthsWide() []string { + return yav.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yav *yav_CM) WeekdayAbbreviated(weekday time.Weekday) string { + return yav.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yav *yav_CM) WeekdaysAbbreviated() []string { + return yav.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yav *yav_CM) WeekdayNarrow(weekday time.Weekday) string { + return yav.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yav *yav_CM) WeekdaysNarrow() []string { + return yav.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yav *yav_CM) WeekdayShort(weekday time.Weekday) string { + return yav.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yav *yav_CM) WeekdaysShort() []string { + return yav.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yav *yav_CM) WeekdayWide(weekday time.Weekday) string { + return yav.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yav *yav_CM) WeekdaysWide() []string { + return yav.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yav_CM' and handles both Whole and Real numbers based on 'v' +func (yav *yav_CM) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(yav.group) - 1; j >= 0; j-- { + b = append(b, yav.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yav.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yav_CM' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yav *yav_CM) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 1 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yav.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yav.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yav.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yav_CM' +func (yav *yav_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yav.currencies[currency] + l := len(s) + len(symbol) + 3 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(yav.group) - 1; j >= 0; j-- { + b = append(b, yav.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yav.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yav.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, yav.currencyPositiveSuffix...) + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yav_CM' +// in accounting notation. +func (yav *yav_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yav.currencies[currency] + l := len(s) + len(symbol) + 5 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yav.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(yav.group) - 1; j >= 0; j-- { + b = append(b, yav.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, yav.currencyNegativePrefix[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yav.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, yav.currencyNegativeSuffix...) + b = append(b, symbol...) + } else { + + b = append(b, yav.currencyPositiveSuffix...) + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yav_CM' +func (yav *yav_CM) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yav_CM' +func (yav *yav_CM) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yav.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yav_CM' +func (yav *yav_CM) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yav.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yav_CM' +func (yav *yav_CM) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, yav.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yav.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yav_CM' +func (yav *yav_CM) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yav_CM' +func (yav *yav_CM) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yav_CM' +func (yav *yav_CM) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yav_CM' +func (yav *yav_CM) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yav.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yav.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := yav.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yav_CM/yav_CM_test.go b/vendor/github.com/go-playground/locales/yav_CM/yav_CM_test.go new file mode 100644 index 0000000000..030467dc01 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yav_CM/yav_CM_test.go @@ -0,0 +1,1120 @@ +package yav_CM + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yav_CM" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yi/yi.go b/vendor/github.com/go-playground/locales/yi/yi.go new file mode 100644 index 0000000000..e6c630d70b --- /dev/null +++ b/vendor/github.com/go-playground/locales/yi/yi.go @@ -0,0 +1,505 @@ +package yi + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yi struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yi' locale +func New() locales.Translator { + return &yi{ + locale: "yi", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "יאַנואַר", "פֿעברואַר", "מערץ", "אַפּריל", "מיי", "יוני", "יולי", "אויגוסט", "סעפּטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"}, + monthsWide: []string{"", "יאַנואַר", "פֿעברואַר", "מערץ", "אַפּריל", "מיי", "יוני", "יולי", "אויגוסט", "סעפּטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"}, + daysAbbreviated: []string{"זונטיק", "מאָנטיק", "דינסטיק", "מיטוואך", "דאנערשטיק", "פֿרײַטיק", "שבת"}, + daysShort: []string{"זונטיק", "מאָנטיק", "דינסטיק", "מיטוואך", "דאנערשטיק", "פֿרײַטיק", "שבת"}, + daysWide: []string{"זונטיק", "מאָנטיק", "דינסטיק", "מיטוואך", "דאנערשטיק", "פֿרײַטיק", "שבת"}, + periodsAbbreviated: []string{"פֿאַרמיטאָג", "נאָכמיטאָג"}, + periodsWide: []string{"פֿאַרמיטאָג", "נאָכמיטאָג"}, + timezones: map[string]string{"OEZ": "OEZ", "EST": "EST", "AEST": "AEST", "AWDT": "AWDT", "GMT": "GMT", "CLT": "CLT", "TMT": "TMT", "ChST": "ChST", "UYT": "UYT", "HNCU": "HNCU", "WESZ": "WESZ", "HNNOMX": "HNNOMX", "BT": "BT", "LHDT": "LHDT", "HEPMX": "HEPMX", "JST": "JST", "HKST": "HKST", "EAT": "EAT", "WIB": "WIB", "HAST": "HAST", "JDT": "JDT", "WARST": "WARST", "ART": "ART", "AEDT": "AEDT", "SRT": "SRT", "CHADT": "CHADT", "NZDT": "NZDT", "MDT": "MDT", "BOT": "BOT", "HADT": "HADT", "IST": "IST", "AST": "AST", "ADT": "ADT", "CDT": "CDT", "SGT": "SGT", "PST": "PST", "ACWDT": "ACWDT", "HNT": "HNT", "HAT": "HAT", "AKDT": "AKDT", "HNPM": "HNPM", "HECU": "HECU", "COST": "COST", "HNEG": "HNEG", "HEEG": "HEEG", "∅∅∅": "∅∅∅", "AKST": "AKST", "SAST": "SAST", "ECT": "ECT", "ACWST": "ACWST", "WEZ": "WEZ", "TMST": "TMST", "EDT": "EDT", "GFT": "GFT", "HNPMX": "HNPMX", "AWST": "AWST", "MYT": "MYT", "ARST": "ARST", "WAT": "WAT", "ACDT": "ACDT", "CHAST": "CHAST", "PDT": "PDT", "CAT": "CAT", "MEZ": "MEZ", "WAST": "WAST", "COT": "COT", "HENOMX": "HENOMX", "VET": "VET", "UYST": "UYST", "LHST": "LHST", "CLST": "CLST", "MST": "MST", "HKT": "HKT", "HEPM": "HEPM", "CST": "CST", "NZST": "NZST", "HEOG": "HEOG", "WART": "WART", "ACST": "ACST", "WITA": "WITA", "GYT": "GYT", "WIT": "WIT", "MESZ": "MESZ", "HNOG": "HNOG", "OESZ": "OESZ"}, + } +} + +// Locale returns the current translators string locale +func (yi *yi) Locale() string { + return yi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yi' +func (yi *yi) PluralsCardinal() []locales.PluralRule { + return yi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yi' +func (yi *yi) PluralsOrdinal() []locales.PluralRule { + return yi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yi' +func (yi *yi) PluralsRange() []locales.PluralRule { + return yi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yi' +func (yi *yi) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yi' +func (yi *yi) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yi' +func (yi *yi) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yi *yi) MonthAbbreviated(month time.Month) string { + return yi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yi *yi) MonthsAbbreviated() []string { + return yi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yi *yi) MonthNarrow(month time.Month) string { + return yi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yi *yi) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yi *yi) MonthWide(month time.Month) string { + return yi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yi *yi) MonthsWide() []string { + return yi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yi *yi) WeekdayAbbreviated(weekday time.Weekday) string { + return yi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yi *yi) WeekdaysAbbreviated() []string { + return yi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yi *yi) WeekdayNarrow(weekday time.Weekday) string { + return yi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yi *yi) WeekdaysNarrow() []string { + return yi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yi *yi) WeekdayShort(weekday time.Weekday) string { + return yi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yi *yi) WeekdaysShort() []string { + return yi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yi *yi) WeekdayWide(weekday time.Weekday) string { + return yi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yi *yi) WeekdaysWide() []string { + return yi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yi' and handles both Whole and Real numbers based on 'v' +func (yi *yi) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yi' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yi *yi) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yi' +func (yi *yi) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yi.currencies[currency] + l := len(s) + len(symbol) + 5 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(yi.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, yi.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, yi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yi.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yi' +// in accounting notation. +func (yi *yi) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yi.currencies[currency] + l := len(s) + len(symbol) + 5 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(yi.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, yi.currencyNegativePrefix[j]) + } + + b = append(b, yi.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(yi.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, yi.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, yi.currencyNegativeSuffix...) + } else { + + b = append(b, yi.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yi' +func (yi *yi) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yi' +func (yi *yi) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xd7, 0x98, 0xd7, 0x9f, 0x20}...) + b = append(b, yi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yi' +func (yi *yi) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xd7, 0x98, 0xd7, 0x9f, 0x20}...) + b = append(b, yi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yi' +func (yi *yi) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, yi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xd7, 0x98, 0xd7, 0x9f, 0x20}...) + b = append(b, yi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yi' +func (yi *yi) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yi' +func (yi *yi) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yi' +func (yi *yi) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yi' +func (yi *yi) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := yi.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yi/yi_test.go b/vendor/github.com/go-playground/locales/yi/yi_test.go new file mode 100644 index 0000000000..1b5cdaa99b --- /dev/null +++ b/vendor/github.com/go-playground/locales/yi/yi_test.go @@ -0,0 +1,1120 @@ +package yi + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yi" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yi_001/yi_001.go b/vendor/github.com/go-playground/locales/yi_001/yi_001.go new file mode 100644 index 0000000000..22fcce6385 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yi_001/yi_001.go @@ -0,0 +1,505 @@ +package yi_001 + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yi_001 struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositivePrefix string + currencyPositiveSuffix string + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yi_001' locale +func New() locales.Translator { + return &yi_001{ + locale: "yi_001", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositivePrefix: " ", + currencyPositiveSuffix: "K", + currencyNegativePrefix: " ", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "יאַנואַר", "פֿעברואַר", "מערץ", "אַפּריל", "מיי", "יוני", "יולי", "אויגוסט", "סעפּטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"}, + monthsWide: []string{"", "יאַנואַר", "פֿעברואַר", "מערץ", "אַפּריל", "מיי", "יוני", "יולי", "אויגוסט", "סעפּטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"}, + daysAbbreviated: []string{"זונטיק", "מאָנטיק", "דינסטיק", "מיטוואך", "דאנערשטיק", "פֿרײַטיק", "שבת"}, + daysShort: []string{"זונטיק", "מאָנטיק", "דינסטיק", "מיטוואך", "דאנערשטיק", "פֿרײַטיק", "שבת"}, + daysWide: []string{"זונטיק", "מאָנטיק", "דינסטיק", "מיטוואך", "דאנערשטיק", "פֿרײַטיק", "שבת"}, + periodsAbbreviated: []string{"פֿאַרמיטאָג", "נאָכמיטאָג"}, + periodsWide: []string{"פֿאַרמיטאָג", "נאָכמיטאָג"}, + timezones: map[string]string{"MESZ": "MESZ", "EDT": "EDT", "ECT": "ECT", "WIB": "WIB", "MEZ": "MEZ", "AST": "AST", "HENOMX": "HENOMX", "SAST": "SAST", "CHAST": "CHAST", "CAT": "CAT", "ACST": "ACST", "AEST": "AEST", "HEPMX": "HEPMX", "EAT": "EAT", "AWST": "AWST", "BOT": "BOT", "ACWST": "ACWST", "OEZ": "OEZ", "COST": "COST", "LHST": "LHST", "HECU": "HECU", "SGT": "SGT", "PDT": "PDT", "CLT": "CLT", "∅∅∅": "∅∅∅", "ARST": "ARST", "CST": "CST", "LHDT": "LHDT", "SRT": "SRT", "HNCU": "HNCU", "NZDT": "NZDT", "MYT": "MYT", "HKT": "HKT", "WITA": "WITA", "HNT": "HNT", "HEOG": "HEOG", "ART": "ART", "EST": "EST", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "BT": "BT", "GFT": "GFT", "UYST": "UYST", "HEPM": "HEPM", "HNPMX": "HNPMX", "CDT": "CDT", "HADT": "HADT", "IST": "IST", "HAT": "HAT", "AWDT": "AWDT", "WART": "WART", "HNOG": "HNOG", "TMST": "TMST", "HKST": "HKST", "HEEG": "HEEG", "HAST": "HAST", "VET": "VET", "JDT": "JDT", "OESZ": "OESZ", "HNPM": "HNPM", "UYT": "UYT", "WAT": "WAT", "MDT": "MDT", "AKST": "AKST", "ChST": "ChST", "WIT": "WIT", "ADT": "ADT", "WEZ": "WEZ", "COT": "COT", "MST": "MST", "NZST": "NZST", "AKDT": "AKDT", "CHADT": "CHADT", "ACWDT": "ACWDT", "WARST": "WARST", "CLST": "CLST", "TMT": "TMT", "HNEG": "HNEG", "GYT": "GYT", "PST": "PST", "JST": "JST", "WESZ": "WESZ", "GMT": "GMT", "WAST": "WAST", "AEDT": "AEDT"}, + } +} + +// Locale returns the current translators string locale +func (yi *yi_001) Locale() string { + return yi.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yi_001' +func (yi *yi_001) PluralsCardinal() []locales.PluralRule { + return yi.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yi_001' +func (yi *yi_001) PluralsOrdinal() []locales.PluralRule { + return yi.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yi_001' +func (yi *yi_001) PluralsRange() []locales.PluralRule { + return yi.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yi_001' +func (yi *yi_001) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if i == 1 && v == 0 { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yi_001' +func (yi *yi_001) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yi_001' +func (yi *yi_001) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yi *yi_001) MonthAbbreviated(month time.Month) string { + return yi.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yi *yi_001) MonthsAbbreviated() []string { + return yi.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yi *yi_001) MonthNarrow(month time.Month) string { + return yi.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yi *yi_001) MonthsNarrow() []string { + return nil +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yi *yi_001) MonthWide(month time.Month) string { + return yi.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yi *yi_001) MonthsWide() []string { + return yi.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yi *yi_001) WeekdayAbbreviated(weekday time.Weekday) string { + return yi.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yi *yi_001) WeekdaysAbbreviated() []string { + return yi.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yi *yi_001) WeekdayNarrow(weekday time.Weekday) string { + return yi.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yi *yi_001) WeekdaysNarrow() []string { + return yi.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yi *yi_001) WeekdayShort(weekday time.Weekday) string { + return yi.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yi *yi_001) WeekdaysShort() []string { + return yi.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yi *yi_001) WeekdayWide(weekday time.Weekday) string { + return yi.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yi *yi_001) WeekdaysWide() []string { + return yi.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yi_001' and handles both Whole and Real numbers based on 'v' +func (yi *yi_001) FmtNumber(num float64, v uint64) string { + + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yi_001' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yi *yi_001) FmtPercent(num float64, v uint64) string { + return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yi_001' +func (yi *yi_001) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yi.currencies[currency] + l := len(s) + len(symbol) + 5 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(yi.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, yi.currencyPositivePrefix[j]) + } + + if num < 0 { + b = append(b, yi.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yi.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yi_001' +// in accounting notation. +func (yi *yi_001) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yi.currencies[currency] + l := len(s) + len(symbol) + 5 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yi.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(yi.currencyNegativePrefix) - 1; j >= 0; j-- { + b = append(b, yi.currencyNegativePrefix[j]) + } + + b = append(b, yi.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + for j := len(yi.currencyPositivePrefix) - 1; j >= 0; j-- { + b = append(b, yi.currencyPositivePrefix[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, yi.currencyNegativeSuffix...) + } else { + + b = append(b, yi.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yi_001' +func (yi *yi_001) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yi_001' +func (yi *yi_001) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xd7, 0x98, 0xd7, 0x9f, 0x20}...) + b = append(b, yi.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yi_001' +func (yi *yi_001) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xd7, 0x98, 0xd7, 0x9f, 0x20}...) + b = append(b, yi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yi_001' +func (yi *yi_001) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, yi.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xd7, 0x98, 0xd7, 0x9f, 0x20}...) + b = append(b, yi.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yi_001' +func (yi *yi_001) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yi_001' +func (yi *yi_001) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yi_001' +func (yi *yi_001) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yi_001' +func (yi *yi_001) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yi.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yi.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := yi.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yi_001/yi_001_test.go b/vendor/github.com/go-playground/locales/yi_001/yi_001_test.go new file mode 100644 index 0000000000..d76c9bb36e --- /dev/null +++ b/vendor/github.com/go-playground/locales/yi_001/yi_001_test.go @@ -0,0 +1,1120 @@ +package yi_001 + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yi_001" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yo/yo.go b/vendor/github.com/go-playground/locales/yo/yo.go new file mode 100644 index 0000000000..7a1b6628e5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yo/yo.go @@ -0,0 +1,585 @@ +package yo + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yo struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yo' locale +func New() locales.Translator { + return &yo{ + locale: "yo", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "₦", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ṣẹ́rẹ́", "Èrèlè", "Ẹrẹ̀nà", "Ìgbé", "Ẹ̀bibi", "Òkúdu", "Agẹmọ", "Ògún", "Owewe", "Ọ̀wàrà", "Bélú", "Ọ̀pẹ̀"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Oṣù Ṣẹ́rẹ́", "Oṣù Èrèlè", "Oṣù Ẹrẹ̀nà", "Oṣù Ìgbé", "Oṣù Ẹ̀bibi", "Oṣù Òkúdu", "Oṣù Agẹmọ", "Oṣù Ògún", "Oṣù Owewe", "Oṣù Ọ̀wàrà", "Oṣù Bélú", "Oṣù Ọ̀pẹ̀"}, + daysAbbreviated: []string{"Àìkú", "Ajé", "Ìsẹ́gun", "Ọjọ́rú", "Ọjọ́bọ", "Ẹtì", "Àbámẹ́ta"}, + daysShort: []string{"Àìkú", "Ajé", "Ìsẹ́gun", "Ọjọ́rú", "Ọjọ́bọ", "Ẹtì", "Àbámẹ́ta"}, + daysWide: []string{"Ọjọ́ Àìkú", "Ọjọ́ Ajé", "Ọjọ́ Ìsẹ́gun", "Ọjọ́rú", "Ọjọ́bọ", "Ọjọ́ Ẹtì", "Ọjọ́ Àbámẹ́ta"}, + periodsAbbreviated: []string{"Àárọ̀", "Ọ̀sán"}, + periodsNarrow: []string{"Àárọ̀", "Ọ̀sán"}, + periodsWide: []string{"Àárọ̀", "Ọ̀sán"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Saju Kristi", "Lehin Kristi"}, + timezones: map[string]string{"WEZ": "WEZ", "COT": "COT", "COST": "COST", "ChST": "ChST", "LHST": "LHST", "SRT": "SRT", "WIB": "WIB", "MYT": "MYT", "CLT": "CLT", "TMST": "TMST", "ACWDT": "ACWDT", "GMT": "GMT", "ARST": "ARST", "WAT": "WAT", "EST": "EST", "GFT": "GFT", "HEOG": "HEOG", "LHDT": "LHDT", "HAST": "HAST", "CAT": "CAT", "IST": "IST", "ACDT": "ACDT", "AEST": "AEST", "HECU": "HECU", "NZST": "NZST", "WESZ": "WESZ", "MDT": "MDT", "ART": "ART", "HNNOMX": "HNNOMX", "∅∅∅": "∅∅∅", "PST": "PST", "HENOMX": "HENOMX", "CDT": "CDT", "VET": "VET", "ADT": "ADT", "AKDT": "AKDT", "AST": "AST", "BT": "BT", "AKST": "AKST", "HNCU": "HNCU", "CHADT": "CHADT", "HADT": "HADT", "OEZ": "OEZ", "HEPM": "HEPM", "CST": "CST", "JDT": "JDT", "OESZ": "OESZ", "HKT": "HKT", "SAST": "SAST", "AWST": "AWST", "PDT": "PDT", "BOT": "BOT", "TMT": "TMT", "ACST": "ACST", "HNEG": "HNEG", "UYST": "UYST", "HNPM": "HNPM", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "ECT": "ECT", "WARST": "WARST", "CLST": "CLST", "HKST": "HKST", "HAT": "HAT", "UYT": "UYT", "NZDT": "NZDT", "EDT": "EDT", "WITA": "WITA", "AWDT": "AWDT", "CHAST": "CHAST", "MESZ": "MESZ", "MST": "MST", "HNT": "HNT", "HEEG": "HEEG", "AEDT": "AEDT", "GYT": "GYT", "JST": "JST", "MEZ": "MEZ", "HNOG": "HNOG", "WART": "WART", "WAST": "WAST", "EAT": "EAT", "WIT": "WIT", "SGT": "SGT", "ACWST": "ACWST"}, + } +} + +// Locale returns the current translators string locale +func (yo *yo) Locale() string { + return yo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yo' +func (yo *yo) PluralsCardinal() []locales.PluralRule { + return yo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yo' +func (yo *yo) PluralsOrdinal() []locales.PluralRule { + return yo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yo' +func (yo *yo) PluralsRange() []locales.PluralRule { + return yo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yo' +func (yo *yo) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yo' +func (yo *yo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yo' +func (yo *yo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yo *yo) MonthAbbreviated(month time.Month) string { + return yo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yo *yo) MonthsAbbreviated() []string { + return yo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yo *yo) MonthNarrow(month time.Month) string { + return yo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yo *yo) MonthsNarrow() []string { + return yo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yo *yo) MonthWide(month time.Month) string { + return yo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yo *yo) MonthsWide() []string { + return yo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yo *yo) WeekdayAbbreviated(weekday time.Weekday) string { + return yo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yo *yo) WeekdaysAbbreviated() []string { + return yo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yo *yo) WeekdayNarrow(weekday time.Weekday) string { + return yo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yo *yo) WeekdaysNarrow() []string { + return yo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yo *yo) WeekdayShort(weekday time.Weekday) string { + return yo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yo *yo) WeekdaysShort() []string { + return yo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yo *yo) WeekdayWide(weekday time.Weekday) string { + return yo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yo *yo) WeekdaysWide() []string { + return yo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yo' and handles both Whole and Real numbers based on 'v' +func (yo *yo) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yo' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yo *yo) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yo' +func (yo *yo) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yo.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yo' +// in accounting notation. +func (yo *yo) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, yo.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, yo.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yo' +func (yo *yo) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yo' +func (yo *yo) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yo' +func (yo *yo) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yo' +func (yo *yo) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, yo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yo' +func (yo *yo) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yo' +func (yo *yo) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yo' +func (yo *yo) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yo' +func (yo *yo) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := yo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yo/yo_test.go b/vendor/github.com/go-playground/locales/yo/yo_test.go new file mode 100644 index 0000000000..eb7a5289dc --- /dev/null +++ b/vendor/github.com/go-playground/locales/yo/yo_test.go @@ -0,0 +1,1120 @@ +package yo + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yo" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yo_BJ/yo_BJ.go b/vendor/github.com/go-playground/locales/yo_BJ/yo_BJ.go new file mode 100644 index 0000000000..987bf2bbc4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yo_BJ/yo_BJ.go @@ -0,0 +1,585 @@ +package yo_BJ + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yo_BJ struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yo_BJ' locale +func New() locales.Translator { + return &yo_BJ{ + locale: "yo_BJ", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Shɛ́rɛ́", "Èrèlè", "Ɛrɛ̀nà", "Ìgbé", "Ɛ̀bibi", "Òkúdu", "Agɛmɔ", "Ògún", "Owewe", "Ɔ̀wàrà", "Bélú", "Ɔ̀pɛ̀"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Oshù Shɛ́rɛ́", "Oshù Èrèlè", "Oshù Ɛrɛ̀nà", "Oshù Ìgbé", "Oshù Ɛ̀bibi", "Oshù Òkúdu", "Oshù Agɛmɔ", "Oshù Ògún", "Oshù Owewe", "Oshù Ɔ̀wàrà", "Oshù Bélú", "Oshù Ɔ̀pɛ̀"}, + daysAbbreviated: []string{"Àìkú", "Ajé", "Ìsɛ́gun", "Ɔjɔ́rú", "Ɔjɔ́bɔ", "Ɛtì", "Àbámɛ́ta"}, + daysShort: []string{"Àìkú", "Ajé", "Ìsɛ́gun", "Ɔjɔ́rú", "Ɔjɔ́bɔ", "Ɛtì", "Àbámɛ́ta"}, + daysWide: []string{"Ɔjɔ́ Àìkú", "Ɔjɔ́ Ajé", "Ɔjɔ́ Ìsɛ́gun", "Ɔjɔ́rú", "Ɔjɔ́bɔ", "Ɔjɔ́ Ɛtì", "Ɔjɔ́ Àbámɛ́ta"}, + periodsAbbreviated: []string{"Àárɔ̀", "Ɔ̀sán"}, + periodsNarrow: []string{"Àárɔ̀", "Ɔ̀sán"}, + periodsWide: []string{"Àárɔ̀", "Ɔ̀sán"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Saju Kristi", "Lehin Kristi"}, + timezones: map[string]string{"HAT": "HAT", "ACWST": "ACWST", "ADT": "ADT", "TMT": "TMT", "HADT": "HADT", "WARST": "WARST", "ARST": "ARST", "AEDT": "AEDT", "HEPMX": "HEPMX", "AWST": "AWST", "WESZ": "WESZ", "ART": "ART", "WAST": "WAST", "EST": "EST", "HKST": "HKST", "CDT": "CDT", "BOT": "BOT", "HNOG": "HNOG", "HENOMX": "HENOMX", "BT": "BT", "HNT": "HNT", "CHADT": "CHADT", "IST": "IST", "UYT": "UYT", "HEPM": "HEPM", "GYT": "GYT", "COST": "COST", "HECU": "HECU", "OESZ": "OESZ", "EDT": "EDT", "COT": "COT", "AEST": "AEST", "HNCU": "HNCU", "MESZ": "MESZ", "HNPM": "HNPM", "SRT": "SRT", "HNNOMX": "HNNOMX", "CAT": "CAT", "GMT": "GMT", "TMST": "TMST", "HEEG": "HEEG", "HNPMX": "HNPMX", "CST": "CST", "HAST": "HAST", "LHST": "LHST", "ECT": "ECT", "HEOG": "HEOG", "WAT": "WAT", "HKT": "HKT", "HNEG": "HNEG", "GFT": "GFT", "MEZ": "MEZ", "MYT": "MYT", "WIT": "WIT", "PST": "PST", "ACWDT": "ACWDT", "NZDT": "NZDT", "CLST": "CLST", "WITA": "WITA", "AKDT": "AKDT", "∅∅∅": "∅∅∅", "OEZ": "OEZ", "SGT": "SGT", "PDT": "PDT", "NZST": "NZST", "WEZ": "WEZ", "MST": "MST", "SAST": "SAST", "EAT": "EAT", "ChST": "ChST", "WIB": "WIB", "WART": "WART", "AWDT": "AWDT", "ACST": "ACST", "CHAST": "CHAST", "JST": "JST", "JDT": "JDT", "CLT": "CLT", "ACDT": "ACDT", "AKST": "AKST", "UYST": "UYST", "LHDT": "LHDT", "MDT": "MDT", "VET": "VET", "AST": "AST"}, + } +} + +// Locale returns the current translators string locale +func (yo *yo_BJ) Locale() string { + return yo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yo_BJ' +func (yo *yo_BJ) PluralsCardinal() []locales.PluralRule { + return yo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yo_BJ' +func (yo *yo_BJ) PluralsOrdinal() []locales.PluralRule { + return yo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yo_BJ' +func (yo *yo_BJ) PluralsRange() []locales.PluralRule { + return yo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yo_BJ' +func (yo *yo_BJ) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yo_BJ' +func (yo *yo_BJ) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yo_BJ' +func (yo *yo_BJ) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yo *yo_BJ) MonthAbbreviated(month time.Month) string { + return yo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yo *yo_BJ) MonthsAbbreviated() []string { + return yo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yo *yo_BJ) MonthNarrow(month time.Month) string { + return yo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yo *yo_BJ) MonthsNarrow() []string { + return yo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yo *yo_BJ) MonthWide(month time.Month) string { + return yo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yo *yo_BJ) MonthsWide() []string { + return yo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yo *yo_BJ) WeekdayAbbreviated(weekday time.Weekday) string { + return yo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yo *yo_BJ) WeekdaysAbbreviated() []string { + return yo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yo *yo_BJ) WeekdayNarrow(weekday time.Weekday) string { + return yo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yo *yo_BJ) WeekdaysNarrow() []string { + return yo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yo *yo_BJ) WeekdayShort(weekday time.Weekday) string { + return yo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yo *yo_BJ) WeekdaysShort() []string { + return yo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yo *yo_BJ) WeekdayWide(weekday time.Weekday) string { + return yo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yo *yo_BJ) WeekdaysWide() []string { + return yo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yo_BJ' and handles both Whole and Real numbers based on 'v' +func (yo *yo_BJ) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yo_BJ' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yo *yo_BJ) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yo_BJ' +func (yo *yo_BJ) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yo.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yo_BJ' +// in accounting notation. +func (yo *yo_BJ) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, yo.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, yo.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yo_BJ' +func (yo *yo_BJ) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yo_BJ' +func (yo *yo_BJ) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yo_BJ' +func (yo *yo_BJ) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yo_BJ' +func (yo *yo_BJ) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, yo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yo_BJ' +func (yo *yo_BJ) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yo_BJ' +func (yo *yo_BJ) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yo_BJ' +func (yo *yo_BJ) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yo_BJ' +func (yo *yo_BJ) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := yo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yo_BJ/yo_BJ_test.go b/vendor/github.com/go-playground/locales/yo_BJ/yo_BJ_test.go new file mode 100644 index 0000000000..1724f00156 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yo_BJ/yo_BJ_test.go @@ -0,0 +1,1120 @@ +package yo_BJ + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yo_BJ" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yo_NG/yo_NG.go b/vendor/github.com/go-playground/locales/yo_NG/yo_NG.go new file mode 100644 index 0000000000..df4f6b6ecb --- /dev/null +++ b/vendor/github.com/go-playground/locales/yo_NG/yo_NG.go @@ -0,0 +1,585 @@ +package yo_NG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yo_NG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yo_NG' locale +func New() locales.Translator { + return &yo_NG{ + locale: "yo_NG", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Ṣẹ́rẹ́", "Èrèlè", "Ẹrẹ̀nà", "Ìgbé", "Ẹ̀bibi", "Òkúdu", "Agẹmọ", "Ògún", "Owewe", "Ọ̀wàrà", "Bélú", "Ọ̀pẹ̀"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "Oṣù Ṣẹ́rẹ́", "Oṣù Èrèlè", "Oṣù Ẹrẹ̀nà", "Oṣù Ìgbé", "Oṣù Ẹ̀bibi", "Oṣù Òkúdu", "Oṣù Agẹmọ", "Oṣù Ògún", "Oṣù Owewe", "Oṣù Ọ̀wàrà", "Oṣù Bélú", "Oṣù Ọ̀pẹ̀"}, + daysAbbreviated: []string{"Àìkú", "Ajé", "Ìsẹ́gun", "Ọjọ́rú", "Ọjọ́bọ", "Ẹtì", "Àbámẹ́ta"}, + daysShort: []string{"Àìkú", "Ajé", "Ìsẹ́gun", "Ọjọ́rú", "Ọjọ́bọ", "Ẹtì", "Àbámẹ́ta"}, + daysWide: []string{"Ọjọ́ Àìkú", "Ọjọ́ Ajé", "Ọjọ́ Ìsẹ́gun", "Ọjọ́rú", "Ọjọ́bọ", "Ọjọ́ Ẹtì", "Ọjọ́ Àbámẹ́ta"}, + periodsAbbreviated: []string{"Àárọ̀", "Ọ̀sán"}, + periodsNarrow: []string{"Àárọ̀", "Ọ̀sán"}, + periodsWide: []string{"Àárọ̀", "Ọ̀sán"}, + erasAbbreviated: []string{"", ""}, + erasNarrow: []string{"", ""}, + erasWide: []string{"Saju Kristi", "Lehin Kristi"}, + timezones: map[string]string{"TMT": "TMT", "WIT": "WIT", "HAST": "HAST", "NZDT": "NZDT", "AST": "AST", "WESZ": "WESZ", "HNEG": "HNEG", "UYT": "UYT", "HNPM": "HNPM", "HNCU": "HNCU", "BOT": "BOT", "WAT": "WAT", "CDT": "CDT", "ACWST": "ACWST", "UYST": "UYST", "WEZ": "WEZ", "ART": "ART", "EST": "EST", "∅∅∅": "∅∅∅", "AKST": "AKST", "WITA": "WITA", "ChST": "ChST", "WIB": "WIB", "AWDT": "AWDT", "MST": "MST", "SAST": "SAST", "HADT": "HADT", "OESZ": "OESZ", "EDT": "EDT", "HEPMX": "HEPMX", "PDT": "PDT", "MEZ": "MEZ", "WARST": "WARST", "COST": "COST", "BT": "BT", "GFT": "GFT", "SRT": "SRT", "AWST": "AWST", "CHADT": "CHADT", "MESZ": "MESZ", "ADT": "ADT", "HNPMX": "HNPMX", "HECU": "HECU", "PST": "PST", "JDT": "JDT", "WART": "WART", "CLT": "CLT", "HNOG": "HNOG", "COT": "COT", "HEPM": "HEPM", "SGT": "SGT", "ACWDT": "ACWDT", "HEOG": "HEOG", "TMST": "TMST", "MDT": "MDT", "AKDT": "AKDT", "LHST": "LHST", "CST": "CST", "CLST": "CLST", "WAST": "WAST", "HKT": "HKT", "HENOMX": "HENOMX", "AEDT": "AEDT", "ECT": "ECT", "CAT": "CAT", "OEZ": "OEZ", "HKST": "HKST", "ACDT": "ACDT", "HNNOMX": "HNNOMX", "HNT": "HNT", "HEEG": "HEEG", "AEST": "AEST", "GYT": "GYT", "MYT": "MYT", "NZST": "NZST", "JST": "JST", "ACST": "ACST", "EAT": "EAT", "CHAST": "CHAST", "VET": "VET", "GMT": "GMT", "ARST": "ARST", "HAT": "HAT", "LHDT": "LHDT", "IST": "IST"}, + } +} + +// Locale returns the current translators string locale +func (yo *yo_NG) Locale() string { + return yo.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yo_NG' +func (yo *yo_NG) PluralsCardinal() []locales.PluralRule { + return yo.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yo_NG' +func (yo *yo_NG) PluralsOrdinal() []locales.PluralRule { + return yo.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yo_NG' +func (yo *yo_NG) PluralsRange() []locales.PluralRule { + return yo.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yo_NG' +func (yo *yo_NG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yo_NG' +func (yo *yo_NG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yo_NG' +func (yo *yo_NG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yo *yo_NG) MonthAbbreviated(month time.Month) string { + return yo.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yo *yo_NG) MonthsAbbreviated() []string { + return yo.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yo *yo_NG) MonthNarrow(month time.Month) string { + return yo.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yo *yo_NG) MonthsNarrow() []string { + return yo.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yo *yo_NG) MonthWide(month time.Month) string { + return yo.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yo *yo_NG) MonthsWide() []string { + return yo.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yo *yo_NG) WeekdayAbbreviated(weekday time.Weekday) string { + return yo.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yo *yo_NG) WeekdaysAbbreviated() []string { + return yo.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yo *yo_NG) WeekdayNarrow(weekday time.Weekday) string { + return yo.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yo *yo_NG) WeekdaysNarrow() []string { + return yo.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yo *yo_NG) WeekdayShort(weekday time.Weekday) string { + return yo.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yo *yo_NG) WeekdaysShort() []string { + return yo.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yo *yo_NG) WeekdayWide(weekday time.Weekday) string { + return yo.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yo *yo_NG) WeekdaysWide() []string { + return yo.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yo_NG' and handles both Whole and Real numbers based on 'v' +func (yo *yo_NG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yo_NG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yo *yo_NG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yo.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yo_NG' +func (yo *yo_NG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yo.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, yo.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yo_NG' +// in accounting notation. +func (yo *yo_NG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yo.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yo.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yo.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, yo.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yo.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, yo.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yo_NG' +func (yo *yo_NG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yo_NG' +func (yo *yo_NG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yo_NG' +func (yo *yo_NG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yo_NG' +func (yo *yo_NG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, yo.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, yo.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yo_NG' +func (yo *yo_NG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yo_NG' +func (yo *yo_NG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yo_NG' +func (yo *yo_NG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yo_NG' +func (yo *yo_NG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, yo.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yo.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := yo.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yo_NG/yo_NG_test.go b/vendor/github.com/go-playground/locales/yo_NG/yo_NG_test.go new file mode 100644 index 0000000000..95fa4a0812 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yo_NG/yo_NG_test.go @@ -0,0 +1,1120 @@ +package yo_NG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yo_NG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yue/yue.go b/vendor/github.com/go-playground/locales/yue/yue.go new file mode 100644 index 0000000000..5bb8c9e024 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yue/yue.go @@ -0,0 +1,606 @@ +package yue + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yue struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yue' locale +func New() locales.Translator { + return &yue{ + locale: "yue", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + daysAbbreviated: []string{"週日", "週一", "週二", "週三", "週四", "週五", "週六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"西元前", "西元"}, + erasNarrow: []string{"西元前", "西元"}, + erasWide: []string{"西元前", "西元"}, + timezones: map[string]string{"HEEG": "格陵蘭東部夏令時間", "WITA": "印尼中部時間", "WIT": "印尼東部時間", "AWST": "澳洲西部標準時間", "NZDT": "紐西蘭夏令時間", "JST": "日本標準時間", "CLST": "智利夏令時間", "OESZ": "東歐夏令時間", "WESZ": "西歐夏令時間", "UYT": "烏拉圭標準時間", "LHST": "豪勳爵島標準時間", "HNPMX": "墨西哥太平洋標準時間", "SGT": "新加坡標準時間", "EST": "東部標準時間", "HNNOMX": "墨西哥西北部標準時間", "SAST": "南非標準時間", "PDT": "太平洋夏令時間", "BT": "不丹時間", "AKDT": "阿拉斯加夏令時間", "ChST": "查莫洛時間", "CDT": "中部夏令時間", "NZST": "紐西蘭標準時間", "JDT": "日本夏令時間", "MYT": "馬來西亞時間", "HENOMX": "墨西哥西北部夏令時間", "TMST": "土庫曼夏令時間", "ART": "阿根廷標準時間", "HAT": "紐芬蘭夏令時間", "HNPM": "聖皮埃爾和密克隆群島標準時間", "AST": "大西洋標準時間", "HEPM": "聖皮埃爾和密克隆群島夏令時間", "HAST": "夏威夷-阿留申標準時間", "ACWDT": "澳洲中西部夏令時間", "OEZ": "東歐標準時間", "COT": "哥倫比亞標準時間", "HNT": "紐芬蘭標準時間", "HECU": "古巴夏令時間", "WIB": "印尼西部時間", "CHADT": "查坦群島夏令時間", "AEST": "澳洲東部標準時間", "GFT": "法屬圭亞那時間", "GYT": "蓋亞那時間", "BOT": "玻利維亞時間", "IST": "印度標準時間", "HNOG": "格陵蘭西部標準時間", "HNCU": "古巴標準時間", "HADT": "夏威夷-阿留申夏令時間", "MESZ": "中歐夏令時間", "WARST": "阿根廷西部夏令時間", "WAT": "西非標準時間", "HNEG": "格陵蘭東部標準時間", "HKST": "香港夏令時間", "AKST": "阿拉斯加標準時間", "EAT": "東非時間", "CHAST": "查坦群島標準時間", "ECT": "厄瓜多時間", "PST": "太平洋標準時間", "ACWST": "澳洲中西部標準時間", "WART": "阿根廷西部標準時間", "HEOG": "格陵蘭西部夏令時間", "MST": "澳門標準時間", "WAST": "西非夏令時間", "UYST": "烏拉圭夏令時間", "HEPMX": "墨西哥太平洋夏令時間", "MEZ": "中歐標準時間", "CLT": "智利標準時間", "ADT": "大西洋夏令時間", "TMT": "土庫曼標準時間", "MDT": "澳門夏令時間", "ARST": "阿根廷夏令時間", "ACDT": "澳洲中部夏令時間", "AEDT": "澳洲東部夏令時間", "LHDT": "豪勳爵島夏令時間", "∅∅∅": "亞馬遜夏令時間", "VET": "委內瑞拉時間", "ACST": "澳洲中部標準時間", "COST": "哥倫比亞夏令時間", "AWDT": "澳洲西部夏令時間", "CAT": "中非時間", "GMT": "格林威治標準時間", "WEZ": "西歐標準時間", "EDT": "東部夏令時間", "HKT": "香港標準時間", "SRT": "蘇利南時間", "CST": "中部標準時間"}, + } +} + +// Locale returns the current translators string locale +func (yue *yue) Locale() string { + return yue.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yue' +func (yue *yue) PluralsCardinal() []locales.PluralRule { + return yue.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yue' +func (yue *yue) PluralsOrdinal() []locales.PluralRule { + return yue.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yue' +func (yue *yue) PluralsRange() []locales.PluralRule { + return yue.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yue' +func (yue *yue) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yue' +func (yue *yue) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yue' +func (yue *yue) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yue *yue) MonthAbbreviated(month time.Month) string { + return yue.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yue *yue) MonthsAbbreviated() []string { + return yue.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yue *yue) MonthNarrow(month time.Month) string { + return yue.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yue *yue) MonthsNarrow() []string { + return yue.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yue *yue) MonthWide(month time.Month) string { + return yue.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yue *yue) MonthsWide() []string { + return yue.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yue *yue) WeekdayAbbreviated(weekday time.Weekday) string { + return yue.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yue *yue) WeekdaysAbbreviated() []string { + return yue.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yue *yue) WeekdayNarrow(weekday time.Weekday) string { + return yue.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yue *yue) WeekdaysNarrow() []string { + return yue.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yue *yue) WeekdayShort(weekday time.Weekday) string { + return yue.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yue *yue) WeekdaysShort() []string { + return yue.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yue *yue) WeekdayWide(weekday time.Weekday) string { + return yue.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yue *yue) WeekdaysWide() []string { + return yue.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yue' and handles both Whole and Real numbers based on 'v' +func (yue *yue) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yue.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yue.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yue.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yue' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yue *yue) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yue.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yue.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yue.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yue' +func (yue *yue) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yue.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yue.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yue.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, yue.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yue.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yue' +// in accounting notation. +func (yue *yue) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yue.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yue.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yue.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, yue.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yue.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yue' +func (yue *yue) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yue' +func (yue *yue) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yue' +func (yue *yue) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yue' +func (yue *yue) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5, 0x20}...) + b = append(b, yue.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yue' +func (yue *yue) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, yue.periodsAbbreviated[0]...) + } else { + b = append(b, yue.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, yue.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yue' +func (yue *yue) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, yue.periodsAbbreviated[0]...) + } else { + b = append(b, yue.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, yue.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yue.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yue' +func (yue *yue) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, yue.periodsAbbreviated[0]...) + } else { + b = append(b, yue.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, yue.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yue.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x5b}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x5d}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yue' +func (yue *yue) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, yue.periodsAbbreviated[0]...) + } else { + b = append(b, yue.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, yue.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yue.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x5b}...) + + tz, _ := t.Zone() + + if btz, ok := yue.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x5d}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yue/yue_test.go b/vendor/github.com/go-playground/locales/yue/yue_test.go new file mode 100644 index 0000000000..bd89d49eba --- /dev/null +++ b/vendor/github.com/go-playground/locales/yue/yue_test.go @@ -0,0 +1,1120 @@ +package yue + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yue" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/yue_HK/yue_HK.go b/vendor/github.com/go-playground/locales/yue_HK/yue_HK.go new file mode 100644 index 0000000000..0ee508dd57 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yue_HK/yue_HK.go @@ -0,0 +1,606 @@ +package yue_HK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type yue_HK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'yue_HK' locale +func New() locales.Translator { + return &yue_HK{ + locale: "yue_HK", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + daysAbbreviated: []string{"週日", "週一", "週二", "週三", "週四", "週五", "週六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"西元前", "西元"}, + erasNarrow: []string{"西元前", "西元"}, + erasWide: []string{"西元前", "西元"}, + timezones: map[string]string{"HEPM": "聖皮埃爾和密克隆群島夏令時間", "WIB": "印尼西部時間", "CHADT": "查坦群島夏令時間", "SGT": "新加坡標準時間", "NZDT": "紐西蘭夏令時間", "BT": "不丹時間", "HAT": "紐芬蘭夏令時間", "HEEG": "格陵蘭東部夏令時間", "SAST": "南非標準時間", "LHST": "豪勳爵島標準時間", "GYT": "蓋亞那時間", "HNCU": "古巴標準時間", "CAT": "中非時間", "HEOG": "格陵蘭西部夏令時間", "HKST": "香港夏令時間", "CHAST": "查坦群島標準時間", "GMT": "格林威治標準時間", "WARST": "阿根廷西部夏令時間", "WESZ": "西歐夏令時間", "ART": "阿根廷標準時間", "COST": "哥倫比亞夏令時間", "HNPMX": "墨西哥太平洋標準時間", "AST": "大西洋標準時間", "MDT": "澳門夏令時間", "HNNOMX": "墨西哥西北部標準時間", "WITA": "印尼中部時間", "HNPM": "聖皮埃爾和密克隆群島標準時間", "SRT": "蘇利南時間", "OEZ": "東歐標準時間", "OESZ": "東歐夏令時間", "HENOMX": "墨西哥西北部夏令時間", "AKDT": "阿拉斯加夏令時間", "WIT": "印尼東部時間", "HAST": "夏威夷-阿留申標準時間", "IST": "印度標準時間", "JDT": "日本夏令時間", "GFT": "法屬圭亞那時間", "MEZ": "中歐標準時間", "CLT": "智利標準時間", "HNT": "紐芬蘭標準時間", "HECU": "古巴夏令時間", "AWST": "澳洲西部標準時間", "VET": "委內瑞拉時間", "WEZ": "西歐標準時間", "AEST": "澳洲東部標準時間", "PDT": "太平洋夏令時間", "WAST": "西非夏令時間", "ACST": "澳洲中部標準時間", "ACDT": "澳洲中部夏令時間", "UYT": "烏拉圭標準時間", "EST": "東部標準時間", "∅∅∅": "亞速爾群島夏令時間", "BOT": "玻利維亞時間", "ECT": "厄瓜多時間", "MYT": "馬來西亞時間", "WART": "阿根廷西部標準時間", "AEDT": "澳洲東部夏令時間", "CDT": "中部夏令時間", "ACWDT": "澳洲中西部夏令時間", "MST": "澳門標準時間", "PST": "太平洋標準時間", "HADT": "夏威夷-阿留申夏令時間", "COT": "哥倫比亞標準時間", "AKST": "阿拉斯加標準時間", "TMT": "土庫曼標準時間", "ChST": "查莫洛時間", "LHDT": "豪勳爵島夏令時間", "HEPMX": "墨西哥太平洋夏令時間", "EAT": "東非時間", "MESZ": "中歐夏令時間", "JST": "日本標準時間", "ADT": "大西洋夏令時間", "HNEG": "格陵蘭東部標準時間", "UYST": "烏拉圭夏令時間", "CST": "中部標準時間", "NZST": "紐西蘭標準時間", "ACWST": "澳洲中西部標準時間", "TMST": "土庫曼夏令時間", "HKT": "香港標準時間", "AWDT": "澳洲西部夏令時間", "CLST": "智利夏令時間", "HNOG": "格陵蘭西部標準時間", "ARST": "阿根廷夏令時間", "WAT": "西非標準時間", "EDT": "東部夏令時間"}, + } +} + +// Locale returns the current translators string locale +func (yue *yue_HK) Locale() string { + return yue.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'yue_HK' +func (yue *yue_HK) PluralsCardinal() []locales.PluralRule { + return yue.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'yue_HK' +func (yue *yue_HK) PluralsOrdinal() []locales.PluralRule { + return yue.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'yue_HK' +func (yue *yue_HK) PluralsRange() []locales.PluralRule { + return yue.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'yue_HK' +func (yue *yue_HK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'yue_HK' +func (yue *yue_HK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'yue_HK' +func (yue *yue_HK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (yue *yue_HK) MonthAbbreviated(month time.Month) string { + return yue.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (yue *yue_HK) MonthsAbbreviated() []string { + return yue.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (yue *yue_HK) MonthNarrow(month time.Month) string { + return yue.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (yue *yue_HK) MonthsNarrow() []string { + return yue.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (yue *yue_HK) MonthWide(month time.Month) string { + return yue.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (yue *yue_HK) MonthsWide() []string { + return yue.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (yue *yue_HK) WeekdayAbbreviated(weekday time.Weekday) string { + return yue.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (yue *yue_HK) WeekdaysAbbreviated() []string { + return yue.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (yue *yue_HK) WeekdayNarrow(weekday time.Weekday) string { + return yue.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (yue *yue_HK) WeekdaysNarrow() []string { + return yue.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (yue *yue_HK) WeekdayShort(weekday time.Weekday) string { + return yue.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (yue *yue_HK) WeekdaysShort() []string { + return yue.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (yue *yue_HK) WeekdayWide(weekday time.Weekday) string { + return yue.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (yue *yue_HK) WeekdaysWide() []string { + return yue.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'yue_HK' and handles both Whole and Real numbers based on 'v' +func (yue *yue_HK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yue.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yue.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yue.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'yue_HK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (yue *yue_HK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yue.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, yue.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, yue.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'yue_HK' +func (yue *yue_HK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yue.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yue.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yue.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, yue.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yue.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'yue_HK' +// in accounting notation. +func (yue *yue_HK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := yue.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, yue.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, yue.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, yue.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, yue.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'yue_HK' +func (yue *yue_HK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'yue_HK' +func (yue *yue_HK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'yue_HK' +func (yue *yue_HK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'yue_HK' +func (yue *yue_HK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5, 0x20}...) + b = append(b, yue.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'yue_HK' +func (yue *yue_HK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, yue.periodsAbbreviated[0]...) + } else { + b = append(b, yue.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, yue.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'yue_HK' +func (yue *yue_HK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, yue.periodsAbbreviated[0]...) + } else { + b = append(b, yue.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, yue.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yue.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'yue_HK' +func (yue *yue_HK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, yue.periodsAbbreviated[0]...) + } else { + b = append(b, yue.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, yue.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yue.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x5b}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x5d}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'yue_HK' +func (yue *yue_HK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, yue.periodsAbbreviated[0]...) + } else { + b = append(b, yue.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, yue.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, yue.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x5b}...) + + tz, _ := t.Zone() + + if btz, ok := yue.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x5d}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/yue_HK/yue_HK_test.go b/vendor/github.com/go-playground/locales/yue_HK/yue_HK_test.go new file mode 100644 index 0000000000..e8904660a7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/yue_HK/yue_HK_test.go @@ -0,0 +1,1120 @@ +package yue_HK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "yue_HK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zgh/zgh.go b/vendor/github.com/go-playground/locales/zgh/zgh.go new file mode 100644 index 0000000000..6acf48bcbd --- /dev/null +++ b/vendor/github.com/go-playground/locales/zgh/zgh.go @@ -0,0 +1,573 @@ +package zgh + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zgh struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zgh' locale +func New() locales.Translator { + return &zgh{ + locale: "zgh", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "ⵉⵏⵏ", "ⴱⵕⴰ", "ⵎⴰⵕ", "ⵉⴱⵔ", "ⵎⴰⵢ", "ⵢⵓⵏ", "ⵢⵓⵍ", "ⵖⵓⵛ", "ⵛⵓⵜ", "ⴽⵜⵓ", "ⵏⵓⵡ", "ⴷⵓⵊ"}, + monthsNarrow: []string{"", "ⵉ", "ⴱ", "ⵎ", "ⵉ", "ⵎ", "ⵢ", "ⵢ", "ⵖ", "ⵛ", "ⴽ", "ⵏ", "ⴷ"}, + monthsWide: []string{"", "ⵉⵏⵏⴰⵢⵔ", "ⴱⵕⴰⵢⵕ", "ⵎⴰⵕⵚ", "ⵉⴱⵔⵉⵔ", "ⵎⴰⵢⵢⵓ", "ⵢⵓⵏⵢⵓ", "ⵢⵓⵍⵢⵓⵣ", "ⵖⵓⵛⵜ", "ⵛⵓⵜⴰⵏⴱⵉⵔ", "ⴽⵜⵓⴱⵔ", "ⵏⵓⵡⴰⵏⴱⵉⵔ", "ⴷⵓⵊⴰⵏⴱⵉⵔ"}, + daysAbbreviated: []string{"ⴰⵙⴰ", "ⴰⵢⵏ", "ⴰⵙⵉ", "ⴰⴽⵕ", "ⴰⴽⵡ", "ⴰⵙⵉⵎ", "ⴰⵙⵉⴹ"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"ⴰⵙⴰ", "ⴰⵢⵏ", "ⴰⵙⵉ", "ⴰⴽⵕ", "ⴰⴽⵡ", "ⴰⵙⵉⵎ", "ⴰⵙⵉⴹ"}, + daysWide: []string{"ⴰⵙⴰⵎⴰⵙ", "ⴰⵢⵏⴰⵙ", "ⴰⵙⵉⵏⴰⵙ", "ⴰⴽⵕⴰⵙ", "ⴰⴽⵡⴰⵙ", "ⴰⵙⵉⵎⵡⴰⵙ", "ⴰⵙⵉⴹⵢⴰⵙ"}, + periodsAbbreviated: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + periodsNarrow: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + periodsWide: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + erasAbbreviated: []string{"ⴷⴰⵄ", "ⴷⴼⵄ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ⴷⴰⵜ ⵏ ⵄⵉⵙⴰ", "ⴷⴼⴼⵉⵔ ⵏ ⵄⵉⵙⴰ"}, + timezones: map[string]string{"CDT": "CDT", "TMT": "TMT", "AEDT": "AEDT", "LHST": "LHST", "NZST": "NZST", "MESZ": "MESZ", "WEZ": "WEZ", "WARST": "WARST", "HEOG": "HEOG", "AEST": "AEST", "WITA": "WITA", "MST": "MST", "ARST": "ARST", "ACDT": "ACDT", "COST": "COST", "HNEG": "HNEG", "GYT": "GYT", "WIB": "WIB", "BOT": "BOT", "IST": "IST", "OEZ": "OEZ", "OESZ": "OESZ", "HNOG": "HNOG", "AWDT": "AWDT", "PDT": "PDT", "ECT": "ECT", "MEZ": "MEZ", "ADT": "ADT", "TMST": "TMST", "MDT": "MDT", "GFT": "GFT", "SAST": "SAST", "AWST": "AWST", "CHADT": "CHADT", "HADT": "HADT", "ACWST": "ACWST", "WART": "WART", "UYT": "UYT", "HNPM": "HNPM", "AKST": "AKST", "LHDT": "LHDT", "HECU": "HECU", "∅∅∅": "∅∅∅", "JST": "JST", "CLST": "CLST", "HEPM": "HEPM", "UYST": "UYST", "SRT": "SRT", "EAT": "EAT", "CST": "CST", "WIT": "WIT", "PST": "PST", "HAST": "HAST", "ACWDT": "ACWDT", "CLT": "CLT", "WAT": "WAT", "HEEG": "HEEG", "MYT": "MYT", "EDT": "EDT", "HAT": "HAT", "CHAST": "CHAST", "CAT": "CAT", "NZDT": "NZDT", "WAST": "WAST", "HKT": "HKT", "HNT": "HNT", "AKDT": "AKDT", "ChST": "ChST", "HNCU": "HNCU", "EST": "EST", "BT": "BT", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "VET": "VET", "AST": "AST", "GMT": "GMT", "ACST": "ACST", "HNNOMX": "HNNOMX", "SGT": "SGT", "ART": "ART", "JDT": "JDT", "WESZ": "WESZ", "HKST": "HKST", "COT": "COT", "HENOMX": "HENOMX"}, + } +} + +// Locale returns the current translators string locale +func (zgh *zgh) Locale() string { + return zgh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zgh' +func (zgh *zgh) PluralsCardinal() []locales.PluralRule { + return zgh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zgh' +func (zgh *zgh) PluralsOrdinal() []locales.PluralRule { + return zgh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zgh' +func (zgh *zgh) PluralsRange() []locales.PluralRule { + return zgh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zgh' +func (zgh *zgh) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zgh' +func (zgh *zgh) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zgh' +func (zgh *zgh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zgh *zgh) MonthAbbreviated(month time.Month) string { + return zgh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zgh *zgh) MonthsAbbreviated() []string { + return zgh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zgh *zgh) MonthNarrow(month time.Month) string { + return zgh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zgh *zgh) MonthsNarrow() []string { + return zgh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zgh *zgh) MonthWide(month time.Month) string { + return zgh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zgh *zgh) MonthsWide() []string { + return zgh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zgh *zgh) WeekdayAbbreviated(weekday time.Weekday) string { + return zgh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zgh *zgh) WeekdaysAbbreviated() []string { + return zgh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zgh *zgh) WeekdayNarrow(weekday time.Weekday) string { + return zgh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zgh *zgh) WeekdaysNarrow() []string { + return zgh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zgh *zgh) WeekdayShort(weekday time.Weekday) string { + return zgh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zgh *zgh) WeekdaysShort() []string { + return zgh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zgh *zgh) WeekdayWide(weekday time.Weekday) string { + return zgh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zgh *zgh) WeekdaysWide() []string { + return zgh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zgh' and handles both Whole and Real numbers based on 'v' +func (zgh *zgh) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zgh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(zgh.group) - 1; j >= 0; j-- { + b = append(b, zgh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zgh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zgh' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zgh *zgh) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zgh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zgh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zgh.percentSuffix...) + + b = append(b, zgh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zgh' +func (zgh *zgh) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zgh.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zgh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(zgh.group) - 1; j >= 0; j-- { + b = append(b, zgh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zgh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zgh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zgh' +// in accounting notation. +func (zgh *zgh) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zgh.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zgh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(zgh.group) - 1; j >= 0; j-- { + b = append(b, zgh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, zgh.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zgh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zgh' +func (zgh *zgh) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zgh' +func (zgh *zgh) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, zgh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zgh' +func (zgh *zgh) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, zgh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zgh' +func (zgh *zgh) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, zgh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, zgh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zgh' +func (zgh *zgh) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zgh' +func (zgh *zgh) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zgh' +func (zgh *zgh) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zgh' +func (zgh *zgh) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := zgh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zgh/zgh_test.go b/vendor/github.com/go-playground/locales/zgh/zgh_test.go new file mode 100644 index 0000000000..ec2f57e33f --- /dev/null +++ b/vendor/github.com/go-playground/locales/zgh/zgh_test.go @@ -0,0 +1,1120 @@ +package zgh + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zgh" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zgh_MA/zgh_MA.go b/vendor/github.com/go-playground/locales/zgh_MA/zgh_MA.go new file mode 100644 index 0000000000..4569ae7be4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zgh_MA/zgh_MA.go @@ -0,0 +1,573 @@ +package zgh_MA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zgh_MA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + percentSuffix string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zgh_MA' locale +func New() locales.Translator { + return &zgh_MA{ + locale: "zgh_MA", + pluralsCardinal: nil, + pluralsOrdinal: nil, + pluralsRange: nil, + decimal: ",", + group: " ", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + percentSuffix: " ", + monthsAbbreviated: []string{"", "ⵉⵏⵏ", "ⴱⵕⴰ", "ⵎⴰⵕ", "ⵉⴱⵔ", "ⵎⴰⵢ", "ⵢⵓⵏ", "ⵢⵓⵍ", "ⵖⵓⵛ", "ⵛⵓⵜ", "ⴽⵜⵓ", "ⵏⵓⵡ", "ⴷⵓⵊ"}, + monthsNarrow: []string{"", "ⵉ", "ⴱ", "ⵎ", "ⵉ", "ⵎ", "ⵢ", "ⵢ", "ⵖ", "ⵛ", "ⴽ", "ⵏ", "ⴷ"}, + monthsWide: []string{"", "ⵉⵏⵏⴰⵢⵔ", "ⴱⵕⴰⵢⵕ", "ⵎⴰⵕⵚ", "ⵉⴱⵔⵉⵔ", "ⵎⴰⵢⵢⵓ", "ⵢⵓⵏⵢⵓ", "ⵢⵓⵍⵢⵓⵣ", "ⵖⵓⵛⵜ", "ⵛⵓⵜⴰⵏⴱⵉⵔ", "ⴽⵜⵓⴱⵔ", "ⵏⵓⵡⴰⵏⴱⵉⵔ", "ⴷⵓⵊⴰⵏⴱⵉⵔ"}, + daysAbbreviated: []string{"ⴰⵙⴰ", "ⴰⵢⵏ", "ⴰⵙⵉ", "ⴰⴽⵕ", "ⴰⴽⵡ", "ⴰⵙⵉⵎ", "ⴰⵙⵉⴹ"}, + daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"}, + daysShort: []string{"ⴰⵙⴰ", "ⴰⵢⵏ", "ⴰⵙⵉ", "ⴰⴽⵕ", "ⴰⴽⵡ", "ⴰⵙⵉⵎ", "ⴰⵙⵉⴹ"}, + daysWide: []string{"ⴰⵙⴰⵎⴰⵙ", "ⴰⵢⵏⴰⵙ", "ⴰⵙⵉⵏⴰⵙ", "ⴰⴽⵕⴰⵙ", "ⴰⴽⵡⴰⵙ", "ⴰⵙⵉⵎⵡⴰⵙ", "ⴰⵙⵉⴹⵢⴰⵙ"}, + periodsAbbreviated: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + periodsNarrow: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + periodsWide: []string{"ⵜⵉⴼⴰⵡⵜ", "ⵜⴰⴷⴳⴳⵯⴰⵜ"}, + erasAbbreviated: []string{"ⴷⴰⵄ", "ⴷⴼⵄ"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"ⴷⴰⵜ ⵏ ⵄⵉⵙⴰ", "ⴷⴼⴼⵉⵔ ⵏ ⵄⵉⵙⴰ"}, + timezones: map[string]string{"GFT": "GFT", "EAT": "EAT", "EST": "EST", "HNNOMX": "HNNOMX", "HNCU": "HNCU", "PST": "PST", "WART": "WART", "TMST": "TMST", "ACDT": "ACDT", "CAT": "CAT", "IST": "IST", "HKST": "HKST", "BT": "BT", "MST": "MST", "CHADT": "CHADT", "WEZ": "WEZ", "WAT": "WAT", "HNT": "HNT", "HEEG": "HEEG", "HKT": "HKT", "LHDT": "LHDT", "AWDT": "AWDT", "ACWST": "ACWST", "NZST": "NZST", "JDT": "JDT", "HNOG": "HNOG", "MYT": "MYT", "LHST": "LHST", "HECU": "HECU", "ADT": "ADT", "UYT": "UYT", "HEPM": "HEPM", "HNPMX": "HNPMX", "HEPMX": "HEPMX", "HADT": "HADT", "COT": "COT", "COST": "COST", "AKDT": "AKDT", "CST": "CST", "SGT": "SGT", "BOT": "BOT", "ACWDT": "ACWDT", "HEOG": "HEOG", "WITA": "WITA", "SRT": "SRT", "AWST": "AWST", "ECT": "ECT", "JST": "JST", "GMT": "GMT", "ACST": "ACST", "AKST": "AKST", "GYT": "GYT", "WIB": "WIB", "OEZ": "OEZ", "CLST": "CLST", "ARST": "ARST", "HENOMX": "HENOMX", "CDT": "CDT", "EDT": "EDT", "HNEG": "HNEG", "AEST": "AEST", "SAST": "SAST", "WIT": "WIT", "CHAST": "CHAST", "VET": "VET", "CLT": "CLT", "HAT": "HAT", "MESZ": "MESZ", "OESZ": "OESZ", "ChST": "ChST", "HNPM": "HNPM", "WESZ": "WESZ", "TMT": "TMT", "ART": "ART", "UYST": "UYST", "∅∅∅": "∅∅∅", "PDT": "PDT", "AST": "AST", "WAST": "WAST", "AEDT": "AEDT", "MDT": "MDT", "HAST": "HAST", "NZDT": "NZDT", "MEZ": "MEZ", "WARST": "WARST"}, + } +} + +// Locale returns the current translators string locale +func (zgh *zgh_MA) Locale() string { + return zgh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zgh_MA' +func (zgh *zgh_MA) PluralsCardinal() []locales.PluralRule { + return zgh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zgh_MA' +func (zgh *zgh_MA) PluralsOrdinal() []locales.PluralRule { + return zgh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zgh_MA' +func (zgh *zgh_MA) PluralsRange() []locales.PluralRule { + return zgh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zgh_MA' +func (zgh *zgh_MA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zgh_MA' +func (zgh *zgh_MA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zgh_MA' +func (zgh *zgh_MA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleUnknown +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zgh *zgh_MA) MonthAbbreviated(month time.Month) string { + return zgh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zgh *zgh_MA) MonthsAbbreviated() []string { + return zgh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zgh *zgh_MA) MonthNarrow(month time.Month) string { + return zgh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zgh *zgh_MA) MonthsNarrow() []string { + return zgh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zgh *zgh_MA) MonthWide(month time.Month) string { + return zgh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zgh *zgh_MA) MonthsWide() []string { + return zgh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zgh *zgh_MA) WeekdayAbbreviated(weekday time.Weekday) string { + return zgh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zgh *zgh_MA) WeekdaysAbbreviated() []string { + return zgh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zgh *zgh_MA) WeekdayNarrow(weekday time.Weekday) string { + return zgh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zgh *zgh_MA) WeekdaysNarrow() []string { + return zgh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zgh *zgh_MA) WeekdayShort(weekday time.Weekday) string { + return zgh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zgh *zgh_MA) WeekdaysShort() []string { + return zgh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zgh *zgh_MA) WeekdayWide(weekday time.Weekday) string { + return zgh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zgh *zgh_MA) WeekdaysWide() []string { + return zgh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zgh_MA' and handles both Whole and Real numbers based on 'v' +func (zgh *zgh_MA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zgh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(zgh.group) - 1; j >= 0; j-- { + b = append(b, zgh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zgh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zgh_MA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zgh *zgh_MA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 5 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zgh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zgh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zgh.percentSuffix...) + + b = append(b, zgh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zgh_MA' +func (zgh *zgh_MA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zgh.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zgh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(zgh.group) - 1; j >= 0; j-- { + b = append(b, zgh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zgh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zgh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + b = append(b, symbol...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zgh_MA' +// in accounting notation. +func (zgh *zgh_MA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zgh.currencies[currency] + l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zgh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + for j := len(zgh.group) - 1; j >= 0; j-- { + b = append(b, zgh.group[j]) + } + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + b = append(b, zgh.minus[0]) + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zgh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, symbol...) + } else { + + b = append(b, symbol...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zgh_MA' +func (zgh *zgh_MA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zgh_MA' +func (zgh *zgh_MA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, zgh.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zgh_MA' +func (zgh *zgh_MA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, zgh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zgh_MA' +func (zgh *zgh_MA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, zgh.daysWide[t.Weekday()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x20}...) + b = append(b, zgh.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zgh_MA' +func (zgh *zgh_MA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zgh_MA' +func (zgh *zgh_MA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zgh_MA' +func (zgh *zgh_MA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zgh_MA' +func (zgh *zgh_MA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zgh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := zgh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zgh_MA/zgh_MA_test.go b/vendor/github.com/go-playground/locales/zgh_MA/zgh_MA_test.go new file mode 100644 index 0000000000..f80267d5d5 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zgh_MA/zgh_MA_test.go @@ -0,0 +1,1120 @@ +package zgh_MA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zgh_MA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh/zh.go b/vendor/github.com/go-playground/locales/zh/zh.go new file mode 100644 index 0000000000..8746b96762 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh/zh.go @@ -0,0 +1,604 @@ +package zh + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh' locale +func New() locales.Translator { + return &zh{ + locale: "zh", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILS", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"公元前", "公元"}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"∅∅∅": "阿克里夏令时间", "WIT": "印度尼西亚东部时间", "ACWDT": "澳大利亚中西部夏令时间", "JDT": "日本夏令时间", "HNNOMX": "墨西哥西北部标准时间", "HEEG": "格陵兰岛东部夏令时间", "SAST": "南部非洲时间", "HEPMX": "墨西哥太平洋夏令时间", "CAT": "中部非洲时间", "IST": "印度时间", "MESZ": "中欧夏令时间", "WAT": "西部非洲标准时间", "WAST": "西部非洲夏令时间", "EDT": "北美东部夏令时间", "CST": "北美中部标准时间", "AWST": "澳大利亚西部标准时间", "CHADT": "查坦夏令时间", "GMT": "格林尼治标准时间", "EST": "北美东部标准时间", "AKDT": "阿拉斯加夏令时间", "LHST": "豪勋爵岛标准时间", "BOT": "玻利维亚标准时间", "HADT": "夏威夷-阿留申夏令时间", "OEZ": "东欧标准时间", "ART": "阿根廷标准时间", "HKT": "香港标准时间", "HAT": "纽芬兰夏令时间", "PST": "北美太平洋标准时间", "WART": "阿根廷西部标准时间", "WARST": "阿根廷西部夏令时间", "CLT": "智利标准时间", "ARST": "阿根廷夏令时间", "AKST": "阿拉斯加标准时间", "SRT": "苏里南时间", "NZDT": "新西兰夏令时间", "WEZ": "西欧标准时间", "HENOMX": "墨西哥西北部夏令时间", "HNEG": "格陵兰岛东部标准时间", "HNPMX": "墨西哥太平洋标准时间", "CHAST": "查坦标准时间", "AEDT": "澳大利亚东部夏令时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "SGT": "新加坡标准时间", "PDT": "北美太平洋夏令时间", "MYT": "马来西亚时间", "UYT": "乌拉圭标准时间", "GYT": "圭亚那时间", "ECT": "厄瓜多尔标准时间", "WESZ": "西欧夏令时间", "HKST": "香港夏令时间", "ChST": "查莫罗时间", "HNCU": "古巴标准时间", "ACWST": "澳大利亚中西部标准时间", "JST": "日本标准时间", "WITA": "印度尼西亚中部时间", "HEOG": "格陵兰岛西部夏令时间", "TMT": "土库曼斯坦标准时间", "MST": "澳门标准时间", "MDT": "澳门夏令时间", "ACST": "澳大利亚中部标准时间", "COST": "哥伦比亚夏令时间", "HNT": "纽芬兰标准时间", "CDT": "北美中部夏令时间", "TMST": "土库曼斯坦夏令时间", "AEST": "澳大利亚东部标准时间", "EAT": "东部非洲时间", "AWDT": "澳大利亚西部夏令时间", "VET": "委内瑞拉时间", "CLST": "智利夏令时间", "OESZ": "东欧夏令时间", "ACDT": "澳大利亚中部夏令时间", "COT": "哥伦比亚标准时间", "HAST": "夏威夷-阿留申标准时间", "HNOG": "格陵兰岛西部标准时间", "ADT": "大西洋夏令时间", "UYST": "乌拉圭夏令时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "HECU": "古巴夏令时间", "WIB": "印度尼西亚西部时间", "AST": "大西洋标准时间", "BT": "不丹时间", "GFT": "法属圭亚那标准时间", "NZST": "新西兰标准时间", "MEZ": "中欧标准时间", "LHDT": "豪勋爵岛夏令时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh' +func (zh *zh) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh' +func (zh *zh) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh' +func (zh *zh) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh' +func (zh *zh) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh' +func (zh *zh) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh' +func (zh *zh) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh' and handles both Whole and Real numbers based on 'v' +func (zh *zh) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh' +func (zh *zh) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh' +// in accounting notation. +func (zh *zh) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh' +func (zh *zh) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh' +func (zh *zh) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh' +func (zh *zh) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh' +func (zh *zh) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh' +func (zh *zh) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh' +func (zh *zh) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh' +func (zh *zh) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh' +func (zh *zh) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh/zh_test.go b/vendor/github.com/go-playground/locales/zh/zh_test.go new file mode 100644 index 0000000000..a6518eeda6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh/zh_test.go @@ -0,0 +1,1120 @@ +package zh + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans/zh_Hans.go b/vendor/github.com/go-playground/locales/zh_Hans/zh_Hans.go new file mode 100644 index 0000000000..f6d696fef4 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans/zh_Hans.go @@ -0,0 +1,604 @@ +package zh_Hans + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hans struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hans' locale +func New() locales.Translator { + return &zh_Hans{ + locale: "zh_Hans", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"公元前", "公元"}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"COT": "哥伦比亚标准时间", "BT": "不丹时间", "WEZ": "西欧标准时间", "TMST": "土库曼斯坦夏令时间", "HEEG": "格陵兰岛东部夏令时间", "HAST": "夏威夷-阿留申标准时间", "HADT": "夏威夷-阿留申夏令时间", "ACWST": "澳大利亚中西部标准时间", "HKST": "香港夏令时间", "ACDT": "澳大利亚中部夏令时间", "HNEG": "格陵兰岛东部标准时间", "GFT": "法属圭亚那标准时间", "PDT": "北美太平洋夏令时间", "WARST": "阿根廷西部夏令时间", "TMT": "土库曼斯坦标准时间", "OESZ": "东欧夏令时间", "ACST": "澳大利亚中部标准时间", "HEPMX": "墨西哥太平洋夏令时间", "NZDT": "新西兰夏令时间", "WESZ": "西欧夏令时间", "WART": "阿根廷西部标准时间", "GMT": "格林尼治标准时间", "AEST": "澳大利亚东部标准时间", "EST": "北美东部标准时间", "AEDT": "澳大利亚东部夏令时间", "MYT": "马来西亚时间", "ART": "阿根廷标准时间", "CDT": "北美中部夏令时间", "AWDT": "澳大利亚西部夏令时间", "AST": "大西洋标准时间", "LHST": "豪勋爵岛标准时间", "HNT": "纽芬兰标准时间", "SGT": "新加坡标准时间", "CLST": "智利夏令时间", "EDT": "北美东部夏令时间", "AKDT": "阿拉斯加夏令时间", "WIB": "印度尼西亚西部时间", "WIT": "印度尼西亚东部时间", "ECT": "厄瓜多尔标准时间", "IST": "印度时间", "JDT": "日本夏令时间", "HKT": "香港标准时间", "WAT": "西部非洲标准时间", "ChST": "查莫罗时间", "LHDT": "豪勋爵岛夏令时间", "HECU": "古巴夏令时间", "CST": "北美中部标准时间", "CHAST": "查坦标准时间", "MESZ": "中欧夏令时间", "VET": "委内瑞拉时间", "NZST": "新西兰标准时间", "SAST": "南部非洲时间", "EAT": "东部非洲时间", "HNCU": "古巴标准时间", "CAT": "中部非洲时间", "MST": "澳门标准时间", "WAST": "西部非洲夏令时间", "OEZ": "东欧标准时间", "MDT": "澳门夏令时间", "HNNOMX": "墨西哥西北部标准时间", "∅∅∅": "阿克里夏令时间", "HAT": "纽芬兰夏令时间", "WITA": "印度尼西亚中部时间", "CLT": "智利标准时间", "HNOG": "格陵兰岛西部标准时间", "UYT": "乌拉圭标准时间", "HNPMX": "墨西哥太平洋标准时间", "HENOMX": "墨西哥西北部夏令时间", "BOT": "玻利维亚标准时间", "PST": "北美太平洋标准时间", "JST": "日本标准时间", "HEOG": "格陵兰岛西部夏令时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "GYT": "圭亚那时间", "AWST": "澳大利亚西部标准时间", "ACWDT": "澳大利亚中西部夏令时间", "COST": "哥伦比亚夏令时间", "AKST": "阿拉斯加标准时间", "CHADT": "查坦夏令时间", "ARST": "阿根廷夏令时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "UYST": "乌拉圭夏令时间", "SRT": "苏里南时间", "MEZ": "中欧标准时间", "ADT": "大西洋夏令时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hans) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hans' +func (zh *zh_Hans) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hans' +func (zh *zh_Hans) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hans' +func (zh *zh_Hans) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans' +func (zh *zh_Hans) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans' +func (zh *zh_Hans) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hans' +func (zh *zh_Hans) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hans) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hans) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hans) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hans) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hans) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hans) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hans) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hans) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hans) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hans) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hans) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hans) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hans) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hans) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hans' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hans) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hans' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hans) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans' +func (zh *zh_Hans) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans' +// in accounting notation. +func (zh *zh_Hans) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hans' +func (zh *zh_Hans) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hans' +func (zh *zh_Hans) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hans' +func (zh *zh_Hans) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hans' +func (zh *zh_Hans) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hans' +func (zh *zh_Hans) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hans' +func (zh *zh_Hans) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hans' +func (zh *zh_Hans) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hans' +func (zh *zh_Hans) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans/zh_Hans_test.go b/vendor/github.com/go-playground/locales/zh_Hans/zh_Hans_test.go new file mode 100644 index 0000000000..42cc454cfd --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans/zh_Hans_test.go @@ -0,0 +1,1120 @@ +package zh_Hans + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hans" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans_CN/zh_Hans_CN.go b/vendor/github.com/go-playground/locales/zh_Hans_CN/zh_Hans_CN.go new file mode 100644 index 0000000000..01cb596500 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans_CN/zh_Hans_CN.go @@ -0,0 +1,604 @@ +package zh_Hans_CN + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hans_CN struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hans_CN' locale +func New() locales.Translator { + return &zh_Hans_CN{ + locale: "zh_Hans_CN", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"公元前", "公元"}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"ACDT": "澳大利亚中部夏令时间", "AEDT": "澳大利亚东部夏令时间", "SRT": "苏里南时间", "PST": "北美太平洋标准时间", "ACWST": "澳大利亚中西部标准时间", "AST": "大西洋标准时间", "ART": "阿根廷标准时间", "HNT": "纽芬兰标准时间", "AEST": "澳大利亚东部标准时间", "GYT": "圭亚那时间", "CHADT": "查坦夏令时间", "JST": "日本标准时间", "GMT": "格林尼治标准时间", "WAT": "西部非洲标准时间", "EST": "北美东部标准时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "CDT": "北美中部夏令时间", "BOT": "玻利维亚标准时间", "OESZ": "东欧夏令时间", "HNNOMX": "墨西哥西北部标准时间", "MDT": "北美山区夏令时间", "CST": "北美中部标准时间", "HAST": "夏威夷-阿留申标准时间", "HNCU": "古巴标准时间", "MESZ": "中欧夏令时间", "WEZ": "西欧标准时间", "MEZ": "中欧标准时间", "WART": "阿根廷西部标准时间", "ARST": "阿根廷夏令时间", "HEEG": "格陵兰岛东部夏令时间", "AKDT": "阿拉斯加夏令时间", "MST": "北美山区标准时间", "CHAST": "查坦标准时间", "PDT": "北美太平洋夏令时间", "ACWDT": "澳大利亚中西部夏令时间", "HNOG": "格陵兰岛西部标准时间", "OEZ": "东欧标准时间", "WESZ": "西欧夏令时间", "AKST": "阿拉斯加标准时间", "LHST": "豪勋爵岛标准时间", "HNPMX": "墨西哥太平洋标准时间", "EDT": "北美东部夏令时间", "COT": "哥伦比亚标准时间", "HENOMX": "墨西哥西北部夏令时间", "ACST": "澳大利亚中部标准时间", "CAT": "中部非洲时间", "CLST": "智利夏令时间", "HKST": "香港夏令时间", "HEOG": "格陵兰岛西部夏令时间", "TMT": "土库曼斯坦标准时间", "HNEG": "格陵兰岛东部标准时间", "∅∅∅": "亚速尔群岛夏令时间", "HADT": "夏威夷-阿留申夏令时间", "NZDT": "新西兰夏令时间", "ECT": "厄瓜多尔标准时间", "NZST": "新西兰标准时间", "ADT": "大西洋夏令时间", "HAT": "纽芬兰夏令时间", "WITA": "印度尼西亚中部时间", "WIB": "印度尼西亚西部时间", "AWST": "澳大利亚西部标准时间", "MYT": "马来西亚时间", "COST": "哥伦比亚夏令时间", "HECU": "古巴夏令时间", "WIT": "印度尼西亚东部时间", "JDT": "日本夏令时间", "IST": "印度时间", "VET": "委内瑞拉时间", "WARST": "阿根廷西部夏令时间", "CLT": "智利标准时间", "UYT": "乌拉圭标准时间", "HEPMX": "墨西哥太平洋夏令时间", "AWDT": "澳大利亚西部夏令时间", "TMST": "土库曼斯坦夏令时间", "WAST": "西部非洲夏令时间", "BT": "不丹时间", "GFT": "法属圭亚那标准时间", "SAST": "南部非洲时间", "EAT": "东部非洲时间", "UYST": "乌拉圭夏令时间", "LHDT": "豪勋爵岛夏令时间", "SGT": "新加坡标准时间", "ChST": "查莫罗时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "HKT": "香港标准时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hans_CN) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hans_CN' +func (zh *zh_Hans_CN) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hans_CN' +func (zh *zh_Hans_CN) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hans_CN' +func (zh *zh_Hans_CN) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hans_CN) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hans_CN) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hans_CN) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hans_CN) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hans_CN) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hans_CN) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hans_CN) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hans_CN) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hans_CN) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hans_CN) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hans_CN) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hans_CN) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hans_CN) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hans_CN) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hans_CN' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hans_CN) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hans_CN' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hans_CN) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_CN' +// in accounting notation. +func (zh *zh_Hans_CN) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hans_CN' +func (zh *zh_Hans_CN) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans_CN/zh_Hans_CN_test.go b/vendor/github.com/go-playground/locales/zh_Hans_CN/zh_Hans_CN_test.go new file mode 100644 index 0000000000..c7260d4b41 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans_CN/zh_Hans_CN_test.go @@ -0,0 +1,1120 @@ +package zh_Hans_CN + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hans_CN" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans_HK/zh_Hans_HK.go b/vendor/github.com/go-playground/locales/zh_Hans_HK/zh_Hans_HK.go new file mode 100644 index 0000000000..6810139e2f --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans_HK/zh_Hans_HK.go @@ -0,0 +1,604 @@ +package zh_Hans_HK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hans_HK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hans_HK' locale +func New() locales.Translator { + return &zh_Hans_HK{ + locale: "zh_Hans_HK", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"公元前", "公元"}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"WAT": "西部非洲标准时间", "EST": "北美东部标准时间", "UYST": "乌拉圭夏令时间", "SAST": "南部非洲时间", "AST": "大西洋标准时间", "SGT": "新加坡标准时间", "MYT": "马来西亚时间", "MST": "澳门标准时间", "HNNOMX": "墨西哥西北部标准时间", "WITA": "印度尼西亚中部时间", "AEST": "澳大利亚东部标准时间", "LHDT": "豪勋爵岛夏令时间", "AKDT": "阿拉斯加夏令时间", "HNPMX": "墨西哥太平洋标准时间", "CDT": "北美中部夏令时间", "HAST": "夏威夷-阿留申标准时间", "JST": "日本标准时间", "MDT": "澳门夏令时间", "∅∅∅": "阿克里夏令时间", "UYT": "乌拉圭标准时间", "GYT": "圭亚那时间", "WART": "阿根廷西部标准时间", "WEZ": "西欧标准时间", "COST": "哥伦比亚夏令时间", "EAT": "东部非洲时间", "HECU": "古巴夏令时间", "PDT": "北美太平洋夏令时间", "HADT": "夏威夷-阿留申夏令时间", "BT": "不丹时间", "NZST": "新西兰标准时间", "NZDT": "新西兰夏令时间", "SRT": "苏里南时间", "CHADT": "查坦夏令时间", "ACST": "澳大利亚中部标准时间", "HNCU": "古巴标准时间", "CLT": "智利标准时间", "ART": "阿根廷标准时间", "HNEG": "格陵兰岛东部标准时间", "GFT": "法属圭亚那标准时间", "HEPMX": "墨西哥太平洋夏令时间", "MEZ": "中欧标准时间", "HEEG": "格陵兰岛东部夏令时间", "IST": "印度时间", "HEOG": "格陵兰岛西部夏令时间", "OESZ": "东欧夏令时间", "CLST": "智利夏令时间", "TMT": "土库曼斯坦标准时间", "HKT": "香港标准时间", "ACDT": "澳大利亚中部夏令时间", "HAT": "纽芬兰夏令时间", "ChST": "查莫罗时间", "MESZ": "中欧夏令时间", "CHAST": "查坦标准时间", "ACWST": "澳大利亚中西部标准时间", "ACWDT": "澳大利亚中西部夏令时间", "ARST": "阿根廷夏令时间", "AEDT": "澳大利亚东部夏令时间", "WIB": "印度尼西亚西部时间", "WIT": "印度尼西亚东部时间", "AWDT": "澳大利亚西部夏令时间", "VET": "委内瑞拉时间", "GMT": "格林尼治标准时间", "HKST": "香港夏令时间", "COT": "哥伦比亚标准时间", "AKST": "阿拉斯加标准时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "CAT": "中部非洲时间", "BOT": "玻利维亚标准时间", "ECT": "厄瓜多尔标准时间", "JDT": "日本夏令时间", "EDT": "北美东部夏令时间", "HENOMX": "墨西哥西北部夏令时间", "HNT": "纽芬兰标准时间", "LHST": "豪勋爵岛标准时间", "AWST": "澳大利亚西部标准时间", "OEZ": "东欧标准时间", "TMST": "土库曼斯坦夏令时间", "WAST": "西部非洲夏令时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "WESZ": "西欧夏令时间", "CST": "北美中部标准时间", "PST": "北美太平洋标准时间", "HNOG": "格陵兰岛西部标准时间", "ADT": "大西洋夏令时间", "WARST": "阿根廷西部夏令时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hans_HK) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hans_HK' +func (zh *zh_Hans_HK) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hans_HK' +func (zh *zh_Hans_HK) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hans_HK' +func (zh *zh_Hans_HK) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hans_HK) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hans_HK) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hans_HK) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hans_HK) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hans_HK) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hans_HK) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hans_HK) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hans_HK) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hans_HK) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hans_HK) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hans_HK) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hans_HK) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hans_HK) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hans_HK) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hans_HK' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hans_HK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hans_HK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hans_HK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_HK' +// in accounting notation. +func (zh *zh_Hans_HK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hans_HK' +func (zh *zh_Hans_HK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans_HK/zh_Hans_HK_test.go b/vendor/github.com/go-playground/locales/zh_Hans_HK/zh_Hans_HK_test.go new file mode 100644 index 0000000000..419355c62e --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans_HK/zh_Hans_HK_test.go @@ -0,0 +1,1120 @@ +package zh_Hans_HK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hans_HK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans_MO/zh_Hans_MO.go b/vendor/github.com/go-playground/locales/zh_Hans_MO/zh_Hans_MO.go new file mode 100644 index 0000000000..f9bcff53c2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans_MO/zh_Hans_MO.go @@ -0,0 +1,604 @@ +package zh_Hans_MO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hans_MO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hans_MO' locale +func New() locales.Translator { + return &zh_Hans_MO{ + locale: "zh_Hans_MO", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP$", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"公元前", "公元"}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"HAT": "纽芬兰夏令时间", "HNCU": "古巴标准时间", "BOT": "玻利维亚标准时间", "PDT": "北美太平洋夏令时间", "MESZ": "中欧夏令时间", "∅∅∅": "阿克里夏令时间", "GFT": "法属圭亚那标准时间", "PST": "北美太平洋标准时间", "HEOG": "格陵兰岛西部夏令时间", "ARST": "阿根廷夏令时间", "LHST": "豪勋爵岛标准时间", "CST": "北美中部标准时间", "CHAST": "查坦标准时间", "VET": "委内瑞拉时间", "WARST": "阿根廷西部夏令时间", "EST": "北美东部标准时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "HEPMX": "墨西哥太平洋夏令时间", "HADT": "夏威夷-阿留申夏令时间", "MEZ": "中欧标准时间", "JDT": "日本夏令时间", "WART": "阿根廷西部标准时间", "HKST": "香港夏令时间", "AEDT": "澳大利亚东部夏令时间", "SAST": "南部非洲时间", "LHDT": "豪勋爵岛夏令时间", "HNPMX": "墨西哥太平洋标准时间", "SRT": "苏里南时间", "WITA": "印度尼西亚中部时间", "ChST": "查莫罗时间", "NZST": "新西兰标准时间", "OESZ": "东欧夏令时间", "WESZ": "西欧夏令时间", "ACDT": "澳大利亚中部夏令时间", "HECU": "古巴夏令时间", "WIB": "印度尼西亚西部时间", "AWDT": "澳大利亚西部夏令时间", "AST": "大西洋标准时间", "HENOMX": "墨西哥西北部夏令时间", "HAST": "夏威夷-阿留申标准时间", "HNOG": "格陵兰岛西部标准时间", "CLT": "智利标准时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "AWST": "澳大利亚西部标准时间", "CHADT": "查坦夏令时间", "ACWST": "澳大利亚中西部标准时间", "GMT": "格林尼治标准时间", "WAST": "西部非洲夏令时间", "HNEG": "格陵兰岛东部标准时间", "MST": "北美山区标准时间", "CDT": "北美中部夏令时间", "WEZ": "西欧标准时间", "CLST": "智利夏令时间", "TMT": "土库曼斯坦标准时间", "WAT": "西部非洲标准时间", "ACST": "澳大利亚中部标准时间", "SGT": "新加坡标准时间", "ECT": "厄瓜多尔标准时间", "CAT": "中部非洲时间", "ART": "阿根廷标准时间", "HKT": "香港标准时间", "UYST": "乌拉圭夏令时间", "GYT": "圭亚那时间", "AEST": "澳大利亚东部标准时间", "MDT": "北美山区夏令时间", "IST": "印度时间", "ADT": "大西洋夏令时间", "TMST": "土库曼斯坦夏令时间", "EDT": "北美东部夏令时间", "COT": "哥伦比亚标准时间", "HNT": "纽芬兰标准时间", "HEEG": "格陵兰岛东部夏令时间", "AKDT": "阿拉斯加夏令时间", "UYT": "乌拉圭标准时间", "ACWDT": "澳大利亚中西部夏令时间", "JST": "日本标准时间", "COST": "哥伦比亚夏令时间", "HNNOMX": "墨西哥西北部标准时间", "AKST": "阿拉斯加标准时间", "EAT": "东部非洲时间", "NZDT": "新西兰夏令时间", "MYT": "马来西亚时间", "BT": "不丹时间", "WIT": "印度尼西亚东部时间", "OEZ": "东欧标准时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hans_MO) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hans_MO' +func (zh *zh_Hans_MO) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hans_MO' +func (zh *zh_Hans_MO) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hans_MO' +func (zh *zh_Hans_MO) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hans_MO) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hans_MO) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hans_MO) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hans_MO) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hans_MO) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hans_MO) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hans_MO) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hans_MO) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hans_MO) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hans_MO) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hans_MO) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hans_MO) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hans_MO) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hans_MO) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hans_MO' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hans_MO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hans_MO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hans_MO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_MO' +// in accounting notation. +func (zh *zh_Hans_MO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hans_MO' +func (zh *zh_Hans_MO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans_MO/zh_Hans_MO_test.go b/vendor/github.com/go-playground/locales/zh_Hans_MO/zh_Hans_MO_test.go new file mode 100644 index 0000000000..ebb7ad3c69 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans_MO/zh_Hans_MO_test.go @@ -0,0 +1,1120 @@ +package zh_Hans_MO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hans_MO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans_SG/zh_Hans_SG.go b/vendor/github.com/go-playground/locales/zh_Hans_SG/zh_Hans_SG.go new file mode 100644 index 0000000000..4bab826c48 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans_SG/zh_Hans_SG.go @@ -0,0 +1,614 @@ +package zh_Hans_SG + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hans_SG struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hans_SG' locale +func New() locales.Translator { + return &zh_Hans_SG{ + locale: "zh_Hans_SG", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "$", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"公元前", "公元"}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"WESZ": "西欧夏令时间", "WITA": "印度尼西亚中部时间", "HAST": "夏威夷-阿留申标准时间", "AEST": "澳大利亚东部标准时间", "WIT": "印度尼西亚东部时间", "MST": "澳门标准时间", "AKST": "阿拉斯加标准时间", "ChST": "查莫罗时间", "VET": "委内瑞拉时间", "HKST": "香港夏令时间", "COT": "哥伦比亚标准时间", "HENOMX": "墨西哥西北部夏令时间", "HNT": "纽芬兰标准时间", "GYT": "圭亚那时间", "AWST": "澳大利亚西部标准时间", "PDT": "北美太平洋夏令时间", "CAT": "中部非洲时间", "AST": "大西洋标准时间", "HNEG": "格陵兰岛东部标准时间", "CHADT": "查坦夏令时间", "PST": "北美太平洋标准时间", "GMT": "格林尼治标准时间", "ADT": "大西洋夏令时间", "TMST": "土库曼斯坦夏令时间", "ARST": "阿根廷夏令时间", "HKT": "香港标准时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "LHDT": "豪勋爵岛夏令时间", "HADT": "夏威夷-阿留申夏令时间", "ACWST": "澳大利亚中西部标准时间", "JST": "日本标准时间", "CLST": "智利夏令时间", "WEZ": "西欧标准时间", "WAT": "西部非洲标准时间", "EDT": "北美东部夏令时间", "UYST": "乌拉圭夏令时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "NZDT": "新西兰夏令时间", "∅∅∅": "亚马逊夏令时间", "MYT": "马来西亚时间", "OEZ": "东欧标准时间", "WAST": "西部非洲夏令时间", "ACST": "澳大利亚中部标准时间", "BOT": "玻利维亚标准时间", "ACWDT": "澳大利亚中西部夏令时间", "HNNOMX": "墨西哥西北部标准时间", "HEEG": "格陵兰岛东部夏令时间", "AEDT": "澳大利亚东部夏令时间", "LHST": "豪勋爵岛标准时间", "ECT": "厄瓜多尔标准时间", "HNOG": "格陵兰岛西部标准时间", "UYT": "乌拉圭标准时间", "CHAST": "查坦标准时间", "SGT": "新加坡标准时间", "NZST": "新西兰标准时间", "MEZ": "中欧标准时间", "ART": "阿根廷标准时间", "HAT": "纽芬兰夏令时间", "HNCU": "古巴标准时间", "AWDT": "澳大利亚西部夏令时间", "JDT": "日本夏令时间", "HEOG": "格陵兰岛西部夏令时间", "OESZ": "东欧夏令时间", "SRT": "苏里南时间", "EAT": "东部非洲时间", "TMT": "土库曼斯坦标准时间", "SAST": "南部非洲时间", "HEPMX": "墨西哥太平洋夏令时间", "HECU": "古巴夏令时间", "IST": "印度时间", "CLT": "智利标准时间", "BT": "不丹时间", "GFT": "法属圭亚那标准时间", "EST": "北美东部标准时间", "ACDT": "澳大利亚中部夏令时间", "COST": "哥伦比亚夏令时间", "CST": "北美中部标准时间", "MESZ": "中欧夏令时间", "WART": "阿根廷西部标准时间", "WARST": "阿根廷西部夏令时间", "MDT": "澳门夏令时间", "AKDT": "阿拉斯加夏令时间", "HNPMX": "墨西哥太平洋标准时间", "WIB": "印度尼西亚西部时间", "CDT": "北美中部夏令时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hans_SG) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hans_SG' +func (zh *zh_Hans_SG) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hans_SG' +func (zh *zh_Hans_SG) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hans_SG' +func (zh *zh_Hans_SG) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hans_SG) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hans_SG) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hans_SG) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hans_SG) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hans_SG) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hans_SG) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hans_SG) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hans_SG) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hans_SG) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hans_SG) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hans_SG) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hans_SG) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hans_SG) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hans_SG) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hans_SG' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hans_SG) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hans_SG' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hans_SG) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hans_SG' +// in accounting notation. +func (zh *zh_Hans_SG) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Day() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Month() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Month()), 10) + + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hans_SG' +func (zh *zh_Hans_SG) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hans_SG/zh_Hans_SG_test.go b/vendor/github.com/go-playground/locales/zh_Hans_SG/zh_Hans_SG_test.go new file mode 100644 index 0000000000..e186a9018f --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hans_SG/zh_Hans_SG_test.go @@ -0,0 +1,1120 @@ +package zh_Hans_SG + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hans_SG" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hant/zh_Hant.go b/vendor/github.com/go-playground/locales/zh_Hant/zh_Hant.go new file mode 100644 index 0000000000..d5ba705759 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hant/zh_Hant.go @@ -0,0 +1,606 @@ +package zh_Hant + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hant struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hant' locale +func New() locales.Translator { + return &zh_Hant{ + locale: "zh_Hant", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + daysAbbreviated: []string{"週日", "週一", "週二", "週三", "週四", "週五", "週六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"西元前", "西元"}, + erasNarrow: []string{"西元前", "西元"}, + erasWide: []string{"西元前", "西元"}, + timezones: map[string]string{"∅∅∅": "亞速爾群島夏令時間", "EAT": "東非時間", "BOT": "玻利維亞時間", "JST": "日本標準時間", "HNOG": "格陵蘭西部標準時間", "HKST": "香港夏令時間", "PDT": "太平洋夏令時間", "WART": "阿根廷西部標準時間", "TMT": "土庫曼標準時間", "WAT": "西非標準時間", "COST": "哥倫比亞夏令時間", "CDT": "中部夏令時間", "MEZ": "中歐標準時間", "MESZ": "中歐夏令時間", "WARST": "阿根廷西部夏令時間", "WAST": "西非夏令時間", "WIT": "印尼東部時間", "ART": "阿根廷標準時間", "HENOMX": "墨西哥西北部夏令時間", "JDT": "日本夏令時間", "COT": "哥倫比亞標準時間", "HEPMX": "墨西哥太平洋夏令時間", "ECT": "厄瓜多時間", "CAT": "中非時間", "GMT": "格林威治標準時間", "ACST": "澳洲中部標準時間", "SRT": "蘇利南時間", "OEZ": "東歐標準時間", "HNT": "紐芬蘭標準時間", "UYST": "烏拉圭夏令時間", "LHST": "豪勳爵島標準時間", "SGT": "新加坡標準時間", "ACWDT": "澳洲中西部夏令時間", "MDT": "澳門夏令時間", "EDT": "東部夏令時間", "BT": "不丹時間", "CLT": "智利標準時間", "ADT": "大西洋夏令時間", "OESZ": "東歐夏令時間", "HAT": "紐芬蘭夏令時間", "HECU": "古巴夏令時間", "PST": "太平洋標準時間", "VET": "委內瑞拉時間", "HEOG": "格陵蘭西部夏令時間", "AWST": "澳洲西部標準時間", "AWDT": "澳洲西部夏令時間", "CHADT": "查坦群島夏令時間", "AST": "大西洋標準時間", "ACDT": "澳洲中部夏令時間", "WITA": "印尼中部時間", "HNPM": "聖皮埃爾和密克隆群島標準時間", "AEST": "澳洲東部標準時間", "HNPMX": "墨西哥太平洋標準時間", "MYT": "馬來西亞時間", "WEZ": "西歐標準時間", "TMST": "土庫曼夏令時間", "MST": "澳門標準時間", "HKT": "香港標準時間", "HEEG": "格陵蘭東部夏令時間", "CHAST": "查坦群島標準時間", "GFT": "法屬圭亞那時間", "AKST": "阿拉斯加標準時間", "AKDT": "阿拉斯加夏令時間", "WIB": "印尼西部時間", "IST": "印度標準時間", "CLST": "智利夏令時間", "EST": "東部標準時間", "AEDT": "澳洲東部夏令時間", "HNNOMX": "墨西哥西北部標準時間", "GYT": "蓋亞那時間", "HNCU": "古巴標準時間", "CST": "中部標準時間", "NZST": "紐西蘭標準時間", "NZDT": "紐西蘭夏令時間", "WESZ": "西歐夏令時間", "ARST": "阿根廷夏令時間", "ChST": "查莫洛時間", "UYT": "烏拉圭標準時間", "SAST": "南非標準時間", "LHDT": "豪勳爵島夏令時間", "HAST": "夏威夷-阿留申標準時間", "HADT": "夏威夷-阿留申夏令時間", "ACWST": "澳洲中西部標準時間", "HNEG": "格陵蘭東部標準時間", "HEPM": "聖皮埃爾和密克隆群島夏令時間"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hant) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hant' +func (zh *zh_Hant) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hant' +func (zh *zh_Hant) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hant' +func (zh *zh_Hant) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant' +func (zh *zh_Hant) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant' +func (zh *zh_Hant) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hant' +func (zh *zh_Hant) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hant) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hant) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hant) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hant) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hant) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hant) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hant) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hant) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hant) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hant) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hant) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hant) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hant) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hant) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hant' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hant) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hant' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hant) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant' +func (zh *zh_Hant) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant' +// in accounting notation. +func (zh *zh_Hant) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hant' +func (zh *zh_Hant) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hant' +func (zh *zh_Hant) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hant' +func (zh *zh_Hant) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hant' +func (zh *zh_Hant) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5, 0x20}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hant' +func (zh *zh_Hant) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hant' +func (zh *zh_Hant) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hant' +func (zh *zh_Hant) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x5b}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x5d}...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hant' +func (zh *zh_Hant) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20, 0x5b}...) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x5d}...) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hant/zh_Hant_test.go b/vendor/github.com/go-playground/locales/zh_Hant/zh_Hant_test.go new file mode 100644 index 0000000000..116cf196f2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hant/zh_Hant_test.go @@ -0,0 +1,1120 @@ +package zh_Hant + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hant" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hant_HK/zh_Hant_HK.go b/vendor/github.com/go-playground/locales/zh_Hant_HK/zh_Hant_HK.go new file mode 100644 index 0000000000..f4b0cec9c6 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hant_HK/zh_Hant_HK.go @@ -0,0 +1,573 @@ +package zh_Hant_HK + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hant_HK struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyPositiveSuffix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hant_HK' locale +func New() locales.Translator { + return &zh_Hant_HK{ + locale: "zh_Hant_HK", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyPositiveSuffix: "K", + currencyNegativeSuffix: "K", + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"CST": "北美中部標準時間", "HNOG": "格陵兰岛西部标准时间", "WEZ": "西欧标准时间", "WAST": "西部非洲夏令时间", "ACDT": "澳大利亚中部夏令时间", "HNT": "纽芬兰标准时间", "AEDT": "澳大利亚东部夏令时间", "∅∅∅": "亚速尔群岛夏令时间", "ACWDT": "澳大利亚中西部夏令时间", "OEZ": "东欧标准时间", "MYT": "马来西亚时间", "TMT": "土库曼斯坦标准时间", "GMT": "格林尼治标准时间", "MST": "澳门标准时间", "ARST": "阿根廷夏令时间", "SRT": "蘇里南時間", "BOT": "玻利维亚标准时间", "IST": "印度時間", "NZDT": "新西兰夏令时间", "VET": "委内瑞拉时间", "EST": "北美東部標準時間", "HNNOMX": "墨西哥西北部标准时间", "HAST": "夏威夷-阿留申标准时间", "MEZ": "中欧标准时间", "MDT": "澳门夏令时间", "BT": "不丹时间", "EAT": "东部非洲时间", "OESZ": "东欧夏令时间", "WARST": "阿根廷西部夏令时间", "TMST": "土库曼斯坦夏令时间", "HNCU": "古巴标准时间", "AWDT": "澳大利亚西部夏令时间", "CAT": "中部非洲时间", "GFT": "法属圭亚那标准时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "HNPMX": "墨西哥太平洋标准时间", "CLT": "智利标准时间", "HENOMX": "墨西哥西北部夏令时间", "WITA": "印度尼西亚中部时间", "ChST": "查莫罗时间", "AWST": "澳大利亚西部标准时间", "ACWST": "澳大利亚中西部标准时间", "COST": "哥伦比亚夏令时间", "HEEG": "格陵兰岛东部夏令时间", "UYST": "乌拉圭夏令时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "SAST": "南非時間", "PST": "北美太平洋標準時間", "ADT": "大西洋夏令时间", "HKST": "香港夏令时间", "AKDT": "阿拉斯加夏令时间", "JDT": "日本夏令时间", "AST": "大西洋标准时间", "WESZ": "西欧夏令时间", "HEPMX": "墨西哥太平洋夏令时间", "WIB": "印度尼西亚西部时间", "CHAST": "查坦标准时间", "NZST": "新西兰标准时间", "MESZ": "中欧夏令时间", "EDT": "北美東部夏令時間", "HNEG": "格陵兰岛东部标准时间", "AEST": "澳大利亚东部标准时间", "JST": "日本标准时间", "HKT": "香港标准时间", "ACST": "澳大利亚中部标准时间", "COT": "哥伦比亚标准时间", "HAT": "纽芬兰夏令时间", "CHADT": "查坦夏令时间", "CLST": "智利夏令时间", "HEOG": "格陵兰岛西部夏令时间", "UYT": "乌拉圭标准时间", "CDT": "中部夏令時間", "PDT": "北美太平洋夏令時間", "WART": "阿根廷西部标准时间", "GYT": "圭亞那時間", "HECU": "古巴夏令时间", "ECT": "厄瓜多爾時間", "ART": "阿根廷标准时间", "WAT": "西部非洲标准时间", "AKST": "阿拉斯加标准时间", "LHST": "豪勋爵岛标准时间", "LHDT": "豪勋爵岛夏令时间", "WIT": "印度尼西亚东部时间", "SGT": "新加坡時間", "HADT": "夏威夷-阿留申夏令时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hant_HK) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hant_HK' +func (zh *zh_Hant_HK) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hant_HK' +func (zh *zh_Hant_HK) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hant_HK' +func (zh *zh_Hant_HK) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hant_HK) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hant_HK) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hant_HK) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hant_HK) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hant_HK) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hant_HK) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hant_HK) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hant_HK) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hant_HK) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hant_HK) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hant_HK) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hant_HK) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hant_HK) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hant_HK) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hant_HK' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hant_HK) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hant_HK' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hant_HK) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.currencyPositiveSuffix...) + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant_HK' +// in accounting notation. +func (zh *zh_Hant_HK) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 3 + + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if num < 0 { + b = append(b, zh.currencyNegativeSuffix...) + } else { + + b = append(b, zh.currencyPositiveSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hant_HK' +func (zh *zh_Hant_HK) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hant_HK/zh_Hant_HK_test.go b/vendor/github.com/go-playground/locales/zh_Hant_HK/zh_Hant_HK_test.go new file mode 100644 index 0000000000..fb0c856108 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hant_HK/zh_Hant_HK_test.go @@ -0,0 +1,1120 @@ +package zh_Hant_HK + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hant_HK" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hant_MO/zh_Hant_MO.go b/vendor/github.com/go-playground/locales/zh_Hant_MO/zh_Hant_MO.go new file mode 100644 index 0000000000..035055b171 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hant_MO/zh_Hant_MO.go @@ -0,0 +1,604 @@ +package zh_Hant_MO + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hant_MO struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hant_MO' locale +func New() locales.Translator { + return &zh_Hant_MO{ + locale: "zh_Hant_MO", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP$", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"公元前", "公元"}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"∅∅∅": "亚马逊夏令时间", "WART": "阿根廷西部标准时间", "HKST": "香港夏令时间", "HENOMX": "墨西哥西北部夏令时间", "CDT": "北美中部夏令时间", "BOT": "玻利维亚标准时间", "CHAST": "查坦标准时间", "PDT": "北美太平洋夏令时间", "MEZ": "中欧标准时间", "ADT": "大西洋夏令时间", "MDT": "澳门夏令时间", "AEST": "澳大利亚东部标准时间", "PST": "北美太平洋标准时间", "OEZ": "东欧标准时间", "HNNOMX": "墨西哥西北部标准时间", "HNCU": "古巴标准时间", "SGT": "新加坡标准时间", "HAT": "纽芬兰夏令时间", "HADT": "夏威夷-阿留申夏令时间", "ACWST": "澳大利亚中西部标准时间", "HNOG": "格陵兰岛西部标准时间", "EDT": "北美东部夏令时间", "HNEG": "格陵兰岛东部标准时间", "IST": "印度时间", "CLT": "智利标准时间", "SAST": "南部非洲时间", "WIT": "印度尼西亚东部时间", "HKT": "香港标准时间", "BT": "不丹时间", "AWST": "澳大利亚西部标准时间", "ECT": "厄瓜多尔标准时间", "CAT": "中部非洲时间", "JST": "日本标准时间", "GMT": "格林尼治标准时间", "ART": "阿根廷标准时间", "NZST": "新西兰标准时间", "MYT": "马来西亚时间", "WAST": "西部非洲夏令时间", "ChST": "查莫罗时间", "HEPMX": "墨西哥太平洋夏令时间", "COT": "哥伦比亚标准时间", "GFT": "法属圭亚那标准时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "HAST": "夏威夷-阿留申标准时间", "ACWDT": "澳大利亚中西部夏令时间", "NZDT": "新西兰夏令时间", "LHDT": "豪勋爵岛夏令时间", "ACDT": "澳大利亚中部夏令时间", "AEDT": "澳大利亚东部夏令时间", "UYST": "乌拉圭夏令时间", "WEZ": "西欧标准时间", "TMST": "土库曼斯坦夏令时间", "EST": "北美东部标准时间", "WAT": "西部非洲标准时间", "COST": "哥伦比亚夏令时间", "HEPM": "圣皮埃尔和密克隆群岛夏令时间", "LHST": "豪勋爵岛标准时间", "VET": "委内瑞拉时间", "AST": "大西洋标准时间", "UYT": "乌拉圭标准时间", "SRT": "苏里南时间", "CST": "北美中部标准时间", "HNPMX": "墨西哥太平洋标准时间", "GYT": "圭亚那时间", "CLST": "智利夏令时间", "HEOG": "格陵兰岛西部夏令时间", "MST": "澳门标准时间", "HNT": "纽芬兰标准时间", "EAT": "东部非洲时间", "TMT": "土库曼斯坦标准时间", "ACST": "澳大利亚中部标准时间", "HECU": "古巴夏令时间", "JDT": "日本夏令时间", "MESZ": "中欧夏令时间", "OESZ": "东欧夏令时间", "WESZ": "西欧夏令时间", "WARST": "阿根廷西部夏令时间", "AWDT": "澳大利亚西部夏令时间", "WIB": "印度尼西亚西部时间", "CHADT": "查坦夏令时间", "ARST": "阿根廷夏令时间", "HEEG": "格陵兰岛东部夏令时间", "WITA": "印度尼西亚中部时间", "AKST": "阿拉斯加标准时间", "AKDT": "阿拉斯加夏令时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hant_MO) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hant_MO' +func (zh *zh_Hant_MO) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hant_MO' +func (zh *zh_Hant_MO) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hant_MO' +func (zh *zh_Hant_MO) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hant_MO) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hant_MO) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hant_MO) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hant_MO) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hant_MO) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hant_MO) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hant_MO) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hant_MO) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hant_MO) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hant_MO) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hant_MO) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hant_MO) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hant_MO) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hant_MO) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hant_MO' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hant_MO) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hant_MO' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hant_MO) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant_MO' +// in accounting notation. +func (zh *zh_Hant_MO) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hant_MO' +func (zh *zh_Hant_MO) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hant_MO/zh_Hant_MO_test.go b/vendor/github.com/go-playground/locales/zh_Hant_MO/zh_Hant_MO_test.go new file mode 100644 index 0000000000..bf43b0344f --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hant_MO/zh_Hant_MO_test.go @@ -0,0 +1,1120 @@ +package zh_Hant_MO + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hant_MO" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zh_Hant_TW/zh_Hant_TW.go b/vendor/github.com/go-playground/locales/zh_Hant_TW/zh_Hant_TW.go new file mode 100644 index 0000000000..e8a052f94c --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hant_TW/zh_Hant_TW.go @@ -0,0 +1,604 @@ +package zh_Hant_TW + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zh_Hant_TW struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zh_Hant_TW' locale +func New() locales.Translator { + return &zh_Hant_TW{ + locale: "zh_Hant_TW", + pluralsCardinal: []locales.PluralRule{6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + monthsAbbreviated: []string{"", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}, + monthsNarrow: []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"}, + monthsWide: []string{"", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"}, + daysAbbreviated: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysNarrow: []string{"日", "一", "二", "三", "四", "五", "六"}, + daysShort: []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}, + daysWide: []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}, + periodsAbbreviated: []string{"上午", "下午"}, + periodsNarrow: []string{"上午", "下午"}, + periodsWide: []string{"上午", "下午"}, + erasAbbreviated: []string{"公元前", "公元"}, + erasNarrow: []string{"公元前", "公元"}, + erasWide: []string{"公元前", "公元"}, + timezones: map[string]string{"HEPM": "圣皮埃尔和密克隆群岛夏令时间", "GYT": "圭亚那时间", "WEZ": "西欧标准时间", "WAST": "西部非洲夏令时间", "HNT": "纽芬兰标准时间", "WITA": "印度尼西亚中部时间", "AKST": "阿拉斯加标准时间", "UYST": "乌拉圭夏令时间", "ADT": "大西洋夏令时间", "TMST": "土库曼斯坦夏令时间", "LHDT": "豪勋爵岛夏令时间", "SRT": "苏里南时间", "HEEG": "格陵兰岛东部夏令时间", "AEDT": "澳大利亚东部夏令时间", "GFT": "法属圭亚那标准时间", "UYT": "乌拉圭标准时间", "LHST": "豪勋爵岛标准时间", "HNNOMX": "墨西哥西北部标准时间", "HENOMX": "墨西哥西北部夏令时间", "∅∅∅": "阿克里夏令时间", "WIT": "印度尼西亚东部时间", "HAST": "夏威夷-阿留申标准时间", "ART": "阿根廷标准时间", "BT": "不丹时间", "AWST": "澳大利亚西部标准时间", "MEZ": "中欧标准时间", "HNOG": "格陵兰岛西部标准时间", "HAT": "纽芬兰夏令时间", "HNCU": "古巴标准时间", "CST": "北美中部标准时间", "MESZ": "中欧夏令时间", "CAT": "中部非洲时间", "CLST": "智利夏令时间", "COT": "哥伦比亚标准时间", "HNEG": "格陵兰岛东部标准时间", "HECU": "古巴夏令时间", "SGT": "新加坡标准时间", "ACWST": "澳大利亚中西部标准时间", "WIB": "印度尼西亚西部时间", "EAT": "东部非洲时间", "NZST": "新西兰标准时间", "HADT": "夏威夷-阿留申夏令时间", "ECT": "厄瓜多尔标准时间", "OEZ": "东欧标准时间", "HKT": "香港标准时间", "ACST": "澳大利亚中部标准时间", "CDT": "北美中部夏令时间", "CHAST": "查坦标准时间", "CHADT": "查坦夏令时间", "WARST": "阿根廷西部夏令时间", "HEOG": "格陵兰岛西部夏令时间", "PST": "北美太平洋标准时间", "IST": "印度时间", "JDT": "日本夏令时间", "ARST": "阿根廷夏令时间", "EDT": "北美东部夏令时间", "HKST": "香港夏令时间", "HEPMX": "墨西哥太平洋夏令时间", "AWDT": "澳大利亚西部夏令时间", "GMT": "格林尼治标准时间", "AST": "大西洋标准时间", "AEST": "澳大利亚东部标准时间", "AKDT": "阿拉斯加夏令时间", "CLT": "智利标准时间", "HNPM": "圣皮埃尔和密克隆群岛标准时间", "NZDT": "新西兰夏令时间", "JST": "日本标准时间", "OESZ": "东欧夏令时间", "WART": "阿根廷西部标准时间", "WAT": "西部非洲标准时间", "COST": "哥伦比亚夏令时间", "ChST": "查莫罗时间", "BOT": "玻利维亚标准时间", "ACWDT": "澳大利亚中西部夏令时间", "SAST": "南部非洲时间", "PDT": "北美太平洋夏令时间", "MDT": "澳门夏令时间", "VET": "委内瑞拉时间", "WESZ": "西欧夏令时间", "MYT": "马来西亚时间", "MST": "澳门标准时间", "EST": "北美东部标准时间", "ACDT": "澳大利亚中部夏令时间", "HNPMX": "墨西哥太平洋标准时间", "TMT": "土库曼斯坦标准时间"}, + } +} + +// Locale returns the current translators string locale +func (zh *zh_Hant_TW) Locale() string { + return zh.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zh_Hant_TW' +func (zh *zh_Hant_TW) PluralsCardinal() []locales.PluralRule { + return zh.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zh_Hant_TW' +func (zh *zh_Hant_TW) PluralsOrdinal() []locales.PluralRule { + return zh.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zh_Hant_TW' +func (zh *zh_Hant_TW) PluralsRange() []locales.PluralRule { + return zh.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zh *zh_Hant_TW) MonthAbbreviated(month time.Month) string { + return zh.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zh *zh_Hant_TW) MonthsAbbreviated() []string { + return zh.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zh *zh_Hant_TW) MonthNarrow(month time.Month) string { + return zh.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zh *zh_Hant_TW) MonthsNarrow() []string { + return zh.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zh *zh_Hant_TW) MonthWide(month time.Month) string { + return zh.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zh *zh_Hant_TW) MonthsWide() []string { + return zh.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zh *zh_Hant_TW) WeekdayAbbreviated(weekday time.Weekday) string { + return zh.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zh *zh_Hant_TW) WeekdaysAbbreviated() []string { + return zh.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zh *zh_Hant_TW) WeekdayNarrow(weekday time.Weekday) string { + return zh.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zh *zh_Hant_TW) WeekdaysNarrow() []string { + return zh.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zh *zh_Hant_TW) WeekdayShort(weekday time.Weekday) string { + return zh.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zh *zh_Hant_TW) WeekdaysShort() []string { + return zh.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zh *zh_Hant_TW) WeekdayWide(weekday time.Weekday) string { + return zh.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zh *zh_Hant_TW) WeekdaysWide() []string { + return zh.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zh_Hant_TW' and handles both Whole and Real numbers based on 'v' +func (zh *zh_Hant_TW) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zh_Hant_TW' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zh *zh_Hant_TW) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zh.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zh.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zh_Hant_TW' +// in accounting notation. +func (zh *zh_Hant_TW) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zh.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zh.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zh.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zh.minus[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zh.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + b = append(b, []byte{0xe5, 0xb9, 0xb4}...) + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0xe6, 0x9c, 0x88}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0xe6, 0x97, 0xa5}...) + b = append(b, zh.daysWide[t.Weekday()]...) + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + b = append(b, tz...) + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zh_Hant_TW' +func (zh *zh_Hant_TW) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + tz, _ := t.Zone() + + if btz, ok := zh.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + b = append(b, []byte{0x20}...) + + if t.Hour() < 12 { + b = append(b, zh.periodsAbbreviated[0]...) + } else { + b = append(b, zh.periodsAbbreviated[1]...) + } + + h := t.Hour() + + if h > 12 { + h -= 12 + } + + b = strconv.AppendInt(b, int64(h), 10) + b = append(b, zh.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zh.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zh_Hant_TW/zh_Hant_TW_test.go b/vendor/github.com/go-playground/locales/zh_Hant_TW/zh_Hant_TW_test.go new file mode 100644 index 0000000000..b25db16621 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zh_Hant_TW/zh_Hant_TW_test.go @@ -0,0 +1,1120 @@ +package zh_Hant_TW + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zh_Hant_TW" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zu/zu.go b/vendor/github.com/go-playground/locales/zu/zu.go new file mode 100644 index 0000000000..3f222184c2 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zu/zu.go @@ -0,0 +1,595 @@ +package zu + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zu struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zu' locale +func New() locales.Translator { + return &zu{ + locale: "zu", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "R", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mas", "Eph", "Mey", "Jun", "Jul", "Aga", "Sep", "Okt", "Nov", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "E", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "UMasingana", "Februwari", "Mashi", "Ephreli", "Meyi", "Juni", "Julayi", "Agasti", "Septhemba", "Okthoba", "Novemba", "Disemba"}, + daysAbbreviated: []string{"Son", "Mso", "Bil", "Tha", "Sin", "Hla", "Mgq"}, + daysNarrow: []string{"S", "M", "B", "T", "S", "H", "M"}, + daysShort: []string{"Son", "Mso", "Bil", "Tha", "Sin", "Hla", "Mgq"}, + daysWide: []string{"ISonto", "UMsombuluko", "ULwesibili", "ULwesithathu", "ULwesine", "ULwesihlanu", "UMgqibelo"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"BC", "AD"}, + timezones: map[string]string{"HNOG": "Isikhathi sase-West Greenland esijwayelekile", "MST": "MST", "HENOMX": "Isikhathi sase-Northwest Mexico sasemini", "AKDT": "Isikhathi sase-Alaska sasemini", "HNCU": "Isikhathi sase-Cuba esijwayelekile", "JDT": "Isikhathi semini sase-Japan", "HNEG": "Isikhathi sase-East Greenland esijwayelekile", "HEPMX": "Isikhathi sase-Mexican Pacific sasemini", "CDT": "Isikhathi sase-North American Central sasemini", "CLST": "Isikhathi sase-Chile sasehlobo", "VET": "Isikhathi sase-Venezuela", "AEST": "Isikhathi esivamile sase-Australian East", "HNPM": "Iikhathi sase-Saint Pierre nase-Miquelon esijwayelekile", "WIT": "Isikhathi sase-Eastern Indonesia", "HAST": "Isikhathi sase-Hawaii-Aleutia esijwayelekile", "MESZ": "Isikhathi sasehlobo sase-Central Europe", "HEPM": "Isikhathi sase-Saint Pierre nase-Miquelon sasemini", "SRT": "Isikhathi sase-Suriname", "ECT": "Isikhathi sase-Ecuador", "WAT": "Isikhathi esijwayelekile saseNtshonalanga Afrika", "COT": "Isikhathi sase-Colombia esijwayelekile", "GFT": "Isikhathi sase-French Guiana", "WITA": "Isikhathi sase-Central Indonesia", "AKST": "Isikhathi sase-Alaska esijwayelekile", "NZDT": "Isikhathi sasemini sase-New Zealand", "HKT": "Isikhathi esivamile sase-Hong Kong", "AEDT": "Isikhathi sasemini sase-Australian East", "WEZ": "Isikhathi esijwayelekile sase-Western Europe", "HEOG": "Isikhathi sase-West Greenland sasehlobo", "ADT": "Isikhathi sase-Atlantic sasemini", "EDT": "Isikhathi sase-North American East sasemini", "ACDT": "Isikhathi sase-Australian Central sasemini", "HNPMX": "Isikhathi sase-Mexican Pacific esijwayelekile", "SAST": "Isikhathi esijwayelekile saseNingizimu Afrika", "AWST": "Isikhathi sase-Australian Western esivamile", "ACWDT": "Isikhathi sasemini sase-Australian Central West", "HNNOMX": "Isikhathi sase-Northwest Mexico esijwayelekile", "HNT": "Isikhathi sase-Newfoundland esijwayelekile", "ChST": "Isikhathi esijwayelekile sase-Chamorro", "AWDT": "Isikhathi sase-Australian Western sasemini", "HADT": "Isikhathi sase-Hawaii-Aleutia sasemini", "COST": "Isikhathi sase-Colombia sasehlobo", "MEZ": "Isikhathi esijwayelekile sase-Central Europe", "UYT": "Isikhathi sase-Uruguay esijwayelekile", "JST": "Isikhathi esivamile sase-Japan", "WESZ": "Isikhathi sasehlobo sase-Western Europe", "LHDT": "Isikhathi sase-Lord Howe sasemini", "GYT": "Isikhathi sase-Guyana", "PDT": "Isikhathi sase-North American Pacific sasemini", "ART": "Isikhathi sase-Argentina esijwayelekile", "ARST": "Isikhathi sase-Argentina sasehlobo", "HKST": "Isikhathi sehlobo sase-Hong Kong", "WAST": "Isikhathi sasehlobo saseNtshonalanga Afrika", "LHST": "Isikhathi sase-Lord Howe esivamile", "WART": "Isikhathi saseNyakatho ne-Argentina esijwayelekile", "WARST": "Isikhathi saseNyakatho ne-Argentina sasehlobo", "IST": "Isikhathi sase-India esivamile", "∅∅∅": "∅∅∅", "HAT": "Isikhathi sase-Newfoundland sasemini", "EAT": "Isikhathi saseMpumalanga Afrika", "BOT": "Isikhathi sase-Bolivia", "CAT": "Isikhathi sase-Central Africa", "BT": "Isikhathi sase-Bhutan", "CHAST": "Isikhathi esivamile sase-Chatham", "SGT": "Isikhathi esivamile sase-Singapore", "TMST": "Isikhathi sehlobo sase-Turkmenistan", "ACST": "Isikhathi sase-Australian Central esivamile", "PST": "Isikhathi sase-North American Pacific esijwayelekile", "CLT": "Isikhathi sase-Chile esijwayelekile", "AST": "Isikhathi sase-Atlantic esijwayelekile", "TMT": "Isikhathi esivamile sase-Turkmenistan", "NZST": "Isikhathi esivamile sase-New Zealand", "MYT": "Isikhathi sase-Malaysia", "OEZ": "Isikhathi esijwayelekile sase-Eastern Europe", "MDT": "MDT", "HEEG": "Isikhathi sase-East Greenland sasemini", "UYST": "Isikhathi sase-Uruguay sasehlobo", "CST": "Isikhathi sase-North American Central esijwayelekile", "GMT": "Isikhathi sase-Greenwich Mean", "OESZ": "Isikhathi sasehlobo sase-Eastern Europe", "EST": "Isikhathi sase-North American East esijwayelekile", "WIB": "Isikhathi sase-Western Indonesia", "HECU": "Isikhathi sase-Cuba sasemini", "CHADT": "Isikhathi sasemini sase-Chatham", "ACWST": "Isikhathi sase-Australian Central West esivamile"}, + } +} + +// Locale returns the current translators string locale +func (zu *zu) Locale() string { + return zu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zu' +func (zu *zu) PluralsCardinal() []locales.PluralRule { + return zu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zu' +func (zu *zu) PluralsOrdinal() []locales.PluralRule { + return zu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zu' +func (zu *zu) PluralsRange() []locales.PluralRule { + return zu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zu' +func (zu *zu) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zu' +func (zu *zu) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zu' +func (zu *zu) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := zu.CardinalPluralRule(num1, v1) + end := zu.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zu *zu) MonthAbbreviated(month time.Month) string { + return zu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zu *zu) MonthsAbbreviated() []string { + return zu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zu *zu) MonthNarrow(month time.Month) string { + return zu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zu *zu) MonthsNarrow() []string { + return zu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zu *zu) MonthWide(month time.Month) string { + return zu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zu *zu) MonthsWide() []string { + return zu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zu *zu) WeekdayAbbreviated(weekday time.Weekday) string { + return zu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zu *zu) WeekdaysAbbreviated() []string { + return zu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zu *zu) WeekdayNarrow(weekday time.Weekday) string { + return zu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zu *zu) WeekdaysNarrow() []string { + return zu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zu *zu) WeekdayShort(weekday time.Weekday) string { + return zu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zu *zu) WeekdaysShort() []string { + return zu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zu *zu) WeekdayWide(weekday time.Weekday) string { + return zu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zu *zu) WeekdaysWide() []string { + return zu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zu' and handles both Whole and Real numbers based on 'v' +func (zu *zu) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zu' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zu *zu) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zu' +func (zu *zu) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zu.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zu' +// in accounting notation. +func (zu *zu) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zu.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, zu.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zu' +func (zu *zu) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zu' +func (zu *zu) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, zu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zu' +func (zu *zu) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, zu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zu' +func (zu *zu) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, zu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, zu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zu' +func (zu *zu) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zu' +func (zu *zu) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zu' +func (zu *zu) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zu' +func (zu *zu) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := zu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zu/zu_test.go b/vendor/github.com/go-playground/locales/zu/zu_test.go new file mode 100644 index 0000000000..2dcabb62c8 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zu/zu_test.go @@ -0,0 +1,1120 @@ +package zu + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zu" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/locales/zu_ZA/zu_ZA.go b/vendor/github.com/go-playground/locales/zu_ZA/zu_ZA.go new file mode 100644 index 0000000000..2f9bc2b6f7 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zu_ZA/zu_ZA.go @@ -0,0 +1,595 @@ +package zu_ZA + +import ( + "math" + "strconv" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +type zu_ZA struct { + locale string + pluralsCardinal []locales.PluralRule + pluralsOrdinal []locales.PluralRule + pluralsRange []locales.PluralRule + decimal string + group string + minus string + percent string + perMille string + timeSeparator string + inifinity string + currencies []string // idx = enum of currency code + currencyNegativePrefix string + currencyNegativeSuffix string + monthsAbbreviated []string + monthsNarrow []string + monthsWide []string + daysAbbreviated []string + daysNarrow []string + daysShort []string + daysWide []string + periodsAbbreviated []string + periodsNarrow []string + periodsShort []string + periodsWide []string + erasAbbreviated []string + erasNarrow []string + erasWide []string + timezones map[string]string +} + +// New returns a new instance of translator for the 'zu_ZA' locale +func New() locales.Translator { + return &zu_ZA{ + locale: "zu_ZA", + pluralsCardinal: []locales.PluralRule{2, 6}, + pluralsOrdinal: []locales.PluralRule{6}, + pluralsRange: []locales.PluralRule{2, 6}, + decimal: ".", + group: ",", + minus: "-", + percent: "%", + perMille: "‰", + timeSeparator: ":", + inifinity: "∞", + currencies: []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"}, + currencyNegativePrefix: "(", + currencyNegativeSuffix: ")", + monthsAbbreviated: []string{"", "Jan", "Feb", "Mas", "Eph", "Mey", "Jun", "Jul", "Aga", "Sep", "Okt", "Nov", "Dis"}, + monthsNarrow: []string{"", "J", "F", "M", "E", "M", "J", "J", "A", "S", "O", "N", "D"}, + monthsWide: []string{"", "UMasingana", "Februwari", "Mashi", "Ephreli", "Meyi", "Juni", "Julayi", "Agasti", "Septhemba", "Okthoba", "Novemba", "Disemba"}, + daysAbbreviated: []string{"Son", "Mso", "Bil", "Tha", "Sin", "Hla", "Mgq"}, + daysNarrow: []string{"S", "M", "B", "T", "S", "H", "M"}, + daysShort: []string{"Son", "Mso", "Bil", "Tha", "Sin", "Hla", "Mgq"}, + daysWide: []string{"ISonto", "UMsombuluko", "ULwesibili", "ULwesithathu", "ULwesine", "ULwesihlanu", "UMgqibelo"}, + periodsAbbreviated: []string{"AM", "PM"}, + periodsNarrow: []string{"a", "p"}, + periodsWide: []string{"AM", "PM"}, + erasAbbreviated: []string{"BC", "AD"}, + erasNarrow: []string{"", ""}, + erasWide: []string{"BC", "AD"}, + timezones: map[string]string{"LHDT": "Isikhathi sase-Lord Howe sasemini", "HNCU": "Isikhathi sase-Cuba esijwayelekile", "PDT": "Isikhathi sase-North American Pacific sasemini", "MESZ": "Isikhathi sasehlobo sase-Central Europe", "ACDT": "Isikhathi sase-Australian Central sasemini", "HAT": "Isikhathi sase-Newfoundland sasemini", "AKDT": "Isikhathi sase-Alaska sasemini", "HNPM": "Iikhathi sase-Saint Pierre nase-Miquelon esijwayelekile", "AWST": "Isikhathi sase-Australian Western esivamile", "ECT": "Isikhathi sase-Ecuador", "ACWST": "Isikhathi sase-Australian Central West esivamile", "NZDT": "Isikhathi sasemini sase-New Zealand", "OEZ": "Isikhathi esijwayelekile sase-Eastern Europe", "WESZ": "Isikhathi sasehlobo sase-Western Europe", "MDT": "MDT", "GFT": "Isikhathi sase-French Guiana", "CDT": "Isikhathi sase-North American Central sasemini", "GMT": "Isikhathi sase-Greenwich Mean", "MYT": "Isikhathi sase-Malaysia", "ACST": "Isikhathi sase-Australian Central esivamile", "HNT": "Isikhathi sase-Newfoundland esijwayelekile", "HENOMX": "Isikhathi sase-Northwest Mexico sasemini", "WIB": "Isikhathi sase-Western Indonesia", "PST": "Isikhathi sase-North American Pacific esijwayelekile", "MEZ": "Isikhathi esijwayelekile sase-Central Europe", "WARST": "Isikhathi saseNyakatho ne-Argentina sasehlobo", "WAST": "Isikhathi sasehlobo saseNtshonalanga Afrika", "EST": "Isikhathi sase-North American East esijwayelekile", "EDT": "Isikhathi sase-North American East sasemini", "WEZ": "Isikhathi esijwayelekile sase-Western Europe", "CLST": "Isikhathi sase-Chile sasehlobo", "HKST": "Isikhathi sehlobo sase-Hong Kong", "CST": "Isikhathi sase-North American Central esijwayelekile", "ADT": "Isikhathi sase-Atlantic sasemini", "ChST": "Isikhathi esijwayelekile sase-Chamorro", "CHAST": "Isikhathi esivamile sase-Chatham", "HADT": "Isikhathi sase-Hawaii-Aleutia sasemini", "HEOG": "Isikhathi sase-West Greenland sasehlobo", "TMST": "Isikhathi sehlobo sase-Turkmenistan", "COST": "Isikhathi sase-Colombia sasehlobo", "BT": "Isikhathi sase-Bhutan", "SGT": "Isikhathi esivamile sase-Singapore", "CAT": "Isikhathi sase-Central Africa", "JST": "Isikhathi esivamile sase-Japan", "JDT": "Isikhathi semini sase-Japan", "WAT": "Isikhathi esijwayelekile saseNtshonalanga Afrika", "AKST": "Isikhathi sase-Alaska esijwayelekile", "HNPMX": "Isikhathi sase-Mexican Pacific esijwayelekile", "HEPMX": "Isikhathi sase-Mexican Pacific sasemini", "HAST": "Isikhathi sase-Hawaii-Aleutia esijwayelekile", "HNOG": "Isikhathi sase-West Greenland esijwayelekile", "CLT": "Isikhathi sase-Chile esijwayelekile", "HEEG": "Isikhathi sase-East Greenland sasemini", "AEDT": "Isikhathi sasemini sase-Australian East", "SAST": "Isikhathi esijwayelekile saseNingizimu Afrika", "GYT": "Isikhathi sase-Guyana", "EAT": "Isikhathi saseMpumalanga Afrika", "AWDT": "Isikhathi sase-Australian Western sasemini", "ART": "Isikhathi sase-Argentina esijwayelekile", "SRT": "Isikhathi sase-Suriname", "IST": "Isikhathi sase-India esivamile", "AST": "Isikhathi sase-Atlantic esijwayelekile", "COT": "Isikhathi sase-Colombia esijwayelekile", "∅∅∅": "Isikhathi sase-Amazon sasehlobo", "OESZ": "Isikhathi sasehlobo sase-Eastern Europe", "WART": "Isikhathi saseNyakatho ne-Argentina esijwayelekile", "LHST": "Isikhathi sase-Lord Howe esivamile", "BOT": "Isikhathi sase-Bolivia", "TMT": "Isikhathi esivamile sase-Turkmenistan", "WITA": "Isikhathi sase-Central Indonesia", "AEST": "Isikhathi esivamile sase-Australian East", "UYT": "Isikhathi sase-Uruguay esijwayelekile", "WIT": "Isikhathi sase-Eastern Indonesia", "NZST": "Isikhathi esivamile sase-New Zealand", "HNNOMX": "Isikhathi sase-Northwest Mexico esijwayelekile", "HEPM": "Isikhathi sase-Saint Pierre nase-Miquelon sasemini", "HECU": "Isikhathi sase-Cuba sasemini", "UYST": "Isikhathi sase-Uruguay sasehlobo", "CHADT": "Isikhathi sasemini sase-Chatham", "ACWDT": "Isikhathi sasemini sase-Australian Central West", "VET": "Isikhathi sase-Venezuela", "MST": "MST", "ARST": "Isikhathi sase-Argentina sasehlobo", "HKT": "Isikhathi esivamile sase-Hong Kong", "HNEG": "Isikhathi sase-East Greenland esijwayelekile"}, + } +} + +// Locale returns the current translators string locale +func (zu *zu_ZA) Locale() string { + return zu.locale +} + +// PluralsCardinal returns the list of cardinal plural rules associated with 'zu_ZA' +func (zu *zu_ZA) PluralsCardinal() []locales.PluralRule { + return zu.pluralsCardinal +} + +// PluralsOrdinal returns the list of ordinal plural rules associated with 'zu_ZA' +func (zu *zu_ZA) PluralsOrdinal() []locales.PluralRule { + return zu.pluralsOrdinal +} + +// PluralsRange returns the list of range plural rules associated with 'zu_ZA' +func (zu *zu_ZA) PluralsRange() []locales.PluralRule { + return zu.pluralsRange +} + +// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'zu_ZA' +func (zu *zu_ZA) CardinalPluralRule(num float64, v uint64) locales.PluralRule { + + n := math.Abs(num) + i := int64(n) + + if (i == 0) || (n == 1) { + return locales.PluralRuleOne + } + + return locales.PluralRuleOther +} + +// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'zu_ZA' +func (zu *zu_ZA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { + return locales.PluralRuleOther +} + +// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'zu_ZA' +func (zu *zu_ZA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { + + start := zu.CardinalPluralRule(num1, v1) + end := zu.CardinalPluralRule(num2, v2) + + if start == locales.PluralRuleOne && end == locales.PluralRuleOne { + return locales.PluralRuleOne + } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { + return locales.PluralRuleOther + } + + return locales.PluralRuleOther + +} + +// MonthAbbreviated returns the locales abbreviated month given the 'month' provided +func (zu *zu_ZA) MonthAbbreviated(month time.Month) string { + return zu.monthsAbbreviated[month] +} + +// MonthsAbbreviated returns the locales abbreviated months +func (zu *zu_ZA) MonthsAbbreviated() []string { + return zu.monthsAbbreviated[1:] +} + +// MonthNarrow returns the locales narrow month given the 'month' provided +func (zu *zu_ZA) MonthNarrow(month time.Month) string { + return zu.monthsNarrow[month] +} + +// MonthsNarrow returns the locales narrow months +func (zu *zu_ZA) MonthsNarrow() []string { + return zu.monthsNarrow[1:] +} + +// MonthWide returns the locales wide month given the 'month' provided +func (zu *zu_ZA) MonthWide(month time.Month) string { + return zu.monthsWide[month] +} + +// MonthsWide returns the locales wide months +func (zu *zu_ZA) MonthsWide() []string { + return zu.monthsWide[1:] +} + +// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided +func (zu *zu_ZA) WeekdayAbbreviated(weekday time.Weekday) string { + return zu.daysAbbreviated[weekday] +} + +// WeekdaysAbbreviated returns the locales abbreviated weekdays +func (zu *zu_ZA) WeekdaysAbbreviated() []string { + return zu.daysAbbreviated +} + +// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided +func (zu *zu_ZA) WeekdayNarrow(weekday time.Weekday) string { + return zu.daysNarrow[weekday] +} + +// WeekdaysNarrow returns the locales narrow weekdays +func (zu *zu_ZA) WeekdaysNarrow() []string { + return zu.daysNarrow +} + +// WeekdayShort returns the locales short weekday given the 'weekday' provided +func (zu *zu_ZA) WeekdayShort(weekday time.Weekday) string { + return zu.daysShort[weekday] +} + +// WeekdaysShort returns the locales short weekdays +func (zu *zu_ZA) WeekdaysShort() []string { + return zu.daysShort +} + +// WeekdayWide returns the locales wide weekday given the 'weekday' provided +func (zu *zu_ZA) WeekdayWide(weekday time.Weekday) string { + return zu.daysWide[weekday] +} + +// WeekdaysWide returns the locales wide weekdays +func (zu *zu_ZA) WeekdaysWide() []string { + return zu.daysWide +} + +// FmtNumber returns 'num' with digits/precision of 'v' for 'zu_ZA' and handles both Whole and Real numbers based on 'v' +func (zu *zu_ZA) FmtNumber(num float64, v uint64) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + return string(b) +} + +// FmtPercent returns 'num' with digits/precision of 'v' for 'zu_ZA' and handles both Whole and Real numbers based on 'v' +// NOTE: 'num' passed into FmtPercent is assumed to be in percent already +func (zu *zu_ZA) FmtPercent(num float64, v uint64) string { + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + l := len(s) + 3 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zu.decimal[0]) + continue + } + + b = append(b, s[i]) + } + + if num < 0 { + b = append(b, zu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + b = append(b, zu.percent...) + + return string(b) +} + +// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'zu_ZA' +func (zu *zu_ZA) FmtCurrency(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zu.currencies[currency] + l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + if num < 0 { + b = append(b, zu.minus[0]) + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + return string(b) +} + +// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'zu_ZA' +// in accounting notation. +func (zu *zu_ZA) FmtAccounting(num float64, v uint64, currency currency.Type) string { + + s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) + symbol := zu.currencies[currency] + l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 + count := 0 + inWhole := v == 0 + b := make([]byte, 0, l) + + for i := len(s) - 1; i >= 0; i-- { + + if s[i] == '.' { + b = append(b, zu.decimal[0]) + inWhole = true + continue + } + + if inWhole { + if count == 3 { + b = append(b, zu.group[0]) + count = 1 + } else { + count++ + } + } + + b = append(b, s[i]) + } + + if num < 0 { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + b = append(b, zu.currencyNegativePrefix[0]) + + } else { + + for j := len(symbol) - 1; j >= 0; j-- { + b = append(b, symbol[j]) + } + + } + + // reverse + for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { + b[i], b[j] = b[j], b[i] + } + + if int(v) < 2 { + + if v == 0 { + b = append(b, zu.decimal...) + } + + for i := 0; i < 2-int(v); i++ { + b = append(b, '0') + } + } + + if num < 0 { + b = append(b, zu.currencyNegativeSuffix...) + } + + return string(b) +} + +// FmtDateShort returns the short date representation of 't' for 'zu_ZA' +func (zu *zu_ZA) FmtDateShort(t time.Time) string { + + b := make([]byte, 0, 32) + + b = strconv.AppendInt(b, int64(t.Month()), 10) + b = append(b, []byte{0x2f}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2f}...) + + if t.Year() > 9 { + b = append(b, strconv.Itoa(t.Year())[2:]...) + } else { + b = append(b, strconv.Itoa(t.Year())[1:]...) + } + + return string(b) +} + +// FmtDateMedium returns the medium date representation of 't' for 'zu_ZA' +func (zu *zu_ZA) FmtDateMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, zu.monthsAbbreviated[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateLong returns the long date representation of 't' for 'zu_ZA' +func (zu *zu_ZA) FmtDateLong(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, zu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtDateFull returns the full date representation of 't' for 'zu_ZA' +func (zu *zu_ZA) FmtDateFull(t time.Time) string { + + b := make([]byte, 0, 32) + + b = append(b, zu.daysWide[t.Weekday()]...) + b = append(b, []byte{0x2c, 0x20}...) + b = append(b, zu.monthsWide[t.Month()]...) + b = append(b, []byte{0x20}...) + b = strconv.AppendInt(b, int64(t.Day()), 10) + b = append(b, []byte{0x2c, 0x20}...) + + if t.Year() > 0 { + b = strconv.AppendInt(b, int64(t.Year()), 10) + } else { + b = strconv.AppendInt(b, int64(t.Year()*-1), 10) + } + + return string(b) +} + +// FmtTimeShort returns the short time representation of 't' for 'zu_ZA' +func (zu *zu_ZA) FmtTimeShort(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + + return string(b) +} + +// FmtTimeMedium returns the medium time representation of 't' for 'zu_ZA' +func (zu *zu_ZA) FmtTimeMedium(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + + return string(b) +} + +// FmtTimeLong returns the long time representation of 't' for 'zu_ZA' +func (zu *zu_ZA) FmtTimeLong(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + b = append(b, tz...) + + return string(b) +} + +// FmtTimeFull returns the full time representation of 't' for 'zu_ZA' +func (zu *zu_ZA) FmtTimeFull(t time.Time) string { + + b := make([]byte, 0, 32) + + if t.Hour() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Hour()), 10) + b = append(b, zu.timeSeparator...) + + if t.Minute() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Minute()), 10) + b = append(b, zu.timeSeparator...) + + if t.Second() < 10 { + b = append(b, '0') + } + + b = strconv.AppendInt(b, int64(t.Second()), 10) + b = append(b, []byte{0x20}...) + + tz, _ := t.Zone() + + if btz, ok := zu.timezones[tz]; ok { + b = append(b, btz...) + } else { + b = append(b, tz...) + } + + return string(b) +} diff --git a/vendor/github.com/go-playground/locales/zu_ZA/zu_ZA_test.go b/vendor/github.com/go-playground/locales/zu_ZA/zu_ZA_test.go new file mode 100644 index 0000000000..19e814dec9 --- /dev/null +++ b/vendor/github.com/go-playground/locales/zu_ZA/zu_ZA_test.go @@ -0,0 +1,1120 @@ +package zu_ZA + +import ( + "testing" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" +) + +func TestLocale(t *testing.T) { + + trans := New() + expected := "zu_ZA" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestPluralsRange(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsRange() + // expected := 1 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsOrdinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleTwo, + // }, + // { + // expected: locales.PluralRuleFew, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsOrdinal() + // expected := 4 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestPluralsCardinal(t *testing.T) { + + trans := New() + + tests := []struct { + expected locales.PluralRule + }{ + // { + // expected: locales.PluralRuleOne, + // }, + // { + // expected: locales.PluralRuleOther, + // }, + } + + rules := trans.PluralsCardinal() + // expected := 2 + // if len(rules) != expected { + // t.Errorf("Expected '%d' Got '%d'", expected, len(rules)) + // } + + for _, tt := range tests { + + r := locales.PluralRuleUnknown + + for i := 0; i < len(rules); i++ { + if rules[i] == tt.expected { + r = rules[i] + break + } + } + if r == locales.PluralRuleUnknown { + t.Errorf("Expected '%s' Got '%s'", tt.expected, r) + } + } +} + +func TestRangePlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num1 float64 + v1 uint64 + num2 float64 + v2 uint64 + expected locales.PluralRule + }{ + // { + // num1: 1, + // v1: 1, + // num2: 2, + // v2: 2, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.RangePluralRule(tt.num1, tt.v1, tt.num2, tt.v2) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestOrdinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 2, + // v: 0, + // expected: locales.PluralRuleTwo, + // }, + // { + // num: 3, + // v: 0, + // expected: locales.PluralRuleFew, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.OrdinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestCardinalPlurals(t *testing.T) { + + trans := New() + + tests := []struct { + num float64 + v uint64 + expected locales.PluralRule + }{ + // { + // num: 1, + // v: 0, + // expected: locales.PluralRuleOne, + // }, + // { + // num: 4, + // v: 0, + // expected: locales.PluralRuleOther, + // }, + } + + for _, tt := range tests { + rule := trans.CardinalPluralRule(tt.num, tt.v) + if rule != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, rule) + } + } +} + +func TestDaysAbbreviated(t *testing.T) { + + trans := New() + days := trans.WeekdaysAbbreviated() + + for i, day := range days { + s := trans.WeekdayAbbreviated(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sun", + // }, + // { + // idx: 1, + // expected: "Mon", + // }, + // { + // idx: 2, + // expected: "Tue", + // }, + // { + // idx: 3, + // expected: "Wed", + // }, + // { + // idx: 4, + // expected: "Thu", + // }, + // { + // idx: 5, + // expected: "Fri", + // }, + // { + // idx: 6, + // expected: "Sat", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayAbbreviated(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysNarrow(t *testing.T) { + + trans := New() + days := trans.WeekdaysNarrow() + + for i, day := range days { + s := trans.WeekdayNarrow(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", string(day), s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "S", + // }, + // { + // idx: 1, + // expected: "M", + // }, + // { + // idx: 2, + // expected: "T", + // }, + // { + // idx: 3, + // expected: "W", + // }, + // { + // idx: 4, + // expected: "T", + // }, + // { + // idx: 5, + // expected: "F", + // }, + // { + // idx: 6, + // expected: "S", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayNarrow(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysShort(t *testing.T) { + + trans := New() + days := trans.WeekdaysShort() + + for i, day := range days { + s := trans.WeekdayShort(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Su", + // }, + // { + // idx: 1, + // expected: "Mo", + // }, + // { + // idx: 2, + // expected: "Tu", + // }, + // { + // idx: 3, + // expected: "We", + // }, + // { + // idx: 4, + // expected: "Th", + // }, + // { + // idx: 5, + // expected: "Fr", + // }, + // { + // idx: 6, + // expected: "Sa", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayShort(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestDaysWide(t *testing.T) { + + trans := New() + days := trans.WeekdaysWide() + + for i, day := range days { + s := trans.WeekdayWide(time.Weekday(i)) + if s != day { + t.Errorf("Expected '%s' Got '%s'", day, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 0, + // expected: "Sunday", + // }, + // { + // idx: 1, + // expected: "Monday", + // }, + // { + // idx: 2, + // expected: "Tuesday", + // }, + // { + // idx: 3, + // expected: "Wednesday", + // }, + // { + // idx: 4, + // expected: "Thursday", + // }, + // { + // idx: 5, + // expected: "Friday", + // }, + // { + // idx: 6, + // expected: "Saturday", + // }, + } + + for _, tt := range tests { + s := trans.WeekdayWide(time.Weekday(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsAbbreviated(t *testing.T) { + + trans := New() + months := trans.MonthsAbbreviated() + + for i, month := range months { + s := trans.MonthAbbreviated(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "Jan", + // }, + // { + // idx: 2, + // expected: "Feb", + // }, + // { + // idx: 3, + // expected: "Mar", + // }, + // { + // idx: 4, + // expected: "Apr", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "Jun", + // }, + // { + // idx: 7, + // expected: "Jul", + // }, + // { + // idx: 8, + // expected: "Aug", + // }, + // { + // idx: 9, + // expected: "Sep", + // }, + // { + // idx: 10, + // expected: "Oct", + // }, + // { + // idx: 11, + // expected: "Nov", + // }, + // { + // idx: 12, + // expected: "Dec", + // }, + } + + for _, tt := range tests { + s := trans.MonthAbbreviated(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsNarrow(t *testing.T) { + + trans := New() + months := trans.MonthsNarrow() + + for i, month := range months { + s := trans.MonthNarrow(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "J", + // }, + // { + // idx: 2, + // expected: "F", + // }, + // { + // idx: 3, + // expected: "M", + // }, + // { + // idx: 4, + // expected: "A", + // }, + // { + // idx: 5, + // expected: "M", + // }, + // { + // idx: 6, + // expected: "J", + // }, + // { + // idx: 7, + // expected: "J", + // }, + // { + // idx: 8, + // expected: "A", + // }, + // { + // idx: 9, + // expected: "S", + // }, + // { + // idx: 10, + // expected: "O", + // }, + // { + // idx: 11, + // expected: "N", + // }, + // { + // idx: 12, + // expected: "D", + // }, + } + + for _, tt := range tests { + s := trans.MonthNarrow(time.Month(tt.idx)) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestMonthsWide(t *testing.T) { + + trans := New() + months := trans.MonthsWide() + + for i, month := range months { + s := trans.MonthWide(time.Month(i + 1)) + if s != month { + t.Errorf("Expected '%s' Got '%s'", month, s) + } + } + + tests := []struct { + idx int + expected string + }{ + // { + // idx: 1, + // expected: "January", + // }, + // { + // idx: 2, + // expected: "February", + // }, + // { + // idx: 3, + // expected: "March", + // }, + // { + // idx: 4, + // expected: "April", + // }, + // { + // idx: 5, + // expected: "May", + // }, + // { + // idx: 6, + // expected: "June", + // }, + // { + // idx: 7, + // expected: "July", + // }, + // { + // idx: 8, + // expected: "August", + // }, + // { + // idx: 9, + // expected: "September", + // }, + // { + // idx: 10, + // expected: "October", + // }, + // { + // idx: 11, + // expected: "November", + // }, + // { + // idx: 12, + // expected: "December", + // }, + } + + for _, tt := range tests { + s := string(trans.MonthWide(time.Month(tt.idx))) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeFull(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + // fixed := time.FixedZone("OTHER", -4) + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am Eastern Standard Time", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, fixed), + // expected: "8:05:01 pm OTHER", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeLong(t *testing.T) { + + // loc, err := time.LoadLocation("America/Toronto") + // if err != nil { + // t.Errorf("Expected '' Got '%s'", err) + // } + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, loc), + // expected: "9:05:01 am EST", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, loc), + // expected: "8:05:01 pm EST", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05:01 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05:01 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtTimeShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 5, 1, 0, time.UTC), + // expected: "9:05 am", + // }, + // { + // t: time.Date(2016, 02, 03, 20, 5, 1, 0, time.UTC), + // expected: "8:05 pm", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtTimeShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateFull(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Wednesday, February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateFull(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateLong(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "February 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateLong(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateMedium(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "Feb 3, 2016", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateMedium(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtDateShort(t *testing.T) { + + tests := []struct { + t time.Time + expected string + }{ + // { + // t: time.Date(2016, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/16", + // }, + // { + // t: time.Date(-500, 02, 03, 9, 0, 1, 0, time.UTC), + // expected: "2/3/500", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtDateShort(tt.t) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtNumber(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // expected: "1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // expected: "1,123,456.6", + // }, + // { + // num: 221123456.5643, + // v: 3, + // expected: "221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // expected: "-221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + // { + // num: -0, + // v: 2, + // expected: "0.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtNumber(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtCurrency(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "-$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "-CAD 221,123,456.564", + // }, + // { + // num: 0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtCurrency(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtAccounting(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + currency currency.Type + expected string + }{ + // { + // num: 1123456.5643, + // v: 2, + // currency: currency.USD, + // expected: "$1,123,456.56", + // }, + // { + // num: 1123456.5643, + // v: 1, + // currency: currency.USD, + // expected: "$1,123,456.60", + // }, + // { + // num: 221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "$221,123,456.564", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.USD, + // expected: "($221,123,456.564)", + // }, + // { + // num: -221123456.5643, + // v: 3, + // currency: currency.CAD, + // expected: "(CAD 221,123,456.564)", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.USD, + // expected: "$0.00", + // }, + // { + // num: -0, + // v: 2, + // currency: currency.CAD, + // expected: "CAD 0.00", + // }, + // { + // num: 1.23, + // v: 0, + // currency: currency.USD, + // expected: "$1.00", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtAccounting(tt.num, tt.v, tt.currency) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFmtPercent(t *testing.T) { + + tests := []struct { + num float64 + v uint64 + expected string + }{ + // { + // num: 15, + // v: 0, + // expected: "15%", + // }, + // { + // num: 15, + // v: 2, + // expected: "15.00%", + // }, + // { + // num: 434.45, + // v: 0, + // expected: "434%", + // }, + // { + // num: 34.4, + // v: 2, + // expected: "34.40%", + // }, + // { + // num: -34, + // v: 0, + // expected: "-34%", + // }, + } + + trans := New() + + for _, tt := range tests { + s := trans.FmtPercent(tt.num, tt.v) + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} diff --git a/vendor/github.com/go-playground/universal-translator/.gitignore b/vendor/github.com/go-playground/universal-translator/.gitignore new file mode 100644 index 0000000000..26617857ee --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/LICENSE b/vendor/github.com/go-playground/universal-translator/LICENSE new file mode 100644 index 0000000000..8d8aba15ba --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Go Playground + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/go-playground/universal-translator/README.md b/vendor/github.com/go-playground/universal-translator/README.md new file mode 100644 index 0000000000..24aef15859 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/README.md @@ -0,0 +1,90 @@ +## universal-translator + +![Project status](https://img.shields.io/badge/version-0.16.0-green.svg) +[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/universal-translator/branches/master/badge.svg)](https://semaphoreci.com/joeybloggs/universal-translator) +[![Coverage Status](https://coveralls.io/repos/github/go-playground/universal-translator/badge.svg)](https://coveralls.io/github/go-playground/universal-translator) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/universal-translator)](https://goreportcard.com/report/github.com/go-playground/universal-translator) +[![GoDoc](https://godoc.org/github.com/go-playground/universal-translator?status.svg)](https://godoc.org/github.com/go-playground/universal-translator) +![License](https://img.shields.io/dub/l/vibe-d.svg) +[![Gitter](https://badges.gitter.im/go-playground/universal-translator.svg)](https://gitter.im/go-playground/universal-translator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + +Universal Translator is an i18n Translator for Go/Golang using CLDR data + pluralization rules + +Why another i18n library? +-------------------------- +Because none of the plural rules seem to be correct out there, including the previous implementation of this package, +so I took it upon myself to create [locales](https://github.com/go-playground/locales) for everyone to use; this package +is a thin wrapper around [locales](https://github.com/go-playground/locales) in order to store and translate text for +use in your applications. + +Features +-------- +- [x] Rules generated from the [CLDR](http://cldr.unicode.org/index/downloads) data, v30.0.3 +- [x] Contains Cardinal, Ordinal and Range Plural Rules +- [x] Contains Month, Weekday and Timezone translations built in +- [x] Contains Date & Time formatting functions +- [x] Contains Number, Currency, Accounting and Percent formatting functions +- [x] Supports the "Gregorian" calendar only ( my time isn't unlimited, had to draw the line somewhere ) +- [x] Support loading translations from files +- [x] Exporting translations to file(s), mainly for getting them professionally translated +- [ ] Code Generation for translation files -> Go code.. i.e. after it has been professionally translated +- [ ] Tests for all languages, I need help with this, please see [here](https://github.com/go-playground/locales/issues/1) + +Installation +----------- + +Use go get + +```shell +go get github.com/go-playground/universal-translator +``` + +Usage & Documentation +------- + +Please see https://godoc.org/github.com/go-playground/universal-translator for usage docs + +##### Examples: + +- [Basic](https://github.com/go-playground/universal-translator/tree/master/examples/basic) +- [Full - no files](https://github.com/go-playground/universal-translator/tree/master/examples/full-no-files) +- [Full - with files](https://github.com/go-playground/universal-translator/tree/master/examples/full-with-files) + +File formatting +-------------- +All types, Plain substitution, Cardinal, Ordinal and Range translations can all be contained withing the same file(s); +they are only separated for easy viewing. + +##### Examples: + +- [Formats](https://github.com/go-playground/universal-translator/tree/master/examples/file-formats) + +##### Basic Makeup +NOTE: not all fields are needed for all translation types, see [examples](https://github.com/go-playground/universal-translator/tree/master/examples/file-formats) +```json +{ + "locale": "en", + "key": "days-left", + "trans": "You have {0} day left.", + "type": "Cardinal", + "rule": "One", + "override": false +} +``` +|Field|Description| +|---|---| +|locale|The locale for which the translation is for.| +|key|The translation key that will be used to store and lookup each translation; normally it is a string or integer.| +|trans|The actual translation text.| +|type|The type of translation Cardinal, Ordinal, Range or "" for a plain substitution(not required to be defined if plain used)| +|rule|The plural rule for which the translation is for eg. One, Two, Few, Many or Other.(not required to be defined if plain used)| +|override|If you wish to override an existing translation that has already been registered, set this to 'true'. 99% of the time there is no need to define it.| + +Help With Tests +--------------- +To anyone interesting in helping or contributing, I sure could use some help creating tests for each language. +Please see issue [here](https://github.com/go-playground/locales/issues/1) for details. + +License +------ +Distributed under MIT License, please see license file in code for more details. diff --git a/vendor/github.com/go-playground/universal-translator/benchmarks_test.go b/vendor/github.com/go-playground/universal-translator/benchmarks_test.go new file mode 100644 index 0000000000..3f5d0a4c41 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/benchmarks_test.go @@ -0,0 +1,110 @@ +package ut + +import ( + "testing" + + "github.com/go-playground/locales/en" +) + +func BenchmarkBasicTranslation(b *testing.B) { + + en := en.New() + ut := New(en, en) + loc, found := ut.FindTranslator("en") + if !found { + b.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + expected error + override bool + }{ + { + key: "welcome", + trans: "Welcome to the site", + expected: nil, + }, + { + key: "welcome-user", + trans: "Welcome to the site {0}", + expected: nil, + }, + { + key: "welcome-user2", + trans: "Welcome to the site {0}, your location is {1}", + expected: nil, + }, + } + + for _, tt := range translations { + if err := loc.Add(tt.key, tt.trans, tt.override); err != nil { + b.Fatalf("adding translation '%s' failed with key '%s'", tt.trans, tt.key) + } + } + + var err error + + b.ResetTimer() + + b.Run("", func(b *testing.B) { + for i := 0; i < b.N; i++ { + if _, err = loc.T("welcome"); err != nil { + b.Error(err) + } + } + }) + + b.Run("Parallel", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + if _, err = loc.T("welcome"); err != nil { + b.Error(err) + } + } + }) + }) + + b.Run("With1Param", func(b *testing.B) { + for i := 0; i < b.N; i++ { + if _, err = loc.T("welcome-user", "Joeybloggs"); err != nil { + b.Error(err) + } + } + }) + + b.Run("ParallelWith1Param", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + if _, err = loc.T("welcome-user", "Joeybloggs"); err != nil { + b.Error(err) + } + } + }) + }) + + b.Run("With2Param", func(b *testing.B) { + for i := 0; i < b.N; i++ { + if _, err = loc.T("welcome-user2", "Joeybloggs", "/dev/tty0"); err != nil { + b.Error(err) + } + } + }) + + b.Run("ParallelWith2Param", func(b *testing.B) { + + b.RunParallel(func(pb *testing.PB) { + + for pb.Next() { + if _, err = loc.T("welcome-user2", "Joeybloggs", "/dev/tty0"); err != nil { + b.Error(err) + } + } + }) + }) +} diff --git a/vendor/github.com/go-playground/universal-translator/errors.go b/vendor/github.com/go-playground/universal-translator/errors.go new file mode 100644 index 0000000000..38b163b626 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/errors.go @@ -0,0 +1,148 @@ +package ut + +import ( + "errors" + "fmt" + + "github.com/go-playground/locales" +) + +var ( + // ErrUnknowTranslation indicates the translation could not be found + ErrUnknowTranslation = errors.New("Unknown Translation") +) + +var _ error = new(ErrConflictingTranslation) +var _ error = new(ErrRangeTranslation) +var _ error = new(ErrOrdinalTranslation) +var _ error = new(ErrCardinalTranslation) +var _ error = new(ErrMissingPluralTranslation) +var _ error = new(ErrExistingTranslator) + +// ErrExistingTranslator is the error representing a conflicting translator +type ErrExistingTranslator struct { + locale string +} + +// Error returns ErrExistingTranslator's internal error text +func (e *ErrExistingTranslator) Error() string { + return fmt.Sprintf("error: conflicting translator for locale '%s'", e.locale) +} + +// ErrConflictingTranslation is the error representing a conflicting translation +type ErrConflictingTranslation struct { + locale string + key interface{} + rule locales.PluralRule + text string +} + +// Error returns ErrConflictingTranslation's internal error text +func (e *ErrConflictingTranslation) Error() string { + + if _, ok := e.key.(string); !ok { + return fmt.Sprintf("error: conflicting key '%#v' rule '%s' with text '%s' for locale '%s', value being ignored", e.key, e.rule, e.text, e.locale) + } + + return fmt.Sprintf("error: conflicting key '%s' rule '%s' with text '%s' for locale '%s', value being ignored", e.key, e.rule, e.text, e.locale) +} + +// ErrRangeTranslation is the error representing a range translation error +type ErrRangeTranslation struct { + text string +} + +// Error returns ErrRangeTranslation's internal error text +func (e *ErrRangeTranslation) Error() string { + return e.text +} + +// ErrOrdinalTranslation is the error representing an ordinal translation error +type ErrOrdinalTranslation struct { + text string +} + +// Error returns ErrOrdinalTranslation's internal error text +func (e *ErrOrdinalTranslation) Error() string { + return e.text +} + +// ErrCardinalTranslation is the error representing a cardinal translation error +type ErrCardinalTranslation struct { + text string +} + +// Error returns ErrCardinalTranslation's internal error text +func (e *ErrCardinalTranslation) Error() string { + return e.text +} + +// ErrMissingPluralTranslation is the error signifying a missing translation given +// the locales plural rules. +type ErrMissingPluralTranslation struct { + locale string + key interface{} + rule locales.PluralRule + translationType string +} + +// Error returns ErrMissingPluralTranslation's internal error text +func (e *ErrMissingPluralTranslation) Error() string { + + if _, ok := e.key.(string); !ok { + return fmt.Sprintf("error: missing '%s' plural rule '%s' for translation with key '%#v' and locale '%s'", e.translationType, e.rule, e.key, e.locale) + } + + return fmt.Sprintf("error: missing '%s' plural rule '%s' for translation with key '%s' and locale '%s'", e.translationType, e.rule, e.key, e.locale) +} + +// ErrMissingBracket is the error representing a missing bracket in a translation +// eg. This is a {0 <-- missing ending '}' +type ErrMissingBracket struct { + locale string + key interface{} + text string +} + +// Error returns ErrMissingBracket error message +func (e *ErrMissingBracket) Error() string { + return fmt.Sprintf("error: missing bracket '{}', in translation. locale: '%s' key: '%v' text: '%s'", e.locale, e.key, e.text) +} + +// ErrBadParamSyntax is the error representing a bad parameter definition in a translation +// eg. This is a {must-be-int} +type ErrBadParamSyntax struct { + locale string + param string + key interface{} + text string +} + +// Error returns ErrBadParamSyntax error message +func (e *ErrBadParamSyntax) Error() string { + return fmt.Sprintf("error: bad parameter syntax, missing parameter '%s' in translation. locale: '%s' key: '%v' text: '%s'", e.param, e.locale, e.key, e.text) +} + +// import/export errors + +// ErrMissingLocale is the error representing an expected locale that could +// not be found aka locale not registered with the UniversalTranslator Instance +type ErrMissingLocale struct { + locale string +} + +// Error returns ErrMissingLocale's internal error text +func (e *ErrMissingLocale) Error() string { + return fmt.Sprintf("error: locale '%s' not registered.", e.locale) +} + +// ErrBadPluralDefinition is the error representing an incorrect plural definition +// usually found within translations defined within files during the import process. +type ErrBadPluralDefinition struct { + tl translation +} + +// Error returns ErrBadPluralDefinition's internal error text +func (e *ErrBadPluralDefinition) Error() string { + return fmt.Sprintf("error: bad plural definition '%#v'", e.tl) +} diff --git a/vendor/github.com/go-playground/universal-translator/examples/basic/main.go b/vendor/github.com/go-playground/universal-translator/examples/basic/main.go new file mode 100644 index 0000000000..c0f4fca36c --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/basic/main.go @@ -0,0 +1,70 @@ +package main + +import ( + "fmt" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/en" + "github.com/go-playground/locales/en_CA" + "github.com/go-playground/locales/fr" + "github.com/go-playground/locales/nl" + "github.com/go-playground/universal-translator" +) + +// only one instance as translators within are shared + goroutine safe +var universalTraslator *ut.UniversalTranslator + +func main() { + + // NOTE: this example is omitting a lot of error checking for brevity + e := en.New() + universalTraslator = ut.New(e, e, en_CA.New(), nl.New(), fr.New()) + + en, _ := universalTraslator.GetTranslator("en") + + // generally used after parsing an http 'Accept-Language' header + // and this will try to find a matching locale you support or + // fallback locale. + // en, _ := ut.FindTranslator([]string{"en", "en_CA", "nl"}) + + // this will help + fmt.Println("Cardinal Plural Rules:", en.PluralsCardinal()) + fmt.Println("Ordinal Plural Rules:", en.PluralsOrdinal()) + fmt.Println("Range Plural Rules:", en.PluralsRange()) + + // add basic language only translations + // last param indicates if it's ok to override the translation if one already exists + en.Add("welcome", "Welcome {0} to our test", false) + + // add language translations dependant on cardinal plural rules + en.AddCardinal("days", "You have {0} day left to register", locales.PluralRuleOne, false) + en.AddCardinal("days", "You have {0} days left to register", locales.PluralRuleOther, false) + + // add language translations dependant on ordinal plural rules + en.AddOrdinal("day-of-month", "{0}st", locales.PluralRuleOne, false) + en.AddOrdinal("day-of-month", "{0}nd", locales.PluralRuleTwo, false) + en.AddOrdinal("day-of-month", "{0}rd", locales.PluralRuleFew, false) + en.AddOrdinal("day-of-month", "{0}th", locales.PluralRuleOther, false) + + // add language translations dependant on range plural rules + // NOTE: only one plural rule for range in 'en' locale + en.AddRange("between", "It's {0}-{1} days away", locales.PluralRuleOther, false) + + // now lets use the translations we just added, in the same order we added them + + fmt.Println(en.T("welcome", "Joeybloggs")) + + fmt.Println(en.C("days", 1, 0, en.FmtNumber(1, 0))) // you'd normally have variables defined for 1 and 0 + fmt.Println(en.C("days", 2, 0, en.FmtNumber(2, 0))) + fmt.Println(en.C("days", 10456.25, 2, en.FmtNumber(10456.25, 2))) + + fmt.Println(en.O("day-of-month", 1, 0, en.FmtNumber(1, 0))) + fmt.Println(en.O("day-of-month", 2, 0, en.FmtNumber(2, 0))) + fmt.Println(en.O("day-of-month", 3, 0, en.FmtNumber(3, 0))) + fmt.Println(en.O("day-of-month", 4, 0, en.FmtNumber(4, 0))) + fmt.Println(en.O("day-of-month", 10456.25, 0, en.FmtNumber(10456.25, 0))) + + fmt.Println(en.R("between", 0, 0, 1, 0, en.FmtNumber(0, 0), en.FmtNumber(1, 0))) + fmt.Println(en.R("between", 1, 0, 2, 0, en.FmtNumber(1, 0), en.FmtNumber(2, 0))) + fmt.Println(en.R("between", 1, 0, 100, 0, en.FmtNumber(1, 0), en.FmtNumber(100, 0))) +} diff --git a/vendor/github.com/go-playground/universal-translator/examples/file-formats/cardinal.json b/vendor/github.com/go-playground/universal-translator/examples/file-formats/cardinal.json new file mode 100644 index 0000000000..ca605894ab --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/file-formats/cardinal.json @@ -0,0 +1,16 @@ +[ + { + "locale": "en", + "key": "cardinal_test", + "trans": "You have {0} day left.", + "type": "Cardinal", + "rule": "One" + }, + { + "locale": "en", + "key": "cardinal_test", + "trans": "You have {0} days left.", + "type": "Cardinal", + "rule": "Other" + } +] \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/examples/file-formats/ordinal.json b/vendor/github.com/go-playground/universal-translator/examples/file-formats/ordinal.json new file mode 100644 index 0000000000..364255a4db --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/file-formats/ordinal.json @@ -0,0 +1,30 @@ +[ + { + "locale": "en", + "key": "day", + "trans": "{0}st", + "type": "Ordinal", + "rule": "One" + }, + { + "locale": "en", + "key": "day", + "trans": "{0}nd", + "type": "Ordinal", + "rule": "Two" + }, + { + "locale": "en", + "key": "day", + "trans": "{0}rd", + "type": "Ordinal", + "rule": "Few" + }, + { + "locale": "en", + "key": "day", + "trans": "{0}th", + "type": "Ordinal", + "rule": "Other" + } +] \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/examples/file-formats/plain-substitution.json b/vendor/github.com/go-playground/universal-translator/examples/file-formats/plain-substitution.json new file mode 100644 index 0000000000..407422db9d --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/file-formats/plain-substitution.json @@ -0,0 +1,27 @@ +[ + { + "locale": "en", + "key": "test_trans4", + "trans": "{0}{1}" + }, + { + "locale": "en", + "key": "test_trans", + "trans": "Welcome {0} to the {1}." + }, + { + "locale": "en", + "key": -1, + "trans": "Welcome {0}" + }, + { + "locale": "en", + "key": "test_trans2", + "trans": "{0} to the {1}." + }, + { + "locale": "en", + "key": "test_trans3", + "trans": "Welcome {0} to the {1}" + } +] \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/examples/file-formats/range.json b/vendor/github.com/go-playground/universal-translator/examples/file-formats/range.json new file mode 100644 index 0000000000..7986566dde --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/file-formats/range.json @@ -0,0 +1,16 @@ +[ + { + "locale": "nl", + "key": "day", + "trans": "er {0}-{1} dag vertrokken", + "type": "Range", + "rule": "One" + }, + { + "locale": "nl", + "key": "day", + "trans": "er zijn {0}-{1} dagen over", + "type": "Range", + "rule": "Other" + } +] \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/examples/full-no-files/home.tmpl b/vendor/github.com/go-playground/universal-translator/examples/full-no-files/home.tmpl new file mode 100644 index 0000000000..2b37f27631 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/full-no-files/home.tmpl @@ -0,0 +1,35 @@ +{{ define "home" }} + + + + Home + + +

Locale: {{ .Trans.Locale }}

+

Trans1: {{ .Trans.C "days-left" 1 0 "1" }}

+

Trans2: {{ .Trans.C "days-left" 2 0 "2" }}

+

FmtNumber Positive: {{ .Trans.FmtNumber .PositiveNum 2 }}

+

FmtNumber Negative: {{ .Trans.FmtNumber .NegativeNum 2 }}

+

FmtPercent Negative: {{ .Trans.FmtPercent .Percent 2 }}

+

FmtCurrency Negative: {{ .Trans.FmtCurrency .PositiveNum 2 .Trans.Currency }}

+

FmtCurrency Negative: {{ .Trans.FmtCurrency .NegativeNum 2 .Trans.Currency }}

+

FmtAccounting Negative: {{ .Trans.FmtAccounting .PositiveNum 2 .Trans.Currency }}

+

FmtAccounting Negative: {{ .Trans.FmtAccounting .NegativeNum 2 .Trans.Currency }}

+

FmtDateShort: {{ .Trans.FmtDateShort .Now }}

+

FmtDateMedium: {{ .Trans.FmtDateMedium .Now }}

+

FmtDateLong: {{ .Trans.FmtDateLong .Now }}

+

FmtDateFull: {{ .Trans.FmtDateFull .Now }}

+

FmtTimeShort: {{ .Trans.FmtTimeShort .Now }}

+

FmtTimeMedium: {{ .Trans.FmtTimeMedium .Now }}

+

FmtTimeLong: {{ .Trans.FmtTimeLong .Now }}

+

FmtTimeFull: {{ .Trans.FmtTimeFull .Now }}

+

MonthsAbbreviated: {{ .Trans.MonthsAbbreviated }}

+

MonthsNarrow: {{ .Trans.MonthsNarrow }}

+

MonthsWide: {{ .Trans.MonthsWide }}

+

WeekdaysAbbreviated: {{ .Trans.WeekdaysAbbreviated }}

+

WeekdaysNarrow: {{ .Trans.WeekdaysNarrow }}

+

WeekdaysShort: {{ .Trans.WeekdaysShort }}

+

WeekdaysWide: {{ .Trans.WeekdaysWide }}

+ + +{{ end }} \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/examples/full-no-files/main.go b/vendor/github.com/go-playground/universal-translator/examples/full-no-files/main.go new file mode 100644 index 0000000000..392d36bd7f --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/full-no-files/main.go @@ -0,0 +1,210 @@ +package main + +import ( + "context" + "html/template" + "log" + "net/http" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" + "github.com/go-playground/locales/en" + "github.com/go-playground/locales/fr" + "github.com/go-playground/pure" + "github.com/go-playground/pure/examples/middleware/logging-recovery" + "github.com/go-playground/universal-translator" +) + +var ( + tmpls *template.Template + utrans *ut.UniversalTranslator + transKey = struct { + name string + }{ + name: "transKey", + } +) + +// Translator wraps ut.Translator in order to handle errors transparently +// it is totally optional but recommended as it can now be used directly in +// templates and nobody can add translations where they're not supposed to. +type Translator interface { + locales.Translator + + // creates the translation for the locale given the 'key' and params passed in. + // wraps ut.Translator.T to handle errors + T(key interface{}, params ...string) string + + // creates the cardinal translation for the locale given the 'key', 'num' and 'digit' arguments + // and param passed in. + // wraps ut.Translator.C to handle errors + C(key interface{}, num float64, digits uint64, param string) string + + // creates the ordinal translation for the locale given the 'key', 'num' and 'digit' arguments + // and param passed in. + // wraps ut.Translator.O to handle errors + O(key interface{}, num float64, digits uint64, param string) string + + // creates the range translation for the locale given the 'key', 'num1', 'digit1', 'num2' and + // 'digit2' arguments and 'param1' and 'param2' passed in + // wraps ut.Translator.R to handle errors + R(key interface{}, num1 float64, digits1 uint64, num2 float64, digits2 uint64, param1, param2 string) string + + // Currency returns the type used by the given locale. + Currency() currency.Type +} + +// implements Translator interface definition above. +type translator struct { + locales.Translator + trans ut.Translator +} + +var _ Translator = (*translator)(nil) + +func (t *translator) T(key interface{}, params ...string) string { + + s, err := t.trans.T(key, params...) + if err != nil { + log.Printf("issue translating key: '%v' error: '%s'", key, err) + } + + return s +} + +func (t *translator) C(key interface{}, num float64, digits uint64, param string) string { + + s, err := t.trans.C(key, num, digits, param) + if err != nil { + log.Printf("issue translating cardinal key: '%v' error: '%s'", key, err) + } + + return s +} + +func (t *translator) O(key interface{}, num float64, digits uint64, param string) string { + + s, err := t.trans.C(key, num, digits, param) + if err != nil { + log.Printf("issue translating ordinal key: '%v' error: '%s'", key, err) + } + + return s +} + +func (t *translator) R(key interface{}, num1 float64, digits1 uint64, num2 float64, digits2 uint64, param1, param2 string) string { + + s, err := t.trans.R(key, num1, digits1, num2, digits2, param1, param2) + if err != nil { + log.Printf("issue translating range key: '%v' error: '%s'", key, err) + } + + return s +} + +func (t *translator) Currency() currency.Type { + + // choose your own locale. The reason it isn't mapped for you is because many + // countries have multiple currencies; it's up to you and you're application how + // and which currencies to use. I recommend adding a function it to to your custon translator + // interface like defined above. + switch t.Locale() { + case "en": + return currency.USD + case "fr": + return currency.EUR + default: + return currency.USD + } +} + +func main() { + + en := en.New() + utrans = ut.New(en, en, fr.New()) + setup() + + tmpls, _ = template.ParseFiles("home.tmpl") + + r := pure.New() + r.Use(middleware.LoggingAndRecovery(true), translatorMiddleware) + r.Get("/", home) + + log.Println("Running on Port :8080") + log.Println("Try me with URL http://localhost:8080/?locale=en") + log.Println("and then http://localhost:8080/?locale=fr") + http.ListenAndServe(":8080", r.Serve()) +} + +func home(w http.ResponseWriter, r *http.Request) { + + // get locale translator ( could be wrapped into a helper function ) + t := r.Context().Value(transKey).(Translator) + + s := struct { + Trans Translator + Now time.Time + PositiveNum float64 + NegativeNum float64 + Percent float64 + }{ + Trans: t, + Now: time.Now(), + PositiveNum: 1234576.45, + NegativeNum: -35900394.34, + Percent: 96.76, + } + + if err := tmpls.ExecuteTemplate(w, "home", s); err != nil { + log.Fatal(err) + } +} + +func translatorMiddleware(next http.HandlerFunc) http.HandlerFunc { + + return func(w http.ResponseWriter, r *http.Request) { + + // there are many ways to check, this is just checking for query param & + // Accept-Language header but can be expanded to Cookie's etc.... + + params := r.URL.Query() + + locale := params.Get("locale") + var t ut.Translator + + if len(locale) > 0 { + + var found bool + + if t, found = utrans.GetTranslator(locale); found { + goto END + } + } + + // get and parse the "Accept-Language" http header and return an array + t, _ = utrans.FindTranslator(pure.AcceptedLanguages(r)...) + END: + // I would normally wrap ut.Translator with one with my own functions in order + // to handle errors and be able to use all functions from translator within the templates. + r = r.WithContext(context.WithValue(r.Context(), transKey, &translator{trans: t, Translator: t.(locales.Translator)})) + + next(w, r) + } +} + +func setup() { + + en, _ := utrans.FindTranslator("en") + en.AddCardinal("days-left", "There is {0} day left", locales.PluralRuleOne, false) + en.AddCardinal("days-left", "There are {0} days left", locales.PluralRuleOther, false) + + fr, _ := utrans.FindTranslator("fr") + fr.AddCardinal("days-left", "Il reste {0} jour", locales.PluralRuleOne, false) + fr.AddCardinal("days-left", "Il reste {0} jours", locales.PluralRuleOther, false) + + err := utrans.VerifyTranslations() + if err != nil { + log.Fatal(err) + } +} diff --git a/vendor/github.com/go-playground/universal-translator/examples/full-with-files/home.tmpl b/vendor/github.com/go-playground/universal-translator/examples/full-with-files/home.tmpl new file mode 100644 index 0000000000..2b37f27631 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/full-with-files/home.tmpl @@ -0,0 +1,35 @@ +{{ define "home" }} + + + + Home + + +

Locale: {{ .Trans.Locale }}

+

Trans1: {{ .Trans.C "days-left" 1 0 "1" }}

+

Trans2: {{ .Trans.C "days-left" 2 0 "2" }}

+

FmtNumber Positive: {{ .Trans.FmtNumber .PositiveNum 2 }}

+

FmtNumber Negative: {{ .Trans.FmtNumber .NegativeNum 2 }}

+

FmtPercent Negative: {{ .Trans.FmtPercent .Percent 2 }}

+

FmtCurrency Negative: {{ .Trans.FmtCurrency .PositiveNum 2 .Trans.Currency }}

+

FmtCurrency Negative: {{ .Trans.FmtCurrency .NegativeNum 2 .Trans.Currency }}

+

FmtAccounting Negative: {{ .Trans.FmtAccounting .PositiveNum 2 .Trans.Currency }}

+

FmtAccounting Negative: {{ .Trans.FmtAccounting .NegativeNum 2 .Trans.Currency }}

+

FmtDateShort: {{ .Trans.FmtDateShort .Now }}

+

FmtDateMedium: {{ .Trans.FmtDateMedium .Now }}

+

FmtDateLong: {{ .Trans.FmtDateLong .Now }}

+

FmtDateFull: {{ .Trans.FmtDateFull .Now }}

+

FmtTimeShort: {{ .Trans.FmtTimeShort .Now }}

+

FmtTimeMedium: {{ .Trans.FmtTimeMedium .Now }}

+

FmtTimeLong: {{ .Trans.FmtTimeLong .Now }}

+

FmtTimeFull: {{ .Trans.FmtTimeFull .Now }}

+

MonthsAbbreviated: {{ .Trans.MonthsAbbreviated }}

+

MonthsNarrow: {{ .Trans.MonthsNarrow }}

+

MonthsWide: {{ .Trans.MonthsWide }}

+

WeekdaysAbbreviated: {{ .Trans.WeekdaysAbbreviated }}

+

WeekdaysNarrow: {{ .Trans.WeekdaysNarrow }}

+

WeekdaysShort: {{ .Trans.WeekdaysShort }}

+

WeekdaysWide: {{ .Trans.WeekdaysWide }}

+ + +{{ end }} \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/examples/full-with-files/main.go b/vendor/github.com/go-playground/universal-translator/examples/full-with-files/main.go new file mode 100644 index 0000000000..97553ee880 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/full-with-files/main.go @@ -0,0 +1,207 @@ +package main + +import ( + "context" + "html/template" + "log" + "net/http" + "time" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/currency" + "github.com/go-playground/locales/en" + "github.com/go-playground/locales/fr" + "github.com/go-playground/pure" + "github.com/go-playground/pure/examples/middleware/logging-recovery" + "github.com/go-playground/universal-translator" +) + +var ( + tmpls *template.Template + utrans *ut.UniversalTranslator + transKey = struct { + name string + }{ + name: "transKey", + } +) + +// Translator wraps ut.Translator in order to handle errors transparently +// it is totally optional but recommended as it can now be used directly in +// templates and nobody can add translations where they're not supposed to. +type Translator interface { + locales.Translator + + // creates the translation for the locale given the 'key' and params passed in. + // wraps ut.Translator.T to handle errors + T(key interface{}, params ...string) string + + // creates the cardinal translation for the locale given the 'key', 'num' and 'digit' arguments + // and param passed in. + // wraps ut.Translator.C to handle errors + C(key interface{}, num float64, digits uint64, param string) string + + // creates the ordinal translation for the locale given the 'key', 'num' and 'digit' arguments + // and param passed in. + // wraps ut.Translator.O to handle errors + O(key interface{}, num float64, digits uint64, param string) string + + // creates the range translation for the locale given the 'key', 'num1', 'digit1', 'num2' and + // 'digit2' arguments and 'param1' and 'param2' passed in + // wraps ut.Translator.R to handle errors + R(key interface{}, num1 float64, digits1 uint64, num2 float64, digits2 uint64, param1, param2 string) string + + // Currency returns the type used by the given locale. + Currency() currency.Type +} + +// implements Translator interface definition above. +type translator struct { + locales.Translator + trans ut.Translator +} + +var _ Translator = (*translator)(nil) + +func (t *translator) T(key interface{}, params ...string) string { + + s, err := t.trans.T(key, params...) + if err != nil { + log.Printf("issue translating key: '%v' error: '%s'", key, err) + } + + return s +} + +func (t *translator) C(key interface{}, num float64, digits uint64, param string) string { + + s, err := t.trans.C(key, num, digits, param) + if err != nil { + log.Printf("issue translating cardinal key: '%v' error: '%s'", key, err) + } + + return s +} + +func (t *translator) O(key interface{}, num float64, digits uint64, param string) string { + + s, err := t.trans.C(key, num, digits, param) + if err != nil { + log.Printf("issue translating ordinal key: '%v' error: '%s'", key, err) + } + + return s +} + +func (t *translator) R(key interface{}, num1 float64, digits1 uint64, num2 float64, digits2 uint64, param1, param2 string) string { + + s, err := t.trans.R(key, num1, digits1, num2, digits2, param1, param2) + if err != nil { + log.Printf("issue translating range key: '%v' error: '%s'", key, err) + } + + return s +} + +func (t *translator) Currency() currency.Type { + + // choose your own locale. The reason it isn't mapped for you is because many + // countries have multiple currencies; it's up to you and you're application how + // and which currencies to use. I recommend adding a function it to to your custon translator + // interface like defined above. + switch t.Locale() { + case "en": + return currency.USD + case "fr": + return currency.EUR + default: + return currency.USD + } +} + +func main() { + + en := en.New() + utrans = ut.New(en, en, fr.New()) + setup() + + tmpls, _ = template.ParseFiles("home.tmpl") + + r := pure.New() + r.Use(middleware.LoggingAndRecovery(true), translatorMiddleware) + r.Get("/", home) + + log.Println("Running on Port :8080") + log.Println("Try me with URL http://localhost:8080/?locale=en") + log.Println("and then http://localhost:8080/?locale=fr") + http.ListenAndServe(":8080", r.Serve()) +} + +func home(w http.ResponseWriter, r *http.Request) { + + // get locale translator ( could be wrapped into a helper function ) + t := r.Context().Value(transKey).(Translator) + + s := struct { + Trans Translator + Now time.Time + PositiveNum float64 + NegativeNum float64 + Percent float64 + }{ + Trans: t, + Now: time.Now(), + PositiveNum: 1234576.45, + NegativeNum: -35900394.34, + Percent: 96.76, + } + + if err := tmpls.ExecuteTemplate(w, "home", s); err != nil { + log.Fatal(err) + } +} + +func translatorMiddleware(next http.HandlerFunc) http.HandlerFunc { + + return func(w http.ResponseWriter, r *http.Request) { + + // there are many ways to check, this is just checking for query param & + // Accept-Language header but can be expanded to Cookie's etc.... + + params := r.URL.Query() + + locale := params.Get("locale") + var t ut.Translator + + if len(locale) > 0 { + + var found bool + + if t, found = utrans.GetTranslator(locale); found { + goto END + } + } + + // get and parse the "Accept-Language" http header and return an array + t, _ = utrans.FindTranslator(pure.AcceptedLanguages(r)...) + END: + // I would normally wrap ut.Translator with one with my own functions in order + // to handle errors and be able to use all functions from translator within the templates. + r = r.WithContext(context.WithValue(r.Context(), transKey, &translator{trans: t, Translator: t.(locales.Translator)})) + + next(w, r) + } +} + +func setup() { + + err := utrans.Import(ut.FormatJSON, "translations") + if err != nil { + log.Fatal(err) + } + + err = utrans.VerifyTranslations() + if err != nil { + log.Fatal(err) + } +} diff --git a/vendor/github.com/go-playground/universal-translator/examples/full-with-files/translations/en/home.json b/vendor/github.com/go-playground/universal-translator/examples/full-with-files/translations/en/home.json new file mode 100644 index 0000000000..395b66f60f --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/full-with-files/translations/en/home.json @@ -0,0 +1,16 @@ +[ + { + "locale": "en", + "key": "days-left", + "trans": "There is {0} day left", + "type": "Cardinal", + "rule": "One" + }, + { + "locale": "en", + "key": "days-left", + "trans": "There are {0} days left", + "type": "Cardinal", + "rule": "Other" + } +] \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/examples/full-with-files/translations/fr/home.json b/vendor/github.com/go-playground/universal-translator/examples/full-with-files/translations/fr/home.json new file mode 100644 index 0000000000..e694bd775e --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/examples/full-with-files/translations/fr/home.json @@ -0,0 +1,16 @@ +[ + { + "locale": "fr", + "key": "days-left", + "trans": "Il reste {0} jour", + "type": "Cardinal", + "rule": "One" + }, + { + "locale": "fr", + "key": "days-left", + "trans": "Il reste {0} jours", + "type": "Cardinal", + "rule": "Other" + } +] \ No newline at end of file diff --git a/vendor/github.com/go-playground/universal-translator/import_export.go b/vendor/github.com/go-playground/universal-translator/import_export.go new file mode 100644 index 0000000000..7bd76f26b6 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/import_export.go @@ -0,0 +1,274 @@ +package ut + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "os" + "path/filepath" + + "io" + + "github.com/go-playground/locales" +) + +type translation struct { + Locale string `json:"locale"` + Key interface{} `json:"key"` // either string or integer + Translation string `json:"trans"` + PluralType string `json:"type,omitempty"` + PluralRule string `json:"rule,omitempty"` + OverrideExisting bool `json:"override,omitempty"` +} + +const ( + cardinalType = "Cardinal" + ordinalType = "Ordinal" + rangeType = "Range" +) + +// ImportExportFormat is the format of the file import or export +type ImportExportFormat uint8 + +// supported Export Formats +const ( + FormatJSON ImportExportFormat = iota +) + +// Export writes the translations out to a file on disk. +// +// NOTE: this currently only works with string or int translations keys. +func (t *UniversalTranslator) Export(format ImportExportFormat, dirname string) error { + + _, err := os.Stat(dirname) + fmt.Println(dirname, err, os.IsNotExist(err)) + if err != nil { + + if !os.IsNotExist(err) { + return err + } + + if err = os.MkdirAll(dirname, 0744); err != nil { + return err + } + } + + // build up translations + var trans []translation + var b []byte + var ext string + + for _, locale := range t.translators { + + for k, v := range locale.(*translator).translations { + trans = append(trans, translation{ + Locale: locale.Locale(), + Key: k, + Translation: v.text, + }) + } + + for k, pluralTrans := range locale.(*translator).cardinalTanslations { + + for i, plural := range pluralTrans { + + // leave enough for all plural rules + // but not all are set for all languages. + if plural == nil { + continue + } + + trans = append(trans, translation{ + Locale: locale.Locale(), + Key: k.(string), + Translation: plural.text, + PluralType: cardinalType, + PluralRule: locales.PluralRule(i).String(), + }) + } + } + + for k, pluralTrans := range locale.(*translator).ordinalTanslations { + + for i, plural := range pluralTrans { + + // leave enough for all plural rules + // but not all are set for all languages. + if plural == nil { + continue + } + + trans = append(trans, translation{ + Locale: locale.Locale(), + Key: k.(string), + Translation: plural.text, + PluralType: ordinalType, + PluralRule: locales.PluralRule(i).String(), + }) + } + } + + for k, pluralTrans := range locale.(*translator).rangeTanslations { + + for i, plural := range pluralTrans { + + // leave enough for all plural rules + // but not all are set for all languages. + if plural == nil { + continue + } + + trans = append(trans, translation{ + Locale: locale.Locale(), + Key: k.(string), + Translation: plural.text, + PluralType: rangeType, + PluralRule: locales.PluralRule(i).String(), + }) + } + } + + switch format { + case FormatJSON: + b, err = json.MarshalIndent(trans, "", " ") + ext = ".json" + } + + if err != nil { + return err + } + + err = ioutil.WriteFile(filepath.Join(dirname, fmt.Sprintf("%s%s", locale.Locale(), ext)), b, 0644) + if err != nil { + return err + } + + trans = trans[0:0] + } + + return nil +} + +// Import reads the translations out of a file or directory on disk. +// +// NOTE: this currently only works with string or int translations keys. +func (t *UniversalTranslator) Import(format ImportExportFormat, dirnameOrFilename string) error { + + fi, err := os.Stat(dirnameOrFilename) + if err != nil { + return err + } + + processFn := func(filename string) error { + + f, err := os.Open(filename) + if err != nil { + return err + } + defer f.Close() + + return t.ImportByReader(format, f) + } + + if !fi.IsDir() { + return processFn(dirnameOrFilename) + } + + // recursively go through directory + walker := func(path string, info os.FileInfo, err error) error { + + if info.IsDir() { + return nil + } + + switch format { + case FormatJSON: + // skip non JSON files + if filepath.Ext(info.Name()) != ".json" { + return nil + } + } + + return processFn(path) + } + + return filepath.Walk(dirnameOrFilename, walker) +} + +// ImportByReader imports the the translations found within the contents read from the supplied reader. +// +// NOTE: generally used when assets have been embedded into the binary and are already in memory. +func (t *UniversalTranslator) ImportByReader(format ImportExportFormat, reader io.Reader) error { + + b, err := ioutil.ReadAll(reader) + if err != nil { + return err + } + + var trans []translation + + switch format { + case FormatJSON: + err = json.Unmarshal(b, &trans) + } + + if err != nil { + return err + } + + for _, tl := range trans { + + locale, found := t.FindTranslator(tl.Locale) + if !found { + return &ErrMissingLocale{locale: tl.Locale} + } + + pr := stringToPR(tl.PluralRule) + + if pr == locales.PluralRuleUnknown { + + err = locale.Add(tl.Key, tl.Translation, tl.OverrideExisting) + if err != nil { + return err + } + + continue + } + + switch tl.PluralType { + case cardinalType: + err = locale.AddCardinal(tl.Key, tl.Translation, pr, tl.OverrideExisting) + case ordinalType: + err = locale.AddOrdinal(tl.Key, tl.Translation, pr, tl.OverrideExisting) + case rangeType: + err = locale.AddRange(tl.Key, tl.Translation, pr, tl.OverrideExisting) + default: + return &ErrBadPluralDefinition{tl: tl} + } + + if err != nil { + return err + } + } + + return nil +} + +func stringToPR(s string) locales.PluralRule { + + switch s { + case "One": + return locales.PluralRuleOne + case "Two": + return locales.PluralRuleTwo + case "Few": + return locales.PluralRuleFew + case "Many": + return locales.PluralRuleMany + case "Other": + return locales.PluralRuleOther + default: + return locales.PluralRuleUnknown + } + +} diff --git a/vendor/github.com/go-playground/universal-translator/import_export_test.go b/vendor/github.com/go-playground/universal-translator/import_export_test.go new file mode 100644 index 0000000000..e6a8505572 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/import_export_test.go @@ -0,0 +1,789 @@ +package ut + +import ( + "fmt" + "path/filepath" + "testing" + + "os" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/en" + "github.com/go-playground/locales/nl" +) + +// NOTES: +// - Run "go test" to run tests +// - Run "gocov test | gocov report" to report on test converage by file +// - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called +// +// or +// +// -- may be a good idea to change to output path to somewherelike /tmp +// go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html +// + +func TestExportImportBasic(t *testing.T) { + + e := en.New() + uni := New(e, e) + en, found := uni.GetTranslator("en") // or fallback if fails to find 'en' + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + expected error + expectedError bool + override bool + }{ + { + key: "test_trans", + trans: "Welcome {0}", + expected: nil, + }, + { + key: -1, + trans: "Welcome {0}", + expected: nil, + }, + { + key: "test_trans2", + trans: "{0} to the {1}.", + expected: nil, + }, + { + key: "test_trans3", + trans: "Welcome {0} to the {1}", + expected: nil, + }, + { + key: "test_trans4", + trans: "{0}{1}", + expected: nil, + }, + { + key: "test_trans", + trans: "{0}{1}", + expected: &ErrConflictingTranslation{locale: en.Locale(), key: "test_trans", text: "{0}{1}"}, + expectedError: true, + }, + { + key: -1, + trans: "{0}{1}", + expected: &ErrConflictingTranslation{locale: en.Locale(), key: -1, text: "{0}{1}"}, + expectedError: true, + }, + { + key: "test_trans", + trans: "Welcome {0} to the {1}.", + expected: nil, + override: true, + }, + } + + for _, tt := range translations { + + err := en.Add(tt.key, tt.trans, tt.override) + if err != tt.expected { + if !tt.expectedError { + t.Errorf("Expected '%s' Got '%s'", tt.expected, err) + } else { + if err.Error() != tt.expected.Error() { + t.Errorf("Expected '%s' Got '%s'", tt.expected.Error(), err.Error()) + } + } + } + } + + dirname := "testdata/translations" + defer os.RemoveAll(dirname) + + err := uni.Export(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + uni = New(e, e) + + err = uni.Import(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + en, found = uni.GetTranslator("en") // or fallback if fails to find 'en' + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + tests := []struct { + key interface{} + params []string + expected string + expectedError bool + }{ + { + key: "test_trans", + params: []string{"Joeybloggs", "The Test"}, + expected: "Welcome Joeybloggs to the The Test.", + }, + { + key: "test_trans2", + params: []string{"Joeybloggs", "The Test"}, + expected: "Joeybloggs to the The Test.", + }, + { + key: "test_trans3", + params: []string{"Joeybloggs", "The Test"}, + expected: "Welcome Joeybloggs to the The Test", + }, + { + key: "test_trans4", + params: []string{"Joeybloggs", "The Test"}, + expected: "JoeybloggsThe Test", + }, + // bad translation + { + key: "non-existant-key", + params: []string{"Joeybloggs", "The Test"}, + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + + s, err := en.T(tt.key, tt.params...) + if s != tt.expected { + if !tt.expectedError || (tt.expectedError && err != ErrUnknowTranslation) { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } + } +} + +func TestExportImportCardinal(t *testing.T) { + + e := en.New() + uni := New(e, e) + en, found := uni.GetTranslator("en") + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + rule locales.PluralRule + expected error + expectedError bool + override bool + }{ + // bad translation + { + key: "cardinal_test", + trans: "You have a day left.", + rule: locales.PluralRuleOne, + expected: &ErrCardinalTranslation{text: fmt.Sprintf("error: parameter '%s' not found, may want to use 'Add' instead of 'AddCardinal'. locale: '%s' key: '%v' text: '%s'", paramZero, en.Locale(), "cardinal_test", "You have a day left.")}, + expectedError: true, + }, + { + key: "cardinal_test", + trans: "You have {0} day", + rule: locales.PluralRuleOne, + expected: nil, + }, + { + key: "cardinal_test", + trans: "You have {0} days left.", + rule: locales.PluralRuleOther, + expected: nil, + }, + { + key: "cardinal_test", + trans: "You have {0} days left.", + rule: locales.PluralRuleOther, + expected: &ErrConflictingTranslation{locale: en.Locale(), key: "cardinal_test", rule: locales.PluralRuleOther, text: "You have {0} days left."}, + expectedError: true, + }, + { + key: "cardinal_test", + trans: "You have {0} day left.", + rule: locales.PluralRuleOne, + expected: nil, + override: true, + }, + } + + for _, tt := range translations { + + err := en.AddCardinal(tt.key, tt.trans, tt.rule, tt.override) + if err != tt.expected { + if !tt.expectedError || err.Error() != tt.expected.Error() { + t.Errorf("Expected '%s' Got '%s'", tt.expected, err) + } + } + } + + dirname := "testdata/translations" + defer os.RemoveAll(dirname) + + err := uni.Export(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + uni = New(e, e) + + err = uni.Import(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + en, found = uni.GetTranslator("en") // or fallback if fails to find 'en' + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + tests := []struct { + key interface{} + num float64 + digits uint64 + param string + expected string + expectedError bool + }{ + { + key: "cardinal_test", + num: 1, + digits: 0, + param: string(en.FmtNumber(1, 0)), + expected: "You have 1 day left.", + }, + // bad translation key + { + key: "non-existant", + num: 1, + digits: 0, + param: string(en.FmtNumber(1, 0)), + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + + s, err := en.C(tt.key, tt.num, tt.digits, tt.param) + if err != nil { + if !tt.expectedError && err != ErrUnknowTranslation { + t.Errorf("Expected '' Got '%s'", err) + } + } + + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestExportImportOrdinal(t *testing.T) { + + e := en.New() + uni := New(e, e) + en, found := uni.GetTranslator("en") + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + rule locales.PluralRule + expected error + expectedError bool + override bool + }{ + // bad translation + { + key: "day", + trans: "st", + rule: locales.PluralRuleOne, + expected: &ErrOrdinalTranslation{text: fmt.Sprintf("error: parameter '%s' not found, may want to use 'Add' instead of 'AddOrdinal'. locale: '%s' key: '%v' text: '%s'", paramZero, en.Locale(), "day", "st")}, + expectedError: true, + }, + { + key: "day", + trans: "{0}sfefewt", + rule: locales.PluralRuleOne, + expected: nil, + }, + { + key: "day", + trans: "{0}nd", + rule: locales.PluralRuleTwo, + expected: nil, + }, + { + key: "day", + trans: "{0}rd", + rule: locales.PluralRuleFew, + expected: nil, + }, + { + key: "day", + trans: "{0}th", + rule: locales.PluralRuleOther, + expected: nil, + }, + // bad translation + { + key: "day", + trans: "{0}th", + rule: locales.PluralRuleOther, + expected: &ErrConflictingTranslation{locale: en.Locale(), key: "day", rule: locales.PluralRuleOther, text: "{0}th"}, + expectedError: true, + }, + { + key: "day", + trans: "{0}st", + rule: locales.PluralRuleOne, + expected: nil, + override: true, + }, + } + + for _, tt := range translations { + + err := en.AddOrdinal(tt.key, tt.trans, tt.rule, tt.override) + if err != tt.expected { + if !tt.expectedError || err.Error() != tt.expected.Error() { + t.Errorf("Expected '' Got '%s'", err) + } + } + } + + dirname := "testdata/translations" + defer os.RemoveAll(dirname) + + err := uni.Export(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + uni = New(e, e) + + err = uni.Import(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + en, found = uni.GetTranslator("en") // or fallback if fails to find 'en' + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + tests := []struct { + key interface{} + num float64 + digits uint64 + param string + expected string + expectedError bool + }{ + { + key: "day", + num: 1, + digits: 0, + param: string(en.FmtNumber(1, 0)), + expected: "1st", + }, + { + key: "day", + num: 2, + digits: 0, + param: string(en.FmtNumber(2, 0)), + expected: "2nd", + }, + { + key: "day", + num: 3, + digits: 0, + param: string(en.FmtNumber(3, 0)), + expected: "3rd", + }, + { + key: "day", + num: 4, + digits: 0, + param: string(en.FmtNumber(4, 0)), + expected: "4th", + }, + { + key: "day", + num: 10258.43, + digits: 0, + param: string(en.FmtNumber(10258.43, 0)), + expected: "10,258th", + }, + // bad translation + { + key: "d-day", + num: 10258.43, + digits: 0, + param: string(en.FmtNumber(10258.43, 0)), + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + + s, err := en.O(tt.key, tt.num, tt.digits, tt.param) + if err != nil { + if !tt.expectedError && err != ErrUnknowTranslation { + t.Errorf("Expected '' Got '%s'", err) + } + } + + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestExportImportRange(t *testing.T) { + + n := nl.New() + uni := New(n, n) + + // dutch + nl, found := uni.GetTranslator("nl") + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + rule locales.PluralRule + expected error + expectedError bool + override bool + }{ + // bad translation + { + key: "day", + trans: "er -{1} dag vertrokken", + rule: locales.PluralRuleOne, + expected: &ErrRangeTranslation{text: fmt.Sprintf("error: parameter '%s' not found, are you sure you're adding a Range Translation? locale: '%s' key: '%s' text: '%s'", paramZero, nl.Locale(), "day", "er -{1} dag vertrokken")}, + expectedError: true, + }, + // bad translation + { + key: "day", + trans: "er {0}- dag vertrokken", + rule: locales.PluralRuleOne, + expected: &ErrRangeTranslation{text: fmt.Sprintf("error: parameter '%s' not found, a Range Translation requires two parameters. locale: '%s' key: '%s' text: '%s'", paramOne, nl.Locale(), "day", "er {0}- dag vertrokken")}, + expectedError: true, + }, + { + key: "day", + trans: "er {0}-{1} dag", + rule: locales.PluralRuleOne, + expected: nil, + }, + { + key: "day", + trans: "er zijn {0}-{1} dagen over", + rule: locales.PluralRuleOther, + expected: nil, + }, + // bad translation + { + key: "day", + trans: "er zijn {0}-{1} dagen over", + rule: locales.PluralRuleOther, + expected: &ErrConflictingTranslation{locale: nl.Locale(), key: "day", rule: locales.PluralRuleOther, text: "er zijn {0}-{1} dagen over"}, + expectedError: true, + }, + { + key: "day", + trans: "er {0}-{1} dag vertrokken", + rule: locales.PluralRuleOne, + expected: nil, + override: true, + }, + } + + for _, tt := range translations { + + err := nl.AddRange(tt.key, tt.trans, tt.rule, tt.override) + if err != tt.expected { + if !tt.expectedError || err.Error() != tt.expected.Error() { + t.Errorf("Expected '%#v' Got '%s'", tt.expected, err) + } + } + } + + dirname := "testdata/translations" + defer os.RemoveAll(dirname) + + err := uni.Export(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + uni = New(n, n) + + err = uni.Import(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + nl, found = uni.GetTranslator("nl") // or fallback if fails to find 'en' + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + tests := []struct { + key interface{} + num1 float64 + digits1 uint64 + num2 float64 + digits2 uint64 + param1 string + param2 string + expected string + expectedError bool + }{ + { + key: "day", + num1: 1, + digits1: 0, + num2: 2, + digits2: 0, + param1: string(nl.FmtNumber(1, 0)), + param2: string(nl.FmtNumber(2, 0)), + expected: "er zijn 1-2 dagen over", + }, + { + key: "day", + num1: 0, + digits1: 0, + num2: 1, + digits2: 0, + param1: string(nl.FmtNumber(0, 0)), + param2: string(nl.FmtNumber(1, 0)), + expected: "er 0-1 dag vertrokken", + }, + { + key: "day", + num1: 0, + digits1: 0, + num2: 2, + digits2: 0, + param1: string(nl.FmtNumber(0, 0)), + param2: string(nl.FmtNumber(2, 0)), + expected: "er zijn 0-2 dagen over", + }, + // bad translations from here + { + key: "d-day", + num1: 0, + digits1: 0, + num2: 2, + digits2: 0, + param1: string(nl.FmtNumber(0, 0)), + param2: string(nl.FmtNumber(2, 0)), + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + + s, err := nl.R(tt.key, tt.num1, tt.digits1, tt.num2, tt.digits2, tt.param1, tt.param2) + if err != nil { + if !tt.expectedError && err != ErrUnknowTranslation { + t.Errorf("Expected '' Got '%s'", err) + } + } + + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestImportRecursive(t *testing.T) { + + e := en.New() + uni := New(e, e) + + dirname := "testdata/nested1" + err := uni.Import(FormatJSON, dirname) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + en, found := uni.GetTranslator("en") // or fallback if fails to find 'en' + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + tests := []struct { + key interface{} + params []string + expected string + expectedError bool + }{ + { + key: "test_trans", + params: []string{"Joeybloggs", "The Test"}, + expected: "Welcome Joeybloggs to the The Test.", + }, + { + key: "test_trans2", + params: []string{"Joeybloggs", "The Test"}, + expected: "Joeybloggs to the The Test.", + }, + { + key: "test_trans3", + params: []string{"Joeybloggs", "The Test"}, + expected: "Welcome Joeybloggs to the The Test", + }, + { + key: "test_trans4", + params: []string{"Joeybloggs", "The Test"}, + expected: "JoeybloggsThe Test", + }, + // bad translation + { + key: "non-existant-key", + params: []string{"Joeybloggs", "The Test"}, + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + + s, err := en.T(tt.key, tt.params...) + if s != tt.expected { + if !tt.expectedError || (tt.expectedError && err != ErrUnknowTranslation) { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } + } +} + +func TestBadImport(t *testing.T) { + + // test non existant file + e := en.New() + uni := New(e, e) + + filename := "testdata/non-existant-file.json" + expected := "stat testdata/non-existant-file.json: no such file or directory" + err := uni.Import(FormatJSON, filename) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + // test bad parameter basic translation + filename = "testdata/bad-translation1.json" + expected = "error: bad parameter syntax, missing parameter '{0}' in translation. locale: 'en' key: 'test_trans3' text: 'Welcome {lettersnotpermitted} to the {1}'" + err = uni.Import(FormatJSON, filename) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + // test missing bracket basic translation + filename = "testdata/bad-translation2.json" + expected = "error: missing bracket '{}', in translation. locale: 'en' key: 'test_trans3' text: 'Welcome {0 to the {1}'" + err = uni.Import(FormatJSON, filename) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + // test missing locale basic translation + filename = "testdata/bad-translation3.json" + expected = "error: locale 'nl' not registered." + err = uni.Import(FormatJSON, filename) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + // test bad plural definition + filename = "testdata/bad-translation4.json" + expected = "error: bad plural definition 'ut.translation{Locale:\"en\", Key:\"cardinal_test\", Translation:\"You have {0} day left.\", PluralType:\"NotAPluralType\", PluralRule:\"One\", OverrideExisting:false}'" + err = uni.Import(FormatJSON, filename) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + // test bad plural rule for locale + filename = "testdata/bad-translation5.json" + expected = "error: cardinal plural rule 'Many' does not exist for locale 'en' key: 'cardinal_test' text: 'You have {0} day left.'" + err = uni.Import(FormatJSON, filename) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + // test invalid JSON + filename = "testdata/bad-translation6.json" + expected = "invalid character ']' after object key:value pair" + err = uni.Import(FormatJSON, filename) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + // test bad io.Reader + f, err := os.Open(filename) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + f.Close() + + expected = "read testdata/bad-translation6.json: bad file descriptor" + err = uni.ImportByReader(FormatJSON, f) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } +} + +func TestBadExport(t *testing.T) { + + // test readonly directory + e := en.New() + uni := New(e, e) + + en, found := uni.GetTranslator("en") // or fallback if fails to find 'en' + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + dirname := "testdata/readonly" + err := os.Mkdir(dirname, 0444) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + defer os.RemoveAll(dirname) + + en.Add("day", "this is a day", false) + + expected := "open testdata/readonly/en.json: permission denied" + err = uni.Export(FormatJSON, dirname) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + // test exporting into directory inside readonly directory + expected = "stat testdata/readonly/inner: permission denied" + err = uni.Export(FormatJSON, filepath.Join(dirname, "inner")) + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } +} diff --git a/vendor/github.com/go-playground/universal-translator/logo.png b/vendor/github.com/go-playground/universal-translator/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..a37aa8c0cd0f6e1b98e0be3eb2531ebc6ac6717b GIT binary patch literal 16598 zcmV(yK*U_<=i=1Q$^7;0v#+eDrK0%p z>%6(N%f`XBv#;pk-N3xJlaY`9`tZ@r#>d0H&B?^Dtf>F`_3`TEoSK)csHK;dl)1LD z{xUb9o}0zMyZALSjf{%1BqI0!{{5jc`1SO`zPq8KpwB5MBz`@`DJHxnB>jUjr=XpP zhJ*ceGX0V>qah&tt}xmxDK3XPA9F;SA|8N$duRs?{%JJ*T{HG>5AcL8I*&O1Ju^KN z1^!Yp@h&apFDzno38}29au*Y6VF#%(B=Pd^`t{{04g#CPRH8PEL>89OH1Y4=wM`?Y+cnsCD|dZGb#-yb zPbYsY6v#U#TTlf1)HKmxCR88|TWkfi;WgJmEa>U!iH1CPzc%zlFUrZIxOpL50SAW2 zHrkRe-Bv8!+}rP-U23*Bp`mB-jzz%dHuKoF($TRq)t%&MEAPFIet}u?$D-;-NTfd? zqGBFudL7@{$H>RCmXS~SDk-e2cr(q3b}2D4;I^fdk8wf@!NHcex`pmIGxX}ykX2Zk zP#l(MXu)GF(Pvk zb5n$3uu@QfLrR3XE#bH{zmF;My}ImfZ|eE@n0GU+i65iC#kVv_JUkHP6q^ z=b4$1KRnawHnN9;XOVD+dTcU@PWtQI+{V7)vVb@}2{~W|d768ob{*KawLyATCMyBY zhk?3y?SQh*YZ(!U#KDNg9qaM-(p?CZPE$X(8z(y`Rk002FaNkl8uC7fajE|-h>jHG2b9lbevz(KOfu`z+X2)PND2t1w1WGFmB z;BZ@Tf}w8eW!d6lVUNJlhe<3w@VLAr5!hqYo=(frj?qrXhNe@r$z?o#)_BC$c#6Tn zw%ibJSrePzu1EE-o7FRWE@Bmr=0#t-W8=a(6GTqoYvcqTWN@=@*0!nMye8HIu2(T+Ak@9J5Z~>D99iw*`m8V%yP8G^_lKA3_-39D4+I+C1zz z%PxAIjtxqC6rEeEoK;TYRK5moFT3e)S;c473ltAKvc{hCWlVc;gKFP7(_^pP+TQSQ zjTnnuLBc{Sdb7KSnYy{T8Mi%*-`7X=bnva_VNVf!d<1rL=-JH6uuGF1?^y5f9AB6q zotFt+&fvKN9wTt?2px9TxG)4b)AV}%MO>l#`PSCbhc8CH z(ahGS3jt5QrHGrvLqpybTd3aT!_Ma3C?0!8iS}-@N4$|3Vjk~Odfkur_B2j4Q=ai9 zwCdFE-MgodJ$v@--@hOJdcD5T)wQs^+~2>veB#83lSsEgpFKBQ8LAYfrz?!j@VGrK zfD?mhnuhu zc6A*>`uqE-yqo0c(WA$Y&khU>p!`akr_C16;qx9(K3}Q48GMs(2|#W(U+C>U+gs?p z^6}jBk0WP#6@}XUG1|MFxifa;Gu`Gf@{^8r3D0vJ&-0ExB2Qql!KaO@u%q%RuxCa- z=nDq{@3OWa?o`}pF?bNzz;Q^nz?4c2d1Yzhk<6eIWaeu#=B8Cm810v^Rke)+e)?h zH``r9!+0zn64TyHj(U9NCw8Ir?OU83bm-%VH;0Wb>dWQso<4o4T$akBA7WgT3iz&_ zN#||w+mrl%lwSPt^Vg61UR6`~YFWHi_l{!JcULueSU zuU#7-U!wAd^F!yiGqsgYce}fpeBa&ns10GwH=8Hj)>BVDk~}BH;~@vhCnx{=D_1_h z9(z4@+Q`0r`z}a*NhgoKotri}dCcg8TMu47d)M~vT^slBr56_$zkgrMPE@N|O(WZ! zsLQ%0YpP1+LKrd6^35*)GUSB5)MzwrJS8#U4D>#RSz-pt?c=lJXO zeSaQ*)aC{sacalkE(o<+>1c~WPfGnKtu-k`2YJOl(N%r)u4fVPB7smYkR!~c!2?5` z13>TVn~)3sx0VVE3qQ8?KZ&MxkE4I%0~`Az9FB(`>c8OVKkXPppkEAHPbYRdx2|$6 zf*j~H;Ex?orIrKyj}eYAQ%S`h#fdpw@Cz<58T?>}2zx?ZT|%y(T{~Xpi=gkZTF;#e z3F=$F{`}PNFa>wR$HyM5Ztd#os_vSakjh6}Iy<|C2zX8|>ielr&R9gEe{Fo0|8gK| zkY8VlfcpEtiRi!U(S93Z-L~--2kINT8Vb8(?fP;$%dGar++*t=TX-4CqacXL~rY1d|=Z=r( zT@Q{j(+PIADfOvY)=!t^b(wRg^=0R7n8aR zGu)okchJ@@r~V1+Ujz8JBY#ZBac;u{>vE*5fRzYXDa*3>N)mKP)O|L;_+)+@W$#W_ z1HCSw0BPQbdWUK^n3k3~2){GaaiQou{J~fvivE1qGekZm14C^s_>uYe_~`Zew$6dh z&dz2jY$hilM;G9l1sq4)7Rn-P`H|OEqLr&S14g)DnOR!8zA!U0bMNinM7RaVpGDl; zY-jGh@Wtt|F$}V_tG&EfzS=j}cU7%lLF4S~p35Z7OJBR(*!bOV-xB?PmY6P)N+eR& zm~-CP8no)@pwxKED3P8YEr^+%?8q=F+vn#4EnG5nUJd7iSCx$h8STYo>M5XqKb%>U znOOtZDR(?fN4Uox1Ub*XkD$wZHf)e>(EIqv@I>f+HsGnMd7^oAVqjvh1vQ|K6RZ%6 zS(agDR(SBQc^!rdmzN8vK88rJqp)LqgEnqF@z805HGQJ@1$%=?VI znx@@zXBFMuwRP&sqPpVZvLw6xjS9oC{Zv}oug2jiu%}ZIcF@Ph^RCBI+pC^=W&^+h zj2nbIz;VS1L`O&K^(`$vP;`|5u!wLu!{jbqrQrBbaLVo`2m4qAM6qoVHq>>S?SyR` z*c}LXS5Tn6g}o`iI4?0VQ5zK%Rio1xlm=zWuo0G1 z^py0Jec*;-d4*BepMTH?oH9ZSY$|#H{6GG`^dbW~(Tbd;`3i5jm;5kK&YSMhLvC&3 zHVlp9eiusn*^WX_1XErv-9)w42ysdA?Q+H zW2CX6=ZBNdm?l$Xli3vMR5s}}x+#0!T+v)!UV9=H(9Y8J_>rsU{BkbR#TC3Ak&M^yN+acyB-!s$e-Ut;vL8ySlm4a z;eC8dRw94`tf=X%Uv6%$8=aRI9J<1TIMbMW6^gFu(4jHQl%}SF=r%{bpn^hWvR;$u# z?d{>=gnV=2*2E~n{(eP81u1Vp-=CRI+4rUIi{BUTb=|}MLKVTK$?cJhCIQZa#yajY zS(}2N?bT>;%*x8uf2KJB_nPh{ry9GsF6g#rFPyoz{6b}Ux%JHA;^J%)xNpWt!c`tW z{u(CNPsL)vuD!{O6hY2%>I8qZSX5O>PtGWEy~`Lmb<%8B>Xe$#4z(JbN}bN!q|z#P z103ko^(ZQx!H{Jz7!K^;PuL-zok!n77@PpuN3`=QIJaXNJwN>xw8No`D|!K~UHql+Qv5HWo# zB}cT^)aaC12QmqJ`hK3=ZTlv`6W5{ViSOGfIrW*|Np9;)2Kq```l9tRy)3$O^iF?{ zPUxJ75m{!I-KK-QaAxVc*K(Nd4R;SXqMht4{NEVX+)5Xg*@A@Hq<~LB?(fg+E!|uH zU3PZ%u1f#x_XH9a#ZAHrAeO}~uDGbkZnqajX~LVrJ32BtOdr;k&6(!Li-vb=RcYZo z`qr(9iCZ7x(X%SDkm@`-$X^FI#FKA=?VA8jd`GrF3{<|9@ts|UOIx>`TRl)x)i(4! zVqK1178248PoY+zy&b-K_%Oy7g$1LI+PVzSss7D$wDbGdl?MTRO~_3yx};tzTQz$r zSe*>=WM;>E0%_2DZ|vGpUk`K^A_F2WgkGGN_tjVSqN1X_;l#xEe>Y_`nRX?JRuvab z&g~`&C+yn9tq{;bzH_ItrY6OpN)iIAqhPS4RrcG0}H-ItzJ63yu82&@oOwU+_mf1X}n+g2RO*VZncK44<-BB z+G+Yq=F+7-dwvP<@5T-$&i;rIO9hgIw?BI0!*bRmde8z!{OebMCn_45k1IEu%%;5w zZ2pLs8`5bugFNbyN1`6vx%0719fnqA*1>c_p8opl;C9=-g_85G(`0|)akx&hT0i8E z*A@6EL~^dPMBnD8U_geo*8BDX#{gcTd}-NoZ9(W=)2}TPcDLmocn>*d*J+ov2jn5X zXFPA=Qd371{#Zkjvdg7$5|ZN*kx0rQ<9P{LJPXA|<1mAld=H zeF6pxh+y>)4x?&9&JdUXE;854k?u3tb-luOx$vDg{YKA04)&K8U7-bQ)+Wt*$g!p+ zd>R)h=2(eXDrI1_slN=}1S%ohp zYxPt}n<|U+ZLLX3DU^`n%%gKDue)jSGZ|@jXG+Vz=eq5l&YUz)X3nM`O}_;8bW6G= z_o!T>E7p}a=o+%+4G~%088Lh6<#L=(cY(ZrFR_KH+jR%FgZ+7u*Ku0ym53ZDlD%;M zDK00U$79jCFr3=+e>+Zd8Kbx^y8rpdw;+ePi0(rEcF{vXXUH9M*J=IbOtmtzv9U2p zZ8n=LDb51T5%B!EI7_u9F0HyYe&&bWyDz1GlxsT+qsKmW{8-WTmSZB|aUiV( zp-$K&$n7N5VfYthn(2a0mpq8WDj|Q##oe9cXkS151>`UX`LAYm5)73sDbrS_7t)At z*5MiTSA0^HksSw%*X)LU1ay357LSh~J$h6Zm8R3Ap?k~D-LOHIy{AFm-Px^**;QYa zRWHuV0((CzdpO8}4s*y3Xwud&^^FK$SLZ;dLr&F+Ft25_rg2cGMHE*=P(hwTxPLCH!Q#wALd+)uu>YY1x z@80P^ABRO1AI(Ks%hl*K+3~t~e6n@AtgJn{^)dCj`q*8&RP*TJAcw=-+1WIg>Og-! zi0R>uof>t-y6A!jjiN=dZvEf4lN?@2@VXN~XWf0N=0ImPpPrm-n>8vX&)n@Ol2R#B znbf1LwNQFh?-AAi|L(|>>jb9nKL5a# z9Oin*V%Hps8x@|4J7>=Pz-uLu-d02$AM6y*6+OQCyoDT5;^I)icc$llc4<5}_oyZ} z9q6GAFnMu9vAj6DbA5(iJ=DU~vNpz>?Ab;zfJ01KKV`b&+4+RMK#-yA2MrCG_ zjasUD`OG&}adz8*Hiir*E=5IYiqq0M(?ZkbGuepsVqLeqJEOB(2kKohauw41-dFoo zTMPU9LH@!E;jl%)zA-iRc}Di9+Jk~xPK8|TB|^jN?%g<&O~C;*1>ZTr|1HqT^~&AZ zt2|$RWm0odWs$lF-$Id8uw<=`?m#1}vaQK}T3tBj~iK{rDR^4%a1L}Fip6pKf zo^E+P(CcIO@2Z!pRH`=%LEgUw>`rv2>e~rA)5v2sH_8=VnBt-*_gW4*wPuqbAjy{F zg8t9slNhyMMJprJo3Y9#Q_FY~k2ZAkutg4!9=0@%*iP77rNsdba<2F7igPm&jID>o z#Kgo_Rqc*a9xqlw4X(wq?9avVNq zlfWb>_yT3k)!mnn1Ko?Cg6jldkn@@v0Zpnql3mf#LUJI^Vez+xlB;b|b15a~Lmi@X zJWG2YK1tUT^v0&MU$F+&){6@@u6Tr zjdB19{%^XtMFoAbLxMTGeca3`Dl2Pk)9Z^WWs<-7woPeKX~Znm6;#ut=)i4DZGI`h zOUtV7N~y{@4xQgO_dr`{X@zvA z9J2{nIpTZ?Ix9NJfxgt`Nv!vrR&C#Sx@&moL?lHYuRFE;i^icGLGYMgK=2as!*F+y zzYB7^=2C^ii(DQ062r07cvB{%yjs=fMwz`zF6@(vkk(-#is~cOIV0CsxT=)reLM7O z{`m-UPzCo=aF7%BcH;2FTvT^-HCu;GT{Si0(*uFSLtPj@?fr^guIS!|F@Y(-mgIM0 zaW8WisqhzQofDQsa1z#?_ca*OC3#HY)*TC(}?XH@?&Z-WxtL~JYjrGCdlLMQysqz8SfFa-G>$_VQx`Nh36<)yN?DnC)#7fB z!>_%4IZIsJ+?=ICB0tL7{@(1QvYaHs45Uw{tXPiEHi zq;9v>)C6A~O&ks3E?4zOPYwjEGlgLhcHN7M-5uy4zvVcsRg7q(#oprRXf3(HQ)IUJ z(u5qhYprT2kK(wXIgT4Cestix!M$rbb2e+FyM>a9riL|Pi${b zWYL!fd*tdHml<@G>e3Yo=eHL4-U>46j7L+xp|&jsyRdcav_GR z?TLwOu)`KNH6uRBVLeKlQl-)kmWV=@sXCVuBE7nXm4b>5UH&(vkkqhs7x<)`RO!=hk@B#+>Rab5%2HV z@qUDT;C_V5J-1;)dF|B@?)S7eM0aW)%WxBPyXuLse{y(u{0LS@BmIVYYLo{hWD2@W zboZVy!GJQ!6dA~Det&WKgV$KiKP2R^X|e|>@v@5htOl`G9KBCW0iDKWi+vohILtX5 z^p*J^*^es_9A7ZZoR6G~M`F*2FVBc^fIH)yC5P$^JM5o4eyi0V`;&p#WgX~oN6;>J z0et0m>jc5dfw0Ihzd--h$)=yy!QEN%TWxJW>+df)pr5|OSDf3oFFG2ZXzc}>q&b_B zMpg&^BI6+advZH0JMHW&ICIl5U)0LyHUE0eet<6}U*hm=L-*YCgZ@xG46Ceyo+d7D zd3%z`xob`i3j~46u;DJPA=%%@|0kPmUi4qEJc4B@?^XHJXFAqO`V1r1zKLtsR*;NE zNzF#Pd#CU{q(+zR9chQO!m{&Hv4xPQX#j3VXTf1#kFu$KhQ1i<)SPUJuM zj6L-LfC+56y*~W^lm#th`;^yuyU3>Y=Bs#gX zxN*THx|cicONSWMm{YK(W-A(|v90N^r041!rU`A>rg4C?uVnZw%yymDml4p z^m^gTU=MovKC&c}*us#r9&ZPCq7Nqfe2aR-pda$Z&s?U*NA?7pOv(Y%6~k)7gUQK0 zPXzxS#^$&-EO5FRvD@!aGJV(U+5=erBbz^6`zYjanHk5nd2`k^-vU{R(Sp&GUG>oM zZ5lf{)4a0iGhRQkVSen#&u&g#tE(%ltE+q2en+0jqO)y0J_P+)(#k#;`K>=vJhLjj zDUys|mm@j;KfzeA0IK^LwAwBofAX$JdD#!-1bxj)vM1(_E%vq6zP{+w){!n8mrh3; zP?>3?t*o`RwXLm94=ZA`CPfMH&zg&g9c98Cs=H{;pvT01{ONu+!|ngfTKN5O>D1Ks z9zV8_B>{)%4%Nf)K|f~~9kP!c9En^VwmOiYuRDl&ySn`A%x**wgO0!UE)4c?Ms(|g2CMy12+&Pq_u%a! ziOWhQZw%-Gfyx`CR6=wgpC=AI^yt$zfZw|H0Q}u;1(u~|^$B3tVn=nvYQ4ed2zgxS zE>vK*U!tfik_qSiodN)Tp2_W+;!qadsW~ZX1U+VRZAlf|$MhE>%)cUcmcFa5x76XP zJduPuW)*eUUzl&>!y);g^^r$>h9i^xfsWT$ICA<@{~MmBOC;O{I_0brprKJlb|J+N zgZ&Vmu|4|e&9I`IX0;XsGxg9iuu zuqIF5#P}!U6;uFJ7mT4u{r~d{{YO5J)tr*#)Qq8zwfTvo#i?CPtTX5!huvS|)--)a zw#q}{A!(XCZ|$>Mts^5NR&tLlRg*lYuGAyZt6S$YJjeGH{cYSNYBb}WgdFH;5svdY zJ~6}?^eSp<6xf?_U?H9R$5?|PZITxa^q>|(e$2hsyTr=+`}M~s1`m^+} zk2rdWpck2C5|LhA$x9JQGc#F_$6+?9IdeQ+jvIysW^EuLAuqlmuUj6mzB@0AxVyL$ z4qu-aJCQT;`sS@0+g~r-xOdA*nUt*3k`V|&2YJh}RphC_r-R6Ig#F?g!ysM&;#ElG zL7#6|M+Tbw0&44d(q-Q%l06rGzZ+>}TLX6*pw|{x?0MNM(^eHS2w6q_?+H`NP_lgzP>mx6aB=_u_k3P+) z?qe7vNjYG^WP0@gS$Q~#=Lw3FI z^kQ#lUte#p+rA4F$6!E4qNPdBj>arwkE;qgrLh@`!#X>ea{d=7=N{8m702;%aa^D< zV6csc@^TEk>mZD>DT%9=&`nn;gh)mlB7!rdB9AJME`b_S!eiwj ztdeHfL{c_bjmTcch>`u}|Hkh*x3{+)Iw$_<;Qj;ar@!axl#^7s(}uH{Y;^fAa2w@GE+?S3Ep z{Oz~%^F4tvUh2BKPS&D;Oly$Rx%c=!JlS~bVug~%%PXR^tFgEVUFh02#JbG1Hj4fs zK|iWiefYX6=Vd3lDs^3Z}T+Ya;&Ni@f!YgQA1J`fWyK%5;X(4!FEX-yLqx}StO zvq`UuOHP2T0^S!C>=UXTiWi?HgPSd*;fB$KaJ9bkRLETcolYqut+(&mx3K>6{O>(6 z(xBB&wIz3z1iCvgYY78VLd(Bg2Z+2ir8OlLRQf6^D$l010h^$|1oUdv`+2I5dGy!v zw0Uo7b($(eu6+&YXc+P65lgLzaR@ILFc;IX>f_gL+Az^7-f8e=hu$F%q3A7}estPl zClWei9YrA0N6X`Y}!prk%Okx6*BdR;WvleVA97X%R&DC&^KGs4G%(E9BPQ3WVdbTMFDE;wHAn3hB92y`<(J4RpFY&niX{j{c{56Ajx2`3ml z3fQ;c>p4Jo)B2IDr>0~gI!SKW&s+)ExP68iybs8Cn>KJ{GmNBl7`%LMaDv`qk|)q8 zHxsyH^j%19*lhfyv{Tm^M^|oc=wK(aO{nJfg)QB^NrbM+Cg#s=d3U|a7w%$7!w0WjnU;tsxcgfeU z!?dyx7KV9G__}WK*;7dg`FeRQjqo#4cN+G;pa+uVW{6GJVKT>Y@9r}s&UvEy?;{8Q z&z$ienRm*$b0Z@-4u%F5>Am6&pQ(Y?1u=tp?;Tih9fz8ispN9RXD5#@M; zUofRC52d6oL`9K%EKJWmrz2O^$de5Sa+{ki%nln=5G-1gS{}57_x38x_&7y$jFZ## zx)WV0t*op2e!iCY`o#BDyx=f6mT!;;VjCm~uFlJ6-XzA55Fs*gIpRz!<4JhY;1C}BLr<47kbpwp6LEtidvj$ud5s%uc(|KfsBujHs zu&DiuCeolf92|`Gx_Pw4UJ1D9V@qY-!+W&I#AW{29FwE2=PFt>@h#h zt83>+6l!>Rt$O|(1e@nSZo3i;tX{b|f1ug3=c{HsbI`g!Gpgm$tGA*1!O`1o2iI&x ze~V5d{Gu)+_2JOdQD)kZ&6#$XrqM%POeS3#xfef}x)b&Uawo^A)iBnHv>qa$3)#(Y zR|nLNF`uH5`Pw=Zv9=FJftcKx8M3trvP+}!MTCi;sSA~5@A^0wGD`#u@a zPY`s4>LQPxrPgNUXj3-qyEOLw<+i9bTa1v~Ku*z7&4C=f5?|kSQ)=pZSd@+)E_k?i zT4z2LVvRNH_2KEyau{9QA$#!gq;zw5EY|%xY(Y?Tu#1U(cRSU3Gql}Tr)Y!D;p>R+ zw(%-nUWEudt==&Ci0tMwJzX_LXTGT6u(Dv*>;aNd?bVmxQmIcUh_B~$Q*>zk{BFCy z%pTQYi!|7RM07$f6{4IEt}wZ~n3}pV7`B(#d)`p&b9#qEXHK?S^3&g(9w0+5GT9D{ zo{2i14x5j6bdF8;-V3=)J5(Y%&2B&sX#e?~Q^vo)NsRsGcy@L+4^NhF5{B*of!({N zr1aDBlG4(W&u9R;Zx5Bg*H2tkDNxI_=3$*$U6)m$%_z_Y_}WHCZGMPxqc+5MF~Ead zK!>mIj*LSIZ(1DGV+O=DsDIvc4_o5X4y&biF6F@NB*$Env3I157c78za&+`6tm$S$ ze7FT2*N~7?+Y>w32|7|a0vn=R8TE4rzCm92=1_5cNsWYotuwTg^)7#}SqeWW=VL&W z&F(X5U%YriMdV_JR;AL`W#y~TvkAJeX|ru=?%Td#qwm~S^`r3rdWmkw(A_ZEroDXB-mrlx2GAF?s==(t${^?w zUiWO9p;$Nv7+M5$C|z)MitbC$BcpUVD^JsFOHju4S{?LWD!ggyMk3}wPEN{}u3wi8 zkUd1N|8nb6fB#&6Z@)!7hCdi0E?dJqLVU;gxrsU|WE*0l z%F)~gbllSvYF?;4p6^DdPo+Iefy}C|^Ia#!LicZx|=kx;>#>W*m5$35-OP}~2($)sWSM+5L zV}#I2OF4kVH+~tA(W`!DFJ@7pL)Lh~OgZ6=68MPisZB)3;w5VTVLA2y%=mIR^!oVN za9o=7%<|Go>#b`m-M`^#21YutbVv5&T}nwX)w)%$9r>>m^wyho>i54Tc5$@-0|-^qv5389|oe03Z9LVZLDo@$A6KChyh0HFb zH|ekA^*^-Xq<(=~-FL`Hb?zd+to(?BY9G`5mrZ$+6K9vnVpwKiz>6mbx@hn2sV$OM zx`58#I~W^2XUVr*-@~%AlU^LLIT;BlEKM=)I%iqUKdFR$1L*kb*CV^R%J|T279Vra znbN;OkGa_B0*5r+_(=H?N}9)@vyFLnOlern>=agSth1P*!@GE9=pzJ1!2Y8(j?VDtI3JWOqCdKV*>@q}he~y2-0s-K{cKKo9a*x=?b8&f7b>u^^`# z%sPvuKfgeogGi~_NSvZWKRhb=lQR0m(e&}y`hKv*ItTLp1ie~L)Q%>VE6@SmrS>9S zop8E9eaLtW=m4kEnA=l$nS}C3RVZb_Q zLr^-sTY=1-lhBT_YrJoOi%O^Huy^;Q?o>K=1xUtEJY7?Lw5zbeUY7t>e@cVp)&9rjhRZL@fiLU zrln!fK{?De4Re>ji@tQZr)STlo*U5|+k?w_7{SVxy8+FklYbz`r^BqH6dUm7(J8rS zCC8(KT(EbX@d`PmvtZT@qCVohi>Ld*B$kaXduBN)RY5fS4+&j-@}B`Z#sT6_jg1|5 zQ#-m;e1nd%<0_h=PNX#j&POZG76Kd8g+`pxtWE^ zON@Zd>}y5+D#o}g10)b5_$AIpgIp6BNR=*F+*~lm}B~8kn%Sz?&C8hFo&_{(Bb_!y|k|xpJD$#tM6v`FKZc zQ~INxPFy{1I_G(iQ*?DcnQ5hw1GXa-K4flvSxOT1azhW<|(3Ixh;XVH5*TL2eCp0E53{WhKEG`gQ5;{d6>n1~Y%ma5 ze%K}aNC~DK+Vp_bAjJX&l~pX!HM@JUkSiCE6(PF9szj`{VmUYnXKNuyYDA-?mnbI= zsh~ZyRfU{fDpf5|C4zE^Q2q(TcV>4o9$LVOR9;-yQ7`@Y`{vD?H?#AWj`#f-Tvb8Q zUxWKlaGD_9;s-W;cL!JpYxaX9{H|njNAxrP{08)3)lS)azB%(9Qkr}U?AFTRqbo-b zTZUFDhsq_bTvp4Lx;{EpLvo`M^rK}B=xpIG%i}ZL;Rk1KDR4;S-xqIb96ccCbGjfp zVqD)Z!Ce(JzK^vBkLS;AqgJx}6XJ(3+PUn0kpH{vllyxveEH@X`^Y5bH zJ^uSU3>{aL@axuK2%L&cu2tNv0bO7hWcOYE(F<#j|L_L}`pfU;&!0?zdu64RR?CK= zOP65uu<`3BHspiAXcZJDAca~fGrg@ zXaUNypPzhv!T|cGVXbP_jO{5Sw?W=(En_)N(2?B$eXCq1IZZ<^LUX_)o>TO(4;^ez zlZuqxP(hyLE{ivC?6?#-Q@L5-8-bNImmP%IEA*pTR~CjEX8 z>A)_?&e&qn8IoWk7-CsWpnHEm4E)p9JqzF|z|j9S{59x_T{BPGjLSp#~jHQiDq zsGg;YW;(C;L2N8*xG7Ur(2`b z8bu!(CFsatG1p-T$UZs|9U086-xhmRX~Aq@w%2m8^k#3-ZFF_ndLtHP`GtGq!0v zF(NuA?-t2{4)Wg*ku4V(*eCs~(j&iZ!r?(axGLfd-NZEC>G{!N$R4mC5ZNI+Vej5I zn}=C>ihe7XZ|1j>Eu(4}O4({!B`sA-!_$vinp{q`q;;za^stn1OfTsG&iSKXRNxrc%gd^^9xB5b@^qq~|8u$i?VRV;s)e zf3rCiOXGobOKn<)Va2d;l?Zwhi&p#<);vsZwwX=Nn-#}|`{(8h+MJ%4vvZD?gEOtE0_g@+bTz-JE3tKTXm%mBT z^LK7yBdUL~7w|#fgS3hXN=v3Unl-gnBF?@MADXTjHBuFI^^8Owlkn`cr-xk~GHVT6 z#mn>-^h(q-l*t_jANT-SAV8EK@>Q9n2(Ueq}&dkrOkQyCnK;ggPO| z!yt^^*Ig{wK!&^Lanorve**{f19reCeD?G>rPnliRX8yXIZHf5&~vKoNYWQ(*fz-* z;M!rwjoWTUpPSd?b=&sliR6qt&>W%*1D%m$NS>BNOZ>WuaL+ZDw=a%ugIoqxhoO$i zPT7Ip&JOh1>l3g~w^?jVcxVAZ8$PIk`gn^Ic*!H^URYH!r*tQ3yJ=+Z`dpMqp7Gq=oE`nlZHw)q z<}8`Pyv9Ty7BW^A+L-Fd;#SWMUWE3$YX$SzC9eC9%Tsndasz)S=<92=XoJ-|7oJLw z{ubjnFh|C`N(Vmp@h9Zzu?)~L%jvq8Fy|4~qlIEtuefH^p6h8iEpuL&)dX@RGsN9F z`N);~?C60q#6BxMSIPP{#5UbJp5PceOX}Lf{8tqHgB#sJ!AgJ^y4)AOy<2b!$cE8t%=oOIDMpsA~@74TSHqZwM`NJLD9VqXm`O76C)V;u~ zRZEY*_`}3`kgxeg8yII7;h9nLG|;s=vi7XrsO$6fLN-&V7xe|#?6KXt9?95quH7GD z)A{Y2ocy^Uxcj0H_yc`-JoMifd%DEn8K5(EA=JU=ucIf&ylJtPPZ13ae}EbQrV zV26r&v4U421KtMG8GFGj7VWNxQ_yGk`{d-P)Sm!n`72G`LEb*lp9=jK8G`zrYrqR+?Y^hyzW7cvbqA4f-Sr5ueUzLvaeN$c zN4~mq=gtS4q#5s%SFUt3c+fwz)XZ9+$XWABkh2YCQFBE14o3Rk8(kf|4|{N)uJ1bFF9hp%-l;Rvb+;eJ;5k1mnn*vn zRR5`tmENP7u0(G#8I97WR;;HNeh)bt=Pb5U&1rCd;(_ZHiyEwno#Y`YP z=)oSiJ!{S?@Z$sdh<6zNiBL0eLe3l2ve3@Qxsb|0^hxP~+r$6B&T?ARtbF0Q@`N77 z;R&Z;nSQP}xQPjUTE$82e&nx658Oi1fxoe{+C1BsAngAEz5qf00MAd3Cq<=4x Z{{;$xH 0 && tarr[rule] != nil && !override { + return &ErrConflictingTranslation{locale: t.Locale(), key: key, rule: rule, text: text} + } + + } else { + tarr = make([]*transText, 7, 7) + t.cardinalTanslations[key] = tarr + } + + trans := &transText{ + text: text, + indexes: make([]int, 2, 2), + } + + tarr[rule] = trans + + idx := strings.Index(text, paramZero) + if idx == -1 { + tarr[rule] = nil + return &ErrCardinalTranslation{text: fmt.Sprintf("error: parameter '%s' not found, may want to use 'Add' instead of 'AddCardinal'. locale: '%s' key: '%v' text: '%s'", paramZero, t.Locale(), key, text)} + } + + trans.indexes[0] = idx + trans.indexes[1] = idx + len(paramZero) + + return nil +} + +// AddOrdinal adds an ordinal plural translation for a particular language/locale +// {0} is the only replacement type accepted and only one variable is accepted as +// multiple cannot be used for a plural rule determination, unless it is a range; +// see AddRange below. +// eg. in locale 'en' one: '{0}st day of spring' other: '{0}nd day of spring' - 1st, 2nd, 3rd... +func (t *translator) AddOrdinal(key interface{}, text string, rule locales.PluralRule, override bool) error { + + var verified bool + + // verify plural rule exists for locale + for _, pr := range t.PluralsOrdinal() { + if pr == rule { + verified = true + break + } + } + + if !verified { + return &ErrOrdinalTranslation{text: fmt.Sprintf("error: ordinal plural rule '%s' does not exist for locale '%s' key: '%v' text: '%s'", rule, t.Locale(), key, text)} + } + + tarr, ok := t.ordinalTanslations[key] + if ok { + // verify not adding a conflicting record + if len(tarr) > 0 && tarr[rule] != nil && !override { + return &ErrConflictingTranslation{locale: t.Locale(), key: key, rule: rule, text: text} + } + + } else { + tarr = make([]*transText, 7, 7) + t.ordinalTanslations[key] = tarr + } + + trans := &transText{ + text: text, + indexes: make([]int, 2, 2), + } + + tarr[rule] = trans + + idx := strings.Index(text, paramZero) + if idx == -1 { + tarr[rule] = nil + return &ErrOrdinalTranslation{text: fmt.Sprintf("error: parameter '%s' not found, may want to use 'Add' instead of 'AddOrdinal'. locale: '%s' key: '%v' text: '%s'", paramZero, t.Locale(), key, text)} + } + + trans.indexes[0] = idx + trans.indexes[1] = idx + len(paramZero) + + return nil +} + +// AddRange adds a range plural translation for a particular language/locale +// {0} and {1} are the only replacement types accepted and only these are accepted. +// eg. in locale 'nl' one: '{0}-{1} day left' other: '{0}-{1} days left' +func (t *translator) AddRange(key interface{}, text string, rule locales.PluralRule, override bool) error { + + var verified bool + + // verify plural rule exists for locale + for _, pr := range t.PluralsRange() { + if pr == rule { + verified = true + break + } + } + + if !verified { + return &ErrRangeTranslation{text: fmt.Sprintf("error: range plural rule '%s' does not exist for locale '%s' key: '%v' text: '%s'", rule, t.Locale(), key, text)} + } + + tarr, ok := t.rangeTanslations[key] + if ok { + // verify not adding a conflicting record + if len(tarr) > 0 && tarr[rule] != nil && !override { + return &ErrConflictingTranslation{locale: t.Locale(), key: key, rule: rule, text: text} + } + + } else { + tarr = make([]*transText, 7, 7) + t.rangeTanslations[key] = tarr + } + + trans := &transText{ + text: text, + indexes: make([]int, 4, 4), + } + + tarr[rule] = trans + + idx := strings.Index(text, paramZero) + if idx == -1 { + tarr[rule] = nil + return &ErrRangeTranslation{text: fmt.Sprintf("error: parameter '%s' not found, are you sure you're adding a Range Translation? locale: '%s' key: '%v' text: '%s'", paramZero, t.Locale(), key, text)} + } + + trans.indexes[0] = idx + trans.indexes[1] = idx + len(paramZero) + + idx = strings.Index(text, paramOne) + if idx == -1 { + tarr[rule] = nil + return &ErrRangeTranslation{text: fmt.Sprintf("error: parameter '%s' not found, a Range Translation requires two parameters. locale: '%s' key: '%v' text: '%s'", paramOne, t.Locale(), key, text)} + } + + trans.indexes[2] = idx + trans.indexes[3] = idx + len(paramOne) + + return nil +} + +// T creates the translation for the locale given the 'key' and params passed in +func (t *translator) T(key interface{}, params ...string) (string, error) { + + trans, ok := t.translations[key] + if !ok { + return unknownTranslation, ErrUnknowTranslation + } + + b := make([]byte, 0, 64) + + var start, end, count int + + for i := 0; i < len(trans.indexes); i++ { + end = trans.indexes[i] + b = append(b, trans.text[start:end]...) + b = append(b, params[count]...) + i++ + start = trans.indexes[i] + count++ + } + + b = append(b, trans.text[start:]...) + + return string(b), nil +} + +// C creates the cardinal translation for the locale given the 'key', 'num' and 'digit' arguments and param passed in +func (t *translator) C(key interface{}, num float64, digits uint64, param string) (string, error) { + + tarr, ok := t.cardinalTanslations[key] + if !ok { + return unknownTranslation, ErrUnknowTranslation + } + + rule := t.CardinalPluralRule(num, digits) + + trans := tarr[rule] + + b := make([]byte, 0, 64) + b = append(b, trans.text[:trans.indexes[0]]...) + b = append(b, param...) + b = append(b, trans.text[trans.indexes[1]:]...) + + return string(b), nil +} + +// O creates the ordinal translation for the locale given the 'key', 'num' and 'digit' arguments and param passed in +func (t *translator) O(key interface{}, num float64, digits uint64, param string) (string, error) { + + tarr, ok := t.ordinalTanslations[key] + if !ok { + return unknownTranslation, ErrUnknowTranslation + } + + rule := t.OrdinalPluralRule(num, digits) + + trans := tarr[rule] + + b := make([]byte, 0, 64) + b = append(b, trans.text[:trans.indexes[0]]...) + b = append(b, param...) + b = append(b, trans.text[trans.indexes[1]:]...) + + return string(b), nil +} + +// R creates the range translation for the locale given the 'key', 'num1', 'digit1', 'num2' and 'digit2' arguments +// and 'param1' and 'param2' passed in +func (t *translator) R(key interface{}, num1 float64, digits1 uint64, num2 float64, digits2 uint64, param1, param2 string) (string, error) { + + tarr, ok := t.rangeTanslations[key] + if !ok { + return unknownTranslation, ErrUnknowTranslation + } + + rule := t.RangePluralRule(num1, digits1, num2, digits2) + + trans := tarr[rule] + + b := make([]byte, 0, 64) + b = append(b, trans.text[:trans.indexes[0]]...) + b = append(b, param1...) + b = append(b, trans.text[trans.indexes[1]:trans.indexes[2]]...) + b = append(b, param2...) + b = append(b, trans.text[trans.indexes[3]:]...) + + return string(b), nil +} + +// VerifyTranslations checks to ensures that no plural rules have been +// missed within the translations. +func (t *translator) VerifyTranslations() error { + + for k, v := range t.cardinalTanslations { + + for _, rule := range t.PluralsCardinal() { + + if v[rule] == nil { + return &ErrMissingPluralTranslation{locale: t.Locale(), translationType: "plural", rule: rule, key: k} + } + } + } + + for k, v := range t.ordinalTanslations { + + for _, rule := range t.PluralsOrdinal() { + + if v[rule] == nil { + return &ErrMissingPluralTranslation{locale: t.Locale(), translationType: "ordinal", rule: rule, key: k} + } + } + } + + for k, v := range t.rangeTanslations { + + for _, rule := range t.PluralsRange() { + + if v[rule] == nil { + return &ErrMissingPluralTranslation{locale: t.Locale(), translationType: "range", rule: rule, key: k} + } + } + } + + return nil +} diff --git a/vendor/github.com/go-playground/universal-translator/translator_test.go b/vendor/github.com/go-playground/universal-translator/translator_test.go new file mode 100644 index 0000000000..837d2d39c7 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/translator_test.go @@ -0,0 +1,858 @@ +package ut + +import ( + "fmt" + "testing" + + "github.com/go-playground/locales" + "github.com/go-playground/locales/en" + "github.com/go-playground/locales/en_CA" + "github.com/go-playground/locales/nl" +) + +// NOTES: +// - Run "go test" to run tests +// - Run "gocov test | gocov report" to report on test converage by file +// - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called +// +// or +// +// -- may be a good idea to change to output path to somewherelike /tmp +// go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html +// + +func TestBasicTranslation(t *testing.T) { + + e := en.New() + uni := New(e, e) + en, found := uni.GetTranslator("en") // or fallback if fails to find 'en' + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + expected error + expectedError bool + override bool + }{ + { + key: "test_trans", + trans: "Welcome {0}", + expected: nil, + }, + { + key: -1, + trans: "Welcome {0}", + expected: nil, + }, + { + key: "test_trans2", + trans: "{0} to the {1}.", + expected: nil, + }, + { + key: "test_trans3", + trans: "Welcome {0} to the {1}", + expected: nil, + }, + { + key: "test_trans4", + trans: "{0}{1}", + expected: nil, + }, + { + key: "test_trans", + trans: "{0}{1}", + expected: &ErrConflictingTranslation{locale: en.Locale(), key: "test_trans", text: "{0}{1}"}, + expectedError: true, + }, + { + key: -1, + trans: "{0}{1}", + expected: &ErrConflictingTranslation{locale: en.Locale(), key: -1, text: "{0}{1}"}, + expectedError: true, + }, + { + key: "test_trans", + trans: "Welcome {0} to the {1}.", + expected: nil, + override: true, + }, + } + + for _, tt := range translations { + + err := en.Add(tt.key, tt.trans, tt.override) + if err != tt.expected { + if !tt.expectedError { + t.Errorf("Expected '%s' Got '%s'", tt.expected, err) + } else { + if err.Error() != tt.expected.Error() { + t.Errorf("Expected '%s' Got '%s'", tt.expected.Error(), err.Error()) + } + } + } + } + + tests := []struct { + key interface{} + params []string + expected string + expectedError bool + }{ + { + key: "test_trans", + params: []string{"Joeybloggs", "The Test"}, + expected: "Welcome Joeybloggs to the The Test.", + }, + { + key: "test_trans2", + params: []string{"Joeybloggs", "The Test"}, + expected: "Joeybloggs to the The Test.", + }, + { + key: "test_trans3", + params: []string{"Joeybloggs", "The Test"}, + expected: "Welcome Joeybloggs to the The Test", + }, + { + key: "test_trans4", + params: []string{"Joeybloggs", "The Test"}, + expected: "JoeybloggsThe Test", + }, + // bad translation + { + key: "non-existant-key", + params: []string{"Joeybloggs", "The Test"}, + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + s, err := en.T(tt.key, tt.params...) + if s != tt.expected { + if !tt.expectedError && err != ErrUnknowTranslation { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } + } +} + +func TestCardinalTranslation(t *testing.T) { + + e := en.New() + uni := New(e, e) + en, found := uni.GetTranslator("en") + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + rule locales.PluralRule + expected error + expectedError bool + override bool + }{ + // bad translation + { + key: "cardinal_test", + trans: "You have a day left.", + rule: locales.PluralRuleOne, + expected: &ErrCardinalTranslation{text: fmt.Sprintf("error: parameter '%s' not found, may want to use 'Add' instead of 'AddCardinal'. locale: '%s' key: '%v' text: '%s'", paramZero, en.Locale(), "cardinal_test", "You have a day left.")}, + expectedError: true, + }, + // bad translation + { + key: "cardinal_test", + trans: "You have a day left few.", + rule: locales.PluralRuleFew, + expected: &ErrCardinalTranslation{text: fmt.Sprintf("error: cardinal plural rule '%s' does not exist for locale '%s' key: '%s' text: '%s'", locales.PluralRuleFew, en.Locale(), "cardinal_test", "You have a day left few.")}, + expectedError: true, + }, + { + key: "cardinal_test", + trans: "You have {0} day", + rule: locales.PluralRuleOne, + expected: nil, + }, + { + key: "cardinal_test", + trans: "You have {0} days left.", + rule: locales.PluralRuleOther, + expected: nil, + }, + { + key: "cardinal_test", + trans: "You have {0} days left.", + rule: locales.PluralRuleOther, + expected: &ErrConflictingTranslation{locale: en.Locale(), key: "cardinal_test", rule: locales.PluralRuleOther, text: "You have {0} days left."}, + expectedError: true, + }, + { + key: "cardinal_test", + trans: "You have {0} day left.", + rule: locales.PluralRuleOne, + expected: nil, + override: true, + }, + } + + for _, tt := range translations { + + err := en.AddCardinal(tt.key, tt.trans, tt.rule, tt.override) + if err != tt.expected { + if !tt.expectedError || err.Error() != tt.expected.Error() { + t.Errorf("Expected '' Got '%s'", err) + } + } + } + + tests := []struct { + key interface{} + num float64 + digits uint64 + param string + expected string + expectedError bool + }{ + { + key: "cardinal_test", + num: 1, + digits: 0, + param: string(en.FmtNumber(1, 0)), + expected: "You have 1 day left.", + }, + // bad translation key + { + key: "non-existant", + num: 1, + digits: 0, + param: string(en.FmtNumber(1, 0)), + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + + s, err := en.C(tt.key, tt.num, tt.digits, tt.param) + if err != nil { + if !tt.expectedError && err != ErrUnknowTranslation { + t.Errorf("Expected '' Got '%s'", err) + } + } + + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestOrdinalTranslation(t *testing.T) { + + e := en.New() + uni := New(e, e) + en, found := uni.GetTranslator("en") + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + rule locales.PluralRule + expected error + expectedError bool + override bool + }{ + // bad translation + { + key: "day", + trans: "st", + rule: locales.PluralRuleOne, + expected: &ErrOrdinalTranslation{text: fmt.Sprintf("error: parameter '%s' not found, may want to use 'Add' instead of 'AddOrdinal'. locale: '%s' key: '%v' text: '%s'", paramZero, en.Locale(), "day", "st")}, + expectedError: true, + }, + // bad translation + { + key: "day", + trans: "st", + rule: locales.PluralRuleMany, + expected: &ErrOrdinalTranslation{text: fmt.Sprintf("error: ordinal plural rule '%s' does not exist for locale '%s' key: '%s' text: '%s'", locales.PluralRuleMany, en.Locale(), "day", "st")}, + expectedError: true, + }, + { + key: "day", + trans: "{0}st", + rule: locales.PluralRuleOne, + expected: nil, + }, + { + key: "day", + trans: "{0}nd", + rule: locales.PluralRuleTwo, + expected: nil, + }, + { + key: "day", + trans: "{0}rd", + rule: locales.PluralRuleFew, + expected: nil, + }, + { + key: "day", + trans: "{0}th", + rule: locales.PluralRuleOther, + expected: nil, + }, + // bad translation + { + key: "day", + trans: "{0}th", + rule: locales.PluralRuleOther, + expected: &ErrConflictingTranslation{locale: en.Locale(), key: "day", rule: locales.PluralRuleOther, text: "{0}th"}, + expectedError: true, + }, + { + key: "day", + trans: "{0}st", + rule: locales.PluralRuleOne, + expected: nil, + override: true, + }, + } + + for _, tt := range translations { + + err := en.AddOrdinal(tt.key, tt.trans, tt.rule, tt.override) + if err != tt.expected { + if !tt.expectedError || err.Error() != tt.expected.Error() { + t.Errorf("Expected '' Got '%s'", err) + } + } + } + + tests := []struct { + key interface{} + num float64 + digits uint64 + param string + expected string + expectedError bool + }{ + { + key: "day", + num: 1, + digits: 0, + param: string(en.FmtNumber(1, 0)), + expected: "1st", + }, + { + key: "day", + num: 2, + digits: 0, + param: string(en.FmtNumber(2, 0)), + expected: "2nd", + }, + { + key: "day", + num: 3, + digits: 0, + param: string(en.FmtNumber(3, 0)), + expected: "3rd", + }, + { + key: "day", + num: 4, + digits: 0, + param: string(en.FmtNumber(4, 0)), + expected: "4th", + }, + { + key: "day", + num: 10258.43, + digits: 0, + param: string(en.FmtNumber(10258.43, 0)), + expected: "10,258th", + }, + // bad translation + { + key: "d-day", + num: 10258.43, + digits: 0, + param: string(en.FmtNumber(10258.43, 0)), + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + + s, err := en.O(tt.key, tt.num, tt.digits, tt.param) + if err != nil { + if !tt.expectedError && err != ErrUnknowTranslation { + t.Errorf("Expected '' Got '%s'", err) + } + } + + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestRangeTranslation(t *testing.T) { + + n := nl.New() + uni := New(n, n) + + // dutch + nl, found := uni.GetTranslator("nl") + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + rule locales.PluralRule + expected error + expectedError bool + override bool + }{ + // bad translation + { + key: "day", + trans: "er -{1} dag vertrokken", + rule: locales.PluralRuleOne, + expected: &ErrRangeTranslation{text: fmt.Sprintf("error: parameter '%s' not found, are you sure you're adding a Range Translation? locale: '%s' key: '%s' text: '%s'", paramZero, nl.Locale(), "day", "er -{1} dag vertrokken")}, + expectedError: true, + }, + // bad translation + { + key: "day", + trans: "er {0}- dag vertrokken", + rule: locales.PluralRuleMany, + expected: &ErrRangeTranslation{text: fmt.Sprintf("error: range plural rule '%s' does not exist for locale '%s' key: '%s' text: '%s'", locales.PluralRuleMany, nl.Locale(), "day", "er {0}- dag vertrokken")}, + expectedError: true, + }, + // bad translation + { + key: "day", + trans: "er {0}- dag vertrokken", + rule: locales.PluralRuleOne, + expected: &ErrRangeTranslation{text: fmt.Sprintf("error: parameter '%s' not found, a Range Translation requires two parameters. locale: '%s' key: '%s' text: '%s'", paramOne, nl.Locale(), "day", "er {0}- dag vertrokken")}, + expectedError: true, + }, + { + key: "day", + trans: "er {0}-{1} dag", + rule: locales.PluralRuleOne, + expected: nil, + }, + { + key: "day", + trans: "er zijn {0}-{1} dagen over", + rule: locales.PluralRuleOther, + expected: nil, + }, + // bad translation + { + key: "day", + trans: "er zijn {0}-{1} dagen over", + rule: locales.PluralRuleOther, + expected: &ErrConflictingTranslation{locale: nl.Locale(), key: "day", rule: locales.PluralRuleOther, text: "er zijn {0}-{1} dagen over"}, + expectedError: true, + }, + { + key: "day", + trans: "er {0}-{1} dag vertrokken", + rule: locales.PluralRuleOne, + expected: nil, + override: true, + }, + } + + for _, tt := range translations { + + err := nl.AddRange(tt.key, tt.trans, tt.rule, tt.override) + if err != tt.expected { + if !tt.expectedError || err.Error() != tt.expected.Error() { + t.Errorf("Expected '%#v' Got '%s'", tt.expected, err) + } + } + } + + tests := []struct { + key interface{} + num1 float64 + digits1 uint64 + num2 float64 + digits2 uint64 + param1 string + param2 string + expected string + expectedError bool + }{ + { + key: "day", + num1: 1, + digits1: 0, + num2: 2, + digits2: 0, + param1: string(nl.FmtNumber(1, 0)), + param2: string(nl.FmtNumber(2, 0)), + expected: "er zijn 1-2 dagen over", + }, + { + key: "day", + num1: 0, + digits1: 0, + num2: 1, + digits2: 0, + param1: string(nl.FmtNumber(0, 0)), + param2: string(nl.FmtNumber(1, 0)), + expected: "er 0-1 dag vertrokken", + }, + { + key: "day", + num1: 0, + digits1: 0, + num2: 2, + digits2: 0, + param1: string(nl.FmtNumber(0, 0)), + param2: string(nl.FmtNumber(2, 0)), + expected: "er zijn 0-2 dagen over", + }, + // bad translations from here + { + key: "d-day", + num1: 0, + digits1: 0, + num2: 2, + digits2: 0, + param1: string(nl.FmtNumber(0, 0)), + param2: string(nl.FmtNumber(2, 0)), + expected: "", + expectedError: true, + }, + } + + for _, tt := range tests { + + s, err := nl.R(tt.key, tt.num1, tt.digits1, tt.num2, tt.digits2, tt.param1, tt.param2) + if err != nil { + if !tt.expectedError && err != ErrUnknowTranslation { + t.Errorf("Expected '' Got '%s'", err) + } + } + + if s != tt.expected { + t.Errorf("Expected '%s' Got '%s'", tt.expected, s) + } + } +} + +func TestFallbackTranslator(t *testing.T) { + + e := en.New() + uni := New(e, e) + en, found := uni.GetTranslator("en") + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + if en.Locale() != "en" { + t.Errorf("Expected '%s' Got '%s'", "en", en.Locale()) + } + + fallback, _ := uni.GetTranslator("nl") + if fallback.Locale() != "en" { + t.Errorf("Expected '%s' Got '%s'", "en", fallback.Locale()) + } + + en, _ = uni.FindTranslator("nl", "en") + if en.Locale() != "en" { + t.Errorf("Expected '%s' Got '%s'", "en", en.Locale()) + } + + fallback, _ = uni.FindTranslator("nl") + if fallback.Locale() != "en" { + t.Errorf("Expected '%s' Got '%s'", "en", fallback.Locale()) + } +} + +func TestAddTranslator(t *testing.T) { + + e := en.New() + n := nl.New() + uni := New(e, n) + + tests := []struct { + trans locales.Translator + expected error + expectedError bool + override bool + }{ + { + trans: en_CA.New(), + expected: nil, + override: false, + }, + { + trans: n, + expected: &ErrExistingTranslator{locale: n.Locale()}, + expectedError: true, + override: false, + }, + { + trans: e, + expected: &ErrExistingTranslator{locale: e.Locale()}, + expectedError: true, + override: false, + }, + { + trans: e, + expected: nil, + override: true, + }, + } + + for _, tt := range tests { + + err := uni.AddTranslator(tt.trans, tt.override) + if err != tt.expected { + if !tt.expectedError || err.Error() != tt.expected.Error() { + t.Errorf("Expected '%s' Got '%s'", tt.expected, err) + } + } + } +} + +func TestVerifyTranslations(t *testing.T) { + + n := nl.New() + // dutch + uni := New(n, n) + + loc, _ := uni.GetTranslator("nl") + if loc.Locale() != "nl" { + t.Errorf("Expected '%s' Got '%s'", "nl", loc.Locale()) + } + + // cardinal checks + + err := loc.AddCardinal("day", "je {0} dag hebben verlaten", locales.PluralRuleOne, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + // fail cardinal rules + expected := &ErrMissingPluralTranslation{locale: loc.Locale(), translationType: "plural", rule: locales.PluralRuleOther, key: "day"} + err = loc.VerifyTranslations() + if err == nil || err.Error() != expected.Error() { + t.Errorf("Expected '%s' Got '%s'", expected, err) + } + + // success cardinal + err = loc.AddCardinal("day", "je {0} dagen hebben verlaten", locales.PluralRuleOther, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + err = loc.VerifyTranslations() + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + // range checks + err = loc.AddRange("day", "je {0}-{1} dagen hebben verlaten", locales.PluralRuleOther, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + // fail range rules + expected = &ErrMissingPluralTranslation{locale: loc.Locale(), translationType: "range", rule: locales.PluralRuleOne, key: "day"} + err = loc.VerifyTranslations() + if err == nil || err.Error() != expected.Error() { + t.Errorf("Expected '%s' Got '%s'", expected, err) + } + + // success range + err = loc.AddRange("day", "je {0}-{1} dag hebben verlaten", locales.PluralRuleOne, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + err = loc.VerifyTranslations() + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + // ok so 'nl' aka dutch, ony has one plural rule for ordinals, so going to switch to english from here which has 4 + + err = uni.AddTranslator(en.New(), false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + loc, _ = uni.GetTranslator("en") + if loc.Locale() != "en" { + t.Errorf("Expected '%s' Got '%s'", "en", loc.Locale()) + } + + // ordinal checks + + err = loc.AddOrdinal("day", "{0}st", locales.PluralRuleOne, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + err = loc.AddOrdinal("day", "{0}rd", locales.PluralRuleFew, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + err = loc.AddOrdinal("day", "{0}th", locales.PluralRuleOther, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + // fail ordinal rules + expected = &ErrMissingPluralTranslation{locale: loc.Locale(), translationType: "ordinal", rule: locales.PluralRuleTwo, key: "day"} + err = loc.VerifyTranslations() + if err == nil || err.Error() != expected.Error() { + t.Errorf("Expected '%s' Got '%s'", expected, err) + } + + // success ordinal + + err = loc.AddOrdinal("day", "{0}nd", locales.PluralRuleTwo, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + err = loc.VerifyTranslations() + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } +} + +func TestVerifyTranslationsWithNonStringKeys(t *testing.T) { + + n := nl.New() + // dutch + uni := New(n, n) + + loc, _ := uni.GetTranslator("nl") + if loc.Locale() != "nl" { + t.Errorf("Expected '%s' Got '%s'", "nl", loc.Locale()) + } + + // cardinal checks + + err := loc.AddCardinal(-1, "je {0} dag hebben verlaten", locales.PluralRuleOne, false) + if err != nil { + t.Fatalf("Expected '' Got '%s'", err) + } + + // fail cardinal rules + expected := &ErrMissingPluralTranslation{locale: loc.Locale(), translationType: "plural", rule: locales.PluralRuleOther, key: -1} + err = loc.VerifyTranslations() + if err == nil || err.Error() != expected.Error() { + t.Errorf("Expected '%s' Got '%s'", expected, err) + } +} + +func TestGetFallback(t *testing.T) { + + // dutch + n := nl.New() + e := en.New() + + uni := New(e, n) + + trans := uni.GetFallback() + + expected := "en" + + if trans.Locale() != expected { + t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale()) + } +} + +func TestVerifyUTTranslations(t *testing.T) { + + e := en.New() + uni := New(e, e) + en, found := uni.GetTranslator("en") + if !found { + t.Fatalf("Expected '%t' Got '%t'", true, found) + } + + translations := []struct { + key interface{} + trans string + rule locales.PluralRule + expected error + expectedError bool + override bool + }{ + { + key: "day", + trans: "{0}st", + rule: locales.PluralRuleOne, + expected: nil, + }, + { + key: "day", + trans: "{0}nd", + rule: locales.PluralRuleTwo, + expected: nil, + }, + { + key: "day", + trans: "{0}rd", + rule: locales.PluralRuleFew, + expected: nil, + }, + // intentionally leaving out plural other + // { + // key: "day", + // trans: "{0}th", + // rule: locales.PluralRuleOther, + // expected: nil, + // }, + } + + for _, tt := range translations { + + err := en.AddOrdinal(tt.key, tt.trans, tt.rule, tt.override) + if err != tt.expected { + if !tt.expectedError || err.Error() != tt.expected.Error() { + t.Errorf("Expected '' Got '%s'", err) + } + } + } + + expected := "error: missing 'ordinal' plural rule 'Other' for translation with key 'day' and locale 'en'" + err := uni.VerifyTranslations() + if err == nil || err.Error() != expected { + t.Fatalf("Expected '%s' Got '%s'", expected, err) + } + + err = en.AddOrdinal("day", "{0}th", locales.PluralRuleOther, false) + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } + + err = uni.VerifyTranslations() + if err != nil { + t.Fatalf("Expected '%v' Got '%s'", nil, err) + } +} diff --git a/vendor/github.com/go-playground/universal-translator/universal_translator.go b/vendor/github.com/go-playground/universal-translator/universal_translator.go new file mode 100644 index 0000000000..dbf707f5c7 --- /dev/null +++ b/vendor/github.com/go-playground/universal-translator/universal_translator.go @@ -0,0 +1,113 @@ +package ut + +import ( + "strings" + + "github.com/go-playground/locales" +) + +// UniversalTranslator holds all locale & translation data +type UniversalTranslator struct { + translators map[string]Translator + fallback Translator +} + +// New returns a new UniversalTranslator instance set with +// the fallback locale and locales it should support +func New(fallback locales.Translator, supportedLocales ...locales.Translator) *UniversalTranslator { + + t := &UniversalTranslator{ + translators: make(map[string]Translator), + } + + for _, v := range supportedLocales { + + trans := newTranslator(v) + t.translators[strings.ToLower(trans.Locale())] = trans + + if fallback.Locale() == v.Locale() { + t.fallback = trans + } + } + + if t.fallback == nil && fallback != nil { + t.fallback = newTranslator(fallback) + } + + return t +} + +// FindTranslator trys to find a Translator based on an array of locales +// and returns the first one it can find, otherwise returns the +// fallback translator. +func (t *UniversalTranslator) FindTranslator(locales ...string) (trans Translator, found bool) { + + for _, locale := range locales { + + if trans, found = t.translators[strings.ToLower(locale)]; found { + return + } + } + + return t.fallback, false +} + +// GetTranslator returns the specified translator for the given locale, +// or fallback if not found +func (t *UniversalTranslator) GetTranslator(locale string) (trans Translator, found bool) { + + if trans, found = t.translators[strings.ToLower(locale)]; found { + return + } + + return t.fallback, false +} + +// GetFallback returns the fallback locale +func (t *UniversalTranslator) GetFallback() Translator { + return t.fallback +} + +// AddTranslator adds the supplied translator, if it already exists the override param +// will be checked and if false an error will be returned, otherwise the translator will be +// overridden; if the fallback matches the supplied translator it will be overridden as well +// NOTE: this is normally only used when translator is embedded within a library +func (t *UniversalTranslator) AddTranslator(translator locales.Translator, override bool) error { + + lc := strings.ToLower(translator.Locale()) + _, ok := t.translators[lc] + if ok && !override { + return &ErrExistingTranslator{locale: translator.Locale()} + } + + trans := newTranslator(translator) + + if t.fallback.Locale() == translator.Locale() { + + // because it's optional to have a fallback, I don't impose that limitation + // don't know why you wouldn't but... + if !override { + return &ErrExistingTranslator{locale: translator.Locale()} + } + + t.fallback = trans + } + + t.translators[lc] = trans + + return nil +} + +// VerifyTranslations runs through all locales and identifies any issues +// eg. missing plural rules for a locale +func (t *UniversalTranslator) VerifyTranslations() (err error) { + + for _, trans := range t.translators { + err = trans.VerifyTranslations() + if err != nil { + return + } + } + + return +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/.github/CONTRIBUTING.md b/vendor/gopkg.in/go-playground/validator.v9/.github/CONTRIBUTING.md new file mode 100644 index 0000000000..b8cf8b6815 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/.github/CONTRIBUTING.md @@ -0,0 +1,9 @@ +# Contribution Guidelines + +## Quality Standard + +To ensure the continued stability of this package tests are required to be written or already exist in order for a pull request to be merged. + +## Reporting issues + +Please open an issue or join the gitter chat [![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) for any issues, questions or possible enhancements to the package. diff --git a/vendor/gopkg.in/go-playground/validator.v9/.github/ISSUE_TEMPLATE.md b/vendor/gopkg.in/go-playground/validator.v9/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..8afb259129 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,13 @@ +### Package version eg. v8, v9: + + + +### Issue, Question or Enhancement: + + + +### Code sample, to showcase or reproduce: + +```go + +``` diff --git a/vendor/gopkg.in/go-playground/validator.v9/.github/PULL_REQUEST_TEMPLATE.md b/vendor/gopkg.in/go-playground/validator.v9/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..7bebde392e --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,13 @@ +Fixes Or Enhances # . + +**Make sure that you've checked the boxes below before you submit PR:** +- [ ] Tests exist or have been written that cover this particular change. + +Change Details: + +- +- +- + + +@go-playground/admins \ No newline at end of file diff --git a/vendor/gopkg.in/go-playground/validator.v9/.gitignore b/vendor/gopkg.in/go-playground/validator.v9/.gitignore new file mode 100644 index 0000000000..792ca00d28 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/.gitignore @@ -0,0 +1,29 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof +*.test +*.out +*.txt +cover.html +README.html \ No newline at end of file diff --git a/vendor/gopkg.in/go-playground/validator.v9/LICENSE b/vendor/gopkg.in/go-playground/validator.v9/LICENSE new file mode 100644 index 0000000000..6a2ae9aa4d --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Dean Karn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/vendor/gopkg.in/go-playground/validator.v9/README.md b/vendor/gopkg.in/go-playground/validator.v9/README.md new file mode 100644 index 0000000000..f5869664b3 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/README.md @@ -0,0 +1,139 @@ +Package validator +================ +[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +![Project status](https://img.shields.io/badge/version-9.4.0-green.svg) +[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/validator/branches/v9/badge.svg)](https://semaphoreci.com/joeybloggs/validator) +[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=v9&service=github)](https://coveralls.io/github/go-playground/validator?branch=v9) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator) +[![GoDoc](https://godoc.org/gopkg.in/go-playground/validator.v9?status.svg)](https://godoc.org/gopkg.in/go-playground/validator.v9) +![License](https://img.shields.io/dub/l/vibe-d.svg) + +Package validator implements value validations for structs and individual fields based on tags. + +It has the following **unique** features: + +- Cross Field and Cross Struct validations by using validation tags or custom validators. +- Slice, Array and Map diving, which allows any or all levels of a multidimensional field to be validated. +- Handles type interface by determining it's underlying type prior to validation. +- Handles custom field types such as sql driver Valuer see [Valuer](https://golang.org/src/database/sql/driver/types.go?s=1210:1293#L29) +- Alias validation tags, which allows for mapping of several validations to a single tag for easier defining of validations on structs +- Extraction of custom defined Field Name e.g. can specify to extract the JSON name while validating and have it available in the resulting FieldError +- Customizable i18n aware error messages. +- Default validator for the [gin](https://github.com/gin-gonic/gin) web framework; upgrading from v8 to v9 in gin see [here](https://github.com/go-playground/validator/tree/v9/_examples/gin-upgrading-overriding) + +Installation +------------ + +Use go get. + + go get gopkg.in/go-playground/validator.v9 + +Then import the validator package into your own code. + + import "gopkg.in/go-playground/validator.v9" + +Error Return Value +------- + +Validation functions return type error + +They return type error to avoid the issue discussed in the following, where err is always != nil: + +* http://stackoverflow.com/a/29138676/3158232 +* https://github.com/go-playground/validator/issues/134 + +Validator only InvalidValidationError for bad validation input, nil or ValidationErrors as type error; so, in your code all you need to do is check if the error returned is not nil, and if it's not check if error is InvalidValidationError ( if necessary, most of the time it isn't ) type cast it to type ValidationErrors like so: + +```go +err := validate.Struct(mystruct) +validationErrors := err.(validator.ValidationErrors) + ``` + +Usage and documentation +------ + +Please see http://godoc.org/gopkg.in/go-playground/validator.v9 for detailed usage docs. + +##### Examples: + +- [Simple](https://github.com/go-playground/validator/blob/v9/_examples/simple/main.go) +- [Custom Field Types](https://github.com/go-playground/validator/blob/v9/_examples/custom/main.go) +- [Struct Level](https://github.com/go-playground/validator/blob/v9/_examples/struct-level/main.go) +- [Translations & Custom Errors](https://github.com/go-playground/validator/blob/v9/_examples/translations/main.go) +- [Gin upgrade and/or override validator](https://github.com/go-playground/validator/tree/v9/_examples/gin-upgrading-overriding) +- [wash - an example application putting it all together](https://github.com/bluesuncorp/wash) + +Benchmarks +------ +###### Run on i5-7600 16 GB DDR4-2400 using Go version go1.8 linux/amd64 +```go +BenchmarkFieldSuccess-4 20000000 74.3 ns/op 0 B/op 0 allocs/op +BenchmarkFieldSuccessParallel-4 50000000 31.5 ns/op 0 B/op 0 allocs/op +BenchmarkFieldFailure-4 3000000 556 ns/op 208 B/op 4 allocs/op +BenchmarkFieldFailureParallel-4 20000000 88.7 ns/op 208 B/op 4 allocs/op +BenchmarkFieldDiveSuccess-4 2000000 630 ns/op 201 B/op 11 allocs/op +BenchmarkFieldDiveSuccessParallel-4 10000000 173 ns/op 201 B/op 11 allocs/op +BenchmarkFieldDiveFailure-4 1000000 1350 ns/op 412 B/op 16 allocs/op +BenchmarkFieldDiveFailureParallel-4 5000000 250 ns/op 412 B/op 16 allocs/op +BenchmarkFieldCustomTypeSuccess-4 10000000 202 ns/op 32 B/op 2 allocs/op +BenchmarkFieldCustomTypeSuccessParallel-4 20000000 63.5 ns/op 32 B/op 2 allocs/op +BenchmarkFieldCustomTypeFailure-4 5000000 568 ns/op 208 B/op 4 allocs/op +BenchmarkFieldCustomTypeFailureParallel-4 20000000 87.5 ns/op 208 B/op 4 allocs/op +BenchmarkFieldOrTagSuccess-4 2000000 703 ns/op 16 B/op 1 allocs/op +BenchmarkFieldOrTagSuccessParallel-4 3000000 447 ns/op 16 B/op 1 allocs/op +BenchmarkFieldOrTagFailure-4 3000000 604 ns/op 224 B/op 5 allocs/op +BenchmarkFieldOrTagFailureParallel-4 5000000 353 ns/op 224 B/op 5 allocs/op +BenchmarkStructLevelValidationSuccess-4 10000000 190 ns/op 32 B/op 2 allocs/op +BenchmarkStructLevelValidationSuccessParallel-4 30000000 59.9 ns/op 32 B/op 2 allocs/op +BenchmarkStructLevelValidationFailure-4 2000000 705 ns/op 304 B/op 8 allocs/op +BenchmarkStructLevelValidationFailureParallel-4 10000000 146 ns/op 304 B/op 8 allocs/op +BenchmarkStructSimpleCustomTypeSuccess-4 5000000 361 ns/op 32 B/op 2 allocs/op +BenchmarkStructSimpleCustomTypeSuccessParallel-4 20000000 101 ns/op 32 B/op 2 allocs/op +BenchmarkStructSimpleCustomTypeFailure-4 1000000 1210 ns/op 424 B/op 9 allocs/op +BenchmarkStructSimpleCustomTypeFailureParallel-4 10000000 196 ns/op 440 B/op 10 allocs/op +BenchmarkStructFilteredSuccess-4 2000000 757 ns/op 288 B/op 9 allocs/op +BenchmarkStructFilteredSuccessParallel-4 10000000 167 ns/op 288 B/op 9 allocs/op +BenchmarkStructFilteredFailure-4 3000000 619 ns/op 256 B/op 7 allocs/op +BenchmarkStructFilteredFailureParallel-4 10000000 134 ns/op 256 B/op 7 allocs/op +BenchmarkStructPartialSuccess-4 2000000 687 ns/op 256 B/op 6 allocs/op +BenchmarkStructPartialSuccessParallel-4 10000000 159 ns/op 256 B/op 6 allocs/op +BenchmarkStructPartialFailure-4 1000000 1281 ns/op 480 B/op 11 allocs/op +BenchmarkStructPartialFailureParallel-4 10000000 218 ns/op 480 B/op 11 allocs/op +BenchmarkStructExceptSuccess-4 1000000 1041 ns/op 496 B/op 12 allocs/op +BenchmarkStructExceptSuccessParallel-4 10000000 140 ns/op 240 B/op 5 allocs/op +BenchmarkStructExceptFailure-4 1000000 1014 ns/op 464 B/op 10 allocs/op +BenchmarkStructExceptFailureParallel-4 10000000 201 ns/op 464 B/op 10 allocs/op +BenchmarkStructSimpleCrossFieldSuccess-4 5000000 364 ns/op 72 B/op 3 allocs/op +BenchmarkStructSimpleCrossFieldSuccessParallel-4 20000000 103 ns/op 72 B/op 3 allocs/op +BenchmarkStructSimpleCrossFieldFailure-4 2000000 789 ns/op 304 B/op 8 allocs/op +BenchmarkStructSimpleCrossFieldFailureParallel-4 10000000 174 ns/op 304 B/op 8 allocs/op +BenchmarkStructSimpleCrossStructCrossFieldSuccess-4 3000000 522 ns/op 80 B/op 4 allocs/op +BenchmarkStructSimpleCrossStructCrossFieldSuccessParallel-4 10000000 146 ns/op 80 B/op 4 allocs/op +BenchmarkStructSimpleCrossStructCrossFieldFailure-4 2000000 879 ns/op 320 B/op 9 allocs/op +BenchmarkStructSimpleCrossStructCrossFieldFailureParallel-4 10000000 225 ns/op 320 B/op 9 allocs/op +BenchmarkStructSimpleSuccess-4 10000000 223 ns/op 0 B/op 0 allocs/op +BenchmarkStructSimpleSuccessParallel-4 20000000 63.3 ns/op 0 B/op 0 allocs/op +BenchmarkStructSimpleFailure-4 2000000 1097 ns/op 424 B/op 9 allocs/op +BenchmarkStructSimpleFailureParallel-4 10000000 182 ns/op 424 B/op 9 allocs/op +BenchmarkStructComplexSuccess-4 1000000 1362 ns/op 128 B/op 8 allocs/op +BenchmarkStructComplexSuccessParallel-4 5000000 359 ns/op 128 B/op 8 allocs/op +BenchmarkStructComplexFailure-4 300000 6446 ns/op 3040 B/op 53 allocs/op +BenchmarkStructComplexFailureParallel-4 1000000 1203 ns/op 3040 B/op 53 allocs/op +``` + +Complementary Software +---------------------- + +Here is a list of software that complements using this library either pre or post validation. + +* [form](https://github.com/go-playground/form) - Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support. +* [Conform](https://github.com/leebenson/conform) - Trims, sanitizes & scrubs data based on struct tags. + +How to Contribute +------ + +Make a pull request... + +License +------ +Distributed under MIT License, please see license file within the code for more details. diff --git a/vendor/gopkg.in/go-playground/validator.v9/_examples/custom/main.go b/vendor/gopkg.in/go-playground/validator.v9/_examples/custom/main.go new file mode 100644 index 0000000000..724f57aa4f --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/_examples/custom/main.go @@ -0,0 +1,51 @@ +package main + +import ( + "database/sql" + "database/sql/driver" + "fmt" + "reflect" + + "gopkg.in/go-playground/validator.v9" +) + +// DbBackedUser User struct +type DbBackedUser struct { + Name sql.NullString `validate:"required"` + Age sql.NullInt64 `validate:"required"` +} + +// use a single instance of Validate, it caches struct info +var validate *validator.Validate + +func main() { + + validate = validator.New() + + // register all sql.Null* types to use the ValidateValuer CustomTypeFunc + validate.RegisterCustomTypeFunc(ValidateValuer, sql.NullString{}, sql.NullInt64{}, sql.NullBool{}, sql.NullFloat64{}) + + // build object for validation + x := DbBackedUser{Name: sql.NullString{String: "", Valid: true}, Age: sql.NullInt64{Int64: 0, Valid: false}} + + err := validate.Struct(x) + + if err != nil { + fmt.Printf("Err(s):\n%+v\n", err) + } +} + +// ValidateValuer implements validator.CustomTypeFunc +func ValidateValuer(field reflect.Value) interface{} { + + if valuer, ok := field.Interface().(driver.Valuer); ok { + + val, err := valuer.Value() + if err == nil { + return val + } + // handle the error how you want + } + + return nil +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/_examples/gin-upgrading-overriding/main.go b/vendor/gopkg.in/go-playground/validator.v9/_examples/gin-upgrading-overriding/main.go new file mode 100644 index 0000000000..46fdf2adc4 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/_examples/gin-upgrading-overriding/main.go @@ -0,0 +1,10 @@ +package main + +import "github.com/gin-gonic/gin/binding" + +func main() { + + binding.Validator = new(defaultValidator) + + // regular gin logic +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/_examples/gin-upgrading-overriding/v8_to_v9.go b/vendor/gopkg.in/go-playground/validator.v9/_examples/gin-upgrading-overriding/v8_to_v9.go new file mode 100644 index 0000000000..272b670c9c --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/_examples/gin-upgrading-overriding/v8_to_v9.go @@ -0,0 +1,50 @@ +package main + +import ( + "reflect" + "sync" + + "github.com/gin-gonic/gin/binding" + "gopkg.in/go-playground/validator.v9" +) + +type defaultValidator struct { + once sync.Once + validate *validator.Validate +} + +var _ binding.StructValidator = &defaultValidator{} + +func (v *defaultValidator) ValidateStruct(obj interface{}) error { + + if kindOfData(obj) == reflect.Struct { + + v.lazyinit() + + if err := v.validate.Struct(obj); err != nil { + return error(err) + } + } + + return nil +} + +func (v *defaultValidator) lazyinit() { + v.once.Do(func() { + v.validate = validator.New() + v.validate.SetTagName("binding") + + // add any custom validations etc. here + }) +} + +func kindOfData(data interface{}) reflect.Kind { + + value := reflect.ValueOf(data) + valueType := value.Kind() + + if valueType == reflect.Ptr { + valueType = value.Elem().Kind() + } + return valueType +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/_examples/simple/main.go b/vendor/gopkg.in/go-playground/validator.v9/_examples/simple/main.go new file mode 100644 index 0000000000..9e3d106486 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/_examples/simple/main.go @@ -0,0 +1,101 @@ +package main + +import ( + "fmt" + + "gopkg.in/go-playground/validator.v9" +) + +// User contains user information +type User struct { + FirstName string `validate:"required"` + LastName string `validate:"required"` + Age uint8 `validate:"gte=0,lte=130"` + Email string `validate:"required,email"` + FavouriteColor string `validate:"iscolor"` // alias for 'hexcolor|rgb|rgba|hsl|hsla' + Addresses []*Address `validate:"required,dive,required"` // a person can have a home and cottage... +} + +// Address houses a users address information +type Address struct { + Street string `validate:"required"` + City string `validate:"required"` + Planet string `validate:"required"` + Phone string `validate:"required"` +} + +// use a single instance of Validate, it caches struct info +var validate *validator.Validate + +func main() { + + validate = validator.New() + + validateStruct() + validateVariable() +} + +func validateStruct() { + + address := &Address{ + Street: "Eavesdown Docks", + Planet: "Persphone", + Phone: "none", + } + + user := &User{ + FirstName: "Badger", + LastName: "Smith", + Age: 135, + Email: "Badger.Smith@gmail.com", + FavouriteColor: "#000-", + Addresses: []*Address{address}, + } + + // returns nil or ValidationErrors ( map[string]*FieldError ) + err := validate.Struct(user) + if err != nil { + + // this check is only needed when your code could produce + // an invalid value for validation such as interface with nil + // value most including myself do not usually have code like this. + if _, ok := err.(*validator.InvalidValidationError); ok { + fmt.Println(err) + return + } + + for _, err := range err.(validator.ValidationErrors) { + + fmt.Println(err.Namespace()) + fmt.Println(err.Field()) + fmt.Println(err.StructNamespace()) // can differ when a custom TagNameFunc is registered or + fmt.Println(err.StructField()) // by passing alt name to ReportError like below + fmt.Println(err.Tag()) + fmt.Println(err.ActualTag()) + fmt.Println(err.Kind()) + fmt.Println(err.Type()) + fmt.Println(err.Value()) + fmt.Println(err.Param()) + fmt.Println() + } + + // from here you can create your own error messages in whatever language you wish + return + } + + // save user to database +} + +func validateVariable() { + + myEmail := "joeybloggs.gmail.com" + + errs := validate.Var(myEmail, "required,email") + + if errs != nil { + fmt.Println(errs) // output: Key: "" Error:Field validation for "" failed on the "email" tag + return + } + + // email ok, move on +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/_examples/struct-level/main.go b/vendor/gopkg.in/go-playground/validator.v9/_examples/struct-level/main.go new file mode 100644 index 0000000000..87742fc898 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/_examples/struct-level/main.go @@ -0,0 +1,109 @@ +package main + +import ( + "fmt" + + "gopkg.in/go-playground/validator.v9" +) + +// User contains user information +type User struct { + FirstName string `json:"fname"` + LastName string `json:"lname"` + Age uint8 `validate:"gte=0,lte=130"` + Email string `validate:"required,email"` + FavouriteColor string `validate:"hexcolor|rgb|rgba"` + Addresses []*Address `validate:"required,dive,required"` // a person can have a home and cottage... +} + +// Address houses a users address information +type Address struct { + Street string `validate:"required"` + City string `validate:"required"` + Planet string `validate:"required"` + Phone string `validate:"required"` +} + +// use a single instance of Validate, it caches struct info +var validate *validator.Validate + +func main() { + + validate = validator.New() + + // register validation for 'User' + // NOTE: only have to register a non-pointer type for 'User', validator + // interanlly dereferences during it's type checks. + validate.RegisterStructValidation(UserStructLevelValidation, User{}) + + // build 'User' info, normally posted data etc... + address := &Address{ + Street: "Eavesdown Docks", + Planet: "Persphone", + Phone: "none", + City: "Unknown", + } + + user := &User{ + FirstName: "", + LastName: "", + Age: 45, + Email: "Badger.Smith@gmail.com", + FavouriteColor: "#000", + Addresses: []*Address{address}, + } + + // returns InvalidValidationError for bad validation input, nil or ValidationErrors ( []FieldError ) + err := validate.Struct(user) + if err != nil { + + // this check is only needed when your code could produce + // an invalid value for validation such as interface with nil + // value most including myself do not usually have code like this. + if _, ok := err.(*validator.InvalidValidationError); ok { + fmt.Println(err) + return + } + + for _, err := range err.(validator.ValidationErrors) { + + fmt.Println(err.Namespace()) + fmt.Println(err.Field()) + fmt.Println(err.StructNamespace()) // can differ when a custom TagNameFunc is registered or + fmt.Println(err.StructField()) // by passing alt name to ReportError like below + fmt.Println(err.Tag()) + fmt.Println(err.ActualTag()) + fmt.Println(err.Kind()) + fmt.Println(err.Type()) + fmt.Println(err.Value()) + fmt.Println(err.Param()) + fmt.Println() + } + + // from here you can create your own error messages in whatever language you wish + return + } + + // save user to database +} + +// UserStructLevelValidation contains custom struct level validations that don't always +// make sense at the field validation level. For Example this function validates that either +// FirstName or LastName exist; could have done that with a custom field validation but then +// would have had to add it to both fields duplicating the logic + overhead, this way it's +// only validated once. +// +// NOTE: you may ask why wouldn't I just do this outside of validator, because doing this way +// hooks right into validator and you can combine with validation tags and still have a +// common error output format. +func UserStructLevelValidation(sl validator.StructLevel) { + + user := sl.Current().Interface().(User) + + if len(user.FirstName) == 0 && len(user.LastName) == 0 { + sl.ReportError(user.FirstName, "FirstName", "fname", "fnameorlname", "") + sl.ReportError(user.LastName, "LastName", "lname", "fnameorlname", "") + } + + // plus can to more, even with different tag than "fnameorlname" +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/_examples/translations/main.go b/vendor/gopkg.in/go-playground/validator.v9/_examples/translations/main.go new file mode 100644 index 0000000000..0c298e431f --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/_examples/translations/main.go @@ -0,0 +1,129 @@ +package main + +import ( + "fmt" + + "github.com/go-playground/locales/en" + ut "github.com/go-playground/universal-translator" + "gopkg.in/go-playground/validator.v9" + en_translations "gopkg.in/go-playground/validator.v9/translations/en" +) + +// User contains user information +type User struct { + FirstName string `validate:"required"` + LastName string `validate:"required"` + Age uint8 `validate:"gte=0,lte=130"` + Email string `validate:"required,email"` + FavouriteColor string `validate:"iscolor"` // alias for 'hexcolor|rgb|rgba|hsl|hsla' + Addresses []*Address `validate:"required,dive,required"` // a person can have a home and cottage... +} + +// Address houses a users address information +type Address struct { + Street string `validate:"required"` + City string `validate:"required"` + Planet string `validate:"required"` + Phone string `validate:"required"` +} + +// use a single instance , it caches struct info +var ( + uni *ut.UniversalTranslator + validate *validator.Validate +) + +func main() { + + // NOTE: ommitting allot of error checking for brevity + + en := en.New() + uni = ut.New(en, en) + + // this is usually know or extracted from http 'Accept-Language' header + // also see uni.FindTranslator(...) + trans, _ := uni.GetTranslator("en") + + validate = validator.New() + en_translations.RegisterDefaultTranslations(validate, trans) + + translateAll(trans) + translateIndividual(trans) + translateOverride(trans) // yep you can specify your own in whatever locale you want! +} + +func translateAll(trans ut.Translator) { + + type User struct { + Username string `validate:"required"` + Tagline string `validate:"required,lt=10"` + Tagline2 string `validate:"required,gt=1"` + } + + user := User{ + Username: "Joeybloggs", + Tagline: "This tagline is way too long.", + Tagline2: "1", + } + + err := validate.Struct(user) + if err != nil { + + // translate all error at once + errs := err.(validator.ValidationErrors) + + // returns a map with key = namespace & value = translated error + // NOTICE: 2 errors are returned and you'll see something surprising + // translations are i18n aware!!!! + // eg. '10 characters' vs '1 character' + fmt.Println(errs.Translate(trans)) + } +} + +func translateIndividual(trans ut.Translator) { + + type User struct { + Username string `validate:"required"` + } + + var user User + + err := validate.Struct(user) + if err != nil { + + errs := err.(validator.ValidationErrors) + + for _, e := range errs { + // can translate each error one at a time. + fmt.Println(e.Translate(trans)) + } + } +} + +func translateOverride(trans ut.Translator) { + + validate.RegisterTranslation("required", trans, func(ut ut.Translator) error { + return ut.Add("required", "{0} must have a value!", true) // see universal-translator for details + }, func(ut ut.Translator, fe validator.FieldError) string { + t, _ := ut.T("required", fe.Field()) + + return t + }) + + type User struct { + Username string `validate:"required"` + } + + var user User + + err := validate.Struct(user) + if err != nil { + + errs := err.(validator.ValidationErrors) + + for _, e := range errs { + // can translate each error one at a time. + fmt.Println(e.Translate(trans)) + } + } +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/baked_in.go b/vendor/gopkg.in/go-playground/validator.v9/baked_in.go new file mode 100644 index 0000000000..9e0b173c8a --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/baked_in.go @@ -0,0 +1,1469 @@ +package validator + +import ( + "fmt" + "net" + "net/url" + "reflect" + "strings" + "time" + "unicode/utf8" +) + +// Func accepts all values needed for file and cross field validation +// fl = FieldLevel validation helper +// field = field value for validation +// fieldType = fields +// param = parameter used in validation i.e. gt=0 param would be 0 +type Func func(fl FieldLevel) bool + +var ( + restrictedTags = map[string]struct{}{ + diveTag: {}, + structOnlyTag: {}, + omitempty: {}, + skipValidationTag: {}, + utf8HexComma: {}, + utf8Pipe: {}, + noStructLevelTag: {}, + requiredTag: {}, + } + + // BakedInAliasValidators is a default mapping of a single validation tag that + // defines a common or complex set of validation(s) to simplify + // adding validation to structs. + bakedInAliases = map[string]string{ + "iscolor": "hexcolor|rgb|rgba|hsl|hsla", + } + + // BakedInValidators is the default map of ValidationFunc + // you can add, remove or even replace items to suite your needs, + // or even disregard and use your own map if so desired. + bakedInValidators = map[string]Func{ + "required": hasValue, + "len": hasLengthOf, + "min": hasMinOf, + "max": hasMaxOf, + "eq": isEq, + "ne": isNe, + "lt": isLt, + "lte": isLte, + "gt": isGt, + "gte": isGte, + "eqfield": isEqField, + "eqcsfield": isEqCrossStructField, + "necsfield": isNeCrossStructField, + "gtcsfield": isGtCrossStructField, + "gtecsfield": isGteCrossStructField, + "ltcsfield": isLtCrossStructField, + "ltecsfield": isLteCrossStructField, + "nefield": isNeField, + "gtefield": isGteField, + "gtfield": isGtField, + "ltefield": isLteField, + "ltfield": isLtField, + "alpha": isAlpha, + "alphanum": isAlphanum, + "alphaunicode": isAlphaUnicode, + "alphanumunicode": isAlphanumUnicode, + "numeric": isNumeric, + "number": isNumber, + "hexadecimal": isHexadecimal, + "hexcolor": isHEXColor, + "rgb": isRGB, + "rgba": isRGBA, + "hsl": isHSL, + "hsla": isHSLA, + "email": isEmail, + "url": isURL, + "uri": isURI, + "base64": isBase64, + "contains": contains, + "containsany": containsAny, + "containsrune": containsRune, + "excludes": excludes, + "excludesall": excludesAll, + "excludesrune": excludesRune, + "isbn": isISBN, + "isbn10": isISBN10, + "isbn13": isISBN13, + "uuid": isUUID, + "uuid3": isUUID3, + "uuid4": isUUID4, + "uuid5": isUUID5, + "ascii": isASCII, + "printascii": isPrintableASCII, + "multibyte": hasMultiByteCharacter, + "datauri": isDataURI, + "latitude": isLatitude, + "longitude": isLongitude, + "ssn": isSSN, + "ipv4": isIPv4, + "ipv6": isIPv6, + "ip": isIP, + "cidrv4": isCIDRv4, + "cidrv6": isCIDRv6, + "cidr": isCIDR, + "tcp4_addr": isTCP4AddrResolvable, + "tcp6_addr": isTCP6AddrResolvable, + "tcp_addr": isTCPAddrResolvable, + "udp4_addr": isUDP4AddrResolvable, + "udp6_addr": isUDP6AddrResolvable, + "udp_addr": isUDPAddrResolvable, + "ip4_addr": isIP4AddrResolvable, + "ip6_addr": isIP6AddrResolvable, + "ip_addr": isIPAddrResolvable, + "unix_addr": isUnixAddrResolvable, + "mac": isMAC, + } +) + +// IsMAC is the validation function for validating if the field's value is a valid MAC address. +func isMAC(fl FieldLevel) bool { + + _, err := net.ParseMAC(fl.Field().String()) + + return err == nil +} + +// IsCIDRv4 is the validation function for validating if the field's value is a valid v4 CIDR address. +func isCIDRv4(fl FieldLevel) bool { + + ip, _, err := net.ParseCIDR(fl.Field().String()) + + return err == nil && ip.To4() != nil +} + +// IsCIDRv6 is the validation function for validating if the field's value is a valid v6 CIDR address. +func isCIDRv6(fl FieldLevel) bool { + + ip, _, err := net.ParseCIDR(fl.Field().String()) + + return err == nil && ip.To4() == nil +} + +// IsCIDR is the validation function for validating if the field's value is a valid v4 or v6 CIDR address. +func isCIDR(fl FieldLevel) bool { + + _, _, err := net.ParseCIDR(fl.Field().String()) + + return err == nil +} + +// IsIPv4 is the validation function for validating if a value is a valid v4 IP address. +func isIPv4(fl FieldLevel) bool { + + ip := net.ParseIP(fl.Field().String()) + + return ip != nil && ip.To4() != nil +} + +// IsIPv6 is the validation function for validating if the field's value is a valid v6 IP address. +func isIPv6(fl FieldLevel) bool { + + ip := net.ParseIP(fl.Field().String()) + + return ip != nil && ip.To4() == nil +} + +// IsIP is the validation function for validating if the field's value is a valid v4 or v6 IP address. +func isIP(fl FieldLevel) bool { + + ip := net.ParseIP(fl.Field().String()) + + return ip != nil +} + +// IsSSN is the validation function for validating if the field's value is a valid SSN. +func isSSN(fl FieldLevel) bool { + + field := fl.Field() + + if field.Len() != 11 { + return false + } + + return sSNRegex.MatchString(field.String()) +} + +// IsLongitude is the validation function for validating if the field's value is a valid longitude coordinate. +func isLongitude(fl FieldLevel) bool { + return longitudeRegex.MatchString(fl.Field().String()) +} + +// IsLatitude is the validation function for validating if the field's value is a valid latitude coordinate. +func isLatitude(fl FieldLevel) bool { + return latitudeRegex.MatchString(fl.Field().String()) +} + +// IsDataURI is the validation function for validating if the field's value is a valid data URI. +func isDataURI(fl FieldLevel) bool { + + uri := strings.SplitN(fl.Field().String(), ",", 2) + + if len(uri) != 2 { + return false + } + + if !dataURIRegex.MatchString(uri[0]) { + return false + } + + return base64Regex.MatchString(uri[1]) +} + +// HasMultiByteCharacter is the validation function for validating if the field's value has a multi byte character. +func hasMultiByteCharacter(fl FieldLevel) bool { + + field := fl.Field() + + if field.Len() == 0 { + return true + } + + return multibyteRegex.MatchString(field.String()) +} + +// IsPrintableASCII is the validation function for validating if the field's value is a valid printable ASCII character. +func isPrintableASCII(fl FieldLevel) bool { + return printableASCIIRegex.MatchString(fl.Field().String()) +} + +// IsASCII is the validation function for validating if the field's value is a valid ASCII character. +func isASCII(fl FieldLevel) bool { + return aSCIIRegex.MatchString(fl.Field().String()) +} + +// IsUUID5 is the validation function for validating if the field's value is a valid v5 UUID. +func isUUID5(fl FieldLevel) bool { + return uUID5Regex.MatchString(fl.Field().String()) +} + +// IsUUID4 is the validation function for validating if the field's value is a valid v4 UUID. +func isUUID4(fl FieldLevel) bool { + return uUID4Regex.MatchString(fl.Field().String()) +} + +// IsUUID3 is the validation function for validating if the field's value is a valid v3 UUID. +func isUUID3(fl FieldLevel) bool { + return uUID3Regex.MatchString(fl.Field().String()) +} + +// IsUUID is the validation function for validating if the field's value is a valid UUID of any version. +func isUUID(fl FieldLevel) bool { + return uUIDRegex.MatchString(fl.Field().String()) +} + +// IsISBN is the validation function for validating if the field's value is a valid v10 or v13 ISBN. +func isISBN(fl FieldLevel) bool { + return isISBN10(fl) || isISBN13(fl) +} + +// IsISBN13 is the validation function for validating if the field's value is a valid v13 ISBN. +func isISBN13(fl FieldLevel) bool { + + s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 4), " ", "", 4) + + if !iSBN13Regex.MatchString(s) { + return false + } + + var checksum int32 + var i int32 + + factor := []int32{1, 3} + + for i = 0; i < 12; i++ { + checksum += factor[i%2] * int32(s[i]-'0') + } + + return (int32(s[12]-'0'))-((10-(checksum%10))%10) == 0 +} + +// IsISBN10 is the validation function for validating if the field's value is a valid v10 ISBN. +func isISBN10(fl FieldLevel) bool { + + s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 3), " ", "", 3) + + if !iSBN10Regex.MatchString(s) { + return false + } + + var checksum int32 + var i int32 + + for i = 0; i < 9; i++ { + checksum += (i + 1) * int32(s[i]-'0') + } + + if s[9] == 'X' { + checksum += 10 * 10 + } else { + checksum += 10 * int32(s[9]-'0') + } + + return checksum%11 == 0 +} + +// ExcludesRune is the validation function for validating that the field's value does not contain the rune specified within the param. +func excludesRune(fl FieldLevel) bool { + return !containsRune(fl) +} + +// ExcludesAll is the validation function for validating that the field's value does not contain any of the characters specified within the param. +func excludesAll(fl FieldLevel) bool { + return !containsAny(fl) +} + +// Excludes is the validation function for validating that the field's value does not contain the text specified within the param. +func excludes(fl FieldLevel) bool { + return !contains(fl) +} + +// ContainsRune is the validation function for validating that the field's value contains the rune specified within the param. +func containsRune(fl FieldLevel) bool { + + r, _ := utf8.DecodeRuneInString(fl.Param()) + + return strings.ContainsRune(fl.Field().String(), r) +} + +// ContainsAny is the validation function for validating that the field's value contains any of the characters specified within the param. +func containsAny(fl FieldLevel) bool { + return strings.ContainsAny(fl.Field().String(), fl.Param()) +} + +// Contains is the validation function for validating that the field's value contains the text specified within the param. +func contains(fl FieldLevel) bool { + return strings.Contains(fl.Field().String(), fl.Param()) +} + +// IsNeField is the validation function for validating if the current field's value is not equal to the field specified by the param's value. +func isNeField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + currentField, currentKind, ok := fl.GetStructFieldOK() + + if !ok || currentKind != kind { + return true + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return field.Int() != currentField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return field.Uint() != currentField.Uint() + + case reflect.Float32, reflect.Float64: + return field.Float() != currentField.Float() + + case reflect.Slice, reflect.Map, reflect.Array: + return int64(field.Len()) != int64(currentField.Len()) + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != currentField.Type() { + return true + } + + if fieldType == timeType { + + t := currentField.Interface().(time.Time) + fieldTime := field.Interface().(time.Time) + + return !fieldTime.Equal(t) + } + + } + + // default reflect.String: + return field.String() != currentField.String() +} + +// IsNe is the validation function for validating that the field's value does not equal the provided param value. +func isNe(fl FieldLevel) bool { + return !isEq(fl) +} + +// IsLteCrossStructField is the validation function for validating if the current field's value is less than or equal to the field, within a separate struct, specified by the param's value. +func isLteCrossStructField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + topField, topKind, ok := fl.GetStructFieldOK() + if !ok || topKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return field.Int() <= topField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return field.Uint() <= topField.Uint() + + case reflect.Float32, reflect.Float64: + return field.Float() <= topField.Float() + + case reflect.Slice, reflect.Map, reflect.Array: + return int64(field.Len()) <= int64(topField.Len()) + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != topField.Type() { + return false + } + + if fieldType == timeType { + + fieldTime := field.Interface().(time.Time) + topTime := topField.Interface().(time.Time) + + return fieldTime.Before(topTime) || fieldTime.Equal(topTime) + } + } + + // default reflect.String: + return field.String() <= topField.String() +} + +// IsLtCrossStructField is the validation function for validating if the current field's value is less than the field, within a separate struct, specified by the param's value. +// NOTE: This is exposed for use within your own custom functions and not intended to be called directly. +func isLtCrossStructField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + topField, topKind, ok := fl.GetStructFieldOK() + if !ok || topKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return field.Int() < topField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return field.Uint() < topField.Uint() + + case reflect.Float32, reflect.Float64: + return field.Float() < topField.Float() + + case reflect.Slice, reflect.Map, reflect.Array: + return int64(field.Len()) < int64(topField.Len()) + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != topField.Type() { + return false + } + + if fieldType == timeType { + + fieldTime := field.Interface().(time.Time) + topTime := topField.Interface().(time.Time) + + return fieldTime.Before(topTime) + } + } + + // default reflect.String: + return field.String() < topField.String() +} + +// IsGteCrossStructField is the validation function for validating if the current field's value is greater than or equal to the field, within a separate struct, specified by the param's value. +func isGteCrossStructField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + topField, topKind, ok := fl.GetStructFieldOK() + if !ok || topKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return field.Int() >= topField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return field.Uint() >= topField.Uint() + + case reflect.Float32, reflect.Float64: + return field.Float() >= topField.Float() + + case reflect.Slice, reflect.Map, reflect.Array: + return int64(field.Len()) >= int64(topField.Len()) + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != topField.Type() { + return false + } + + if fieldType == timeType { + + fieldTime := field.Interface().(time.Time) + topTime := topField.Interface().(time.Time) + + return fieldTime.After(topTime) || fieldTime.Equal(topTime) + } + } + + // default reflect.String: + return field.String() >= topField.String() +} + +// IsGtCrossStructField is the validation function for validating if the current field's value is greater than the field, within a separate struct, specified by the param's value. +func isGtCrossStructField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + topField, topKind, ok := fl.GetStructFieldOK() + if !ok || topKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return field.Int() > topField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return field.Uint() > topField.Uint() + + case reflect.Float32, reflect.Float64: + return field.Float() > topField.Float() + + case reflect.Slice, reflect.Map, reflect.Array: + return int64(field.Len()) > int64(topField.Len()) + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != topField.Type() { + return false + } + + if fieldType == timeType { + + fieldTime := field.Interface().(time.Time) + topTime := topField.Interface().(time.Time) + + return fieldTime.After(topTime) + } + } + + // default reflect.String: + return field.String() > topField.String() +} + +// IsNeCrossStructField is the validation function for validating that the current field's value is not equal to the field, within a separate struct, specified by the param's value. +func isNeCrossStructField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + topField, currentKind, ok := fl.GetStructFieldOK() + if !ok || currentKind != kind { + return true + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return topField.Int() != field.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return topField.Uint() != field.Uint() + + case reflect.Float32, reflect.Float64: + return topField.Float() != field.Float() + + case reflect.Slice, reflect.Map, reflect.Array: + return int64(topField.Len()) != int64(field.Len()) + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != topField.Type() { + return true + } + + if fieldType == timeType { + + t := field.Interface().(time.Time) + fieldTime := topField.Interface().(time.Time) + + return !fieldTime.Equal(t) + } + } + + // default reflect.String: + return topField.String() != field.String() +} + +// IsEqCrossStructField is the validation function for validating that the current field's value is equal to the field, within a separate struct, specified by the param's value. +func isEqCrossStructField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + topField, topKind, ok := fl.GetStructFieldOK() + if !ok || topKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return topField.Int() == field.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return topField.Uint() == field.Uint() + + case reflect.Float32, reflect.Float64: + return topField.Float() == field.Float() + + case reflect.Slice, reflect.Map, reflect.Array: + return int64(topField.Len()) == int64(field.Len()) + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != topField.Type() { + return false + } + + if fieldType == timeType { + + t := field.Interface().(time.Time) + fieldTime := topField.Interface().(time.Time) + + return fieldTime.Equal(t) + } + } + + // default reflect.String: + return topField.String() == field.String() +} + +// IsEqField is the validation function for validating if the current field's value is equal to the field specified by the param's value. +func isEqField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + currentField, currentKind, ok := fl.GetStructFieldOK() + if !ok || currentKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return field.Int() == currentField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + return field.Uint() == currentField.Uint() + + case reflect.Float32, reflect.Float64: + return field.Float() == currentField.Float() + + case reflect.Slice, reflect.Map, reflect.Array: + return int64(field.Len()) == int64(currentField.Len()) + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != currentField.Type() { + return false + } + + if fieldType == timeType { + + t := currentField.Interface().(time.Time) + fieldTime := field.Interface().(time.Time) + + return fieldTime.Equal(t) + } + + } + + // default reflect.String: + return field.String() == currentField.String() +} + +// IsEq is the validation function for validating if the current field's value is equal to the param's value. +func isEq(fl FieldLevel) bool { + + field := fl.Field() + param := fl.Param() + + switch field.Kind() { + + case reflect.String: + return field.String() == param + + case reflect.Slice, reflect.Map, reflect.Array: + p := asInt(param) + + return int64(field.Len()) == p + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + p := asInt(param) + + return field.Int() == p + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + p := asUint(param) + + return field.Uint() == p + + case reflect.Float32, reflect.Float64: + p := asFloat(param) + + return field.Float() == p + } + + panic(fmt.Sprintf("Bad field type %T", field.Interface())) +} + +// IsBase64 is the validation function for validating if the current field's value is a valid base 64. +func isBase64(fl FieldLevel) bool { + return base64Regex.MatchString(fl.Field().String()) +} + +// IsURI is the validation function for validating if the current field's value is a valid URI. +func isURI(fl FieldLevel) bool { + + field := fl.Field() + + switch field.Kind() { + + case reflect.String: + + s := field.String() + + // checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195 + // emulate browser and strip the '#' suffix prior to validation. see issue-#237 + if i := strings.Index(s, "#"); i > -1 { + s = s[:i] + } + + if len(s) == 0 { + return false + } + + _, err := url.ParseRequestURI(s) + + return err == nil + } + + panic(fmt.Sprintf("Bad field type %T", field.Interface())) +} + +// IsURL is the validation function for validating if the current field's value is a valid URL. +func isURL(fl FieldLevel) bool { + + field := fl.Field() + + switch field.Kind() { + + case reflect.String: + + var i int + s := field.String() + + // checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195 + // emulate browser and strip the '#' suffix prior to validation. see issue-#237 + if i = strings.Index(s, "#"); i > -1 { + s = s[:i] + } + + if len(s) == 0 { + return false + } + + url, err := url.ParseRequestURI(s) + + if err != nil || url.Scheme == "" { + return false + } + + return err == nil + } + + panic(fmt.Sprintf("Bad field type %T", field.Interface())) +} + +// IsEmail is the validation function for validating if the current field's value is a valid email address. +func isEmail(fl FieldLevel) bool { + return emailRegex.MatchString(fl.Field().String()) +} + +// IsHSLA is the validation function for validating if the current field's value is a valid HSLA color. +func isHSLA(fl FieldLevel) bool { + return hslaRegex.MatchString(fl.Field().String()) +} + +// IsHSL is the validation function for validating if the current field's value is a valid HSL color. +func isHSL(fl FieldLevel) bool { + return hslRegex.MatchString(fl.Field().String()) +} + +// IsRGBA is the validation function for validating if the current field's value is a valid RGBA color. +func isRGBA(fl FieldLevel) bool { + return rgbaRegex.MatchString(fl.Field().String()) +} + +// IsRGB is the validation function for validating if the current field's value is a valid RGB color. +func isRGB(fl FieldLevel) bool { + return rgbRegex.MatchString(fl.Field().String()) +} + +// IsHEXColor is the validation function for validating if the current field's value is a valid HEX color. +func isHEXColor(fl FieldLevel) bool { + return hexcolorRegex.MatchString(fl.Field().String()) +} + +// IsHexadecimal is the validation function for validating if the current field's value is a valid hexadecimal. +func isHexadecimal(fl FieldLevel) bool { + return hexadecimalRegex.MatchString(fl.Field().String()) +} + +// IsNumber is the validation function for validating if the current field's value is a valid number. +func isNumber(fl FieldLevel) bool { + return numberRegex.MatchString(fl.Field().String()) +} + +// IsNumeric is the validation function for validating if the current field's value is a valid numeric value. +func isNumeric(fl FieldLevel) bool { + return numericRegex.MatchString(fl.Field().String()) +} + +// IsAlphanum is the validation function for validating if the current field's value is a valid alphanumeric value. +func isAlphanum(fl FieldLevel) bool { + return alphaNumericRegex.MatchString(fl.Field().String()) +} + +// IsAlpha is the validation function for validating if the current field's value is a valid alpha value. +func isAlpha(fl FieldLevel) bool { + return alphaRegex.MatchString(fl.Field().String()) +} + +// IsAlphanumUnicode is the validation function for validating if the current field's value is a valid alphanumeric unicode value. +func isAlphanumUnicode(fl FieldLevel) bool { + return alphaUnicodeNumericRegex.MatchString(fl.Field().String()) +} + +// IsAlphaUnicode is the validation function for validating if the current field's value is a valid alpha unicode value. +func isAlphaUnicode(fl FieldLevel) bool { + return alphaUnicodeRegex.MatchString(fl.Field().String()) +} + +// HasValue is the validation function for validating if the current field's value is not the default static value. +func hasValue(fl FieldLevel) bool { + + field := fl.Field() + + switch field.Kind() { + case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func: + return !field.IsNil() + default: + + if fl.(*validate).fldIsPointer && field.Interface() != nil { + return true + } + + return field.IsValid() && field.Interface() != reflect.Zero(field.Type()).Interface() + } +} + +// IsGteField is the validation function for validating if the current field's value is greater than or equal to the field specified by the param's value. +func isGteField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + currentField, currentKind, ok := fl.GetStructFieldOK() + if !ok || currentKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + + return field.Int() >= currentField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + + return field.Uint() >= currentField.Uint() + + case reflect.Float32, reflect.Float64: + + return field.Float() >= currentField.Float() + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != currentField.Type() { + return false + } + + if fieldType == timeType { + + t := currentField.Interface().(time.Time) + fieldTime := field.Interface().(time.Time) + + return fieldTime.After(t) || fieldTime.Equal(t) + } + } + + // default reflect.String + return len(field.String()) >= len(currentField.String()) +} + +// IsGtField is the validation function for validating if the current field's value is greater than the field specified by the param's value. +func isGtField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + currentField, currentKind, ok := fl.GetStructFieldOK() + if !ok || currentKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + + return field.Int() > currentField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + + return field.Uint() > currentField.Uint() + + case reflect.Float32, reflect.Float64: + + return field.Float() > currentField.Float() + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != currentField.Type() { + return false + } + + if fieldType == timeType { + + t := currentField.Interface().(time.Time) + fieldTime := field.Interface().(time.Time) + + return fieldTime.After(t) + } + } + + // default reflect.String + return len(field.String()) > len(currentField.String()) +} + +// IsGte is the validation function for validating if the current field's value is greater than or equal to the param's value. +func isGte(fl FieldLevel) bool { + + field := fl.Field() + param := fl.Param() + + switch field.Kind() { + + case reflect.String: + p := asInt(param) + + return int64(utf8.RuneCountInString(field.String())) >= p + + case reflect.Slice, reflect.Map, reflect.Array: + p := asInt(param) + + return int64(field.Len()) >= p + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + p := asInt(param) + + return field.Int() >= p + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + p := asUint(param) + + return field.Uint() >= p + + case reflect.Float32, reflect.Float64: + p := asFloat(param) + + return field.Float() >= p + + case reflect.Struct: + + if field.Type() == timeType { + + now := time.Now().UTC() + t := field.Interface().(time.Time) + + return t.After(now) || t.Equal(now) + } + } + + panic(fmt.Sprintf("Bad field type %T", field.Interface())) +} + +// IsGt is the validation function for validating if the current field's value is greater than the param's value. +func isGt(fl FieldLevel) bool { + + field := fl.Field() + param := fl.Param() + + switch field.Kind() { + + case reflect.String: + p := asInt(param) + + return int64(utf8.RuneCountInString(field.String())) > p + + case reflect.Slice, reflect.Map, reflect.Array: + p := asInt(param) + + return int64(field.Len()) > p + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + p := asInt(param) + + return field.Int() > p + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + p := asUint(param) + + return field.Uint() > p + + case reflect.Float32, reflect.Float64: + p := asFloat(param) + + return field.Float() > p + case reflect.Struct: + + if field.Type() == timeType { + + return field.Interface().(time.Time).After(time.Now().UTC()) + } + } + + panic(fmt.Sprintf("Bad field type %T", field.Interface())) +} + +// HasLengthOf is the validation function for validating if the current field's value is equal to the param's value. +func hasLengthOf(fl FieldLevel) bool { + + field := fl.Field() + param := fl.Param() + + switch field.Kind() { + + case reflect.String: + p := asInt(param) + + return int64(utf8.RuneCountInString(field.String())) == p + + case reflect.Slice, reflect.Map, reflect.Array: + p := asInt(param) + + return int64(field.Len()) == p + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + p := asInt(param) + + return field.Int() == p + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + p := asUint(param) + + return field.Uint() == p + + case reflect.Float32, reflect.Float64: + p := asFloat(param) + + return field.Float() == p + } + + panic(fmt.Sprintf("Bad field type %T", field.Interface())) +} + +// HasMinOf is the validation function for validating if the current field's value is greater than or equal to the param's value. +func hasMinOf(fl FieldLevel) bool { + return isGte(fl) +} + +// IsLteField is the validation function for validating if the current field's value is less than or equal to the field specified by the param's value. +func isLteField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + currentField, currentKind, ok := fl.GetStructFieldOK() + if !ok || currentKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + + return field.Int() <= currentField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + + return field.Uint() <= currentField.Uint() + + case reflect.Float32, reflect.Float64: + + return field.Float() <= currentField.Float() + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != currentField.Type() { + return false + } + + if fieldType == timeType { + + t := currentField.Interface().(time.Time) + fieldTime := field.Interface().(time.Time) + + return fieldTime.Before(t) || fieldTime.Equal(t) + } + } + + // default reflect.String + return len(field.String()) <= len(currentField.String()) +} + +// IsLtField is the validation function for validating if the current field's value is less than the field specified by the param's value. +func isLtField(fl FieldLevel) bool { + + field := fl.Field() + kind := field.Kind() + + currentField, currentKind, ok := fl.GetStructFieldOK() + if !ok || currentKind != kind { + return false + } + + switch kind { + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + + return field.Int() < currentField.Int() + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + + return field.Uint() < currentField.Uint() + + case reflect.Float32, reflect.Float64: + + return field.Float() < currentField.Float() + + case reflect.Struct: + + fieldType := field.Type() + + // Not Same underlying type i.e. struct and time + if fieldType != currentField.Type() { + return false + } + + if fieldType == timeType { + + t := currentField.Interface().(time.Time) + fieldTime := field.Interface().(time.Time) + + return fieldTime.Before(t) + } + } + + // default reflect.String + return len(field.String()) < len(currentField.String()) +} + +// IsLte is the validation function for validating if the current field's value is less than or equal to the param's value. +func isLte(fl FieldLevel) bool { + + field := fl.Field() + param := fl.Param() + + switch field.Kind() { + + case reflect.String: + p := asInt(param) + + return int64(utf8.RuneCountInString(field.String())) <= p + + case reflect.Slice, reflect.Map, reflect.Array: + p := asInt(param) + + return int64(field.Len()) <= p + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + p := asInt(param) + + return field.Int() <= p + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + p := asUint(param) + + return field.Uint() <= p + + case reflect.Float32, reflect.Float64: + p := asFloat(param) + + return field.Float() <= p + + case reflect.Struct: + + if field.Type() == timeType { + + now := time.Now().UTC() + t := field.Interface().(time.Time) + + return t.Before(now) || t.Equal(now) + } + } + + panic(fmt.Sprintf("Bad field type %T", field.Interface())) +} + +// IsLt is the validation function for validating if the current field's value is less than the param's value. +func isLt(fl FieldLevel) bool { + + field := fl.Field() + param := fl.Param() + + switch field.Kind() { + + case reflect.String: + p := asInt(param) + + return int64(utf8.RuneCountInString(field.String())) < p + + case reflect.Slice, reflect.Map, reflect.Array: + p := asInt(param) + + return int64(field.Len()) < p + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + p := asInt(param) + + return field.Int() < p + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: + p := asUint(param) + + return field.Uint() < p + + case reflect.Float32, reflect.Float64: + p := asFloat(param) + + return field.Float() < p + + case reflect.Struct: + + if field.Type() == timeType { + + return field.Interface().(time.Time).Before(time.Now().UTC()) + } + } + + panic(fmt.Sprintf("Bad field type %T", field.Interface())) +} + +// HasMaxOf is the validation function for validating if the current field's value is less than or equal to the param's value. +func hasMaxOf(fl FieldLevel) bool { + return isLte(fl) +} + +// IsTCP4AddrResolvable is the validation function for validating if the field's value is a resolvable tcp4 address. +func isTCP4AddrResolvable(fl FieldLevel) bool { + + if !isIP4Addr(fl) { + return false + } + + _, err := net.ResolveTCPAddr("tcp4", fl.Field().String()) + return err == nil +} + +// IsTCP6AddrResolvable is the validation function for validating if the field's value is a resolvable tcp6 address. +func isTCP6AddrResolvable(fl FieldLevel) bool { + + if !isIP6Addr(fl) { + return false + } + + _, err := net.ResolveTCPAddr("tcp6", fl.Field().String()) + + return err == nil +} + +// IsTCPAddrResolvable is the validation function for validating if the field's value is a resolvable tcp address. +func isTCPAddrResolvable(fl FieldLevel) bool { + + if !isIP4Addr(fl) && !isIP6Addr(fl) { + return false + } + + _, err := net.ResolveTCPAddr("tcp", fl.Field().String()) + + return err == nil +} + +// IsUDP4AddrResolvable is the validation function for validating if the field's value is a resolvable udp4 address. +func isUDP4AddrResolvable(fl FieldLevel) bool { + + if !isIP4Addr(fl) { + return false + } + + _, err := net.ResolveUDPAddr("udp4", fl.Field().String()) + + return err == nil +} + +// IsUDP6AddrResolvable is the validation function for validating if the field's value is a resolvable udp6 address. +func isUDP6AddrResolvable(fl FieldLevel) bool { + + if !isIP6Addr(fl) { + return false + } + + _, err := net.ResolveUDPAddr("udp6", fl.Field().String()) + + return err == nil +} + +// IsUDPAddrResolvable is the validation function for validating if the field's value is a resolvable udp address. +func isUDPAddrResolvable(fl FieldLevel) bool { + + if !isIP4Addr(fl) && !isIP6Addr(fl) { + return false + } + + _, err := net.ResolveUDPAddr("udp", fl.Field().String()) + + return err == nil +} + +// IsIP4AddrResolvable is the validation function for validating if the field's value is a resolvable ip4 address. +func isIP4AddrResolvable(fl FieldLevel) bool { + + if !isIPv4(fl) { + return false + } + + _, err := net.ResolveIPAddr("ip4", fl.Field().String()) + + return err == nil +} + +// IsIP6AddrResolvable is the validation function for validating if the field's value is a resolvable ip6 address. +func isIP6AddrResolvable(fl FieldLevel) bool { + + if !isIPv6(fl) { + return false + } + + _, err := net.ResolveIPAddr("ip6", fl.Field().String()) + + return err == nil +} + +// IsIPAddrResolvable is the validation function for validating if the field's value is a resolvable ip address. +func isIPAddrResolvable(fl FieldLevel) bool { + + if !isIP(fl) { + return false + } + + _, err := net.ResolveIPAddr("ip", fl.Field().String()) + + return err == nil +} + +// IsUnixAddrResolvable is the validation function for validating if the field's value is a resolvable unix address. +func isUnixAddrResolvable(fl FieldLevel) bool { + + _, err := net.ResolveUnixAddr("unix", fl.Field().String()) + + return err == nil +} + +func isIP4Addr(fl FieldLevel) bool { + + val := fl.Field().String() + + if idx := strings.LastIndex(val, ":"); idx != -1 { + val = val[0:idx] + } + + ip := net.ParseIP(val) + + return ip != nil && ip.To4() != nil +} + +func isIP6Addr(fl FieldLevel) bool { + + val := fl.Field().String() + + if idx := strings.LastIndex(val, ":"); idx != -1 { + if idx != 0 && val[idx-1:idx] == "]" { + val = val[1 : idx-1] + } + } + + ip := net.ParseIP(val) + + return ip != nil && ip.To4() == nil +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go b/vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go new file mode 100644 index 0000000000..b2a1c424e8 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go @@ -0,0 +1,1080 @@ +package validator + +import ( + "bytes" + sql "database/sql/driver" + "testing" + "time" +) + +func BenchmarkFieldSuccess(b *testing.B) { + + validate := New() + + s := "1" + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Var(&s, "len=1") + } +} + +func BenchmarkFieldSuccessParallel(b *testing.B) { + + validate := New() + + s := "1" + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Var(&s, "len=1") + } + }) +} + +func BenchmarkFieldFailure(b *testing.B) { + + validate := New() + + s := "12" + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Var(&s, "len=1") + } +} + +func BenchmarkFieldFailureParallel(b *testing.B) { + + validate := New() + + s := "12" + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Var(&s, "len=1") + } + }) +} + +func BenchmarkFieldDiveSuccess(b *testing.B) { + + validate := New() + + m := []string{"val1", "val2", "val3"} + + b.ResetTimer() + + for n := 0; n < b.N; n++ { + validate.Var(m, "required,dive,required") + } +} + +func BenchmarkFieldDiveSuccessParallel(b *testing.B) { + + validate := New() + + m := []string{"val1", "val2", "val3"} + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Var(m, "required,dive,required") + } + }) +} + +func BenchmarkFieldDiveFailure(b *testing.B) { + + validate := New() + + m := []string{"val1", "", "val3"} + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Var(m, "required,dive,required") + } +} + +func BenchmarkFieldDiveFailureParallel(b *testing.B) { + + validate := New() + + m := []string{"val1", "", "val3"} + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Var(m, "required,dive,required") + } + }) +} + +func BenchmarkFieldCustomTypeSuccess(b *testing.B) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{}) + + val := valuer{ + Name: "1", + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Var(val, "len=1") + } +} + +func BenchmarkFieldCustomTypeSuccessParallel(b *testing.B) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{}) + + val := valuer{ + Name: "1", + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Var(val, "len=1") + } + }) +} + +func BenchmarkFieldCustomTypeFailure(b *testing.B) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{}) + + val := valuer{} + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Var(val, "len=1") + } +} + +func BenchmarkFieldCustomTypeFailureParallel(b *testing.B) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{}) + + val := valuer{} + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Var(val, "len=1") + } + }) +} + +func BenchmarkFieldOrTagSuccess(b *testing.B) { + + validate := New() + + s := "rgba(0,0,0,1)" + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Var(s, "rgb|rgba") + } +} + +func BenchmarkFieldOrTagSuccessParallel(b *testing.B) { + + validate := New() + + s := "rgba(0,0,0,1)" + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Var(s, "rgb|rgba") + } + }) +} + +func BenchmarkFieldOrTagFailure(b *testing.B) { + + validate := New() + + s := "#000" + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Var(s, "rgb|rgba") + } +} + +func BenchmarkFieldOrTagFailureParallel(b *testing.B) { + + validate := New() + + s := "#000" + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Var(s, "rgb|rgba") + } + }) +} + +func BenchmarkStructLevelValidationSuccess(b *testing.B) { + + validate := New() + validate.RegisterStructValidation(StructValidationTestStructSuccess, TestStruct{}) + + tst := TestStruct{ + String: "good value", + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(tst) + } +} + +func BenchmarkStructLevelValidationSuccessParallel(b *testing.B) { + + validate := New() + validate.RegisterStructValidation(StructValidationTestStructSuccess, TestStruct{}) + + tst := TestStruct{ + String: "good value", + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(tst) + } + }) +} + +func BenchmarkStructLevelValidationFailure(b *testing.B) { + + validate := New() + validate.RegisterStructValidation(StructValidationTestStruct, TestStruct{}) + + tst := TestStruct{ + String: "good value", + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(tst) + } +} + +func BenchmarkStructLevelValidationFailureParallel(b *testing.B) { + + validate := New() + validate.RegisterStructValidation(StructValidationTestStruct, TestStruct{}) + + tst := TestStruct{ + String: "good value", + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(tst) + } + }) +} + +func BenchmarkStructSimpleCustomTypeSuccess(b *testing.B) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{}) + + val := valuer{ + Name: "1", + } + + type Foo struct { + Valuer valuer `validate:"len=1"` + IntValue int `validate:"min=5,max=10"` + } + + validFoo := &Foo{Valuer: val, IntValue: 7} + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(validFoo) + } +} + +func BenchmarkStructSimpleCustomTypeSuccessParallel(b *testing.B) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{}) + + val := valuer{ + Name: "1", + } + + type Foo struct { + Valuer valuer `validate:"len=1"` + IntValue int `validate:"min=5,max=10"` + } + + validFoo := &Foo{Valuer: val, IntValue: 7} + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(validFoo) + } + }) +} + +func BenchmarkStructSimpleCustomTypeFailure(b *testing.B) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{}) + + val := valuer{} + + type Foo struct { + Valuer valuer `validate:"len=1"` + IntValue int `validate:"min=5,max=10"` + } + + validFoo := &Foo{Valuer: val, IntValue: 3} + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(validFoo) + } +} + +func BenchmarkStructSimpleCustomTypeFailureParallel(b *testing.B) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{}) + + val := valuer{} + + type Foo struct { + Valuer valuer `validate:"len=1"` + IntValue int `validate:"min=5,max=10"` + } + + validFoo := &Foo{Valuer: val, IntValue: 3} + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(validate.Struct(validFoo)) + } + }) +} + +func BenchmarkStructFilteredSuccess(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + byts := []byte("Name") + + fn := func(ns []byte) bool { + return !bytes.HasSuffix(ns, byts) + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.StructFiltered(test, fn) + } +} + +func BenchmarkStructFilteredSuccessParallel(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + byts := []byte("Name") + + fn := func(ns []byte) bool { + return !bytes.HasSuffix(ns, byts) + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.StructFiltered(test, fn) + } + }) +} + +func BenchmarkStructFilteredFailure(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + byts := []byte("NickName") + + fn := func(ns []byte) bool { + return !bytes.HasSuffix(ns, byts) + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.StructFiltered(test, fn) + } +} + +func BenchmarkStructFilteredFailureParallel(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + byts := []byte("NickName") + + fn := func(ns []byte) bool { + return !bytes.HasSuffix(ns, byts) + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.StructFiltered(test, fn) + } + }) +} + +func BenchmarkStructPartialSuccess(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.StructPartial(test, "Name") + } +} + +func BenchmarkStructPartialSuccessParallel(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.StructPartial(test, "Name") + } + }) +} + +func BenchmarkStructPartialFailure(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.StructPartial(test, "NickName") + } +} + +func BenchmarkStructPartialFailureParallel(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.StructPartial(test, "NickName") + } + }) +} + +func BenchmarkStructExceptSuccess(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.StructExcept(test, "Nickname") + } +} + +func BenchmarkStructExceptSuccessParallel(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.StructExcept(test, "NickName") + } + }) +} + +func BenchmarkStructExceptFailure(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.StructExcept(test, "Name") + } +} + +func BenchmarkStructExceptFailureParallel(b *testing.B) { + + validate := New() + + type Test struct { + Name string `validate:"required"` + NickName string `validate:"required"` + } + + test := &Test{ + Name: "Joey Bloggs", + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.StructExcept(test, "Name") + } + }) +} + +func BenchmarkStructSimpleCrossFieldSuccess(b *testing.B) { + + validate := New() + + type Test struct { + Start time.Time + End time.Time `validate:"gtfield=Start"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * 5) + + test := &Test{ + Start: now, + End: then, + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(test) + } +} + +func BenchmarkStructSimpleCrossFieldSuccessParallel(b *testing.B) { + + validate := New() + + type Test struct { + Start time.Time + End time.Time `validate:"gtfield=Start"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * 5) + + test := &Test{ + Start: now, + End: then, + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(test) + } + }) +} + +func BenchmarkStructSimpleCrossFieldFailure(b *testing.B) { + + validate := New() + + type Test struct { + Start time.Time + End time.Time `validate:"gtfield=Start"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * -5) + + test := &Test{ + Start: now, + End: then, + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(test) + } +} + +func BenchmarkStructSimpleCrossFieldFailureParallel(b *testing.B) { + + validate := New() + + type Test struct { + Start time.Time + End time.Time `validate:"gtfield=Start"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * -5) + + test := &Test{ + Start: now, + End: then, + } + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(test) + } + }) +} + +func BenchmarkStructSimpleCrossStructCrossFieldSuccess(b *testing.B) { + + validate := New() + + type Inner struct { + Start time.Time + } + + type Outer struct { + Inner *Inner + CreatedAt time.Time `validate:"eqcsfield=Inner.Start"` + } + + now := time.Now().UTC() + + inner := &Inner{ + Start: now, + } + + outer := &Outer{ + Inner: inner, + CreatedAt: now, + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(outer) + } +} + +func BenchmarkStructSimpleCrossStructCrossFieldSuccessParallel(b *testing.B) { + + validate := New() + + type Inner struct { + Start time.Time + } + + type Outer struct { + Inner *Inner + CreatedAt time.Time `validate:"eqcsfield=Inner.Start"` + } + + now := time.Now().UTC() + + inner := &Inner{ + Start: now, + } + + outer := &Outer{ + Inner: inner, + CreatedAt: now, + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(outer) + } + }) +} + +func BenchmarkStructSimpleCrossStructCrossFieldFailure(b *testing.B) { + + validate := New() + + type Inner struct { + Start time.Time + } + + type Outer struct { + Inner *Inner + CreatedAt time.Time `validate:"eqcsfield=Inner.Start"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * 5) + + inner := &Inner{ + Start: then, + } + + outer := &Outer{ + Inner: inner, + CreatedAt: now, + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(outer) + } +} + +func BenchmarkStructSimpleCrossStructCrossFieldFailureParallel(b *testing.B) { + + validate := New() + + type Inner struct { + Start time.Time + } + + type Outer struct { + Inner *Inner + CreatedAt time.Time `validate:"eqcsfield=Inner.Start"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * 5) + + inner := &Inner{ + Start: then, + } + + outer := &Outer{ + Inner: inner, + CreatedAt: now, + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(outer) + } + }) +} + +func BenchmarkStructSimpleSuccess(b *testing.B) { + + validate := New() + + type Foo struct { + StringValue string `validate:"min=5,max=10"` + IntValue int `validate:"min=5,max=10"` + } + + validFoo := &Foo{StringValue: "Foobar", IntValue: 7} + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(validFoo) + } +} + +func BenchmarkStructSimpleSuccessParallel(b *testing.B) { + + validate := New() + + type Foo struct { + StringValue string `validate:"min=5,max=10"` + IntValue int `validate:"min=5,max=10"` + } + + validFoo := &Foo{StringValue: "Foobar", IntValue: 7} + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(validFoo) + } + }) +} + +func BenchmarkStructSimpleFailure(b *testing.B) { + + validate := New() + + type Foo struct { + StringValue string `validate:"min=5,max=10"` + IntValue int `validate:"min=5,max=10"` + } + + invalidFoo := &Foo{StringValue: "Fo", IntValue: 3} + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(invalidFoo) + } +} + +func BenchmarkStructSimpleFailureParallel(b *testing.B) { + + validate := New() + + type Foo struct { + StringValue string `validate:"min=5,max=10"` + IntValue int `validate:"min=5,max=10"` + } + + invalidFoo := &Foo{StringValue: "Fo", IntValue: 3} + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(invalidFoo) + } + }) +} + +func BenchmarkStructComplexSuccess(b *testing.B) { + + validate := New() + + tSuccess := &TestString{ + Required: "Required", + Len: "length==10", + Min: "min=1", + Max: "1234567890", + MinMax: "12345", + Lt: "012345678", + Lte: "0123456789", + Gt: "01234567890", + Gte: "0123456789", + OmitEmpty: "", + Sub: &SubTest{ + Test: "1", + }, + SubIgnore: &SubTest{ + Test: "", + }, + Anonymous: struct { + A string `validate:"required"` + }{ + A: "1", + }, + Iface: &Impl{ + F: "123", + }, + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(tSuccess) + } +} + +func BenchmarkStructComplexSuccessParallel(b *testing.B) { + + validate := New() + + tSuccess := &TestString{ + Required: "Required", + Len: "length==10", + Min: "min=1", + Max: "1234567890", + MinMax: "12345", + Lt: "012345678", + Lte: "0123456789", + Gt: "01234567890", + Gte: "0123456789", + OmitEmpty: "", + Sub: &SubTest{ + Test: "1", + }, + SubIgnore: &SubTest{ + Test: "", + }, + Anonymous: struct { + A string `validate:"required"` + }{ + A: "1", + }, + Iface: &Impl{ + F: "123", + }, + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(tSuccess) + } + }) +} + +func BenchmarkStructComplexFailure(b *testing.B) { + + validate := New() + + tFail := &TestString{ + Required: "", + Len: "", + Min: "", + Max: "12345678901", + MinMax: "", + Lt: "0123456789", + Lte: "01234567890", + Gt: "1", + Gte: "1", + OmitEmpty: "12345678901", + Sub: &SubTest{ + Test: "", + }, + Anonymous: struct { + A string `validate:"required"` + }{ + A: "", + }, + Iface: &Impl{ + F: "12", + }, + } + + b.ResetTimer() + for n := 0; n < b.N; n++ { + validate.Struct(tFail) + } +} + +func BenchmarkStructComplexFailureParallel(b *testing.B) { + + validate := New() + + tFail := &TestString{ + Required: "", + Len: "", + Min: "", + Max: "12345678901", + MinMax: "", + Lt: "0123456789", + Lte: "01234567890", + Gt: "1", + Gte: "1", + OmitEmpty: "12345678901", + Sub: &SubTest{ + Test: "", + }, + Anonymous: struct { + A string `validate:"required"` + }{ + A: "", + }, + Iface: &Impl{ + F: "12", + }, + } + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(tFail) + } + }) +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/cache.go b/vendor/gopkg.in/go-playground/validator.v9/cache.go new file mode 100644 index 0000000000..d596bd5b52 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/cache.go @@ -0,0 +1,267 @@ +package validator + +import ( + "fmt" + "reflect" + "strings" + "sync" + "sync/atomic" +) + +type tagType uint8 + +const ( + typeDefault tagType = iota + typeOmitEmpty + typeNoStructLevel + typeStructOnly + typeDive + typeOr +) + +const ( + invalidValidation = "Invalid validation tag on field '%s'" + undefinedValidation = "Undefined validation function '%s' on field '%s'" +) + +type structCache struct { + lock sync.Mutex + m atomic.Value // map[reflect.Type]*cStruct +} + +func (sc *structCache) Get(key reflect.Type) (c *cStruct, found bool) { + c, found = sc.m.Load().(map[reflect.Type]*cStruct)[key] + return +} + +func (sc *structCache) Set(key reflect.Type, value *cStruct) { + + m := sc.m.Load().(map[reflect.Type]*cStruct) + + nm := make(map[reflect.Type]*cStruct, len(m)+1) + for k, v := range m { + nm[k] = v + } + nm[key] = value + sc.m.Store(nm) +} + +type tagCache struct { + lock sync.Mutex + m atomic.Value // map[string]*cTag +} + +func (tc *tagCache) Get(key string) (c *cTag, found bool) { + c, found = tc.m.Load().(map[string]*cTag)[key] + return +} + +func (tc *tagCache) Set(key string, value *cTag) { + + m := tc.m.Load().(map[string]*cTag) + + nm := make(map[string]*cTag, len(m)+1) + for k, v := range m { + nm[k] = v + } + nm[key] = value + tc.m.Store(nm) +} + +type cStruct struct { + name string + fields []*cField + fn StructLevelFunc +} + +type cField struct { + idx int + name string + altName string + namesEqual bool + cTags *cTag +} + +type cTag struct { + tag string + aliasTag string + actualAliasTag string + param string + hasAlias bool + typeof tagType + hasTag bool + fn Func + next *cTag +} + +func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStruct { + + v.structCache.lock.Lock() + defer v.structCache.lock.Unlock() // leave as defer! because if inner panics, it will never get unlocked otherwise! + + typ := current.Type() + + // could have been multiple trying to access, but once first is done this ensures struct + // isn't parsed again. + cs, ok := v.structCache.Get(typ) + if ok { + return cs + } + + cs = &cStruct{name: sName, fields: make([]*cField, 0), fn: v.structLevelFuncs[typ]} + + numFields := current.NumField() + + var ctag *cTag + var fld reflect.StructField + var tag string + var customName string + + for i := 0; i < numFields; i++ { + + fld = typ.Field(i) + + if !fld.Anonymous && len(fld.PkgPath) > 0 { + continue + } + + tag = fld.Tag.Get(v.tagName) + + if tag == skipValidationTag { + continue + } + + customName = fld.Name + + if v.hasTagNameFunc { + + name := v.tagNameFunc(fld) + + if len(name) > 0 { + customName = name + } + } + + // NOTE: cannot use shared tag cache, because tags may be equal, but things like alias may be different + // and so only struct level caching can be used instead of combined with Field tag caching + + if len(tag) > 0 { + ctag, _ = v.parseFieldTagsRecursive(tag, fld.Name, "", false) + } else { + // even if field doesn't have validations need cTag for traversing to potential inner/nested + // elements of the field. + ctag = new(cTag) + } + + cs.fields = append(cs.fields, &cField{ + idx: i, + name: fld.Name, + altName: customName, + cTags: ctag, + namesEqual: fld.Name == customName, + }) + } + + v.structCache.Set(typ, cs) + + return cs +} + +func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias string, hasAlias bool) (firstCtag *cTag, current *cTag) { + + var t string + var ok bool + noAlias := len(alias) == 0 + tags := strings.Split(tag, tagSeparator) + + for i := 0; i < len(tags); i++ { + + t = tags[i] + + if noAlias { + alias = t + } + + // check map for alias and process new tags, otherwise process as usual + if tagsVal, found := v.aliases[t]; found { + + if i == 0 { + firstCtag, current = v.parseFieldTagsRecursive(tagsVal, fieldName, t, true) + } else { + next, curr := v.parseFieldTagsRecursive(tagsVal, fieldName, t, true) + current.next, current = next, curr + + } + + continue + } + + if i == 0 { + current = &cTag{aliasTag: alias, hasAlias: hasAlias, hasTag: true} + firstCtag = current + } else { + current.next = &cTag{aliasTag: alias, hasAlias: hasAlias, hasTag: true} + current = current.next + } + + switch t { + + case diveTag: + current.typeof = typeDive + continue + + case omitempty: + current.typeof = typeOmitEmpty + continue + + case structOnlyTag: + current.typeof = typeStructOnly + continue + + case noStructLevelTag: + current.typeof = typeNoStructLevel + continue + + default: + + // if a pipe character is needed within the param you must use the utf8Pipe representation "0x7C" + orVals := strings.Split(t, orSeparator) + + for j := 0; j < len(orVals); j++ { + + vals := strings.SplitN(orVals[j], tagKeySeparator, 2) + + if noAlias { + alias = vals[0] + current.aliasTag = alias + } else { + current.actualAliasTag = t + } + + if j > 0 { + current.next = &cTag{aliasTag: alias, actualAliasTag: current.actualAliasTag, hasAlias: hasAlias, hasTag: true} + current = current.next + } + + current.tag = vals[0] + if len(current.tag) == 0 { + panic(strings.TrimSpace(fmt.Sprintf(invalidValidation, fieldName))) + } + + if current.fn, ok = v.validations[current.tag]; !ok { + panic(strings.TrimSpace(fmt.Sprintf(undefinedValidation, current.tag, fieldName))) + } + + if len(orVals) > 1 { + current.typeof = typeOr + } + + if len(vals) > 1 { + current.param = strings.Replace(strings.Replace(vals[1], utf8HexComma, ",", -1), utf8Pipe, "|", -1) + } + } + } + } + + return +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/doc.go b/vendor/gopkg.in/go-playground/validator.v9/doc.go new file mode 100644 index 0000000000..7da5e591f2 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/doc.go @@ -0,0 +1,841 @@ +/* +Package validator implements value validations for structs and individual fields +based on tags. + +It can also handle Cross-Field and Cross-Struct validation for nested structs +and has the ability to dive into arrays and maps of any type. + +see more examples https://github.com/go-playground/validator/tree/v9/_examples + +Validation Functions Return Type error + +Doing things this way is actually the way the standard library does, see the +file.Open method here: + + https://golang.org/pkg/os/#Open. + +The authors return type "error" to avoid the issue discussed in the following, +where err is always != nil: + + http://stackoverflow.com/a/29138676/3158232 + https://github.com/go-playground/validator/issues/134 + +Validator only InvalidValidationError for bad validation input, nil or +ValidationErrors as type error; so, in your code all you need to do is check +if the error returned is not nil, and if it's not check if error is +InvalidValidationError ( if necessary, most of the time it isn't ) type cast +it to type ValidationErrors like so err.(validator.ValidationErrors). + +Custom Validation Functions + +Custom Validation functions can be added. Example: + + // Structure + func customFunc(fl FielddLevel) bool { + + if fl.Field().String() == "invalid" { + return false + } + + return true + } + + validate.RegisterValidation("custom tag name", customFunc) + // NOTES: using the same tag name as an existing function + // will overwrite the existing one + +Cross-Field Validation + +Cross-Field Validation can be done via the following tags: + - eqfield + - nefield + - gtfield + - gtefield + - ltfield + - ltefield + - eqcsfield + - necsfield + - gtcsfield + - ftecsfield + - ltcsfield + - ltecsfield + +If, however, some custom cross-field validation is required, it can be done +using a custom validation. + +Why not just have cross-fields validation tags (i.e. only eqcsfield and not +eqfield)? + +The reason is efficiency. If you want to check a field within the same struct +"eqfield" only has to find the field on the same struct (1 level). But, if we +used "eqcsfield" it could be multiple levels down. Example: + + type Inner struct { + StartDate time.Time + } + + type Outer struct { + InnerStructField *Inner + CreatedAt time.Time `validate:"ltecsfield=InnerStructField.StartDate"` + } + + now := time.Now() + + inner := &Inner{ + StartDate: now, + } + + outer := &Outer{ + InnerStructField: inner, + CreatedAt: now, + } + + errs := validate.Struct(outer) + + // NOTE: when calling validate.Struct(val) topStruct will be the top level struct passed + // into the function + // when calling validate.FieldWithValue(val, field, tag) val will be + // whatever you pass, struct, field... + // when calling validate.Field(field, tag) val will be nil + +Multiple Validators + +Multiple validators on a field will process in the order defined. Example: + + type Test struct { + Field `validate:"max=10,min=1"` + } + + // max will be checked then min + +Bad Validator definitions are not handled by the library. Example: + + type Test struct { + Field `validate:"min=10,max=0"` + } + + // this definition of min max will never succeed + +Using Validator Tags + +Baked In Cross-Field validation only compares fields on the same struct. +If Cross-Field + Cross-Struct validation is needed you should implement your +own custom validator. + +Comma (",") is the default separator of validation tags. If you wish to +have a comma included within the parameter (i.e. excludesall=,) you will need to +use the UTF-8 hex representation 0x2C, which is replaced in the code as a comma, +so the above will become excludesall=0x2C. + + type Test struct { + Field `validate:"excludesall=,"` // BAD! Do not include a comma. + Field `validate:"excludesall=0x2C"` // GOOD! Use the UTF-8 hex representation. + } + +Pipe ("|") is the default separator of validation tags. If you wish to +have a pipe included within the parameter i.e. excludesall=| you will need to +use the UTF-8 hex representation 0x7C, which is replaced in the code as a pipe, +so the above will become excludesall=0x7C + + type Test struct { + Field `validate:"excludesall=|"` // BAD! Do not include a a pipe! + Field `validate:"excludesall=0x7C"` // GOOD! Use the UTF-8 hex representation. + } + + +Baked In Validators and Tags + +Here is a list of the current built in validators: + + +Skip Field + +Tells the validation to skip this struct field; this is particularly +handy in ignoring embedded structs from being validated. (Usage: -) + Usage: - + + +Or Operator + +This is the 'or' operator allowing multiple validators to be used and +accepted. (Usage: rbg|rgba) <-- this would allow either rgb or rgba +colors to be accepted. This can also be combined with 'and' for example +( Usage: omitempty,rgb|rgba) + + Usage: | + +StructOnly + +When a field that is a nested struct is encountered, and contains this flag +any validation on the nested struct will be run, but none of the nested +struct fields will be validated. This is usefull if inside of you program +you know the struct will be valid, but need to verify it has been assigned. +NOTE: only "required" and "omitempty" can be used on a struct itself. + + Usage: structonly + +NoStructLevel + +Same as structonly tag except that any struct level validations will not run. + + Usage: nostructlevel + +Omit Empty + +Allows conditional validation, for example if a field is not set with +a value (Determined by the "required" validator) then other validation +such as min or max won't run, but if a value is set validation will run. + + Usage: omitempty + +Dive + +This tells the validator to dive into a slice, array or map and validate that +level of the slice, array or map with the validation tags that follow. +Multidimensional nesting is also supported, each level you wish to dive will +require another dive tag. + + Usage: dive + +Example #1 + + [][]string with validation tag "gt=0,dive,len=1,dive,required" + // gt=0 will be applied to [] + // len=1 will be applied to []string + // required will be applied to string + +Example #2 + + [][]string with validation tag "gt=0,dive,dive,required" + // gt=0 will be applied to [] + // []string will be spared validation + // required will be applied to string + +Required + +This validates that the value is not the data types default zero value. +For numbers ensures value is not zero. For strings ensures value is +not "". For slices, maps, pointers, interfaces, channels and functions +ensures the value is not nil. + + Usage: required + +Length + +For numbers, length will ensure that the value is +equal to the parameter given. For strings, it checks that +the string length is exactly that number of characters. For slices, +arrays, and maps, validates the number of items. + + Usage: len=10 + +Maximum + +For numbers, max will ensure that the value is +less than or equal to the parameter given. For strings, it checks +that the string length is at most that number of characters. For +slices, arrays, and maps, validates the number of items. + + Usage: max=10 + +Minimum + +For numbers, min will ensure that the value is +greater or equal to the parameter given. For strings, it checks that +the string length is at least that number of characters. For slices, +arrays, and maps, validates the number of items. + + Usage: min=10 + +Equals + +For strings & numbers, eq will ensure that the value is +equal to the parameter given. For slices, arrays, and maps, +validates the number of items. + + Usage: eq=10 + +Not Equal + +For strings & numbers, ne will ensure that the value is not +equal to the parameter given. For slices, arrays, and maps, +validates the number of items. + + Usage: ne=10 + +Greater Than + +For numbers, this will ensure that the value is greater than the +parameter given. For strings, it checks that the string length +is greater than that number of characters. For slices, arrays +and maps it validates the number of items. + +Example #1 + + Usage: gt=10 + +Example #2 (time.Time) + +For time.Time ensures the time value is greater than time.Now.UTC(). + + Usage: gt + +Greater Than or Equal + +Same as 'min' above. Kept both to make terminology with 'len' easier. + + +Example #1 + + Usage: gte=10 + +Example #2 (time.Time) + +For time.Time ensures the time value is greater than or equal to time.Now.UTC(). + + Usage: gte + +Less Than + +For numbers, this will ensure that the value is less than the parameter given. +For strings, it checks that the string length is less than that number of +characters. For slices, arrays, and maps it validates the number of items. + +Example #1 + + Usage: lt=10 + +Example #2 (time.Time) +For time.Time ensures the time value is less than time.Now.UTC(). + + Usage: lt + +Less Than or Equal + +Same as 'max' above. Kept both to make terminology with 'len' easier. + +Example #1 + + Usage: lte=10 + +Example #2 (time.Time) + +For time.Time ensures the time value is less than or equal to time.Now.UTC(). + + Usage: lte + +Field Equals Another Field + +This will validate the field value against another fields value either within +a struct or passed in field. + +Example #1: + + // Validation on Password field using: + Usage: eqfield=ConfirmPassword + +Example #2: + + // Validating by field: + validate.FieldWithValue(password, confirmpassword, "eqfield") + +Field Equals Another Field (relative) + +This does the same as eqfield except that it validates the field provided relative +to the top level struct. + + Usage: eqcsfield=InnerStructField.Field) + +Field Does Not Equal Another Field + +This will validate the field value against another fields value either within +a struct or passed in field. + +Examples: + + // Confirm two colors are not the same: + // + // Validation on Color field: + Usage: nefield=Color2 + + // Validating by field: + validate.FieldWithValue(color1, color2, "nefield") + +Field Does Not Equal Another Field (relative) + +This does the same as nefield except that it validates the field provided +relative to the top level struct. + + Usage: necsfield=InnerStructField.Field + +Field Greater Than Another Field + +Only valid for Numbers and time.Time types, this will validate the field value +against another fields value either within a struct or passed in field. +usage examples are for validation of a Start and End date: + +Example #1: + + // Validation on End field using: + validate.Struct Usage(gtfield=Start) + +Example #2: + + // Validating by field: + validate.FieldWithValue(start, end, "gtfield") + + +Field Greater Than Another Relative Field + +This does the same as gtfield except that it validates the field provided +relative to the top level struct. + + Usage: gtcsfield=InnerStructField.Field + +Field Greater Than or Equal To Another Field + +Only valid for Numbers and time.Time types, this will validate the field value +against another fields value either within a struct or passed in field. +usage examples are for validation of a Start and End date: + +Example #1: + + // Validation on End field using: + validate.Struct Usage(gtefield=Start) + +Example #2: + + // Validating by field: + validate.FieldWithValue(start, end, "gtefield") + +Field Greater Than or Equal To Another Relative Field + +This does the same as gtefield except that it validates the field provided relative +to the top level struct. + + Usage: gtecsfield=InnerStructField.Field + +Less Than Another Field + +Only valid for Numbers and time.Time types, this will validate the field value +against another fields value either within a struct or passed in field. +usage examples are for validation of a Start and End date: + +Example #1: + + // Validation on End field using: + validate.Struct Usage(ltfield=Start) + +Example #2: + + // Validating by field: + validate.FieldWithValue(start, end, "ltfield") + +Less Than Another Relative Field + +This does the same as ltfield except that it validates the field provided relative +to the top level struct. + + Usage: ltcsfield=InnerStructField.Field + +Less Than or Equal To Another Field + +Only valid for Numbers and time.Time types, this will validate the field value +against another fields value either within a struct or passed in field. +usage examples are for validation of a Start and End date: + +Example #1: + + // Validation on End field using: + validate.Struct Usage(ltefield=Start) + +Example #2: + + // Validating by field: + validate.FieldWithValue(start, end, "ltefield") + +Less Than or Equal To Another Relative Field + +This does the same as ltefield except that it validates the field provided relative +to the top level struct. + + Usage: ltecsfield=InnerStructField.Field + +Alpha Only + +This validates that a string value contains ASCII alpha characters only + + Usage: alpha + +Alphanumeric + +This validates that a string value contains ASCII alphanumeric characters only + + Usage: alphanum + +Alpha Unicode + +This validates that a string value contains unicode alpha characters only + + Usage: alphaunicode + +Alphanumeric Unicode + +This validates that a string value contains unicode alphanumeric characters only + + Usage: alphanumunicode + +Numeric + +This validates that a string value contains a basic numeric value. +basic excludes exponents etc... + + Usage: numeric + +Hexadecimal String + +This validates that a string value contains a valid hexadecimal. + + Usage: hexadecimal + +Hexcolor String + +This validates that a string value contains a valid hex color including +hashtag (#) + + Usage: hexcolor + +RGB String + +This validates that a string value contains a valid rgb color + + Usage: rgb + +RGBA String + +This validates that a string value contains a valid rgba color + + Usage: rgba + +HSL String + +This validates that a string value contains a valid hsl color + + Usage: hsl + +HSLA String + +This validates that a string value contains a valid hsla color + + Usage: hsla + +E-mail String + +This validates that a string value contains a valid email +This may not conform to all possibilities of any rfc standard, but neither +does any email provider accept all posibilities. + + Usage: email + +URL String + +This validates that a string value contains a valid url +This will accept any url the golang request uri accepts but must contain +a schema for example http:// or rtmp:// + + Usage: url + +URI String + +This validates that a string value contains a valid uri +This will accept any uri the golang request uri accepts + + Usage: uri + +Base64 String + +This validates that a string value contains a valid base64 value. +Although an empty string is valid base64 this will report an empty string +as an error, if you wish to accept an empty string as valid you can use +this with the omitempty tag. + + Usage: base64 + +Contains + +This validates that a string value contains the substring value. + + Usage: contains=@ + +Contains Any + +This validates that a string value contains any Unicode code points +in the substring value. + + Usage: containsany=!@#? + +Contains Rune + +This validates that a string value contains the supplied rune value. + + Usage: containsrune=@ + +Excludes + +This validates that a string value does not contain the substring value. + + Usage: excludes=@ + +Excludes All + +This validates that a string value does not contain any Unicode code +points in the substring value. + + Usage: excludesall=!@#? + +Excludes Rune + +This validates that a string value does not contain the supplied rune value. + + Usage: excludesrune=@ + +International Standard Book Number + +This validates that a string value contains a valid isbn10 or isbn13 value. + + Usage: isbn + +International Standard Book Number 10 + +This validates that a string value contains a valid isbn10 value. + + Usage: isbn10 + +International Standard Book Number 13 + +This validates that a string value contains a valid isbn13 value. + + Usage: isbn13 + + +Universally Unique Identifier UUID + +This validates that a string value contains a valid UUID. + + Usage: uuid + +Universally Unique Identifier UUID v3 + +This validates that a string value contains a valid version 3 UUID. + + Usage: uuid3 + +Universally Unique Identifier UUID v4 + +This validates that a string value contains a valid version 4 UUID. + + Usage: uuid4 + +Universally Unique Identifier UUID v5 + +This validates that a string value contains a valid version 5 UUID. + + Usage: uuid5 + +ASCII + +This validates that a string value contains only ASCII characters. +NOTE: if the string is blank, this validates as true. + + Usage: ascii + +Printable ASCII + +This validates that a string value contains only printable ASCII characters. +NOTE: if the string is blank, this validates as true. + + Usage: printascii + +Multi-Byte Characters + +This validates that a string value contains one or more multibyte characters. +NOTE: if the string is blank, this validates as true. + + Usage: multibyte + +Data URL + +This validates that a string value contains a valid DataURI. +NOTE: this will also validate that the data portion is valid base64 + + Usage: datauri + +Latitude + +This validates that a string value contains a valid latitude. + + Usage: latitude + +Longitude + +This validates that a string value contains a valid longitude. + + Usage: longitude + +Social Security Number SSN + +This validates that a string value contains a valid U.S. Social Security Number. + + Usage: ssn + +Internet Protocol Address IP + +This validates that a string value contains a valid IP Adress. + + Usage: ip + +Internet Protocol Address IPv4 + +This validates that a string value contains a valid v4 IP Adress. + + Usage: ipv4 + +Internet Protocol Address IPv6 + +This validates that a string value contains a valid v6 IP Adress. + + Usage: ipv6 + +Classless Inter-Domain Routing CIDR + +This validates that a string value contains a valid CIDR Adress. + + Usage: cidr + +Classless Inter-Domain Routing CIDRv4 + +This validates that a string value contains a valid v4 CIDR Adress. + + Usage: cidrv4 + +Classless Inter-Domain Routing CIDRv6 + +This validates that a string value contains a valid v6 CIDR Adress. + + Usage: cidrv6 + +Transmission Control Protocol Address TCP + +This validates that a string value contains a valid resolvable TCP Adress. + + Usage: tcp_addr + +Transmission Control Protocol Address TCPv4 + +This validates that a string value contains a valid resolvable v4 TCP Adress. + + Usage: tcp4_addr + +Transmission Control Protocol Address TCPv6 + +This validates that a string value contains a valid resolvable v6 TCP Adress. + + Usage: tcp6_addr + +User Datagram Protocol Address UDP + +This validates that a string value contains a valid resolvable UDP Adress. + + Usage: udp_addr + +User Datagram Protocol Address UDPv4 + +This validates that a string value contains a valid resolvable v4 UDP Adress. + + Usage: udp4_addr + +User Datagram Protocol Address UDPv6 + +This validates that a string value contains a valid resolvable v6 UDP Adress. + + Usage: udp6_addr + +Internet Protocol Address IP + +This validates that a string value contains a valid resolvable IP Adress. + + Usage: ip_addr + +Internet Protocol Address IPv4 + +This validates that a string value contains a valid resolvable v4 IP Adress. + + Usage: ip4_addr + +Internet Protocol Address IPv6 + +This validates that a string value contains a valid resolvable v6 IP Adress. + + Usage: ip6_addr + +Unix domain socket end point Address + +This validates that a string value contains a valid Unix Adress. + + Usage: unix_addr + +Media Access Control Address MAC + +This validates that a string value contains a valid MAC Adress. + + Usage: mac + +Note: See Go's ParseMAC for accepted formats and types: + + http://golang.org/src/net/mac.go?s=866:918#L29 + +Alias Validators and Tags + +NOTE: When returning an error, the tag returned in "FieldError" will be +the alias tag unless the dive tag is part of the alias. Everything after the +dive tag is not reported as the alias tag. Also, the "ActualTag" in the before +case will be the actual tag within the alias that failed. + +Here is a list of the current built in alias tags: + + "iscolor" + alias is "hexcolor|rgb|rgba|hsl|hsla" (Usage: iscolor) + +Validator notes: + + regex + a regex validator won't be added because commas and = signs can be part + of a regex which conflict with the validation definitions. Although + workarounds can be made, they take away from using pure regex's. + Furthermore it's quick and dirty but the regex's become harder to + maintain and are not reusable, so it's as much a programming philosiphy + as anything. + + In place of this new validator functions should be created; a regex can + be used within the validator function and even be precompiled for better + efficiency within regexes.go. + + And the best reason, you can submit a pull request and we can keep on + adding to the validation library of this package! + +Panics + +This package panics when bad input is provided, this is by design, bad code like +that should not make it to production. + + type Test struct { + TestField string `validate:"nonexistantfunction=1"` + } + + t := &Test{ + TestField: "Test" + } + + validate.Struct(t) // this will panic +*/ +package validator diff --git a/vendor/gopkg.in/go-playground/validator.v9/errors.go b/vendor/gopkg.in/go-playground/validator.v9/errors.go new file mode 100644 index 0000000000..820b4bdad8 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/errors.go @@ -0,0 +1,270 @@ +package validator + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + ut "github.com/go-playground/universal-translator" +) + +const ( + fieldErrMsg = "Key: '%s' Error:Field validation for '%s' failed on the '%s' tag" +) + +// ValidationErrorsTranslations is the translation return type +type ValidationErrorsTranslations map[string]string + +// InvalidValidationError describes an invalid argument passed to +// `Struct`, `StructExcept`, StructPartial` or `Field` +type InvalidValidationError struct { + Type reflect.Type +} + +// Error returns InvalidValidationError message +func (e *InvalidValidationError) Error() string { + + if e.Type == nil { + return "validator: (nil)" + } + + return "validator: (nil " + e.Type.String() + ")" +} + +// ValidationErrors is an array of FieldError's +// for use in custom error messages post validation. +type ValidationErrors []FieldError + +// Error is intended for use in development + debugging and not intended to be a production error message. +// It allows ValidationErrors to subscribe to the Error interface. +// All information to create an error message specific to your application is contained within +// the FieldError found within the ValidationErrors array +func (ve ValidationErrors) Error() string { + + buff := bytes.NewBufferString("") + + var fe *fieldError + + for i := 0; i < len(ve); i++ { + + fe = ve[i].(*fieldError) + buff.WriteString(fe.Error()) + buff.WriteString("\n") + } + + return strings.TrimSpace(buff.String()) +} + +// Translate translates all of the ValidationErrors +func (ve ValidationErrors) Translate(ut ut.Translator) ValidationErrorsTranslations { + + trans := make(ValidationErrorsTranslations) + + var fe *fieldError + + for i := 0; i < len(ve); i++ { + fe = ve[i].(*fieldError) + + // // in case an Anonymous struct was used, ensure that the key + // // would be 'Username' instead of ".Username" + // if len(fe.ns) > 0 && fe.ns[:1] == "." { + // trans[fe.ns[1:]] = fe.Translate(ut) + // continue + // } + + trans[fe.ns] = fe.Translate(ut) + } + + return trans +} + +// FieldError contains all functions to get error details +type FieldError interface { + + // returns the validation tag that failed. if the + // validation was an alias, this will return the + // alias name and not the underlying tag that failed. + // + // eg. alias "iscolor": "hexcolor|rgb|rgba|hsl|hsla" + // will return "iscolor" + Tag() string + + // returns the validation tag that failed, even if an + // alias the actual tag within the alias will be returned. + // If an 'or' validation fails the entire or will be returned. + // + // eg. alias "iscolor": "hexcolor|rgb|rgba|hsl|hsla" + // will return "hexcolor|rgb|rgba|hsl|hsla" + ActualTag() string + + // returns the namespace for the field error, with the tag + // name taking precedence over the fields actual name. + // + // eq. JSON name "User.fname" see ActualNamespace for comparison + // + // NOTE: this field can be blank when validating a single primitive field + // using validate.Field(...) as there is no way to extract it's name + Namespace() string + + // returns the namespace for the field error, with the fields + // actual name. + // + // eq. "User.FirstName" see Namespace for comparison + // + // NOTE: this field can be blank when validating a single primitive field + // using validate.Field(...) as there is no way to extract it's name + StructNamespace() string + + // returns the fields name with the tag name taking precedence over the + // fields actual name. + // + // eq. JSON name "fname" + // see ActualField for comparison + Field() string + + // returns the fields actual name from the struct, when able to determine. + // + // eq. "FirstName" + // see Field for comparison + StructField() string + + // returns the actual fields value in case needed for creating the error + // message + Value() interface{} + + // returns the param value, in string form for comparison; this will also + // help with generating an error message + Param() string + + // Kind returns the Field's reflect Kind + // + // eg. time.Time's kind is a struct + Kind() reflect.Kind + + // Type returns the Field's reflect Type + // + // // eg. time.Time's type is time.Time + Type() reflect.Type + + // returns the FieldError's translated error + // from the provided 'ut.Translator' and registered 'TranslationFunc' + // + // NOTE: is not registered translation can be found it returns the same + // as calling fe.Error() + Translate(ut ut.Translator) string +} + +// compile time interface checks +var _ FieldError = new(fieldError) +var _ error = new(fieldError) + +// fieldError contains a single field's validation error along +// with other properties that may be needed for error message creation +// it complies with the FieldError interface +type fieldError struct { + v *Validate + tag string + actualTag string + ns string + structNs string + fieldLen uint8 + structfieldLen uint8 + value interface{} + param string + kind reflect.Kind + typ reflect.Type +} + +// Tag returns the validation tag that failed. +func (fe *fieldError) Tag() string { + return fe.tag +} + +// ActualTag returns the validation tag that failed, even if an +// alias the actual tag within the alias will be returned. +func (fe *fieldError) ActualTag() string { + return fe.actualTag +} + +// Namespace returns the namespace for the field error, with the tag +// name taking precedence over the fields actual name. +func (fe *fieldError) Namespace() string { + return fe.ns +} + +// StructNamespace returns the namespace for the field error, with the fields +// actual name. +func (fe *fieldError) StructNamespace() string { + return fe.structNs +} + +// Field returns the fields name with the tag name taking precedence over the +// fields actual name. +func (fe *fieldError) Field() string { + + return fe.ns[len(fe.ns)-int(fe.fieldLen):] + // // return fe.field + // fld := fe.ns[len(fe.ns)-int(fe.fieldLen):] + + // log.Println("FLD:", fld) + + // if len(fld) > 0 && fld[:1] == "." { + // return fld[1:] + // } + + // return fld +} + +// returns the fields actual name from the struct, when able to determine. +func (fe *fieldError) StructField() string { + // return fe.structField + return fe.structNs[len(fe.structNs)-int(fe.structfieldLen):] +} + +// Value returns the actual fields value in case needed for creating the error +// message +func (fe *fieldError) Value() interface{} { + return fe.value +} + +// Param returns the param value, in string form for comparison; this will +// also help with generating an error message +func (fe *fieldError) Param() string { + return fe.param +} + +// Kind returns the Field's reflect Kind +func (fe *fieldError) Kind() reflect.Kind { + return fe.kind +} + +// Type returns the Field's reflect Type +func (fe *fieldError) Type() reflect.Type { + return fe.typ +} + +// Error returns the fieldError's error message +func (fe *fieldError) Error() string { + return fmt.Sprintf(fieldErrMsg, fe.ns, fe.Field(), fe.tag) +} + +// Translate returns the FieldError's translated error +// from the provided 'ut.Translator' and registered 'TranslationFunc' +// +// NOTE: is not registered translation can be found it returns the same +// as calling fe.Error() +func (fe *fieldError) Translate(ut ut.Translator) string { + + m, ok := fe.v.transTagFunc[ut] + if !ok { + return fe.Error() + } + + fn, ok := m[fe.tag] + if !ok { + return fe.Error() + } + + return fn(ut, fe) +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/examples_test.go b/vendor/gopkg.in/go-playground/validator.v9/examples_test.go new file mode 100644 index 0000000000..3f4df7e973 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/examples_test.go @@ -0,0 +1,83 @@ +package validator_test + +// import ( +// "fmt" + +// "gopkg.in/go-playground/validator.v8" +// ) + +// func ExampleValidate_new() { +// config := &validator.Config{TagName: "validate"} + +// validator.New(config) +// } + +// func ExampleValidate_field() { +// // This should be stored somewhere globally +// var validate *validator.Validate + +// config := &validator.Config{TagName: "validate"} + +// validate = validator.New(config) + +// i := 0 +// errs := validate.Field(i, "gt=1,lte=10") +// err := errs.(validator.ValidationErrors)[""] +// fmt.Println(err.Field) +// fmt.Println(err.Tag) +// fmt.Println(err.Kind) // NOTE: Kind and Type can be different i.e. time Kind=struct and Type=time.Time +// fmt.Println(err.Type) +// fmt.Println(err.Param) +// fmt.Println(err.Value) +// //Output: +// // +// //gt +// //int +// //int +// //1 +// //0 +// } + +// func ExampleValidate_struct() { +// // This should be stored somewhere globally +// var validate *validator.Validate + +// config := &validator.Config{TagName: "validate"} + +// validate = validator.New(config) + +// type ContactInformation struct { +// Phone string `validate:"required"` +// Street string `validate:"required"` +// City string `validate:"required"` +// } + +// type User struct { +// Name string `validate:"required,excludesall=!@#$%^&*()_+-=:;?/0x2C"` // 0x2C = comma (,) +// Age int8 `validate:"required,gt=0,lt=150"` +// Email string `validate:"email"` +// ContactInformation []*ContactInformation +// } + +// contactInfo := &ContactInformation{ +// Street: "26 Here Blvd.", +// City: "Paradeso", +// } + +// user := &User{ +// Name: "Joey Bloggs", +// Age: 31, +// Email: "joeybloggs@gmail.com", +// ContactInformation: []*ContactInformation{contactInfo}, +// } + +// errs := validate.Struct(user) +// for _, v := range errs.(validator.ValidationErrors) { +// fmt.Println(v.Field) // Phone +// fmt.Println(v.Tag) // required +// //... and so forth +// //Output: +// //Phone +// //required +// } +// } diff --git a/vendor/gopkg.in/go-playground/validator.v9/field_level.go b/vendor/gopkg.in/go-playground/validator.v9/field_level.go new file mode 100644 index 0000000000..6d73192579 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/field_level.go @@ -0,0 +1,69 @@ +package validator + +import "reflect" + +// FieldLevel contains all the information and helper functions +// to validate a field +type FieldLevel interface { + + // returns the top level struct, if any + Top() reflect.Value + + // returns the current fields parent struct, if any or + // the comparison value if called 'VarWithValue' + Parent() reflect.Value + + // returns current field for validation + Field() reflect.Value + + // returns the field's name with the tag + // name takeing precedence over the fields actual name. + FieldName() string + + // returns the struct field's name + StructFieldName() string + + // returns param for validation against current field + Param() string + + // ExtractType gets the actual underlying type of field value. + // It will dive into pointers, customTypes and return you the + // underlying value and it's kind. + ExtractType(field reflect.Value) (value reflect.Value, kind reflect.Kind, nullable bool) + + // traverses the parent struct to retrieve a specific field denoted by the provided namespace + // in the param and returns the field, field kind and whether is was successful in retrieving + // the field at all. + // + // NOTE: when not successful ok will be false, this can happen when a nested struct is nil and so the field + // could not be retrieved because it didn't exist. + GetStructFieldOK() (reflect.Value, reflect.Kind, bool) +} + +var _ FieldLevel = new(validate) + +// Field returns current field for validation +func (v *validate) Field() reflect.Value { + return v.flField +} + +// FieldName returns the field's name with the tag +// name takeing precedence over the fields actual name. +func (v *validate) FieldName() string { + return v.cf.altName +} + +// StructFieldName returns the struct field's name +func (v *validate) StructFieldName() string { + return v.cf.name +} + +// Param returns param for validation against current field +func (v *validate) Param() string { + return v.ct.param +} + +// GetStructFieldOK returns Param returns param for validation against current field +func (v *validate) GetStructFieldOK() (reflect.Value, reflect.Kind, bool) { + return v.getStructFieldOKInternal(v.slflParent, v.ct.param) +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/logo.png b/vendor/gopkg.in/go-playground/validator.v9/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..355000f5247d50e979cf5db5de38188ef4649a34 GIT binary patch literal 13443 zcmbVz^LHiB^LK39wrv|5-`KWoTN~T9%?&s9Mte8f*xWeZ`~Lg^&kxU>)6-|>Om|IH zcUM=vsybFxSr!?A009gP3|U@IN*z>Z{#W2&KzAW<*L_e0I`lYd#@osT8GH952<>}$=#%H%txCM^!YLYIPG*~?*PoX}XfpXD#$r$vg% zUJ@M8Sa6}E0bs?J()q&Aj2!Xx^!*X7wf45!j09TZ!t8tmiZrhYa~rM!hkOgG3jNOL z$t%hsiEZp{`uZS=pUq3db%5@e>LpqUR%RzF4Fp&XYtszH3NMj(x&yBfN!B@dDe(i*$ zFaI9z`VK(*+SzZ3Km$V|gFS(NfPUS&ND}#zKM&MsZR;zy@SJwDwy5moK{eH84yz0`{Dhd+jynpps_Wzr*Rl)ctU%7jk!=>D(g}(sK zP}YV(B1|d_4NeR~4qlx?36qk5ng9u-wt+@fOTlvqhk>WQ%HxtjxBspSS(-6OpP;_x z73LX72W9oA=yUj&B*sjt0z}2U44ACNztdo!tbwR&pl8vCLjf!@HDwcP;p{h$JYsrk zE3Pp7L^A>!xwNPSX+2zrQgJ8|CCr11n`u|=C}{? zlHLN%{DxBD;+;&!6Se$BciUB@EQ~Y8_ZT-Q&4p}|A3l`R=AVR9Kt+V~a3a3V{l=)gHBK2op+X}BW7o(X1K2eRTZ^; ziO?#OmuWkXeCj2*{H(1C#qnQ>tz|Kq>*#cF7g)+?3G3(pVB@N37)9YHmYxa}CVb-% z@SHf5CnrEMiI6-&fkkOb9ema$%-Ld}qN54xNf|CDt?#e@Aec&IEcEEpu3Ak5Y z>0@s)b7yHEr~UCsek0JVuF%66MBgBxj-d!wQu4Evlx;p|pZG{&=4VV)*pIE{{f=SO z;V$)QC5ae=-6(Nc68{(S;2ymNVxIiwAs9}A@vA2?55kfV(qK>S6caF|bywd&p8ydL zB}xJ~6Di7u^Xl{s1E&b!{FXH0#>1$=MTNA7+vd;Pm*#B`iYRecX>5H7^iqDqQ{GQH zKNNh0?p}h?nEjh_Ft*^M`+(a;L*rKgPp=E!!}stvVxG|YKY=Yh25?+RloCoyT3T~2 zr1!?YL58}YTlyj1sTl_H(oBl48zJPwJFr9|r(>T7Npe$Hyl7Pm(dZ}|x;n!X(4wtZ zeNCCz4LTygy(gl;pV;dp+-Lpq=weiOW2Z_Lt@RNd_s43tZ>$@23^%6`T}rfexq!%# z)e|oR;kRY~2fW@V(in6QZzE*6TubN0<>|v2xiX)v6->d$no+&np8 z=DZPj>yPVL2Y2U^MJuW`R8R{2@Rg&}`S+$yEgsGihuW$3 z2y*A5Rm-TCh*xaY#R1q)HfzQS_%fPHCL7200}u=S#u`m zvW%z6F_UcmBq~g~s|d}v6$Q?noL`Z(X;@Q$i>kw^bF}I3A8QQyAE_nz-`H~a9o2}- ztPUs0q(DTZ^Yx3oA6C5I?{nHCX0qfW&C2r}h~~slhe!$_Hh1WB`w?_|D{JsF#zpgf z;F^yDTZs-$?`myzyDj@=x}@L4b~_KtUWzV+uiL${48Qh^ZdoywlRNR<*WLFY>v0fq zeWQS`g6{8q<#x){FrCbZlcTAh?+fw^gB-2LpRnlF^}`$D;(KxTOLn;dXs3Yl(uW$g6hyw3{wZdTVg|kdSet`n+SACG=!&%#r zl+Ha_MzD$G>iQb%tW~Uus7-zOMPI__Qo92dK3VKkGgR#;-!`uw++~l5J?MT+BUCv3 zcItfZO)uKXlipj1XD?F|>3frjQWA;$JV>TcHHrcrR=Ql;-B}Bb4;f|uVo(S7xL(QP zE%c8{bnchCJ%aG)3x8gx0`Hqq`eapfWqK`~Ec6Mea`v0{J?4~x(S2D#-7sMBR1X;{ zO-QlMUsyD!#jI^8v6y2J8TinHz_zsU@;3|?TfT0F2b2A7aX&aEQGc;IZ>UV*cToht z27rX9TA$h1ZMxk`KX|$6o$)=$PxIM3k^FhGmiJMaA3fBM6(M#efLJ9ucfbo2TkroP zxE4Dv?B_Nkef;0LYVj3nk|C9-MLv{y^-tY`SD(5phR2KMn}9@?I@SQ^#m* zu>9T8l>)311+yf)qc`Zp%3Cp9FS4PN18t5zZGy-!{f^5eJQA&Fb>Llf4kF^OZ}Tu z=jyadHyzlQLaf@_eAf{CFb}_v=Gj*BLc$VrMAe%hAL@6JaXkt^p&>`#SXjBAX!3#; zZ(sPdwtkoS08=HP@lruhHm*fIlu{y~LTu@+@;u*LBUU~nbQ7S{eH09xc5^_Xtu!q@ z6^P#P!A-(qwW30Th;TBWNp{b1+lP1D!2Y2In`HJ8=DTs8;1)Y~TE2Tco&agHaJGJRtE&{R2y^@Gnpny|$qxXc2=Ps$@$~9mxET{1Q$%i!i#frlzo0UOe_Y zMxNvLk98G99Jhl+-rMB_{OyQsE?70nTDUTZf%>P_;7WAz0a+FG*4EALUD*p3UWt_( z3yZrIM%L#2dleC=K}bD*)-@4195ctqtgM0iQACxJ?F&0O<{t?%^dK1pMJo*-dHj;E z%Vt=-^pa?Z(eb%_rx~$m@yuyvX^t!IvZZ&&LJtY`#;x+PXT-Gb~(3>gv;tf~4N37#aCX z-tW%A@AM^Cf&WBJl*|wp9s0RGq_rCL)=Klfe3e8BUY|7FGZM)#ZdT04zyZ#{*|<&8 z+dsxt9B+krqDfJbykPO==|6C|yAi)*jkV&C{Du7Y#drV0`{jGeFSFOANIz#B-ncz= zB?v}IR2j5eCJ`2>yNMN9<}h!(e$i><|KSPd(Ff^lC-7pg&G~QJ8T0JD-37gq1-K+V z;1?GW_CVrGX3V0m%yvW#+uGLl^01=9zyGrgZ5fJ6GeeULS25^4)YCL=-Z!w`r$tH= zj-ikdG|nI;y1wvvk2)h7^hL0Xvnxw)Y1u}&9Vv%k1};Z0IqW?AQ8)B@QOUa?ayt31 zX^`u?pa(0F6YpbrT;e2^auw#%0BX_ub?}_ieYF;4rGRd*1_vX-+Xv9I&yR@ zZF(3;`kXg0vHdTn$5Ie;gpS4@djPPJ60-Z_1?!DwQz9NO2jKDbkZ^oJbQVc?6v#&0 zAW|kWVx3>tw#eTFT> z$S^|&ZWo)7Lyes7r)@VL=2A|$JW1nr)ed9~F&(_uHC1f;YO_5oj&Afj!0(9M)7c*f z$rra8Ji?1Bc%e|v^CcS{(B7RRCc7Wrrs=I7)f#8IE{rDM)o~`?Y8!;pSaL!lLHCZ% z2RHV1+l?QSk}_AkH)`_s#(xKJ?jwKC`csy*aOGtV&`hmHIG<5hXtzm+=iQkb{pyZ< z%;RxAP~z<%lTo;vNWd4mn;*jW+1tVM*tJ0j)}5|LR4#M7r{PkXJaW;yHBr@9pIuiG z8V1M4Ci1&Z6T1I>(C@#6rJT=}4_MR%kp=0LFD)iInpDCFQ;rm ziA+yF-c%|NyQ8);!vM6)#xu8qylq9(nieBl!@e}S5}R@)8LEU)Q|o0z)Z3vP);l2n zvCG7gtlR2XtjF1}fhC?!r{BZ4#sNRJi-Kgt?Rd(rePR;wmE}rqM-z^#fA_=ptrRR~ zqS-A)prf=s19gdfPBn?#&j;!a+e1!wX7|RMt|@0KQ_^z7My)2imN}+? z&Ro$-#EC#FN(11}WJ|$X)eQ0hf7Xye3AhvowX$0|1+x+uY~g?ccTKswq+io;vFNd6 zr7#C9z4;>@b-tg$UzV@9U5hK{mDW{6%YjDa>FJu9Z8hZyN}pshPN=W>uI!^Q$kMqm z+}IiQA9sdYvoB1IiBfX#m0axM;6c8}N>K$tD8kW56>r1h5t8J!3X0YAj1|Aw&~l@A zxf2^V`F;A0W?i!7*yQ+#;?4!!1ZQrBEI$9+-N z6P_sTrV&}s7MX}77Nq}~KmQy&5T&0ZWX--y(<$MEOLGIm!7k)jQOWggN0!Rg^`Bj3z7;;PquhhFnoqJeAbUfHR~d2;C{_De_Ogp81i65*qU(X5fweyv+B#w>RW0 zm&_w7Zm z`YWfGxm^7MK^A>0nDITy;gz^Lzudv@BC>+^JOVExD%|?aa0W#9qe``&CHjF6vqV zB8&tSqdhz{r4(|w3!g-DZKg>^k=!a74kk`D{P(2>&R~8kXP)^Ns3jTlnM7|b=I@?W z*3YW^eW^H83@t)lUE4LAm#(ICbAZTgW?ohHU;Ok91QJvMGp6fHL|&TQb|ICaXi{OO zrD__`B5>e)a6orX^!P5CsJZqQhI9-E6v4*!cC1vUi2?G|44quG+rfLS+7ZX;meFoT zMa+fb0pH+x{|o<7L^;cM5J4}K*7m~l#N2_qa(YL%G9rt7(fo;z(CaJOODkCKPA9`Bop?dIYFl3wBU&l zdqN~tz4k#i1&+HT_N>0Qm%uxG;}xqfaciIXXK|67VNTu0yzMz6pt6)m~ z7y^EZ+(wMlK9yMiwkhp&>cmXQoRzGf`o{MmkrGaxJY*%s0Dza_WczOvC8IXtY4zGE zoAfaSy~MQoF^;l5RWb}DJq*S_&wp|_lkCAaR~iQkooeXo>yX+1hRw(?%#&k0 zm|IG1?>%mpBmLr(*DC>|Vr>bN;nKsdZLlS4*_h%G1n`;;6|sE0rg^T9KG)Swoz!z& zJra776~H1@daS@C;jzI*0~;x5(E1Fpo!nLAV=SmM;Q>*#bxdaC<;wO{!IV4ONwN}f z8NK=|T>UjQ5%%_C3KAVb1}wC~Feno-GH|l>&?HI*RX~t*0XtJ~S0R6Kst$kD*7mw& z{mR31-KopNO5bKJqku0*PjnBKFE_1y_|tmDtiN7SF!NZpwNb5#sV6w^bu9#1B5K7# z0N}))422cqc#^(uW?wJU*^KLe?VU&(*c6j;U6^LZcQoK4POU1{yKSH^?k2$VGLEWB zog!7!3_Kl%apr)=%d3Rpw_4BDLZf!1tIdN&D;Yg?X2&jp0vSBqbz)XX`Wu2%`IWJS1s3lhZ7H--?PJxQLg$XONw$8qE z@4G(S5}8yFwM`{Rdz9E__ZH{{Gusj%$t#w4+ac&G3wkM0n&qZPP}J9r*av-Zq- z%NdhH1sgs~Oq9{PLkkxDiK6MQo36OTZrr&F7k6+F*a}5hV<;1u+B`QQSF#ti5`pI3 z@gvRFovLjNAri8~54co-plD$yQSX*b95r9t@B%~eI2r9NqXw{mGRKtdG5*|wk~yO zW)?msL*Rlpy{X4OLKx;RTX5`t1RY4!(bJ`a7rJ?=xM7fwcCL;k7j%-*cj9NLfbojM= zsFk;>hWcz(m*MFBO66YXrs>D4!BqdqWy_oZ>c&}P@|L*1a zVk(-?<3wy?;t9XLM*dyTj^XbicaVIM%BJouomO8jaqzV51LbTf>Ywq=#cXFtO*-oC z$O(ezf}G*);p^d{5Cc9apUxWE7RHp-F$ne9h?~C!5ok6%glp3JFOLJd2A-Fm@I}Id-s z30mMGUBh}2LTd&+z4*b8fB8hNy+ke`kmJbFXYm9=Ud96znCvs;Xa*GB`{*jEPp($~+DX+RP*)$prD03Z~ zot>}r&YE}7>5Wkie5E(*NC^ihU`EdF6Ezw%Y_=C72{{2}2gipm z*Kp)Aa`c2J&xYYZ876z^z{Zt5pR2|?72(fT&g8MYt4OgJ8>+ZDr_oB=>9xhEw%27Y zdZWI$a9GrD@5Los+iFbyl507c-TMRH3x)MMT{uczOKy3!ra7;z>2})#CRqJW`Jr@s z)uA36KCgr8c)q);G>N2B3p4kyV4NWuoxzls;Xqq+eg~fI$A3otuea;KAQGd#L@`_H zA12vy0BVLhln8XMstlX5M43pjjcZzAO3GUc$zV-2^wq;7JE(EwPLoa!*2(XgxwSlx z2_J0xvN3`hnHWW^kuO7z`%AW8B~t4yhgSPHzS%y%$=}V7s+fZJ0#{k0^O+*L0|Zg4 zfX#xMrgl!s6Xo=iNk_&jq83fy!YAvDSuT8GO6%m58Pi*2YUR|;TQb;TdN=rqTpKIZ z-p&;$N{lIA6N##--%mV~CtEEa4=)@J`4YoT@$9}xH&qcX>lvW>wj*s%n1(JbS$r*d zK9ca~LMdTQ7v!Y34Q6Zh;50&tLX-E@$j3m@9%{iLEyrjeeM_lyMFuI6_pPMcUemdp z%6;iM!PP84B5GQ70B|+R^|BqipYC7_%BZRXP;eo#KZ6EBvBzlpn}@P3p}|8#I(4 zul0x<>TxI(s0g?8v|a89+n1)Jx##kH*g@FY*niUw?{Sqmm)Xi-;WBKlUieBT&& zR3bfdZ|yI{!e~+H2q@uF@=N3k*$H|RZpj@5hvmw~_Py+wV14-k8ynOVi-{@1gB;!g zop(C8F2W!)$gD|@VYtF3M2`gl44ny?45baF7yCBl4PB@{E_nNFz6{2b zr3nxXdd~S*FLLzzO#wytqw(3PI0_%D56fEkMQPca=JX$gqH9aJ{ZpKvk8&kz zVxpVpl56nj^P5R4Lm_KK_6WeFW0cD?IY zZu%H?$YfA5eBYF>2g^}+ig>LD^PgW_C#jRJ$|LNXlubK_b)pT9uqy)nlg?;4DG*(P@1w56aN4^TZM6bWUyCM1*1Czy}HIA#1w25=*y73 z^<0dmnQg(qFmL~t3lPYXx1H8~Zxg@d(x{4t40F=4{->PSRp{RzUszJHDlXejc7G)lY;8~fKsU-hk(590&9v& zFxr}ZKJqco?V2qb5bnkeLoQVbyu32=?$Kwh?;N0OiGN|7=6`RkdoJ(JT@djZ8dUCb za?z#~&v8Fm?V}L${Zr&aQ8JC0EF>X56u4pkjt-w^+1bG$r9f1OrJ$<6qE&iV7_}kN zQweT&?sbJOanV*#E0|bLjkCC(vOm|{V<5MsimhiSt-uxzjxz9SMUvMQK{`~RZ+v_m ztb%l8kCZHm@?oa?Mb$L;Bv2$(K*V=w5SD>$*ITQ!W*n%SOXJlQO>pLoRxLI#%aHpA zmYUE<8T)d$P6F=j$+`7W&dSV^FR;c5cvU=igm6$Q0Bz?EE|?msF@JEX89DoMOUuTr z`R{3)%|h-VtA7`wTgs8)s;PQ6$6IvQTsUzrO=Y6G!D)=Xx9w0$Gba6n1y?{dK@SoK ze54vzFH|9D2~QbpUTb_H)IYDfa|J}Lq9?%CFHbsIB8(vc1WUKbA`4uL=6b&iurle2 zi(4jg{2hA5K*7uKNnBA0KV4x*3NO0jb^QuEWV&39?%#Ve9aEQ)AWUUwycBSf_o%|` zTcm^fRU(B}U8I(N*#z&8fsGAkKpBAt5@UnRa>N{07@%qaw@bs$K2R5VP#c$2^Q%RQ zVuW0slT(*~U8kk?duR;_jOTpmwrrbx->n}JX^_|@zO|a)Ik@>X7HOQ(!z(#CF@`^7JGf2aEfn1S0v}oHKo%uVUMDjl3<>f#kD$hfw(^nW(aRB6AaG-TDAh%oHjEJ=J$;2s zNEtTUsuZa{ji(_8)1j8gUOb~B9fXBSc)M%Hfsu<`&aJGt{{#rePUQ zno1K;1#~H`?Rd#V$}MtvkS~UOgsP~@^u^u{ua{D3V=Fa{2IKwI7>|!cOUteP#X!Z_ z0=9Z(Y!#lhZpJ0TKxMl6%R?6~lt!EvNztb>dbADO5-ZkYS1f(TlqF6|c^Euh&Dojz z>7lTs0ClkTp5>|*~0 z_E{QdSna;}KOcu@*xbF3xyhffB&XIT`p{6hS*F))v#>=YEtJB9Cr*b2YtK$qd9@hS zP$+_%N43)URxgAF_fx!4#yRV$Y6W06mtQ<`6RwW>A*AaHVyEylR` z2)a@71;tKHeL9Ik*CB!~)Qw;=Fl6gGLG;?;LTeerep>@XsgVh4FN73z`?Z=yj9;v% zBxr{}l;h6)J_enD_Xs$w_!zAMpK(;B2{L7;9924=)DeQQG^=eR>S_sq&5Q6tF?!ZR z5Qknd!5HirCsnTIK}aSQLQ_)EQtb#JSG@QUVD}mpOr(idOXutsza|QP5K1WjdsWrs zkY855Sph`j8nzw^f)v# zwC?)Bwo9-}lWq~G9ow>)3->q?FnXQ<$)Y*Vq?hu8MmH8aL1yGrPXCBBQZxc2c}gM_ zazx&=nWtc(!DSU&y7M>VVWHK|f42Z4$ zgM>V`3TB$s+ZXAeFq65x>B{Mdc~^YySq_px;%mpmr2Huz$C}=8-KJN$50%RxgBJ`5 zP&~~O#I1B_1NXRe11=!ZG+8?m1fW)N1v3M~LuJCB_sLZ){E+CtNyJ{zEW!m2t6~4F z%H681*4phFkdH+Wb0LC&2rz`YF05QDpj#b^CS9c1iNN6yizQhsjIRb7ouDlN!>cKa zg7n0;K8z}XHxXi2Ecua32b&VylFo$*L~5$eud(~1>99o0y8R!-= zN_$<&9xytjEu>6segSMd2}6=@3VVB@GhvK>e5(3kr&=sV&}-F69b-m9?Ip^S&_1rK z)REQFT(LR2P6B9EqR$$Fjhw z@@PRbM9s{1I>jgtQ$A{Too_2xnL(GQD!IAjpSUUis4yB{sY$2}MT}d+!IfS_pu32*B z(%fM}`E)&K1vl5$L@*MaDwYf>96D4c;kb|PKTS;+YgrY9Ko@0Q)3$VlDZzF2D5qzp z3ooIC#iZNaZ8P4)aA|hlnC{a}TPrb~vTu2a+lFss)C;W1zZ926mndG{GXR|B)WfV} z(w*ugyn0Rs7_}^z1)X+M+)NXwrEUSMFwNFX_HD7RuV z!p-X54t?QhInx8)RxXg9Gk>_MaF-=XqAoa3dpy^>ZnMr+Cdt={MR4L zlI?2b=gsG3&Ijqpwy~pkv)Y=9n_|E|4ghMbhOV!U-CR;Kg+YdeFwVdfiyc*SZ33P= z$^Lo3LKgdGzEro#sbQm;1h}cbE=gD;VPV$RSAC(NX#P3$r*wNcQV1ac_8s?7<*v7Pd5{UE zcj<@b8s(}ugB+l6X(Y2RciZYZr@$lnh&EYVD&Q;@IV#m~)&N`>i%eC8QGg&uMXI=s zQLp~@6So9V;*{|ZngyWwRLWwzOCrXEh&`MazZ2wm)kNAKFDMMTX_jGA!oO_hJ-YRa z$^tLI^PHPVUu(o9eNPBKBkY8oY*JvIpawcN$Hq>rF`BD0kq%ngOwjI!^ei&^{U1>= z!^&Yoa|y-vSLjPKIP(7C?$zHcE6TomiB6zAM~x|S=v76w%>=hQ$rVordZSPGH_r!u za~NE4L)9W;Zi;ur8=N=;g2x`9ew-T?zd44CWDowkmcCKC2ZEkwyy{Cgf?DBwA)VTz zfJ;~J*q-_{>l2=#Z#w%BHa5yiZUb#89mRN|$!s*X41Sj}m@%Y%D8!j#oex}HpuLkT zi_70a875WHbj(&5q=Cb3*-Fn-b_=@DxVxh?M%~C#aO%I9A zfDhFlS)5h5m^sgc`qgo&LB;4CbJ+4Do$EQJL-i45cQ|%b4D${*iHS6$Z!lFja4{Z& zm_cQ;+$jmX_Ipjb?|qoQbz3TEQd@UgHO-t8i&2#uH*%Y+@t8HptKD;^>9mRb|w53r?9PIIfP$v|io_ z*cIdNpF96_?%r4O-CUdtgPsVgQ7~>`(Iv=~Vz&=N0I0@6UyQtkp156a;eRI#QPSg> zAcDjr+gD33>K!@@N;gSJr1%xowp?n{?=lK{fWo0V0xrMs(WD=)!hLrQ-FS z@!mYs_Wz~@&+paJijML41V^ce^;23KtbY_xNJKz@7&zTeFEoHm7;$(UI=YQFs#$@ptk!EQ42Y4FfxEf@TOsVt37 z}4AVbnC9Ri){mLjd@o@_vA;wzpV8G_ypN3Y=M08M6ZfM2Xtkpu^=A9}u!A?A z)0NYU%Y#TSSE#tnm?KTmo4 zd|UY(Tqjl;m?`7^R${$QG*ZIW=)p?(%lWYXyf8k9{rdP=)z$ty1cAPSJfgXTOPXN1 z^D-Pknjk$jWsP@0+o&sn#8=lA=)a-i-j|YE5DwZ9s#vk3w-c?}%C?C;Q@<(1;-i>L zl}SN#MAX*71GGR14&RiPaHe@3srrMMPYHjml+|aGSDU_fRi{h1_NlT;MHYR@D(IR3 zt6;N#m)Tdz?)V=$7s!&Z;ZdmJFd0m>InR~Umqz^)eM=coLx(q4tw%~Z0U73ho^=Mj zF)fREGIOlh6`*ARYk?K%ir!a_Yvw9snW){J#zyP<3!#qD8Q_2~d|so+(Xc54smil}_4kGqEK^l7mVKQmM+ zBR70H=a2QXGB!3jg`P(Kg~lE^KQr-y_EVJi%}cMMzb+f?)6-|yp{QzpZdk)-9EhXzQpEZ(ZuvkddnL`d4Y{JQ>J+Eg}}BSGkUqgbqYuem+;8++@MM(|;Eh?pTI_O&4Gy6PBOnIB)^cWfo! V^Rh-@K?jDw= current.Len() { + return current, kind, false + } + + startIdx := idx2 + 1 + + if startIdx < len(namespace) { + if namespace[startIdx:startIdx+1] == namespaceSeparator { + startIdx++ + } + } + + val = current.Index(arrIdx) + namespace = namespace[startIdx:] + goto BEGIN + + case reflect.Map: + idx := strings.Index(namespace, leftBracket) + 1 + idx2 := strings.Index(namespace, rightBracket) + + endIdx := idx2 + + if endIdx+1 < len(namespace) { + if namespace[endIdx+1:endIdx+2] == namespaceSeparator { + endIdx++ + } + } + + key := namespace[idx:idx2] + + switch current.Type().Key().Kind() { + case reflect.Int: + i, _ := strconv.Atoi(key) + val = current.MapIndex(reflect.ValueOf(i)) + namespace = namespace[endIdx+1:] + + case reflect.Int8: + i, _ := strconv.ParseInt(key, 10, 8) + val = current.MapIndex(reflect.ValueOf(int8(i))) + namespace = namespace[endIdx+1:] + + case reflect.Int16: + i, _ := strconv.ParseInt(key, 10, 16) + val = current.MapIndex(reflect.ValueOf(int16(i))) + namespace = namespace[endIdx+1:] + + case reflect.Int32: + i, _ := strconv.ParseInt(key, 10, 32) + val = current.MapIndex(reflect.ValueOf(int32(i))) + namespace = namespace[endIdx+1:] + + case reflect.Int64: + i, _ := strconv.ParseInt(key, 10, 64) + val = current.MapIndex(reflect.ValueOf(i)) + namespace = namespace[endIdx+1:] + + case reflect.Uint: + i, _ := strconv.ParseUint(key, 10, 0) + val = current.MapIndex(reflect.ValueOf(uint(i))) + namespace = namespace[endIdx+1:] + + case reflect.Uint8: + i, _ := strconv.ParseUint(key, 10, 8) + val = current.MapIndex(reflect.ValueOf(uint8(i))) + namespace = namespace[endIdx+1:] + + case reflect.Uint16: + i, _ := strconv.ParseUint(key, 10, 16) + val = current.MapIndex(reflect.ValueOf(uint16(i))) + namespace = namespace[endIdx+1:] + + case reflect.Uint32: + i, _ := strconv.ParseUint(key, 10, 32) + val = current.MapIndex(reflect.ValueOf(uint32(i))) + namespace = namespace[endIdx+1:] + + case reflect.Uint64: + i, _ := strconv.ParseUint(key, 10, 64) + val = current.MapIndex(reflect.ValueOf(i)) + namespace = namespace[endIdx+1:] + + case reflect.Float32: + f, _ := strconv.ParseFloat(key, 32) + val = current.MapIndex(reflect.ValueOf(float32(f))) + namespace = namespace[endIdx+1:] + + case reflect.Float64: + f, _ := strconv.ParseFloat(key, 64) + val = current.MapIndex(reflect.ValueOf(f)) + namespace = namespace[endIdx+1:] + + case reflect.Bool: + b, _ := strconv.ParseBool(key) + val = current.MapIndex(reflect.ValueOf(b)) + namespace = namespace[endIdx+1:] + + // reflect.Type = string + default: + val = current.MapIndex(reflect.ValueOf(key)) + namespace = namespace[endIdx+1:] + } + + goto BEGIN + } + + // if got here there was more namespace, cannot go any deeper + panic("Invalid field namespace") +} + +// asInt returns the parameter as a int64 +// or panics if it can't convert +func asInt(param string) int64 { + + i, err := strconv.ParseInt(param, 0, 64) + panicIf(err) + + return i +} + +// asUint returns the parameter as a uint64 +// or panics if it can't convert +func asUint(param string) uint64 { + + i, err := strconv.ParseUint(param, 0, 64) + panicIf(err) + + return i +} + +// asFloat returns the parameter as a float64 +// or panics if it can't convert +func asFloat(param string) float64 { + + i, err := strconv.ParseFloat(param, 64) + panicIf(err) + + return i +} + +func panicIf(err error) { + if err != nil { + panic(err.Error()) + } +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/validator.go b/vendor/gopkg.in/go-playground/validator.v9/validator.go new file mode 100644 index 0000000000..98bf265238 --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/validator.go @@ -0,0 +1,444 @@ +package validator + +import ( + "fmt" + "reflect" + "strconv" +) + +// per validate contruct +type validate struct { + v *Validate + top reflect.Value + ns []byte + actualNs []byte + errs ValidationErrors + isPartial bool + hasExcludes bool + includeExclude map[string]struct{} // reset only if StructPartial or StructExcept are called, no need otherwise + + ffn FilterFunc + + // StructLevel & FieldLevel fields + slflParent reflect.Value + slCurrent reflect.Value + flField reflect.Value + fldIsPointer bool + cf *cField + ct *cTag + + // misc reusable values + misc []byte + str1 string + str2 string +} + +// parent and current will be the same the first run of validateStruct +func (v *validate) validateStruct(parent reflect.Value, current reflect.Value, typ reflect.Type, ns []byte, structNs []byte, ct *cTag) { + + cs, ok := v.v.structCache.Get(typ) + if !ok { + cs = v.v.extractStructCache(current, typ.Name()) + } + + if len(ns) == 0 && len(cs.name) != 0 { + + ns = append(ns, cs.name...) + ns = append(ns, '.') + + structNs = append(structNs, cs.name...) + structNs = append(structNs, '.') + } + + // ct is nil on top level struct, and structs as fields that have no tag info + // so if nil or if not nil and the structonly tag isn't present + if ct == nil || ct.typeof != typeStructOnly { + + var f *cField + + for i := 0; i < len(cs.fields); i++ { + + f = cs.fields[i] + + if v.isPartial { + + if v.ffn != nil { + // used with StructFiltered + if v.ffn(append(structNs, f.name...)) { + continue + } + + } else { + // used with StructPartial & StructExcept + _, ok = v.includeExclude[string(append(structNs, f.name...))] + + if (ok && v.hasExcludes) || (!ok && !v.hasExcludes) { + continue + } + } + } + + v.traverseField(parent, current.Field(f.idx), ns, structNs, f, f.cTags) + } + } + + // check if any struct level validations, after all field validations already checked. + // first iteration will have no info about nostructlevel tag, and is checked prior to + // calling the next iteration of validateStruct called from traverseField. + if cs.fn != nil { + + v.slflParent = parent + v.slCurrent = current + v.ns = ns + v.actualNs = structNs + + cs.fn(v) + } +} + +// traverseField validates any field, be it a struct or single field, ensures it's validity and passes it along to be validated via it's tag options +func (v *validate) traverseField(parent reflect.Value, current reflect.Value, ns []byte, structNs []byte, cf *cField, ct *cTag) { + + var typ reflect.Type + var kind reflect.Kind + + current, kind, v.fldIsPointer = v.extractTypeInternal(current, false) + + switch kind { + case reflect.Ptr, reflect.Interface, reflect.Invalid: + + if ct == nil { + return + } + + if ct.typeof == typeOmitEmpty { + return + } + + if ct.hasTag { + + v.str1 = string(append(ns, cf.altName...)) + + if v.v.hasTagNameFunc { + v.str2 = string(append(structNs, cf.name...)) + } else { + v.str2 = v.str1 + } + + if kind == reflect.Invalid { + + v.errs = append(v.errs, + &fieldError{ + v: v.v, + tag: ct.aliasTag, + actualTag: ct.tag, + ns: v.str1, + structNs: v.str2, + fieldLen: uint8(len(cf.altName)), + structfieldLen: uint8(len(cf.name)), + param: ct.param, + kind: kind, + }, + ) + + return + } + + v.errs = append(v.errs, + &fieldError{ + v: v.v, + tag: ct.aliasTag, + actualTag: ct.tag, + ns: v.str1, + structNs: v.str2, + fieldLen: uint8(len(cf.altName)), + structfieldLen: uint8(len(cf.name)), + value: current.Interface(), + param: ct.param, + kind: kind, + typ: current.Type(), + }, + ) + + return + } + + case reflect.Struct: + + typ = current.Type() + + if typ != timeType { + + if ct != nil { + + if ct.typeof == typeStructOnly { + goto CONTINUE + } + + ct = ct.next + } + + if ct != nil && ct.typeof == typeNoStructLevel { + return + } + + CONTINUE: + // if len == 0 then validating using 'Var' or 'VarWithValue' + // Var - doesn't make much sense to do it that way, should call 'Struct', but no harm... + // VarWithField - this allows for validating against each field withing the struct against a specific value + // pretty handly in certain situations + if len(cf.name) > 0 { + ns = append(append(ns, cf.altName...), '.') + structNs = append(append(structNs, cf.name...), '.') + } + + v.validateStruct(current, current, typ, ns, structNs, ct) + return + } + } + + if !ct.hasTag { + return + } + + typ = current.Type() + +OUTER: + for { + if ct == nil { + return + } + + switch ct.typeof { + + case typeOmitEmpty: + + // set Field Level fields + v.slflParent = parent + v.flField = current + v.cf = cf + v.ct = ct + + if !v.fldIsPointer && !hasValue(v) { + return + } + + ct = ct.next + continue + + case typeDive: + + ct = ct.next + + // traverse slice or map here + // or panic ;) + switch kind { + case reflect.Slice, reflect.Array: + + var i64 int64 + reusableCF := &cField{} + + for i := 0; i < current.Len(); i++ { + + i64 = int64(i) + + v.misc = append(v.misc[0:0], cf.name...) + v.misc = append(v.misc, '[') + v.misc = strconv.AppendInt(v.misc, i64, 10) + v.misc = append(v.misc, ']') + + reusableCF.name = string(v.misc) + + if cf.namesEqual { + reusableCF.altName = reusableCF.name + } else { + + v.misc = append(v.misc[0:0], cf.altName...) + v.misc = append(v.misc, '[') + v.misc = strconv.AppendInt(v.misc, i64, 10) + v.misc = append(v.misc, ']') + + reusableCF.altName = string(v.misc) + } + + v.traverseField(parent, current.Index(i), ns, structNs, reusableCF, ct) + } + + case reflect.Map: + + var pv string + reusableCF := &cField{} + + for _, key := range current.MapKeys() { + + pv = fmt.Sprintf("%v", key.Interface()) + + v.misc = append(v.misc[0:0], cf.name...) + v.misc = append(v.misc, '[') + v.misc = append(v.misc, pv...) + v.misc = append(v.misc, ']') + + reusableCF.name = string(v.misc) + + if cf.namesEqual { + reusableCF.altName = reusableCF.name + } else { + v.misc = append(v.misc[0:0], cf.altName...) + v.misc = append(v.misc, '[') + v.misc = append(v.misc, pv...) + v.misc = append(v.misc, ']') + + reusableCF.altName = string(v.misc) + } + + v.traverseField(parent, current.MapIndex(key), ns, structNs, reusableCF, ct) + } + + default: + // throw error, if not a slice or map then should not have gotten here + // bad dive tag + panic("dive error! can't dive on a non slice or map") + } + + return + + case typeOr: + + v.misc = v.misc[0:0] + + for { + + // set Field Level fields + v.slflParent = parent + v.flField = current + v.cf = cf + v.ct = ct + + if ct.fn(v) { + + // drain rest of the 'or' values, then continue or leave + for { + + ct = ct.next + + if ct == nil { + return + } + + if ct.typeof != typeOr { + continue OUTER + } + } + } + + v.misc = append(v.misc, '|') + v.misc = append(v.misc, ct.tag...) + + if len(ct.param) > 0 { + v.misc = append(v.misc, '=') + v.misc = append(v.misc, ct.param...) + } + + if ct.next == nil || ct.next.typeof != typeOr { // ct.typeof != typeOr + // if we get here, no valid 'or' value and no more tags + + v.str1 = string(append(ns, cf.altName...)) + + if v.v.hasTagNameFunc { + v.str2 = string(append(structNs, cf.name...)) + } else { + v.str2 = v.str1 + } + + if ct.hasAlias { + + v.errs = append(v.errs, + &fieldError{ + v: v.v, + tag: ct.aliasTag, + actualTag: ct.actualAliasTag, + ns: v.str1, + structNs: v.str2, + fieldLen: uint8(len(cf.altName)), + structfieldLen: uint8(len(cf.name)), + value: current.Interface(), + param: ct.param, + kind: kind, + typ: typ, + }, + ) + + } else { + + tVal := string(v.misc)[1:] + + v.errs = append(v.errs, + &fieldError{ + v: v.v, + tag: tVal, + actualTag: tVal, + ns: v.str1, + structNs: v.str2, + fieldLen: uint8(len(cf.altName)), + structfieldLen: uint8(len(cf.name)), + value: current.Interface(), + param: ct.param, + kind: kind, + typ: typ, + }, + ) + } + + return + } + + ct = ct.next + } + + default: + + // set Field Level fields + v.slflParent = parent + v.flField = current + v.cf = cf + v.ct = ct + + // // report error interface functions need these + // v.ns = ns + // v.actualNs = structNs + + if !ct.fn(v) { + + v.str1 = string(append(ns, cf.altName...)) + + if v.v.hasTagNameFunc { + v.str2 = string(append(structNs, cf.name...)) + } else { + v.str2 = v.str1 + } + + v.errs = append(v.errs, + &fieldError{ + v: v.v, + tag: ct.aliasTag, + actualTag: ct.tag, + ns: v.str1, + structNs: v.str2, + fieldLen: uint8(len(cf.altName)), + structfieldLen: uint8(len(cf.name)), + value: current.Interface(), + param: ct.param, + kind: kind, + typ: typ, + }, + ) + + return + + } + + ct = ct.next + } + } + +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/validator_instance.go b/vendor/gopkg.in/go-playground/validator.v9/validator_instance.go new file mode 100644 index 0000000000..5f2cd7401d --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/validator_instance.go @@ -0,0 +1,535 @@ +package validator + +import ( + "errors" + "fmt" + "reflect" + "strings" + "sync" + "time" + + ut "github.com/go-playground/universal-translator" +) + +const ( + defaultTagName = "validate" + utf8HexComma = "0x2C" + utf8Pipe = "0x7C" + tagSeparator = "," + orSeparator = "|" + tagKeySeparator = "=" + structOnlyTag = "structonly" + noStructLevelTag = "nostructlevel" + omitempty = "omitempty" + skipValidationTag = "-" + diveTag = "dive" + requiredTag = "required" + namespaceSeparator = "." + leftBracket = "[" + rightBracket = "]" + restrictedTagChars = ".[],|=+()`~!@#$%^&*\\\"/?<>{}" + restrictedAliasErr = "Alias '%s' either contains restricted characters or is the same as a restricted tag needed for normal operation" + restrictedTagErr = "Tag '%s' either contains restricted characters or is the same as a restricted tag needed for normal operation" +) + +var ( + timeType = reflect.TypeOf(time.Time{}) + defaultCField = &cField{namesEqual: true} +) + +// FilterFunc is the type used to filter fields using +// StructFiltered(...) function. +// returning true results in the field being filtered/skiped from +// validation +type FilterFunc func(ns []byte) bool + +// CustomTypeFunc allows for overriding or adding custom field type handler functions +// field = field value of the type to return a value to be validated +// example Valuer from sql drive see https://golang.org/src/database/sql/driver/types.go?s=1210:1293#L29 +type CustomTypeFunc func(field reflect.Value) interface{} + +// TagNameFunc allows for adding of a custom tag name parser +type TagNameFunc func(field reflect.StructField) string + +// Validate contains the validator settings and cache +type Validate struct { + tagName string + pool *sync.Pool + hasCustomFuncs bool + hasTagNameFunc bool + tagNameFunc TagNameFunc + structLevelFuncs map[reflect.Type]StructLevelFunc + customFuncs map[reflect.Type]CustomTypeFunc + aliases map[string]string + validations map[string]Func + transTagFunc map[ut.Translator]map[string]TranslationFunc // map[]map[]TranslationFunc + tagCache *tagCache + structCache *structCache +} + +// New returns a new instacne of 'validate' with sane defaults. +func New() *Validate { + + tc := new(tagCache) + tc.m.Store(make(map[string]*cTag)) + + sc := new(structCache) + sc.m.Store(make(map[reflect.Type]*cStruct)) + + v := &Validate{ + tagName: defaultTagName, + aliases: make(map[string]string, len(bakedInAliases)), + validations: make(map[string]Func, len(bakedInValidators)), + tagCache: tc, + structCache: sc, + } + + // must copy alias validators for separate validations to be used in each validator instance + for k, val := range bakedInAliases { + v.RegisterAlias(k, val) + } + + // must copy validators for separate validations to be used in each instance + for k, val := range bakedInValidators { + + // no need to error check here, baked in will alwaays be valid + v.registerValidation(k, val, true) + } + + v.pool = &sync.Pool{ + New: func() interface{} { + return &validate{ + v: v, + ns: make([]byte, 0, 64), + actualNs: make([]byte, 0, 64), + misc: make([]byte, 32), + } + }, + } + + return v +} + +// SetTagName allows for changing of the default tag name of 'validate' +func (v *Validate) SetTagName(name string) { + v.tagName = name +} + +// RegisterTagNameFunc registers a function to get another name from the +// StructField eg. the JSON name +func (v *Validate) RegisterTagNameFunc(fn TagNameFunc) { + v.tagNameFunc = fn + v.hasTagNameFunc = true +} + +// RegisterValidation adds a validation with the given tag +// +// NOTES: +// - if the key already exists, the previous validation function will be replaced. +// - this method is not thread-safe it is intended that these all be registered prior to any validation +func (v *Validate) RegisterValidation(tag string, fn Func) error { + return v.registerValidation(tag, fn, false) +} + +func (v *Validate) registerValidation(tag string, fn Func, bakedIn bool) error { + + if len(tag) == 0 { + return errors.New("Function Key cannot be empty") + } + + if fn == nil { + return errors.New("Function cannot be empty") + } + + _, ok := restrictedTags[tag] + + if !bakedIn && (ok || strings.ContainsAny(tag, restrictedTagChars)) { + panic(fmt.Sprintf(restrictedTagErr, tag)) + } + + v.validations[tag] = fn + + return nil +} + +// RegisterAlias registers a mapping of a single validation tag that +// defines a common or complex set of validation(s) to simplify adding validation +// to structs. +// +// NOTE: this function is not thread-safe it is intended that these all be registered prior to any validation +func (v *Validate) RegisterAlias(alias, tags string) { + + _, ok := restrictedTags[alias] + + if ok || strings.ContainsAny(alias, restrictedTagChars) { + panic(fmt.Sprintf(restrictedAliasErr, alias)) + } + + v.aliases[alias] = tags +} + +// RegisterStructValidation registers a StructLevelFunc against a number of types. +// This is akin to implementing the 'Validatable' interface, but for structs for which +// you may not have access or rights to change. +// +// NOTES: +// - if this and the 'Validatable' interface are implemented the Struct Level takes precedence as to enable +// a struct out of your control's validation to be overridden +// - this method is not thread-safe it is intended that these all be registered prior to any validation +func (v *Validate) RegisterStructValidation(fn StructLevelFunc, types ...interface{}) { + + if v.structLevelFuncs == nil { + v.structLevelFuncs = make(map[reflect.Type]StructLevelFunc) + } + + for _, t := range types { + v.structLevelFuncs[reflect.TypeOf(t)] = fn + } +} + +// RegisterCustomTypeFunc registers a CustomTypeFunc against a number of types +// +// NOTE: this method is not thread-safe it is intended that these all be registered prior to any validation +func (v *Validate) RegisterCustomTypeFunc(fn CustomTypeFunc, types ...interface{}) { + + if v.customFuncs == nil { + v.customFuncs = make(map[reflect.Type]CustomTypeFunc) + } + + for _, t := range types { + v.customFuncs[reflect.TypeOf(t)] = fn + } + + v.hasCustomFuncs = true +} + +// RegisterTranslation registers translations against the provided tag. +func (v *Validate) RegisterTranslation(tag string, trans ut.Translator, registerFn RegisterTranslationsFunc, translationFn TranslationFunc) (err error) { + + if v.transTagFunc == nil { + v.transTagFunc = make(map[ut.Translator]map[string]TranslationFunc) + } + + if err = registerFn(trans); err != nil { + return + } + + m, ok := v.transTagFunc[trans] + if !ok { + m = make(map[string]TranslationFunc) + v.transTagFunc[trans] = m + } + + m[tag] = translationFn + + return +} + +// Struct validates a structs exposed fields, and automatically validates nested structs, unless otherwise specified. +// +// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise. +// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors. +func (v *Validate) Struct(s interface{}) (err error) { + + val := reflect.ValueOf(s) + top := val + + if val.Kind() == reflect.Ptr && !val.IsNil() { + val = val.Elem() + } + + if val.Kind() != reflect.Struct || val.Type() == timeType { + return &InvalidValidationError{Type: reflect.TypeOf(s)} + } + + // good to validate + vd := v.pool.Get().(*validate) + vd.top = top + vd.isPartial = false + // vd.hasExcludes = false // only need to reset in StructPartial and StructExcept + + vd.validateStruct(top, val, val.Type(), vd.ns[0:0], vd.actualNs[0:0], nil) + + if len(vd.errs) > 0 { + err = vd.errs + vd.errs = nil + } + + v.pool.Put(vd) + + return +} + +// StructFiltered validates a structs exposed fields, that pass the FilterFunc check and automatically validates +// nested structs, unless otherwise specified. +// +// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise. +// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors. +func (v *Validate) StructFiltered(s interface{}, fn FilterFunc) (err error) { + + val := reflect.ValueOf(s) + top := val + + if val.Kind() == reflect.Ptr && !val.IsNil() { + val = val.Elem() + } + + if val.Kind() != reflect.Struct || val.Type() == timeType { + return &InvalidValidationError{Type: reflect.TypeOf(s)} + } + + // good to validate + vd := v.pool.Get().(*validate) + vd.top = top + vd.isPartial = true + vd.ffn = fn + // vd.hasExcludes = false // only need to reset in StructPartial and StructExcept + + vd.validateStruct(top, val, val.Type(), vd.ns[0:0], vd.actualNs[0:0], nil) + + if len(vd.errs) > 0 { + err = vd.errs + vd.errs = nil + } + + v.pool.Put(vd) + + return +} + +// StructPartial validates the fields passed in only, ignoring all others. +// Fields may be provided in a namespaced fashion relative to the struct provided +// eg. NestedStruct.Field or NestedArrayField[0].Struct.Name +// +// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise. +// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors. +func (v *Validate) StructPartial(s interface{}, fields ...string) (err error) { + + val := reflect.ValueOf(s) + top := val + + if val.Kind() == reflect.Ptr && !val.IsNil() { + val = val.Elem() + } + + if val.Kind() != reflect.Struct || val.Type() == timeType { + return &InvalidValidationError{Type: reflect.TypeOf(s)} + } + + // good to validate + vd := v.pool.Get().(*validate) + vd.top = top + vd.isPartial = true + vd.ffn = nil + vd.hasExcludes = false + vd.includeExclude = make(map[string]struct{}) + + typ := val.Type() + name := typ.Name() + + if fields != nil { + for _, k := range fields { + + flds := strings.Split(k, namespaceSeparator) + if len(flds) > 0 { + + vd.misc = append(vd.misc[0:0], name...) + vd.misc = append(vd.misc, '.') + + for _, s := range flds { + + idx := strings.Index(s, leftBracket) + + if idx != -1 { + for idx != -1 { + vd.misc = append(vd.misc, s[:idx]...) + vd.includeExclude[string(vd.misc)] = struct{}{} + + idx2 := strings.Index(s, rightBracket) + idx2++ + vd.misc = append(vd.misc, s[idx:idx2]...) + vd.includeExclude[string(vd.misc)] = struct{}{} + s = s[idx2:] + idx = strings.Index(s, leftBracket) + } + } else { + + vd.misc = append(vd.misc, s...) + vd.includeExclude[string(vd.misc)] = struct{}{} + } + + vd.misc = append(vd.misc, '.') + } + } + } + } + + vd.validateStruct(top, val, typ, vd.ns[0:0], vd.actualNs[0:0], nil) + + if len(vd.errs) > 0 { + err = vd.errs + vd.errs = nil + } + + v.pool.Put(vd) + + return +} + +// StructExcept validates all fields except the ones passed in. +// Fields may be provided in a namespaced fashion relative to the struct provided +// i.e. NestedStruct.Field or NestedArrayField[0].Struct.Name +// +// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise. +// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors. +func (v *Validate) StructExcept(s interface{}, fields ...string) (err error) { + + val := reflect.ValueOf(s) + top := val + + if val.Kind() == reflect.Ptr && !val.IsNil() { + val = val.Elem() + } + + if val.Kind() != reflect.Struct || val.Type() == timeType { + return &InvalidValidationError{Type: reflect.TypeOf(s)} + } + + // good to validate + vd := v.pool.Get().(*validate) + vd.top = top + vd.isPartial = true + vd.ffn = nil + vd.hasExcludes = true + vd.includeExclude = make(map[string]struct{}) + + typ := val.Type() + name := typ.Name() + + for _, key := range fields { + + vd.misc = vd.misc[0:0] + + if len(name) > 0 { + vd.misc = append(vd.misc, name...) + vd.misc = append(vd.misc, '.') + } + + vd.misc = append(vd.misc, key...) + vd.includeExclude[string(vd.misc)] = struct{}{} + } + + vd.validateStruct(top, val, typ, vd.ns[0:0], vd.actualNs[0:0], nil) + + if len(vd.errs) > 0 { + err = vd.errs + vd.errs = nil + } + + v.pool.Put(vd) + + return +} + +// Var validates a single variable using tag style validation. +// eg. +// var i int +// validate.Var(i, "gt=1,lt=10") +// +// WARNING: a struct can be passed for validation eg. time.Time is a struct or if you have a custom type and have registered +// a custom type handler, so must allow it; however unforseen validations will occur if trying to validate a struct +// that is meant to be passed to 'validate.Struct' +// +// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise. +// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors. +// validate Array, Slice and maps fields which may contain more than one error +func (v *Validate) Var(field interface{}, tag string) (err error) { + + if len(tag) == 0 || tag == skipValidationTag { + return nil + } + + // find cached tag + ctag, ok := v.tagCache.Get(tag) + if !ok { + v.tagCache.lock.Lock() + defer v.tagCache.lock.Unlock() + + // could have been multiple trying to access, but once first is done this ensures tag + // isn't parsed again. + ctag, ok = v.tagCache.Get(tag) + if !ok { + ctag, _ = v.parseFieldTagsRecursive(tag, "", "", false) + v.tagCache.Set(tag, ctag) + } + } + + val := reflect.ValueOf(field) + + vd := v.pool.Get().(*validate) + vd.top = val + vd.isPartial = false + + vd.traverseField(val, val, vd.ns[0:0], vd.actualNs[0:0], defaultCField, ctag) + + if len(vd.errs) > 0 { + err = vd.errs + vd.errs = nil + } + + v.pool.Put(vd) + + return +} + +// VarWithValue validates a single variable, against another variable/field's value using tag style validation +// eg. +// s1 := "abcd" +// s2 := "abcd" +// validate.VarWithValue(s1, s2, "eqcsfield") // returns true +// +// WARNING: a struct can be passed for validation eg. time.Time is a struct or if you have a custom type and have registered +// a custom type handler, so must allow it; however unforseen validations will occur if trying to validate a struct +// that is meant to be passed to 'validate.Struct' +// +// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise. +// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors. +// validate Array, Slice and maps fields which may contain more than one error +func (v *Validate) VarWithValue(field interface{}, other interface{}, tag string) (err error) { + + if len(tag) == 0 || tag == skipValidationTag { + return nil + } + + // find cached tag + ctag, ok := v.tagCache.Get(tag) + if !ok { + v.tagCache.lock.Lock() + defer v.tagCache.lock.Unlock() + + // could have been multiple trying to access, but once first is done this ensures tag + // isn't parsed again. + ctag, ok = v.tagCache.Get(tag) + if !ok { + ctag, _ = v.parseFieldTagsRecursive(tag, "", "", false) + v.tagCache.Set(tag, ctag) + } + } + + otherVal := reflect.ValueOf(other) + + vd := v.pool.Get().(*validate) + vd.top = otherVal + vd.isPartial = false + + vd.traverseField(otherVal, reflect.ValueOf(field), vd.ns[0:0], vd.actualNs[0:0], defaultCField, ctag) + + if len(vd.errs) > 0 { + err = vd.errs + vd.errs = nil + } + + v.pool.Put(vd) + + return +} diff --git a/vendor/gopkg.in/go-playground/validator.v9/validator_test.go b/vendor/gopkg.in/go-playground/validator.v9/validator_test.go new file mode 100644 index 0000000000..c1dcb637cc --- /dev/null +++ b/vendor/gopkg.in/go-playground/validator.v9/validator_test.go @@ -0,0 +1,7081 @@ +package validator + +import ( + "bytes" + "database/sql" + "database/sql/driver" + "encoding/json" + "fmt" + "reflect" + "strings" + "testing" + "time" + + . "gopkg.in/go-playground/assert.v1" + + "github.com/go-playground/locales/en" + "github.com/go-playground/locales/fr" + "github.com/go-playground/locales/nl" + ut "github.com/go-playground/universal-translator" +) + +// NOTES: +// - Run "go test" to run tests +// - Run "gocov test | gocov report" to report on test converage by file +// - Run "gocov test | gocov annotate -" to report on all code and functions, those ,marked with "MISS" were never called +// +// or +// +// -- may be a good idea to change to output path to somewherelike /tmp +// go test -coverprofile cover.out && go tool cover -html=cover.out -o cover.html +// +// +// go test -cpuprofile cpu.out +// ./validator.test -test.bench=. -test.cpuprofile=cpu.prof +// go tool pprof validator.test cpu.prof +// +// +// go test -memprofile mem.out + +type I interface { + Foo() string +} + +type Impl struct { + F string `validate:"len=3"` +} + +func (i *Impl) Foo() string { + return i.F +} + +type SubTest struct { + Test string `validate:"required"` +} + +type TestInterface struct { + Iface I +} + +type TestString struct { + BlankTag string `validate:""` + Required string `validate:"required"` + Len string `validate:"len=10"` + Min string `validate:"min=1"` + Max string `validate:"max=10"` + MinMax string `validate:"min=1,max=10"` + Lt string `validate:"lt=10"` + Lte string `validate:"lte=10"` + Gt string `validate:"gt=10"` + Gte string `validate:"gte=10"` + OmitEmpty string `validate:"omitempty,min=1,max=10"` + Sub *SubTest + SubIgnore *SubTest `validate:"-"` + Anonymous struct { + A string `validate:"required"` + } + Iface I +} + +type TestUint64 struct { + Required uint64 `validate:"required"` + Len uint64 `validate:"len=10"` + Min uint64 `validate:"min=1"` + Max uint64 `validate:"max=10"` + MinMax uint64 `validate:"min=1,max=10"` + OmitEmpty uint64 `validate:"omitempty,min=1,max=10"` +} + +type TestFloat64 struct { + Required float64 `validate:"required"` + Len float64 `validate:"len=10"` + Min float64 `validate:"min=1"` + Max float64 `validate:"max=10"` + MinMax float64 `validate:"min=1,max=10"` + Lte float64 `validate:"lte=10"` + OmitEmpty float64 `validate:"omitempty,min=1,max=10"` +} + +type TestSlice struct { + Required []int `validate:"required"` + Len []int `validate:"len=10"` + Min []int `validate:"min=1"` + Max []int `validate:"max=10"` + MinMax []int `validate:"min=1,max=10"` + OmitEmpty []int `validate:"omitempty,min=1,max=10"` +} + +func AssertError(t *testing.T, err error, nsKey, structNsKey, field, structField, expectedTag string) { + + errs := err.(ValidationErrors) + + found := false + var fe FieldError + + for i := 0; i < len(errs); i++ { + if errs[i].Namespace() == nsKey && errs[i].StructNamespace() == structNsKey { + found = true + fe = errs[i] + break + } + } + + EqualSkip(t, 2, found, true) + NotEqualSkip(t, 2, fe, nil) + EqualSkip(t, 2, fe.Field(), field) + EqualSkip(t, 2, fe.StructField(), structField) + EqualSkip(t, 2, fe.Tag(), expectedTag) +} + +func getError(err error, nsKey, structNsKey string) FieldError { + + errs := err.(ValidationErrors) + + var fe FieldError + + for i := 0; i < len(errs); i++ { + if errs[i].Namespace() == nsKey && errs[i].StructNamespace() == structNsKey { + fe = errs[i] + break + } + } + + return fe +} + +type valuer struct { + Name string +} + +func (v valuer) Value() (driver.Value, error) { + + if v.Name == "errorme" { + panic("SQL Driver Valuer error: some kind of error") + // return nil, errors.New("some kind of error") + } + + if len(v.Name) == 0 { + return nil, nil + } + + return v.Name, nil +} + +type MadeUpCustomType struct { + FirstName string + LastName string +} + +func ValidateCustomType(field reflect.Value) interface{} { + + if cust, ok := field.Interface().(MadeUpCustomType); ok { + + if len(cust.FirstName) == 0 || len(cust.LastName) == 0 { + return "" + } + + return cust.FirstName + " " + cust.LastName + } + + return "" +} + +func OverrideIntTypeForSomeReason(field reflect.Value) interface{} { + + if i, ok := field.Interface().(int); ok { + if i == 1 { + return "1" + } + + if i == 2 { + return "12" + } + } + + return "" +} + +type CustomMadeUpStruct struct { + MadeUp MadeUpCustomType `validate:"required"` + OverriddenInt int `validate:"gt=1"` +} + +func ValidateValuerType(field reflect.Value) interface{} { + + if valuer, ok := field.Interface().(driver.Valuer); ok { + + val, err := valuer.Value() + if err != nil { + // handle the error how you want + return nil + } + + return val + } + + return nil +} + +type TestPartial struct { + NoTag string + BlankTag string `validate:""` + Required string `validate:"required"` + SubSlice []*SubTest `validate:"required,dive"` + Sub *SubTest + SubIgnore *SubTest `validate:"-"` + Anonymous struct { + A string `validate:"required"` + ASubSlice []*SubTest `validate:"required,dive"` + + SubAnonStruct []struct { + Test string `validate:"required"` + OtherTest string `validate:"required"` + } `validate:"required,dive"` + } +} + +type TestStruct struct { + String string `validate:"required" json:"StringVal"` +} + +func StructValidationTestStructSuccess(sl StructLevel) { + + st := sl.Current().Interface().(TestStruct) + + if st.String != "good value" { + sl.ReportError(st.String, "StringVal", "String", "badvalueteststruct", "good value") + } +} + +func StructValidationTestStruct(sl StructLevel) { + + st := sl.Current().Interface().(TestStruct) + + if st.String != "bad value" { + sl.ReportError(st.String, "StringVal", "String", "badvalueteststruct", "bad value") + } +} + +func StructValidationNoTestStructCustomName(sl StructLevel) { + + st := sl.Current().Interface().(TestStruct) + + if st.String != "bad value" { + sl.ReportError(st.String, "String", "", "badvalueteststruct", "bad value") + } +} + +func StructValidationTestStructInvalid(sl StructLevel) { + + st := sl.Current().Interface().(TestStruct) + + if st.String != "bad value" { + sl.ReportError(nil, "StringVal", "String", "badvalueteststruct", "bad value") + } +} + +func StructValidationTestStructReturnValidationErrors(sl StructLevel) { + + s := sl.Current().Interface().(TestStructReturnValidationErrors) + + errs := sl.Validator().Struct(s.Inner1.Inner2) + if errs == nil { + return + } + + sl.ReportValidationErrors("Inner1.", "Inner1.", errs.(ValidationErrors)) +} + +func StructValidationTestStructReturnValidationErrors2(sl StructLevel) { + + s := sl.Current().Interface().(TestStructReturnValidationErrors) + + errs := sl.Validator().Struct(s.Inner1.Inner2) + if errs == nil { + return + } + + sl.ReportValidationErrors("Inner1JSON.", "Inner1.", errs.(ValidationErrors)) +} + +type TestStructReturnValidationErrorsInner2 struct { + String string `validate:"required" json:"JSONString"` +} + +type TestStructReturnValidationErrorsInner1 struct { + Inner2 *TestStructReturnValidationErrorsInner2 +} + +type TestStructReturnValidationErrors struct { + Inner1 *TestStructReturnValidationErrorsInner1 `json:"Inner1JSON"` +} + +type StructLevelInvalidErr struct { + Value string +} + +func StructLevelInvalidError(sl StructLevel) { + + top := sl.Top().Interface().(StructLevelInvalidErr) + s := sl.Current().Interface().(StructLevelInvalidErr) + + if top.Value == s.Value { + sl.ReportError(nil, "Value", "Value", "required", "") + } +} + +func TestStructLevelInvalidError(t *testing.T) { + + validate := New() + validate.RegisterStructValidation(StructLevelInvalidError, StructLevelInvalidErr{}) + + var test StructLevelInvalidErr + + err := validate.Struct(test) + NotEqual(t, err, nil) + + errs, ok := err.(ValidationErrors) + Equal(t, ok, true) + + fe := errs[0] + Equal(t, fe.Field(), "Value") + Equal(t, fe.StructField(), "Value") + Equal(t, fe.Namespace(), "StructLevelInvalidErr.Value") + Equal(t, fe.StructNamespace(), "StructLevelInvalidErr.Value") + Equal(t, fe.Tag(), "required") + Equal(t, fe.ActualTag(), "required") + Equal(t, fe.Kind(), reflect.Invalid) + Equal(t, fe.Type(), reflect.TypeOf(nil)) +} + +func TestNameNamespace(t *testing.T) { + + type Inner2Namespace struct { + String []string `validate:"dive,required" json:"JSONString"` + } + + type Inner1Namespace struct { + Inner2 *Inner2Namespace `json:"Inner2JSON"` + } + + type Namespace struct { + Inner1 *Inner1Namespace `json:"Inner1JSON"` + } + + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + i2 := &Inner2Namespace{String: []string{"ok", "ok", "ok"}} + i1 := &Inner1Namespace{Inner2: i2} + ns := &Namespace{Inner1: i1} + + errs := validate.Struct(ns) + Equal(t, errs, nil) + + i2.String[1] = "" + + errs = validate.Struct(ns) + NotEqual(t, errs, nil) + + ve := errs.(ValidationErrors) + Equal(t, len(ve), 1) + AssertError(t, errs, "Namespace.Inner1JSON.Inner2JSON.JSONString[1]", "Namespace.Inner1.Inner2.String[1]", "JSONString[1]", "String[1]", "required") + + fe := getError(ve, "Namespace.Inner1JSON.Inner2JSON.JSONString[1]", "Namespace.Inner1.Inner2.String[1]") + NotEqual(t, fe, nil) + Equal(t, fe.Field(), "JSONString[1]") + Equal(t, fe.StructField(), "String[1]") + Equal(t, fe.Namespace(), "Namespace.Inner1JSON.Inner2JSON.JSONString[1]") + Equal(t, fe.StructNamespace(), "Namespace.Inner1.Inner2.String[1]") +} + +func TestAnonymous(t *testing.T) { + + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + type Test struct { + Anonymous struct { + A string `validate:"required" json:"EH"` + } + AnonymousB struct { + B string `validate:"required" json:"BEE"` + } + anonymousC struct { + c string `validate:"required"` + } + } + + tst := &Test{ + Anonymous: struct { + A string `validate:"required" json:"EH"` + }{ + A: "1", + }, + AnonymousB: struct { + B string `validate:"required" json:"BEE"` + }{ + B: "", + }, + anonymousC: struct { + c string `validate:"required"` + }{ + c: "", + }, + } + + err := validate.Struct(tst) + NotEqual(t, err, nil) + + errs := err.(ValidationErrors) + + Equal(t, len(errs), 1) + AssertError(t, errs, "Test.AnonymousB.BEE", "Test.AnonymousB.B", "BEE", "B", "required") + + fe := getError(errs, "Test.AnonymousB.BEE", "Test.AnonymousB.B") + NotEqual(t, fe, nil) + Equal(t, fe.Field(), "BEE") + Equal(t, fe.StructField(), "B") + + s := struct { + c string `validate:"required"` + }{ + c: "", + } + + err = validate.Struct(s) + Equal(t, err, nil) +} + +func TestAnonymousSameStructDifferentTags(t *testing.T) { + + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + type Test struct { + A interface{} + } + + tst := &Test{ + A: struct { + A string `validate:"required"` + }{ + A: "", + }, + } + + err := validate.Struct(tst) + NotEqual(t, err, nil) + + errs := err.(ValidationErrors) + + Equal(t, len(errs), 1) + AssertError(t, errs, "Test.A.A", "Test.A.A", "A", "A", "required") + + tst = &Test{ + A: struct { + A string `validate:"omitempty,required"` + }{ + A: "", + }, + } + + err = validate.Struct(tst) + Equal(t, err, nil) +} + +func TestStructLevelReturnValidationErrors(t *testing.T) { + + validate := New() + validate.RegisterStructValidation(StructValidationTestStructReturnValidationErrors, TestStructReturnValidationErrors{}) + + inner2 := &TestStructReturnValidationErrorsInner2{ + String: "I'm HERE", + } + + inner1 := &TestStructReturnValidationErrorsInner1{ + Inner2: inner2, + } + + val := &TestStructReturnValidationErrors{ + Inner1: inner1, + } + + errs := validate.Struct(val) + Equal(t, errs, nil) + + inner2.String = "" + + errs = validate.Struct(val) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 2) + AssertError(t, errs, "TestStructReturnValidationErrors.Inner1.Inner2.String", "TestStructReturnValidationErrors.Inner1.Inner2.String", "String", "String", "required") + // this is an extra error reported from struct validation + AssertError(t, errs, "TestStructReturnValidationErrors.Inner1.TestStructReturnValidationErrorsInner2.String", "TestStructReturnValidationErrors.Inner1.TestStructReturnValidationErrorsInner2.String", "String", "String", "required") +} + +func TestStructLevelReturnValidationErrorsWithJSON(t *testing.T) { + + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + validate.RegisterStructValidation(StructValidationTestStructReturnValidationErrors2, TestStructReturnValidationErrors{}) + + inner2 := &TestStructReturnValidationErrorsInner2{ + String: "I'm HERE", + } + + inner1 := &TestStructReturnValidationErrorsInner1{ + Inner2: inner2, + } + + val := &TestStructReturnValidationErrors{ + Inner1: inner1, + } + + errs := validate.Struct(val) + Equal(t, errs, nil) + + inner2.String = "" + + errs = validate.Struct(val) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 2) + AssertError(t, errs, "TestStructReturnValidationErrors.Inner1JSON.Inner2.JSONString", "TestStructReturnValidationErrors.Inner1.Inner2.String", "JSONString", "String", "required") + // this is an extra error reported from struct validation, it's a badly formatted one, but on purpose + AssertError(t, errs, "TestStructReturnValidationErrors.Inner1JSON.TestStructReturnValidationErrorsInner2.JSONString", "TestStructReturnValidationErrors.Inner1.TestStructReturnValidationErrorsInner2.String", "JSONString", "String", "required") + + fe := getError(errs, "TestStructReturnValidationErrors.Inner1JSON.Inner2.JSONString", "TestStructReturnValidationErrors.Inner1.Inner2.String") + NotEqual(t, fe, nil) + + // check for proper JSON namespace + Equal(t, fe.Field(), "JSONString") + Equal(t, fe.StructField(), "String") + Equal(t, fe.Namespace(), "TestStructReturnValidationErrors.Inner1JSON.Inner2.JSONString") + Equal(t, fe.StructNamespace(), "TestStructReturnValidationErrors.Inner1.Inner2.String") + + fe = getError(errs, "TestStructReturnValidationErrors.Inner1JSON.TestStructReturnValidationErrorsInner2.JSONString", "TestStructReturnValidationErrors.Inner1.TestStructReturnValidationErrorsInner2.String") + NotEqual(t, fe, nil) + + // check for proper JSON namespace + Equal(t, fe.Field(), "JSONString") + Equal(t, fe.StructField(), "String") + Equal(t, fe.Namespace(), "TestStructReturnValidationErrors.Inner1JSON.TestStructReturnValidationErrorsInner2.JSONString") + Equal(t, fe.StructNamespace(), "TestStructReturnValidationErrors.Inner1.TestStructReturnValidationErrorsInner2.String") +} + +func TestStructLevelValidations(t *testing.T) { + + v1 := New() + v1.RegisterStructValidation(StructValidationTestStruct, TestStruct{}) + + tst := &TestStruct{ + String: "good value", + } + + errs := v1.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestStruct.StringVal", "TestStruct.String", "StringVal", "String", "badvalueteststruct") + + v2 := New() + v2.RegisterStructValidation(StructValidationNoTestStructCustomName, TestStruct{}) + + errs = v2.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestStruct.String", "TestStruct.String", "String", "String", "badvalueteststruct") + + v3 := New() + v3.RegisterStructValidation(StructValidationTestStructInvalid, TestStruct{}) + + errs = v3.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestStruct.StringVal", "TestStruct.String", "StringVal", "String", "badvalueteststruct") + + v4 := New() + v4.RegisterStructValidation(StructValidationTestStructSuccess, TestStruct{}) + + errs = v4.Struct(tst) + Equal(t, errs, nil) +} + +func TestAliasTags(t *testing.T) { + + validate := New() + validate.RegisterAlias("iscoloralias", "hexcolor|rgb|rgba|hsl|hsla") + + s := "rgb(255,255,255)" + errs := validate.Var(s, "iscoloralias") + Equal(t, errs, nil) + + s = "" + errs = validate.Var(s, "omitempty,iscoloralias") + Equal(t, errs, nil) + + s = "rgb(255,255,0)" + errs = validate.Var(s, "iscoloralias,len=5") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "len") + + type Test struct { + Color string `validate:"iscoloralias"` + } + + tst := &Test{ + Color: "#000", + } + + errs = validate.Struct(tst) + Equal(t, errs, nil) + + tst.Color = "cfvre" + errs = validate.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.Color", "Test.Color", "Color", "Color", "iscoloralias") + + fe := getError(errs, "Test.Color", "Test.Color") + NotEqual(t, fe, nil) + Equal(t, fe.ActualTag(), "hexcolor|rgb|rgba|hsl|hsla") + + validate.RegisterAlias("req", "required,dive,iscoloralias") + arr := []string{"val1", "#fff", "#000"} + + errs = validate.Var(arr, "req") + NotEqual(t, errs, nil) + AssertError(t, errs, "[0]", "[0]", "[0]", "[0]", "iscoloralias") + + PanicMatches(t, func() { validate.RegisterAlias("exists!", "gt=5,lt=10") }, "Alias 'exists!' either contains restricted characters or is the same as a restricted tag needed for normal operation") +} + +func TestNilValidator(t *testing.T) { + + type TestStruct struct { + Test string `validate:"required"` + } + + ts := TestStruct{} + + var val *Validate + + fn := func(fl FieldLevel) bool { + + return fl.Parent().String() == fl.Field().String() + } + + PanicMatches(t, func() { val.RegisterCustomTypeFunc(ValidateCustomType, MadeUpCustomType{}) }, "runtime error: invalid memory address or nil pointer dereference") + PanicMatches(t, func() { val.RegisterValidation("something", fn) }, "runtime error: invalid memory address or nil pointer dereference") + PanicMatches(t, func() { val.Var(ts.Test, "required") }, "runtime error: invalid memory address or nil pointer dereference") + PanicMatches(t, func() { val.VarWithValue("test", ts.Test, "required") }, "runtime error: invalid memory address or nil pointer dereference") + PanicMatches(t, func() { val.Struct(ts) }, "runtime error: invalid memory address or nil pointer dereference") + PanicMatches(t, func() { val.StructExcept(ts, "Test") }, "runtime error: invalid memory address or nil pointer dereference") + PanicMatches(t, func() { val.StructPartial(ts, "Test") }, "runtime error: invalid memory address or nil pointer dereference") +} + +func TestStructPartial(t *testing.T) { + + p1 := []string{ + "NoTag", + "Required", + } + + p2 := []string{ + "SubSlice[0].Test", + "Sub", + "SubIgnore", + "Anonymous.A", + } + + p3 := []string{ + "SubTest.Test", + } + + p4 := []string{ + "A", + } + + tPartial := &TestPartial{ + NoTag: "NoTag", + Required: "Required", + + SubSlice: []*SubTest{ + { + + Test: "Required", + }, + { + + Test: "Required", + }, + }, + + Sub: &SubTest{ + Test: "1", + }, + SubIgnore: &SubTest{ + Test: "", + }, + Anonymous: struct { + A string `validate:"required"` + ASubSlice []*SubTest `validate:"required,dive"` + SubAnonStruct []struct { + Test string `validate:"required"` + OtherTest string `validate:"required"` + } `validate:"required,dive"` + }{ + A: "1", + ASubSlice: []*SubTest{ + { + Test: "Required", + }, + { + Test: "Required", + }, + }, + + SubAnonStruct: []struct { + Test string `validate:"required"` + OtherTest string `validate:"required"` + }{ + {"Required", "RequiredOther"}, + {"Required", "RequiredOther"}, + }, + }, + } + + validate := New() + + // the following should all return no errors as everything is valid in + // the default state + errs := validate.StructPartial(tPartial, p1...) + Equal(t, errs, nil) + + errs = validate.StructPartial(tPartial, p2...) + Equal(t, errs, nil) + + // this isn't really a robust test, but is ment to illustrate the ANON CASE below + errs = validate.StructPartial(tPartial.SubSlice[0], p3...) + Equal(t, errs, nil) + + errs = validate.StructExcept(tPartial, p1...) + Equal(t, errs, nil) + + errs = validate.StructExcept(tPartial, p2...) + Equal(t, errs, nil) + + // mod tParial for required feild and re-test making sure invalid fields are NOT required: + tPartial.Required = "" + + errs = validate.StructExcept(tPartial, p1...) + Equal(t, errs, nil) + + errs = validate.StructPartial(tPartial, p2...) + Equal(t, errs, nil) + + // inversion and retesting Partial to generate failures: + errs = validate.StructPartial(tPartial, p1...) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.Required", "TestPartial.Required", "Required", "Required", "required") + + errs = validate.StructExcept(tPartial, p2...) + AssertError(t, errs, "TestPartial.Required", "TestPartial.Required", "Required", "Required", "required") + + // reset Required field, and set nested struct + tPartial.Required = "Required" + tPartial.Anonymous.A = "" + + // will pass as unset feilds is not going to be tested + errs = validate.StructPartial(tPartial, p1...) + Equal(t, errs, nil) + + errs = validate.StructExcept(tPartial, p2...) + Equal(t, errs, nil) + + // ANON CASE the response here is strange, it clearly does what it is being told to + errs = validate.StructExcept(tPartial.Anonymous, p4...) + Equal(t, errs, nil) + + // will fail as unset feild is tested + errs = validate.StructPartial(tPartial, p2...) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.Anonymous.A", "TestPartial.Anonymous.A", "A", "A", "required") + + errs = validate.StructExcept(tPartial, p1...) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.Anonymous.A", "TestPartial.Anonymous.A", "A", "A", "required") + + // reset nested struct and unset struct in slice + tPartial.Anonymous.A = "Required" + tPartial.SubSlice[0].Test = "" + + // these will pass as unset item is NOT tested + errs = validate.StructPartial(tPartial, p1...) + Equal(t, errs, nil) + + errs = validate.StructExcept(tPartial, p2...) + Equal(t, errs, nil) + + // these will fail as unset item IS tested + errs = validate.StructExcept(tPartial, p1...) + AssertError(t, errs, "TestPartial.SubSlice[0].Test", "TestPartial.SubSlice[0].Test", "Test", "Test", "required") + Equal(t, len(errs.(ValidationErrors)), 1) + + errs = validate.StructPartial(tPartial, p2...) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.SubSlice[0].Test", "TestPartial.SubSlice[0].Test", "Test", "Test", "required") + Equal(t, len(errs.(ValidationErrors)), 1) + + // Unset second slice member concurrently to test dive behavior: + tPartial.SubSlice[1].Test = "" + + errs = validate.StructPartial(tPartial, p1...) + Equal(t, errs, nil) + + // NOTE: When specifying nested items, it is still the users responsibility + // to specify the dive tag, the library does not override this. + errs = validate.StructExcept(tPartial, p2...) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.SubSlice[1].Test", "TestPartial.SubSlice[1].Test", "Test", "Test", "required") + + errs = validate.StructExcept(tPartial, p1...) + Equal(t, len(errs.(ValidationErrors)), 2) + AssertError(t, errs, "TestPartial.SubSlice[0].Test", "TestPartial.SubSlice[0].Test", "Test", "Test", "required") + AssertError(t, errs, "TestPartial.SubSlice[1].Test", "TestPartial.SubSlice[1].Test", "Test", "Test", "required") + + errs = validate.StructPartial(tPartial, p2...) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "TestPartial.SubSlice[0].Test", "TestPartial.SubSlice[0].Test", "Test", "Test", "required") + + // reset struct in slice, and unset struct in slice in unset posistion + tPartial.SubSlice[0].Test = "Required" + + // these will pass as the unset item is NOT tested + errs = validate.StructPartial(tPartial, p1...) + Equal(t, errs, nil) + + errs = validate.StructPartial(tPartial, p2...) + Equal(t, errs, nil) + + // testing for missing item by exception, yes it dives and fails + errs = validate.StructExcept(tPartial, p1...) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "TestPartial.SubSlice[1].Test", "TestPartial.SubSlice[1].Test", "Test", "Test", "required") + + errs = validate.StructExcept(tPartial, p2...) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.SubSlice[1].Test", "TestPartial.SubSlice[1].Test", "Test", "Test", "required") + + tPartial.SubSlice[1].Test = "Required" + + tPartial.Anonymous.SubAnonStruct[0].Test = "" + // these will pass as the unset item is NOT tested + errs = validate.StructPartial(tPartial, p1...) + Equal(t, errs, nil) + + errs = validate.StructPartial(tPartial, p2...) + Equal(t, errs, nil) + + errs = validate.StructExcept(tPartial, p1...) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.Anonymous.SubAnonStruct[0].Test", "TestPartial.Anonymous.SubAnonStruct[0].Test", "Test", "Test", "required") + + errs = validate.StructExcept(tPartial, p2...) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.Anonymous.SubAnonStruct[0].Test", "TestPartial.Anonymous.SubAnonStruct[0].Test", "Test", "Test", "required") + +} + +func TestCrossStructLteFieldValidation(t *testing.T) { + + type Inner struct { + CreatedAt *time.Time + String string + Int int + Uint uint + Float float64 + Array []string + } + + type Test struct { + Inner *Inner + CreatedAt *time.Time `validate:"ltecsfield=Inner.CreatedAt"` + String string `validate:"ltecsfield=Inner.String"` + Int int `validate:"ltecsfield=Inner.Int"` + Uint uint `validate:"ltecsfield=Inner.Uint"` + Float float64 `validate:"ltecsfield=Inner.Float"` + Array []string `validate:"ltecsfield=Inner.Array"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * 5) + + inner := &Inner{ + CreatedAt: &then, + String: "abcd", + Int: 13, + Uint: 13, + Float: 1.13, + Array: []string{"val1", "val2"}, + } + + test := &Test{ + Inner: inner, + CreatedAt: &now, + String: "abc", + Int: 12, + Uint: 12, + Float: 1.12, + Array: []string{"val1"}, + } + + validate := New() + errs := validate.Struct(test) + Equal(t, errs, nil) + + test.CreatedAt = &then + test.String = "abcd" + test.Int = 13 + test.Uint = 13 + test.Float = 1.13 + test.Array = []string{"val1", "val2"} + + errs = validate.Struct(test) + Equal(t, errs, nil) + + after := now.Add(time.Hour * 10) + + test.CreatedAt = &after + test.String = "abce" + test.Int = 14 + test.Uint = 14 + test.Float = 1.14 + test.Array = []string{"val1", "val2", "val3"} + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "ltecsfield") + AssertError(t, errs, "Test.String", "Test.String", "String", "String", "ltecsfield") + AssertError(t, errs, "Test.Int", "Test.Int", "Int", "Int", "ltecsfield") + AssertError(t, errs, "Test.Uint", "Test.Uint", "Uint", "Uint", "ltecsfield") + AssertError(t, errs, "Test.Float", "Test.Float", "Float", "Float", "ltecsfield") + AssertError(t, errs, "Test.Array", "Test.Array", "Array", "Array", "ltecsfield") + + errs = validate.VarWithValue(1, "", "ltecsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltecsfield") + + // this test is for the WARNING about unforseen validation issues. + errs = validate.VarWithValue(test, now, "ltecsfield") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 6) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "ltecsfield") + AssertError(t, errs, "Test.String", "Test.String", "String", "String", "ltecsfield") + AssertError(t, errs, "Test.Int", "Test.Int", "Int", "Int", "ltecsfield") + AssertError(t, errs, "Test.Uint", "Test.Uint", "Uint", "Uint", "ltecsfield") + AssertError(t, errs, "Test.Float", "Test.Float", "Float", "Float", "ltecsfield") + AssertError(t, errs, "Test.Array", "Test.Array", "Array", "Array", "ltecsfield") + + type Other struct { + Value string + } + + type Test2 struct { + Value Other + Time time.Time `validate:"ltecsfield=Value"` + } + + tst := Test2{ + Value: Other{Value: "StringVal"}, + Time: then, + } + + errs = validate.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test2.Time", "Test2.Time", "Time", "Time", "ltecsfield") +} + +func TestCrossStructLtFieldValidation(t *testing.T) { + + type Inner struct { + CreatedAt *time.Time + String string + Int int + Uint uint + Float float64 + Array []string + } + + type Test struct { + Inner *Inner + CreatedAt *time.Time `validate:"ltcsfield=Inner.CreatedAt"` + String string `validate:"ltcsfield=Inner.String"` + Int int `validate:"ltcsfield=Inner.Int"` + Uint uint `validate:"ltcsfield=Inner.Uint"` + Float float64 `validate:"ltcsfield=Inner.Float"` + Array []string `validate:"ltcsfield=Inner.Array"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * 5) + + inner := &Inner{ + CreatedAt: &then, + String: "abcd", + Int: 13, + Uint: 13, + Float: 1.13, + Array: []string{"val1", "val2"}, + } + + test := &Test{ + Inner: inner, + CreatedAt: &now, + String: "abc", + Int: 12, + Uint: 12, + Float: 1.12, + Array: []string{"val1"}, + } + + validate := New() + errs := validate.Struct(test) + Equal(t, errs, nil) + + test.CreatedAt = &then + test.String = "abcd" + test.Int = 13 + test.Uint = 13 + test.Float = 1.13 + test.Array = []string{"val1", "val2"} + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "ltcsfield") + AssertError(t, errs, "Test.String", "Test.String", "String", "String", "ltcsfield") + AssertError(t, errs, "Test.Int", "Test.Int", "Int", "Int", "ltcsfield") + AssertError(t, errs, "Test.Uint", "Test.Uint", "Uint", "Uint", "ltcsfield") + AssertError(t, errs, "Test.Float", "Test.Float", "Float", "Float", "ltcsfield") + AssertError(t, errs, "Test.Array", "Test.Array", "Array", "Array", "ltcsfield") + + errs = validate.VarWithValue(1, "", "ltcsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltcsfield") + + // this test is for the WARNING about unforseen validation issues. + errs = validate.VarWithValue(test, now, "ltcsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "ltcsfield") + AssertError(t, errs, "Test.String", "Test.String", "String", "String", "ltcsfield") + AssertError(t, errs, "Test.Int", "Test.Int", "Int", "Int", "ltcsfield") + AssertError(t, errs, "Test.Uint", "Test.Uint", "Uint", "Uint", "ltcsfield") + AssertError(t, errs, "Test.Float", "Test.Float", "Float", "Float", "ltcsfield") + AssertError(t, errs, "Test.Array", "Test.Array", "Array", "Array", "ltcsfield") + + type Other struct { + Value string + } + + type Test2 struct { + Value Other + Time time.Time `validate:"ltcsfield=Value"` + } + + tst := Test2{ + Value: Other{Value: "StringVal"}, + Time: then, + } + + errs = validate.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test2.Time", "Test2.Time", "Time", "Time", "ltcsfield") +} + +func TestCrossStructGteFieldValidation(t *testing.T) { + + type Inner struct { + CreatedAt *time.Time + String string + Int int + Uint uint + Float float64 + Array []string + } + + type Test struct { + Inner *Inner + CreatedAt *time.Time `validate:"gtecsfield=Inner.CreatedAt"` + String string `validate:"gtecsfield=Inner.String"` + Int int `validate:"gtecsfield=Inner.Int"` + Uint uint `validate:"gtecsfield=Inner.Uint"` + Float float64 `validate:"gtecsfield=Inner.Float"` + Array []string `validate:"gtecsfield=Inner.Array"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * -5) + + inner := &Inner{ + CreatedAt: &then, + String: "abcd", + Int: 13, + Uint: 13, + Float: 1.13, + Array: []string{"val1", "val2"}, + } + + test := &Test{ + Inner: inner, + CreatedAt: &now, + String: "abcde", + Int: 14, + Uint: 14, + Float: 1.14, + Array: []string{"val1", "val2", "val3"}, + } + + validate := New() + errs := validate.Struct(test) + Equal(t, errs, nil) + + test.CreatedAt = &then + test.String = "abcd" + test.Int = 13 + test.Uint = 13 + test.Float = 1.13 + test.Array = []string{"val1", "val2"} + + errs = validate.Struct(test) + Equal(t, errs, nil) + + before := now.Add(time.Hour * -10) + + test.CreatedAt = &before + test.String = "abc" + test.Int = 12 + test.Uint = 12 + test.Float = 1.12 + test.Array = []string{"val1"} + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "gtecsfield") + AssertError(t, errs, "Test.String", "Test.String", "String", "String", "gtecsfield") + AssertError(t, errs, "Test.Int", "Test.Int", "Int", "Int", "gtecsfield") + AssertError(t, errs, "Test.Uint", "Test.Uint", "Uint", "Uint", "gtecsfield") + AssertError(t, errs, "Test.Float", "Test.Float", "Float", "Float", "gtecsfield") + AssertError(t, errs, "Test.Array", "Test.Array", "Array", "Array", "gtecsfield") + + errs = validate.VarWithValue(1, "", "gtecsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtecsfield") + + // this test is for the WARNING about unforseen validation issues. + errs = validate.VarWithValue(test, now, "gtecsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "gtecsfield") + AssertError(t, errs, "Test.String", "Test.String", "String", "String", "gtecsfield") + AssertError(t, errs, "Test.Int", "Test.Int", "Int", "Int", "gtecsfield") + AssertError(t, errs, "Test.Uint", "Test.Uint", "Uint", "Uint", "gtecsfield") + AssertError(t, errs, "Test.Float", "Test.Float", "Float", "Float", "gtecsfield") + AssertError(t, errs, "Test.Array", "Test.Array", "Array", "Array", "gtecsfield") + + type Other struct { + Value string + } + + type Test2 struct { + Value Other + Time time.Time `validate:"gtecsfield=Value"` + } + + tst := Test2{ + Value: Other{Value: "StringVal"}, + Time: then, + } + + errs = validate.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test2.Time", "Test2.Time", "Time", "Time", "gtecsfield") +} + +func TestCrossStructGtFieldValidation(t *testing.T) { + + type Inner struct { + CreatedAt *time.Time + String string + Int int + Uint uint + Float float64 + Array []string + } + + type Test struct { + Inner *Inner + CreatedAt *time.Time `validate:"gtcsfield=Inner.CreatedAt"` + String string `validate:"gtcsfield=Inner.String"` + Int int `validate:"gtcsfield=Inner.Int"` + Uint uint `validate:"gtcsfield=Inner.Uint"` + Float float64 `validate:"gtcsfield=Inner.Float"` + Array []string `validate:"gtcsfield=Inner.Array"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * -5) + + inner := &Inner{ + CreatedAt: &then, + String: "abcd", + Int: 13, + Uint: 13, + Float: 1.13, + Array: []string{"val1", "val2"}, + } + + test := &Test{ + Inner: inner, + CreatedAt: &now, + String: "abcde", + Int: 14, + Uint: 14, + Float: 1.14, + Array: []string{"val1", "val2", "val3"}, + } + + validate := New() + errs := validate.Struct(test) + Equal(t, errs, nil) + + test.CreatedAt = &then + test.String = "abcd" + test.Int = 13 + test.Uint = 13 + test.Float = 1.13 + test.Array = []string{"val1", "val2"} + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "gtcsfield") + AssertError(t, errs, "Test.String", "Test.String", "String", "String", "gtcsfield") + AssertError(t, errs, "Test.Int", "Test.Int", "Int", "Int", "gtcsfield") + AssertError(t, errs, "Test.Uint", "Test.Uint", "Uint", "Uint", "gtcsfield") + AssertError(t, errs, "Test.Float", "Test.Float", "Float", "Float", "gtcsfield") + AssertError(t, errs, "Test.Array", "Test.Array", "Array", "Array", "gtcsfield") + + errs = validate.VarWithValue(1, "", "gtcsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtcsfield") + + // this test is for the WARNING about unforseen validation issues. + errs = validate.VarWithValue(test, now, "gtcsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "gtcsfield") + AssertError(t, errs, "Test.String", "Test.String", "String", "String", "gtcsfield") + AssertError(t, errs, "Test.Int", "Test.Int", "Int", "Int", "gtcsfield") + AssertError(t, errs, "Test.Uint", "Test.Uint", "Uint", "Uint", "gtcsfield") + AssertError(t, errs, "Test.Float", "Test.Float", "Float", "Float", "gtcsfield") + AssertError(t, errs, "Test.Array", "Test.Array", "Array", "Array", "gtcsfield") + + type Other struct { + Value string + } + + type Test2 struct { + Value Other + Time time.Time `validate:"gtcsfield=Value"` + } + + tst := Test2{ + Value: Other{Value: "StringVal"}, + Time: then, + } + + errs = validate.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test2.Time", "Test2.Time", "Time", "Time", "gtcsfield") +} + +func TestCrossStructNeFieldValidation(t *testing.T) { + + type Inner struct { + CreatedAt *time.Time + } + + type Test struct { + Inner *Inner + CreatedAt *time.Time `validate:"necsfield=Inner.CreatedAt"` + } + + now := time.Now().UTC() + then := now.Add(time.Hour * 5) + + inner := &Inner{ + CreatedAt: &then, + } + + test := &Test{ + Inner: inner, + CreatedAt: &now, + } + + validate := New() + errs := validate.Struct(test) + Equal(t, errs, nil) + + test.CreatedAt = &then + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "necsfield") + + var j uint64 + var k float64 + var j2 uint64 + var k2 float64 + s := "abcd" + i := 1 + j = 1 + k = 1.543 + arr := []string{"test"} + + s2 := "abcd" + i2 := 1 + j2 = 1 + k2 = 1.543 + arr2 := []string{"test"} + arr3 := []string{"test", "test2"} + now2 := now + + errs = validate.VarWithValue(s, s2, "necsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "necsfield") + + errs = validate.VarWithValue(i2, i, "necsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "necsfield") + + errs = validate.VarWithValue(j2, j, "necsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "necsfield") + + errs = validate.VarWithValue(k2, k, "necsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "necsfield") + + errs = validate.VarWithValue(arr2, arr, "necsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "necsfield") + + errs = validate.VarWithValue(now2, now, "necsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "necsfield") + + errs = validate.VarWithValue(arr3, arr, "necsfield") + Equal(t, errs, nil) + + type SInner struct { + Name string + } + + type TStruct struct { + Inner *SInner + CreatedAt *time.Time `validate:"necsfield=Inner"` + } + + sinner := &SInner{ + Name: "NAME", + } + + test2 := &TStruct{ + Inner: sinner, + CreatedAt: &now, + } + + errs = validate.Struct(test2) + Equal(t, errs, nil) + + test2.Inner = nil + errs = validate.Struct(test2) + Equal(t, errs, nil) + + errs = validate.VarWithValue(nil, 1, "necsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "necsfield") +} + +func TestCrossStructEqFieldValidation(t *testing.T) { + + type Inner struct { + CreatedAt *time.Time + } + + type Test struct { + Inner *Inner + CreatedAt *time.Time `validate:"eqcsfield=Inner.CreatedAt"` + } + + now := time.Now().UTC() + + inner := &Inner{ + CreatedAt: &now, + } + + test := &Test{ + Inner: inner, + CreatedAt: &now, + } + + validate := New() + errs := validate.Struct(test) + Equal(t, errs, nil) + + newTime := time.Now().UTC() + test.CreatedAt = &newTime + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.CreatedAt", "Test.CreatedAt", "CreatedAt", "CreatedAt", "eqcsfield") + + var j uint64 + var k float64 + s := "abcd" + i := 1 + j = 1 + k = 1.543 + arr := []string{"test"} + + var j2 uint64 + var k2 float64 + s2 := "abcd" + i2 := 1 + j2 = 1 + k2 = 1.543 + arr2 := []string{"test"} + arr3 := []string{"test", "test2"} + now2 := now + + errs = validate.VarWithValue(s, s2, "eqcsfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(i2, i, "eqcsfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(j2, j, "eqcsfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(k2, k, "eqcsfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(arr2, arr, "eqcsfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(now2, now, "eqcsfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(arr3, arr, "eqcsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "eqcsfield") + + type SInner struct { + Name string + } + + type TStruct struct { + Inner *SInner + CreatedAt *time.Time `validate:"eqcsfield=Inner"` + } + + sinner := &SInner{ + Name: "NAME", + } + + test2 := &TStruct{ + Inner: sinner, + CreatedAt: &now, + } + + errs = validate.Struct(test2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TStruct.CreatedAt", "TStruct.CreatedAt", "CreatedAt", "CreatedAt", "eqcsfield") + + test2.Inner = nil + errs = validate.Struct(test2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TStruct.CreatedAt", "TStruct.CreatedAt", "CreatedAt", "CreatedAt", "eqcsfield") + + errs = validate.VarWithValue(nil, 1, "eqcsfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "eqcsfield") +} + +func TestCrossNamespaceFieldValidation(t *testing.T) { + + type SliceStruct struct { + Name string + } + + type MapStruct struct { + Name string + } + + type Inner struct { + CreatedAt *time.Time + Slice []string + SliceStructs []*SliceStruct + SliceSlice [][]string + SliceSliceStruct [][]*SliceStruct + SliceMap []map[string]string + Map map[string]string + MapMap map[string]map[string]string + MapStructs map[string]*SliceStruct + MapMapStruct map[string]map[string]*SliceStruct + MapSlice map[string][]string + MapInt map[int]string + MapInt8 map[int8]string + MapInt16 map[int16]string + MapInt32 map[int32]string + MapInt64 map[int64]string + MapUint map[uint]string + MapUint8 map[uint8]string + MapUint16 map[uint16]string + MapUint32 map[uint32]string + MapUint64 map[uint64]string + MapFloat32 map[float32]string + MapFloat64 map[float64]string + MapBool map[bool]string + } + + type Test struct { + Inner *Inner + CreatedAt *time.Time + } + + now := time.Now() + + inner := &Inner{ + CreatedAt: &now, + Slice: []string{"val1", "val2", "val3"}, + SliceStructs: []*SliceStruct{{Name: "name1"}, {Name: "name2"}, {Name: "name3"}}, + SliceSlice: [][]string{{"1", "2", "3"}, {"4", "5", "6"}, {"7", "8", "9"}}, + SliceSliceStruct: [][]*SliceStruct{{{Name: "name1"}, {Name: "name2"}, {Name: "name3"}}, {{Name: "name4"}, {Name: "name5"}, {Name: "name6"}}, {{Name: "name7"}, {Name: "name8"}, {Name: "name9"}}}, + SliceMap: []map[string]string{{"key1": "val1", "key2": "val2", "key3": "val3"}, {"key4": "val4", "key5": "val5", "key6": "val6"}}, + Map: map[string]string{"key1": "val1", "key2": "val2", "key3": "val3"}, + MapStructs: map[string]*SliceStruct{"key1": {Name: "name1"}, "key2": {Name: "name2"}, "key3": {Name: "name3"}}, + MapMap: map[string]map[string]string{"key1": {"key1-1": "val1"}, "key2": {"key2-1": "val2"}, "key3": {"key3-1": "val3"}}, + MapMapStruct: map[string]map[string]*SliceStruct{"key1": {"key1-1": {Name: "name1"}}, "key2": {"key2-1": {Name: "name2"}}, "key3": {"key3-1": {Name: "name3"}}}, + MapSlice: map[string][]string{"key1": {"1", "2", "3"}, "key2": {"4", "5", "6"}, "key3": {"7", "8", "9"}}, + MapInt: map[int]string{1: "val1", 2: "val2", 3: "val3"}, + MapInt8: map[int8]string{1: "val1", 2: "val2", 3: "val3"}, + MapInt16: map[int16]string{1: "val1", 2: "val2", 3: "val3"}, + MapInt32: map[int32]string{1: "val1", 2: "val2", 3: "val3"}, + MapInt64: map[int64]string{1: "val1", 2: "val2", 3: "val3"}, + MapUint: map[uint]string{1: "val1", 2: "val2", 3: "val3"}, + MapUint8: map[uint8]string{1: "val1", 2: "val2", 3: "val3"}, + MapUint16: map[uint16]string{1: "val1", 2: "val2", 3: "val3"}, + MapUint32: map[uint32]string{1: "val1", 2: "val2", 3: "val3"}, + MapUint64: map[uint64]string{1: "val1", 2: "val2", 3: "val3"}, + MapFloat32: map[float32]string{1.01: "val1", 2.02: "val2", 3.03: "val3"}, + MapFloat64: map[float64]string{1.01: "val1", 2.02: "val2", 3.03: "val3"}, + MapBool: map[bool]string{true: "val1", false: "val2"}, + } + + test := &Test{ + Inner: inner, + CreatedAt: &now, + } + + val := reflect.ValueOf(test) + + vd := New() + v := &validate{ + v: vd, + } + + current, kind, ok := v.getStructFieldOKInternal(val, "Inner.CreatedAt") + Equal(t, ok, true) + Equal(t, kind, reflect.Struct) + tm, ok := current.Interface().(time.Time) + Equal(t, ok, true) + Equal(t, tm, now) + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.Slice[1]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.CrazyNonExistantField") + Equal(t, ok, false) + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.Slice[101]") + Equal(t, ok, false) + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.Map[key3]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val3") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapMap[key2][key2-1]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapStructs[key2].Name") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "name2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapMapStruct[key3][key3-1].Name") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "name3") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.SliceSlice[2][0]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "7") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.SliceSliceStruct[2][1].Name") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "name8") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.SliceMap[1][key5]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val5") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapSlice[key3][2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "9") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapInt[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapInt8[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapInt16[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapInt32[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapInt64[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapUint[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapUint8[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapUint16[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapUint32[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapUint64[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapFloat32[3.03]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val3") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapFloat64[2.02]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val2") + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.MapBool[true]") + Equal(t, ok, true) + Equal(t, kind, reflect.String) + Equal(t, current.String(), "val1") + + inner = &Inner{ + CreatedAt: &now, + Slice: []string{"val1", "val2", "val3"}, + SliceStructs: []*SliceStruct{{Name: "name1"}, {Name: "name2"}, nil}, + SliceSlice: [][]string{{"1", "2", "3"}, {"4", "5", "6"}, {"7", "8", "9"}}, + SliceSliceStruct: [][]*SliceStruct{{{Name: "name1"}, {Name: "name2"}, {Name: "name3"}}, {{Name: "name4"}, {Name: "name5"}, {Name: "name6"}}, {{Name: "name7"}, {Name: "name8"}, {Name: "name9"}}}, + SliceMap: []map[string]string{{"key1": "val1", "key2": "val2", "key3": "val3"}, {"key4": "val4", "key5": "val5", "key6": "val6"}}, + Map: map[string]string{"key1": "val1", "key2": "val2", "key3": "val3"}, + MapStructs: map[string]*SliceStruct{"key1": {Name: "name1"}, "key2": {Name: "name2"}, "key3": {Name: "name3"}}, + MapMap: map[string]map[string]string{"key1": {"key1-1": "val1"}, "key2": {"key2-1": "val2"}, "key3": {"key3-1": "val3"}}, + MapMapStruct: map[string]map[string]*SliceStruct{"key1": {"key1-1": {Name: "name1"}}, "key2": {"key2-1": {Name: "name2"}}, "key3": {"key3-1": {Name: "name3"}}}, + MapSlice: map[string][]string{"key1": {"1", "2", "3"}, "key2": {"4", "5", "6"}, "key3": {"7", "8", "9"}}, + } + + test = &Test{ + Inner: inner, + CreatedAt: nil, + } + + val = reflect.ValueOf(test) + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.SliceStructs[2]") + Equal(t, ok, true) + Equal(t, kind, reflect.Ptr) + Equal(t, current.String(), "<*validator.SliceStruct Value>") + Equal(t, current.IsNil(), true) + + current, kind, ok = v.getStructFieldOKInternal(val, "Inner.SliceStructs[2].Name") + Equal(t, ok, false) + Equal(t, kind, reflect.Ptr) + Equal(t, current.String(), "<*validator.SliceStruct Value>") + Equal(t, current.IsNil(), true) + + PanicMatches(t, func() { v.getStructFieldOKInternal(reflect.ValueOf(1), "crazyinput") }, "Invalid field namespace") +} + +func TestExistsValidation(t *testing.T) { + + jsonText := "{ \"truthiness2\": true }" + + type Thing struct { + Truthiness *bool `json:"truthiness" validate:"required"` + } + + var ting Thing + + err := json.Unmarshal([]byte(jsonText), &ting) + Equal(t, err, nil) + NotEqual(t, ting, nil) + Equal(t, ting.Truthiness, nil) + + validate := New() + errs := validate.Struct(ting) + NotEqual(t, errs, nil) + AssertError(t, errs, "Thing.Truthiness", "Thing.Truthiness", "Truthiness", "Truthiness", "required") + + jsonText = "{ \"truthiness\": true }" + + err = json.Unmarshal([]byte(jsonText), &ting) + Equal(t, err, nil) + NotEqual(t, ting, nil) + Equal(t, ting.Truthiness, true) + + errs = validate.Struct(ting) + Equal(t, errs, nil) +} + +func TestSQLValue2Validation(t *testing.T) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, valuer{}, (*driver.Valuer)(nil), sql.NullString{}, sql.NullInt64{}, sql.NullBool{}, sql.NullFloat64{}) + validate.RegisterCustomTypeFunc(ValidateCustomType, MadeUpCustomType{}) + validate.RegisterCustomTypeFunc(OverrideIntTypeForSomeReason, 1) + + val := valuer{ + Name: "", + } + + errs := validate.Var(val, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + val.Name = "Valid Name" + errs = validate.Var(val, "required") + Equal(t, errs, nil) + + val.Name = "errorme" + + PanicMatches(t, func() { validate.Var(val, "required") }, "SQL Driver Valuer error: some kind of error") + + type myValuer valuer + + myVal := valuer{ + Name: "", + } + + errs = validate.Var(myVal, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + cust := MadeUpCustomType{ + FirstName: "Joey", + LastName: "Bloggs", + } + + c := CustomMadeUpStruct{MadeUp: cust, OverriddenInt: 2} + + errs = validate.Struct(c) + Equal(t, errs, nil) + + c.MadeUp.FirstName = "" + c.OverriddenInt = 1 + + errs = validate.Struct(c) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 2) + AssertError(t, errs, "CustomMadeUpStruct.MadeUp", "CustomMadeUpStruct.MadeUp", "MadeUp", "MadeUp", "required") + AssertError(t, errs, "CustomMadeUpStruct.OverriddenInt", "CustomMadeUpStruct.OverriddenInt", "OverriddenInt", "OverriddenInt", "gt") +} + +func TestSQLValueValidation(t *testing.T) { + + validate := New() + validate.RegisterCustomTypeFunc(ValidateValuerType, (*driver.Valuer)(nil), valuer{}) + validate.RegisterCustomTypeFunc(ValidateCustomType, MadeUpCustomType{}) + validate.RegisterCustomTypeFunc(OverrideIntTypeForSomeReason, 1) + + val := valuer{ + Name: "", + } + + errs := validate.Var(val, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + val.Name = "Valid Name" + errs = validate.Var(val, "required") + Equal(t, errs, nil) + + val.Name = "errorme" + + PanicMatches(t, func() { errs = validate.Var(val, "required") }, "SQL Driver Valuer error: some kind of error") + + type myValuer valuer + + myVal := valuer{ + Name: "", + } + + errs = validate.Var(myVal, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + cust := MadeUpCustomType{ + FirstName: "Joey", + LastName: "Bloggs", + } + + c := CustomMadeUpStruct{MadeUp: cust, OverriddenInt: 2} + + errs = validate.Struct(c) + Equal(t, errs, nil) + + c.MadeUp.FirstName = "" + c.OverriddenInt = 1 + + errs = validate.Struct(c) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 2) + AssertError(t, errs, "CustomMadeUpStruct.MadeUp", "CustomMadeUpStruct.MadeUp", "MadeUp", "MadeUp", "required") + AssertError(t, errs, "CustomMadeUpStruct.OverriddenInt", "CustomMadeUpStruct.OverriddenInt", "OverriddenInt", "OverriddenInt", "gt") +} + +func TestMACValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"3D:F2:C9:A6:B3:4F", true}, + {"3D-F2-C9-A6-B3:4F", false}, + {"123", false}, + {"", false}, + {"abacaba", false}, + {"00:25:96:FF:FE:12:34:56", true}, + {"0025:96FF:FE12:3456", false}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "mac") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d mac failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d mac failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "mac" { + t.Fatalf("Index: %d mac failed Error: %s", i, errs) + } + } + } + } +} + +func TestIPValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"10.0.0.1", true}, + {"172.16.0.1", true}, + {"192.168.0.1", true}, + {"192.168.255.254", true}, + {"192.168.255.256", false}, + {"172.16.255.254", true}, + {"172.16.256.255", false}, + {"2001:cdba:0000:0000:0000:0000:3257:9652", true}, + {"2001:cdba:0:0:0:0:3257:9652", true}, + {"2001:cdba::3257:9652", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "ip") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ip failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ip failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "ip" { + t.Fatalf("Index: %d ip failed Error: %s", i, errs) + } + } + } + } +} + +func TestIPv6Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"10.0.0.1", false}, + {"172.16.0.1", false}, + {"192.168.0.1", false}, + {"192.168.255.254", false}, + {"192.168.255.256", false}, + {"172.16.255.254", false}, + {"172.16.256.255", false}, + {"2001:cdba:0000:0000:0000:0000:3257:9652", true}, + {"2001:cdba:0:0:0:0:3257:9652", true}, + {"2001:cdba::3257:9652", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "ipv6") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ipv6 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ipv6 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "ipv6" { + t.Fatalf("Index: %d ipv6 failed Error: %s", i, errs) + } + } + } + } +} + +func TestIPv4Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"10.0.0.1", true}, + {"172.16.0.1", true}, + {"192.168.0.1", true}, + {"192.168.255.254", true}, + {"192.168.255.256", false}, + {"172.16.255.254", true}, + {"172.16.256.255", false}, + {"2001:cdba:0000:0000:0000:0000:3257:9652", false}, + {"2001:cdba:0:0:0:0:3257:9652", false}, + {"2001:cdba::3257:9652", false}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "ipv4") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ipv4 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ipv4 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "ipv4" { + t.Fatalf("Index: %d ipv4 failed Error: %s", i, errs) + } + } + } + } +} + +func TestCIDRValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"10.0.0.0/0", true}, + {"10.0.0.1/8", true}, + {"172.16.0.1/16", true}, + {"192.168.0.1/24", true}, + {"192.168.255.254/24", true}, + {"192.168.255.254/48", false}, + {"192.168.255.256/24", false}, + {"172.16.255.254/16", true}, + {"172.16.256.255/16", false}, + {"2001:cdba:0000:0000:0000:0000:3257:9652/64", true}, + {"2001:cdba:0000:0000:0000:0000:3257:9652/256", false}, + {"2001:cdba:0:0:0:0:3257:9652/32", true}, + {"2001:cdba::3257:9652/16", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "cidr") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d cidr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d cidr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "cidr" { + t.Fatalf("Index: %d cidr failed Error: %s", i, errs) + } + } + } + } +} + +func TestCIDRv6Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"10.0.0.0/0", false}, + {"10.0.0.1/8", false}, + {"172.16.0.1/16", false}, + {"192.168.0.1/24", false}, + {"192.168.255.254/24", false}, + {"192.168.255.254/48", false}, + {"192.168.255.256/24", false}, + {"172.16.255.254/16", false}, + {"172.16.256.255/16", false}, + {"2001:cdba:0000:0000:0000:0000:3257:9652/64", true}, + {"2001:cdba:0000:0000:0000:0000:3257:9652/256", false}, + {"2001:cdba:0:0:0:0:3257:9652/32", true}, + {"2001:cdba::3257:9652/16", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "cidrv6") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d cidrv6 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d cidrv6 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "cidrv6" { + t.Fatalf("Index: %d cidrv6 failed Error: %s", i, errs) + } + } + } + } +} + +func TestCIDRv4Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"10.0.0.0/0", true}, + {"10.0.0.1/8", true}, + {"172.16.0.1/16", true}, + {"192.168.0.1/24", true}, + {"192.168.255.254/24", true}, + {"192.168.255.254/48", false}, + {"192.168.255.256/24", false}, + {"172.16.255.254/16", true}, + {"172.16.256.255/16", false}, + {"2001:cdba:0000:0000:0000:0000:3257:9652/64", false}, + {"2001:cdba:0000:0000:0000:0000:3257:9652/256", false}, + {"2001:cdba:0:0:0:0:3257:9652/32", false}, + {"2001:cdba::3257:9652/16", false}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "cidrv4") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d cidrv4 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d cidrv4 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "cidrv4" { + t.Fatalf("Index: %d cidrv4 failed Error: %s", i, errs) + } + } + } + } +} + +func TestTCPAddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {":80", false}, + {"127.0.0.1:80", true}, + {"[::1]:80", true}, + {"256.0.0.0:1", false}, + {"[::1]", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "tcp_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d tcp_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d tcp_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "tcp_addr" { + t.Fatalf("Index: %d tcp_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestTCP6AddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {":80", false}, + {"127.0.0.1:80", false}, + {"[::1]:80", true}, + {"256.0.0.0:1", false}, + {"[::1]", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "tcp6_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d tcp6_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d tcp6_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "tcp6_addr" { + t.Fatalf("Index: %d tcp6_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestTCP4AddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {":80", false}, + {"127.0.0.1:80", true}, + {"[::1]:80", false}, // https://github.com/golang/go/issues/14037 + {"256.0.0.0:1", false}, + {"[::1]", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "tcp4_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d tcp4_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Log(test.param, IsEqual(errs, nil)) + t.Fatalf("Index: %d tcp4_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "tcp4_addr" { + t.Fatalf("Index: %d tcp4_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestUDPAddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {":80", false}, + {"127.0.0.1:80", true}, + {"[::1]:80", true}, + {"256.0.0.0:1", false}, + {"[::1]", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "udp_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d udp_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d udp_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "udp_addr" { + t.Fatalf("Index: %d udp_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestUDP6AddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {":80", false}, + {"127.0.0.1:80", false}, + {"[::1]:80", true}, + {"256.0.0.0:1", false}, + {"[::1]", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "udp6_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d udp6_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d udp6_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "udp6_addr" { + t.Fatalf("Index: %d udp6_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestUDP4AddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {":80", false}, + {"127.0.0.1:80", true}, + {"[::1]:80", false}, // https://github.com/golang/go/issues/14037 + {"256.0.0.0:1", false}, + {"[::1]", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "udp4_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d udp4_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Log(test.param, IsEqual(errs, nil)) + t.Fatalf("Index: %d udp4_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "udp4_addr" { + t.Fatalf("Index: %d udp4_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestIPAddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"127.0.0.1", true}, + {"127.0.0.1:80", false}, + {"::1", true}, + {"256.0.0.0", false}, + {"localhost", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "ip_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ip_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ip_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "ip_addr" { + t.Fatalf("Index: %d ip_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestIP6AddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"127.0.0.1", false}, // https://github.com/golang/go/issues/14037 + {"127.0.0.1:80", false}, + {"::1", true}, + {"0:0:0:0:0:0:0:1", true}, + {"256.0.0.0", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "ip6_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ip6_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ip6_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "ip6_addr" { + t.Fatalf("Index: %d ip6_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestIP4AddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"127.0.0.1", true}, + {"127.0.0.1:80", false}, + {"::1", false}, // https://github.com/golang/go/issues/14037 + {"256.0.0.0", false}, + {"localhost", false}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "ip4_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ip4_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Log(test.param, IsEqual(errs, nil)) + t.Fatalf("Index: %d ip4_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "ip4_addr" { + t.Fatalf("Index: %d ip4_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestUnixAddrValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", true}, + {"v.sock", true}, + } + + validate := New() + + for i, test := range tests { + errs := validate.Var(test.param, "unix_addr") + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d unix_addr failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Log(test.param, IsEqual(errs, nil)) + t.Fatalf("Index: %d unix_addr failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "unix_addr" { + t.Fatalf("Index: %d unix_addr failed Error: %s", i, errs) + } + } + } + } +} + +func TestSliceMapArrayChanFuncPtrInterfaceRequiredValidation(t *testing.T) { + + validate := New() + + var m map[string]string + + errs := validate.Var(m, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + m = map[string]string{} + errs = validate.Var(m, "required") + Equal(t, errs, nil) + + var arr [5]string + errs = validate.Var(arr, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + arr[0] = "ok" + errs = validate.Var(arr, "required") + Equal(t, errs, nil) + + var s []string + errs = validate.Var(s, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + s = []string{} + errs = validate.Var(s, "required") + Equal(t, errs, nil) + + var c chan string + errs = validate.Var(c, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + c = make(chan string) + errs = validate.Var(c, "required") + Equal(t, errs, nil) + + var tst *int + errs = validate.Var(tst, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + one := 1 + tst = &one + errs = validate.Var(tst, "required") + Equal(t, errs, nil) + + var iface interface{} + + errs = validate.Var(iface, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + errs = validate.Var(iface, "omitempty,required") + Equal(t, errs, nil) + + errs = validate.Var(iface, "") + Equal(t, errs, nil) + + errs = validate.VarWithValue(nil, iface, "") + Equal(t, errs, nil) + + var f func(string) + + errs = validate.Var(f, "required") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "required") + + f = func(name string) {} + + errs = validate.Var(f, "required") + Equal(t, errs, nil) +} + +func TestDatePtrValidationIssueValidation(t *testing.T) { + + type Test struct { + LastViewed *time.Time + Reminder *time.Time + } + + test := &Test{} + + validate := New() + errs := validate.Struct(test) + Equal(t, errs, nil) +} + +func TestCommaAndPipeObfuscationValidation(t *testing.T) { + s := "My Name Is, |joeybloggs|" + + validate := New() + + errs := validate.Var(s, "excludesall=0x2C") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "excludesall") + + errs = validate.Var(s, "excludesall=0x7C") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "excludesall") +} + +func TestBadKeyValidation(t *testing.T) { + type Test struct { + Name string `validate:"required, "` + } + + tst := &Test{ + Name: "test", + } + + validate := New() + + PanicMatches(t, func() { validate.Struct(tst) }, "Undefined validation function ' ' on field 'Name'") + + type Test2 struct { + Name string `validate:"required,,len=2"` + } + + tst2 := &Test2{ + Name: "test", + } + + PanicMatches(t, func() { validate.Struct(tst2) }, "Invalid validation tag on field 'Name'") +} + +func TestInterfaceErrValidation(t *testing.T) { + + var v1 interface{} + var v2 interface{} + + v2 = 1 + v1 = v2 + + validate := New() + errs := validate.Var(v1, "len=1") + Equal(t, errs, nil) + + errs = validate.Var(v2, "len=1") + Equal(t, errs, nil) + + type ExternalCMD struct { + Userid string `json:"userid"` + Action uint32 `json:"action"` + Data interface{} `json:"data,omitempty" validate:"required"` + } + + s := &ExternalCMD{ + Userid: "123456", + Action: 10000, + // Data: 1, + } + + errs = validate.Struct(s) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "ExternalCMD.Data", "ExternalCMD.Data", "Data", "Data", "required") + + type ExternalCMD2 struct { + Userid string `json:"userid"` + Action uint32 `json:"action"` + Data interface{} `json:"data,omitempty" validate:"len=1"` + } + + s2 := &ExternalCMD2{ + Userid: "123456", + Action: 10000, + // Data: 1, + } + + errs = validate.Struct(s2) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "ExternalCMD2.Data", "ExternalCMD2.Data", "Data", "Data", "len") + + s3 := &ExternalCMD2{ + Userid: "123456", + Action: 10000, + Data: 2, + } + + errs = validate.Struct(s3) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "ExternalCMD2.Data", "ExternalCMD2.Data", "Data", "Data", "len") + + type Inner struct { + Name string `validate:"required"` + } + + inner := &Inner{ + Name: "", + } + + s4 := &ExternalCMD{ + Userid: "123456", + Action: 10000, + Data: inner, + } + + errs = validate.Struct(s4) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "ExternalCMD.Data.Name", "ExternalCMD.Data.Name", "Name", "Name", "required") + + type TestMapStructPtr struct { + Errs map[int]interface{} `validate:"gt=0,dive,len=2"` + } + + mip := map[int]interface{}{0: &Inner{"ok"}, 3: nil, 4: &Inner{"ok"}} + + msp := &TestMapStructPtr{ + Errs: mip, + } + + errs = validate.Struct(msp) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "TestMapStructPtr.Errs[3]", "TestMapStructPtr.Errs[3]", "Errs[3]", "Errs[3]", "len") + + type TestMultiDimensionalStructs struct { + Errs [][]interface{} `validate:"gt=0,dive,dive"` + } + + var errStructArray [][]interface{} + + errStructArray = append(errStructArray, []interface{}{&Inner{"ok"}, &Inner{""}, &Inner{""}}) + errStructArray = append(errStructArray, []interface{}{&Inner{"ok"}, &Inner{""}, &Inner{""}}) + + tms := &TestMultiDimensionalStructs{ + Errs: errStructArray, + } + + errs = validate.Struct(tms) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 4) + AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][1].Name", "TestMultiDimensionalStructs.Errs[0][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][2].Name", "TestMultiDimensionalStructs.Errs[0][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructs.Errs[1][1].Name", "TestMultiDimensionalStructs.Errs[1][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructs.Errs[1][2].Name", "TestMultiDimensionalStructs.Errs[1][2].Name", "Name", "Name", "required") + + type TestMultiDimensionalStructsPtr2 struct { + Errs [][]*Inner `validate:"gt=0,dive,dive,required"` + } + + var errStructPtr2Array [][]*Inner + + errStructPtr2Array = append(errStructPtr2Array, []*Inner{{"ok"}, {""}, {""}}) + errStructPtr2Array = append(errStructPtr2Array, []*Inner{{"ok"}, {""}, {""}}) + errStructPtr2Array = append(errStructPtr2Array, []*Inner{{"ok"}, {""}, nil}) + + tmsp2 := &TestMultiDimensionalStructsPtr2{ + Errs: errStructPtr2Array, + } + + errs = validate.Struct(tmsp2) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 6) + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][1].Name", "TestMultiDimensionalStructsPtr2.Errs[0][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][2].Name", "TestMultiDimensionalStructsPtr2.Errs[0][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[1][1].Name", "TestMultiDimensionalStructsPtr2.Errs[1][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[1][2].Name", "TestMultiDimensionalStructsPtr2.Errs[1][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[2][1].Name", "TestMultiDimensionalStructsPtr2.Errs[2][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[2][2]", "TestMultiDimensionalStructsPtr2.Errs[2][2]", "Errs[2][2]", "Errs[2][2]", "required") + + m := map[int]interface{}{0: "ok", 3: "", 4: "ok"} + + errs = validate.Var(m, "len=3,dive,len=2") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "[3]", "[3]", "[3]", "[3]", "len") + + errs = validate.Var(m, "len=2,dive,required") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "", "", "", "", "len") + + arr := []interface{}{"ok", "", "ok"} + + errs = validate.Var(arr, "len=3,dive,len=2") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "[1]", "[1]", "[1]", "[1]", "len") + + errs = validate.Var(arr, "len=2,dive,required") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "", "", "", "", "len") + + type MyStruct struct { + A, B string + C interface{} + } + + var a MyStruct + + a.A = "value" + a.C = "nu" + + errs = validate.Struct(a) + Equal(t, errs, nil) +} + +func TestMapDiveValidation(t *testing.T) { + + validate := New() + + n := map[int]interface{}{0: nil} + errs := validate.Var(n, "omitempty,required") + Equal(t, errs, nil) + + m := map[int]string{0: "ok", 3: "", 4: "ok"} + + errs = validate.Var(m, "len=3,dive,required") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "[3]", "[3]", "[3]", "[3]", "required") + + errs = validate.Var(m, "len=2,dive,required") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "", "", "", "", "len") + + type Inner struct { + Name string `validate:"required"` + } + + type TestMapStruct struct { + Errs map[int]Inner `validate:"gt=0,dive"` + } + + mi := map[int]Inner{0: {"ok"}, 3: {""}, 4: {"ok"}} + + ms := &TestMapStruct{ + Errs: mi, + } + + errs = validate.Struct(ms) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "TestMapStruct.Errs[3].Name", "TestMapStruct.Errs[3].Name", "Name", "Name", "required") + + // for full test coverage + s := fmt.Sprint(errs.Error()) + NotEqual(t, s, "") + + type TestMapTimeStruct struct { + Errs map[int]*time.Time `validate:"gt=0,dive,required"` + } + + t1 := time.Now().UTC() + + mta := map[int]*time.Time{0: &t1, 3: nil, 4: nil} + + mt := &TestMapTimeStruct{ + Errs: mta, + } + + errs = validate.Struct(mt) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 2) + AssertError(t, errs, "TestMapTimeStruct.Errs[3]", "TestMapTimeStruct.Errs[3]", "Errs[3]", "Errs[3]", "required") + AssertError(t, errs, "TestMapTimeStruct.Errs[4]", "TestMapTimeStruct.Errs[4]", "Errs[4]", "Errs[4]", "required") + + type TestMapStructPtr struct { + Errs map[int]*Inner `validate:"gt=0,dive,required"` + } + + mip := map[int]*Inner{0: {"ok"}, 3: nil, 4: {"ok"}} + + msp := &TestMapStructPtr{ + Errs: mip, + } + + errs = validate.Struct(msp) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "TestMapStructPtr.Errs[3]", "TestMapStructPtr.Errs[3]", "Errs[3]", "Errs[3]", "required") + + type TestMapStructPtr2 struct { + Errs map[int]*Inner `validate:"gt=0,dive,omitempty,required"` + } + + mip2 := map[int]*Inner{0: {"ok"}, 3: nil, 4: {"ok"}} + + msp2 := &TestMapStructPtr2{ + Errs: mip2, + } + + errs = validate.Struct(msp2) + Equal(t, errs, nil) + + v2 := New() + v2.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + type MapDiveJSONTest struct { + Map map[string]string `validate:"required,gte=1,dive,gte=1" json:"MyName"` + } + + mdjt := &MapDiveJSONTest{ + Map: map[string]string{ + "Key1": "Value1", + "Key2": "", + }, + } + + err := v2.Struct(mdjt) + NotEqual(t, err, nil) + + errs = err.(ValidationErrors) + fe := getError(errs, "MapDiveJSONTest.MyName[Key2]", "MapDiveJSONTest.Map[Key2]") + NotEqual(t, fe, nil) + Equal(t, fe.Tag(), "gte") + Equal(t, fe.ActualTag(), "gte") + Equal(t, fe.Field(), "MyName[Key2]") + Equal(t, fe.StructField(), "Map[Key2]") +} + +func TestArrayDiveValidation(t *testing.T) { + + validate := New() + + arr := []string{"ok", "", "ok"} + + errs := validate.Var(arr, "len=3,dive,required") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "[1]", "[1]", "[1]", "[1]", "required") + + errs = validate.Var(arr, "len=2,dive,required") + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "", "", "", "", "len") + + type BadDive struct { + Name string `validate:"dive"` + } + + bd := &BadDive{ + Name: "TEST", + } + + PanicMatches(t, func() { validate.Struct(bd) }, "dive error! can't dive on a non slice or map") + + type Test struct { + Errs []string `validate:"gt=0,dive,required"` + } + + test := &Test{ + Errs: []string{"ok", "", "ok"}, + } + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "Test.Errs[1]", "Test.Errs[1]", "Errs[1]", "Errs[1]", "required") + + test = &Test{ + Errs: []string{"ok", "ok", ""}, + } + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "Test.Errs[2]", "Test.Errs[2]", "Errs[2]", "Errs[2]", "required") + + type TestMultiDimensional struct { + Errs [][]string `validate:"gt=0,dive,dive,required"` + } + + var errArray [][]string + + errArray = append(errArray, []string{"ok", "", ""}) + errArray = append(errArray, []string{"ok", "", ""}) + + tm := &TestMultiDimensional{ + Errs: errArray, + } + + errs = validate.Struct(tm) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 4) + AssertError(t, errs, "TestMultiDimensional.Errs[0][1]", "TestMultiDimensional.Errs[0][1]", "Errs[0][1]", "Errs[0][1]", "required") + AssertError(t, errs, "TestMultiDimensional.Errs[0][2]", "TestMultiDimensional.Errs[0][2]", "Errs[0][2]", "Errs[0][2]", "required") + AssertError(t, errs, "TestMultiDimensional.Errs[1][1]", "TestMultiDimensional.Errs[1][1]", "Errs[1][1]", "Errs[1][1]", "required") + AssertError(t, errs, "TestMultiDimensional.Errs[1][2]", "TestMultiDimensional.Errs[1][2]", "Errs[1][2]", "Errs[1][2]", "required") + + type Inner struct { + Name string `validate:"required"` + } + + type TestMultiDimensionalStructs struct { + Errs [][]Inner `validate:"gt=0,dive,dive"` + } + + var errStructArray [][]Inner + + errStructArray = append(errStructArray, []Inner{{"ok"}, {""}, {""}}) + errStructArray = append(errStructArray, []Inner{{"ok"}, {""}, {""}}) + + tms := &TestMultiDimensionalStructs{ + Errs: errStructArray, + } + + errs = validate.Struct(tms) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 4) + AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][1].Name", "TestMultiDimensionalStructs.Errs[0][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructs.Errs[0][2].Name", "TestMultiDimensionalStructs.Errs[0][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructs.Errs[1][1].Name", "TestMultiDimensionalStructs.Errs[1][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructs.Errs[1][2].Name", "TestMultiDimensionalStructs.Errs[1][2].Name", "Name", "Name", "required") + + type TestMultiDimensionalStructsPtr struct { + Errs [][]*Inner `validate:"gt=0,dive,dive"` + } + + var errStructPtrArray [][]*Inner + + errStructPtrArray = append(errStructPtrArray, []*Inner{{"ok"}, {""}, {""}}) + errStructPtrArray = append(errStructPtrArray, []*Inner{{"ok"}, {""}, {""}}) + errStructPtrArray = append(errStructPtrArray, []*Inner{{"ok"}, {""}, nil}) + + tmsp := &TestMultiDimensionalStructsPtr{ + Errs: errStructPtrArray, + } + + errs = validate.Struct(tmsp) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 5) + AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][1].Name", "TestMultiDimensionalStructsPtr.Errs[0][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][2].Name", "TestMultiDimensionalStructsPtr.Errs[0][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[1][1].Name", "TestMultiDimensionalStructsPtr.Errs[1][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[1][2].Name", "TestMultiDimensionalStructsPtr.Errs[1][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[2][1].Name", "TestMultiDimensionalStructsPtr.Errs[2][1].Name", "Name", "Name", "required") + + // for full test coverage + s := fmt.Sprint(errs.Error()) + NotEqual(t, s, "") + + type TestMultiDimensionalStructsPtr2 struct { + Errs [][]*Inner `validate:"gt=0,dive,dive,required"` + } + + var errStructPtr2Array [][]*Inner + + errStructPtr2Array = append(errStructPtr2Array, []*Inner{{"ok"}, {""}, {""}}) + errStructPtr2Array = append(errStructPtr2Array, []*Inner{{"ok"}, {""}, {""}}) + errStructPtr2Array = append(errStructPtr2Array, []*Inner{{"ok"}, {""}, nil}) + + tmsp2 := &TestMultiDimensionalStructsPtr2{ + Errs: errStructPtr2Array, + } + + errs = validate.Struct(tmsp2) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 6) + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][1].Name", "TestMultiDimensionalStructsPtr2.Errs[0][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[0][2].Name", "TestMultiDimensionalStructsPtr2.Errs[0][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[1][1].Name", "TestMultiDimensionalStructsPtr2.Errs[1][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[1][2].Name", "TestMultiDimensionalStructsPtr2.Errs[1][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[2][1].Name", "TestMultiDimensionalStructsPtr2.Errs[2][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr2.Errs[2][2]", "TestMultiDimensionalStructsPtr2.Errs[2][2]", "Errs[2][2]", "Errs[2][2]", "required") + + type TestMultiDimensionalStructsPtr3 struct { + Errs [][]*Inner `validate:"gt=0,dive,dive,omitempty"` + } + + var errStructPtr3Array [][]*Inner + + errStructPtr3Array = append(errStructPtr3Array, []*Inner{{"ok"}, {""}, {""}}) + errStructPtr3Array = append(errStructPtr3Array, []*Inner{{"ok"}, {""}, {""}}) + errStructPtr3Array = append(errStructPtr3Array, []*Inner{{"ok"}, {""}, nil}) + + tmsp3 := &TestMultiDimensionalStructsPtr3{ + Errs: errStructPtr3Array, + } + + errs = validate.Struct(tmsp3) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 5) + AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[0][1].Name", "TestMultiDimensionalStructsPtr3.Errs[0][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[0][2].Name", "TestMultiDimensionalStructsPtr3.Errs[0][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[1][1].Name", "TestMultiDimensionalStructsPtr3.Errs[1][1].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[1][2].Name", "TestMultiDimensionalStructsPtr3.Errs[1][2].Name", "Name", "Name", "required") + AssertError(t, errs, "TestMultiDimensionalStructsPtr3.Errs[2][1].Name", "TestMultiDimensionalStructsPtr3.Errs[2][1].Name", "Name", "Name", "required") + + type TestMultiDimensionalTimeTime struct { + Errs [][]*time.Time `validate:"gt=0,dive,dive,required"` + } + + var errTimePtr3Array [][]*time.Time + + t1 := time.Now().UTC() + t2 := time.Now().UTC() + t3 := time.Now().UTC().Add(time.Hour * 24) + + errTimePtr3Array = append(errTimePtr3Array, []*time.Time{&t1, &t2, &t3}) + errTimePtr3Array = append(errTimePtr3Array, []*time.Time{&t1, &t2, nil}) + errTimePtr3Array = append(errTimePtr3Array, []*time.Time{&t1, nil, nil}) + + tmtp3 := &TestMultiDimensionalTimeTime{ + Errs: errTimePtr3Array, + } + + errs = validate.Struct(tmtp3) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 3) + AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[1][2]", "TestMultiDimensionalTimeTime.Errs[1][2]", "Errs[1][2]", "Errs[1][2]", "required") + AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[2][1]", "TestMultiDimensionalTimeTime.Errs[2][1]", "Errs[2][1]", "Errs[2][1]", "required") + AssertError(t, errs, "TestMultiDimensionalTimeTime.Errs[2][2]", "TestMultiDimensionalTimeTime.Errs[2][2]", "Errs[2][2]", "Errs[2][2]", "required") + + type TestMultiDimensionalTimeTime2 struct { + Errs [][]*time.Time `validate:"gt=0,dive,dive,required"` + } + + var errTimeArray [][]*time.Time + + t1 = time.Now().UTC() + t2 = time.Now().UTC() + t3 = time.Now().UTC().Add(time.Hour * 24) + + errTimeArray = append(errTimeArray, []*time.Time{&t1, &t2, &t3}) + errTimeArray = append(errTimeArray, []*time.Time{&t1, &t2, nil}) + errTimeArray = append(errTimeArray, []*time.Time{&t1, nil, nil}) + + tmtp := &TestMultiDimensionalTimeTime2{ + Errs: errTimeArray, + } + + errs = validate.Struct(tmtp) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 3) + AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[1][2]", "TestMultiDimensionalTimeTime2.Errs[1][2]", "Errs[1][2]", "Errs[1][2]", "required") + AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[2][1]", "TestMultiDimensionalTimeTime2.Errs[2][1]", "Errs[2][1]", "Errs[2][1]", "required") + AssertError(t, errs, "TestMultiDimensionalTimeTime2.Errs[2][2]", "TestMultiDimensionalTimeTime2.Errs[2][2]", "Errs[2][2]", "Errs[2][2]", "required") +} + +func TestNilStructPointerValidation(t *testing.T) { + type Inner struct { + Data string + } + + type Outer struct { + Inner *Inner `validate:"omitempty"` + } + + inner := &Inner{ + Data: "test", + } + + outer := &Outer{ + Inner: inner, + } + + validate := New() + errs := validate.Struct(outer) + Equal(t, errs, nil) + + outer = &Outer{ + Inner: nil, + } + + errs = validate.Struct(outer) + Equal(t, errs, nil) + + type Inner2 struct { + Data string + } + + type Outer2 struct { + Inner2 *Inner2 `validate:"required"` + } + + inner2 := &Inner2{ + Data: "test", + } + + outer2 := &Outer2{ + Inner2: inner2, + } + + errs = validate.Struct(outer2) + Equal(t, errs, nil) + + outer2 = &Outer2{ + Inner2: nil, + } + + errs = validate.Struct(outer2) + NotEqual(t, errs, nil) + AssertError(t, errs, "Outer2.Inner2", "Outer2.Inner2", "Inner2", "Inner2", "required") + + type Inner3 struct { + Data string + } + + type Outer3 struct { + Inner3 *Inner3 + } + + inner3 := &Inner3{ + Data: "test", + } + + outer3 := &Outer3{ + Inner3: inner3, + } + + errs = validate.Struct(outer3) + Equal(t, errs, nil) + + type Inner4 struct { + Data string + } + + type Outer4 struct { + Inner4 *Inner4 `validate:"-"` + } + + inner4 := &Inner4{ + Data: "test", + } + + outer4 := &Outer4{ + Inner4: inner4, + } + + errs = validate.Struct(outer4) + Equal(t, errs, nil) +} + +func TestSSNValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"00-90-8787", false}, + {"66690-76", false}, + {"191 60 2869", true}, + {"191-60-2869", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "ssn") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d SSN failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d SSN failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "ssn" { + t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) + } + } + } + } +} + +func TestLongitudeValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"-180.000", true}, + {"180.1", false}, + {"+73.234", true}, + {"+382.3811", false}, + {"23.11111111", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "longitude") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d Longitude failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d Longitude failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "longitude" { + t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) + } + } + } + } +} + +func TestLatitudeValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"-90.000", true}, + {"+90", true}, + {"47.1231231", true}, + {"+99.9", false}, + {"108", false}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "latitude") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "latitude" { + t.Fatalf("Index: %d Latitude failed Error: %s", i, errs) + } + } + } + } +} + +func TestDataURIValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"data:image/png;base64,TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4=", true}, + {"data:text/plain;base64,Vml2YW11cyBmZXJtZW50dW0gc2VtcGVyIHBvcnRhLg==", true}, + {"image/gif;base64,U3VzcGVuZGlzc2UgbGVjdHVzIGxlbw==", false}, + {"data:image/gif;base64,MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuMPNS1Ufof9EW/M98FNw" + + "UAKrwflsqVxaxQjBQnHQmiI7Vac40t8x7pIb8gLGV6wL7sBTJiPovJ0V7y7oc0Ye" + + "rhKh0Rm4skP2z/jHwwZICgGzBvA0rH8xlhUiTvcwDCJ0kc+fh35hNt8srZQM4619" + + "FTgB66Xmp4EtVyhpQV+t02g6NzK72oZI0vnAvqhpkxLeLiMCyrI416wHm5Tkukhx" + + "QmcL2a6hNOyu0ixX/x2kSFXApEnVrJ+/IxGyfyw8kf4N2IZpW5nEP847lpfj0SZZ" + + "Fwrd1mnfnDbYohX2zRptLy2ZUn06Qo9pkG5ntvFEPo9bfZeULtjYzIl6K8gJ2uGZ" + "HQIDAQAB", true}, + {"data:image/png;base64,12345", false}, + {"", false}, + {"data:text,:;base85,U3VzcGVuZGlzc2UgbGVjdHVzIGxlbw==", false}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "datauri") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d DataURI failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d DataURI failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "datauri" { + t.Fatalf("Index: %d DataURI failed Error: %s", i, errs) + } + } + } + } +} + +func TestMultibyteValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", true}, + {"abc", false}, + {"123", false}, + {"<>@;.-=", false}, + {"ひらがな・カタカナ、.漢字", true}, + {"あいうえお foobar", true}, + {"test@example.com", true}, + {"test@example.com", true}, + {"1234abcDExyz", true}, + {"カタカナ", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "multibyte") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d Multibyte failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d Multibyte failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "multibyte" { + t.Fatalf("Index: %d Multibyte failed Error: %s", i, errs) + } + } + } + } +} + +func TestPrintableASCIIValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", true}, + {"foobar", false}, + {"xyz098", false}, + {"123456", false}, + {"カタカナ", false}, + {"foobar", true}, + {"0987654321", true}, + {"test@example.com", true}, + {"1234abcDEF", true}, + {"newline\n", false}, + {"\x19test\x7F", false}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "printascii") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d Printable ASCII failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d Printable ASCII failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "printascii" { + t.Fatalf("Index: %d Printable ASCII failed Error: %s", i, errs) + } + } + } + } +} + +func TestASCIIValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", true}, + {"foobar", false}, + {"xyz098", false}, + {"123456", false}, + {"カタカナ", false}, + {"foobar", true}, + {"0987654321", true}, + {"test@example.com", true}, + {"1234abcDEF", true}, + {"", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "ascii") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ASCII failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ASCII failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "ascii" { + t.Fatalf("Index: %d ASCII failed Error: %s", i, errs) + } + } + } + } +} + +func TestUUID5Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + + {"", false}, + {"xxxa987fbc9-4bed-3078-cf07-9141ba07c9f3", false}, + {"9c858901-8a57-4791-81fe-4c455b099bc9", false}, + {"a987fbc9-4bed-3078-cf07-9141ba07c9f3", false}, + {"987fbc97-4bed-5078-af07-9141ba07c9f3", true}, + {"987fbc97-4bed-5078-9f07-9141ba07c9f3", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "uuid5") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d UUID5 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d UUID5 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "uuid5" { + t.Fatalf("Index: %d UUID5 failed Error: %s", i, errs) + } + } + } + } +} + +func TestUUID4Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"xxxa987fbc9-4bed-3078-cf07-9141ba07c9f3", false}, + {"a987fbc9-4bed-5078-af07-9141ba07c9f3", false}, + {"934859", false}, + {"57b73598-8764-4ad0-a76a-679bb6640eb1", true}, + {"625e63f3-58f5-40b7-83a1-a72ad31acffb", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "uuid4") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d UUID4 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d UUID4 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "uuid4" { + t.Fatalf("Index: %d UUID4 failed Error: %s", i, errs) + } + } + } + } +} + +func TestUUID3Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"412452646", false}, + {"xxxa987fbc9-4bed-3078-cf07-9141ba07c9f3", false}, + {"a987fbc9-4bed-4078-8f07-9141ba07c9f3", false}, + {"a987fbc9-4bed-3078-cf07-9141ba07c9f3", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "uuid3") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d UUID3 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d UUID3 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "uuid3" { + t.Fatalf("Index: %d UUID3 failed Error: %s", i, errs) + } + } + } + } +} + +func TestUUIDValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"xxxa987fbc9-4bed-3078-cf07-9141ba07c9f3", false}, + {"a987fbc9-4bed-3078-cf07-9141ba07c9f3xxx", false}, + {"a987fbc94bed3078cf079141ba07c9f3", false}, + {"934859", false}, + {"987fbc9-4bed-3078-cf07a-9141ba07c9f3", false}, + {"aaaaaaaa-1111-1111-aaag-111111111111", false}, + {"a987fbc9-4bed-3078-cf07-9141ba07c9f3", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "uuid") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d UUID failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d UUID failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "uuid" { + t.Fatalf("Index: %d UUID failed Error: %s", i, errs) + } + } + } + } +} + +func TestISBNValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"foo", false}, + {"3836221195", true}, + {"1-61729-085-8", true}, + {"3 423 21412 0", true}, + {"3 401 01319 X", true}, + {"9784873113685", true}, + {"978-4-87311-368-5", true}, + {"978 3401013190", true}, + {"978-3-8362-2119-1", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "isbn") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ISBN failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ISBN failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "isbn" { + t.Fatalf("Index: %d ISBN failed Error: %s", i, errs) + } + } + } + } +} + +func TestISBN13Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"foo", false}, + {"3-8362-2119-5", false}, + {"01234567890ab", false}, + {"978 3 8362 2119 0", false}, + {"9784873113685", true}, + {"978-4-87311-368-5", true}, + {"978 3401013190", true}, + {"978-3-8362-2119-1", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "isbn13") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ISBN13 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ISBN13 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "isbn13" { + t.Fatalf("Index: %d ISBN13 failed Error: %s", i, errs) + } + } + } + } +} + +func TestISBN10Validation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"foo", false}, + {"3423214121", false}, + {"978-3836221191", false}, + {"3-423-21412-1", false}, + {"3 423 21412 1", false}, + {"3836221195", true}, + {"1-61729-085-8", true}, + {"3 423 21412 0", true}, + {"3 401 01319 X", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "isbn10") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d ISBN10 failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d ISBN10 failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "isbn10" { + t.Fatalf("Index: %d ISBN10 failed Error: %s", i, errs) + } + } + } + } +} + +func TestExcludesRuneValidation(t *testing.T) { + + tests := []struct { + Value string `validate:"excludesrune=☻"` + Tag string + ExpectedNil bool + }{ + {Value: "a☺b☻c☹d", Tag: "excludesrune=☻", ExpectedNil: false}, + {Value: "abcd", Tag: "excludesrune=☻", ExpectedNil: true}, + } + + validate := New() + + for i, s := range tests { + errs := validate.Var(s.Value, s.Tag) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + + errs = validate.Struct(s) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + } +} + +func TestExcludesAllValidation(t *testing.T) { + + tests := []struct { + Value string `validate:"excludesall=@!{}[]"` + Tag string + ExpectedNil bool + }{ + {Value: "abcd@!jfk", Tag: "excludesall=@!{}[]", ExpectedNil: false}, + {Value: "abcdefg", Tag: "excludesall=@!{}[]", ExpectedNil: true}, + } + + validate := New() + + for i, s := range tests { + errs := validate.Var(s.Value, s.Tag) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + + errs = validate.Struct(s) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + } + + username := "joeybloggs " + + errs := validate.Var(username, "excludesall=@ ") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "excludesall") + + excluded := "," + + errs = validate.Var(excluded, "excludesall=!@#$%^&*()_+.0x2C?") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "excludesall") + + excluded = "=" + + errs = validate.Var(excluded, "excludesall=!@#$%^&*()_+.0x2C=?") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "excludesall") +} + +func TestExcludesValidation(t *testing.T) { + + tests := []struct { + Value string `validate:"excludes=@"` + Tag string + ExpectedNil bool + }{ + {Value: "abcd@!jfk", Tag: "excludes=@", ExpectedNil: false}, + {Value: "abcdq!jfk", Tag: "excludes=@", ExpectedNil: true}, + } + + validate := New() + + for i, s := range tests { + errs := validate.Var(s.Value, s.Tag) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + + errs = validate.Struct(s) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + } +} + +func TestContainsRuneValidation(t *testing.T) { + + tests := []struct { + Value string `validate:"containsrune=☻"` + Tag string + ExpectedNil bool + }{ + {Value: "a☺b☻c☹d", Tag: "containsrune=☻", ExpectedNil: true}, + {Value: "abcd", Tag: "containsrune=☻", ExpectedNil: false}, + } + + validate := New() + + for i, s := range tests { + errs := validate.Var(s.Value, s.Tag) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + + errs = validate.Struct(s) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + } +} + +func TestContainsAnyValidation(t *testing.T) { + + tests := []struct { + Value string `validate:"containsany=@!{}[]"` + Tag string + ExpectedNil bool + }{ + {Value: "abcd@!jfk", Tag: "containsany=@!{}[]", ExpectedNil: true}, + {Value: "abcdefg", Tag: "containsany=@!{}[]", ExpectedNil: false}, + } + + validate := New() + + for i, s := range tests { + errs := validate.Var(s.Value, s.Tag) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + + errs = validate.Struct(s) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + } +} + +func TestContainsValidation(t *testing.T) { + + tests := []struct { + Value string `validate:"contains=@"` + Tag string + ExpectedNil bool + }{ + {Value: "abcd@!jfk", Tag: "contains=@", ExpectedNil: true}, + {Value: "abcdq!jfk", Tag: "contains=@", ExpectedNil: false}, + } + + validate := New() + + for i, s := range tests { + errs := validate.Var(s.Value, s.Tag) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + + errs = validate.Struct(s) + + if (s.ExpectedNil && errs != nil) || (!s.ExpectedNil && errs == nil) { + t.Fatalf("Index: %d failed Error: %s", i, errs) + } + } +} + +func TestIsNeFieldValidation(t *testing.T) { + + validate := New() + + var j uint64 + var k float64 + s := "abcd" + i := 1 + j = 1 + k = 1.543 + arr := []string{"test"} + now := time.Now().UTC() + + var j2 uint64 + var k2 float64 + s2 := "abcdef" + i2 := 3 + j2 = 2 + k2 = 1.5434456 + arr2 := []string{"test", "test2"} + arr3 := []string{"test"} + now2 := now + + errs := validate.VarWithValue(s, s2, "nefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(i2, i, "nefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(j2, j, "nefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(k2, k, "nefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(arr2, arr, "nefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(now2, now, "nefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "nefield") + + errs = validate.VarWithValue(arr3, arr, "nefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "nefield") + + type Test struct { + Start *time.Time `validate:"nefield=End"` + End *time.Time + } + + sv := &Test{ + Start: &now, + End: &now, + } + + errs = validate.Struct(sv) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.Start", "Test.Start", "Start", "Start", "nefield") + + now3 := time.Now().UTC() + + sv = &Test{ + Start: &now, + End: &now3, + } + + errs = validate.Struct(sv) + Equal(t, errs, nil) + + errs = validate.VarWithValue(nil, 1, "nefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "nefield") + + errs = validate.VarWithValue(sv, now, "nefield") + Equal(t, errs, nil) + + type Test2 struct { + Start *time.Time `validate:"nefield=NonExistantField"` + End *time.Time + } + + sv2 := &Test2{ + Start: &now, + End: &now, + } + + errs = validate.Struct(sv2) + Equal(t, errs, nil) + + type Other struct { + Value string + } + + type Test3 struct { + Value Other + Time time.Time `validate:"nefield=Value"` + } + + tst := Test3{ + Value: Other{Value: "StringVal"}, + Time: now, + } + + errs = validate.Struct(tst) + Equal(t, errs, nil) +} + +func TestIsNeValidation(t *testing.T) { + + validate := New() + + var j uint64 + var k float64 + s := "abcdef" + i := 3 + j = 2 + k = 1.5434 + arr := []string{"test"} + now := time.Now().UTC() + + errs := validate.Var(s, "ne=abcd") + Equal(t, errs, nil) + + errs = validate.Var(i, "ne=1") + Equal(t, errs, nil) + + errs = validate.Var(j, "ne=1") + Equal(t, errs, nil) + + errs = validate.Var(k, "ne=1.543") + Equal(t, errs, nil) + + errs = validate.Var(arr, "ne=2") + Equal(t, errs, nil) + + errs = validate.Var(arr, "ne=1") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ne") + + PanicMatches(t, func() { validate.Var(now, "ne=now") }, "Bad field type time.Time") +} + +func TestIsEqFieldValidation(t *testing.T) { + + validate := New() + + var j uint64 + var k float64 + s := "abcd" + i := 1 + j = 1 + k = 1.543 + arr := []string{"test"} + now := time.Now().UTC() + + var j2 uint64 + var k2 float64 + s2 := "abcd" + i2 := 1 + j2 = 1 + k2 = 1.543 + arr2 := []string{"test"} + arr3 := []string{"test", "test2"} + now2 := now + + errs := validate.VarWithValue(s, s2, "eqfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(i2, i, "eqfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(j2, j, "eqfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(k2, k, "eqfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(arr2, arr, "eqfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(now2, now, "eqfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(arr3, arr, "eqfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "eqfield") + + type Test struct { + Start *time.Time `validate:"eqfield=End"` + End *time.Time + } + + sv := &Test{ + Start: &now, + End: &now, + } + + errs = validate.Struct(sv) + Equal(t, errs, nil) + + now3 := time.Now().UTC() + + sv = &Test{ + Start: &now, + End: &now3, + } + + errs = validate.Struct(sv) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.Start", "Test.Start", "Start", "Start", "eqfield") + + errs = validate.VarWithValue(nil, 1, "eqfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "eqfield") + + channel := make(chan string) + errs = validate.VarWithValue(5, channel, "eqfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "eqfield") + + errs = validate.VarWithValue(5, now, "eqfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "eqfield") + + type Test2 struct { + Start *time.Time `validate:"eqfield=NonExistantField"` + End *time.Time + } + + sv2 := &Test2{ + Start: &now, + End: &now, + } + + errs = validate.Struct(sv2) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test2.Start", "Test2.Start", "Start", "Start", "eqfield") + + type Inner struct { + Name string + } + + type TStruct struct { + Inner *Inner + CreatedAt *time.Time `validate:"eqfield=Inner"` + } + + inner := &Inner{ + Name: "NAME", + } + + test := &TStruct{ + Inner: inner, + CreatedAt: &now, + } + + errs = validate.Struct(test) + NotEqual(t, errs, nil) + AssertError(t, errs, "TStruct.CreatedAt", "TStruct.CreatedAt", "CreatedAt", "CreatedAt", "eqfield") +} + +func TestIsEqValidation(t *testing.T) { + + validate := New() + + var j uint64 + var k float64 + s := "abcd" + i := 1 + j = 1 + k = 1.543 + arr := []string{"test"} + now := time.Now().UTC() + + errs := validate.Var(s, "eq=abcd") + Equal(t, errs, nil) + + errs = validate.Var(i, "eq=1") + Equal(t, errs, nil) + + errs = validate.Var(j, "eq=1") + Equal(t, errs, nil) + + errs = validate.Var(k, "eq=1.543") + Equal(t, errs, nil) + + errs = validate.Var(arr, "eq=1") + Equal(t, errs, nil) + + errs = validate.Var(arr, "eq=2") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "eq") + + PanicMatches(t, func() { validate.Var(now, "eq=now") }, "Bad field type time.Time") +} + +func TestBase64Validation(t *testing.T) { + + validate := New() + + s := "dW5pY29ybg==" + + errs := validate.Var(s, "base64") + Equal(t, errs, nil) + + s = "dGhpIGlzIGEgdGVzdCBiYXNlNjQ=" + errs = validate.Var(s, "base64") + Equal(t, errs, nil) + + s = "" + errs = validate.Var(s, "base64") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "base64") + + s = "dW5pY29ybg== foo bar" + errs = validate.Var(s, "base64") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "base64") +} + +func TestNoStructLevelValidation(t *testing.T) { + + type Inner struct { + Test string `validate:"len=5"` + } + + type Outer struct { + InnerStruct *Inner `validate:"required,nostructlevel"` + } + + outer := &Outer{ + InnerStruct: nil, + } + + validate := New() + + errs := validate.Struct(outer) + NotEqual(t, errs, nil) + AssertError(t, errs, "Outer.InnerStruct", "Outer.InnerStruct", "InnerStruct", "InnerStruct", "required") + + inner := &Inner{ + Test: "1234", + } + + outer = &Outer{ + InnerStruct: inner, + } + + errs = validate.Struct(outer) + Equal(t, errs, nil) +} + +func TestStructOnlyValidation(t *testing.T) { + + type Inner struct { + Test string `validate:"len=5"` + } + + type Outer struct { + InnerStruct *Inner `validate:"required,structonly"` + } + + outer := &Outer{ + InnerStruct: nil, + } + + validate := New() + + errs := validate.Struct(outer) + NotEqual(t, errs, nil) + AssertError(t, errs, "Outer.InnerStruct", "Outer.InnerStruct", "InnerStruct", "InnerStruct", "required") + + inner := &Inner{ + Test: "1234", + } + + outer = &Outer{ + InnerStruct: inner, + } + + errs = validate.Struct(outer) + Equal(t, errs, nil) + + // Address houses a users address information + type Address struct { + Street string `validate:"required"` + City string `validate:"required"` + Planet string `validate:"required"` + Phone string `validate:"required"` + } + + type User struct { + FirstName string `json:"fname"` + LastName string `json:"lname"` + Age uint8 `validate:"gte=0,lte=130"` + Email string `validate:"required,email"` + FavouriteColor string `validate:"hexcolor|rgb|rgba"` + Addresses []*Address `validate:"required"` // a person can have a home and cottage... + Address Address `validate:"structonly"` // a person can have a home and cottage... + } + + address := &Address{ + Street: "Eavesdown Docks", + Planet: "Persphone", + Phone: "none", + City: "Unknown", + } + + user := &User{ + FirstName: "", + LastName: "", + Age: 45, + Email: "Badger.Smith@gmail.com", + FavouriteColor: "#000", + Addresses: []*Address{address}, + Address: Address{ + // Street: "Eavesdown Docks", + Planet: "Persphone", + Phone: "none", + City: "Unknown", + }, + } + + errs = validate.Struct(user) + Equal(t, errs, nil) +} + +func TestGtField(t *testing.T) { + + validate := New() + + type TimeTest struct { + Start *time.Time `validate:"required,gt"` + End *time.Time `validate:"required,gt,gtfield=Start"` + } + + now := time.Now() + start := now.Add(time.Hour * 24) + end := start.Add(time.Hour * 24) + + timeTest := &TimeTest{ + Start: &start, + End: &end, + } + + errs := validate.Struct(timeTest) + Equal(t, errs, nil) + + timeTest = &TimeTest{ + Start: &end, + End: &start, + } + + errs = validate.Struct(timeTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "TimeTest.End", "TimeTest.End", "End", "End", "gtfield") + + errs = validate.VarWithValue(&end, &start, "gtfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(&start, &end, "gtfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtfield") + + errs = validate.VarWithValue(&end, &start, "gtfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(&timeTest, &end, "gtfield") + NotEqual(t, errs, nil) + + errs = validate.VarWithValue("test bigger", "test", "gtfield") + Equal(t, errs, nil) + + type IntTest struct { + Val1 int `validate:"required"` + Val2 int `validate:"required,gtfield=Val1"` + } + + intTest := &IntTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(intTest) + Equal(t, errs, nil) + + intTest = &IntTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(intTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "IntTest.Val2", "IntTest.Val2", "Val2", "Val2", "gtfield") + + errs = validate.VarWithValue(int(5), int(1), "gtfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(int(1), int(5), "gtfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtfield") + + type UIntTest struct { + Val1 uint `validate:"required"` + Val2 uint `validate:"required,gtfield=Val1"` + } + + uIntTest := &UIntTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(uIntTest) + Equal(t, errs, nil) + + uIntTest = &UIntTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(uIntTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "UIntTest.Val2", "UIntTest.Val2", "Val2", "Val2", "gtfield") + + errs = validate.VarWithValue(uint(5), uint(1), "gtfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(uint(1), uint(5), "gtfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtfield") + + type FloatTest struct { + Val1 float64 `validate:"required"` + Val2 float64 `validate:"required,gtfield=Val1"` + } + + floatTest := &FloatTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(floatTest) + Equal(t, errs, nil) + + floatTest = &FloatTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(floatTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "FloatTest.Val2", "FloatTest.Val2", "Val2", "Val2", "gtfield") + + errs = validate.VarWithValue(float32(5), float32(1), "gtfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(float32(1), float32(5), "gtfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtfield") + + errs = validate.VarWithValue(nil, 1, "gtfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtfield") + + errs = validate.VarWithValue(5, "T", "gtfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtfield") + + errs = validate.VarWithValue(5, start, "gtfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtfield") + + type TimeTest2 struct { + Start *time.Time `validate:"required"` + End *time.Time `validate:"required,gtfield=NonExistantField"` + } + + timeTest2 := &TimeTest2{ + Start: &start, + End: &end, + } + + errs = validate.Struct(timeTest2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TimeTest2.End", "TimeTest2.End", "End", "End", "gtfield") + + type Other struct { + Value string + } + + type Test struct { + Value Other + Time time.Time `validate:"gtfield=Value"` + } + + tst := Test{ + Value: Other{Value: "StringVal"}, + Time: end, + } + + errs = validate.Struct(tst) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.Time", "Test.Time", "Time", "Time", "gtfield") +} + +func TestLtField(t *testing.T) { + + validate := New() + + type TimeTest struct { + Start *time.Time `validate:"required,lt,ltfield=End"` + End *time.Time `validate:"required,lt"` + } + + now := time.Now() + start := now.Add(time.Hour * 24 * -1 * 2) + end := start.Add(time.Hour * 24) + + timeTest := &TimeTest{ + Start: &start, + End: &end, + } + + errs := validate.Struct(timeTest) + Equal(t, errs, nil) + + timeTest = &TimeTest{ + Start: &end, + End: &start, + } + + errs = validate.Struct(timeTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "TimeTest.Start", "TimeTest.Start", "Start", "Start", "ltfield") + + errs = validate.VarWithValue(&start, &end, "ltfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(&end, &start, "ltfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltfield") + + errs = validate.VarWithValue(&end, timeTest, "ltfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltfield") + + errs = validate.VarWithValue("tes", "test", "ltfield") + Equal(t, errs, nil) + + type IntTest struct { + Val1 int `validate:"required"` + Val2 int `validate:"required,ltfield=Val1"` + } + + intTest := &IntTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(intTest) + Equal(t, errs, nil) + + intTest = &IntTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(intTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "IntTest.Val2", "IntTest.Val2", "Val2", "Val2", "ltfield") + + errs = validate.VarWithValue(int(1), int(5), "ltfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(int(5), int(1), "ltfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltfield") + + type UIntTest struct { + Val1 uint `validate:"required"` + Val2 uint `validate:"required,ltfield=Val1"` + } + + uIntTest := &UIntTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(uIntTest) + Equal(t, errs, nil) + + uIntTest = &UIntTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(uIntTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "UIntTest.Val2", "UIntTest.Val2", "Val2", "Val2", "ltfield") + + errs = validate.VarWithValue(uint(1), uint(5), "ltfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(uint(5), uint(1), "ltfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltfield") + + type FloatTest struct { + Val1 float64 `validate:"required"` + Val2 float64 `validate:"required,ltfield=Val1"` + } + + floatTest := &FloatTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(floatTest) + Equal(t, errs, nil) + + floatTest = &FloatTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(floatTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "FloatTest.Val2", "FloatTest.Val2", "Val2", "Val2", "ltfield") + + errs = validate.VarWithValue(float32(1), float32(5), "ltfield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(float32(5), float32(1), "ltfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltfield") + + errs = validate.VarWithValue(nil, 5, "ltfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltfield") + + errs = validate.VarWithValue(1, "T", "ltfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltfield") + + errs = validate.VarWithValue(1, end, "ltfield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltfield") + + type TimeTest2 struct { + Start *time.Time `validate:"required"` + End *time.Time `validate:"required,ltfield=NonExistantField"` + } + + timeTest2 := &TimeTest2{ + Start: &end, + End: &start, + } + + errs = validate.Struct(timeTest2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TimeTest2.End", "TimeTest2.End", "End", "End", "ltfield") +} + +func TestLteField(t *testing.T) { + + validate := New() + + type TimeTest struct { + Start *time.Time `validate:"required,lte,ltefield=End"` + End *time.Time `validate:"required,lte"` + } + + now := time.Now() + start := now.Add(time.Hour * 24 * -1 * 2) + end := start.Add(time.Hour * 24) + + timeTest := &TimeTest{ + Start: &start, + End: &end, + } + + errs := validate.Struct(timeTest) + Equal(t, errs, nil) + + timeTest = &TimeTest{ + Start: &end, + End: &start, + } + + errs = validate.Struct(timeTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "TimeTest.Start", "TimeTest.Start", "Start", "Start", "ltefield") + + errs = validate.VarWithValue(&start, &end, "ltefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(&end, &start, "ltefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltefield") + + errs = validate.VarWithValue(&end, timeTest, "ltefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltefield") + + errs = validate.VarWithValue("tes", "test", "ltefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue("test", "test", "ltefield") + Equal(t, errs, nil) + + type IntTest struct { + Val1 int `validate:"required"` + Val2 int `validate:"required,ltefield=Val1"` + } + + intTest := &IntTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(intTest) + Equal(t, errs, nil) + + intTest = &IntTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(intTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "IntTest.Val2", "IntTest.Val2", "Val2", "Val2", "ltefield") + + errs = validate.VarWithValue(int(1), int(5), "ltefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(int(5), int(1), "ltefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltefield") + + type UIntTest struct { + Val1 uint `validate:"required"` + Val2 uint `validate:"required,ltefield=Val1"` + } + + uIntTest := &UIntTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(uIntTest) + Equal(t, errs, nil) + + uIntTest = &UIntTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(uIntTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "UIntTest.Val2", "UIntTest.Val2", "Val2", "Val2", "ltefield") + + errs = validate.VarWithValue(uint(1), uint(5), "ltefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(uint(5), uint(1), "ltefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltefield") + + type FloatTest struct { + Val1 float64 `validate:"required"` + Val2 float64 `validate:"required,ltefield=Val1"` + } + + floatTest := &FloatTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(floatTest) + Equal(t, errs, nil) + + floatTest = &FloatTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(floatTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "FloatTest.Val2", "FloatTest.Val2", "Val2", "Val2", "ltefield") + + errs = validate.VarWithValue(float32(1), float32(5), "ltefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(float32(5), float32(1), "ltefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltefield") + + errs = validate.VarWithValue(nil, 5, "ltefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltefield") + + errs = validate.VarWithValue(1, "T", "ltefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltefield") + + errs = validate.VarWithValue(1, end, "ltefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "ltefield") + + type TimeTest2 struct { + Start *time.Time `validate:"required"` + End *time.Time `validate:"required,ltefield=NonExistantField"` + } + + timeTest2 := &TimeTest2{ + Start: &end, + End: &start, + } + + errs = validate.Struct(timeTest2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TimeTest2.End", "TimeTest2.End", "End", "End", "ltefield") +} + +func TestGteField(t *testing.T) { + + validate := New() + + type TimeTest struct { + Start *time.Time `validate:"required,gte"` + End *time.Time `validate:"required,gte,gtefield=Start"` + } + + now := time.Now() + start := now.Add(time.Hour * 24) + end := start.Add(time.Hour * 24) + + timeTest := &TimeTest{ + Start: &start, + End: &end, + } + + errs := validate.Struct(timeTest) + Equal(t, errs, nil) + + timeTest = &TimeTest{ + Start: &end, + End: &start, + } + + errs = validate.Struct(timeTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "TimeTest.End", "TimeTest.End", "End", "End", "gtefield") + + errs = validate.VarWithValue(&end, &start, "gtefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(&start, &end, "gtefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtefield") + + errs = validate.VarWithValue(&start, timeTest, "gtefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtefield") + + errs = validate.VarWithValue("test", "test", "gtefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue("test bigger", "test", "gtefield") + Equal(t, errs, nil) + + type IntTest struct { + Val1 int `validate:"required"` + Val2 int `validate:"required,gtefield=Val1"` + } + + intTest := &IntTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(intTest) + Equal(t, errs, nil) + + intTest = &IntTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(intTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "IntTest.Val2", "IntTest.Val2", "Val2", "Val2", "gtefield") + + errs = validate.VarWithValue(int(5), int(1), "gtefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(int(1), int(5), "gtefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtefield") + + type UIntTest struct { + Val1 uint `validate:"required"` + Val2 uint `validate:"required,gtefield=Val1"` + } + + uIntTest := &UIntTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(uIntTest) + Equal(t, errs, nil) + + uIntTest = &UIntTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(uIntTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "UIntTest.Val2", "UIntTest.Val2", "Val2", "Val2", "gtefield") + + errs = validate.VarWithValue(uint(5), uint(1), "gtefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(uint(1), uint(5), "gtefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtefield") + + type FloatTest struct { + Val1 float64 `validate:"required"` + Val2 float64 `validate:"required,gtefield=Val1"` + } + + floatTest := &FloatTest{ + Val1: 1, + Val2: 5, + } + + errs = validate.Struct(floatTest) + Equal(t, errs, nil) + + floatTest = &FloatTest{ + Val1: 5, + Val2: 1, + } + + errs = validate.Struct(floatTest) + NotEqual(t, errs, nil) + AssertError(t, errs, "FloatTest.Val2", "FloatTest.Val2", "Val2", "Val2", "gtefield") + + errs = validate.VarWithValue(float32(5), float32(1), "gtefield") + Equal(t, errs, nil) + + errs = validate.VarWithValue(float32(1), float32(5), "gtefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtefield") + + errs = validate.VarWithValue(nil, 1, "gtefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtefield") + + errs = validate.VarWithValue(5, "T", "gtefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtefield") + + errs = validate.VarWithValue(5, start, "gtefield") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gtefield") + + type TimeTest2 struct { + Start *time.Time `validate:"required"` + End *time.Time `validate:"required,gtefield=NonExistantField"` + } + + timeTest2 := &TimeTest2{ + Start: &start, + End: &end, + } + + errs = validate.Struct(timeTest2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TimeTest2.End", "TimeTest2.End", "End", "End", "gtefield") +} + +func TestValidateByTagAndValue(t *testing.T) { + + validate := New() + + val := "test" + field := "test" + errs := validate.VarWithValue(val, field, "required") + Equal(t, errs, nil) + + fn := func(fl FieldLevel) bool { + + return fl.Parent().String() == fl.Field().String() + } + + validate.RegisterValidation("isequaltestfunc", fn) + + errs = validate.VarWithValue(val, field, "isequaltestfunc") + Equal(t, errs, nil) + + val = "unequal" + + errs = validate.VarWithValue(val, field, "isequaltestfunc") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "isequaltestfunc") +} + +func TestAddFunctions(t *testing.T) { + + fn := func(fl FieldLevel) bool { + + return true + } + + validate := New() + + errs := validate.RegisterValidation("new", fn) + Equal(t, errs, nil) + + errs = validate.RegisterValidation("", fn) + NotEqual(t, errs, nil) + + validate.RegisterValidation("new", nil) + NotEqual(t, errs, nil) + + errs = validate.RegisterValidation("new", fn) + Equal(t, errs, nil) + + PanicMatches(t, func() { validate.RegisterValidation("dive", fn) }, "Tag 'dive' either contains restricted characters or is the same as a restricted tag needed for normal operation") +} + +func TestChangeTag(t *testing.T) { + + validate := New() + validate.SetTagName("val") + + type Test struct { + Name string `val:"len=4"` + } + s := &Test{ + Name: "TEST", + } + + errs := validate.Struct(s) + Equal(t, errs, nil) + + s.Name = "" + + errs = validate.Struct(s) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.Name", "Test.Name", "Name", "Name", "len") +} + +func TestUnexposedStruct(t *testing.T) { + + validate := New() + + type Test struct { + Name string + unexposed struct { + A string `validate:"required"` + } + } + + s := &Test{ + Name: "TEST", + } + + errs := validate.Struct(s) + Equal(t, errs, nil) +} + +func TestBadParams(t *testing.T) { + + validate := New() + + i := 1 + errs := validate.Var(i, "-") + Equal(t, errs, nil) + + PanicMatches(t, func() { validate.Var(i, "len=a") }, "strconv.ParseInt: parsing \"a\": invalid syntax") + PanicMatches(t, func() { validate.Var(i, "len=a") }, "strconv.ParseInt: parsing \"a\": invalid syntax") + + var ui uint = 1 + PanicMatches(t, func() { validate.Var(ui, "len=a") }, "strconv.ParseUint: parsing \"a\": invalid syntax") + + f := 1.23 + PanicMatches(t, func() { validate.Var(f, "len=a") }, "strconv.ParseFloat: parsing \"a\": invalid syntax") +} + +func TestLength(t *testing.T) { + + validate := New() + + i := true + PanicMatches(t, func() { validate.Var(i, "len") }, "Bad field type bool") +} + +func TestIsGt(t *testing.T) { + + validate := New() + + myMap := map[string]string{} + errs := validate.Var(myMap, "gt=0") + NotEqual(t, errs, nil) + + f := 1.23 + errs = validate.Var(f, "gt=5") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gt") + + var ui uint = 5 + errs = validate.Var(ui, "gt=10") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gt") + + i := true + PanicMatches(t, func() { validate.Var(i, "gt") }, "Bad field type bool") + + tm := time.Now().UTC() + tm = tm.Add(time.Hour * 24) + + errs = validate.Var(tm, "gt") + Equal(t, errs, nil) + + t2 := time.Now().UTC() + + errs = validate.Var(t2, "gt") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gt") + + type Test struct { + Now *time.Time `validate:"gt"` + } + s := &Test{ + Now: &tm, + } + + errs = validate.Struct(s) + Equal(t, errs, nil) + + s = &Test{ + Now: &t2, + } + + errs = validate.Struct(s) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.Now", "Test.Now", "Now", "Now", "gt") +} + +func TestIsGte(t *testing.T) { + + validate := New() + + i := true + PanicMatches(t, func() { validate.Var(i, "gte") }, "Bad field type bool") + + t1 := time.Now().UTC() + t1 = t1.Add(time.Hour * 24) + + errs := validate.Var(t1, "gte") + Equal(t, errs, nil) + + t2 := time.Now().UTC() + + errs = validate.Var(t2, "gte") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "gte") + + type Test struct { + Now *time.Time `validate:"gte"` + } + s := &Test{ + Now: &t1, + } + + errs = validate.Struct(s) + Equal(t, errs, nil) + + s = &Test{ + Now: &t2, + } + + errs = validate.Struct(s) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.Now", "Test.Now", "Now", "Now", "gte") +} + +func TestIsLt(t *testing.T) { + + validate := New() + + myMap := map[string]string{} + errs := validate.Var(myMap, "lt=0") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "lt") + + f := 1.23 + errs = validate.Var(f, "lt=0") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "lt") + + var ui uint = 5 + errs = validate.Var(ui, "lt=0") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "lt") + + i := true + PanicMatches(t, func() { validate.Var(i, "lt") }, "Bad field type bool") + + t1 := time.Now().UTC() + + errs = validate.Var(t1, "lt") + Equal(t, errs, nil) + + t2 := time.Now().UTC() + t2 = t2.Add(time.Hour * 24) + + errs = validate.Var(t2, "lt") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "lt") + + type Test struct { + Now *time.Time `validate:"lt"` + } + + s := &Test{ + Now: &t1, + } + + errs = validate.Struct(s) + Equal(t, errs, nil) + + s = &Test{ + Now: &t2, + } + + errs = validate.Struct(s) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.Now", "Test.Now", "Now", "Now", "lt") +} + +func TestIsLte(t *testing.T) { + + validate := New() + + i := true + PanicMatches(t, func() { validate.Var(i, "lte") }, "Bad field type bool") + + t1 := time.Now().UTC() + + errs := validate.Var(t1, "lte") + Equal(t, errs, nil) + + t2 := time.Now().UTC() + t2 = t2.Add(time.Hour * 24) + + errs = validate.Var(t2, "lte") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "lte") + + type Test struct { + Now *time.Time `validate:"lte"` + } + + s := &Test{ + Now: &t1, + } + + errs = validate.Struct(s) + Equal(t, errs, nil) + + s = &Test{ + Now: &t2, + } + + errs = validate.Struct(s) + NotEqual(t, errs, nil) +} + +func TestUrl(t *testing.T) { + + var tests = []struct { + param string + expected bool + }{ + {"http://foo.bar#com", true}, + {"http://foobar.com", true}, + {"https://foobar.com", true}, + {"foobar.com", false}, + {"http://foobar.coffee/", true}, + {"http://foobar.中文网/", true}, + {"http://foobar.org/", true}, + {"http://foobar.org:8080/", true}, + {"ftp://foobar.ru/", true}, + {"http://user:pass@www.foobar.com/", true}, + {"http://127.0.0.1/", true}, + {"http://duckduckgo.com/?q=%2F", true}, + {"http://localhost:3000/", true}, + {"http://foobar.com/?foo=bar#baz=qux", true}, + {"http://foobar.com?foo=bar", true}, + {"http://www.xn--froschgrn-x9a.net/", true}, + {"", false}, + {"xyz://foobar.com", true}, + {"invalid.", false}, + {".com", false}, + {"rtmp://foobar.com", true}, + {"http://www.foo_bar.com/", true}, + {"http://localhost:3000/", true}, + {"http://foobar.com/#baz", true}, + {"http://foobar.com#baz=qux", true}, + {"http://foobar.com/t$-_.+!*\\'(),", true}, + {"http://www.foobar.com/~foobar", true}, + {"http://www.-foobar.com/", true}, + {"http://www.foo---bar.com/", true}, + {"mailto:someone@example.com", true}, + {"irc://irc.server.org/channel", true}, + {"irc://#channel@network", true}, + {"/abs/test/dir", false}, + {"./rel/test/dir", false}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "url") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d URL failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d URL failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "url" { + t.Fatalf("Index: %d URL failed Error: %s", i, errs) + } + } + } + } + + i := 1 + PanicMatches(t, func() { validate.Var(i, "url") }, "Bad field type int") +} + +func TestUri(t *testing.T) { + + var tests = []struct { + param string + expected bool + }{ + {"http://foo.bar#com", true}, + {"http://foobar.com", true}, + {"https://foobar.com", true}, + {"foobar.com", false}, + {"http://foobar.coffee/", true}, + {"http://foobar.中文网/", true}, + {"http://foobar.org/", true}, + {"http://foobar.org:8080/", true}, + {"ftp://foobar.ru/", true}, + {"http://user:pass@www.foobar.com/", true}, + {"http://127.0.0.1/", true}, + {"http://duckduckgo.com/?q=%2F", true}, + {"http://localhost:3000/", true}, + {"http://foobar.com/?foo=bar#baz=qux", true}, + {"http://foobar.com?foo=bar", true}, + {"http://www.xn--froschgrn-x9a.net/", true}, + {"", false}, + {"xyz://foobar.com", true}, + {"invalid.", false}, + {".com", false}, + {"rtmp://foobar.com", true}, + {"http://www.foo_bar.com/", true}, + {"http://localhost:3000/", true}, + {"http://foobar.com#baz=qux", true}, + {"http://foobar.com/t$-_.+!*\\'(),", true}, + {"http://www.foobar.com/~foobar", true}, + {"http://www.-foobar.com/", true}, + {"http://www.foo---bar.com/", true}, + {"mailto:someone@example.com", true}, + {"irc://irc.server.org/channel", true}, + {"irc://#channel@network", true}, + {"/abs/test/dir", true}, + {"./rel/test/dir", false}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "uri") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d URI failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d URI failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "uri" { + t.Fatalf("Index: %d URI failed Error: %s", i, errs) + } + } + } + } + + i := 1 + PanicMatches(t, func() { validate.Var(i, "uri") }, "Bad field type int") +} + +func TestOrTag(t *testing.T) { + + validate := New() + + s := "rgba(0,31,255,0.5)" + errs := validate.Var(s, "rgb|rgba") + Equal(t, errs, nil) + + s = "rgba(0,31,255,0.5)" + errs = validate.Var(s, "rgb|rgba|len=18") + Equal(t, errs, nil) + + s = "this ain't right" + errs = validate.Var(s, "rgb|rgba") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgb|rgba") + + s = "this ain't right" + errs = validate.Var(s, "rgb|rgba|len=10") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgb|rgba|len=10") + + s = "this is right" + errs = validate.Var(s, "rgb|rgba|len=13") + Equal(t, errs, nil) + + s = "" + errs = validate.Var(s, "omitempty,rgb|rgba") + Equal(t, errs, nil) + + s = "this is right, but a blank or isn't" + + PanicMatches(t, func() { validate.Var(s, "rgb||len=13") }, "Invalid validation tag on field ''") + PanicMatches(t, func() { validate.Var(s, "rgb|rgbaa|len=13") }, "Undefined validation function 'rgbaa' on field ''") + + v2 := New() + v2.RegisterTagNameFunc(func(fld reflect.StructField) string { + + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + type Colors struct { + Fav string `validate:"rgb|rgba" json:"fc"` + } + + c := Colors{Fav: "this ain't right"} + + err := v2.Struct(c) + NotEqual(t, err, nil) + + errs = err.(ValidationErrors) + fe := getError(errs, "Colors.fc", "Colors.Fav") + NotEqual(t, fe, nil) +} + +func TestHsla(t *testing.T) { + + validate := New() + + s := "hsla(360,100%,100%,1)" + errs := validate.Var(s, "hsla") + Equal(t, errs, nil) + + s = "hsla(360,100%,100%,0.5)" + errs = validate.Var(s, "hsla") + Equal(t, errs, nil) + + s = "hsla(0,0%,0%, 0)" + errs = validate.Var(s, "hsla") + Equal(t, errs, nil) + + s = "hsl(361,100%,50%,1)" + errs = validate.Var(s, "hsla") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsla") + + s = "hsl(361,100%,50%)" + errs = validate.Var(s, "hsla") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsla") + + s = "hsla(361,100%,50%)" + errs = validate.Var(s, "hsla") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsla") + + s = "hsla(360,101%,50%)" + errs = validate.Var(s, "hsla") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsla") + + s = "hsla(360,100%,101%)" + errs = validate.Var(s, "hsla") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsla") + + i := 1 + validate.Var(i, "hsla") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsla") +} + +func TestHsl(t *testing.T) { + + validate := New() + + s := "hsl(360,100%,50%)" + errs := validate.Var(s, "hsl") + Equal(t, errs, nil) + + s = "hsl(0,0%,0%)" + errs = validate.Var(s, "hsl") + Equal(t, errs, nil) + + s = "hsl(361,100%,50%)" + errs = validate.Var(s, "hsl") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsl") + + s = "hsl(361,101%,50%)" + errs = validate.Var(s, "hsl") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsl") + + s = "hsl(361,100%,101%)" + errs = validate.Var(s, "hsl") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsl") + + s = "hsl(-10,100%,100%)" + errs = validate.Var(s, "hsl") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsl") + + i := 1 + errs = validate.Var(i, "hsl") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hsl") +} + +func TestRgba(t *testing.T) { + + validate := New() + + s := "rgba(0,31,255,0.5)" + errs := validate.Var(s, "rgba") + Equal(t, errs, nil) + + s = "rgba(0,31,255,0.12)" + errs = validate.Var(s, "rgba") + Equal(t, errs, nil) + + s = "rgba(12%,55%,100%,0.12)" + errs = validate.Var(s, "rgba") + Equal(t, errs, nil) + + s = "rgba( 0, 31, 255, 0.5)" + errs = validate.Var(s, "rgba") + Equal(t, errs, nil) + + s = "rgba(12%,55,100%,0.12)" + errs = validate.Var(s, "rgba") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgba") + + s = "rgb(0, 31, 255)" + errs = validate.Var(s, "rgba") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgba") + + s = "rgb(1,349,275,0.5)" + errs = validate.Var(s, "rgba") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgba") + + s = "rgb(01,31,255,0.5)" + errs = validate.Var(s, "rgba") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgba") + + i := 1 + errs = validate.Var(i, "rgba") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgba") +} + +func TestRgb(t *testing.T) { + + validate := New() + + s := "rgb(0,31,255)" + errs := validate.Var(s, "rgb") + Equal(t, errs, nil) + + s = "rgb(0, 31, 255)" + errs = validate.Var(s, "rgb") + Equal(t, errs, nil) + + s = "rgb(10%, 50%, 100%)" + errs = validate.Var(s, "rgb") + Equal(t, errs, nil) + + s = "rgb(10%, 50%, 55)" + errs = validate.Var(s, "rgb") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgb") + + s = "rgb(1,349,275)" + errs = validate.Var(s, "rgb") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgb") + + s = "rgb(01,31,255)" + errs = validate.Var(s, "rgb") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgb") + + s = "rgba(0,31,255)" + errs = validate.Var(s, "rgb") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgb") + + i := 1 + errs = validate.Var(i, "rgb") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "rgb") +} + +func TestEmail(t *testing.T) { + + validate := New() + + s := "test@mail.com" + errs := validate.Var(s, "email") + Equal(t, errs, nil) + + s = "Dörte@Sörensen.example.com" + errs = validate.Var(s, "email") + Equal(t, errs, nil) + + s = "θσερ@εχαμπλε.ψομ" + errs = validate.Var(s, "email") + Equal(t, errs, nil) + + s = "юзер@екзампл.ком" + errs = validate.Var(s, "email") + Equal(t, errs, nil) + + s = "उपयोगकर्ता@उदाहरण.कॉम" + errs = validate.Var(s, "email") + Equal(t, errs, nil) + + s = "用户@例子.广告" + errs = validate.Var(s, "email") + Equal(t, errs, nil) + + s = "" + errs = validate.Var(s, "email") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "email") + + s = "test@email" + errs = validate.Var(s, "email") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "email") + + s = "test@email." + errs = validate.Var(s, "email") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "email") + + s = "@email.com" + errs = validate.Var(s, "email") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "email") + + i := true + errs = validate.Var(i, "email") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "email") +} + +func TestHexColor(t *testing.T) { + + validate := New() + + s := "#fff" + errs := validate.Var(s, "hexcolor") + Equal(t, errs, nil) + + s = "#c2c2c2" + errs = validate.Var(s, "hexcolor") + Equal(t, errs, nil) + + s = "fff" + errs = validate.Var(s, "hexcolor") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hexcolor") + + s = "fffFF" + errs = validate.Var(s, "hexcolor") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hexcolor") + + i := true + errs = validate.Var(i, "hexcolor") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hexcolor") +} + +func TestHexadecimal(t *testing.T) { + + validate := New() + + s := "ff0044" + errs := validate.Var(s, "hexadecimal") + Equal(t, errs, nil) + + s = "abcdefg" + errs = validate.Var(s, "hexadecimal") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hexadecimal") + + i := true + errs = validate.Var(i, "hexadecimal") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "hexadecimal") +} + +func TestNumber(t *testing.T) { + + validate := New() + + s := "1" + errs := validate.Var(s, "number") + Equal(t, errs, nil) + + s = "+1" + errs = validate.Var(s, "number") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "number") + + s = "-1" + errs = validate.Var(s, "number") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "number") + + s = "1.12" + errs = validate.Var(s, "number") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "number") + + s = "+1.12" + errs = validate.Var(s, "number") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "number") + + s = "-1.12" + errs = validate.Var(s, "number") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "number") + + s = "1." + errs = validate.Var(s, "number") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "number") + + s = "1.o" + errs = validate.Var(s, "number") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "number") + + i := 1 + errs = validate.Var(i, "number") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "number") +} + +func TestNumeric(t *testing.T) { + + validate := New() + + s := "1" + errs := validate.Var(s, "numeric") + Equal(t, errs, nil) + + s = "+1" + errs = validate.Var(s, "numeric") + Equal(t, errs, nil) + + s = "-1" + errs = validate.Var(s, "numeric") + Equal(t, errs, nil) + + s = "1.12" + errs = validate.Var(s, "numeric") + Equal(t, errs, nil) + + s = "+1.12" + errs = validate.Var(s, "numeric") + Equal(t, errs, nil) + + s = "-1.12" + errs = validate.Var(s, "numeric") + Equal(t, errs, nil) + + s = "1." + errs = validate.Var(s, "numeric") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "numeric") + + s = "1.o" + errs = validate.Var(s, "numeric") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "numeric") + + i := 1 + errs = validate.Var(i, "numeric") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "numeric") +} + +func TestAlphaNumeric(t *testing.T) { + + validate := New() + + s := "abcd123" + errs := validate.Var(s, "alphanum") + Equal(t, errs, nil) + + s = "abc!23" + errs = validate.Var(s, "alphanum") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "alphanum") + + errs = validate.Var(1, "alphanum") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "alphanum") +} + +func TestAlpha(t *testing.T) { + + validate := New() + + s := "abcd" + errs := validate.Var(s, "alpha") + Equal(t, errs, nil) + + s = "abc®" + errs = validate.Var(s, "alpha") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "alpha") + + s = "abc÷" + errs = validate.Var(s, "alpha") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "alpha") + + s = "abc1" + errs = validate.Var(s, "alpha") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "alpha") + + s = "this is a test string" + errs = validate.Var(s, "alpha") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "alpha") + + errs = validate.Var(1, "alpha") + NotEqual(t, errs, nil) + AssertError(t, errs, "", "", "", "", "alpha") + +} + +func TestStructStringValidation(t *testing.T) { + + validate := New() + + tSuccess := &TestString{ + Required: "Required", + Len: "length==10", + Min: "min=1", + Max: "1234567890", + MinMax: "12345", + Lt: "012345678", + Lte: "0123456789", + Gt: "01234567890", + Gte: "0123456789", + OmitEmpty: "", + Sub: &SubTest{ + Test: "1", + }, + SubIgnore: &SubTest{ + Test: "", + }, + Anonymous: struct { + A string `validate:"required"` + }{ + A: "1", + }, + Iface: &Impl{ + F: "123", + }, + } + + errs := validate.Struct(tSuccess) + Equal(t, errs, nil) + + tFail := &TestString{ + Required: "", + Len: "", + Min: "", + Max: "12345678901", + MinMax: "", + Lt: "0123456789", + Lte: "01234567890", + Gt: "1", + Gte: "1", + OmitEmpty: "12345678901", + Sub: &SubTest{ + Test: "", + }, + Anonymous: struct { + A string `validate:"required"` + }{ + A: "", + }, + Iface: &Impl{ + F: "12", + }, + } + + errs = validate.Struct(tFail) + + // Assert Top Level + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 13) + + // Assert Fields + AssertError(t, errs, "TestString.Required", "TestString.Required", "Required", "Required", "required") + AssertError(t, errs, "TestString.Len", "TestString.Len", "Len", "Len", "len") + AssertError(t, errs, "TestString.Min", "TestString.Min", "Min", "Min", "min") + AssertError(t, errs, "TestString.Max", "TestString.Max", "Max", "Max", "max") + AssertError(t, errs, "TestString.MinMax", "TestString.MinMax", "MinMax", "MinMax", "min") + AssertError(t, errs, "TestString.Lt", "TestString.Lt", "Lt", "Lt", "lt") + AssertError(t, errs, "TestString.Lte", "TestString.Lte", "Lte", "Lte", "lte") + AssertError(t, errs, "TestString.Gt", "TestString.Gt", "Gt", "Gt", "gt") + AssertError(t, errs, "TestString.Gte", "TestString.Gte", "Gte", "Gte", "gte") + AssertError(t, errs, "TestString.OmitEmpty", "TestString.OmitEmpty", "OmitEmpty", "OmitEmpty", "max") + + // Nested Struct Field Errs + AssertError(t, errs, "TestString.Anonymous.A", "TestString.Anonymous.A", "A", "A", "required") + AssertError(t, errs, "TestString.Sub.Test", "TestString.Sub.Test", "Test", "Test", "required") + AssertError(t, errs, "TestString.Iface.F", "TestString.Iface.F", "F", "F", "len") +} + +func TestStructInt32Validation(t *testing.T) { + + type TestInt32 struct { + Required int `validate:"required"` + Len int `validate:"len=10"` + Min int `validate:"min=1"` + Max int `validate:"max=10"` + MinMax int `validate:"min=1,max=10"` + Lt int `validate:"lt=10"` + Lte int `validate:"lte=10"` + Gt int `validate:"gt=10"` + Gte int `validate:"gte=10"` + OmitEmpty int `validate:"omitempty,min=1,max=10"` + } + + tSuccess := &TestInt32{ + Required: 1, + Len: 10, + Min: 1, + Max: 10, + MinMax: 5, + Lt: 9, + Lte: 10, + Gt: 11, + Gte: 10, + OmitEmpty: 0, + } + + validate := New() + errs := validate.Struct(tSuccess) + Equal(t, errs, nil) + + tFail := &TestInt32{ + Required: 0, + Len: 11, + Min: -1, + Max: 11, + MinMax: -1, + Lt: 10, + Lte: 11, + Gt: 10, + Gte: 9, + OmitEmpty: 11, + } + + errs = validate.Struct(tFail) + + // Assert Top Level + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 10) + + // Assert Fields + AssertError(t, errs, "TestInt32.Required", "TestInt32.Required", "Required", "Required", "required") + AssertError(t, errs, "TestInt32.Len", "TestInt32.Len", "Len", "Len", "len") + AssertError(t, errs, "TestInt32.Min", "TestInt32.Min", "Min", "Min", "min") + AssertError(t, errs, "TestInt32.Max", "TestInt32.Max", "Max", "Max", "max") + AssertError(t, errs, "TestInt32.MinMax", "TestInt32.MinMax", "MinMax", "MinMax", "min") + AssertError(t, errs, "TestInt32.Lt", "TestInt32.Lt", "Lt", "Lt", "lt") + AssertError(t, errs, "TestInt32.Lte", "TestInt32.Lte", "Lte", "Lte", "lte") + AssertError(t, errs, "TestInt32.Gt", "TestInt32.Gt", "Gt", "Gt", "gt") + AssertError(t, errs, "TestInt32.Gte", "TestInt32.Gte", "Gte", "Gte", "gte") + AssertError(t, errs, "TestInt32.OmitEmpty", "TestInt32.OmitEmpty", "OmitEmpty", "OmitEmpty", "max") +} + +func TestStructUint64Validation(t *testing.T) { + + validate := New() + + tSuccess := &TestUint64{ + Required: 1, + Len: 10, + Min: 1, + Max: 10, + MinMax: 5, + OmitEmpty: 0, + } + + errs := validate.Struct(tSuccess) + Equal(t, errs, nil) + + tFail := &TestUint64{ + Required: 0, + Len: 11, + Min: 0, + Max: 11, + MinMax: 0, + OmitEmpty: 11, + } + + errs = validate.Struct(tFail) + + // Assert Top Level + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 6) + + // Assert Fields + AssertError(t, errs, "TestUint64.Required", "TestUint64.Required", "Required", "Required", "required") + AssertError(t, errs, "TestUint64.Len", "TestUint64.Len", "Len", "Len", "len") + AssertError(t, errs, "TestUint64.Min", "TestUint64.Min", "Min", "Min", "min") + AssertError(t, errs, "TestUint64.Max", "TestUint64.Max", "Max", "Max", "max") + AssertError(t, errs, "TestUint64.MinMax", "TestUint64.MinMax", "MinMax", "MinMax", "min") + AssertError(t, errs, "TestUint64.OmitEmpty", "TestUint64.OmitEmpty", "OmitEmpty", "OmitEmpty", "max") +} + +func TestStructFloat64Validation(t *testing.T) { + + validate := New() + + tSuccess := &TestFloat64{ + Required: 1, + Len: 10, + Min: 1, + Max: 10, + MinMax: 5, + OmitEmpty: 0, + } + + errs := validate.Struct(tSuccess) + Equal(t, errs, nil) + + tFail := &TestFloat64{ + Required: 0, + Len: 11, + Min: 0, + Max: 11, + MinMax: 0, + OmitEmpty: 11, + } + + errs = validate.Struct(tFail) + + // Assert Top Level + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 6) + + // Assert Fields + AssertError(t, errs, "TestFloat64.Required", "TestFloat64.Required", "Required", "Required", "required") + AssertError(t, errs, "TestFloat64.Len", "TestFloat64.Len", "Len", "Len", "len") + AssertError(t, errs, "TestFloat64.Min", "TestFloat64.Min", "Min", "Min", "min") + AssertError(t, errs, "TestFloat64.Max", "TestFloat64.Max", "Max", "Max", "max") + AssertError(t, errs, "TestFloat64.MinMax", "TestFloat64.MinMax", "MinMax", "MinMax", "min") + AssertError(t, errs, "TestFloat64.OmitEmpty", "TestFloat64.OmitEmpty", "OmitEmpty", "OmitEmpty", "max") +} + +func TestStructSliceValidation(t *testing.T) { + + validate := New() + + tSuccess := &TestSlice{ + Required: []int{1}, + Len: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + Min: []int{1, 2}, + Max: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}, + MinMax: []int{1, 2, 3, 4, 5}, + OmitEmpty: nil, + } + + errs := validate.Struct(tSuccess) + Equal(t, errs, nil) + + tFail := &TestSlice{ + Required: nil, + Len: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1}, + Min: []int{}, + Max: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1}, + MinMax: []int{}, + OmitEmpty: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1}, + } + + errs = validate.Struct(tFail) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 6) + + // Assert Field Errors + AssertError(t, errs, "TestSlice.Required", "TestSlice.Required", "Required", "Required", "required") + AssertError(t, errs, "TestSlice.Len", "TestSlice.Len", "Len", "Len", "len") + AssertError(t, errs, "TestSlice.Min", "TestSlice.Min", "Min", "Min", "min") + AssertError(t, errs, "TestSlice.Max", "TestSlice.Max", "Max", "Max", "max") + AssertError(t, errs, "TestSlice.MinMax", "TestSlice.MinMax", "MinMax", "MinMax", "min") + AssertError(t, errs, "TestSlice.OmitEmpty", "TestSlice.OmitEmpty", "OmitEmpty", "OmitEmpty", "max") + + fe := getError(errs, "TestSlice.Len", "TestSlice.Len") + NotEqual(t, fe, nil) + Equal(t, fe.Field(), "Len") + Equal(t, fe.StructField(), "Len") + Equal(t, fe.Namespace(), "TestSlice.Len") + Equal(t, fe.StructNamespace(), "TestSlice.Len") + Equal(t, fe.Tag(), "len") + Equal(t, fe.ActualTag(), "len") + Equal(t, fe.Param(), "10") + Equal(t, fe.Kind(), reflect.Slice) + Equal(t, fe.Type(), reflect.TypeOf([]int{})) + + _, ok := fe.Value().([]int) + Equal(t, ok, true) + +} + +func TestInvalidStruct(t *testing.T) { + + validate := New() + + s := &SubTest{ + Test: "1", + } + + err := validate.Struct(s.Test) + NotEqual(t, err, nil) + Equal(t, err.Error(), "validator: (nil string)") + + err = validate.Struct(nil) + NotEqual(t, err, nil) + Equal(t, err.Error(), "validator: (nil)") + + err = validate.StructPartial(nil, "SubTest.Test") + NotEqual(t, err, nil) + Equal(t, err.Error(), "validator: (nil)") + + err = validate.StructExcept(nil, "SubTest.Test") + NotEqual(t, err, nil) + Equal(t, err.Error(), "validator: (nil)") +} + +func TestInvalidValidatorFunction(t *testing.T) { + + validate := New() + + s := &SubTest{ + Test: "1", + } + + PanicMatches(t, func() { validate.Var(s.Test, "zzxxBadFunction") }, "Undefined validation function 'zzxxBadFunction' on field ''") +} + +func TestCustomFieldName(t *testing.T) { + + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("schema"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + type A struct { + B string `schema:"b" validate:"required"` + C string `schema:"c" validate:"required"` + D []bool `schema:"d" validate:"required"` + E string `schema:"-" validate:"required"` + } + + a := &A{} + + err := validate.Struct(a) + NotEqual(t, err, nil) + + errs := err.(ValidationErrors) + Equal(t, len(errs), 4) + Equal(t, getError(errs, "A.b", "A.B").Field(), "b") + Equal(t, getError(errs, "A.c", "A.C").Field(), "c") + Equal(t, getError(errs, "A.d", "A.D").Field(), "d") + Equal(t, getError(errs, "A.E", "A.E").Field(), "E") + + v2 := New() + err = v2.Struct(a) + NotEqual(t, err, nil) + + errs = err.(ValidationErrors) + Equal(t, len(errs), 4) + Equal(t, getError(errs, "A.B", "A.B").Field(), "B") + Equal(t, getError(errs, "A.C", "A.C").Field(), "C") + Equal(t, getError(errs, "A.D", "A.D").Field(), "D") + Equal(t, getError(errs, "A.E", "A.E").Field(), "E") +} + +func TestMutipleRecursiveExtractStructCache(t *testing.T) { + + validate := New() + + type Recursive struct { + Field *string `validate:"required,len=5,ne=string"` + } + + var test Recursive + + current := reflect.ValueOf(test) + name := "Recursive" + proceed := make(chan struct{}) + + sc := validate.extractStructCache(current, name) + ptr := fmt.Sprintf("%p", sc) + + for i := 0; i < 100; i++ { + + go func() { + <-proceed + sc := validate.extractStructCache(current, name) + Equal(t, ptr, fmt.Sprintf("%p", sc)) + }() + } + + close(proceed) +} + +// Thanks @robbrockbank, see https://github.com/go-playground/validator/issues/249 +func TestPointerAndOmitEmpty(t *testing.T) { + + validate := New() + + type Test struct { + MyInt *int `validate:"omitempty,gte=2,lte=255"` + } + + val1 := 0 + val2 := 256 + + t1 := Test{MyInt: &val1} // This should fail validation on gte because value is 0 + t2 := Test{MyInt: &val2} // This should fail validate on lte because value is 256 + t3 := Test{MyInt: nil} // This should succeed validation because pointer is nil + + errs := validate.Struct(t1) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.MyInt", "Test.MyInt", "MyInt", "MyInt", "gte") + + errs = validate.Struct(t2) + NotEqual(t, errs, nil) + AssertError(t, errs, "Test.MyInt", "Test.MyInt", "MyInt", "MyInt", "lte") + + errs = validate.Struct(t3) + Equal(t, errs, nil) + + type TestIface struct { + MyInt interface{} `validate:"omitempty,gte=2,lte=255"` + } + + ti1 := TestIface{MyInt: &val1} // This should fail validation on gte because value is 0 + ti2 := TestIface{MyInt: &val2} // This should fail validate on lte because value is 256 + ti3 := TestIface{MyInt: nil} // This should succeed validation because pointer is nil + + errs = validate.Struct(ti1) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestIface.MyInt", "TestIface.MyInt", "MyInt", "MyInt", "gte") + + errs = validate.Struct(ti2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestIface.MyInt", "TestIface.MyInt", "MyInt", "MyInt", "lte") + + errs = validate.Struct(ti3) + Equal(t, errs, nil) +} + +func TestRequired(t *testing.T) { + + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + type Test struct { + Value interface{} `validate:"required"` + } + + var test Test + + err := validate.Struct(test) + NotEqual(t, err, nil) + AssertError(t, err.(ValidationErrors), "Test.Value", "Test.Value", "Value", "Value", "required") +} + +func TestTranslations(t *testing.T) { + en := en.New() + uni := ut.New(en, en, fr.New()) + + trans, _ := uni.GetTranslator("en") + fr, _ := uni.GetTranslator("fr") + + validate := New() + err := validate.RegisterTranslation("required", trans, + func(ut ut.Translator) (err error) { + + // using this stype because multiple translation may have to be added for the full translation + if err = ut.Add("required", "{0} is a required field", false); err != nil { + return + } + + return + + }, func(ut ut.Translator, fe FieldError) string { + + t, err := ut.T(fe.Tag(), fe.Field()) + if err != nil { + fmt.Printf("warning: error translating FieldError: %#v", fe.(*fieldError)) + return fe.(*fieldError).Error() + } + + return t + }) + Equal(t, err, nil) + + err = validate.RegisterTranslation("required", fr, + func(ut ut.Translator) (err error) { + + // using this stype because multiple translation may have to be added for the full translation + if err = ut.Add("required", "{0} est un champ obligatoire", false); err != nil { + return + } + + return + + }, func(ut ut.Translator, fe FieldError) string { + + t, err := ut.T(fe.Tag(), fe.Field()) + if err != nil { + fmt.Printf("warning: error translating FieldError: %#v", fe.(*fieldError)) + return fe.(*fieldError).Error() + } + + return t + }) + + Equal(t, err, nil) + + type Test struct { + Value interface{} `validate:"required"` + } + + var test Test + + err = validate.Struct(test) + NotEqual(t, err, nil) + + errs := err.(ValidationErrors) + Equal(t, len(errs), 1) + + fe := errs[0] + Equal(t, fe.Tag(), "required") + Equal(t, fe.Namespace(), "Test.Value") + Equal(t, fe.Translate(trans), fmt.Sprintf("%s is a required field", fe.Field())) + Equal(t, fe.Translate(fr), fmt.Sprintf("%s est un champ obligatoire", fe.Field())) + + nl := nl.New() + uni2 := ut.New(nl, nl) + trans2, _ := uni2.GetTranslator("nl") + Equal(t, fe.Translate(trans2), "Key: 'Test.Value' Error:Field validation for 'Value' failed on the 'required' tag") + + terrs := errs.Translate(trans) + Equal(t, len(terrs), 1) + + v, ok := terrs["Test.Value"] + Equal(t, ok, true) + Equal(t, v, fmt.Sprintf("%s is a required field", fe.Field())) + + terrs = errs.Translate(fr) + Equal(t, len(terrs), 1) + + v, ok = terrs["Test.Value"] + Equal(t, ok, true) + Equal(t, v, fmt.Sprintf("%s est un champ obligatoire", fe.Field())) + + type Test2 struct { + Value string `validate:"gt=1"` + } + + var t2 Test2 + + err = validate.Struct(t2) + NotEqual(t, err, nil) + + errs = err.(ValidationErrors) + Equal(t, len(errs), 1) + + fe = errs[0] + Equal(t, fe.Tag(), "gt") + Equal(t, fe.Namespace(), "Test2.Value") + Equal(t, fe.Translate(trans), "Key: 'Test2.Value' Error:Field validation for 'Value' failed on the 'gt' tag") +} + +func TestTranslationErrors(t *testing.T) { + + en := en.New() + uni := ut.New(en, en, fr.New()) + + trans, _ := uni.GetTranslator("en") + trans.Add("required", "{0} is a required field", false) // using translator outside of validator also + + validate := New() + err := validate.RegisterTranslation("required", trans, + func(ut ut.Translator) (err error) { + + // using this stype because multiple translation may have to be added for the full translation + if err = ut.Add("required", "{0} is a required field", false); err != nil { + return + } + + return + + }, func(ut ut.Translator, fe FieldError) string { + + t, err := ut.T(fe.Tag(), fe.Field()) + if err != nil { + fmt.Printf("warning: error translating FieldError: %#v", fe.(*fieldError)) + return fe.(*fieldError).Error() + } + + return t + }) + + NotEqual(t, err, nil) + Equal(t, err.Error(), "error: conflicting key 'required' rule 'Unknown' with text '{0} is a required field' for locale 'en', value being ignored") +} + +func TestStructFiltered(t *testing.T) { + + p1 := func(ns []byte) bool { + if bytes.HasSuffix(ns, []byte("NoTag")) || bytes.HasSuffix(ns, []byte("Required")) { + return false + } + + return true + } + + p2 := func(ns []byte) bool { + if bytes.HasSuffix(ns, []byte("SubSlice[0].Test")) || + bytes.HasSuffix(ns, []byte("SubSlice[0]")) || + bytes.HasSuffix(ns, []byte("SubSlice")) || + bytes.HasSuffix(ns, []byte("Sub")) || + bytes.HasSuffix(ns, []byte("SubIgnore")) || + bytes.HasSuffix(ns, []byte("Anonymous")) || + bytes.HasSuffix(ns, []byte("Anonymous.A")) { + return false + } + + return true + } + + p3 := func(ns []byte) bool { + return !bytes.HasSuffix(ns, []byte("SubTest.Test")) + } + + // p4 := []string{ + // "A", + // } + + tPartial := &TestPartial{ + NoTag: "NoTag", + Required: "Required", + + SubSlice: []*SubTest{ + { + + Test: "Required", + }, + { + + Test: "Required", + }, + }, + + Sub: &SubTest{ + Test: "1", + }, + SubIgnore: &SubTest{ + Test: "", + }, + Anonymous: struct { + A string `validate:"required"` + ASubSlice []*SubTest `validate:"required,dive"` + SubAnonStruct []struct { + Test string `validate:"required"` + OtherTest string `validate:"required"` + } `validate:"required,dive"` + }{ + A: "1", + ASubSlice: []*SubTest{ + { + Test: "Required", + }, + { + Test: "Required", + }, + }, + + SubAnonStruct: []struct { + Test string `validate:"required"` + OtherTest string `validate:"required"` + }{ + {"Required", "RequiredOther"}, + {"Required", "RequiredOther"}, + }, + }, + } + + validate := New() + + // the following should all return no errors as everything is valid in + // the default state + errs := validate.StructFiltered(tPartial, p1) + Equal(t, errs, nil) + + errs = validate.StructFiltered(tPartial, p2) + Equal(t, errs, nil) + + // this isn't really a robust test, but is ment to illustrate the ANON CASE below + errs = validate.StructFiltered(tPartial.SubSlice[0], p3) + Equal(t, errs, nil) + + // mod tParial for required feild and re-test making sure invalid fields are NOT required: + tPartial.Required = "" + + // inversion and retesting Partial to generate failures: + errs = validate.StructFiltered(tPartial, p1) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.Required", "TestPartial.Required", "Required", "Required", "required") + + // reset Required field, and set nested struct + tPartial.Required = "Required" + tPartial.Anonymous.A = "" + + // will pass as unset feilds is not going to be tested + errs = validate.StructFiltered(tPartial, p1) + Equal(t, errs, nil) + + // will fail as unset feild is tested + errs = validate.StructFiltered(tPartial, p2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.Anonymous.A", "TestPartial.Anonymous.A", "A", "A", "required") + + // reset nested struct and unset struct in slice + tPartial.Anonymous.A = "Required" + tPartial.SubSlice[0].Test = "" + + // these will pass as unset item is NOT tested + errs = validate.StructFiltered(tPartial, p1) + Equal(t, errs, nil) + + errs = validate.StructFiltered(tPartial, p2) + NotEqual(t, errs, nil) + AssertError(t, errs, "TestPartial.SubSlice[0].Test", "TestPartial.SubSlice[0].Test", "Test", "Test", "required") + Equal(t, len(errs.(ValidationErrors)), 1) + + // Unset second slice member concurrently to test dive behavior: + tPartial.SubSlice[1].Test = "" + + errs = validate.StructFiltered(tPartial, p1) + Equal(t, errs, nil) + + errs = validate.StructFiltered(tPartial, p2) + NotEqual(t, errs, nil) + Equal(t, len(errs.(ValidationErrors)), 1) + AssertError(t, errs, "TestPartial.SubSlice[0].Test", "TestPartial.SubSlice[0].Test", "Test", "Test", "required") + + // reset struct in slice, and unset struct in slice in unset posistion + tPartial.SubSlice[0].Test = "Required" + + // these will pass as the unset item is NOT tested + errs = validate.StructFiltered(tPartial, p1) + Equal(t, errs, nil) + + errs = validate.StructFiltered(tPartial, p2) + Equal(t, errs, nil) + + tPartial.SubSlice[1].Test = "Required" + tPartial.Anonymous.SubAnonStruct[0].Test = "" + + // these will pass as the unset item is NOT tested + errs = validate.StructFiltered(tPartial, p1) + Equal(t, errs, nil) + + errs = validate.StructFiltered(tPartial, p2) + Equal(t, errs, nil) + + dt := time.Now() + err := validate.StructFiltered(&dt, func(ns []byte) bool { return true }) + NotEqual(t, err, nil) + Equal(t, err.Error(), "validator: (nil *time.Time)") +} + +func TestRequiredPtr(t *testing.T) { + + type Test struct { + Bool *bool `validate:"required"` + } + + validate := New() + + f := false + + test := Test{ + Bool: &f, + } + + err := validate.Struct(test) + Equal(t, err, nil) + + tr := true + + test.Bool = &tr + + err = validate.Struct(test) + Equal(t, err, nil) + + test.Bool = nil + + err = validate.Struct(test) + NotEqual(t, err, nil) + + errs, ok := err.(ValidationErrors) + Equal(t, ok, true) + Equal(t, len(errs), 1) + AssertError(t, errs, "Test.Bool", "Test.Bool", "Bool", "Bool", "required") + + type Test2 struct { + Bool bool `validate:"required"` + } + + var test2 Test2 + + err = validate.Struct(test2) + NotEqual(t, err, nil) + + errs, ok = err.(ValidationErrors) + Equal(t, ok, true) + Equal(t, len(errs), 1) + AssertError(t, errs, "Test2.Bool", "Test2.Bool", "Bool", "Bool", "required") + + test2.Bool = true + + err = validate.Struct(test2) + Equal(t, err, nil) + + type Test3 struct { + Arr []string `validate:"required"` + } + + var test3 Test3 + + err = validate.Struct(test3) + NotEqual(t, err, nil) + + errs, ok = err.(ValidationErrors) + Equal(t, ok, true) + Equal(t, len(errs), 1) + AssertError(t, errs, "Test3.Arr", "Test3.Arr", "Arr", "Arr", "required") + + test3.Arr = make([]string, 0) + + err = validate.Struct(test3) + Equal(t, err, nil) + + type Test4 struct { + Arr *[]string `validate:"required"` // I know I know pointer to array, just making sure validation works as expected... + } + + var test4 Test4 + + err = validate.Struct(test4) + NotEqual(t, err, nil) + + errs, ok = err.(ValidationErrors) + Equal(t, ok, true) + Equal(t, len(errs), 1) + AssertError(t, errs, "Test4.Arr", "Test4.Arr", "Arr", "Arr", "required") + + arr := make([]string, 0) + test4.Arr = &arr + + err = validate.Struct(test4) + Equal(t, err, nil) +} + +func TestAlphaUnicodeValidation(t *testing.T) { + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"abc", true}, + {"this is a test string", false}, + {"这是一个测试字符串", true}, + {"123", false}, + {"<>@;.-=", false}, + {"ひらがな・カタカナ、.漢字", false}, + {"あいうえおfoobar", true}, + {"test@example.com", false}, + {"1234abcDE", false}, + {"カタカナ", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "alphaunicode") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d Alpha Unicode failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d Alpha Unicode failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "alphaunicode" { + t.Fatalf("Index: %d Alpha Unicode failed Error: %s", i, errs) + } + } + } + } +} + +func TestAlphanumericUnicodeValidation(t *testing.T) { + + tests := []struct { + param string + expected bool + }{ + {"", false}, + {"abc", true}, + {"this is a test string", false}, + {"这是一个测试字符串", true}, + {"\u0031\u0032\u0033", true}, // unicode 5 + {"123", true}, + {"<>@;.-=", false}, + {"ひらがな・カタカナ、.漢字", false}, + {"あいうえおfoobar", true}, + {"test@example.com", false}, + {"1234abcDE", true}, + {"カタカナ", true}, + } + + validate := New() + + for i, test := range tests { + + errs := validate.Var(test.param, "alphanumunicode") + + if test.expected { + if !IsEqual(errs, nil) { + t.Fatalf("Index: %d Alphanum Unicode failed Error: %s", i, errs) + } + } else { + if IsEqual(errs, nil) { + t.Fatalf("Index: %d Alphanum Unicode failed Error: %s", i, errs) + } else { + val := getError(errs, "", "") + if val.Tag() != "alphanumunicode" { + t.Fatalf("Index: %d Alphanum Unicode failed Error: %s", i, errs) + } + } + } + } +} + +func TestArrayStructNamespace(t *testing.T) { + + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + type child struct { + Name string `json:"name" validate:"required"` + } + var input struct { + Children []child `json:"children" validate:"required,gt=0,dive"` + } + input.Children = []child{{"ok"}, {""}} + + errs := validate.Struct(input) + NotEqual(t, errs, nil) + + ve := errs.(ValidationErrors) + Equal(t, len(ve), 1) + AssertError(t, errs, "children[1].name", "Children[1].Name", "name", "Name", "required") +} + +func TestMapStructNamespace(t *testing.T) { + + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + + type child struct { + Name string `json:"name" validate:"required"` + } + var input struct { + Children map[int]child `json:"children" validate:"required,gt=0,dive"` + } + input.Children = map[int]child{ + 0: {Name: "ok"}, + 1: {Name: ""}, + } + + errs := validate.Struct(input) + NotEqual(t, errs, nil) + + ve := errs.(ValidationErrors) + Equal(t, len(ve), 1) + AssertError(t, errs, "children[1].name", "Children[1].Name", "name", "Name", "required") +} + +func TestFieldLevelName(t *testing.T) { + type Test struct { + String string `validate:"custom1" json:"json1"` + Array []string `validate:"dive,custom2" json:"json2"` + Map map[string]string `validate:"dive,custom3" json:"json3"` + Array2 []string `validate:"custom4" json:"json4"` + Map2 map[string]string `validate:"custom5" json:"json5"` + } + + var res1, res2, res3, res4, res5, alt1, alt2, alt3, alt4, alt5 string + validate := New() + validate.RegisterTagNameFunc(func(fld reflect.StructField) string { + name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0] + + if name == "-" { + return "" + } + + return name + }) + validate.RegisterValidation("custom1", func(fl FieldLevel) bool { + res1 = fl.FieldName() + alt1 = fl.StructFieldName() + return true + }) + validate.RegisterValidation("custom2", func(fl FieldLevel) bool { + res2 = fl.FieldName() + alt2 = fl.StructFieldName() + return true + }) + validate.RegisterValidation("custom3", func(fl FieldLevel) bool { + res3 = fl.FieldName() + alt3 = fl.StructFieldName() + return true + }) + validate.RegisterValidation("custom4", func(fl FieldLevel) bool { + res4 = fl.FieldName() + alt4 = fl.StructFieldName() + return true + }) + validate.RegisterValidation("custom5", func(fl FieldLevel) bool { + res5 = fl.FieldName() + alt5 = fl.StructFieldName() + return true + }) + + test := Test{ + String: "test", + Array: []string{"1"}, + Map: map[string]string{"test": "test"}, + } + + errs := validate.Struct(test) + Equal(t, errs, nil) + Equal(t, res1, "json1") + Equal(t, alt1, "String") + Equal(t, res2, "json2[0]") + Equal(t, alt2, "Array[0]") + Equal(t, res3, "json3[test]") + Equal(t, alt3, "Map[test]") + Equal(t, res4, "json4") + Equal(t, alt4, "Array2") + Equal(t, res5, "json5") + Equal(t, alt5, "Map2") +}